[English] · 日本語 (Japanese)
Vector × tree × graph-lite × calibrated decisions. Fully local (one GPU). Built on openvons, the finite-candidate decision engine (Jev-style calibrated choices).
Live demo: https://ragnarok.openvons.com · Full video (2.7 min, Japanese narration & subtitles): mp4 on the demo site · release asset
| 50 candidates → 25+25 → 10, one token each | "none of these" ≥ 50% → abstain | every page judged, 25 ms each |
|---|---|---|
![]() |
![]() |
![]() |
Most RAG stacks pick one paradigm — vectors, a table-of-contents tree (PageIndex), or a knowledge graph (GraphRAG) — and each loses somewhere. ragnarok uses vectors for breadth, a document tree for structure, query-time sweeps instead of a pre-built graph for coverage, and — the part that is new — 1-token probability decisions (not generation) to choose among candidates at every step. That gives you three things the others don't:
- Precision at the same cost: re-rank 50 candidates with three 1-token forwards instead of a generative re-ranker → FinanceBench evidence hit@5 0.67 → 0.89, answer accuracy 0.47 → 0.77.
- Abstention that actually works: a calibrated "none of these" option. When the answer is not in the document, it says so — even when the document looks right (same company, different fiscal year: AUROC 0.96 vs 0.73 for embedding similarity).
- Coverage without an index of extractions: "every place this topic appears" is a yes/no decision per page (25 ms each on a 4B model) → recall 0.93 vs 0.57 for vector top-10.
FinanceBench open-source set (150 questions, 84 10-K filings, 12,013 pages). Answerer and judge are the same local 27B for every row, so compare rows, not absolute values.
| Retrieval | evidence hit@1 | evidence hit@5 | answer accuracy |
|---|---|---|---|
| Vector search (page embeddings) | 0.36 | 0.67 | 0.47 |
| + cross-encoder re-rank (bge-reranker-v2-m3, top-50) | 0.28 | 0.61 | 0.46 |
| + generative listwise re-rank (RankGPT-style, 27B, top-25) | 0.57 | 0.81 | 0.59 |
| PageIndex-style (show the tree, generate node ids) | 0.39 | 0.58 | 0.45 |
| ragnarok: vector top-50 → 2-stage 1-token decisions (25+25 → 10 → 5) | 0.63 | 0.89 | 0.68 |
| same, answerer with thinking | 0.63 | 0.89 | 0.77 |
Abstention — ask each question against a different document and look at the "none of these" probability:
| Decoy document | embedding-similarity threshold AUROC | ragnarok "none" probability AUROC | at none>0.5: false reject / reject |
|---|---|---|---|
| another company's 10-K | 0.993 | 0.985 | 3% / 90% |
| same company, ≥3 years apart | 0.731 | 0.960 | 1% / 79% |
Coverage — "all pages that discuss X" (6 filings × 8 topics, oracle = 27B page labels):
| Method | recall | precision | decision calls |
|---|---|---|---|
| vector top-10 | 0.57 | 0.48 | 0 |
| keyword match | 0.80 | 0.57 | 0 |
| vector top-50 → 4B yes/no | 0.82 | 0.66 | 50 |
| every page → 4B yes/no (sweep mode) | 0.93 | 0.61 | ~155 (≈4 s per filing) |
Full tables, what did not work (tree navigation on 10-Ks, distilling the re-ranker into a 4B head), and the qualitative comparison with GraphRAG / PageIndex / vector RAG: docs/comparison.md, bench/README.md.
Japanese securities reports (EDINET, 10 companies × 26 fiscal years, 130 synthetic questions): vector hit@5 0.78 → 2-stage decisions 0.91, answer accuracy 0.92 (27B thinking). Details in bench/README.md.
question ──► page embeddings (top-50)
──► decision ×2: "which of these 25 pages holds the answer? / none" → top-5 each
──► decision: "which of these 10? / none" → pages + P(none)
──► P(none) ≥ 0.5 ? abstain : answer from those pages (with citations)
sweep: every page ──► "does this page discuss X? yes/no" (4B, 25 ms) ──► all hits ──► summary
Decisions are made with openvons' LLMBackend (guided choice + first-token logprobs on any OpenAI-compatible server): one forward pass returns a full probability distribution over the options.
git clone https://github.com/genai-craft/ragnarok && cd ragnarok
uv venv && uv pip install -e ".[demo]"
ragnarok up # picks a tier from free VRAM + what's installed (vllm / llama-server), starts the model servers
ragnarok status # which tiers are alive, which one "auto" will use
python - <<'PY'
import asyncio
from ragnarok.engine import Engine
eng = Engine.from_profile() # "auto": the best tier whose servers are alive (no servers → nollm)
ix = eng.index_pdf("your.pdf") # pages + embeddings + layout tree, no LLM
async def main():
r = await eng.retrieve(ix, "What was total revenue in fiscal 2022?")
print(r.pages, r.none_final, r.abstain) # pages (0-based), P(none), abstain?
print(await eng.answer(ix, "What was total revenue in fiscal 2022?", r.pages, think=True))
hits = await eng.sweep(ix, "share repurchases") # {page: P(yes)} for every page
asyncio.run(main())
PY
python -m examples.demo.server --port 8608 # the web demoThe demo takes PDF, DOCX, PPTX, HTML, TXT and Markdown (non-PDF files are split into sections/slides instead of pages), shows each decision stage with probabilities, previews the cited PDF page, streams the answer, and has a sweep mode.
Any OpenAI-compatible server that returns logprobs can be the judge (vLLM with guided choice, or llama.cpp with a GBNF grammar via kind="llamacpp"); scripts/serve_models.sh / scripts/serve_gguf.sh start them by hand if you'd rather not use ragnarok up.
Four tiers, all measured on FinanceBench with the same embeddings and the same 27B scorer. The rule: 27B if it fits, otherwise a 4B, otherwise embeddings only.
| tier | judge / answerer | evidence hit@5 | answer accuracy | needs |
|---|---|---|---|---|
| full | Qwen3.8-27B / 27B (vLLM) | 0.91 | 0.73 | GPU ≥ 24 GB, vllm |
| light | Qwen3-4B / 4B (vLLM) | 0.82 | 0.64 | GPU ≥ 10 GB, vllm |
| gguf | Qwen3.5-4B Q3_K_M / Qwen3-4B Q4_K_M (llama.cpp) | 0.84 | 0.63 | GPU ≥ 8 GB, llama-server (judge only: 4 GB, accuracy 0.49) |
| nollm | none / none (returns candidate pages) | 0.71 | — | CPU |
ragnarok up # auto: full if ≥ 24 GB free and vllm is installed, else gguf (llama-server) or light (vllm), else nollm
ragnarok up gguf # or name the tier; --gpu N, --judge-only for a 4 GB card
ragnarok status # what is alive; what Engine.from_profile("auto") will choose
ragnarok downEngine.from_profile("auto") (the default) uses the best tier whose servers answer, and falls back to the judge for any missing fast/answer server. Pin a tier with Engine.from_profile("gguf"), --profile gguf on the CLI, or RAGNAROK_PROFILE=gguf. ragnarok up downloads the GGUFs on first use (RAGNAROK_GGUF_DIR), finds vllm / llama-server on PATH or via RAGNAROK_VLLM / RAGNAROK_LLAMA_SERVER, and writes logs under ~/.cache/ragnarok/logs/.
Why these four: a 4B judge is the floor (2B decisions add nothing over embeddings), answer quality scales with the answerer (2B → 4B → 27B: 0.18 → 0.64 → 0.73), and 4B quantization is nearly free (Qwen3.5-4B keeps its judge quality down to Q3_K_M, Qwen3-4B Q4_K_M answers like bf16). Every variant we tried, including light2 (Qwen3.5-4B judge + Qwen3-4B answerer, hit@5 0.87) and the 2B/9B/merge GGUFs, is in bench/README.md.
Default is google/embeddinggemma-2 (Apache-2.0, 100+ languages, 768d with Matryoshka truncation, and page images embed into the same space — pages with no text layer are embedded as images, so scanned PDFs and figures are searchable without OCR). Compared with Qwen3-Embedding-0.6B on our benchmarks the English results are equal within noise and Japanese is slightly better; candidate recall@50 rises to 0.98 (FinanceBench) / 1.00 (Japanese reports). Set RAGNAROK_EMBED=Qwen/Qwen3-Embedding-0.6B to switch back; Engine(embed_dim=256) cuts vector storage to a quarter at near-identical accuracy. Add Engine(image_pages=True) to embed every page as an image as well: English filings gain candidate recall@5 +3pt from the fused score (text + 0.3·image); for CJK documents the image score is switched off because it hurts. Details: bench/README.md.
NVIDIA Nemotron 3.5 Embed (OpenMDW-1.1, commercial use OK) can be selected with RAGNAROK_EMBED=nvidia/Nemotron-3.5-Embed-1B-BF16 (or -8B-BF16; needs transformers ≥ 5.20). In our benchmarks the 1B model indexes text as fast as EmbeddingGemma-2 and is better everywhere, most of all on Japanese and page images (Japanese reports, image only: recall@5 0.56 → 0.88; Japanese scans, image only: 0.58 → 0.83). The 8B model reaches FinanceBench recall@5 0.90 from the embedding alone, the level ragnarok previously needed two 27B decision rounds for. Nemotron Rerank 8B as the first re-ranking stage raises evidence hit@5 from 0.91 to 0.96–0.97 with one 27B call instead of three, but weakens same-company abstention. Nemotron Parse OCRs scans 6–7× faster than a VLM at similar quality. Numbers and caveats: bench/README.md (section "NVIDIA Nemotron 3.5 Retriever").
Scanned PDFs: pages without a text layer are embedded as images (English scans retrieve at recall@5 0.79 with no OCR at all), and if you give Engine(vlm_url=...) an OpenAI-compatible VLM (e.g. Qwen3-VL-8B on vLLM, ~1 s/page batched) they are OCR'd at index time — on 1960s–80s government scans that gives answer accuracy 0.75 (EN) / 0.79 (JA) with the usual text pipeline. Details: bench/README.md.
EmbeddingGemma 2 embeds audio into the same space as text, so a recording can be searched by a text question with no transcription step:
ix = eng.index_audio("meeting.wav") # 20 s segments, 15 s hop; embeddings are the audio itself
eng.search_audio(ix, "when did we decide the budget?", k=3) # -> [{"start": 300.0, "end": 320.0, "score": 0.68, ...}]Measured on Japanese read speech (FLEURS, 60 sentences in three 4-minute recordings): the segment containing the sentence is top-1 in 93% of queries (20 s segments) and top-3 in 98% (bench/audio_search_check.py). Pass transcriber=ragnarok.audio.whisper_transcriber() (kotoba-whisper) or ragnarok.audio.haas_transcriber() (Haas-ja-v1.0, Apache-2.0, GPU; about half the errors of kotoba-whisper on Japanese and a custom vocabulary for names) to also transcribe each segment; the index then has text pages and the usual retrieve / answer work on it.
ragnarok index /mnt/nas/share --store /data/ragnarok/store # recursive, incremental (mtime/size); PDF/DOCX/PPTX/HTML/TXT/MD
ragnarok ask --store /data/ragnarok/store "What was total revenue in fiscal 2022?" # searches across every indexed document
ragnarok sweep --store /data/ragnarok/store "share repurchases" # every page that discusses the topic, across documentsAll page embeddings live in one matrix (faiss is used automatically above 200k pages); candidates are capped per document for diversity; the decision options carry the document name, so one call ranks pages across documents and can abstain for the whole corpus. Measured on 110 documents / 17,418 pages without being told the document: FinanceBench document hit@1 0.75 → 0.87, evidence page hit@5 0.53 → 0.75; Japanese reports 0.32 → 0.64 / 0.39 → 0.65 (vector top-5 → ragnarok). The demo has a "search all documents" entry.
- The tree is a helper, not the core: on FinanceBench-type questions (numbers inside tables) tree navigation lost to embeddings, even with LLM summaries on every node. It stays for structure-heavy documents (laws, contracts) and is measured separately.
- Relation questions ("who is connected to X") are not measured; coverage/aggregation is. A lazy graph (edges verified by decisions at query time) is the plan.
- Japanese works end-to-end (demo includes 26 EDINET securities reports and a government white paper); the Japanese QA set is synthetic (questions generated from the evidence page) and easier than FinanceBench.
Apache-2.0 — free to use, modify and redistribute with attribution: keep LICENSE and NOTICE, and credit "ragnarok — https://github.com/genai-craft/ragnarok" (CITATION.cff). ragnarok is independent of TypeSafe AI and its product Jev; it builds on openvons, an independent implementation of Jev-style calibrated decisions.



