{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/code2vec-learning-distributed-representations","title":"code2vec: Learning Distributed Representations of Code","arxiv_id":"1803.09473","date":"2018-03-26","proceeding":null,"authors":["Uri Alon","Meital Zilberstein","Omer Levy","Eran Yahav"],"abstract":"We present a neural model for representing snippets of code as continuous\ndistributed vectors (\"code embeddings\"). The main idea is to represent a code\nsnippet as a single fixed-length $\\textit{code vector}$, which can be used to\npredict semantic properties of the snippet. This is performed by decomposing\ncode to a collection of paths in its abstract syntax tree, and learning the\natomic representation of each path $\\textit{simultaneously}$ with learning how\nto aggregate a set of them. We demonstrate the effectiveness of our approach by\nusing it to predict a method's name from the vector representation of its body.\nWe evaluate our approach by training a model on a dataset of 14M methods. We\nshow that code vectors trained on this dataset can predict method names from\nfiles that were completely unobserved during training. Furthermore, we show\nthat our model learns useful method name vectors that capture semantic\nsimilarities, combinations, and analogies. Comparing previous techniques over\nthe same data set, our approach obtains a relative improvement of over 75%,\nbeing the first to successfully predict method names based on a large,\ncross-project, corpus. Our trained model, visualizations and vector\nsimilarities are available as an interactive online demo at\nhttp://code2vec.org. The code, data, and trained models are available at\nhttps://github.com/tech-srl/code2vec.","url_abs":"http://arxiv.org/abs/1803.09473v5","url_pdf":"http://arxiv.org/pdf/1803.09473v5.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"code2vec-learning-distributed-representations","repo_url":"https://github.com/tech-srl/code2vec","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"tf","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"code2vec-learning-distributed-representations","repo_url":"https://github.com/Asteur/code2vec","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"code2vec-learning-distributed-representations","repo_url":"https://github.com/LRNavin/AutoComments","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}},{"paper_slug":"code2vec-learning-distributed-representations","repo_url":"https://github.com/TakutoYoshikai/code2vec","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":null},{"paper_slug":"code2vec-learning-distributed-representations","repo_url":"https://github.com/Vitaly-Protasov/DL_project_skoltech","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"code2vec-learning-distributed-representations","repo_url":"https://github.com/kano1021/my-internship","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}},{"paper_slug":"code2vec-learning-distributed-representations","repo_url":"https://github.com/src-d/code2vec","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"code2vec-learning-distributed-representations","repo_url":"https://github.com/tech-srl/adversarial-examples","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":null},{"paper_slug":"code2vec-learning-distributed-representations","repo_url":"https://github.com/vovak/astminer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1803.09473","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1803.09473"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Vitaly-Protasov/DL_project_skoltech","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Asteur/code2vec","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tech-srl/adversarial-examples","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tech-srl/code2vec","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/vovak/astminer","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/TakutoYoshikai/code2vec","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/kano1021/my-internship","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/src-d/code2vec","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/LRNavin/AutoComments","reach":{"status":"ok"}}],"summary":{"ran_fixture":3,"ran_draft_wrong":3,"ran_violates":1},"by_repo_kind":{"listed":{"samples":7,"ran":7,"repositories":2}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":3,"samples":[{"code_sha256_prefix":"9ab8f76e5ee9bc91","entry":"adversary_by_prefix_random","repo":"tech-srl/adversarial-examples","repo_kind":"listed","path":"tf-gnn-samples/adversarial.py","file_url":"https://github.com/tech-srl/adversarial-examples/blob/HEAD/tf-gnn-samples/adversarial.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9ab8f76e5ee9bc91"}},{"code_sha256_prefix":"4534c7d95faadccc","entry":"construct_name_from_ints","repo":"tech-srl/adversarial-examples","repo_kind":"listed","path":"tf-gnn-samples/adversarial.py","file_url":"https://github.com/tech-srl/adversarial-examples/blob/HEAD/tf-gnn-samples/adversarial.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4534c7d95faadccc"}},{"code_sha256_prefix":"748bf8510e84bca3","entry":"get_label_length","repo":"tech-srl/adversarial-examples","repo_kind":"listed","path":"tf-gnn-samples/adversarial.py","file_url":"https://github.com/tech-srl/adversarial-examples/blob/HEAD/tf-gnn-samples/adversarial.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"748bf8510e84bca3"}},{"code_sha256_prefix":"d2024a1a569eaabf","entry":"init_deadcode_variable","repo":"tech-srl/adversarial-examples","repo_kind":"listed","path":"code2vec/adversarialsearcher.py","file_url":"https://github.com/tech-srl/adversarial-examples/blob/HEAD/code2vec/adversarialsearcher.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d2024a1a569eaabf"}},{"code_sha256_prefix":"9a14ad661cafefde","entry":"is_equal_path_context","repo":"TakutoYoshikai/code2vec","repo_kind":"listed","path":"code2vec.py","file_url":"https://github.com/TakutoYoshikai/code2vec/blob/HEAD/code2vec.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9a14ad661cafefde"}},{"code_sha256_prefix":"0380fb616d64670b","entry":"path_context","repo":"TakutoYoshikai/code2vec","repo_kind":"listed","path":"code2vec.py","file_url":"https://github.com/TakutoYoshikai/code2vec/blob/HEAD/code2vec.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0380fb616d64670b"}},{"code_sha256_prefix":"b77f421883ace0b9","entry":"path_down","repo":"TakutoYoshikai/code2vec","repo_kind":"listed","path":"code2vec.py","file_url":"https://github.com/TakutoYoshikai/code2vec/blob/HEAD/code2vec.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b77f421883ace0b9"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}