Infinity-1995 commited on
Commit
8850ba6
·
verified ·
1 Parent(s): 3e41ed4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -37
app.py CHANGED
@@ -1,44 +1,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")
 
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}")