Blockchain — smart contract developer toolingKnowledge graph engineering & GraphRAG

An 11% benchmark lift on Solidity code generation from ontology work, not a bigger model

A dApp copilot beat the Claude 4-Sonnet baseline by 11.3% on SolEval — earned through a graph database migration, a hand-refined ontology and a deterministic post-processing pass.

Three stacked levers, none of them the model. Lever one is the backend: the live knowledge graph migrated to Memgraph, giving hybrid retrieval where a vector index finds the neighbourhood and Cypher expansion supplies the context, with a vendor-reported 120 times advantage in concurrent workloads and no paid compute or visualisation cost. Lever two is the ontology, refined by hand with human-in-the-loop review: IMPORTS consolidated from 2,043 to 7,399 instances, 11,571 generic CONTAIN edges specialised into typed relations, 247 unique edge types removed, leaving a smaller and more precise graph with 208 fewer nodes and 1,091 fewer edges while file size rose from 4.5 to 7.5 megabytes. Lever three is a deterministic post-processing refactoring pass that standardises headers and pragmas, strips non-Solidity artifacts, fixes compilation issues and conforms to the Forge test structure. Together they produce Pass@10 plus 11.3 percent, Pass@1 plus 11.2 percent and Compile@1 plus 10.4 percent against the Claude 4-Sonnet baseline.
The baseline was already a frontier model, so every remaining gain had to come from somewhere else.

Project snapshot

Client
A dApp co-pilot plugin for Solidity smart contract development, evaluated against the public SolEval benchmark
Industry
Blockchain infrastructure and developer tooling
Business function
AI-assisted code generation and testing
Challenge
Generated Solidity had to compile and pass tests, not merely look plausible. That required efficient retrieval over a large domain graph, an ontology precise enough to query against, and a way to turn raw model output into production-shaped test contracts.
Solution
The live graph moved to Memgraph, whose vector index drives semantic search before Cypher expands to subjects, objects, chunk texts and relationship types. The Solidity ontology was hand-refined with human-in-the-loop review — import edges consolidated, redundant property edges removed, generic CONTAIN edges specialised. Claude 3.5 Sonnet then runs as a refactoring agent producing SolEval-compliant contracts.
Result
Against the Claude 4-Sonnet baseline on SolEval: Pass@10 +11.3%, Pass@1 +11.2%, Compile@1 +10.4%, with consistent gains across all function complexity levels and strongest results on gas optimisation.

Key outcomes

+11.3%
Pass@10 on the SolEval benchmark
+10.4%
Compile@1 — code that builds first time
7,399
IMPORTS edges after consolidation
−247
Unique edge types removed

The client

A copilot judged by whether the code runs

dApp development has a harsher correctness bar than most code assistance. Solidity that looks right and does not compile is worthless. Solidity that compiles and fails its tests is worse than worthless, because someone has to find out why.

The copilot is measured on SolEval, a benchmark that actually runs the generated tests. There is no partial credit for plausible-looking output.

The challenge

The obvious lever had already been pulled

The naive path to a better copilot is a better model. That path was already taken — the baseline was a frontier model.

So the remaining gains had to come from three places that are not the model: retrieval efficiency over a large, dense domain graph fast enough for interactive use; ontology precision, because retrieval quality is bounded by how cleanly the graph can be queried; and output conformance, turning raw generation into something a test harness will accept.

Constraints

What we had to design around

  • CostPaid graph compute, storage, I/O and data-transfer fees, plus separate paid visualisation tooling, made iteration expensive on the incumbent stack — and iteration was the whole method.
  • ConcurrencyInteractive copilot use means concurrent queries, which is precisely where JVM-based graph databases degrade.
  • ConsistencyReal-time accuracy demands strong data consistency without hand-rolled locking protocols.
  • OntologyThe Solidity graph had accumulated redundant, overlapping and generically-typed edges. A graph you cannot query cleanly is a graph you cannot retrieve from cleanly.

Our approach

Fix the substrate before touching the model

Three changes, none of them a model swap. Each is individually unremarkable; the result comes from the fact that they compound.

Retrieval became hybrid: Memgraph’s vector index drives semantic search, then Cypher expands to subjects and objects, attaches chunk texts, and collects relationship types. Semantic search finds the neighbourhood; graph expansion supplies the context. Neither half works alone.

What the backend migration bought

120×
vendor-reported speed advantage in concurrent workloads — native C++ against JVM-based alternatives
$0
graph compute, storage, I/O and visualisation cost, on the free Community Edition

Snapshot isolation came out of the box, so strong consistency needed no manual locking protocol — and deployment stayed flexible across cloud, on-premise and hybrid.

The solution

A smaller graph that answers better

The ontology work is the part that generalises. Solidity KG v0.3 was refined by hand with human-in-the-loop feedback, and every change made the graph smaller.

A before-and-after of the Solidity knowledge graph ontology. Before: import-related edges fragmented across several relation names totalling 2,043 instances; 11,571 generic CONTAIN edges all meaning is-inside; redundant property edges such as HAS OPTION, NAME and HAS ATTRIBUTE; and USED-family edges with several spellings of one relation. After: a single standardised IMPORTS relation covering 7,399 instances; CONTAIN specialised into typed relations including LANGUAGE_CONTAINS_FEATURE and FILE_CONTAINS_SYMBOL; redundant property edges removed entirely; and USES standardised to one spelling and one meaning. Net result: 247 fewer unique edge types, 1,091 fewer edges, 208 fewer nodes, and file size rising from 4.5 to 7.5 megabytes as structured metadata replaced undifferentiated volume.
Every change removed something. The graph got smaller and the file got bigger — structured metadata replacing undifferentiated volume.

Edge consolidation. Import-related edges merged into one standardised IMPORTS relation, taking coverage from 2,043 to 7,399 instances. Property cleanup. Redundant edges — HAS OPTION, NAME, HAS ATTRIBUTE — removed entirely. Polarisation. USED-family edges standardised to USES.

And the largest single gain: CONTAIN specialisation. 11,571 generic CONTAIN edges split into LANGUAGE_CONTAINS_FEATURE, FILE_CONTAINS_SYMBOL, CONTRACT_CONTAINS_STORAGE and similar. One edge type that meant “is inside” became several that mean something specific enough to query.

4.5 → 7.5MBthe graph shrank by 208 nodes and 1,091 edges while the file grew — richer metadata on fewer, more meaningful relations

The last stage is a Claude 3.5 Sonnet refactoring agent turning raw API output into production-ready, SolEval-compliant test contracts:

  1. StandardiseSPDX headers, pragma statements and imports brought to one form.
  2. PurifyConverted to pure Solidity, stripping the non-Solidity artifacts a model tends to emit around the code.
  3. CompleteComprehensive test scenarios generated where the draft was thin.
  4. CompileSyntax corrections and type consistency fixes — the pass that moves Compile@1 most directly.
  5. ConformOutput shaped to the Forge test structure and assertion style the benchmark actually runs.

Responsible by design

The deterministic layer is the one that can be audited

Two of the three levers involve no model inference at all. The ontology is a versioned artifact a human reviewed edge type by edge type. The retrieval expansion is Cypher. Both are inspectable, diffable and reproducible in a way a prompt is not.

That matters for a benchmark result specifically. When a system beats a baseline, the useful question is which part of the system did it — and a gain that lives in deterministic code is a gain you can still explain a year later, after the model underneath has been replaced twice.

Results

Measured on SolEval against a frontier baseline

  • Pass@10 improved 11.3% over the Claude 4-Sonnet baseline, with Pass@1 up 11.2% — absolute improvements on the SolEval benchmark, which executes the generated tests rather than scoring them for plausibility.
  • Compile@1 improved 10.4%. This is the metric the deterministic post-processing pass targets, and the clearest evidence that the gain is not coming from the model.
  • Gains held across every function complexity bracket, including functions with five or more parameters — so the system handles complex dependency relationships, not just simple ones.
  • Gas optimisation showed the largest advantage of any domain, which is what curated, domain-specific knowledge buys you over general capability.
Pass rate by function complexity against the Claude 4-Sonnet baseline. Simple functions of one to two parameters: dApp 49.8 percent, baseline 39.2 percent, an improvement of 10.6 points. Medium functions of three to four parameters: dApp 43.1 percent, baseline 32.7 percent, an improvement of 10.4 points. Complex functions of five or more parameters: dApp 38.7 percent, baseline 27.3 percent, an improvement of 11.4 points. The complex bracket improves most, which is where dependency relationships are hardest.
The gain does not decay as functions get harder — the complex bracket improves most, which is the opposite of what a prompt-level trick would do.
Pass rate by contract domain against the same baseline. Security: dApp 48.6 percent, baseline 37.4 percent, an improvement of 11.2 points. Finance and DeFi: dApp 46.2 percent, baseline 34.9 percent, an improvement of 12.3 points. Gaming: dApp 48.7 percent, baseline 37.0 percent, an improvement of 11.7 points. Gas optimisation: dApp 57.1 percent, baseline 45.8 percent, an improvement of 11.3 points and the highest absolute pass rate of the four.
Gas optimisation reaches the highest absolute pass rate of any domain — that is curated assembly technique in the graph, not general capability.

Beyond the numbers

What generalises

Hybrid retrieval and ontology refinement compound. Memgraph supplies the efficient traversal engine; the refined ontology supplies data worth traversing. Neither alone produces the result.

Post-processing is not a detail. A deterministic refinement layer between raw generation and delivered artifact carries a large share of both Compile@1 and Pass@k. It is the cheapest place in the whole pipeline to buy accuracy.

Human review earned the ontology gains. Not automation — a person deciding, edge type by edge type, what a relation actually means.

One figure above is not ours: the 120× concurrency advantage is Memgraph’s own published claim about its product, quoted here because it drove the migration decision. The benchmark deltas are measured.

If your RAG system plateaued and a bigger model did not help

It is usually the retrieval layer, and usually the ontology underneath it. That is diagnosable against your own corpus before anyone commits to a rebuild.