Local Llama 3.1 8B with a Wikidata Graph Checks Facts Correctly 79% of the Time, Up from 17%
Without a source, Llama 3.1 8B is nearly useless at fact-checking: in 293 of 380 cases, it answered "insufficient data." The author connected it to a Wikidata graph stored in Neo4j, where facts are written as "Romania — capital — Bucharest," and the share of correct verdicts rose from 17.37% to 79.21%. Everything runs on a laptop with no external APIs, and the format of the facts had little effect. The takeaway: an accurate graph matters more than clever templates.
AI-processed from Habr AI; edited by Hamidun News
The open-weight Llama 3.1 8B from Meta, run locally, is poor at fact-checking: on a test set of 380 statements, it returned a correct verdict in only 17.37% of cases. Give it a reference of facts drawn from the Wikidata knowledge graph, and the share of correct verdicts (this is the "accuracy" in the author's tables) rises to 79.21%. The graph here is simply a database where each fact is stored as a short link of the form "who — relation — what," for example "Romania — capital — Bucharest." The author of the write-up on Habr showed that this approach works on a single laptop, without cloud APIs and without fine-tuning the model.
The problem: the model confidently gets things wrong
Ask a language model in what year Hermann von Helmholtz died, and it may answer 1894 or 1896, with the same confidence either way. The correct answer, 1894, is in Wikidata. For news verification, document analysis, or scientific work, that behavior is unacceptable.
Plain text RAG helps only sometimes. It retrieves paragraphs that are semantically similar to the query, but the needed fact may not be among them. If you need to verify a specific relation between two entities, such as a country and its capital, it is more reliable to pull the exact record from a structured database.
How the system works
The core is Llama 3.1 8B served through Ollama. The full Wikidata dump is about 133 GB, so the author filtered it in a single pass. What remained were records with Russian labels and 34 relation types: capital, citizenship, place of birth and death, occupation, educational institution, award, and similar. The resulting graph in Neo4j has 960,076 nodes and 2,680,098 edges.
For the statement "The capital of Romania is Budapest," simple heuristics identify the entities and the relation type. The system then pulls a small subgraph from Neo4j: Romania's capital is Bucharest, and Hungary's is Budapest. These facts go into the prompt, labeled as trustworthy, and the model chooses one of three verdicts: supported, refuted, or insufficient data. On top of the answer sits a compact MiniVerifier classifier with 5.4 million parameters, which is meant to stabilize the final decision. The material gives no separate figures for its contribution, so there is currently no way to assess its benefit.
What the measurements showed
The test set has 380 statements: 190 real facts from the graph and 190 fakes, in which the object is replaced with another entity of the same type. The model was run in four modes.
Without context, accuracy was 17.37%. The model did not invent answers; it refused to answer. Out of 380 statements, it wrote "insufficient information" 293 times, "supported" 61 times, and "refuted" only 26 times. Caution is better than confident fabrication, but for a verification system such refusals are useless.
With the graph, the picture changes: 79.21% accuracy with raw triplets, 77.63% with facts rewritten as ordinary sentences, and 77.37% with filtered sentences. The spread is under two percentage points. Response times are nearly identical, from 2.49 to 2.59 seconds per example. Filtering slightly shortens the prompt and yields a small speed gain.
The practical conclusion for those building RAG on graphs: there is no need to spend days humanizing triplets with templates. An eight-billion-parameter model understands short strings of the form "subject — relation — object" no worse than elaborate phrasing. Time is better spent on the quality of the graph itself and on selecting the right relations.
Honest limitations
The result should not be carried over one-to-one to real news. First, the test statements were generated from the same graph that serves as the source of truth. This makes the evaluation reproducible but considerably simplifies the task: the needed fact is guaranteed to be in the database. In real text it may be missing, recorded differently, or require linking several entities.
Second, graph search is limited to a single hop. A statement like "Einstein's teacher was born in Germany" would require traversal through an intermediate node, and the system has no such capability. Third, the statements are very simple: one subject, one relation, one object, with no dates or qualifications.
Finally, macro-F1 (the average precision across the three verdicts) stays around 57%, noticeably below overall accuracy. The author attributes this to errors on individual relation types. A sample of 20 examples per relation type is too small to judge specific predicates.
Why it matters
The value of this work is engineering: Ollama, Neo4j in Docker, and an 8-billion-parameter model run on one laptop, without paid APIs and without sending data outside. For internal checks, closed networks, and prototypes, that is enough. The jump in quality from 17% to 79% came not from a larger model or fine-tuning but from access to structured facts. The next step the author proposes is multi-hop graph traversal and handling dates. Those experiments will show whether the approach holds up against real texts.
- Nov 24, 2026Meta Launches Muse in Britain, a Personal AI Agent That Shops and Books on Your Behalf
- Nov 24, 2026A 180-Billion-Parameter Qwen Runs on Two RTX 5090s: 180 Tokens/s and Bug Hunting in 28 Minutes
- Nov 24, 2026Support Agent Hides Names and Card Numbers from an External LLM: 30+ Data Types
- Nov 24, 2026Two States Sue SpaceX: Over 90% of xAI's Child Abuse Reports Could Not Be Acted On
Key Questions Answered
What are the key details on The problem: the model confidently gets things wrong?
Ask a language model in what year Hermann von Helmholtz died, and it may answer 1894 or 1896, with the same confidence either way. The correct answer, 1894, is in Wikidata. For news verification, document analysis, or scientific work, that behavior is unacceptable. Plain text RAG helps only sometimes. It retrieves paragraphs that are semantically similar to the query, but the needed fact may not be among them.
How the system works?
The core is Llama 3.1 8B served through Ollama. The full Wikidata dump is about 133 GB, so the author filtered it in a single pass. What remained were records with Russian labels and 34 relation types: capital, citizenship, place of birth and death, occupation, educational institution, award, and similar. The resulting graph in Neo4j has 960,076 nodes and 2,680,098 edges. For the statement "The capital of Romania is Budapest," simple heuristics identify the entities and the relation type.
What the measurements showed?
The test set has 380 statements: 190 real facts from the graph and 190 fakes, in which the object is replaced with another entity of the same type. The model was run in four modes. Without context, accuracy was 17.37%. The model did not invent answers; it refused to answer. Out of 380 statements, it wrote "insufficient information" 293 times, "supported" 61 times, and "refuted" only 26 times. Caution is better than confident fabrication, but for a verification system such refusals are useless.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.