Papers › code2vec: Learning Distributed Representations of Code

code2vec: Learning Distributed Representations of Code

26 Mar 2018arXiv:1803.09473archive 2025-07-28

Uri Alon, Meital Zilberstein, Omer Levy, Eran Yahav

We present a neural model for representing snippets of code as continuous distributed vectors ("code embeddings"). The main idea is to represent a code snippet as a single fixed-length code vector, which can be used to predict semantic properties of the snippet. This is performed by decomposing code to a collection of paths in its abstract syntax tree, and learning the atomic representation of each path simultaneously with learning how to aggregate a set of them. We demonstrate the effectiveness of our approach by using it to predict a method's name from the vector representation of its body. We evaluate our approach by training a model on a dataset of 14M methods. We show that code vectors trained on this dataset can predict method names from files that were completely unobserved during training. Furthermore, we show that our model learns useful method name vectors that capture semantic similarities, combinations, and analogies. Comparing previous techniques over the same data set, our approach obtains a relative improvement of over 75%, being the first to successfully predict method names based on a large, cross-project, corpus. Our trained model, visualizations and vector similarities are available as an interactive online demo at http://code2vec.org. The code, data, and trained models are available at https://github.com/tech-srl/code2vec.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="1803.09473")

Code

Syntology Ran 7 of 7 code samples harvested from 2 repositories linked to this paper; 0 have no recorded run. Of those that ran: 1 ran · violated contract; 3 ran · our draft was wrong; 3 ran · fixture could not drive it.

By repository: community (archive-listed): 7 samples from 2 repositories, 7 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

tech-srl/code2vec officialmentioned in papermentioned on GitHubtfMIT report
Asteur/code2vec mentioned on GitHubApache-2.0 report
LRNavin/AutoComments mentioned on GitHub report
TakutoYoshikai/code2vec mentioned on GitHubtf report
Vitaly-Protasov/DL_project_skoltech mentioned on GitHubpytorch report
kano1021/my-internship mentioned on GitHub report
src-d/code2vec mentioned on GitHubApache-2.0 report
tech-srl/adversarial-examples mentioned on GitHubtf report
vovak/astminer mentioned on GitHubMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

7 samples harvested; 7 ran; 0 honoured the contract we drafted; 0 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · violated contract
3ran · our draft was wrong
3ran · fixture could not drive it

Licence: 3 of the 7 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

adversary_by_prefix_random tech-srl/adversarial-examples/tf-gnn-samples/adversarial.py community (archive-listed) ran · fixture could not drive it fingerprinted MIT (permissive) · 9ab8f76e5ee9bc91 · report
construct_name_from_ints tech-srl/adversarial-examples/tf-gnn-samples/adversarial.py community (archive-listed) ran · fixture could not drive it MIT (permissive) · 4534c7d95faadccc · report
get_label_length tech-srl/adversarial-examples/tf-gnn-samples/adversarial.py community (archive-listed) ran · fixture could not drive it fingerprinted MIT (permissive) · 748bf8510e84bca3 · report
init_deadcode_variable tech-srl/adversarial-examples/code2vec/adversarialsearcher.py community (archive-listed) ran · our draft was wrong MIT (permissive) · d2024a1a569eaabf · report
is_equal_path_context TakutoYoshikai/code2vec/code2vec.py community (archive-listed) ran · violated contract fingerprinted no licence file found · pointer only · 9a14ad661cafefde · report
path_context TakutoYoshikai/code2vec/code2vec.py community (archive-listed) ran · our draft was wrong no licence file found · pointer only · 0380fb616d64670b · report
path_down TakutoYoshikai/code2vec/code2vec.py community (archive-listed) ran · our draft was wrong no licence file found · pointer only · b77f421883ace0b9 · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections