AI驱动的编码工具“CodeT5”来了:一种可以实时理解和生成代码的机器学习模型

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/95\/957a3531cf8c636c227a65760a4aba7b.webp","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"图片来源:https:\/\/blog.einstein.ai\/codet5\/"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"人工智能驱动的编码工具,使用机器学习算法来根据输入数据生成代码,吸引了越来越多的关注。理论上,这些系统可以减少编写代码所花费的时间以及计算和运维成本,并且输出最少的错误。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"然而,目前的编码预训练系统存在许多挑战。这些方法要么严重依赖一种类似 BERT 的编码器模型,要么严重依赖一种类似 GPT 的解码器模型。无论哪种方式,它都不是生成和理解任务的最优选项。例如,当用于代码摘要之类的任务时,CodeBERT 需要一个额外的解码器。除上述问题外,大多数现有方法都采用传统的 NLP 源代码预训练技术,将其视为自然语言(NL)中的标记序列。这在很大程度上忽视了编程语言中存在的丰富的结构信息,这对于充分理解其语义至关重要。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Salesforce 团队已经创建并开源了一种新的标识符感知统一预训练编码器 - 解码器模型,称为 CodeT5。到目前为止,他们已经在多个与代码相关的下游任务中展示了最先进的成果,例如跨多个方向的理解和生成,包括 PL 到 NL、NL 到 PL,以及从一种编程语言到另一种编程语言。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"CodeT5 构建在与谷歌的 T5(文本到文本传输转换器,Text-to-Text Transfer Transformer)框架类似的架构上,但具有更好的代码理解能力。它提出了自然语言处理任务的统一模型。它将文本重新格式化为文本,其中输入和输出都是文本字符串。这允许任何任务应用到这个模型。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/2f\/2f32758f8b02f121b1a9ab43f8410ab9.webp","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"图片来源:https:\/\/blog.einstein.ai\/codet5\/"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"CodeT5 的研究团队有 835 万多个例子可以用来训练人工智能,包括来自开源 GitHub 代码库的用户写的评论。在训练期间,拥有 2.2 亿个参数的 CodeT5 的最大、功能最强的版本,在 16 个 Nvidia A100 GPUs 和 40GB 内存的集群上花费了 12 天时间。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"CodeT5 在代码智能基准 CodeXGLUE [3] 中的 14 个子任务上实现了最先进的(SOTA)性能,如下表所示。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/23\/23d11b5bc0121aec2d623043b1ac4e04.webp","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"图片来源:https:\/\/blog.einstein.ai\/codet5\/"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在 CodeT5 的应用方面,Salesforce 团队计划使用它为 Apex 开发者构建一个人工智能驱动的编码助手。下面,你可以看到一个具有三种编码智能功能并由 CodeT5 支持的编码助手示例:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"文本到代码生成"},{"type":"text","text":":它可以根据自然语言描述生成代码"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"代码自动补全"},{"type":"text","text":":给定目标函数名,可以补全函数的完整代码"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"代码摘要"},{"type":"text","text":":它可以用自然语言描述生成一个函数的摘要"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"尽管 Salesforce 的 CodeT5 具有所有的优点和功能,但研究人员承认,它的一个主要缺点是,它可以从用于训练的数据集中的文本注释对种族或性别等刻板印象进行编码。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"论文链接:https:\/\/arxiv.org\/pdf\/2109.00859.pdf"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"代码链接:https:\/\/github.com\/salesforce\/CodeT5"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"来源链接:https:\/\/blog.einstein.ai\/codet5\/"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"作者介绍:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Asif Razzaq 是 Marketpost,LLC 的编辑和联合创始人。他是一名人工智能科技记者和数字健康业务战略家,拥有丰富的医疗设备和生物技术行业经验,在健康应用程序、人工智能和数据科学的开发方面拥有令人羡慕的投资组合。作为一名精明的企业家,Asif 成功地将初创企业从初创阶段发展为盈利企业,从而使自己成为一名杰出的初创企业专业管理人士。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"原文链接:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"https:\/\/www.marktechpost.com\/2021\/09\/08\/salesforce-open-sources-codet5-a-machine-learning-model-that-understands-and-generates-code-in-real-time"}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章