Spaces:
Sleeping
Sleeping
Update app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344import streamlit as stfrom transformers import AutoTokenizer, AutoModelForCausalLMimport torchst.title("🚨 Fake Job Posting Detector")st.write("Enter a job description below to check if it is likely **Fake** or **Legit**. ""This tool uses AI to help job seekers avoid scams.")# Load the model@st.cache_resource(show_spinner=True)def load_model():model_id = "openai/gpt-oss-20b"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained(model_id)return tokenizer, modeltokenizer, model = load_model()# Input textjob_description = st.text_area("Paste the job description here:","Example: Urgent hiring! Work from home, no experience needed, $5000/month!")# Button to run predictionif st.button("Check Job Posting"):if job_description.strip() == "":st.warning("⚠️ Please enter a job description first.")else:# Prepare prompt for GPT-OSSprompt = f"Classify the following job posting as Fake or Legit:\n\n{job_description}\n\nAnswer with only 'Fake' or 'Legit'."inputs = tokenizer(prompt, return_tensors="pt")with torch.no_grad():outputs = model.generate(**inputs, max_new_tokens=20)prediction = tokenizer.decode(outputs[0], skip_special_tokens=True)# Display result with colorif "Fake" in prediction:st.error(f"Prediction: Fake")else:st.success(f"Prediction: Legit")12345678910111213141516171819202122# app.pyimport streamlit as stfrom transformers import pipelinest.title("Fake Job Posting Detector")# Use a small model that fits in Hugging Face Space memoryclassifier = pipeline("zero-shot-classification", model="Groq/compound-mini")job_description = st.text_area("Enter the job description:")if st.button("Check Job"):if job_description.strip() == "":st.warning("Please enter a job description.")else:labels = ["Legit", "Fake"]result = classifier(job_description, candidate_labels=labels)predicted_label = result['labels'][0]confidence = result['scores'][0]st.write(f"Prediction: **{predicted_label}**")st.write(f"Confidence: {confidence:.2f}")
app.py+15-37