File size: 589 Bytes
37eeeb1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from transformers import pipeline

# Public, stable model that works on Spaces
text_model = pipeline(
    task="text-classification",
    model="distilbert-base-uncased-finetuned-sst-2-english",  # sentiment model used as a placeholder for "credibility"
    device=-1  # CPU
)

# Map a variety of possible raw labels to friendly names.
# Different transformers versions may return NEGATIVE/POSITIVE or LABEL_0/LABEL_1.
TEXT_FRIENDLY_MAP = {
    "NEGATIVE": "Fake / Not Credible",
    "LABEL_0": "Fake / Not Credible",
    "POSITIVE": "Real / Credible",
    "LABEL_1": "Real / Credible",
}