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