Skip to main content
Back

Tsinghua's PriCoder Doubles Code Pass Rates Where RAG Consistently Fails

A graph-based data synthesis pipeline teaches code LLMs how to actually call internal APIs, delivering 20%+ pass@1 gains without hurting general coding.

Pro

  • PriCoder shows retrieval alone fails on private libraries: oracle API specs only lift LLaMa-70B pass@1 by 8.32 points.
  • The method synthesizes training data as a DAG, alternating diversity growth and quality pruning steps.
  • Pruning uses AST parsing, sandboxed unit test execution, and an LLM-as-a-judge functionality check.
  • Gains exceed 20 points in pass@1 across DeepSeek-Coder-6.7B, Qwen2.5-Coder-7B, and LLaMa3.1-8B.
  • HumanEval performance holds steady, unlike RAG baselines that lose 20-plus points on general coding.
  • Code and the NdonnxEval and NumbaEval benchmarks are open sourced at github.com/eniacode/PriCoder.

Retrieval augmented generation has become the default answer for pointing a code model at an in-house library it has never seen. Drop the API docs into the context, let the model read them, and hope it produces something that compiles. A new paper argues that this hope is misplaced, and proposes a training-based fix that consistently beats retrieval on two freshly built benchmarks.

The work, called PriCoder, comes from a team at Tsinghua, Nanjing University, Beihang, BIT, and Proxseer. Their claim is blunt: seeing an API specification is not the same as knowing how to invoke it, and the only reliable way to close that gap is to train the model on synthetic examples of the private library in action.

Reading the docs is not enough

The authors start with an experiment that undercuts the RAG-only assumption. They build an oracle setting where, for every task, the prompt contains the signatures and functional descriptions of exactly the APIs needed to solve it. This is the theoretical ceiling for any retrieval system.

The ceiling turns out to be low. On NumbaEval, oracle prompting only increases pass@1 from 10.59% to 17.97% for DeepSeek-Coder-6.7B-Instruct, and from 8.13% to 13.10% for LLaMa3.1-8B-Instruct, leaving most instances unsolved. Even when scaling up to the substantially larger LLaMa3.1-70B-Instruct, the pass@1 score also experiences a modest increase from 35.88% to 44.20%.

Digging into the failures, the authors find two recurring patterns: the model skips a required API even when it is described in the prompt, or it calls the API with the wrong number of arguments. In one example, the task needed ndonnx.asarray to convert an input before calling ndonnx.multiply, and the model simply ignored the conversion, producing a runtime type error.

Why naive synthesis breaks

If the fix is training, the next question is where the training data comes from. Real code that uses a closed-source library is scarce by definition, so the natural move is to ask an LLM to synthesize it. The authors tried this and it did not work well.

Two failure modes dominated their pilot on the ndonnx library: 84% of the synthesized samples invoke fewer than four APIs, meaning the tasks were trivially small compared to real usage, and 57% of the synthesized samples contain obvious runtime errors, often caused by invoking non-existent APIs or using existing APIs incorrectly. Fine-tuning on that mixture yielded less than a 10% pass@1 bump.

The graph-based synthesis loop

PriCoder reframes data synthesis as building a directed acyclic graph. Nodes are either API specifications or synthesized samples, and edges record which parent nodes produced each child. Two operators take turns growing and cleaning the graph.

The first, Progressive Graph Evolution, is the diversity engine. It starts from a random subset of API specs and asks the model to write a coding requirement plus reference solution that uses them. Once a pool of samples exists, later iterations combine several existing samples into a more complex one, forcing the model to coordinate multiple APIs in a single task. This is what closes the gap between the toy examples LLMs prefer to generate and the multi-API workflows real developers write.

The second, Multidimensional Graph Pruning, is the quality filter. Every candidate sample runs through three checks:

  • Syntactic verification. The reference solution is parsed with a standard AST parser. If it fails to parse, discard.
  • Execution verification. The LLM generates unit tests for the task, and the reference solution is run against them inside a sandbox. Any runtime error or failed assertion drops the sample.
  • Overall functionality verification. An LLM-as-a-judge step checks whether the requirement is realistic and whether the solution actually satisfies it.

Only samples that survive all three checks stay in the graph. The training set is then just the retained sample nodes, and the base model is fine-tuned on it with LoRA.

Two benchmarks the models have never seen

Because most public library benchmarks predate current model cutoffs, the authors built two new ones on libraries released in 2024 and still evolving. NdonnxEval targets ndonnx, a NumPy-like ONNX library, and NumbaEval targets numba-cuda. Five annotators with an average of four-plus years of programming experience spent more than 150 person-hours writing the instances.

BenchmarkInstancesAvg APIs per taskAvg tests per taskLibrary APIs
NdonnxEval1694.569.00179
NumbaEval1876.739.10725

The numbers

Across DeepSeek-Coder-6.7B, Qwen2.5-Coder-7B, and LLaMa3.1-8B, PriCoder produces double-digit gains where existing retrieval methods produce single digits. On NdonnxEval with Qwen-7B, PriCoder increases pass@1 from 23.37% to 47.99% and improves exec@1 from 28.52% to 55.86%. On NumbaEval with LLaMa-8B, PriCoder raises pass@5 from 21.73% to 40.84% and boosts exec@5 from 55.25% to 87.90%. By comparison, the strongest RAG baseline on the same Qwen-7B configuration lifts pass@1 by roughly five points.

Two other findings matter for anyone thinking about deployment:

  1. It composes with retrieval. Combining PriCoder with the Oracle prompting setting gives the best results in nearly every configuration, so a team can keep its existing RAG stack and still benefit.
  2. It does not damage general coding. On HumanEval, retrieval baselines cratered scores because they nudged the model to shove private-library calls into unrelated problems. PriCoder-trained models stayed within a point or two of the base score, and in some cases improved it slightly, which the authors attribute to the pruning step reinforcing correct syntax during fine-tuning.

Scaling, portability, and cost

The ablation studies confirm both operators are load-bearing: removing pruning collapses executability, removing evolution collapses pass rates. More interestingly, with only 1,000 synthesized training samples, pass@5 and exec@5 increase from 33.3% and 42.2% to 50.6% and 61.9%, respectively, meaning teams do not need to synthesize tens of thousands of examples before seeing a real bump.

The pipeline also survives swapping the synthesizer model. Training LLaMa-8B on data produced by Qwen-7B lands within a couple of points of training it on its own self-generated data, so a strong open model can bootstrap data once and then adapt weaker or newer models cheaply. The authors report that end-to-end synthesis and fine-tuning per target model completes in under 50 hours on eight A100s.

Availability

Code, the synthesis pipeline, and both benchmarks are open sourced at the PriCoder GitHub repository. The fine-tuning uses standard LoRA through LLaMA-Factory and vLLM for inference, so a team with an existing internal library, its API docs, and a small GPU budget can reproduce the recipe on its own codebase without waiting on a vendor.

The broader signal from this work is that the frontier of enterprise code generation is shifting from prompt engineering to targeted post-training. Retrieval will keep its place for freshness, but the paper is a clean demonstration that teaching a model how to call an API is a different problem from showing it the signature.