Arun | Software Developer
arrow_back BACK_TO_BLOG

2026.10.19 // AI SYSTEMS · GRAPHS

The Card Says Apache‑2.0. The Weights Say Llama.

Every open AI model ships with a licence on its model card, and almost nobody checks where the model actually came from. I built ModelBrain, a tool that reads the licence a model really inherited: through its family tree, and through its own weights. This is what was hard about it, and why a graph database turned out to be the only sane place to put the answer.

One line of code, one licence you never read

Somewhere right now, an engineer is adding a line like from_pretrained("some-org/some-model") to a product. Increasingly it isn't even an engineer: it's a coding agent picking a model because the benchmark looked good. Before that line ships, someone glances at the model card. It says apache-2.0. Use it for anything. Done.

Here's the problem. Most open models aren't original. They're fine-tunes of fine-tunes, quantised copies, merges of two parents, re-uploads with a fresh name. And the licence of the original model doesn't evaporate when someone uploads a derivative. The obligations travel with the weights. The card is just text a person typed, and it only describes the last hop.

A real example, live on Hugging Face as I write this. OPEA/Llama-3.2V-11B-cot-int4-sym-inc declares apache-2.0. It's a quantisation of Xkev/Llama-3.2V-11B-cot, which also declares apache-2.0. Xkev is a fine-tune of Meta's Llama 3.2 11B Vision, and Meta's licence for its multimodal Llama 3.2 models does not grant those rights to companies based in the EU. Two cards say "free for anyone". The root says a startup in Berlin can't ship it.

The card describes the last hop. The obligations come from the first one.

Nobody in that chain did anything sinister. Metadata drifts, people copy cards, fields get left blank. But the company at the end of the chain carries the risk, and the tools that check licences today read exactly one thing: the card. So I built ModelBrain to answer one question properly: can this company ship this model, in these countries, and who has to sign off?

Pain point one: the paperwork is wrong, or silent

The obvious approach is to follow the base_model field on each card up to the root. That works until it doesn't, and it stops working constantly. Re-uploads leave the field empty. Fine-tunes name a sibling instead of the real parent. Renamed repositories quietly redirect, so a lineage you crawled last week now points at an id that no longer exists.

How bad is it? Across the 381 models I fingerprinted, 169 have weights matching a parent their card never mentions, and 119 of those trace back to a licence with real conditions attached. One card says WTFPL, the "do what you want" licence; its sampled weights are identical to Meta's Llama 3.1 8B Instruct. Another, from a large company, names Llama 3.1 as its base, while its weights sit measurably closer to Llama 3. Many of these cards explain their history in prose. The machine-readable metadata, the part that scanners and agents actually read, doesn't.

If the paperwork can't be trusted, you need evidence that can't be typed in.

Pain point two: you can't download 16 GB to check

The evidence is in the weights. A fine-tune starts from its parent's numbers and moves them a little; an independently trained model of the same shape has numbers that look like noise next to it. So compare the weights. The catch: an 8B model is 16 GB, and I wanted to check hundreds of them from a laptop.

The trick is that safetensors files put a JSON header at the front that says exactly where every tensor lives, byte for byte. With HTTP range requests you can read that header, then read 512 values from an attention projection a quarter of the way into the network and 512 from an MLP projection further down. That's a 1,024-number fingerprint for about 2 KB of traffic, never the whole file. The same idea works for GGUF, the format people run in Ollama and LM Studio: parse the header, sample F16, BF16 or Q8_0 tensors, land in the same space.

The numbers separate cleanly. Fine-tunes against their parent typically score 0.98 to 0.9995 cosine similarity. Unrelated models with identical tensor shapes, such as Llama 3 8B and Mistral 7B, score about zero. To check that wasn't wishful thinking, I calibrated on 15 known parent/child pairs and 15 unrelated same-shape pairs: the lowest real pair was 0.648 (a heavily instruction-tuned Gemma against its base), the highest unrelated pair was −0.02, and there were zero false links at the thresholds the product uses.

Pain point three: family trees are messy

Real lineage isn't a tidy chain. Three things bit me hard.

Merges. Model merges blend two parents, so a child can owe obligations to both. I fit each candidate child as a least-squares mix of two parents, and a known 60/40 merge came back as 0.600 / 0.402. The first version also "found" merges everywhere among near-identical re-uploads, because any two copies of the same model explain each other perfectly. The fix was a rule: only accept a merge when the best single parent genuinely can't explain the weights, and a second parent removes almost all of what's left.

Cycles. Weight similarity is symmetric; ancestry isn't. At one point an inferred edge from a popular re-upload back to its own descendant closed a loop, and a "who is my ancestor" query started going in circles. Every write of an inferred edge now refuses to create a path back to itself, enforced inside the query.

Renames. Hugging Face answers a renamed repo with a redirect. My client didn't follow it, so whole branches of lineage silently vanished. Following redirects and merging aliases into one canonical node fixed a dozen models at once.

Pain point four: an answer you can't defend is worthless

A compliance tool that says "blocked, trust me" is useless to the lawyer who has to sign off, and dangerous in the hands of an agent. So every ModelBrain verdict carries three things: the path that produced it, the licence sentence quoted word for word from the official text with a link to the source, and the query that computed it. Quotes are never paraphrased and never stored in the repo; they're fetched from the official licence text at startup and matched by locator, so a changed licence text is caught rather than misquoted. A language model is allowed to phrase an explanation. It is never allowed to decide.

I tested the decisions on 160 frozen cases across an EU and a US company. ModelBrain never once said "allowed" where the answer was "blocked". Reading the card alone gets 27.5% right. Reviewing the disagreements honestly also caught a real bug: one model merged a parent licensed CC BY-NC-ND (non-commercial, no derivatives), and the product didn't know that licence existed yet, so it said "needs a person" instead of "blocked". The cheap answer would have been to change the label. The right one was to teach the product the licence.

Pain point five: the past keeps changing

Licences get fixed after the fact, and the fix almost never travels. On 9 July 2025 someone opened a discussion asking Xkev/Llama-3.2V-11B-cot about its licence. 130 days later the author uploaded Meta's licence file. The card still says apache-2.0, and none of its nine children picked up the change.

So ModelBrain doesn't just answer; it remembers what each answer rested on. Every company decision is an append-only ruling linked to the exact facts it used. When an upstream model changes, a reverse traversal finds every descendant, reopens every ruling that rested on any of them, and opens a review task for the person who owns that deployment. Approving the review writes a new ruling that supersedes the old one. Nothing is edited in place, so the history is the audit trail.

Pain point six: nobody will tell you what they use

The most useful evidence is a second opinion: another company that already verified "this model really comes from that one". But no company wants to publish which models it runs. So each company's decisions live in its own private graph, and when a company confirms a lineage edge, the shared graph receives only a salted hash. Two different hashes on the same edge raise its trust tier for everyone, and a cautious company's "cannot determine" becomes a real answer, without anyone learning who confirmed it.

Why FalkorDB was the right tool

Look back at those six problems and they're all the same shape: things connected to things, with the answer living in the connections. Models derive from models, licences impose clauses, rulings rest on facts, people own deployments, companies vouch for edges. The usual way to build this is a relational database, plus a vector store, plus a pile of glue code between them, and the glue always wins. FalkorDB let me skip the glue entirely. A few things stood out.

Vectors live inside the graph. This is the one that made the project possible. The weight fingerprints sit on the model nodes under a cosine vector index, so one Cypher statement goes from a fingerprint, to the nearest parent, to its trusted ancestry, to the licence clauses. No second database, no syncing ids between systems, no N+1 round trips. Here's the real query, lightly trimmed:

// weights → nearest parent → trusted ancestry → licence clauses
MATCH (c:Model {id: $id})
CALL db.idx.vector.queryNodes('Model', 'dna', $k, c.dna) YIELD node, score
WITH c, node, 1 - score AS sim
WHERE node <> c AND node.dna_sig = c.dna_sig AND sim >= $min_sim
WITH node, sim ORDER BY sim DESC LIMIT 1
MATCH p = (node)-[:DERIVED_FROM*0..6]->(a:Model)
WHERE all(r IN relationships(p) WHERE r.tier >= $min_tier)
MATCH (a)-[:DECLARES]->(l:License)
OPTIONAL MATCH (l)-[:IMPOSES]->(cl:Clause)
RETURN node.id AS parent, sim, [n IN nodes(p) | n.id] AS path,
       l.key AS licence, collect(DISTINCT cl.id) AS clauses

That returns in a few milliseconds. Read the WHERE all(...) line again: trust tiers live on the edges and are enforced inside the traversal, so a strict company that refuses inferred lineage gets that behaviour from the query itself, not from post-processing in application code.

Two kilobytes in, a defensible answer out. Everything in blue is a single FalkorDB query.

Many graphs, one instance. FalkorDB treats graphs as cheap, named things. ModelBrain runs a shared hub of public facts, one private graph per company, and a sandbox per website visitor, cloned from a demo company with GRAPH.COPY and thrown away two hours later. Per-tenant memory, isolation and a safe playground for strangers, with zero extra infrastructure.

Shared facts in one graph, private decisions in their own. The hub never learns who uses what.

Graph algorithms are just Cypher. Weakly connected components group re-uploads that share file fingerprints. PageRank surfaces the models whose permissive card hides a restrictive ancestor and that the most other models depend on. Betweenness finds the chokepoints, the single models where one licence fix would reach the most descendants. Label propagation finds families. Each is one CALL away, on the live graph, with no export to an analytics stack.

Operations that stay boring. One Docker image, with a browser UI for poking at the graph while you debug. When it was time to deploy, I seeded production by dumping the local graphs and restoring them on the server; the vector index came across intact, and a hub that took a long crawl to build was live in seconds.

The best test of whether a database is central or decorative is to turn it off. Stop FalkorDB and ModelBrain doesn't degrade into a worse answer: it returns a 503, because there is no answer without the graph. That's what I wanted. The graph isn't where the data is stored; it's where the reasoning happens.

Notes for the next person building on it

A few things I'd have liked to know on hour one:

  • db.idx.vector.queryNodes returns a cosine distance, so similarity is 1 - score. Obvious once you know it, very confusing before.
  • A vector of the wrong length is simply not indexed. Validate dimensions before you write, or a model quietly disappears from search.
  • vec.cosineDistance(a, b) works in plain Cypher for one-off comparisons, which made the calibration a pure graph job.
  • Keep variable-length paths bounded (*1..6) and run reads with the read-only query command; both keep latency flat as the graph grows.
  • For heavy pairwise analysis, pull per-node sets in one query and pair them in code rather than writing one giant pattern; the default query timeout is there to protect you.

The part that made it feel real: agents

Agents are where the graph really earns its keep. ModelBrain is also an MCP server. In a real Claude Code session, I asked it to add the OPEA model to a pipeline for a German product. Before touching any code, the agent called ModelBrain's can_i_use tool, got back BLOCKED with the path to Meta's licence and the clause, and declined to add the model. A GitHub Action runs the same check on every pull request.

That's the future I'm betting on: agents writing the line that downloads the model, and asking a graph first.

What's next

Fingerprints for mixture-of-experts and hybrid layouts, dequantising K-quant GGUF files so they join the vector index, Hub webhooks instead of polling, and an AI bill of materials exported straight from the graph. The core won't change: follow the family tree, check the weights, carry the rules down, remember why.

Cards can be wrong. Weights can't.

ModelBrain is live at web-production-8d8cb.up.railway.app, the code is at github.com/bytes-as/modelbrain, and the three-minute demo is on YouTube. It's automated screening, not legal advice; the examples describe public metadata, not anyone's intent.