Siddh12334 commited on
Commit
40b1abb
·
1 Parent(s): 67601e4

chore: add HF Space frontmatter and README draft

Browse files
Files changed (1) hide show
  1. README.md +87 -4
README.md CHANGED
@@ -1,10 +1,93 @@
1
  ---
2
  title: Context Corruption Env
3
- emoji: 📊
4
- colorFrom: gray
5
- colorTo: blue
6
  sdk: docker
 
7
  pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: Context Corruption Env
3
+ emoji: 🔍
4
+ colorFrom: blue
5
+ colorTo: purple
6
  sdk: docker
7
+ app_port: 7860
8
  pinned: false
9
+ license: mit
10
  ---
11
 
12
+ # ContextCorruption-Env
13
+
14
+ > OpenEnv Hackathon | Meta × HuggingFace × PyTorch
15
+
16
+ An RL environment for training **epistemic robustness** in LLMs — teaching models to identify corrupted documents and resist misleading retrieved context.
17
+
18
+ ## The Problem
19
+
20
+ LLMs fine-tuned with RLHF increasingly defer to retrieved documents even when those documents contradict the model's own (correct) parametric knowledge. Standard retrieval-augmented generation makes this worse. We train a model to cross-reference claims, flag corrupted sources, and answer from reliable knowledge.
21
+
22
+ ## The Environment
23
+
24
+ - **8 documents** per episode, 1–4 deliberately corrupted
25
+ - **4 corruption levels**: number mutation → entity swap → semantic inversion → coherent fabrication
26
+ - **450 QA facts** from Natural Questions + PopQA
27
+ - **Deterministic reward**, no LLM judge
28
+
29
+ ### Reward Signal
30
+
31
+ | Component | Logic | Weight |
32
+ |---|---|---|
33
+ | Answer correctness | Exact match after normalisation | +0.40 |
34
+ | Corruption detection recall | Fraction of corrupt docs flagged | +0.30 |
35
+ | Precision (no false flags) | −0.1 per false positive, floor 0 | +0.20 |
36
+ | Confidence calibration | +0.1×conf if correct, −0.2×conf if wrong | ±0.10 |
37
+ | Efficiency bonus | Budget not wasted | +0.05 |
38
+
39
+ **Range:** −0.5 to 1.05 · **Random baseline:** avg 0.1302
40
+
41
+ ## Results
42
+
43
+ | Agent | Avg Reward | Answer Acc | Corruption Detection |
44
+ |---|---|---|---|
45
+ | Random baseline | 0.1302 | ~0% | ~25% |
46
+ | Qwen2-1.5B GRPO | _after training_ | — | — |
47
+
48
+ ## Training
49
+
50
+ ```bash
51
+ # Colab (A100 recommended)
52
+ # Open training/ContextCorruption_GRPO.ipynb
53
+ ```
54
+
55
+ Training script: [`training/train_grpo.py`](training/train_grpo.py)
56
+ Notebook: [`training/ContextCorruption_GRPO.ipynb`](training/ContextCorruption_GRPO.ipynb)
57
+
58
+ ## Links
59
+
60
+ - **HF Space (env server):** https://huggingface.co/spaces/Siddh12334/context-corruption-env
61
+ - **Colab notebook:** _add link after training_
62
+ - **WandB run:** _add link after training_
63
+ - **Blog post:** _add link_
64
+
65
+ ## Quick Start
66
+
67
+ ```python
68
+ from openenv.core import SyncEnvClient
69
+
70
+ client = SyncEnvClient(base_url="https://Siddh12334-context-corruption-env.hf.space")
71
+ obs = client.reset()
72
+ print(obs["question"])
73
+ ```
74
+
75
+ ## Repo Structure
76
+
77
+ ```
78
+ environment/ # OpenEnv-compliant env (actions, reward, env, server)
79
+ data/ # QA loader, corruption functions, document generator
80
+ training/ # GRPO training script + Colab notebook
81
+ eval/ # Baseline evaluation
82
+ assets/ # reward_curve.png, loss_curve.png (after training)
83
+ ```
84
+
85
+ ## Citation
86
+
87
+ ```bibtex
88
+ @misc{contextcorruption2026,
89
+ title={ContextCorruption-Env: Training Epistemic Robustness in LLMs},
90
+ year={2026},
91
+ note={OpenEnv Hackathon Submission}
92
+ }
93
+ ```