AI帮你写Python,安装只需5步,还能任你调教 | 开源
<div style="color: black; text-align: left; margin-bottom: 10px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">鱼羊 发自 凹非寺 </p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">量子位 <span style="color: black;">报告</span> | 公众号 QbitAI</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">一行一行地敲代码就像是徒手搬砖,聪明<span style="color: black;">的程序猿</span>们<span style="color: black;">暗示</span>:<span style="color: black;">咱们</span>要解放生产力!</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">例如</span>像<span style="color: black;">这般</span>:</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/40e77188806a408cb8af5681a7368522~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723893633&x-signature=adbg1mSIu59hbAIIE1gUXQJzCG4%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在<span style="color: black;">设备</span>学习的时代,AI智能补全代码早已不是梦想,<span style="color: black;">各样</span>IDE和插件都在<span style="color: black;">奋斗</span><span style="color: black;">帮忙</span>程序猿减少击键次数,延长键盘寿命(雾。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">有位来自斯里兰卡的<span style="color: black;">程序猿</span><span style="color: black;">亦</span>加入了关爱键盘协会,他尝试用简单的深度学习模型来实现自动补全Python代码这个<span style="color: black;">目的</span>,效果意外的不错。该项目现已<strong style="color: blue;">开源</strong>!</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">简单的模型<span style="color: black;">亦</span>强大</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">抱着实验的<span style="color: black;">心理</span>,在这个项目中,斯里兰卡小哥用到的只是一个简单的LSTM(Long Short-Term Memory)模型。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">用来进行预测的算法是集束搜索(beam search),这是一种启发式图搜索算法。在进行每一步深度扩展时,集束搜索仅<span style="color: black;">保存</span><span style="color: black;">有些</span>质量较高的节点,减少空间消耗,<span style="color: black;">加强</span>时间效率。采用集束搜索算法最多<span style="color: black;">能够</span>实现10个字符的预测。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">而投喂给模型的数据是标记化的Python代码,这些代码里的注释、字符串和空行事先清理掉了。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">训练效果是<span style="color: black;">这般</span>的:</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/935bfd853010405383105caef13012c6~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723893633&x-signature=lKdaKCNWGMHIgkDGnzNWWTrPUfs%3D" style="width: 50%; margin-bottom: 20px;"></div>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/8886ef8318fc460786e5e383bd163f94~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723893633&x-signature=89grXGj6ceQRoNwtPO8NYTGptRU%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">绿色的字母<span style="color: black;">便是</span>自动补全<span style="color: black;">起始</span>的位置,按下TAB键<span style="color: black;">选取</span>补全,高亮标注为灰色的部分<span style="color: black;">便是</span>AI<span style="color: black;">弥补</span>的代码。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">小哥<span style="color: black;">暗示</span>,如此简单的模型下,<span style="color: black;">运用</span>深度学习来自动补全Python代码,仍<span style="color: black;">能够</span>减少30-50%的击键次数,真的是surprise!</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在GitHub上,小哥<span style="color: black;">供给</span>了一个Python的解析器,而只要写一个其他语言的解析器,这个<span style="color: black;">方法</span>完全<span style="color: black;">能够</span>推广到其他语言上,实现Java自动补全,C自动补全等等。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">运用</span><span style="color: black;">办法</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">想要亲测一下效果?</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">没问题,只需五步,你就<span style="color: black;">能够</span>训练自己的自动补全模型。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/e6494a1ccbca4f12abd9ec1bbb3d3d2b~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723893633&x-signature=Wez3bcxGdRaAvpl4s%2FGCEz1qXRk%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1、安装进行<span style="color: black;">设备</span>学习的实验环境(<strong style="color: blue;">lab</strong>,<span style="color: black;">位置</span>见文末)。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2、将数据复制到 ./data/source。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3、运行 extract_code.py 来收集所有的python文件,编码并将其合并到 all.py。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4、运行 evaluate.py 对模型进行<span style="color: black;">评定</span>。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">5、运行 train.py 训练模型。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">仍需成长</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">办法</span>简单,效果还挺好,听上去这个项目<span style="color: black;">特别有</span><span style="color: black;">潜能</span>啊。<span style="color: black;">不外</span>理想很<span style="color: black;">饱满</span>,现实还是有点骨感的。这个新生的AI还是面临着许多成长挑战的。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">挑战一:效率太低</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">首要</span>是它的性能尚未能满足<span style="color: black;">实质</span><span style="color: black;">运用</span>的<span style="color: black;">必须</span>。<span style="color: black;">因为</span>编辑集成器的限制,集束搜索算法效率低下,有等它补全代码的时间,手动都<span style="color: black;">能够</span>敲好几行代码了。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">对此斯里兰卡小哥<span style="color: black;">暗示</span>,下一步<span style="color: black;">她们</span>会尝试用<span style="color: black;">区别</span>的架构来<span style="color: black;">加强</span>推理性能,<span style="color: black;">亦</span>欢迎<span style="color: black;">大众</span>向<span style="color: black;">她们</span>分享想法和<span style="color: black;">意见</span>。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">挑战二:<span style="color: black;">先辈</span>强大</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Reddit网友们还指出,用<span style="color: black;">设备</span>学习来补全代码这个想法早已有比较成功的实现<span style="color: black;">方法</span>,<span style="color: black;">例如</span><span style="color: black;">得到</span>了Trith Ventures投资的<strong style="color: blue;">Kite</strong>。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/da095acb15744db2aae0ebe232079886~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723893633&x-signature=lzqFNCgR7%2BQm7IRymLzbHRgVFlw%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">全世界</span>有超过3万名Python<span style="color: black;">研发</span>人员<span style="color: black;">运用</span>Kite,它被誉为当前最好用的Python自动补全工具。不仅能补全代码,Kite还能帮你跳过文档<span style="color: black;">认识</span>到别人是<span style="color: black;">怎样</span>实时<span style="color: black;">运用</span>函数的,<span style="color: black;">同期</span>,它<span style="color: black;">亦</span>能<span style="color: black;">供给</span>你的自定义代码库里的定义和用法。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">连Python之父都忍不住为Kite点赞:这可真够酷的。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/7d520c024cb942279687cb355895d65d~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723893633&x-signature=AZENWxBoyNpkWG2Ve5dAY9nEl3U%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">比起Kite这位<span style="color: black;">先辈</span>,小哥的这个项目还是非常稚嫩的,<span style="color: black;">不外</span>Kite并<span style="color: black;">无</span>开源,其<span style="color: black;">做为</span><span style="color: black;">弥补</span><span style="color: black;">运用</span>的云引擎<span style="color: black;">亦</span><span style="color: black;">导致</span>了<span style="color: black;">相关</span>安全性的质疑,有网友<span style="color: black;">暗示</span>:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">要是在工作上用了Kite,贵<span style="color: black;">机构</span>的法务<span style="color: black;">分部</span>怕不是要疯。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/212ec25321c8411fabf7622e47156c62~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723893633&x-signature=w6lQcxriejmrzMjC5bFpVFZdr2k%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">另外</span>,还有网友好奇AI跟Pycharm比起来又<span style="color: black;">怎样</span>?毕竟Pycharm的自动补全就<span style="color: black;">已然</span>挺好用了。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">传送门</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Github:https://github.com/vpj/python_autocomplete</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Lab:https://github.com/vpj/lab</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">— 完 —</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">诚挚招聘</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">量子位正在招募编辑/记者,工作地点在北京中关村。期待有才气、有热情的<span style="color: black;">朋友</span>加入<span style="color: black;">咱们</span>!<span style="color: black;">关联</span>细节,请在量子位公众号(QbitAI)对话界面,回复“招聘”两个字。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">量子位 QbitAI · 头条号签约作者</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">վᴗ ի <span style="color: black;">跟踪</span>AI技术和<span style="color: black;">制品</span>新动态</p>
</div>
回顾历史,我们感慨万千;放眼未来,我们信心百倍。 期待与你深入交流,共探知识的无穷魅力。 你的见解独到,让我受益匪浅,非常感谢。 祝福你、祝你幸福、早日实现等。 感谢你的精彩评论,带给我新的思考角度。 你说得对,我们一起加油,未来可期。 谷歌外链发布 http://www.fok120.com/
页:
[1]