Spaces:
Sleeping
Sleeping
Update app.py
Browse files1234567867899101112131112141516171819202122232418252620212223242526272728293031323334import streamlit as stfrom transformers import pipeline
# App titlest.set_page_config(page_title="Fake Job Detector", page_icon="🕵️♂️")st.title("Fake Job / Lie Detector")st.markdown("Enter a job description and check if it seems suspicious!")
st.write( "This app classifies a job description as potentially fake or real. " "Runs entirely locally on CPU, no API key needed.")# Load small NLI model for zero-shot classification (CPU-friendly)@st.cache_resourcedef load_model(): return pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
# Use a small, CPU-friendly modelclassifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli", device=-1)classifier = load_model()
# Input from userjob_description = st.text_area("Enter the job description:")
# Label optionslabels = ["Legitimate", "Suspicious", "Fake", "Scam"]
# Button to checkif st.button("Check Job"): if not job_description.strip(): st.warning("Please enter a job description.") st.warning("Please enter a job description!") else: # Define the candidate labels labels = ["real", "fake"] result = classifier(job_description, candidate_labels=labels) top_label = result["labels"][0] score = result["scores"][0]
st.write(f"Prediction: **{top_label.upper()}**") st.write(f"Confidence: **{score*100:.2f}%**") # Run zero-shot classification results = classifier(job_description, candidate_labels=labels) st.subheader("Prediction:") # Show top label and scores top_label = results["labels"][0] score = results["scores"][0] st.success(f"Most likely: **{top_label}** ({score*100:.2f}%)") st.write("Full results:", results)app.py+22-15