ProBERT-1.0 / QUICKSTART.md
collapseindex's picture
Upload 11 files
14a0518 verified
```python
# ProBERT Quick Inference Example
# Zero dependencies beyond transformers + torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
# Load frozen model
model = AutoModelForSequenceClassification.from_pretrained("collapseindex/ProBERT-1.0")
tokenizer = AutoTokenizer.from_pretrained("collapseindex/ProBERT-1.0")
def score_text(text: str) -> dict:
"""Score text for rhetorical patterns"""
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)[0]
labels = ["process_clarity", "rhetorical_confidence", "scope_blur"]
scores_dict = {label: float(probs[i]) for i, label in enumerate(labels)}
prediction = labels[torch.argmax(probs).item()]
# Confidence: max probability
confidence = float(probs.max())
# Coherence: margin between top 2 predictions (lower = less clear decision)
sorted_probs = torch.sort(probs, descending=True)[0]
coherence = float(sorted_probs[0] - sorted_probs[1])
return {
**scores_dict,
"prediction": prediction,
"confidence": confidence,
"coherence": coherence
}
# Test examples
examples = [
"This revolutionary AI will transform your business and guarantee results.",
"To implement binary search: 1. Define left and right pointers. 2. Calculate mid. 3. Compare value. If less, move right pointer.",
"Trust your intuition and embrace the cosmic energy flowing through all things.",
]
for text in examples:
scores = score_text(text)
print(f"\nText: {text[:60]}...")
print(f"Prediction: {scores['prediction']}")
print(f" • Process Clarity: {scores['process_clarity']:.1%}")
print(f" • Rhetorical Confidence: {scores['rhetorical_confidence']:.1%}")
print(f" • Scope Blur: {scores['scope_blur']:.1%}")
print(f"Confidence: {scores['confidence']:.1%}")
print(f"Coherence: {scores['coherence']:.1%} (decision clarity)")
```
**Output Example:**
```
Text: This revolutionary AI will transform your business and guarantee r...
Prediction: rhetorical_confidence
• Process Clarity: 11.5%
• Rhetorical Confidence: 67.2%
• Scope Blur: 21.3%
Confidence: 67.2%
Coherence: 45.9% (decision clarity)
Text: To implement binary search: 1. Define left and right pointers. 2....
Prediction: process_clarity
• Process Clarity: 79.7%
• Rhetorical Confidence: 12.3%
• Scope Blur: 8.0%
Confidence: 79.7%
Coherence: 67.4% (decision clarity)
Text: Trust your intuition and embrace the cosmic energy flowing through all things.
Prediction: scope_blur
• Process Clarity: 14.2%
• Rhetorical Confidence: 25.3%
• Scope Blur: 60.5%
Confidence: 60.5%
Coherence: 35.2% (decision clarity)
```