Gemma / app.py
ShubhamD95's picture
Update app.py
50c02b0 verified
raw
history blame
1.43 kB
import gradio as gr
from keybert import KeyBERT
from sentence_transformers import SentenceTransformer
# βœ… Load Hugging Face model (no API key needed)
model = SentenceTransformer('all-MiniLM-L6-v2')
kw_model = KeyBERT(model)
# πŸ” Keyword extraction function
def extract_keywords(job_desc, resume_text, analyze_with_jd):
if not resume_text.strip():
return "Please paste your resume."
text = job_desc + "\n\n" + resume_text if analyze_with_jd and job_desc else resume_text
keywords = kw_model.extract_keywords(text, top_n=10, stop_words='english')
return ", ".join([kw for kw, _ in keywords]) if keywords else "No keywords found."
# πŸŽ›οΈ Gradio UI
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
analyze_checkbox = gr.Checkbox(label="Analyze with Job Description", value=True)
job_desc = gr.Textbox(label="Job Description", lines=6, placeholder="Paste job description here...")
resume_text = gr.Textbox(label="Resume Text", lines=12, placeholder="Paste resume content here...")
with gr.Column():
output_keywords = gr.Textbox(label="Extracted Keywords", lines=12)
resume_text.change(fn=extract_keywords, inputs=[job_desc, resume_text, analyze_checkbox], outputs=output_keywords)
job_desc.change(fn=extract_keywords, inputs=[job_desc, resume_text, analyze_checkbox], outputs=output_keywords)
demo.launch()