ATSScanner / model.py
bainskarman's picture
Update model.py
80ed1fd verified
raw
history blame
3.36 kB
import torch
from transformers import pipeline
import os
# Retrieve the token stored as a secret in the environment
hf_token = os.getenv('KEY2')
# Define model id
model_id = "meta-llama/Llama-3.2-1B"
# Create pipeline for text generation with bfloat16 precision and device auto-placement
pipe = pipeline(
"text-generation",
model=model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
use_auth_token=hf_token
)
def modelFeedback(ats_score, resume_data, job_description):
"""
Generate ATS feedback by utilizing a pre-configured pipeline.
"""
input_prompt = f"""
You are now an ATS Score analyzer and given ATS Score is {int(ats_score * 100)}%.
Your task is to provide a comprehensive review and feedback based on the ATS score.
### ATS Score:
The current ATS score is {int(ats_score * 100)}%. Your goal is to increase this score by aligning the resume more closely with the job description. This is the model I am using "model = SentenceTransformer('paraphrase-MiniLM-L6-v2') # Pre-trained BERT model" so make sure the ats score improvements are based on this model.
### Overall Resume Review:
Please assess the following key aspects of the resume and provide specific feedback where necessary. In each case, suggest improvements, if any:
Show overall resume rating out of 100 and matching with job description out of 100 with titles 'Resume Score' and 'Matching Score'
1. **Quantifying Impact**: Are accomplishments supported by measurable data or metrics? Suggest improvements if more quantifiable results could be provided.
2. **Unique Action Verbs**: Are there any unique or strong action verbs? Highlight any overused verbs and suggest stronger alternatives.
3. **Weak Action Verbs**: Identify any weak or passive verbs and provide suggestions to improve them.
4. **Verb Tenses**: Check the consistency of verb tenses. Are past roles described using past tense and current roles in present tense?
5. **Accomplishment-Oriented Language**: Is the language focused on achievements rather than responsibilities? Recommend areas where the resume could be more results-driven.
6. **Spell Check**: Identify any spelling or grammatical errors that need to be fixed.
7. **Sections in Resume**: Evaluate each section of the resume (e.g., contact info, experience, education, skills). Are there any missing sections or sections that could be improved?
### Matching with Job Description:
Now, focus on matching the resume with the job description. Provide detailed feedback on how well the resume aligns with the job description and where it falls short. Suggest specific content that needs to be replaced, added, or modified to improve the ATS score.
#### Resume Data: {resume_data}
#### Job Description: {job_description}
"""
try:
# Generate the feedback using the pre-configured pipeline
response = pipe(input_prompt, max_length=1500, num_return_sequences=1)
# Extract the generated text
response_text = response[0]['generated_text']
return response_text
except Exception as e:
print(f"Error during generation: {e}")
return "Error: Unable to generate feedback."