HarinezumIgel
RAG-LCC
Python

Experimental RAG playground for exploring retrieval quality, corpus construction, and filter-chain design. Features configurable ranking and filtering pipelines, visual document grounding, chat interfaces, web search, Open WebUI integration, and rich debugging insights. Ollama and vLLM, running in Dev Containers or natively on Linux and Windows.

Last updated Aug 6, 2026
27
Stars
3
Forks
0
Issues
0
Stars/day
Attention Score
41
Language breakdown
Python 95.5%
Standard ML 4.5%
Dockerfile 0.0%
โ–ธ Files click to expand
README

๐Ÿงช RAGโ€‘LCC โ€” Experimental RAG Under Constraints

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
CLASSIFYCSVQUERY = "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:

  • 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
  • Translation โ€” nonโ€‘English queries normalised to English via M2M100 (100 languages, MIT)
  • Query rewriting โ€” pronouns and referents from prior turns resolved by a dedicated rewrite LLM; prefix with new: to hardโ€‘switch topics without clearing history
  • Multiโ€‘query expansion โ€” the LLM generates N alternate phrasings to broaden vocabulary coverage across the retrieval pool
  • Hybrid retrieval โ€” Vector + BM25 + Graph fused via weighted Reciprocal Rank Fusion; optional live DuckDuckGo web leg
  • Nearโ€‘duplicate removal โ€” chunks sharing โ‰ฅโ€ฏ85% token overlap collapsed before reranking
  • Crossโ€‘encoder reranking โ€” neural relevance scoring on topโ€‘k candidates
  • Strategyโ€‘gated context assembly โ€” five profiles from NARROW (20 chunks, high precision) to ULTRA_WIDE (1500 chunks, exhaustive), with perโ€‘file diversity caps
  • LLM reasoning โ€” context assembled above is passed to the generation model
  • 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, retrieverk, threshold, websearch, 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 ยท BALANCEDFILECAP ยท DEFAULT ยท WIDE        โ”‚    โ”‚
โ”‚  โ”‚                      โ”‚                                      โ”‚    โ”‚
โ”‚  โ”‚                      โ–ผ                                      โ”‚    โ”‚
โ”‚  โ”‚          context assembly  โ†’  LLM reasoning                 โ”‚    โ”‚
โ”‚  โ”‚                      โ”‚                                      โ”‚    โ”‚
โ”‚  โ”‚                      โ–ผ                                      โ”‚    โ”‚
โ”‚  โ”‚          โ‘ฃ compliance post-check  (answer validation)       โ”‚    โ”‚
โ”‚  โ”‚                      โ”‚                                      โ”‚    โ”‚
โ”‚  โ”‚                      โ–ผ                                      โ”‚    โ”‚
โ”‚  โ”‚          answer grounding  (sentence-level overlap marks)   โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚                                                                     โ”‚
โ”‚  Web leg active only when WEBSEARCHMODE="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 YOURCLASSIFICATION_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 โ€” LOADFROMCLASSIFYCSV + CLASSIFYCSV_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 ULTRAWIDE (1 500 chunks, exhaustive); BALANCEDFILE_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 โ€” websearch (localonly / localandweb / webonly), webweight, fetchpagecontent (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, retrieverk, threshold, websearch, 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
  • OPENWEBUIWEBSEARCH โ€” when True (and WEBSEARCH_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 ConfigModels.py or ConfigBanned.py was edited without updating the stored hash (python src/Scripts/RecalcConfigHashes.py to update)
  • Fully offline after initial setup โ€” HFHUBOFFLINE="1", TRANSFORMERSOFFLINE="1", WEBSEARCHMODE="0" in ConfigInternet_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.

| Area | What you configure | Why you'd tune it | |------|--------------------|-------------------| | Chunking | 7 strategies (Semantic, Heading, PDF/Page, Sliding Window, Recursiveโ€ฆ); per-format routing; chunk size and overlap | Chunking quality determines retrieval precision โ€” wrong boundaries produce noisy embeddings, referential ambiguity, and incoherent context | | Retrieval mode | VECTOR, BM25, GRAPH, ALL, WEB โ€” any combination with per-retriever RRF weights | Switch between lexical precision, semantic recall, and entity-graph traversal; tune each store's influence independently | | Retrieval strategy | 5 profiles (NARROW โ†’ ULTRA_WIDE): chunk count to LLM, score threshold, per-file limits, retriever-k | Dial precision vs recall: 20 chunks for focused Q&A, 1500 for exhaustive exploratory search | | Reranking | Cross-encoder on/off per strategy; sigmoid score threshold | Neural relevance pass after retrieval โ€” switch off for speed, tune threshold for precision | | Query processing | Multi-query expansion (N alternate phrasings); context-dependent rewriting; pronoun/referent resolution; meta-descriptor guard | Boost recall via vocabulary diversity; prevent stale chat history from poisoning retrieval | | Chat session | Turns to keep, history window size, topic summary mode, preferred response language | Control conversational memory budget; isolate topics with new: to prevent referential drift | | Models | Any Ollama or vLLM model; separate roles for generation, query rewriting, and safety checking | Swap models per role โ€” use a large model for generation and a small one for rewriting | | Prompts | Fully customisable per model and task: chat, classification, safety check, query rewrite, topic detect | Adapt RAGโ€‘LCC to any domain by editing prompts; no code changes needed | | Compliance | 5-algorithm detection pipeline (Regex+Levenshtein, Jaccard, BM25, KeyBERT); per-app thresholds; masking; consensus count | Fine-tune false-positive/negative tradeoff independently for indexing vs chat | | Content hardening | Leet-speak and Unicode confusable normalization; WordNet synonym expansion; LLM guard model | Defense-in-depth: obfuscation is neutralized before embedding, LLM gates responses before delivery | | Classification | Customisable extraction keys; STRICT/BALANCED/RECALL profiles; SQLite filter for selective indexing | Classify first, then load only the documents that match your query's domain | | Language | 28-language detection (Lingua); M2M100 query translation (100 languages); Argos banlist translation | Retrieve and filter correctly even in multilingual document corpora | | Web search | DuckDuckGo integration; 3-stage pre-filter (BM25 + cosine + rerank); intent blocking; per-session weight | Augment local retrieval with live web results; configure filtering aggressively enough to suppress noise | | Answer grounding | Sentence-level overlap detection; configurable match strictness; color markers per output mode | Distinguish grounded sentences from hallucinations at the sentence level, in CLI and API | | Deployment | Ollama or vLLM backend; RAGChatService (OpenAI-compatible REST); OpenWebUI drop-in | Same config and pipeline whether you run CLI, a service, or behind OpenWebUI | | Observability | 12 named debug levels (Standard 30 โ†’ Streaming 100); in-chat toggle; performance event log | Trace every step: retrieval scores, merged chunk pool, prompt text, grounding markers, raw token stream |

Full slot-level details: CONFIGURATIONREFERENCE.md ยท per-file reference: CONFIGURATIONREFERENCE.md


โ“ Documentation

| Document | What's inside | | --- | --- | | ๐Ÿ“˜ README.md | Project overview ยท feature summary ยท quick-start | | ๐Ÿš€ INSTALL.md | Prerequisites ยท cloning ยท dependencies ยท Ollama / OpenWebUI / Argos / NLTK / Tesseract / spaCy / GPU setup ยท first-run walkthrough | | ๐Ÿ“š CONFIGURATIONREFERENCE.md | Per-file reference for every Config*.py ยท CLI overrides ยท translation config ยท troubleshooting | | ๐Ÿ“ธ EXAMPLES.md | End-to-end terminal sessions for RAGLoad, RAGChat, DocClassify, RAGChatService | | ๐Ÿ—๏ธ ARCHITECTURE.md | Pipeline internals ยท compliance chain ยท chunking ยท query rewrite ยท graph index | | ๐Ÿงญ HANDSON_TOUR.md | Curated hands-on session and suggested experiments | | ๐Ÿ” SECURITY.md | Security policy ยท threat model ยท limitations ยท web search risks | | โš–๏ธ LEGAL.md | This document โ€” definitions, governance, disclaimers | | ๐Ÿ“‹ CHANGELOG.md | Version history and release notes | | ๐Ÿ™ ACKNOWLEDGMENTS.md | Third-party libraries, models, and attribution |

๐Ÿ“š Background & related writeโ€‘ups

Some design decisions in RAGโ€‘LCC are motivated by concrete failure analyses:

  • Experimenting with RAGโ€‘LCC on constrained hardware
DEV.to article on classification as semantic compression and context reduction https://dev.to/harinezumigel/experimenting-with-rag-lcc-on-constrained-hardware-3dlg
  • When the pronoun โ€œtheyโ€ breaks your RAG
Reddit writeโ€‘up on chatโ€‘context and referential ambiguity failures https://www.reddit.com/r/Rag/comments/1spro5f/whenthepronountheybreaksyourrag_fixing/
  • When Your RAG System Confidently Asks About Hedgehog RAM
Reddit writeโ€‘up on chat history poisoning and the new: topicโ€‘switch fix https://www.reddit.com/r/Rag/comments/1swbmdr/whenyourragsystemconfidentlyasks_about/
  • Filtering the Noise: A Practical Multi-Layer Banlist Pipeline for RAG Systems
Reddit wirte-up on content filtering https://www.reddit.com/r/Rag/comments/1ta1svk/filteringthenoiseapractical_multilayer/
  • Speaking the Corpusโ€™s Language: How Multilingual RAG Stays Coherent Across Turns
DEV.to article on twoโ€‘pass query translation and multilingual coherence in multiโ€‘turn RAG https://dev.to/harinezumigel/speaking-the-corpuss-language-how-multilingual-rag-stays-coherent-across-turns-4pf5
  • Lessons Learned Building an Experimental RAG Lab
Reddit writeโ€‘up on failure modes that only surface with endโ€‘toโ€‘end visibility: retrieval pool size, context poisoning, multilingual gaps, scoring assumptions, and why old workarounds become bugs https://www.reddit.com/r/Rag/comments/1to784v/lessonslearnedbuildinganexperimentalrag_lab/
  • Adding Web Search to Our RAG Pipeline: What Broke and Why
DEV.to article on integrating internet retrieval into an experimental RAG pipeline โ€” query routing, compliance gating, threshold failures, and the edge cases that only appear in production-like conditions https://dev.to/harinezumigel/adding-web-search-to-our-rag-pipeline-what-broke-and-why-4ge5
  • 15 Months Building a RAG System in Retirement: Lessons Learned and What Actually Worked
Reddit writeโ€‘up on lessons learned building RAGโ€‘LCC from the ground up โ€” architectural decisions, what worked, what didn't, and practical insights from extended experimentation https://www.reddit.com/r/Rag/comments/1valvk6/15monthsbuildingaragsystemin_retirement/ These are not tutorials โ€” they document observed failure modes that this lab explores programmatically.

โš ๏ธ 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.

๐Ÿ” Legal, Regulatory, and Security Responsibility

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.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท HarinezumIgel/RAG-LCC ยท Updated daily from GitHub