# piyush314159/rag-evaluation-harness architecture

> Architecture diagram of the GitHub repository piyush314159/rag-evaluation-harness, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/piyush314159/rag-evaluation-harness
- Repository: https://github.com/piyush314159/rag-evaluation-harness

## Overview

RAGEval benchmarks TechQA retrieval and cited-answer generation, with a local RAG serving path. The main workflow prepares a document index offline, retrieves supporting sources for a question, builds and validates a cited answer, and can evaluate retrieval and generation against TechQA. The graph preserves benchmark tooling as a product capability. Relationships use README statements and SOURCE INDEX references; unsampled implementations and wiring are not assumed beyond those references.

Main entry points: [`src/rageval/retrieval/pipeline.py`](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/pipeline.py) (Retrieval dispatcher), [`src/rageval/generation/pipeline.py`](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/generation/pipeline.py) (Evidence and validation), [`scripts/evaluation/run_rag_pilot.py`](https://github.com/piyush314159/rag-evaluation-harness/blob/main/scripts/evaluation/run_rag_pilot.py) (Generation pilot), [`src/rageval/serving/api.py`](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/serving/api.py) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Offline ingestion"]
  node_corpus["Corpus loading<br/>[corpus.py]"]
  node_clean["Text cleaning<br/>[cleaning.py]"]
  node_passages["Passage splitting<br/>[passages.py]"]
  node_streaming["Batch streaming<br/>[streaming.py]"]
  node_indexing["Embedding indexing<br/>[indexing.py]"]
  node_chroma[("Chroma index store<br/>[chroma_store.py]")]
end

subgraph group_retrieve["Question retrieval"]
  node_retrieval["Retrieval dispatcher<br/>[pipeline.py]"]
  node_dense["Dense search<br/>[dense.py]"]
  node_chroma_search["Chroma search<br/>[chroma.py]"]
  node_bm25["BM25 ranking<br/>[bm25.py]"]
  node_fusion["Rank fusion<br/>[fusion.py]"]
  node_rerank["Result reranking<br/>[reranking.py]"]
  node_tokenization["Text tokenization<br/>[tokenization.py]"]
end

subgraph group_generate["Answer generation"]
  node_gen_pipeline["Evidence and validation<br/>[pipeline.py]"]
  node_prompt["Prompt construction<br/>[prompt.py]"]
  node_ollama["Ollama provider<br/>[ollama.py]"]
  node_gemini["Gemini provider<br/>[gemini.py]"]
end

subgraph group_eval["TechQA evaluation"]
  node_techqa["TechQA label audit<br/>[techqa.py]"]
  node_rag_eval["RAG evaluation<br/>[rag.py]"]
  node_reports["Report utilities<br/>[reports.py]"]
  node_hybrid_eval["Hybrid benchmark<br/>[evaluate_hybrid.py]"]
  node_qwen_eval["Qwen benchmark<br/>[evaluate_qwen.py]"]
  node_prompt_preview["Prompt preview"]
  node_pilot["Generation pilot<br/>[run_rag_pilot.py]"]
end

subgraph group_serve["Local serving"]
  node_api["HTTP API<br/>[api.py]"]
end

node_user(("Questioner"))
node_ollama_service["Local Ollama"]
node_gemini_service["Google Gemini"]
node_answer["Cited answer"]
node_techqa_data[("TechQA corpus and labels")]

node_techqa_data -->|"loads documents"| node_corpus
node_corpus -->|"normalizes text"| node_clean
node_clean -->|"splits documents"| node_passages
node_passages -->|"batches passages"| node_streaming
node_streaming -->|"encodes batches"| node_indexing
node_indexing -->|"writes vectors"| node_chroma
node_user -->|"asks question"| node_api
node_api -->|"requests sources"| node_retrieval
node_retrieval -->|"searches index"| node_chroma_search
node_retrieval -->|"encodes query"| node_dense
node_retrieval -->|"ranks passages"| node_bm25
node_retrieval -->|"fuses rankings"| node_fusion
node_chroma -->|"serves passages"| node_chroma_search
node_bm25 -->|"tokenizes terms"| node_tokenization
node_retrieval -->|"provides excerpts"| node_gen_pipeline
node_api -->|"builds response"| node_gen_pipeline
node_gen_pipeline -->|"prepares prompt"| node_prompt
node_gen_pipeline -->|"dispatches generation"| node_ollama
node_gen_pipeline -->|"dispatches generation"| node_gemini
node_ollama -->|"requests draft"| node_ollama_service
node_gemini -->|"requests draft"| node_gemini_service
node_gen_pipeline -->|"validates citations"| node_answer
node_api -->|"returns answer"| node_answer
node_techqa_data -->|"audits labels"| node_techqa
node_techqa -->|"selects benchmark cases"| node_qwen_eval
node_hybrid_eval -->|"reuses Qwen ranking"| node_qwen_eval
node_techqa -->|"loads saved questions"| node_prompt_preview
node_prompt_preview -->|"renders preview"| node_prompt
node_pilot -->|"loads pilot cases"| node_techqa
node_pilot -.->|"replays retrieval"| node_retrieval
node_pilot -->|"evaluates generation"| node_gen_pipeline
node_pilot -->|"writes results"| node_reports
node_rag_eval -->|"uses prompt format"| node_prompt

click node_corpus "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/corpus.py"
click node_clean "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/cleaning.py"
click node_passages "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/passages.py"
click node_streaming "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/streaming.py"
click node_indexing "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/indexing.py"
click node_chroma "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/chroma_store.py"
click node_retrieval "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/pipeline.py"
click node_dense "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/dense.py"
click node_chroma_search "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/chroma.py"
click node_bm25 "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/bm25.py"
click node_fusion "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/fusion.py"
click node_rerank "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/reranking.py"
click node_tokenization "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/tokenization.py"
click node_gen_pipeline "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/generation/pipeline.py"
click node_prompt "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/generation/prompt.py"
click node_ollama "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/generation/ollama.py"
click node_gemini "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/generation/gemini.py"
click node_techqa "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/evaluation/techqa.py"
click node_rag_eval "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/evaluation/rag.py"
click node_reports "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/evaluation/reports.py"
click node_hybrid_eval "https://github.com/piyush314159/rag-evaluation-harness/blob/main/scripts/evaluation/evaluate_hybrid.py"
click node_qwen_eval "https://github.com/piyush314159/rag-evaluation-harness/blob/main/scripts/evaluation/evaluate_qwen.py"
click node_prompt_preview "https://github.com/piyush314159/rag-evaluation-harness/blob/main/scripts/evaluation/build_rag_prompt.py"
click node_pilot "https://github.com/piyush314159/rag-evaluation-harness/blob/main/scripts/evaluation/run_rag_pilot.py"
click node_api "https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/serving/api.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_corpus,node_clean,node_passages,node_streaming,node_indexing,node_chroma toneBlue
class node_retrieval,node_dense,node_chroma_search,node_bm25,node_fusion,node_rerank,node_tokenization,node_techqa_data toneAmber
class node_gen_pipeline,node_prompt,node_ollama,node_gemini toneMint
class node_techqa,node_rag_eval,node_reports,node_hybrid_eval,node_qwen_eval,node_prompt_preview,node_pilot toneRose
class node_api,node_user,node_ollama_service,node_gemini_service,node_answer toneIndigo
```

## Components

### Offline ingestion

- [Corpus loading](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/corpus.py): `src/rageval/ingestion/corpus.py`
- [Text cleaning](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/cleaning.py): `src/rageval/ingestion/cleaning.py`
- [Passage splitting](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/passages.py): `src/rageval/ingestion/passages.py`
- [Batch streaming](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/streaming.py): `src/rageval/ingestion/streaming.py`
- [Embedding indexing](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/indexing.py): `src/rageval/ingestion/indexing.py`
- [Chroma index store](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/ingestion/chroma_store.py): `src/rageval/ingestion/chroma_store.py`

### Question retrieval

- [Retrieval dispatcher](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/pipeline.py): `src/rageval/retrieval/pipeline.py`
- [Dense search](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/dense.py): `src/rageval/retrieval/dense.py`
- [Chroma search](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/chroma.py): `src/rageval/retrieval/chroma.py`
- [BM25 ranking](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/bm25.py): `src/rageval/retrieval/bm25.py`
- [Rank fusion](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/fusion.py): `src/rageval/retrieval/fusion.py`
- [Result reranking](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/retrieval/reranking.py): `src/rageval/retrieval/reranking.py`
- [Text tokenization](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/tokenization.py): `src/rageval/tokenization.py`

### Answer generation

- [Evidence and validation](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/generation/pipeline.py): `src/rageval/generation/pipeline.py`
- [Prompt construction](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/generation/prompt.py): `src/rageval/generation/prompt.py`
- [Ollama provider](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/generation/ollama.py): `src/rageval/generation/ollama.py`
- [Gemini provider](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/generation/gemini.py): `src/rageval/generation/gemini.py`

### TechQA evaluation

- [TechQA label audit](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/evaluation/techqa.py): `src/rageval/evaluation/techqa.py`
- [RAG evaluation](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/evaluation/rag.py): `src/rageval/evaluation/rag.py`
- [Report utilities](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/evaluation/reports.py): `src/rageval/evaluation/reports.py`
- [Hybrid benchmark](https://github.com/piyush314159/rag-evaluation-harness/blob/main/scripts/evaluation/evaluate_hybrid.py): `scripts/evaluation/evaluate_hybrid.py`
- [Qwen benchmark](https://github.com/piyush314159/rag-evaluation-harness/blob/main/scripts/evaluation/evaluate_qwen.py): `scripts/evaluation/evaluate_qwen.py`
- [Prompt preview](https://github.com/piyush314159/rag-evaluation-harness/blob/main/scripts/evaluation/build_rag_prompt.py): `scripts/evaluation/build_rag_prompt.py`
- [Generation pilot](https://github.com/piyush314159/rag-evaluation-harness/blob/main/scripts/evaluation/run_rag_pilot.py): `scripts/evaluation/run_rag_pilot.py`

### Local serving

- [HTTP API](https://github.com/piyush314159/rag-evaluation-harness/blob/main/src/rageval/serving/api.py): `src/rageval/serving/api.py`

### Other components

- **Questioner**
- **Local Ollama**
- **Google Gemini**
- **Cited answer**
- **TechQA corpus and labels**

## Connections

- TechQA corpus and labels → Corpus loading: loads documents (evidence: `Readme.md`)
- Corpus loading → Text cleaning: normalizes text (evidence: `Readme.md`)
- Text cleaning → Passage splitting: splits documents (evidence: `Readme.md`)
- Passage splitting → Batch streaming: batches passages (evidence: `Readme.md`)
- Batch streaming → Embedding indexing: encodes batches (evidence: `Readme.md`)
- Embedding indexing → Chroma index store: writes vectors (evidence: `src/rageval/ingestion/indexing.py`)
- Questioner → HTTP API: asks question (evidence: `Readme.md`)
- HTTP API → Retrieval dispatcher: requests sources (evidence: `src/rageval/serving/api.py`)
- Retrieval dispatcher → Chroma search: searches index (evidence: `src/rageval/retrieval/pipeline.py`)
- Retrieval dispatcher → Dense search: encodes query (evidence: `src/rageval/retrieval/pipeline.py`)
- Retrieval dispatcher → BM25 ranking: ranks passages (evidence: `src/rageval/retrieval/pipeline.py`)
- Retrieval dispatcher → Rank fusion: fuses rankings (evidence: `src/rageval/retrieval/pipeline.py`)
- Chroma index store → Chroma search: serves passages (evidence: `src/rageval/retrieval/chroma.py`)
- BM25 ranking → Text tokenization: tokenizes terms (evidence: `src/rageval/retrieval/bm25.py`)
- Retrieval dispatcher → Evidence and validation: provides excerpts (evidence: `Readme.md`)
- HTTP API → Evidence and validation: builds response (evidence: `src/rageval/serving/api.py`)
- Evidence and validation → Prompt construction: prepares prompt (evidence: `src/rageval/generation/pipeline.py`)
- Evidence and validation → Ollama provider: dispatches generation (evidence: `src/rageval/generation/pipeline.py`)
- Evidence and validation → Gemini provider: dispatches generation (evidence: `src/rageval/generation/pipeline.py`)
- Ollama provider → Local Ollama: requests draft (evidence: `Readme.md`)
- Gemini provider → Google Gemini: requests draft (evidence: `Readme.md`)
- Evidence and validation → Cited answer: validates citations (evidence: `src/rageval/generation/pipeline.py`)
- HTTP API → Cited answer: returns answer (evidence: `Readme.md`)
- TechQA corpus and labels → TechQA label audit: audits labels (evidence: `src/rageval/evaluation/techqa.py`)
- TechQA label audit → Qwen benchmark: selects benchmark cases (evidence: `scripts/evaluation/evaluate_qwen.py`)
- Hybrid benchmark → Qwen benchmark: reuses Qwen ranking (evidence: `scripts/evaluation/evaluate_hybrid.py`)
- TechQA label audit → Prompt preview: loads saved questions (evidence: `scripts/evaluation/build_rag_prompt.py`)
- Prompt preview → Prompt construction: renders preview (evidence: `scripts/evaluation/build_rag_prompt.py`)
- Generation pilot → TechQA label audit: loads pilot cases (evidence: `scripts/evaluation/run_rag_pilot.py`)
- Generation pilot → Retrieval dispatcher: replays retrieval (evidence: `scripts/evaluation/run_rag_pilot.py`)
- Generation pilot → Evidence and validation: evaluates generation (evidence: `scripts/evaluation/run_rag_pilot.py`)
- Generation pilot → Report utilities: writes results (evidence: `scripts/evaluation/run_rag_pilot.py`)
- RAG evaluation → Prompt construction: uses prompt format (evidence: `src/rageval/evaluation/rag.py`)
