Text Generation
Transformers
Safetensors
English
t5
text2text-generation
dialogue
gricean-maxims
cooperative-communication
text-repair
seq2seq
nlp
Eval Results (legacy)
text-generation-inference
Instructions to use Pushkar27/GriceBench-Repair with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Pushkar27/GriceBench-Repair with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Pushkar27/GriceBench-Repair")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Pushkar27/GriceBench-Repair") model = AutoModelForSeq2SeqLM.from_pretrained("Pushkar27/GriceBench-Repair") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Pushkar27/GriceBench-Repair with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Pushkar27/GriceBench-Repair" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Pushkar27/GriceBench-Repair", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Pushkar27/GriceBench-Repair
- SGLang
How to use Pushkar27/GriceBench-Repair with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Pushkar27/GriceBench-Repair" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Pushkar27/GriceBench-Repair", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Pushkar27/GriceBench-Repair" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Pushkar27/GriceBench-Repair", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Pushkar27/GriceBench-Repair with Docker Model Runner:
docker model run hf.co/Pushkar27/GriceBench-Repair
docs: upgrade to production-quality model card with model-index and limitations
Browse files
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
|
| 28 |
|
| 29 |
[](https://opensource.org/licenses/Apache-2.0)
|
|
|
|
| 30 |
[](https://www.python.org/downloads/)
|
| 31 |
|
| 32 |
-
Part of the
|
|
|
|
| 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
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 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 |
-
|
| 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 |
-
|
| 102 |
-
|
| 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 |
-
|
| 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 |
-
|
| 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%**
|
| 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 |
-
|
| 160 |
|
| 161 |
-
|
|
| 162 |
-
|-------
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 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 |
-
##
|
| 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 |
-
**
|
| 184 |
-
|
| 185 |
-
|
| 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 |
-
##
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 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 |
-
##
|
| 208 |
|
| 209 |
-
|
| 210 |
-
|
| 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 |
[](https://opensource.org/licenses/Apache-2.0)
|
| 53 |
+
[](https://huggingface.co/Pushkar27)
|
| 54 |
[](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 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|