Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline | |
# β MUST be the first Streamlit command | |
st.set_page_config(page_title="Resume Tailor", layout="centered") | |
# Load model and tokenizer | |
def load_pipeline(): | |
model_name = "Vamsi/T5_Paraphrase_Paws" | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name) | |
return pipeline("text2text-generation", model=model, tokenizer=tokenizer) | |
rephrase_pipeline = load_pipeline() | |
def tailor_resume(job_description, resume): | |
# Create a concise prompt | |
prompt = f"paraphrase: Adapt this resume for the job description.\nJob: {job_description}\nResume: {resume}" | |
output = rephrase_pipeline( | |
prompt, max_length=512, num_return_sequences=1, clean_up_tokenization_spaces=True | |
)[0]["generated_text"] | |
return output | |
# UI | |
st.title("π― Resume Tailoring App") | |
st.write("Use AI to align your resume with a specific job description.") | |
job_desc = st.text_area("π Paste the Job Description:", height=200) | |
resume_input = st.text_area("π§Ύ Paste Your Resume:", height=300) | |
if st.button("Tailor Resume"): | |
if not job_desc.strip() or not resume_input.strip(): | |
st.warning("Please enter both the job description and your resume.") | |
else: | |
with st.spinner("Tailoring your resume..."): | |
try: | |
tailored_resume = tailor_resume(job_desc, resume_input) | |
st.subheader("π Tailored Resume") | |
st.text_area("You can now copy your optimized resume:", value=tailored_resume, height=400) | |
except Exception as e: | |
st.error(f"Something went wrong: {e}") | |