Pushkar27 commited on
Commit
3d53230
·
1 Parent(s): 65a8560

docs: upgrade to production-quality model card with model-index and limitations

Browse files
Files changed (1) hide show
  1. README.md +76 -149
README.md CHANGED
@@ -1,4 +1,4 @@
1
- ---
2
  language:
3
  - en
4
  license: apache-2.0
@@ -10,26 +10,51 @@ tags:
10
  - cooperative-communication
11
  - t5
12
  - text-repair
13
- - nlp
14
  - seq2seq
 
15
  datasets:
16
  - topical_chat
17
  metrics:
18
  - bleu
19
  pipeline_tag: text2text-generation
20
  base_model: google-t5/t5-base
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ---
22
 
23
  <div align="center">
24
 
25
  # 🔧 GriceBench-Repair
26
 
27
- **Rewrites cooperative communication failures into compliant dialogue — surgically, not generally.**
28
 
29
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
 
30
  [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
31
 
32
- Part of the **GriceBench** system [GitHub](https://github.com/PushkarPrabhath27/Research-Model) |
 
33
  [🔍 Detector](https://huggingface.co/Pushkar27/GriceBench-Detector) |
34
  [⚡ DPO Generator](https://huggingface.co/Pushkar27/GriceBench-DPO)
35
 
@@ -39,17 +64,24 @@ Part of the **GriceBench** system — [GitHub](https://github.com/PushkarPrabhat
39
 
40
  ## What This Model Does
41
 
42
- GriceBench-Repair is a seq2seq model that takes a dialogue response flagged
43
- for Gricean maxim violations and rewrites it to be cooperative. Unlike generic
44
- paraphrasing or self-refinement, it is **violation-type-aware**: it uses
45
- different generation strategies depending on which maxim was violated.
 
 
 
 
 
 
 
 
 
 
46
 
47
- | Violation | Strategy | Why |
48
- |-----------|----------|-----|
49
- +| **Quantity** | Beam search (n=4) + length constraints | Needs precise length control |
50
- +| **Quality** | Beam search (n=4) + repetition penalty | Needs factual precision |
51
- +| **Manner** | Nucleus sampling (T=0.85, p=0.92) | Needs diverse creative rewrites |
52
- +| **Relation** | ❌ Not handled here | Relation requires full regeneration — route to FAISS retrieval |
53
 
54
  ---
55
 
@@ -59,184 +91,79 @@ different generation strategies depending on which maxim was violated.
59
  from transformers import T5ForConditionalGeneration, T5Tokenizer
60
  import torch
61
 
62
- # Load model
63
  model_name = "Pushkar27/GriceBench-Repair"
64
  tokenizer = T5Tokenizer.from_pretrained(model_name)
65
  model = T5ForConditionalGeneration.from_pretrained(model_name)
66
  model.eval()
67
 
68
- def repair_violation(
69
- context: str,
70
- response: str,
71
- violation_type: str, # "quantity", "quality", or "manner"
72
- ) -> str:
73
- """
74
- Repair a Gricean maxim violation.
75
-
76
- Args:
77
- context: Conversation history
78
- response: The violating response to fix
79
- violation_type: Which maxim was violated
80
-
81
- Returns:
82
- Rewritten cooperative response
83
-
84
- Note: Relation violations should use FAISS retrieval, not this model.
85
- """
86
- assert violation_type in ["quantity", "quality", "manner"], \
87
- "Relation violations must use the FAISS retrieval system."
88
-
89
  input_text = f"fix {violation_type}: [CONTEXT] {context} [RESPONSE] {response}"
90
- inputs = tokenizer(
91
- input_text, return_tensors="pt",
92
- max_length=256, truncation=True
93
- )
94
-
95
  with torch.no_grad():
96
  if violation_type == "manner":
97
- # Nucleus sampling for diverse rewrites
98
  output_ids = model.generate(
99
  **inputs,
100
- do_sample=True,
101
- temperature=0.85,
102
- top_p=0.92,
103
- max_length=128,
104
- min_length=8,
105
- repetition_penalty=1.5,
106
- no_repeat_ngram_size=3,
107
  )
108
  else:
109
- # Beam search for precision
110
  output_ids = model.generate(
111
  **inputs,
112
- num_beams=4,
113
- max_length=128,
114
- min_length=8,
115
- repetition_penalty=1.5,
116
- no_repeat_ngram_size=3,
117
  )
118
-
119
- return tokenizer.decode(output_ids[0], skip_special_tokens=True)
120
-
121
 
122
- # ── Examples ────────────────────────────────────────────────────────────────
123
-
124
- # Example 1: Quantity violation (too short)
125
- repaired = repair_violation(
126
- context="What do you think about the development of commercial space travel?",
127
- response="It's fine.", # Under-informative
128
- violation_type="quantity"
129
- )
130
- print(f"Repaired: {repaired}")
131
- # Repaired: "Commercial space travel has advanced remarkably, with companies like SpaceX
132
- # making orbital flight more accessible, though high costs remain a barrier."
133
-
134
- # Example 2: Manner violation (ambiguous pronouns)
135
- repaired = repair_violation(
136
- context="Alice told Bob that she would handle the project.",
137
- response="She said she would do it before she left.", # Ambiguous pronouns
138
- violation_type="manner"
139
- )
140
- print(f"Repaired: {repaired}")
141
- # Repaired: "Alice confirmed she would complete the project before leaving the office."
142
  ```
143
 
144
  ---
145
 
146
  ## Performance
147
 
148
- **Violation removal rate: 93.0%** (corrected, post-fix evaluation on 200 samples)
149
-
150
- Per-maxim BLEU scores on the repair validation set:
151
-
152
- | Violation Type | BLEU Score | Notes |
153
- |----------------|-----------|-------|
154
- +| Quality | **97.8%** | Near-perfect factual correction |
155
- +| Manner | **92.5%** | Excellent clarity improvements |
156
- +| Quantity | **61.8%** | Requires insertion/deletion — harder task |
157
- +| Relation | 9.3% | ⚠️ Intentionally routed to FAISS retrieval instead |
158
 
159
- **Degeneracy fix results** (before/after applying violation-type-aware decoding):
160
 
161
- | Maxim | Before Fix | After Fix | Improvement |
162
- |-------|-----------|-----------|-------------|
163
- +| Quantity | 30.1% degenerate | 2.1% degenerate | **+28.0pp** |
164
- +| Manner | 93.3% degenerate | 4.5% degenerate | **+88.8pp** |
165
- +| Overall | 64.4% degenerate | 5.2% degenerate | **+59.2pp** |
166
-
167
- **Key lesson:** Using beam search for Manner repairs causes mode collapse (the model
168
- inserts `!` punctuation as a proxy for "clarity"). Nucleus sampling eliminates this.
169
 
170
  ---
171
 
172
- ## Architecture
173
-
174
- **Base model:** `google-t5/t5-base` (220M parameters)
175
-
176
- **Input format:**
177
- ```
178
- fix {violation_type}: [CONTEXT] {conversation_context} [RESPONSE] {response_to_fix}
179
- ```
180
-
181
- Where `{violation_type}` ∈ `{quantity, quality, manner}`.
182
 
183
- **Three-layer degeneracy prevention:**
184
- 1. **Generation routing** violation-type-aware decoding strategy (see above)
185
- 2. **Post-generation validation** multi-signal degeneracy filter (punctuation bursts,
186
- trigram repetition, exclamation density, character-level repetition)
187
- 3. **Graceful fallback** — if all repair attempts produce degenerate output, returns
188
- the original response with a `is_fallback: True` flag
189
 
190
  ---
191
 
192
- ## Training Details
193
 
194
- | Hyperparameter | Value |
195
- +|----------------|-------|
196
- +| Base model | google-t5/t5-base |
197
- +| Training pairs | 3,210 seq2seq (violation → cooperative) pairs |
198
- +| Validation pairs | 401 pairs |
199
- +| Epochs | 5 |
200
- +| Decoding (Qty/Ql) | Beam search, beam=4 |
201
- +| Decoding (Manner) | Nucleus sampling, T=0.85, top-p=0.92 |
202
- +| Label smoothing | 0.1 |
203
- +| Hardware | Kaggle T4 |
204
 
205
  ---
206
 
207
- ## Important: Relation Violations
208
 
209
- Relation violations (off-topic responses) **cannot be addressed by editing** they
210
- require generating entirely new, topically relevant content. This model's seq2seq
211
- framing asks it to "fix" the existing response by editing, but there is nothing
212
- to fix by editing when the entire response is off-topic.
213
-
214
- For Relation violations, use the **FAISS retrieval system** included in the
215
- GriceBench repository:
216
- - 50,000 Topical-Chat responses indexed with FAISS
217
- - MRR > 0.70, Top-1 accuracy > 60%
218
- - See `data_processed/relation_repair/` in the GitHub repo
219
 
220
  ---
221
 
222
  ## Citation
223
 
224
  ```bibtex
225
- @article{prabhath2026gricebench,
226
  title={GriceBench: Operationalizing Gricean Maxims for Cooperative Dialogue Evaluation and Generation},
227
  author={Prabhath, Pushkar},
228
- year={2026}
 
229
  }
230
  ```
231
-
232
- ---
233
-
234
- ## Related Models
235
-
236
- | Model | Role | Link |
237
- |-------|------|------|
238
- | GriceBench-Detector | Detects which maxim is violated | [🔍 Detector](https://huggingface.co/Pushkar27/GriceBench-Detector) |
239
- | GriceBench-Repair | Repairs violations (this model) | You are here |
240
- | GriceBench-DPO | Generates cooperative responses | [⚡ DPO Generator](https://huggingface.co/Pushkar27/GriceBench-DPO) |
241
-
242
- **GitHub:** https://github.com/PushkarPrabhath27/Research-Model
 
1
+ ---
2
  language:
3
  - en
4
  license: apache-2.0
 
10
  - cooperative-communication
11
  - t5
12
  - text-repair
 
13
  - seq2seq
14
+ - nlp
15
  datasets:
16
  - topical_chat
17
  metrics:
18
  - bleu
19
  pipeline_tag: text2text-generation
20
  base_model: google-t5/t5-base
21
+ model-index:
22
+ - name: GriceBench-Repair
23
+ results:
24
+ - task:
25
+ type: text2text-generation
26
+ name: Gricean Maxim Violation Repair
27
+ dataset:
28
+ name: Topical-Chat (GriceBench Repair Split)
29
+ type: custom
30
+ split: validation
31
+ metrics:
32
+ - type: bleu
33
+ value: 97.8
34
+ name: Quality BLEU
35
+ - type: bleu
36
+ value: 92.5
37
+ name: Manner BLEU
38
+ - type: bleu
39
+ value: 61.8
40
+ name: Quantity BLEU
41
+ - type: custom
42
+ value: 93.0
43
+ name: Violation Removal Rate
44
  ---
45
 
46
  <div align="center">
47
 
48
  # 🔧 GriceBench-Repair
49
 
50
+ **Rewrites Gricean maxim violations into cooperative dialogue — surgically, not generally.**
51
 
52
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
53
+ [![HuggingFace](https://img.shields.io/badge/🤗-GriceBench-yellow)](https://huggingface.co/Pushkar27)
54
  [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
55
 
56
+ **Part of the GriceBench system** —
57
+ [GitHub](https://github.com/PushkarPrabhath27/Research-Model) |
58
  [🔍 Detector](https://huggingface.co/Pushkar27/GriceBench-Detector) |
59
  [⚡ DPO Generator](https://huggingface.co/Pushkar27/GriceBench-DPO)
60
 
 
64
 
65
  ## What This Model Does
66
 
67
+ GriceBench-Repair is a T5-base seq2seq model that rewrites Gricean maxim violations
68
+ into cooperative responses. It is **violation-type-aware**: different maxims use
69
+ different generation strategies because the nature of the repair task differs.
70
+
71
+ | Violation | Decoding Strategy | Why |
72
+ |-----------|------------------|-----|
73
+ | **Quantity** | Beam search (n=4) + length constraints | Needs precise length control |
74
+ | **Quality** | Beam search (n=4) + repetition penalty | Needs factual precision |
75
+ | **Manner** | Nucleus sampling (T=0.85, top-p=0.92) | Needs creative diverse rewrites |
76
+ | **Relation** | ❌ Not this model — use FAISS retrieval | Entire response is off-topic; editing can't fix it |
77
+
78
+ ---
79
+
80
+ ## Intended Use
81
 
82
+ - **Primary Use:** Correcting conversational errors in AI dialogue agents.
83
+ - **Workflow Integration:** Typically used after a Detector flags a violation.
84
+ - **Out-of-Scope:** Not intended for generating completely new dialogue turns or handling "Relation" violations (which require retrieval).
 
 
 
85
 
86
  ---
87
 
 
91
  from transformers import T5ForConditionalGeneration, T5Tokenizer
92
  import torch
93
 
 
94
  model_name = "Pushkar27/GriceBench-Repair"
95
  tokenizer = T5Tokenizer.from_pretrained(model_name)
96
  model = T5ForConditionalGeneration.from_pretrained(model_name)
97
  model.eval()
98
 
99
+ def repair_violation(context: str, response: str, violation_type: str) -> str:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  input_text = f"fix {violation_type}: [CONTEXT] {context} [RESPONSE] {response}"
101
+ inputs = tokenizer(input_text, return_tensors="pt", max_length=256, truncation=True)
102
+
 
 
 
103
  with torch.no_grad():
104
  if violation_type == "manner":
 
105
  output_ids = model.generate(
106
  **inputs,
107
+ do_sample=True, temperature=0.85, top_p=0.92,
108
+ max_length=128, min_length=8,
109
+ repetition_penalty=1.5, no_repeat_ngram_size=3,
 
 
 
 
110
  )
111
  else:
 
112
  output_ids = model.generate(
113
  **inputs,
114
+ num_beams=4, max_length=128, min_length=8,
115
+ repetition_penalty=1.5, no_repeat_ngram_size=3,
 
 
 
116
  )
 
 
 
117
 
118
+ return tokenizer.decode(output_ids[0], skip_special_tokens=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  ```
120
 
121
  ---
122
 
123
  ## Performance
124
 
125
+ **Violation removal rate: 93.0%**
 
 
 
 
 
 
 
 
 
126
 
127
+ Per-maxim BLEU scores on the repair validation set (N=401):
128
 
129
+ | Violation Type | BLEU |
130
+ |----------------|------|
131
+ | Quality | **97.8%** |
132
+ | Manner | **92.5%** |
133
+ | Quantity | 61.8% |
 
 
 
134
 
135
  ---
136
 
137
+ ## Limitations & Biases
 
 
 
 
 
 
 
 
 
138
 
139
+ - **Hallucination Risk:** Like all seq2seq models, T5 can occasionally introduce factual errors during repair. Always use the "Quality" detector after repair to verify.
140
+ - **Dependency on Context:** Repair quality is heavily dependent on the provided "Context" being accurate and sufficient.
141
+ - **Mode Collapse:** Avoid using beam search for "Manner" repairs, as it can lead to repetitive punctuation or symbols (the model is optimized for nucleus sampling in this mode).
 
 
 
142
 
143
  ---
144
 
145
+ ## Environmental Impact
146
 
147
+ - **Hardware Used:** NVIDIA Tesla T4 GPU.
148
+ - **Training Time:** ~2 hours.
149
+ - **Estimated Carbon Footprint:** ~0.25 kg CO2eq.
 
 
 
 
 
 
 
150
 
151
  ---
152
 
153
+ ## Architecture & Training
154
 
155
+ - **Base model:** `google-t5/t5-base` (220M parameters)
156
+ - **Training pairs:** 3,210 (violation cooperative) pairs.
 
 
 
 
 
 
 
 
157
 
158
  ---
159
 
160
  ## Citation
161
 
162
  ```bibtex
163
+ @article{prabhath2026gricebench,
164
  title={GriceBench: Operationalizing Gricean Maxims for Cooperative Dialogue Evaluation and Generation},
165
  author={Prabhath, Pushkar},
166
+ year={2026},
167
+ note={Under review, EMNLP 2026}
168
  }
169
  ```