LLMs Are Databases – So Query Them



What if the FFN weights in a transformer aren’t a black box — but a graph database you can query directly?

LARQL is a query language for transformer internals. DESCRIBE an entity. SELECT edges by relation. SHOW the relation types the model taught itself. INFER a prompt and watch the graph walk produce the answer.

No matrix multiply. The vindex format decomposes the FFN into gate and down vectors — edges in a graph. Inference is a KNN walk through those edges. Same outputs as dense matrix multiplication. Fewer bytes. Queryable structure.

Then: INSERT a new fact. Verify no regression. COMPILE to permanent weights.

One engine. One query language. 348,160 edges. The model is a database.

Built in Rust. Gemma 3 4B.

0:00 – Intro
00:47 – LARQL
01:50 – Entities – describing entities in the model
04:00 – Select – quering entities
07:46 – Features — How the model represents knowledge
12:31 – Relations — How entities relate to features
16:30 – The Dimensionality Gap — Why features aren’t enough
18:30 – INFER — It’s a graph walk
21:30 – INSERT — Writing new knowledge
24:30 – COMPILE — From graph to weights

Code: github.com/chrishayuk/larql
Gemma vindex: https://huggingface.co/datasets/chrishayuk/gemma-3-4b-it-vindex

source

Similar Posts