Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,22 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from transformers import
|
| 3 |
-
import torch
|
| 4 |
|
| 5 |
-
st.title("
|
| 6 |
-
st.write(
|
| 7 |
-
"Enter a job description below to check if it is likely **Fake** or **Legit**. "
|
| 8 |
-
"This tool uses AI to help job seekers avoid scams."
|
| 9 |
-
)
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
def load_model():
|
| 14 |
-
model_id = "openai/gpt-oss-20b"
|
| 15 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 16 |
-
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 17 |
-
return tokenizer, model
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
| 22 |
-
job_description = st.text_area(
|
| 23 |
-
"Paste the job description here:",
|
| 24 |
-
"Example: Urgent hiring! Work from home, no experience needed, $5000/month!"
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
-
# Button to run prediction
|
| 28 |
-
if st.button("Check Job Posting"):
|
| 29 |
if job_description.strip() == "":
|
| 30 |
-
st.warning("
|
| 31 |
else:
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
# Display result with color
|
| 41 |
-
if "Fake" in prediction:
|
| 42 |
-
st.error(f"Prediction: Fake")
|
| 43 |
-
else:
|
| 44 |
-
st.success(f"Prediction: Legit")
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
import streamlit as st
|
| 3 |
+
from transformers import pipeline
|
|
|
|
| 4 |
|
| 5 |
+
st.title("Fake Job Posting Detector")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Use a small model that fits in Hugging Face Space memory
|
| 8 |
+
classifier = pipeline("zero-shot-classification", model="Groq/compound-mini")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
job_description = st.text_area("Enter the job description:")
|
| 11 |
|
| 12 |
+
if st.button("Check Job"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
if job_description.strip() == "":
|
| 14 |
+
st.warning("Please enter a job description.")
|
| 15 |
else:
|
| 16 |
+
labels = ["Legit", "Fake"]
|
| 17 |
+
result = classifier(job_description, candidate_labels=labels)
|
| 18 |
+
predicted_label = result['labels'][0]
|
| 19 |
+
confidence = result['scores'][0]
|
| 20 |
+
|
| 21 |
+
st.write(f"Prediction: **{predicted_label}**")
|
| 22 |
+
st.write(f"Confidence: {confidence:.2f}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|