collapseindex commited on
Commit
6f05114
·
verified ·
1 Parent(s): 0961fcf

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +61 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
+ import torch
4
+
5
+ # Load model
6
+ model = AutoModelForSequenceClassification.from_pretrained("collapseindex/ProBERT-1.0")
7
+ tokenizer = AutoTokenizer.from_pretrained("collapseindex/ProBERT-1.0")
8
+
9
+ LABELS = ["process_clarity", "rhetorical_confidence", "scope_blur"]
10
+
11
+ EXAMPLES = [
12
+ ["This revolutionary AI will transform your business and guarantee results."],
13
+ ["Step 1: Load data. Step 2: Validate schema. Step 3: Return results."],
14
+ ["Trust your intuition and embrace the journey. The universe has a plan."],
15
+ ["First, check if the input is null. If null, return error. Otherwise, process the request."],
16
+ ["Our cutting-edge solution leverages synergies to maximize value propositions."],
17
+ ]
18
+
19
+ def classify(text):
20
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
21
+ with torch.no_grad():
22
+ outputs = model(**inputs)
23
+ probs = torch.softmax(outputs.logits, dim=1)[0]
24
+
25
+ # Get top prediction and confidence
26
+ top_prob = float(probs.max())
27
+ top_idx = int(probs.argmax())
28
+ top_label = LABELS[top_idx]
29
+
30
+ # Return predictions dict and confidence text
31
+ predictions = {LABELS[i]: float(probs[i]) for i in range(len(LABELS))}
32
+ confidence_text = f"**Top Prediction:** {top_label} (Confidence: {top_prob:.1%})"
33
+
34
+ return predictions, confidence_text
35
+
36
+ demo = gr.Interface(
37
+ fn=classify,
38
+ inputs=gr.Textbox(lines=3, placeholder="Enter text here...", label="Input Text"),
39
+ outputs=[
40
+ gr.Label(
41
+ num_top_classes=3,
42
+ label="Predictions"
43
+ ),
44
+ gr.Markdown(label="Confidence Score")
45
+ ],
46
+ title="ProBERT v1.0 - Rhetorical Confidence Detection",
47
+ description="""
48
+ **Detects rhetorical overconfidence in text.**
49
+
50
+ - 🟢 **process_clarity**: Step-by-step reasoning you can verify
51
+ - 🟠 **rhetorical_confidence**: Assertive claims without supporting process
52
+ - 🔴 **scope_blur**: Vague generalizations with ambiguous boundaries
53
+
54
+ **Model:** [collapseindex/ProBERT-1.0](https://huggingface.co/collapseindex/ProBERT-1.0)
55
+ """,
56
+ examples=EXAMPLES,
57
+ theme="default",
58
+ )
59
+
60
+ if __name__ == "__main__":
61
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio