Add LLM judge to retrieval eval; switch chat to pypdf with 2000/400 chunks
- eval_retrieval.py: --judge MODEL lets an OpenAI model decide whether the top-5 chunks answer each question, regardless of source and page; reports Answer@5, answer-level MRR and agreement with the page check; verdicts are cached in eval/judge_cache.json - On the curated goldset, gpt-6-luna rates pypdf and Docling equal (Answer@5 0.93 each, MRR 0.90 vs 0.92), so the chat stays on pypdf for now - local_rag.py: chunks 2000/400, chunk headers off by default, OpenAI model gpt-6-luna; server.py loads ./vectorstore_pypdf_2000 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+8
-5
@@ -19,9 +19,10 @@ from langchain_text_splitters import RecursiveCharacterTextSplitter
|
||||
import docling_loader
|
||||
|
||||
# Pipeline tuning: used when adding documents (rebuild index after changing).
|
||||
# Characters, not tokens: 1500 characters of German prose are roughly 400 tokens.
|
||||
CHUNK_SIZE = 1500
|
||||
CHUNK_OVERLAP = 300
|
||||
# Characters, not tokens: 2000 characters of German prose are roughly 550 tokens.
|
||||
# With the reranker, 2000/400 beat 1500/300 on both Kafka goldsets (eval/matrix_2000.out).
|
||||
CHUNK_SIZE = 2000
|
||||
CHUNK_OVERLAP = 400
|
||||
|
||||
# Multilingual embedding model with a long input window (8192 tokens), so chunks
|
||||
# are never truncated. Changing it requires rebuilding the index.
|
||||
@@ -34,7 +35,9 @@ PDF_LOADER = "pypdf"
|
||||
PROCESSED_DIR = "corpus_processed/data_split"
|
||||
# Prefix every chunk with author and title from the file name (Docling: plus section),
|
||||
# so questions like "according to Lehmann ..." can match. See docling_loader.chunk_header.
|
||||
CHUNK_HEADERS = True
|
||||
# Needed for Docling (which drops running heads); neutral to slightly harmful for pypdf,
|
||||
# whose pages carry the author in the running head anyway.
|
||||
CHUNK_HEADERS = False
|
||||
|
||||
# Retrieval / query tuning
|
||||
RETRIEVAL_K = 5
|
||||
@@ -75,7 +78,7 @@ class LocalRAG:
|
||||
vectorstore_path="./vectorstore",
|
||||
llm_provider="ollama",
|
||||
ollama_model="gpt-oss:20b",
|
||||
openai_model="gpt-5-mini",
|
||||
openai_model="gpt-6-luna",
|
||||
ollama_base_url="http://localhost:11434",
|
||||
pdf_loader=PDF_LOADER,
|
||||
processed_dir=PROCESSED_DIR,
|
||||
|
||||
Reference in New Issue
Block a user