Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Load model and tokenizer
5model_name = "saipriyaadama/llama-3.1-8b-resume-outreach-v1"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype=torch.float16,
10 device_map="auto"
11)
12
13# Prepare prompt
14prompt = """
15
16You are an expert at writing personalized, professional outreach messages for job applications. Always return only the final message text, with no explanations.<|eot_id|><|start_header_id|>user<|end_header_id|>
17
18Candidate resume:
19[Your resume text here - include name, experience, skills, achievements]
20
21Job posting description:
22[Full job posting text here]
23
24Write a concise LinkedIn message to a recruiter about this role.
25
26Requirements:
27- Tone: professional, friendly, and confident.
28- 60–100 words.
29- Clearly state why the candidate is a strong fit using 1–2 points from the resume.
30- Refer to the role and company from the job description.
31- End with a polite question about next steps or a short call.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
32
33"""
34
35# Generate
36inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
37outputs = model.generate(
38 **inputs,
39 max_new_tokens=200,
40 temperature=0.7,
41 top_p=0.9,
42 do_sample=True,
43 repetition_penalty=1.15,
44 pad_token_id=tokenizer.eos_token_id
45)
46
47# Decode
48message = tokenizer.decode(outputs[0], skip_special_tokens=True)
49# Extract only the assistant's response
50message = message.split("<|start_header_id|>assistant<|end_header_id|>")[-1].strip()
51print(message)1import requests
2
3API_URL = "https://adamasaipriya--llama-resume-api-generate.modal.run"
4
5response = requests.post(
6 API_URL,
7 json={
8 "prompt": prompt, # Full formatted prompt
9 "max_length": 200,
10 "temperature": 0.7
11 }
12)
13
14message = response.json()["response"]
15print(message)1{
2 "resume": "200-300 word resume with specific metrics",
3 "job_posting": "120-180 word job description",
4 "message": "60-180 word personalized outreach"
5}1base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
2method: LoRA
3lora_r: 16
4lora_alpha: 32
5lora_dropout: 0.05
6target_modules: [q_proj, k_proj, v_proj, o_proj]
7learning_rate: 2e-4
8batch_size: 4
9gradient_accumulation_steps: 4
10epochs: 3
11warmup_steps: 100
12max_seq_length: 2048Resume: Data Scientist with 2 years at NextEra Energy building LLM pipelines...
Job: Senior ML Engineer at Google Cloud, requires Python, Kubernetes...Hi,
I'm excited about the Senior ML Engineer role at Google Cloud.
With 2 years building production LLM pipelines at NextEra Energy—including
a 50% latency reduction and 2.5% accuracy improvement on claims
processing—I have hands-on experience with the exact ML infrastructure
challenges your team tackles. My Kubernetes deployments and Python
expertise align directly with your requirements. Would you have
15 minutes to discuss how my background could support Google Cloud's
AI initiatives?
Best regards