File size: 3,576 Bytes
5560955
c7996a1
7e4deac
7bd332d
b0c8c8c
cda75bc
b0c8c8c
7e4deac
c8a23cf
 
 
 
cda75bc
c8a23cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fb6c4a2
5560955
 
c7996a1
 
 
 
 
 
 
 
fb6c4a2
 
b0c8c8c
5560955
 
 
 
 
 
 
 
 
 
 
 
 
 
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
59
60
61
62
from transformers import AutoTokenizer, AutoModelForCausalLM
import os

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}
    """

    # Load the tokenizer and model
    huggingface_token = os.environ.get("KEY2")
    tokenizer = AutoTokenizer.from_pretrained(
        "meta-llama/Llama-3.2-1B",
        use_auth_token=huggingface_token
    )
    model = AutoModelForCausalLM.from_pretrained(
        "meta-llama/Llama-3.2-1B",
        use_auth_token=huggingface_token
    )

    try:
        # Tokenize the input
        input_ids = tokenizer.encode(input_prompt, return_tensors="pt")
        
        # Generate the output
        output = model.generate(
            input_ids,
            max_length=1500,
            temperature=0.01,
            top_p=0.7,
            pad_token_id=tokenizer.eos_token_id  # Ensure padding works properly
        )
        
        # Decode the output
        response_text = tokenizer.decode(output[0], skip_special_tokens=True)
        return response_text
    except Exception as e:
        print(f"Error during generation: {e}")
        return "Error: Unable to generate feedback."