Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: cc-by-4.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# Refusal Classifier Model
|
| 6 |
+
|
| 7 |
+
A simple NLP model for classifying text responses as either `refusal` or `valid`.
|
| 8 |
+
|
| 9 |
+
## 🧠What It Does
|
| 10 |
+
|
| 11 |
+
This model predicts whether a given response from an LLM is:
|
| 12 |
+
- **refusal** – e.g., "I'm sorry, but I can't help with that."
|
| 13 |
+
- **valid** – e.g., "'I can't remember,' she said quietly."
|
| 14 |
+
|
| 15 |
+
Useful for detecting AI refusals and filtering them during generation.
|
| 16 |
+
|
| 17 |
+
## 📚 Training Details
|
| 18 |
+
|
| 19 |
+
- Built using **scikit-learn** with:
|
| 20 |
+
- `TfidfVectorizer` (1–2 n-grams, lowercase)
|
| 21 |
+
- `LogisticRegression`
|
| 22 |
+
- Trained on a small dataset of human-labeled examples (refusal/valid pairs)
|
| 23 |
+
- Dataset stored in `dataset.jsonl` with format:
|
| 24 |
+
```json
|
| 25 |
+
{"text": "The capital of France is Paris.", "label": "valid"}
|
| 26 |
+
```
|
| 27 |
+
## 🚀 How to Use
|
| 28 |
+
|
| 29 |
+
1. Install requirements
|
| 30 |
+
``` bash
|
| 31 |
+
pip install scikit-learn joblib
|
| 32 |
+
```
|
| 33 |
+
3. Load the model
|
| 34 |
+
``` bash
|
| 35 |
+
import joblib
|
| 36 |
+
joblib.load("refusal_classifier.pkl")
|
| 37 |
+
```
|
| 38 |
+
3. Make a prediction
|
| 39 |
+
``` python
|
| 40 |
+
text = "I'm sorry, but I can't help with that."
|
| 41 |
+
label = model.predict([text])[0]
|
| 42 |
+
print(label) # "refusal"
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## 📄 License
|
| 46 |
+
Licensed under CC BY 4.0: you may use this commercially or privately, but must include attribution in code or documentation.
|