ragdemo

command
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

README

Local LM Studio RAG evaluation

This demo makes retrieval quality inspectable instead of judging only the final LLM answer. It chunks the repository Markdown docs, obtains embeddings from an OpenAI-compatible LM Studio server, stores them in TinySQL, and reports the actual retrieved chunks, cosine similarities, vector/BM25 ranks, Hit@k, and MRR. Hybrid mode conservatively reranks the semantic candidate set with BM25, so a weak keyword-only hit cannot displace a strong semantic match.

Start LM Studio's local server on port 1234 and load an embedding model. Then:

go run ./cmd/ragdemo -verbose

Compare vector-only and hybrid retrieval:

go run ./cmd/ragdemo -hybrid=false
go run ./cmd/ragdemo -hybrid=true

Inspect one question and optionally generate a grounded answer:

go run ./cmd/ragdemo \
  -query "How do I expand a vector hit with its neighboring chunks?" \
  -generate

Useful optimization knobs are -chunk-size, -overlap, -candidate-k, and -top-k. Run go run ./cmd/ragdemo -help for model and endpoint options. The built-in quality gate requires every expected source and marker-bearing chunk to occur in the top-k results, so a neighboring but irrelevant chunk does not count as a success.

On the repository docs with Granite Embedding 278M Multilingual, the tested default of 900 characters with 250 characters overlap reached 100% Hit@5, 66.7% Hit@1, and 0.792 MRR across the built-in English/German questions.

Documentation

Overview

Command ragdemo exercises a complete local RAG pipeline with LM Studio and TinySQL. It deliberately prints retrieval evidence before optionally asking an LLM to answer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL