当前位置:网站首页>【AI4Code】《Pythia: AI-assisted Code Completion System》(KDD 2019)
【AI4Code】《Pythia: AI-assisted Code Completion System》(KDD 2019)
2022-07-25 11:11:00 【chad_lee】
代码补全
补全属性/方法,在一个给定集合内推荐item,最简单的方法就是按字母排序,缺点是用户下拉菜单的时间可能要长于直接打代码的时间。用户可以多打几个前缀帮助补全。

基于模型的代码补全
- 基于抽象语法树(AST)——Pythia等
- 基于代码文本——Deep TabNine 、Galois等
数据:AST和代码文本
AST是源代码语法结构的一种抽象表示。它以树状的形式表现编程语言的语法结构,树上的每个节点都表示源代码中的一种结构。之所以说语法是“抽象”的,是因为这里的语法并不会表示出真实语法中出现的每个细节。比如,嵌套括号被隐含在树的结构中,并没有以节点的形式呈现;而类似于 if-condition-then 这样的条件跳转语句,可以使用带有三个分支的节点来表示。

一种是将代码解析为抽象语法树(AST),每个节点包括两个属性:type和value,所以每个节点需要两个embedding。然后使用深度优先遍历把AST的每个节点flatten成序列。
一种是直接将代码处理成文本,包含空格、换行符、缩进符等。
Pythia(KDD’19)
Pythia收集了Github上 Stars 前2700个Python项目的代码,一共包含了1600万个方法调用作为训练数据。

任务是给定一个长为 T T T的代码片段 C C C ,其中每个token为 c t c_t ct,以及一个特殊token “.”,预测token m ∗ m^{*} m∗。所以这个任务就是给定一个序列,根据这个序列的表征预测一个token,很适合用LSTM:
x t = L c t h t = f ( x t , h t − 1 ) P ( m ∣ C ) = y t = softmax ( W h t + b ) m ∗ = argmax ( P ( m ∣ C ) ) \begin{aligned} x_{t} &=L c_{t} \\ h_{t} &=f\left(x_{t}, h_{t-1}\right) \\ P(m \mid C) &=y_{t}=\operatorname{softmax}\left(W h_{t}+b\right) \\ m^{*} &=\operatorname{argmax}(P(m \mid C)) \end{aligned} xthtP(m∣C)m∗=Lct=f(xt,ht−1)=yt=softmax(Wht+b)=argmax(P(m∣C))
即在LSTM的输出后面接一个分类器。这里还用了tying embedding,LSTM的输出经过一个线性层后,直接和候选集里的token的embedding做内积,然后对内积结果做softmax。
Pythia已经作为VSCode的一个插件:

所以代码补全任务和session-based推荐任务和方法是相同的,不过代码补全任务的候选集更小。
DeepTabNine和Galois
这类方法和Pythia类似,只不过数据格式和模型与Pythia不同,在输入数据上用的是代码文本,模型用的是GPT(只有Transformer的Decoder,少一层Attention)而不是LSTM:

但是这两个方法是收费使用的插件,没有开源技术细节和论文。
边栏推荐
- php curl post Length Required 错误设置header头
- flink sql client 连接mysql报错异常,如何解决?
- JaveScript循环
- 【高并发】SimpleDateFormat类到底为啥不是线程安全的?(附六种解决方案,建议收藏)
- brpc源码解析(八)—— 基础类EventDispatcher详解
- 知识图谱用于推荐系统问题(MVIN,KERL,CKAN,KRED,GAEAT)
- JVM performance tuning methods
- 【6篇文章串讲ScalableGNN】围绕WWW 2022 best paper《PaSca》
- 【无标题】
- JS operator
猜你喜欢

【RS采样】A Gain-Tuning Dynamic Negative Sampler for Recommendation (WWW 2022)

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network

【GCN-RS】Region or Global? A Principle for Negative Sampling in Graph-based Recommendation (TKDE‘22)

OSPF综合实验

Functions in JS

Miidock Brief

【GCN多模态RS】《Pre-training Representations of Multi-modal Multi-query E-commerce Search》 KDD 2022

【GCN-CTR】DC-GNN: Decoupled GNN for Improving and Accelerating Large-Scale E-commerce Retrieval WWW22

dirReader. Readentries compatibility issues. Exception error domexception

【多模态】《TransRec: Learning Transferable Recommendation from Mixture-of-Modality Feedback》 Arxiv‘22
随机推荐
[high concurrency] Why is the simpledateformat class thread safe? (six solutions are attached, which are recommended for collection)
【GCN-CTR】DC-GNN: Decoupled GNN for Improving and Accelerating Large-Scale E-commerce Retrieval WWW22
brpc源码解析(七)—— worker基于ParkingLot的bthread调度
Power BI----这几个技能让报表更具“逼格“
toString()与new String()用法区别
JS data types and mutual conversion
一文入门Redis
A beautiful gift for girls from programmers, H5 cube, beautiful, exquisite, HD
W5500 upload temperature and humidity to onenet platform
[imx6ull notes] - a preliminary exploration of the underlying driver of the kernel
已解决 Files‘ name is invalid or does not exist (1205)
JS process control
php 一台服务器传图片到另一台上 curl post file_get_contents保存图片
Similarity matrix, diagonalization condition
JaveScript循环
Miidock Brief
There is no sound output problem in the headphone jack on the front panel of MSI motherboard [solved]
【多模态】《HiT: Hierarchical Transformer with Momentum Contrast for Video-Text Retrieval》ICCV 2021
【云驻共创】AI在数学界有哪些作用?未来对数学界会有哪些颠覆性影响?
JVM performance tuning methods