Views
No views yet
PPC s.302, CONST art.184(3), QSO art.17)| Domain | Statute | QA pairs |
|---|---|---|
| Criminal | Pakistan Penal Code (PPC) | 2,215 |
| Constitutional | Constitution of Pakistan 1973 | 1,957 |
| Evidence | Qanun-e-Shahadat Order 1984 (QSO) | 742 |
| Civil Procedure | Code of Civil Procedure (CPC) | 143 |
| Family | Muslim Family Laws Ordinance 1961 (MFLO) | 59 |
| Total | 5,116 |
1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
2from peft import PeftModel
3import torch
4
5bnb_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16)
6base = AutoModelForCausalLM.from_pretrained(
7 "meta-llama/Llama-3.3-70B-Instruct",
8 quantization_config=bnb_config,
9 device_map="auto"
10)
11model = PeftModel.from_pretrained(base, "abdullah693/pakistan-legal-qa-llama70b")
12tok = AutoTokenizer.from_pretrained("meta-llama/Llama-3.3-70B-Instruct")
13
14question = "Under PPC s.302, what is the punishment for qatl-i-amd?"
15inputs = tok.apply_chat_template(
16 [{"role": "user", "content": question}],
17 return_tensors="pt", return_dict=True, add_generation_prompt=True
18).to(model.device)
19
20out = model.generate(**inputs, max_new_tokens=256, do_sample=False)
21print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))Reasoning: <short chain-of-thought grounded in the statutory text>
Answer: <direct answer>
Citation: <canonical citation e.g. PPC s.302>| Parameter | Value |
|---|---|
| Base model | meta-llama/Llama-3.3-70B-Instruct |
| Method | LoRA (PEFT) |
| LoRA rank | 64 |
| LoRA alpha | 128 |
| LoRA dropout | 0.0 |
| Target modules | all-linear — q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Epochs | 2 (134 steps) |
| Final train loss | 0.675 |
| Final eval loss | 0.625 (monotonically decreasing across all checkpoints) |
| Trained via | Adaption AutoScientist / Together AI |