Downloads · 30 days
19
100% of all-time downloads
snake4u1/strisakhi-gemma4-lora
strisakhi-gemma4-lora is a text generation model from snake4u1. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Developed by: Shubendu Biswas Competition: Kaggle Gemma 4 Hackathon / Women in AI Challenge Base Model: unsloth/gemma-4-E2B-it-unsloth-bnb-4bit Model Type: Causal Language Model (LoRA Adapter) Languages: Hindi (Devana…
Downloads · 30 days
19
100% of all-time downloads
All-time downloads
19
Public
Repo size
82.9 MB
Likes
0
Public
Click a slice to open those files.
.safetensors50.7 MB · 61%
From the Hugging Face model README
Developed by: Shubendu Biswas
Competition: Kaggle Gemma 4 Hackathon / Women in AI Challenge
Base Model: unsloth/gemma-4-E2B-it-unsloth-bnb-4bit
Model Type: Causal Language Model (LoRA Adapter)
Languages: Hindi (Devanagari), English, Hinglish input → Hindi/English output
License: Apache-2.0 (same as base)
Finetuned by: Unsloth + PEFT (Hugging Face ecosystem)
StriSakhi ("Legal Companion") is a fine-tuned Gemma-4 2B Instruct model specialized as a warm, authoritative legal guide for Indian women seeking rights-based information. Unlike general-purpose LLMs, it is explicitly trained to:
Key Differentiator: This is a safety-first, rights-first legal domain model with structured output conditioning baked into the LoRA weights via 549 curated conversational examples.
| Benchmark | Score | Pass Rate |
|---|---|---|
| Overall (50 cases) | 86.4% | 43/50 (86%) |
| Domestic Violence (10) | 91.2% | 9/10 |
| Property Rights (8) | 84.5% | 7/8 |
| Maintenance/Divorce (8) | 82.1% | 6/8 |
| Dowry Harassment (5) | 88.0% | 4/5 |
| Workplace/POSH (5) | 90.0% | 5/5 |
| Hinglish → Hindi (8) | 85.4% | 7/8 |
| Follow-up Short (6) | 79.2% | 5/6 |
Benchmark: Custom 50-case legal evaluation suite covering 7 crime categories with automated checks for citation accuracy, Hindi purity, timeline structure, and hallucination resistance.
| Spec | Value |
|---|---|
| GPU | NVIDIA Tesla T4 (Kaggle) |
| VRAM | 14.5 GB |
| Training Time | ~35 minutes |
| Framework | Unsloth 2026.5.2 + Transformers 5.5.0 |
| Parameter | Value |
|---|---|
| Base Model | unsloth/gemma-4-E2B-it-unsloth-bnb-4bit |
| Method | LoRA (PEFT) |
Rank (r) | 8 |
Alpha (lora_alpha) | 8 |
| Dropout | 0.0 |
| Target Modules | Attention + MLP (vision frozen) |
| Sequence Length | 4096 |
| Quantization | 4-bit BnB (NF4) |
| Batch Size | 2 |
| Gradient Accumulation | 4 |
| Effective Batch Size | 8 |
| Learning Rate | 2e-4 |
| LR Scheduler | Linear |
| Warmup Steps | 5 |
| Epochs | 3 |
| Optimizer | AdamW 8-bit |
| Weight Decay | 0.001 |
| Seed | 42 |
conversations array (system/user/assistant turns)-100 (ignored in loss); only assistant responses trained<bos> tokens introduced by processor<|turn>model\n boundary to precisely mask prefix vs. suffix| Risk | Mitigation | Status |
|---|---|---|
| Hallucinated section numbers | RAG context injected in system prompt; model trained ONLY on provided legal text | Tested |
| Victim-blaming | Explicit negative training: never says "talk to husband", "compromise", "family matter" | Tested |
| Emergency mishandling | Upstream hardcoded detector bypasses LLM for active violence; this model handles post-emergency guidance | Tested |
| Hindi-English script mixing | Purity checker enforces ≥85% Devanagari; LoRA trained on pure Devanagari targets | Tested |
| Malevolent use (evasion advice) | Refuses to provide advice on evading law; always directs to legal aid | Monitored |
from unsloth import FastModel
from unsloth.chat_templates import get_chat_template
# Load base + LoRA adapter
model, tokenizer = FastModel.from_pretrained(
model_name="unsloth/gemma-4-E2B-it-unsloth-bnb-4bit",
adapter_name="your-hf-username/stri-sakhi-gemma4-2b-lora", # this repo
max_seq_length=4096,
load_in_4bit=True,
)
tokenizer = get_chat_template(tokenizer, chat_template="gemma-4")
messages = [
{"role": "system", "content": "Tum Kanoon Sakhi ho. Sirf Devanagari Hindi mein jawab do."},
{"role": "user", "content": "mere pati ne mujhe ghar se nikaala hai"}
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
).to("cuda")
outputs = model.generate(
input_ids=inputs,
max_new_tokens=512,
temperature=0.2,
top_p=0.9,
)
print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[0])
# Merge LoRA into base for single-file deployment
model.save_pretrained_merged(
"stri-sakhi-merged",
tokenizer,
save_method="merged_16bit", # or "merged_4bit_for_mlx"
)
# Or export to GGUF for llama.cpp server
model.save_pretrained_gguf(
"stri-sakhi-q4_k_m",
tokenizer,
quantization_method="q4_k_m",
)
.
├── README.md # This file
├── adapter_config.json # LoRA config (PEFT)
├── adapter_model.safetensors # LoRA weights (~16 MB)
├── tokenizer/ # Tokenizer files (if customized)
├── benchmark_results.json # 50-case evaluation raw results
├── training_logs.txt # Loss curves per step
└── sample_inference.ipynb # Reproducible inference demo
| Step | Loss |
|---|---|
| 10 | 2.373 |
| 50 | 0.315 |
| 100 | 0.162 |
| 150 | 0.130 |
| 200 | 0.123 |
| 207 (final) | 0.349* |
Final epoch loss is higher than mid-epoch because the last batch contains harder, longer examples (property rights with multiple citations).
If you use this model in research or production, please cite:
@misc{stri-sakhi-gemma4-2b-2026,
title = {StriSakhi: A Safety-First Legal Advocate LLM for Indian Women},
author = {shubendu biswas},
year = {2026},
howpublished = {\url{https://huggingface.co/your-username/stri-sakhi-gemma4-2b-lora}},
note = {Fine-tuned Gemma-4 2B Instruct with LoRA for structured legal guidance}
}
Base model citation:
@article{gemma4-2026,
title={Gemma 4: A family of highly capable multimodal models},
author={Google DeepMind},
year={2026}
}
This model provides general legal information only and does not constitute legal advice. It is not a substitute for a licensed advocate. Always contact NALSA 15100 or your District Legal Services Authority (DLSA) for case-specific representation. The developers assume no liability for actions taken based on model outputs.
Model card generated for Hugging Face Open Source AI Challenge — Women Safety & Empowerment Track.