File size: 3,362 Bytes
6b70492
3abe7d4
80ed1fd
 
 
 
b5ac3f0
3abe7d4
 
b5ac3f0
3abe7d4
 
 
 
 
80ed1fd
 
b5ac3f0
 
7bd332d
b0c8c8c
cda75bc
b0c8c8c
7e4deac
c8a23cf
 
 
 
cda75bc
c8a23cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fb6c4a2
5560955
b0c8c8c
3abe7d4
 
5560955
3abe7d4
 
cda75bc
8756a40
5560955
cda75bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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."