Views
No views yet
A 3B fine-tuned model that outperforms the Llama 3 8B zero-shot baseline on U.S. immigration law Q&A (+27% mean score, 4x more fully-correct answers).
| Model | Mean Score (0-3) | % Fully Correct (3) |
|---|---|---|
| Claude Sonnet 4.6 (zero-shot) | 1.515 | 24.8% |
| Llama 3.2 3B fine-tuned (this model) | 1.079 | 16.8% |
| Llama 3 8B zero-shot | 0.851 | 4.0% |
| Setting | Value |
|---|---|
| LoRA rank (r) | 32 |
| LoRA alpha | 64 |
| Target modules | q_proj, v_proj, k_proj, o_proj |
| LoRA dropout | 0.05 |
| Epochs | 2 |
| Learning rate | 5e-5 |
| Batch size | 2 |
| Max sequence length | 1024 |
| Training pairs | 16,065 |
| Infrastructure | ml.g5.2xlarge (AWS SageMaker) |
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_id = "nshportun/usa-immigration-llama-3.2-3b-v3"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
7
8messages = [
9 {"role": "system", "content": "You are an expert on U.S. immigration law and policy. Answer accurately based on USCIS, 8 CFR, and BIA sources."},
10 {"role": "user", "content": "What is the filing fee for Form I-485?"},
11]
12text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
13inputs = tokenizer(text, return_tensors="pt").to(model.device)
14out = model.generate(**inputs, max_new_tokens=300, do_sample=False)
15print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))