Code embedding models have become a key building block for many software engineering applications, yet their internal representations remain poorly understood. Existing evaluations tend to focus on downstream task performance, offering limited insight into whether a single embedding can support both functional abstraction and implementation-sensitive analysis. To address this gap, we present a large-scale empirical study of 14 state-of-the-art code embedding models. We evaluate their representational behavior through three complementary analyses: supervised probing for functional abstraction and implementation fidelity, zero-shot retrieval experiments to assess geometric similarity, and controlled perturbation experiments that measure embedding responses to semantics-preserving code transformations. The results reveal a consistent abstraction-fidelity tension: models that better preserve stylistic and structural signals tend to do so at the expense of semantic generalization, while models with similar retrieval performance can nevertheless respond very differently to the same implementation changes. Overall, our findings suggest that a single universal code representation remains out of reach, motivating more representation-aware evaluation, selection, and deployment of code embedding models in software engineering.
Figures & tables
RQ
Evaluation
Intent
RQ1
Algorithm-Tag Prediction
Measure recoverability of functional abstraction in frozen embeddings.
RQ1
Author Attribution
Measure recoverability of implementation fidelity in frozen embeddings.
RQ2
Cross-Language Functional Retrieval
Test whether code with the same problem tags is retrieved across languages.
RQ2
Cross-Task Author Retrieval
Test whether code by the same author is retrieved.
RQ3
Controlled Transformation Analysis
Measure how controlled implementation changes move embeddings.
TABLE I : Overview of our evaluations.
Category
Controlled change
Data and Declaration
Modify literals, initialization patterns, declarations, or value-preserving container forms.
Control Flow
Rewrite loops, branches, and condition structure while preserving the executed behavior.
Function
Restructure helper boundaries and abstraction structure while preserving the externally tested API.
Dead/Bogus Code
Insert semantically inert code such as unreachable branches or unused helpers.
Format & Rename
Modify lexical and layout cues such as local identifiers, whitespace, wrapping, and comments.
TABLE II : Controlled implementation transformations.
Fig. 1 : An example of implementation changes from our study. The original program’s for-loop was replaced by a while-loop.
TABLE III : Unified model pool. Models are grouped by official positioning and sorted by release year within each group. Parameter counts follow official documentation when available; a dash indicates no public parameter count.
Model
C++
Java
Python
Doubao-Large
0.542
0.505
0.518
CodeR
0.518
0.532
0.512
Voyage-Code-3
0.514
0.530
0.515
Qwen3-4B
0.490
0.512
0.488
Qwen3-8B
0.487
0.504
0.498
Jina-Code-1.5B
0.484
0.497
0.495
TABLE IV : Algorithm-tag prediction sample-F1 by language. Rows are sorted by the three-language average.
Model
C++
Java
Python
TE3-Large
0.988
0.977
0.978
Llama-Embed-8B
0.990
0.969
0.945
Ada-002
0.988
0.935
0.940
TE3-Small
0.968
0.962
0.926
BGE-M3
0.917
0.954
0.924
Doubao-Large
0.923
0.924
0.921
TABLE V : Author-attribution macro-F1 by language. Rows are sorted by the three-language average.
Fig. 2 : Same-problem versus same-author Hit@10 across the 14 models. Circles denote code-focused models, squares denote general-purpose models, the line is a linear fit.
Model
Functional
Author
CodeR
0.996
0.481
Qwen3-8B
0.991
0.323
Qwen3-4B
0.990
0.332
Voyage-Code-3
0.985
0.471
Jina-Code-1.5B
0.985
0.338
Qwen3-0.6B
0.942
0.413
TABLE VI : Hit@10 for cross-language retrieval. Functional retrieval ranks implementations in other languages; author retrieval ranks same-author implementations.
Data/Decl.
Control
Function
Dead/Bogus
Format/Rename
Model
low
med.
high
low
med.
high
low
med.
high
low
med.
high
low
med.
high
CodeR
1.717
4.601
10.209
1.460
3.344
7.282
4.227
7.838
15.403
4.123
10.032
22.136
3.262
5.926
12.204
Qwen3-8B
1.085
2.481
4.392
1.013
2.033
3.656
1.688
3.355
6.434
2.373
5.263
8.684
2.805
4.268
7.620
Qwen3-4B
1.090
2.392
4.168
0.995
2.039
3.479
1.725
3.465
6.416
2.086
4.919
10.526
3.134
4.589
7.407
Voyage-Code-3
0.605
1.704
3.794
0.558
1.390
2.853
0.959
2.321
5.370
1.733
3.881
8.935
1.572
2.413
5.080
Jina-Code-1.5B
1.706
5.181
10.053
1.269
3.121
6.888
2.617
6.426
14.370
3.942
11.361
27.248
2.670
4.063
9.306
TABLE VII : Scaled cosine distance from each original program to its test-passing transformed version, averaged over languages. low ( 0≤r≤0.33 ), med. ( 0.33<r≤0.66 ), and high ( r>0.66 ) denote transformation strength.
General-purpose code embeddings power tools for code search, classification, and retrieval. Compact transformer encoders for code typically rely on either human-written docstrings (labor-intensive and inconsistent) or mined structural signals such as execution traces (setting-specific and costly to collect). We empirically study an alternative: contrastive pretraining of small encoders with synthetically generated natural-language descriptions emphasizing code functionality and intent, paired with code in a dual-encoder framework at training and discarded at inference. We benchmark this approach against pretraining-based baselines, generalist LLMs, and embedding-specific models on eight retrieval, classification, and generation tasks across C, C++, and Java. Synthetic semantic supervision yields statistically significant gains over pretraining baselines of the same inference-time size on five of eight tasks, with parity on two more; once fine-tuned, it matches or exceeds zero-shot models two orders of magnitude larger on classification, and it stays on par with execution-aware supervision at matched pretraining data, suggesting a scalable, effective alternative to existing code-representation paradigms.
Kenneth Paulsen, Florian Tambon, Mike Papadakis +1
University of Luxembourg (SnT) · School of Computing, KAIST
Embedding-based code retrieval is a core component of coding agents and retrieval-augmented code generation, where retrieving correct code matters more than retrieving lexically similar code. Existing code-retrieval benchmarks do not plant controlled, execution-verified single-edit variants of each query's canonical implementation in the search pool, leaving the question of whether embeddings can functionally discriminate correct from near-clone-but-incorrect code unanswered in a retrieval setting. Resolving this requires a benchmark whose search pool itself contains the relevant counterfactuals -- execution-verified buggy variants near-identical to each canonical -- so that a retriever's rank ordering can be directly tested for functional discrimination rather than topical or identity overlap. We introduce ExecRetrieval, 939 Python tasks each paired with one execution-verified canonical implementation and up to four execution-verified buggy distractors, each generated by a mechanical mutation making a single targeted edit, and evaluate 23 dense embedding configurations plus BM25 under provider-native invocation with paired McNemar tests and query-level bootstrap intervals. With near-clone counterfactuals in the pool, the top hosted system reaches exec@10 = 1.00 but only exec@1 = 0.331; rank-1 misses are paired buggy variants 91.5-99.4% of the time across the four leading systems, and the canonical scores below at least one of its four paired distractors in 67-78% of queries on the leading systems. The full dataset, execution oracle, embedding matrices, environment snapshot, and pairwise statistical tests are released at the URL in Appendix D.
Function association is a useful process for binary reverse engineers. Search tools exist to perform association at scale, but they do not utilize the full range of capabilities that AI-enabled search provides. Prior work has explored the development of embedding models for association between certain reverse engineering code representations, but that work does not cover bidirectional association between source code and decompiled, stripped code with standard preprocessing requirements. To bridge this gap, we formalize this function association problem and evaluate the extent to which embedding models can bidirectionally associate between these two representations. To improve model performance at this task, we fine-tune a Qwen3-Embedding model with contrastive learning. We find that our new model outperforms other models on all function association baselines by a substantial margin and generalizes to a constant-algorithm association task it is not explicitly trained on.