Downloads · 30 days
7
2% of all-time downloads
nitin1pawar/gemma-2-2b-legal-raft
gemma-2-2b-legal-raft is a text generation model from nitin1pawar. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as gemma.
google/gemma-2-2b-it fine-tuned with QLoRA for grounded legal/financial question answering, on a synthetic RAFT dataset built from a corpus of US case law and SEC filings.
Downloads · 30 days
7
2% of all-time downloads
All-time downloads
338
Public
Parameters
2.6B
5.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors5.3 GB · 99%
From the Hugging Face model README
google/gemma-2-2b-it fine-tuned with QLoRA for grounded
legal/financial question answering, on a synthetic RAFT dataset built from a corpus of US case
law and SEC filings.
A quarter of the training examples pair a question with passages that do not contain its answer, so the model learns to say so rather than invent one:
The passage does not provide enough information to answer this question.
Evaluated on 506 held-out examples — the same split used by
nitin1pawar/slm125m-instruct, a 125M model trained from
scratch on the identical dataset. Same data, same task, same held-out rows; the only variable is
the pretrained backbone.
| metric | this model | slm125m-instruct (125M, from scratch) |
|---|---|---|
| Refusal recall (answer absent → refuses) | 99.2% | 91.0% |
| False refusal (answer present → wrongly refuses) | 0.7% | 15.3% |
| Val answer-token loss | 0.9522 (ppl 2.59) | 1.6840 (ppl 5.39) |
Both refusal axes improved at once, which is the part that matters: a model that simply refuses more would trade one against the other.
Standard Gemma 2 chat format. Gemma 2 has no system role, so system instructions belong at the top of the user turn:
system = "You are a legal and financial assistant. Answer the question using only the passages provided. If the passages do not contain the answer, reply exactly: The passage does not provide enough information to answer this question."
user = f"{system}\n\nPassage 1:\n{passage}\n\nQuestion: {question}"
prompt = tokenizer.apply_chat_template(
[{"role": "user", "content": user}], tokenize=False, add_generation_prompt=True)
Generation must stop on <end_of_turn>, not <eos>.
296 steps, 2 epochs, 19.4M padded tokens, 277s on 8×H100 (measured 84K tok/s, 99.5% DDP scaling efficiency).
QLoRA: 4-bit NF4 with double quantization, LoRA r=16 α=32 dropout=0.05 on
q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj — 1.28% of parameters trainable.
AdamW, LR 2e-04 cosine → 0, bf16. Loss on answer tokens only; question and
context tokens are masked out.
⚠️ Gemma 2 uses attention logit soft-capping, which SDPA and older FlashAttention do not implement.
Training used attn_implementation="eager".
10,000 synthetic Q&A pairs generated with gpt-5-mini and graded by an LLM
judge on groundedness, correctness, answerability and form (judge pass rate
88.4%). Composition:
Passages come from a deduplicated and decontaminated corpus, so CaseHOLD and LexGLUE
case_hold remain genuinely held out.
A 2B model fine-tuned on synthetic answers written by another language model, not by lawyers. Refusal is learned behaviour, not a guarantee. Context is capped at 1,024 tokens in training. Not legal or financial advice.
Governed by the Gemma Terms of Use. Use of this model is subject to Google's Gemma license and Prohibited Use Policy, which carry over to derivatives.