bainskarman commited on
Commit
cda75bc
·
verified ·
1 Parent(s): 7bd332d

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +11 -54
model.py CHANGED
@@ -1,16 +1,15 @@
1
- from transformers import AutoTokenizer, AutoModelForCausalLM
2
- import torch
3
 
4
  def modelFeedback(ats_score, resume_data, job_description):
5
  """
6
- Generate ATS feedback by loading model and tokenizer directly.
7
  """
8
  input_prompt = f"""
9
  You are now an ATS Score analyzer and given ATS Score is {int(ats_score * 100)}%.
10
  Your task is to provide a comprehensive review and feedback based on the ATS score.
11
 
12
  ### ATS Score:
13
- 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 imporvemnts is based on this model.
14
 
15
  ### Overall Resume Review:
16
  Please assess the following key aspects of the resume and provide specific feedback where necessary. In each case, suggest improvements, if any:
@@ -23,63 +22,21 @@ def modelFeedback(ats_score, resume_data, job_description):
23
  6. **Spell Check**: Identify any spelling or grammatical errors that need to be fixed.
24
  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?
25
 
26
- #### Skills Review Table:
27
- Please use the table below to summarize key suggestions for improvement:
28
-
29
- | **Section** | **Good Points** | **Suggestions for Improvement** |
30
- |-------------------|------------------------------------------|-----------------------------------------------|
31
- | Quantifying Impact| | |
32
- | Action Verbs | | |
33
- | Verb Tenses | | |
34
- | Accomplishments | | |
35
- | Spell Check | | |
36
- | Sections | | |
37
- | Skills | | |
38
-
39
  ### Matching with Job Description:
40
  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.
41
 
42
- - **Missing Skills**: Identify any skills from the job description that are missing from the resume and should be added.
43
- - **Weak Action Verbs**: Highlight verbs that could be made stronger or more relevant to the job description.
44
- - **Weaker Sentences**: Suggest improvements to sentences or bullet points that don't align well with the job description or lack clarity.
45
- - **Content to Replace**: List any content in the resume that could be replaced to better match the job description.
46
-
47
- #### Job Matching Suggestions Table:
48
- Use the table below to show specific suggestions for improving the match between the resume and the job description:
49
-
50
- | **Resume Content** | **Suggested Replacement or Addition** |
51
- |----------------------------------|------------------------------------------------------|
52
- | (Weaker or Missing Skills) | |
53
- | (Weak Action Verbs) | |
54
- | (Weaker Sentences or Bullet Points) | |
55
-
56
- ### Final Recommendations:
57
- Conclude the review by summarizing the key areas where the resume can improve both in overall quality and its match with the job description. Provide a strategy for increasing the ATS score by implementing these changes.
58
-
59
  #### Resume Data: {resume_data}
60
  #### Job Description: {job_description}
61
- IMPORTANT: The output should be as normal organised text not in any other format (don't give markdown text) and focus more on resume matching part that general resume review.
62
  """
63
 
64
- # Load tokenizer and model
65
- tokenizer = AutoTokenizer.from_pretrained("nvidia/Llama-3.1-Nemotron-70B-Instruct-HF")
66
- model = AutoModelForCausalLM.from_pretrained("nvidia/Llama-3.1-Nemotron-70B-Instruct-HF")
67
-
68
- # Tokenize the input
69
- inputs = tokenizer.encode(input_prompt, return_tensors="pt")
70
 
71
- # Generate the response
72
  try:
73
- outputs = model.generate(
74
- inputs,
75
- max_length=1500,
76
- temperature=0.01,
77
- top_p=0.7,
78
- pad_token_id=tokenizer.eos_token_id
79
- )
80
- response_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
81
- cleaned_feedback = clean_text_output(response_text)
82
- return cleaned_feedback
83
  except Exception as e:
84
- print(f"Model generation error: {e}")
85
- return "Error: Unable to generate feedback."
 
1
+ from transformers import pipeline
 
2
 
3
  def modelFeedback(ats_score, resume_data, job_description):
4
  """
5
+ Generate ATS feedback by utilizing a pre-configured pipeline.
6
  """
7
  input_prompt = f"""
8
  You are now an ATS Score analyzer and given ATS Score is {int(ats_score * 100)}%.
9
  Your task is to provide a comprehensive review and feedback based on the ATS score.
10
 
11
  ### ATS Score:
12
+ 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.
13
 
14
  ### Overall Resume Review:
15
  Please assess the following key aspects of the resume and provide specific feedback where necessary. In each case, suggest improvements, if any:
 
22
  6. **Spell Check**: Identify any spelling or grammatical errors that need to be fixed.
23
  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?
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  ### Matching with Job Description:
26
  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.
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  #### Resume Data: {resume_data}
29
  #### Job Description: {job_description}
 
30
  """
31
 
32
+ # Load the pipeline
33
+ pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-3B-Instruct")
 
 
 
 
34
 
35
+ # Generate the response using the pipeline
36
  try:
37
+ output = pipe(input_prompt, max_length=1500, temperature=0.01, top_p=0.7, return_full_text=True)
38
+ response_text = output[0]['generated_text'] # Extract generated text from the pipeline's output
39
+ return response_text
 
 
 
 
 
 
 
40
  except Exception as e:
41
+ print(f"Pipeline generation error: {e}")
42
+ return "Error: Unable to generate feedback."