Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,44 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from transformers import
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
job_description = st.text_area("Enter the job description:")
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
if job_description.strip() == "":
|
| 14 |
-
st.warning("Please enter a job description.")
|
| 15 |
else:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
+
st.title("🚨 Fake Job Posting Detector")
|
| 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 |
+
# Load the model
|
| 12 |
+
@st.cache_resource(show_spinner=True)
|
| 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 |
+
tokenizer, model = load_model()
|
|
|
|
| 20 |
|
| 21 |
+
# Input text
|
| 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("⚠️ Please enter a job description first.")
|
| 31 |
else:
|
| 32 |
+
# Prepare prompt for GPT-OSS
|
| 33 |
+
prompt = f"Classify the following job posting as Fake or Legit:\n\n{job_description}\n\nAnswer with only 'Fake' or 'Legit'."
|
| 34 |
+
|
| 35 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 36 |
+
with torch.no_grad():
|
| 37 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
| 38 |
+
prediction = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 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")
|