Infinity-1995 commited on
Commit
c855119
·
verified ·
1 Parent(s): 311306e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -15
app.py CHANGED
@@ -1,27 +1,34 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
 
 
4
  st.title("Fake Job / Lie Detector")
 
5
 
6
- st.write(
7
- "This app classifies a job description as potentially fake or real. "
8
- "Runs entirely locally on CPU, no API key needed."
9
- )
10
 
11
- # Use a small, CPU-friendly model
12
- classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli", device=-1)
13
 
 
14
  job_description = st.text_area("Enter the job description:")
15
 
 
 
 
 
16
  if st.button("Check Job"):
17
  if not job_description.strip():
18
- st.warning("Please enter a job description.")
19
  else:
20
- # Define the candidate labels
21
- labels = ["real", "fake"]
22
- result = classifier(job_description, candidate_labels=labels)
23
- top_label = result["labels"][0]
24
- score = result["scores"][0]
25
-
26
- st.write(f"Prediction: **{top_label.upper()}**")
27
- st.write(f"Confidence: **{score*100:.2f}%**")
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # App title
5
+ st.set_page_config(page_title="Fake Job Detector", page_icon="🕵️‍♂️")
6
  st.title("Fake Job / Lie Detector")
7
+ st.markdown("Enter a job description and check if it seems suspicious!")
8
 
9
+ # Load small NLI model for zero-shot classification (CPU-friendly)
10
+ @st.cache_resource
11
+ def load_model():
12
+ return pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
13
 
14
+ classifier = load_model()
 
15
 
16
+ # Input from user
17
  job_description = st.text_area("Enter the job description:")
18
 
19
+ # Label options
20
+ labels = ["Legitimate", "Suspicious", "Fake", "Scam"]
21
+
22
+ # Button to check
23
  if st.button("Check Job"):
24
  if not job_description.strip():
25
+ st.warning("Please enter a job description!")
26
  else:
27
+ # Run zero-shot classification
28
+ results = classifier(job_description, candidate_labels=labels)
29
+ st.subheader("Prediction:")
30
+ # Show top label and scores
31
+ top_label = results["labels"][0]
32
+ score = results["scores"][0]
33
+ st.success(f"Most likely: **{top_label}** ({score*100:.2f}%)")
34
+ st.write("Full results:", results)