LLaMA-2-7B-Chat QLoRA Fine-Tuned for Structured Cover Letter Generation
This model is a task-specific fine-tuned version of meta-llama/Llama-2-7b-chat-hf, trained using QLoRA for structured, personalized cover letter generation.
Given a job description and resume fields, the model produces coherent, grounded, and well-structured professional cover letters.
The goal of this project was to improve grounding, reduce hallucinations, and increase template stability compared to the base model.
Note: This repository contains LoRA adapter weights only.
To use the model, load these adapters into the base model
meta-llama/Llama-2-7b-chat-hf, which requires accepting Metaβs license.
Model Summary
- Base: LLaMA-2-7B-Chat
- Fine-tuning method: QLoRA (8-bit NF4)
- Task: Cover letter generation from structured job + resume fields
- Dataset: ShashiVish/cover-letter-dataset (cleaned + reformatted)
- Improvement:
- +65% ROUGE-L vs base
- +3β5% BERTScore
- Lower repetition ratio
- Modes: roduces both short (3β6 sentence) and long (multi-paragraph) letters depending on input richness and sampling settings.
Model Sources
- Repository: https://github.com/soniatyburczy/llama2-qlora-sft-coverletter-project
(Training pipeline, evaluation code, and full experimentation logs.)
Intended Use
Direct Use
- Automatic cover letter generation
- Structured text generation from job/resume fields
- Template generator for job-application tools
Downstream Use
- Further fine-tuning on HR-specific datasets
- Integration into resume/ATS or recruiting tools
- Chrome extensions (original use case)
Out-of-Scope Use
- Fully automated job applications without human review
- General-purpose long-form writing
- Any high-stakes domain requiring factual accuracy
Bias, Risks & Limitations
- Some training samples are low-quality or AI-generated β possible stylistic inconsistency
- Not intended to replace human-written professional communication
- May infer or restate details incorrectly if input fields are sparse
- Performance depends heavily on input structure and clarity
Recommendation: Proofread outputs; keep prompts clean and include key details (βundergraduate,β domain, skills, etc.).
How to Use
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import re
base_model = "meta-llama/Llama-2-7b-chat-hf"
adapter_model = "czszt/llama2-coverletter-qlora"
# Load base model + tokenizer
tokenizer = AutoTokenizer.from_pretrained(base_model)
model = AutoModelForCausalLM.from_pretrained(
base_model,
device_map="auto",
torch_dtype="auto"
)
# Load LoRA adapters onto the base model
model = PeftModel.from_pretrained(model, adapter_model)
prompt = """
### Job Description
Job Title: Data Scientist
Company: DataTech Solutions
Preferred Qualifications: SQL, Python, Tableau
### Applicant Resume
Name: John Smith
Current Experience: Data Scientist at DEF Corp
Past Experience: Data Analyst at XYZ Corp
Skills: SQL, Python, Tableau
Qualifications: Bachelor's degree in Statistics
### Cover Letter
Using the information above, write a professional, personalized cover letter.
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.2,
pad_token_id=tokenizer.eos_token_id # prevents warnings for LLaMA models
)
output_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Optional cleanup: strip everything before "Dear"
text = output_text
if "Dear" in text:
text = "Dear" + text.split("Dear", 1)[1]
print(text)
Training Details
Data
- Dataset: ShashiVish/cover-letter-dataset
- Cleaned: extracted valid cover letter segments
- Prompt schema: structured job + resume fields β cover letter target
Preprocessing
- Regex-based cover letter cleaning
- Removal of β### Sampleβ artifacts
- Addition of EOS tokens
- 768-token max sequence length
Training Hyperparameters
- Epochs: 4
- Batch size: 1
- Grad accumulation: 4
- Learning rate: 2e-4
- Quantization: 8-bit NF4 double quantization
- LoRA: r=8, alpha=16, target_modules=["q_proj", "v_proj"]
- Precision: FP16
- Optimizer: paged AdamW 32bit
Evaluation
Metrics
- ROUGE-L (structure and grounding)
- BERTScore Precision/Recall/F1 (semantic similarity)
- Repetition ratio (hallucination & template stability proxy)
Results (full dataset)
| Model | ROUGE-L β | BERT-P β | BERT-R β | BERT-F1 β | Repetition β |
|---|---|---|---|---|---|
| Base | 0.314 | 0.884 | 0.919 | 0.901 | 0.428 |
| Fine-tuned | 0.519 | 0.927 | 0.939 | 0.933 | 0.361 |
Results (long letters > 500 chars)
| Model | ROUGE-L β | BERT-P β | BERT-R β | BERT-F1 β | Repetition β |
|---|---|---|---|---|---|
| Base | 0.355 | 0.904 | 0.919 | 0.911 | 0.429 |
| Fine-tuned | 0.507 | 0.935 | 0.933 | 0.934 | 0.397 |
Limitations
- Dataset contains noisy, unstructured entries
- Model may revert to generic phrasing for weak inputs
- Not human-rated; evaluation relies on automated metrics
- Output may require editing for tone, voice, or specificity
Contact
For questions, reach out via GitHub: github.com/soniatyburczy
- Downloads last month
- 20
Model tree for czszt/llama2-7b-qlora-cover-letter
Base model
meta-llama/Llama-2-7b-chat-hf