πŸ§ͺ RAG‑LCC

August 4, 2026 Β· View on GitHub

RAG-LCC Logo

🎯 Who this is for

  • πŸ”¬ Researchers and practitioners exploring why RAG pipelines succeed or fail
  • 🧠 Engineers working with large, multilingual, or conflicting document sets
  • πŸ’¬ Anyone debugging multi‑turn chat‑context failures in RAG systems
  • πŸ’» Users running RAG on constrained or commodity hardware
  • πŸ§ͺ People who want to experiment beyond "embed + cosine + top‑k" β€” see Query Output Example for what a full pipeline run looks like

RAG‑LCC is an experimental Retrieval‑Augmented Generation (RAG) lab focused on understanding and controlling retrieval and context assembly under real‑world constraints: limited context windows, modest GPUs, large documents, and multi‑turn chat.

  • DocClassify Document classification - results may be used as input filter for RAGLoad
  • RAGLoad Text extraction (document formats, pictures, MS Office) and Vector DB ingestion
  • RAGChat (CLI GUI) and RAGChatService (Open WebUI integration)

RAG-LCC Document grounding

Instead of pushing ever‑larger context sizes, RAG‑LCC treats classification, chunking, retrieval strategies, and staged loading as first‑class architectural tools.


🎬 Demo

Demo


🧠 What it does β€” and why it exists

Standard RAG is deceptively simple: embed documents, embed query, retrieve by cosine similarity, prompt the LLM. In practice this produces systems that are brittle in exactly the ways that matter most β€” they hallucinate when the corpus has conflicting information, they drift in multi‑turn chat as pronouns accumulate, they fail silently on minority‑language documents, and they have no principled way to prevent prohibited content from being stored or returned.

RAG‑LCC (Retrieval‑Augmented Generation β€” Local Corpus & Classification) is an experimental lab for studying and addressing these failure modes. Instead of pushing ever‑larger context windows, it treats classification, chunking, retrieval strategy, and content filtering as first‑class architectural decisions. Documents are analysed, compressed, filtered, and assembled before reaching the LLM β€” so the model reasons over coherent, non‑contradictory context rather than an arbitrary pile of chunks.

The system is built around four applications that form a deliberate pipeline:


🏷️ DocClassify β€” Know your corpus before you index it

Before anything enters the retrieval indexes, DocClassify runs LLM‑powered keyword extraction and batch classification over your document collection. Every file gets structured metadata β€” topic, category, language, and any custom fields you define β€” written to a CSV.

This is not just labelling. It is semantic compression: large documents are reduced to meaning‑dense keyword signals early, before expensive embedding and retrieval. You can then filter that CSV with a plain SQL WHERE clause to decide exactly which documents proceed to indexing:

# Index only English mammal-related documents classified as Science
CLASSIFY_CSV_QUERY = "Mammal LIKE '%Yes%' AND Language = 'English'"

Documents that fail your criteria never get indexed β€” reducing token waste, context noise, and compliance surface area.


πŸ“₯ RAGLoad β€” Index with intent, filter at the gate

RAGLoad ingests the documents you selected and builds three parallel indexes simultaneously:

  • ChromaDB β€” dense embedding vectors (Snowflake Arctic Embed L v2.0) for semantic search
  • BM25 β€” Okapi BM25 keyword index for term‑frequency scoring and lexical recall; complements vector search on precise terminology and rare terms
  • Entity co‑occurrence graph β€” spaCy NER entities and noun phrases extracted from every chunk and linked by document co‑occurrence; enables graph traversal to pull in thematically connected chunks that neither vector nor BM25 search would surface

Before any chunk is stored, it passes through a multi‑algorithm compliance filter chain β€” Regex+Levenshtein, Jaccard, BM25, KeyBERT β€” that detects and optionally masks prohibited content. Leet‑speak decoding and Unicode confusable normalization run first, so obfuscated phrases are caught before embedding.

Seven chunking strategies handle different document types: semantic boundary detection for free text, heading‑aware chunking for structured documents, per‑page for PDFs, per‑slide for presentations. Chunk boundaries match the document’s natural discourse structure rather than arbitrary token counts.

Files unchanged since the last run are skipped. Files flagged by prior compliance runs can be automatically excluded.


πŸ’¬ RAGChat β€” Retrieval that fights context failures

RAGChat is a multi‑turn chat interface backed by the indexes built by RAGLoad. It is designed around the observation that most RAG failures are not retrieval failures β€” they are context assembly failures: semantically similar chunks that reinforce each other’s errors, pronoun references that resolved to the wrong entity two turns ago, or factually contradictory passages delivered side‑by‑side without scoping. See Query Output Example for an annotated full-pipeline run.

Each query runs through a staged pipeline:

  1. Compliance pre‑check β€” the multi‑algorithm filter chain (Regex+Levenshtein, Jaccard, BM25, KeyBERT) runs on the raw query; matched phrases are masked or the request is blocked before anything else happens
  2. Translation β€” non‑English queries normalised to English via M2M100 (100 languages, MIT)
  3. Query rewriting β€” pronouns and referents from prior turns resolved by a dedicated rewrite LLM; prefix with new: to hard‑switch topics without clearing history
  4. Multi‑query expansion β€” the LLM generates N alternate phrasings to broaden vocabulary coverage across the retrieval pool
  5. Hybrid retrieval β€” Vector + BM25 + Graph fused via weighted Reciprocal Rank Fusion; optional live DuckDuckGo web leg
  6. Near‑duplicate removal β€” chunks sharing β‰₯β€―85% token overlap collapsed before reranking
  7. Cross‑encoder reranking β€” neural relevance scoring on top‑k candidates
  8. Strategy‑gated context assembly β€” five profiles from NARROW (20 chunks, high precision) to ULTRA_WIDE (1500 chunks, exhaustive), with per‑file diversity caps
  9. LLM reasoning β€” context assembled above is passed to the generation model
  10. Compliance post‑check β€” the same filter chain re‑runs on the generated answer; matched spans are masked before the response reaches the user

Answers are grounded β€” every sentence is checked for overlap with retrieved source text and marked visually, in CLI and API output alike. You see exactly which parts of the answer are evidence‑backed and which are not.


🌐 RAGChatService β€” OpenAI‑compatible RAG as a service

RAGChatService wraps the complete RAGChat pipeline in an OpenAI‑compatible REST API (POST /v1/chat/completions). Point OpenWebUI at it β€” or any OpenAI client β€” and your local RAG pipeline becomes a selectable model with no prompt engineering required on the client side.

ChromaDB collections appear as models in the OpenWebUI dropdown. RAG‑LCC knobs (strategy, retriever_k, threshold, web_search, web_weight) are exposed as OpenWebUI Advanced Parameters so non‑technical users can tune retrieval without editing config files.

Supports Bearer‑token authentication, optional streaming, configurable host/port, and fully offline operation after initial setup.


🧭 Quick mental model

Raw documents
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  DocClassify  (optional first pass)       β”‚
β”‚  ─────────────────────────────────────    β”‚
β”‚  KeyBERT keyword extraction               β”‚
β”‚  LLM classification  β†’  CSV metadata      β”‚
β”‚  compliance filter chain (load-time)      β”‚
β”‚  purpose: semantic compression +          β”‚
β”‚           domain-scoped ingestion         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚  optional: filter CSV with
        β”‚  plain SQL WHERE clause, e.g.
        β”‚  "Mammal LIKE '%Yes%'"
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  RAGLoad  (indexes the corpus)            β”‚
β”‚  ─────────────────────────────────────    β”‚
β”‚  leet-speak + Unicode normalisation       β”‚
β”‚  compliance filter chain  β†’  masking      β”‚
β”‚  7 chunking strategies (per file type)    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ ChromaDB β”‚ β”‚  BM25    β”‚ β”‚   Graph   β”‚  β”‚
β”‚  β”‚ vectors  β”‚ β”‚ keyword  β”‚ β”‚  entity   β”‚  β”‚
β”‚  β”‚ (HNSW)   β”‚ β”‚  index   β”‚ β”‚  co-occur β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  skips unchanged files (hash check)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  RAGChat  /  RAGChatService                                         β”‚
β”‚  ─────────────────────────────────────────────────────────────────  β”‚
β”‚                                                                     β”‚
β”‚  RAGChat   β€” interactive CLI                                        β”‚
β”‚  RAGChatService β€” OpenAI-compatible REST API  ──► OpenWebUI         β”‚
β”‚              (same pipeline, same config)                           β”‚
β”‚                                                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  per-query pipeline                                         β”‚    β”‚
β”‚  β”‚                                                             β”‚    β”‚
β”‚  β”‚  user query                                                 β”‚    β”‚
β”‚  β”‚    β”‚  β‘  compliance pre-check  (banned-phrase filter chain)  β”‚    β”‚
β”‚  β”‚    β”‚  β‘‘ M2M100 translation  β†’  English (if non-English)     β”‚    β”‚
β”‚  β”‚    β”‚  β‘’ query rewrite  (coreference resolution via LLM)     β”‚    β”‚
β”‚  β”‚    β–Ό                                                        β”‚    β”‚
β”‚  β”‚  multi-query expansion  (LLM β†’ N alternate phrasings)       β”‚    β”‚
β”‚  β”‚    β”‚  each variant runs an additional Vector search         β”‚    β”‚
β”‚  β”‚    β–Ό                                                        β”‚    β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚    β”‚
β”‚  β”‚  β”‚  Vector  β”‚  β”‚   BM25   β”‚  β”‚  Graph   β”‚  β”‚    Web    β”‚    β”‚    β”‚
β”‚  β”‚  β”‚ (Chroma) β”‚  β”‚ keyword  β”‚  β”‚ entity   β”‚  β”‚ DuckDuckGoβ”‚    β”‚    β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜    β”‚    β”‚
β”‚  β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚    β”‚
β”‚  β”‚                  weighted RRF fusion                        β”‚    β”‚
β”‚  β”‚                      β”‚                                      β”‚    β”‚
β”‚  β”‚                      β–Ό                                      β”‚    β”‚
β”‚  β”‚          near-duplicate removal  (Jaccard)                  β”‚    β”‚
β”‚  β”‚                      β”‚                                      β”‚    β”‚
β”‚  β”‚                      β–Ό                                      β”‚    β”‚
β”‚  β”‚          threshold filter  (sigmoid score β‰₯ T)              β”‚    β”‚
β”‚  β”‚                      β”‚                                      β”‚    β”‚
β”‚  β”‚                      β–Ό                                      β”‚    β”‚
β”‚  β”‚          cross-encoder reranker  (mmarco MiniLM)            β”‚    β”‚
β”‚  β”‚                      β”‚                                      β”‚    β”‚
β”‚  β”‚                      β–Ό                                      β”‚    β”‚
β”‚  β”‚          chunk selection strategy                           β”‚    β”‚
β”‚  β”‚          NARROW Β· BALANCED_FILE_CAP Β· DEFAULT Β· WIDE        β”‚    β”‚
β”‚  β”‚                      β”‚                                      β”‚    β”‚
β”‚  β”‚                      β–Ό                                      β”‚    β”‚
β”‚  β”‚          context assembly  β†’  LLM reasoning                 β”‚    β”‚
β”‚  β”‚                      β”‚                                      β”‚    β”‚
β”‚  β”‚                      β–Ό                                      β”‚    β”‚
β”‚  β”‚          β‘£ compliance post-check  (answer validation)       β”‚    β”‚
β”‚  β”‚                      β”‚                                      β”‚    β”‚
β”‚  β”‚                      β–Ό                                      β”‚    β”‚
β”‚  β”‚          answer grounding  (sentence-level overlap marks)   β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                                                                     β”‚
β”‚  Web leg active only when WEB_SEARCH_MODE="1" and web_search=on     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

A few refinements to keep in mind when reading the pipeline above:

  • Confidence-gated reranking β€” the per-strategy threshold is a cross-encoder confidence floor. When no chunk clears it (the reranker is unconfident about the whole pool, common on technical/tabular content), reranking is skipped and chunks fall back to retrieval (RRF) order instead of being dropped β€” with an orange Rerank skipped notice.
  • Metadata filtering β€” harvested document metadata (author, title, dates, page labels, …) can be used as retrieval filters via the metadata! picker or metadata=Field:Value, narrowing all three local retrievers.
  • Correct source pages β€” citations and highlighted source documents use the document's printed page label (e.g. front-matter iii), while highlighting is placed on the true physical page.

The goal is not to feed the model more text β€” but to feed it better, safer context.


πŸ“Š Presentation

A slide deck is available as RAG-LCC_Presentation.pptx. It provides a quick visual overview of the architecture, the four applications, the retrieval pipeline, and the key design decisions β€” useful as a starting point before diving into the detailed documentation.


πŸ”‘ Feature Highlights

Key capabilities organized by application. Full configuration details, defaults, and code examples in CONFIGURATION_REFERENCE.md.

🏷️ DocClassify

  • Semantic compression β€” KeyBERT keyword extraction + LLM classification produces meaning-dense CSV metadata (topic, category, language, and any custom fields you define)
  • Classify-then-load β€” filter the output CSV with a plain SQL WHERE clause before indexing: "Mammal LIKE '%Yes%' AND Language = 'English'". Documents that fail the filter are never embedded
  • Compliance filter chain runs at classification time β€” detected phrases are masked before any embedding
  • Customisable extraction keys β€” add or remove fields by editing _YOUR_CLASSIFICATION_KEYS and the matching prompt template; no code changes needed
  • Reverse stemming β€” classification output values are back-projected to original surface forms before CSV export
  • STRICT / BALANCED / RECALL extraction profiles control the LLM's sampling parameters

πŸ“₯ RAGLoad

  • 7 chunking strategies with per-format routing: PDFβ†’PDF_PAGE, DOCX/MDβ†’heading, PPTXβ†’slide, plain textβ†’sliding window, sentencesβ†’sentence window, code/CSVβ†’recursive, defaultβ†’semantic boundary detection
  • Three parallel indexes built simultaneously: ChromaDB HNSW dense vectors, Okapi BM25 keyword index, spaCy entity co-occurrence graph
  • Compliance filter chain + masking β€” Regex+Levenshtein, Jaccard, BM25, and KeyBERT all run before any chunk is stored; matched spans are redacted in place
  • Obfuscation hardening β€” leet-speak decoding (1β†’i, 3β†’e, …) and Unicode confusable normalisation (Cyrillic lookalikes, ΓŸβ†’ss, …) run before detection
  • Incremental processing β€” SHA-256 hash check skips unchanged files; exclusion CSVs automatically drop previously-flagged documents
  • Text extraction β€” PDF (pdfplumber + pdfminer), MS Office via COM (Word, PowerPoint, Excel), images via Tesseract OCR, plain text and Markdown
  • Classify-then-load filter β€” LOAD_FROM_CLASSIFY_CSV + CLASSIFY_CSV_QUERY (SQLite WHERE) narrows ingestion to documents that passed DocClassify criteria

πŸ’¬ RAGChat

  • 8 retrieval modes β€” VECTOR, BM25, GRAPH, or any pair/triple fused via weighted Reciprocal Rank Fusion; optional DuckDuckGo web leg as a fourth RRF arm
  • 5 retrieval strategies from NARROW (20 chunks, threshold 0.70, high precision) to ULTRA_WIDE (1 500 chunks, exhaustive); BALANCED_FILE_CAP enforces per-file diversity caps
  • Multi-query expansion β€” a dedicated LLM generates N alternate phrasings of the query; each variant runs an additional Vector search merged into the main pool before fusion
  • Query rewriting / coreference resolution β€” a second dedicated LLM resolves pronouns and referents from conversation history ("are they mammals?" β†’ "are hedgehogs mammals?"); prefix with new: to hard-switch topics without clearing history
  • Near-duplicate chunk removal β€” Jaccard token-level deduplication of the retrieval pool runs after RRF fusion and before reranking
  • Cross-encoder reranking β€” mmarco MiniLM rescores every candidate; per-strategy sigmoid threshold drops weak matches; when no chunk clears the threshold, reranking is skipped and chunks fall back to retrieval (RRF) order so the top chunk always surfaces
  • Answer grounding β€” every answer sentence is checked for overlap with retrieved source chunks and marked visually; CLI uses ANSI highlights, API returns marked source documents as /marked/<token> links
  • Compliance filter chain runs on queries before retrieval and on generated responses before delivery
  • Multi-turn conversational memory β€” rolling topic summary, configurable turn window, batch pruning; new: prefix isolates topics without discarding history
  • Translation β€” M2M100 (100 languages, MIT) normalises non-English queries to English before retrieval and rewriting; Argos Translate expands banlists to the document language
  • Per-session web knobs β€” web_search (local_only / local_and_web / web_only), web_weight, fetch_page_content (snippets only / fetch pages); see CONFIGURATION_REFERENCE.md Β§ Web Search Admin Knobs

🌐 RAGChatService

  • OpenAI-compatible REST API (POST /v1/chat/completions) β€” any OpenAI client, LiteLLM proxy, or custom integration works without modification
  • OpenWebUI integration β€” ChromaDB collections appear as selectable models in the dropdown; retrieval knobs (strategy, retriever_k, threshold, web_search, web_weight) surface as Advanced Parameters
  • In-memory document cache β€” highlighted source documents served as short-lived GET /marked/<token> links; configurable TTL, total size cap, and CORS origins
  • Bearer-token authentication, configurable host/port, optional streaming, automatic streaming downgrade when document grounding is active
  • _OPENWEB_UI_WEBSEARCH β€” when True (and WEB_SEARCH_MODE="1"), the web leg is auto-enabled for every incoming OpenWebUI request that doesn't supply an explicit parameter

πŸ”§ Cross-App

  • Compliance pipeline is identical across all apps β€” same algorithms (Regex+Levenshtein, Jaccard, BM25, KeyBERT), same banlist, per-app consensus thresholds
  • 12 named debug levels (0–100) β€” Standard 30 shows pipeline flow; Chunk Content 32 dumps full retrieved text; Chat Prompt 60 shows the LLM input; all changeable live in-chat with set debug ge 30
  • Config hash verification β€” startup rejects runs where Config_Models.py or Config_Banned.py was edited without updating the stored hash (python src/Scripts/RecalcConfigHashes.py to update)
  • Fully offline after initial setup β€” HF_HUB_OFFLINE="1", TRANSFORMERS_OFFLINE="1", WEB_SEARCH_MODE="0" in Config_Internet_Env.py
  • License consent workflows β€” RAG‑LCC does not bundle any model; consent is recorded per-model in ModelGovernance/licenses/ before first use

πŸŽ›οΈ Configuration at a Glance

RAG‑LCC exposes every significant architectural decision as a configuration slot. Nothing is hardwired β€” chunking boundaries, retrieval algorithm mix, scoring thresholds, model roles, compliance rules, and answer grounding sensitivity are all independently tunable.

If you have a document corpus and want to optimize retrieval β€” start with chunking strategies, retrieval mode and strategy profiles, and BM25/HNSW parameters. If you're studying RAG failure modes β€” every stage from query rewriting to answer grounding can be inspected at named debug levels, disabled, or replaced independently. If you need to integrate or deploy it β€” Ollama or vLLM backend, OpenAI-compatible REST service (RAGChatService), OpenWebUI drop-in, fully offline after initial setup.

AreaWhat you configureWhy you'd tune it
Chunking7 strategies (Semantic, Heading, PDF/Page, Sliding Window, Recursive…); per-format routing; chunk size and overlapChunking quality determines retrieval precision β€” wrong boundaries produce noisy embeddings, referential ambiguity, and incoherent context
Retrieval modeVECTOR, BM25, GRAPH, ALL, WEB β€” any combination with per-retriever RRF weightsSwitch between lexical precision, semantic recall, and entity-graph traversal; tune each store's influence independently
Retrieval strategy5 profiles (NARROW β†’ ULTRA_WIDE): chunk count to LLM, score threshold, per-file limits, retriever-kDial precision vs recall: 20 chunks for focused Q&A, 1500 for exhaustive exploratory search
RerankingCross-encoder on/off per strategy; sigmoid score thresholdNeural relevance pass after retrieval β€” switch off for speed, tune threshold for precision
Query processingMulti-query expansion (N alternate phrasings); context-dependent rewriting; pronoun/referent resolution; meta-descriptor guardBoost recall via vocabulary diversity; prevent stale chat history from poisoning retrieval
Chat sessionTurns to keep, history window size, topic summary mode, preferred response languageControl conversational memory budget; isolate topics with new: to prevent referential drift
ModelsAny Ollama or vLLM model; separate roles for generation, query rewriting, and safety checkingSwap models per role β€” use a large model for generation and a small one for rewriting
PromptsFully customisable per model and task: chat, classification, safety check, query rewrite, topic detectAdapt RAG‑LCC to any domain by editing prompts; no code changes needed
Compliance5-algorithm detection pipeline (Regex+Levenshtein, Jaccard, BM25, KeyBERT); per-app thresholds; masking; consensus countFine-tune false-positive/negative tradeoff independently for indexing vs chat
Content hardeningLeet-speak and Unicode confusable normalization; WordNet synonym expansion; LLM guard modelDefense-in-depth: obfuscation is neutralized before embedding, LLM gates responses before delivery
ClassificationCustomisable extraction keys; STRICT/BALANCED/RECALL profiles; SQLite filter for selective indexingClassify first, then load only the documents that match your query's domain
Language28-language detection (Lingua); M2M100 query translation (100 languages); Argos banlist translationRetrieve and filter correctly even in multilingual document corpora
Web searchDuckDuckGo integration; 3-stage pre-filter (BM25 + cosine + rerank); intent blocking; per-session weightAugment local retrieval with live web results; configure filtering aggressively enough to suppress noise
Answer groundingSentence-level overlap detection; configurable match strictness; color markers per output modeDistinguish grounded sentences from hallucinations at the sentence level, in CLI and API
DeploymentOllama or vLLM backend; RAGChatService (OpenAI-compatible REST); OpenWebUI drop-inSame config and pipeline whether you run CLI, a service, or behind OpenWebUI
Observability12 named debug levels (Standard 30 β†’ Streaming 100); in-chat toggle; performance event logTrace every step: retrieval scores, merged chunk pool, prompt text, grounding markers, raw token stream

Full slot-level details: CONFIGURATION_REFERENCE.md Β· per-file reference: CONFIGURATION_REFERENCE.md


❓ Documentation

DocumentWhat's inside
πŸ“˜ README.mdProject overview Β· feature summary Β· quick-start
πŸš€ INSTALL.mdPrerequisites Β· cloning Β· dependencies Β· Ollama / OpenWebUI / Argos / NLTK / Tesseract / spaCy / GPU setup Β· first-run walkthrough
πŸ“š CONFIGURATION_REFERENCE.mdPer-file reference for every Config_*.py Β· CLI overrides Β· translation config Β· troubleshooting
πŸ“Έ EXAMPLES.mdEnd-to-end terminal sessions for RAGLoad, RAGChat, DocClassify, RAGChatService
πŸ—οΈ ARCHITECTURE.mdPipeline internals Β· compliance chain Β· chunking Β· query rewrite Β· graph index
🧭 HANDS_ON_TOUR.mdCurated hands-on session and suggested experiments
πŸ” SECURITY.mdSecurity policy Β· threat model Β· limitations Β· web search risks
βš–οΈ LEGAL.mdThis document β€” definitions, governance, disclaimers
πŸ“‹ CHANGELOG.mdVersion history and release notes
πŸ™ ACKNOWLEDGMENTS.mdThird-party libraries, models, and attribution

Some design decisions in RAG‑LCC are motivated by concrete failure analyses:


⚠️ Project status

πŸ§ͺ Experimental / lab software

RAG‑LCC is intended for:

  • architectural exploration
  • controlled experimentation
  • learning and research

It is not a plug‑and‑play production framework.


⭐ Citation & visibility

If this project helps you reason about retrieval, chunking, and context assembly failures in RAG systems, a ⭐ helps other practitioners find it.

A CITATION.cff file is included for academic or technical reference.


TL;DR β€” try it locally

Read INSTALL.md before running anything. You get information what will be done during setup.

git clone <this-repo>; cd RAG-LCC
python -m venv .venv; .\.venv\Scripts\Activate.ps1   # or source .venv/bin/activate
# Guided setup, recommended
python src/Scripts/Setup.py                           # guided first-run setup (copies configs, downloads models)
# Note: License acceptance is required and recorded on startup
python ./src/Apps/RAGLoad.py  --doc-dir TestDocs
python ./src/Apps/RAGChat.py  --doc-dir TestDocs

Read INSTALL.md before running anything β€” model licenses must be accepted on first start.

RAG‑LCC β€” Disclaimer

⚠️ Experimental Research Framework

RAG‑LCC is an experimental research framework intended solely for laboratory use, evaluation, and learning. It is not production software and must not be used in operational, regulated, safety‑critical, or compliance‑critical environments.

🚫 No Support, No Warranty, No SLA

This project is provided as‑is with no:

  • support or assistance
  • issue response or troubleshooting
  • bug fixes, patches, or security updates
  • maintenance or compatibility commitments
  • service‑level objectives or availability guarantees

No warrantyβ€”express or impliedβ€”is provided regarding correctness, completeness, security, reliability, or fitness for any purpose.

All legal, regulatory, operational, and security risks arising from the use of this software are assumed entirely by the operator.

This project is not a legal, security, governance, or compliance solution. Nothing in the source code, documentation, examples, or logs should be interpreted as legal or security advice.

For definitions, constraints, and further detail, review:

🎯 Intended Use

RAG‑LCC is intended for:

  • local experimentation with RAG pipelines
  • research into filter chains and scoring
  • teaching and learning RAG architectures
  • development and testing of custom detection algorithms

It is not intended for end users, enterprises, or regulated operational deployment.

πŸ“‰ Limitations

Detection and validation mechanisms in this framework are probabilistic. False positives and false negatives will occur.

Scope includes: document ingestion, prompt validation, document classification, and LLM output validation as defined in ./src/Configuration/Config_*.py.

⚠️ Final Notice

Use of RAG‑LCC is entirely at the operator’s own risk. Nothing in this repository guarantees correctness, safety, regulatory conformity, or suitability for any specific environment or risk profile.