AI_Detector_App / models /text_model.py
ash12321's picture
Create models/text_model.py
37eeeb1 verified
raw
history blame contribute delete
589 Bytes
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",
}