Update model card with YAML frontmatter and two-stage pipeline example
Browse files
README.md
CHANGED
|
@@ -157,14 +157,29 @@ probs = 1 / (1 + np.exp(-logits)) # Sigmoid for multi-label
|
|
| 157 |
|
| 158 |
### Two-Stage Pipeline
|
| 159 |
|
|
|
|
|
|
|
| 160 |
```python
|
| 161 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
-
result = pipeline.analyze("Text to analyze...")
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
```
|
| 169 |
|
| 170 |
## Calibration Config
|
|
|
|
| 157 |
|
| 158 |
### Two-Stage Pipeline
|
| 159 |
|
| 160 |
+
For best results, use with the binary detector:
|
| 161 |
+
|
| 162 |
```python
|
| 163 |
+
from transformers import pipeline
|
| 164 |
+
|
| 165 |
+
# Stage 1: Binary detection (fast filter)
|
| 166 |
+
detector = pipeline("text-classification", model="synapti/nci-binary-detector")
|
| 167 |
+
|
| 168 |
+
# Stage 2: Technique classification
|
| 169 |
+
classifier = pipeline("text-classification", model="synapti/nci-technique-classifier", top_k=None)
|
| 170 |
|
| 171 |
+
text = "Your text to analyze..."
|
|
|
|
| 172 |
|
| 173 |
+
# Quick check first
|
| 174 |
+
detection = detector(text)[0]
|
| 175 |
+
if detection["label"] == "has_propaganda" and detection["score"] > 0.5:
|
| 176 |
+
# Detailed technique analysis
|
| 177 |
+
techniques = classifier(text)[0]
|
| 178 |
+
detected = [t for t in techniques if t["score"] > 0.3]
|
| 179 |
+
for t in detected:
|
| 180 |
+
print(f"{t['label']}: {t['score']:.2%}")
|
| 181 |
+
else:
|
| 182 |
+
print("No propaganda detected")
|
| 183 |
```
|
| 184 |
|
| 185 |
## Calibration Config
|