Views
No views yet

1
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel, PeftConfig
4
5base_model_name = "akjindal53244/Llama-3.1-Storm-8B"
6
7# Load the base model
8base_model = AutoModelForCausalLM.from_pretrained(base_model_name)
9tokenizer = AutoTokenizer.from_pretrained(base_model_name)
10
11# Load the LoRA adapter
12peft_model_id = "LlamaFactoryAI/cv-job-description-matching"
13config = PeftConfig.from_pretrained(peft_model_id)
14model = PeftModel.from_pretrained(base_model, peft_model_id)
15
16# Use the model
17messages = [
18 {
19 "role": "system",
20 "content": """You are an advanced AI model designed to analyze the compatibility between a CV and a job description. You will receive a CV and a job description. Your task is to output a structured JSON format that includes the following:
21
221. matching_analysis: Analyze the CV against the job description to identify key strengths and gaps.
232. description: Summarize the relevance of the CV to the job description in a few concise sentences.
243. score: Provide a numerical compatibility score (0-100) based on qualifications, skills, and experience.
254. recommendation: Suggest actions for the candidate to improve their match or readiness for the role.
26
27Your output must be in JSON format as follows:
28{
29 "matching_analysis": "Your detailed analysis here.",
30 "description": "A brief summary here.",
31 "score": 85,
32 "recommendation": "Your suggestions here."
33}
34""",
35 },
36 {"role": "user", "content": "<CV> {cv} </CV>\n<job_description> {job_description} </job_description>"},
37]
38inputs = tokenizer.apply_chat_template(
39 messages, add_generation_prompt=True, return_tensors="pt"
40)
41outputs = model.generate(inputs, max_new_tokens=128)
42generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
43print(generated_text)