Skip to content

Latest commit

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

maplib Skill — Benchmark Report

Date: 2026-04-17
Executor model: Claude Opus 4.6
Method: 3 test prompts, each run with and without the skill (6 runs total). Outputs graded programmatically against 8 assertions per test case (24 assertions total).

Summary

MetricWith skillWithout skillDelta
Pass rate100% (24/24)29% (7/24)+71 pp
Time20.9s19.7s+1.2s
Tokens30,47025,611+4,859

The skill's overhead is ~5k tokens and ~1 second per run — the cost of loading and following the skill context. In exchange, every baseline run hallucinated a nonexistent maplib API, while every with-skill run produced correct code.

Test cases

Eval 0 — DataFrame to knowledge graph + SPARQL query

Prompt: "I have a Polars DataFrame of employees with columns id, name, department, hire_date. Show me how to turn it into an RDF knowledge graph with maplib, then write a SPARQL query that returns everyone in the Engineering department hired after 2020-01-01."

AssertionWith skillBaseline
Imports Model from maplibpassfail
Uses correct Model() instantiationpassfail
Uses add_template methodpassfail
Uses map method (not expand)passfail
Uses query method on Modelpasspass
Does NOT fall back to rdflibpassfail
Does NOT invent fake maplib classespassfail
Uses OTTR template with ottr:Triplepassfail

Baseline failure mode: Invented Mapper, RDFStore, and Graph imports from maplib, then silently fell back to raw rdflib with manual triple construction in a for-loop.

Eval 1 — SHACL validation flow

Prompt: "I have an RDF graph of people with age values. Some entries have ages over 150 which are clearly wrong. Using maplib, show me how to write a SHACL shape that catches this, validate the graph, and print the violations."

AssertionWith skillBaseline
Imports Model from maplibpassfail
Uses add_template for data shapepassfail
Uses validate() methodpasspass
References report.conformspassfail
Calls report.results()passfail
Defines SHACL shape with sh:NodeShapepasspass
Uses sh:maxInclusive for age boundpasspass
Does NOT invent fake maplib classespassfail

Baseline failure mode: Invented maplib.KnowledgeGraph() with a .parse() method and a .validate() that returns a list of violation objects with .focus_node, .shape, .message attributes — none of which exist.

Eval 2 — Join two DataFrames in a knowledge graph

Prompt: "I have two Polars DataFrames: products (id, name, price) and reviews (product_id, score, reviewer). Using maplib, build a knowledge graph where reviews link to products, then write a SPARQL query to find products with an average review score above 4.0."

AssertionWith skillBaseline
Imports Model from maplibpassfail
Defines template for Productpassfail
Defines template for Reviewpassfail
Calls map twice (one per template)passfail
SPARQL uses AVG aggregatepasspass
SPARQL uses GROUP BYpasspass
SPARQL uses HAVING with > 4.0passpass
Does NOT invent fake maplib classespassfail

Baseline failure mode: Invented MapLibGraph and MapLibStore classes with an add_triple() method, manually iterating over DataFrame rows in a for-loop instead of using templates.

Assertions explained

Each test case was graded against 8 programmatic checks, divided into two categories:

Correct API usage — Does the generated code use the actual maplib API? This includes importing Model, calling add_template(), map(), query(), and validate() correctly. These assertions exist because LLMs without the skill consistently hallucinate plausible-sounding but nonexistent classes and methods.

Architectural correctness — Does the code follow maplib's template-based paradigm? This means using OTTR templates with ottr:Triple patterns, passing DataFrames through map() rather than iterating row-by-row, and using SPARQL for graph queries. The baselines consistently fell back to manual triple construction (rdflib-style for-loops), which defeats the purpose of maplib entirely.

Observations

The baselines are not just slightly wrong — they are fundamentally broken. Each one invents a different fantasy API (Mapper/RDFStore, KnowledgeGraph, MapLibGraph/MapLibStore), none of which exist in maplib. This is consistent with the fact that maplib is a relatively niche library and LLMs have limited training data on it.

The skill eliminates this problem completely. All three with-skill runs produce code that follows the canonical Modeladd_templatemapquery workflow, uses correct OTTR template syntax, and returns Polars DataFrames from SPARQL queries.

The only trade-off is ~5k additional tokens per invocation (the cost of loading the skill into context), which adds roughly 1 second of wall time. For a library where the baseline is 100% hallucinated APIs, this is a straightforward win.

About

LLM skill for writing correct maplib code. Covers the full API, OTTR templates, SPARQL patterns, and common gotchas so LLMs use the real Model → add_template → map → query workflow instead of hallucinating fake classes. Benchmarked at 100% correct API usage vs 29% without.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors