Skip to content

Code Embeddings Across 14 Models: Abstraction vs Implementation Fidelity

THE ARGUMENT

The paper's conclusion is that a single universal code representation remains out of reach: functional abstraction and implementation fidelity are consistently negatively correlated across 14 models (probing r = -0.473, retrieval r = -0.932), so selection has to fix the task axis first and read that axis's numbers, not one cross-task total [1].

On this page

You have a few-hundred-GB code repository and two features to ship: find similar code, and trace who wrote a snippet. A vendor's proposal says one general-purpose code embedding (a model that compresses each snippet into a fixed-length vector) covers both. Should you believe it? Most teams open a public retrieval leaderboard and pick the top overall score. This paper says that misses the thing that decides success. Across 14 SOTA embedding models tested on one shared suite, of which only 4 are code-specialized and the other 10 are general-purpose text models, the authors find a consistent tension between keeping how code is written and grouping code that does the same thing.

The Default Assumption: One Model for Every Workflow

The default judgment has real grounding. An embedding model here means a neural network trained to map code into continuous vectors, not the embedding layer inside a large language model. These models are trained to pull related code together and push unrelated code apart, rather than to optimize one downstream task. If a single training run can serve several pipelines, reuse saves compute and simplifies integration. Natural language processing already validated the pattern, and recent code models followed it.

The paper asks when that reuse assumption actually holds. It splits the question into three complementary analyses: what software information survives inside a frozen vector (probing), what governs geometric proximity in the latent space (zero-shot retrieval), and which implementation-level variations the model treats as irrelevant (controlled perturbation). All three rest on one premise. A vector is a compression, compression forces trade-offs, and those trade-offs are design choices rather than defects, but they have to be made visible [1].

Functional Abstraction and Implementation Fidelity, Measured Separately

Two terms need unpacking. Functional abstraction is the degree to which code that solves the same problem lands close together, even when language, syntax and structure differ. Implementation fidelity is how much information about how the program is written survives: naming conventions, formatting, idiomatic constructs, and how the code is decomposed and organized.

Probing works by freezing the model, so no parameters change, and training a very light prediction head on top of the emitted vectors. If that head predicts a label accurately, the information was already present in the vector.

Each axis gets one task. Functional abstraction uses Algorithm Tag Prediction, assigning labels such as dynamic programming, graph traversal or greedy algorithms. The authors concede that an algorithm tag is not full program semantics, but it is an observable signal that strategy-level concepts survive across implementations. Implementation fidelity uses Author Attribution, predicting who wrote a snippet. The justification is explicit: authorship leaks not through one syntactic feature but through naming habits, formatting preferences, decomposition patterns and recurring local choices, which makes it a good probe for residual surface detail.

Copying the numbers back shows the tension is not just a figure of speech [1]. In Table IV (algorithm-tag prediction, sample-F1), Doubao-Large leads on C++ / Python (0.542 / 0.518) and CodeR leads on Java (0.532), while BGE-M3 is lowest (0.356 / 0.348 / 0.395). In Table V (author attribution, macro-F1), TE3-Large is near-perfect in all three languages (0.988 / 0.977 / 0.978) and Llama-Embed-8B reaches 0.990 on C++, whereas Qwen3-4B drops to 0.417 on Python and Jina-Code-1.5B to 0.430 [1]. Across the 14 models, the Pearson correlation between the two axes' F1 scores is r = -0.473, split by language as C++ -0.392, Java -0.583 and Python -0.398, and the top-five models for the two tasks have no overlap at all in any language [1]. One more counter-intuitive point: Finding 1 states that code-specialized models do not uniformly dominate general-purpose embeddings, with Doubao-Large, TE3-Large and Llama-Embed-8B matching or beating code-focused models on these probes, so filtering by code-specialization alone does not hold [1].

Retrieval Geometry and Controlled Rewrites: Same Score, Different Reactions

Probing only shows that a prediction head can read a signal out. In deployment, many systems consume the geometry directly: whichever neighbors are closest get retrieved. The second experiment therefore runs zero-shot retrieval with no training at all, covering both functionality retrieval and authorship retrieval.

The third experiment applies semantics-preserving code transformations. Each rewrite alters one implementation characteristic while leaving program behavior intact, and the authors then measure how far the vector moves. A small displacement means the model absorbed that variation as noise; a large one means it still treats the difference as meaningful. Stacking displacements across transformations yields an invariance profile for each model.

This step explains the first two. Two models with similar retrieval scores need not share sensitivity to the same code rewrite, and the paper states plainly that models with comparable retrieval performance can respond very differently to identical implementation changes.

Retrieval makes the split larger [1]. Table VI reports Hit@10 for cross-language functional retrieval and author retrieval. A functional-specialist group (CodeR 0.996, Qwen3-8B 0.991, Qwen3-4B 0.990, Voyage-Code-3 0.985, Jina-Code-1.5B 0.985) scores only 0.323-0.481 on author retrieval, while an author-specialist group (BGE-M3 0.957, TE3-Small 0.952, E5-Base 0.935, Llama-Embed-8B 0.973, UniXcoder 0.888) scores only 0.126-0.184 on functional retrieval [1]. Across the 14 models the two retrieval Hit@10 values correlate at r = -0.932, much stronger than the -0.473 in probing [1]. The trend also shows within one model family: scaling Qwen3 embeddings from 0.6B to 4B and 8B raises functional retrieval Hit@10 from 0.942 to 0.991 while author retrieval falls from 0.413 to 0.323 [1].

Model (Table VI alias)Functional Hit@10Author Hit@10
CodeR (code-focused)0.9960.481
Qwen3-8B (general-purpose)0.9910.323
Voyage-Code-3 (code-focused)0.9850.471
Doubao-Large (general-purpose)0.8650.601
TE3-Large (general-purpose)0.5000.948
BGE-M3 (general-purpose)0.1840.957
UniXcoder (code-focused)0.1260.888

For controlled rewrites, the paper does not present a four-snippet teaching grid of same-function-different-style and same-style-different-function; it presents five semantics-preserving transformation families that change one implementation dimension at a time (Table II): Data & Declaration, Control Flow, Function, Dead/Bogus Code, and Format & Rename, with Figure 1 showing a for-loop replaced by a while-loop [1]. Rewrites are generated with GPT-5.4 xhigh and retained only if they pass 100 black-box tests, are independently verified by Claude Opus 4.5, and survive 20% manual inspection, leaving 1,500 test-passing pairs per language and 4,500 in total [1]. The displacement numbers in Table VII are reproducible: Control-Flow changes produce the smallest shifts (under high edit magnitude, Voyage-Code-3 2.853, Doubao-Large 2.804, Qwen3-8B 3.656), while Dead/Bogus and Function are the most disruptive (UniXcoder 45.312 and 37.139; Llama-Embed-8B 30.738 and 24.398); for Function rewrites the average displacement is 5.508 for the high-functional group versus 11.468 for the low-functional group [1]. The most selection-relevant point: models with comparable functional retrieval scores can have entirely different invariance profiles, with Voyage-Code-3 and the Qwen3 series relatively insensitive to most families while CodeR and Jina-Code-1.5B are substantially more sensitive to Function and Dead/Bogus rewrites [1]. That is exactly the check to run before treating two similar-scoring models as interchangeable.

The Finding: Abstraction and Fidelity Pull Against Each Other

Across all three analyses the same pattern appears, and the tension is measurable rather than just qualitative: on probing, the Pearson correlation between the two axes' F1 scores is r = -0.473, and on retrieval, functional versus author Hit@10 correlates at r = -0.932, both across the 14 models [1]. Models that better preserve stylistic and structural signals tend to pay for it in semantic generalization, and the reverse holds too. The authors' conclusion from this suite is that a single universal code representation remains out of reach; note this is their reading of these experiments, not a proof about all future models [1].

AnalysisQuestion askedWhat is observed
Supervised probingWhich software properties remain recoverable from frozen vectorsAlgorithm tag prediction on the functional axis, author attribution on the fidelity axis
Zero-shot retrievalWhat mainly determines geometric proximityNeighborhood structure for functionality retrieval and authorship retrieval
Controlled perturbationWhich implementation differences are treated as irrelevantVector displacement under semantics-preserving rewrites, i.e. the invariance profile

The evaluation setup should be stated as the paper writes it, without treating repository extras as primary evidence [1]. The main study spans 3 RQs and 5 evaluations (algorithm-tag prediction, author attribution, cross-language functional retrieval, cross-task author retrieval, controlled transformation analysis), on function-level code in C++, Java and Python. Data come from Open-R1 Codeforces (3,712 problems, 11,136 implementations), Google Code Jam (6,684 / 5,078 / 3,231 C++ / Java / Python implementations) and HumanEval-X (100 programs per language) [1]. The 14 models are 4 code-focused ones (UniXCoder, Voyage-Code-3, CodeR, Jina-Code-1.5B) plus 10 general-purpose text embeddings (Ada-002, E5-Base, BGE-M3, Doubao-Large, TE3-Large/Small, Llama-Embed-8B, Qwen3-Embedding 0.6B/4B/8B) [1]. The paper also releases an independently collected AtCoder corpus, and the repository adds preliminary CodeSearchNet and BigCloneBench results plus extra Pearson / bootstrap / Spearman uncertainty analyses. The authors label these as released material or preliminary results, not the primary evaluation corpora [1].

How to Use This When Buying or Selecting a Model

  • Do not decide on a cross-task total. In Table VI, functional and author retrieval Hit@10 correlate at r = -0.932, so averaging flattens both specialist groups [1].
  • Fix the axis first, then pick by that axis's numbers. Clone detection, cross-language functionality search and retrieval-augmented context selection use the functional column of Table VI; authorship tracing and style consistency checks use the author column [1].
  • Similar scores do not mean interchangeable models. In Table VI, Qwen3-8B (functional 0.991) and Voyage-Code-3 (0.985) are close on functional retrieval, yet in the perturbation study Voyage-Code-3 and the Qwen3 series stay relatively insensitive to most transformations while CodeR and Jina-Code-1.5B are substantially more sensitive to Function and Dead/Bogus rewrites. Measuring vector displacement on real renames, reformatting and refactors from your own repository is the cheap missing cell [1].
  • One model for two scenarios may not be thrift but a double compromise. The paper argues for representation-aware evaluation, selection and deployment, and Finding 1 states plainly that code-specialized embeddings do not uniformly dominate general-purpose ones, so filtering by code-specialization alone does not hold [1].

When This Approach Does Not Apply

  • Algorithm tags are strategy-level concepts, not full semantics; probing cannot recover meaning the tag vocabulary never covers.
  • Author attribution is one proxy for fidelity, and fidelity dimensions beyond naming and formatting, such as project-specific architectural conventions, are not modeled separately.
  • Perturbation covers only the five transformation families the designers selected (Data & Declaration, Control Flow, Function, Dead/Bogus Code, Format & Rename). Rewrites are LLM-generated and pass 100 black-box tests plus independent-model verification, and the paper concedes such rewrites may not fully represent edits made during real development [1].
  • The primary corpora are competitive-programming and code-generation datasets (Codeforces, GCJ, HumanEval-X), limited to function-level code in C++, Java and Python. In its threats to validity the paper states these may not fully reflect industrial software projects and calls for validation on large-scale industrial repositories [1]. AtCoder is only an extra corpus released with the repository, and CodeSearchNet / BigCloneBench are preliminary results; neither carries the same evidential weight as the main study [1].
  • The paper does not claim a contamination-free evaluation: pre-training exposure to public corpora cannot be ruled out, so it discloses source identities and model release years (Table III) instead [1].
  • This is a representation-level diagnosis and does not promise downstream metric gains from swapping models; 14 models do not guarantee generalization to future architectures either [1].

References

  1. Lost in the Latent Space: How Code Embeddings Represent Functional Intent and Implementation Fidelity

Sign in to Padda

A code in your inbox. No password to remember.

Connecting to sign-in…