RKB109 commited on
Commit
bb6879d
·
verified ·
1 Parent(s): 582fbcb

Publish artifacts for rag-evaluation-lab-20260809

Browse files
Files changed (5) hide show
  1. README.md +61 -0
  2. evaluation.json +5 -0
  3. inference.py +80 -0
  4. model.json +222 -0
  5. project.json +52 -0
README.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: custom
4
+ pipeline_tag: text-classification
5
+ datasets:
6
+ - RKB109/rag-evaluation-lab-20260809-dataset
7
+ tags:
8
+ - synthetic-data
9
+ - transparent-baseline
10
+ - ai-evaluation
11
+ - text-classification
12
+ - question-answering
13
+ - text-ranking
14
+ - summarization
15
+ metrics:
16
+ - accuracy
17
+ ---
18
+
19
+ # RAG Evaluation Lab Baseline Model
20
+
21
+ ## Model Description
22
+
23
+ This repository contains a small, transparent prototype model for
24
+ **RAG systems often ship without a stable regression set or failure taxonomy.**
25
+
26
+ The model combines per-label token weights with IDF-weighted evidence
27
+ retrieval. It was generated for reproducible architecture demonstrations and
28
+ does not call a hosted LLM.
29
+
30
+ ## Evaluation
31
+
32
+ - Held-out synthetic examples: 4
33
+ - Accuracy: 0.75
34
+ - Intended metrics: failure_class_accuracy, citation_coverage, release_gate_pass_rate
35
+
36
+ ## Intended Use
37
+
38
+ - Architecture prototyping
39
+ - CI and evaluation examples
40
+ - Local baseline comparisons
41
+ - Educational experimentation
42
+
43
+ ## Hugging Face Task Coverage
44
+
45
+ - `text-classification`
46
+ - `question-answering`
47
+ - `text-ranking`
48
+ - `summarization`
49
+
50
+ ## Limitations and Risks
51
+
52
+ Synthetic cases validate the harness, not a production RAG system. Teams must add representative domain examples.
53
+
54
+ The dataset is synthetic and small. Do not use this model for consequential
55
+ decisions without representative data, expert review, and production-grade
56
+ evaluation.
57
+
58
+ ## Reproducibility
59
+
60
+ The linked GitHub repository includes `train.py`, the exact dataset split,
61
+ evaluation code, and the model JSON format.
evaluation.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "test_examples": 4,
3
+ "accuracy": 0.75,
4
+ "synthetic_evaluation": true
5
+ }
inference.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Transparent baseline pipeline for the generated AI project."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import math
7
+ import re
8
+ from pathlib import Path
9
+
10
+
11
+ def tokenize(value: str) -> list[str]:
12
+ return re.findall(r"[a-z0-9]+", value.lower())
13
+
14
+
15
+ class Pipeline:
16
+ def __init__(self, model: dict):
17
+ self.model = model
18
+
19
+ @classmethod
20
+ def from_file(cls, path: str | Path) -> "Pipeline":
21
+ return cls(json.loads(Path(path).read_text(encoding="utf-8")))
22
+
23
+ def classify(self, text: str) -> tuple[str, float]:
24
+ tokens = tokenize(text)
25
+ scores = {
26
+ label: sum(weights.get(token, 0) for token in tokens)
27
+ for label, weights in self.model["prototypes"].items()
28
+ }
29
+ ranked = sorted(scores.items(), key=lambda item: (-item[1], item[0]))
30
+ label, best = ranked[0]
31
+ total = sum(max(score, 0) for _, score in ranked) or 1
32
+ return label, best / total
33
+
34
+ def search(self, query: str, limit: int = 3) -> list[dict]:
35
+ query_tokens = set(tokenize(query))
36
+ ranked = []
37
+ for document in self.model["documents"]:
38
+ document_tokens = set(tokenize(document["text"]))
39
+ lexical = sum(
40
+ self.model["idf"].get(token, 1.0)
41
+ for token in query_tokens & document_tokens
42
+ )
43
+ ranked.append({**document, "score": round(lexical, 6)})
44
+ return sorted(ranked, key=lambda item: (-item["score"], item["id"]))[:limit]
45
+
46
+ def graph_evidence(self, text: str) -> list[dict]:
47
+ tokens = set(tokenize(text))
48
+ matches = []
49
+ for subject, relation, target in self.model.get("graph_edges", []):
50
+ edge_tokens = set(tokenize(f"{subject} {relation} {target}"))
51
+ overlap = len(tokens & edge_tokens)
52
+ if overlap:
53
+ matches.append(
54
+ {
55
+ "subject": subject,
56
+ "relation": relation,
57
+ "target": target,
58
+ "overlap": overlap,
59
+ }
60
+ )
61
+ return sorted(matches, key=lambda item: -item["overlap"])
62
+
63
+ def run(self, text: str) -> dict:
64
+ label, confidence = self.classify(text)
65
+ evidence = self.search(text)
66
+ result = {
67
+ "prediction": label,
68
+ "confidence": round(confidence, 4),
69
+ "requires_review": confidence < self.model["confidence_threshold"],
70
+ "evidence": evidence,
71
+ }
72
+ if self.model["mode"] == "graph":
73
+ result["graph_evidence"] = self.graph_evidence(text)
74
+ if self.model["mode"] == "agent":
75
+ result["proposed_tool"] = label
76
+ result["approval_required"] = label in {
77
+ "request-approval",
78
+ "request-human-help",
79
+ }
80
+ return result
model.json ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "daily-project-prototype-v1",
3
+ "project": "rag-evaluation",
4
+ "title": "RAG Evaluation Lab",
5
+ "domain": "ai-evaluation",
6
+ "mode": "classifier",
7
+ "labels": [
8
+ "retrieval-miss",
9
+ "unsupported-answer",
10
+ "citation-gap",
11
+ "abstention-error"
12
+ ],
13
+ "prototypes": {
14
+ "retrieval-miss": {
15
+ "the": 15,
16
+ "expected": 3,
17
+ "document": 3,
18
+ "never": 3,
19
+ "appeared": 3,
20
+ "in": 5,
21
+ "top": 3,
22
+ "results": 3,
23
+ "relevant": 6,
24
+ "evidence": 3,
25
+ "was": 3,
26
+ "absent": 3,
27
+ "from": 3,
28
+ "retrieved": 3,
29
+ "context": 3,
30
+ "an": 4,
31
+ "operations": 2,
32
+ "review": 2,
33
+ "for": 2,
34
+ "evaluation": 2,
35
+ "case": 2,
36
+ "ranking": 3,
37
+ "placed": 3,
38
+ "irrelevant": 3,
39
+ "policy": 3,
40
+ "above": 3,
41
+ "correct": 3,
42
+ "section": 3,
43
+ "item": 3,
44
+ "fell": 3,
45
+ "outside": 3,
46
+ "accepted": 3,
47
+ "retrieval": 3,
48
+ "window": 3
49
+ },
50
+ "unsupported-answer": {
51
+ "in": 4,
52
+ "an": 4,
53
+ "operations": 2,
54
+ "review": 2,
55
+ "the": 6,
56
+ "response": 4,
57
+ "makes": 2,
58
+ "a": 4,
59
+ "claim": 4,
60
+ "not": 2,
61
+ "present": 2,
62
+ "any": 2,
63
+ "source": 2,
64
+ "answer": 2,
65
+ "faithfulness": 2,
66
+ "failed": 2,
67
+ "despite": 2,
68
+ "available": 2,
69
+ "context": 2,
70
+ "for": 2,
71
+ "evaluation": 2,
72
+ "case": 2,
73
+ "invented": 2,
74
+ "product": 2,
75
+ "limit": 2,
76
+ "generated": 2,
77
+ "cannot": 2,
78
+ "be": 2,
79
+ "traced": 2,
80
+ "to": 2,
81
+ "retrieved": 2,
82
+ "evidence": 2
83
+ },
84
+ "citation-gap": {
85
+ "the": 2,
86
+ "answer": 4,
87
+ "is": 2,
88
+ "correct": 2,
89
+ "but": 2,
90
+ "has": 2,
91
+ "no": 2,
92
+ "source": 2,
93
+ "reference": 2,
94
+ "citation": 2,
95
+ "coverage": 2,
96
+ "failed": 2,
97
+ "for": 3,
98
+ "an": 3,
99
+ "otherwise": 2,
100
+ "supported": 2,
101
+ "evaluation": 1,
102
+ "case": 1
103
+ },
104
+ "abstention-error": {
105
+ "the": 4,
106
+ "system": 2,
107
+ "answered": 2,
108
+ "even": 2,
109
+ "though": 2,
110
+ "evidence": 2,
111
+ "was": 2,
112
+ "insufficient": 2,
113
+ "answer": 2,
114
+ "policy": 2,
115
+ "should": 2,
116
+ "have": 2,
117
+ "triggered": 2,
118
+ "abstention": 2,
119
+ "in": 1,
120
+ "an": 1,
121
+ "operations": 1,
122
+ "review": 1
123
+ }
124
+ },
125
+ "idf": {
126
+ "relevant": 1.847298,
127
+ "evidence": 1.847298,
128
+ "was": 2.252763,
129
+ "absent": 2.252763,
130
+ "from": 2.252763,
131
+ "retrieved": 1.847298,
132
+ "context": 1.847298,
133
+ "answer": 1.559616,
134
+ "faithfulness": 2.252763,
135
+ "failed": 1.847298,
136
+ "despite": 2.252763,
137
+ "available": 2.252763,
138
+ "citation": 2.252763,
139
+ "coverage": 2.252763,
140
+ "for": 2.252763,
141
+ "an": 2.252763,
142
+ "otherwise": 2.252763,
143
+ "supported": 2.252763,
144
+ "the": 1.559616,
145
+ "policy": 2.252763,
146
+ "should": 2.252763,
147
+ "have": 2.252763,
148
+ "triggered": 2.252763,
149
+ "abstention": 2.252763,
150
+ "item": 2.252763,
151
+ "fell": 2.252763,
152
+ "outside": 2.252763,
153
+ "accepted": 2.252763,
154
+ "retrieval": 2.252763,
155
+ "window": 2.252763,
156
+ "generated": 2.252763,
157
+ "claim": 2.252763,
158
+ "cannot": 2.252763,
159
+ "be": 2.252763,
160
+ "traced": 2.252763,
161
+ "to": 2.252763
162
+ },
163
+ "documents": [
164
+ {
165
+ "id": "eval-01",
166
+ "label": "retrieval-miss",
167
+ "text": "Relevant evidence was absent from retrieved context.",
168
+ "metadata": {
169
+ "synthetic": true,
170
+ "domain": "ai-evaluation"
171
+ }
172
+ },
173
+ {
174
+ "id": "eval-02",
175
+ "label": "unsupported-answer",
176
+ "text": "Answer faithfulness failed despite available context.",
177
+ "metadata": {
178
+ "synthetic": true,
179
+ "domain": "ai-evaluation"
180
+ }
181
+ },
182
+ {
183
+ "id": "eval-03",
184
+ "label": "citation-gap",
185
+ "text": "Citation coverage failed for an otherwise supported answer.",
186
+ "metadata": {
187
+ "synthetic": true,
188
+ "domain": "ai-evaluation"
189
+ }
190
+ },
191
+ {
192
+ "id": "eval-04",
193
+ "label": "abstention-error",
194
+ "text": "The answer policy should have triggered abstention.",
195
+ "metadata": {
196
+ "synthetic": true,
197
+ "domain": "ai-evaluation"
198
+ }
199
+ },
200
+ {
201
+ "id": "eval-05",
202
+ "label": "retrieval-miss",
203
+ "text": "The relevant item fell outside the accepted retrieval window.",
204
+ "metadata": {
205
+ "synthetic": true,
206
+ "domain": "ai-evaluation"
207
+ }
208
+ },
209
+ {
210
+ "id": "eval-06",
211
+ "label": "unsupported-answer",
212
+ "text": "The generated claim cannot be traced to retrieved evidence.",
213
+ "metadata": {
214
+ "synthetic": true,
215
+ "domain": "ai-evaluation"
216
+ }
217
+ }
218
+ ],
219
+ "graph_edges": [],
220
+ "confidence_threshold": 0.18,
221
+ "trained_on_synthetic_data": true
222
+ }
project.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "RAG Evaluation Lab",
3
+ "problem": "RAG systems often ship without a stable regression set or failure taxonomy.",
4
+ "domain": "ai-evaluation",
5
+ "architecture": "classifier",
6
+ "hugging_face_tasks": [
7
+ "text-classification",
8
+ "question-answering",
9
+ "text-ranking",
10
+ "summarization"
11
+ ],
12
+ "recommended_stack": [
13
+ "FastAPI for evaluation jobs and reports",
14
+ "Ragas-style retrieval and faithfulness metrics",
15
+ "MLflow for experiment and artifact tracking",
16
+ "PostgreSQL for versioned evaluation cases",
17
+ "OpenTelemetry plus Phoenix for trace inspection",
18
+ "GitHub Actions for threshold-based release gates"
19
+ ],
20
+ "real_world_data_sources": [
21
+ {
22
+ "name": "GitHub REST API",
23
+ "url": "https://api.github.com/repos/huggingface/transformers/issues?state=open&per_page=5",
24
+ "purpose": "Real technical questions for evaluation-set construction"
25
+ },
26
+ {
27
+ "name": "arXiv API",
28
+ "url": "https://export.arxiv.org/api/query?search_query=all:retrieval%20augmented%20generation&start=0&max_results=5",
29
+ "purpose": "Public RAG literature for grounded-answer cases"
30
+ }
31
+ ],
32
+ "job_description_skills": [
33
+ "LLM and RAG evaluation design",
34
+ "Golden datasets and failure taxonomies",
35
+ "Experiment tracking and model release gates",
36
+ "Trace-level diagnosis and prompt regression testing",
37
+ "Statistical comparison of AI system versions"
38
+ ],
39
+ "impact_targets": [
40
+ "Detect 100% of seeded unsupported-answer regressions",
41
+ "Track retrieval, faithfulness, citation, latency, and cost metrics",
42
+ "Fail CI when any critical metric drops beyond tolerance",
43
+ "Produce comparable evaluation reports for every model version"
44
+ ],
45
+ "baseline_evaluation": {
46
+ "test_examples": 4,
47
+ "accuracy": 0.75,
48
+ "synthetic_evaluation": true
49
+ },
50
+ "estimated_delivery": "8-12 weeks for one engineer",
51
+ "generated_baseline_is_production_ready": false
52
+ }