Downloads · 30 days
20
30% of all-time downloads
esherialabs/lexchat-Llama-3.1-8B-GRPO
lexchat-Llama-3.1-8B-GRPO is a reinforcement learning model from esherialabs. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as llama3.1.
A Kenya-first, RL-tuned Llama-3.1-8B checkpoint (GRPO on our SFT base) engineered for court-ready submissions. Rewarded for spine discipline (BLUF → Governing Rules → Controlling Holdings → Application → Relief Sought…
Downloads · 30 days
20
30% of all-time downloads
All-time downloads
67
Public
Repo size
353 MB
Likes
0
Public
Click a slice to open those files.
.safetensors336 MB · 95%
From the Hugging Face model README
A Kenya-first, RL-tuned Llama-3.1-8B checkpoint (GRPO on our SFT base) engineered for court-ready submissions. Rewarded for spine discipline (BLUF → Governing Rules → Controlling Holdings → Application → Relief Sought), side alignment, jurisdiction purity, and wordband control—so drafts land clean and on-spec. Purpose-built to democratize legal drafting capacity for NGOs, legal aid clinics, community justice centers, and paralegal programs under advocate supervision.
Who this is for
Primary use cases
Out of scope
esherialabs/kenya-court-submissions-qa (15k Q/A SFT set), plus posture/side variants and short issue packs (rule keys per remedy: Giella/Nguruman tests, proportionality, JR standards, indefeasibility, etc.).Base policy: our Kenya-legal SFT checkpoint on Lexchat-Llama-3.1-8B-Instruct
Parameter-efficient RL: LoRA updates only; 4-bit base frozen
r=32, alpha=16, dropout=0.05 on attention + MLP projections.Why GRPO here? Each prompt spawns 6 completions; relative advantages are computed within the group, so winners are pushed up while underperformers are suppressed—an implicit self-competition that works well with tiny batches and mixed, programmatic rewards.
All heads are summed. A “perfectly formatted, on-side, on-jurisdiction, on-band” answer tops out near 4.0. Partial structure still earns partial credit to avoid collapse.
Section-Order Rewards (0 → 1.5)
soft_spine_reward (+0.5): all five section headers present in order (case-insensitive; tolerates spacing).strict_spine_reward (+0.5): headers present with newline discipline and bullet semantics where required (• in Application).header_quality_reward (+0.5): BLUF starts with a clear, one-paragraph thesis; Relief ends with concrete prayers.Side-Alignment Reward (0 → 0.5)
Jurisdiction-Purity Reward (0 → 0.5)
Wordband Reward (0 → 0.5)
Cite-Format Reward (0 → 0.5)
Doctrine-Coverage Reward (0 → 0.5)
No separate judge model. All verifiers are deterministic string/AST checks and rulepack lookups. This keeps the loop single-model and hardware-friendly.
Recommended chat format
<|system|>
You are a Kenya court submissions generator. Output MUST follow:
BLUF → Governing Rules → Controlling Holdings → Application → Relief Sought.
Kenya authorities only unless marked persuasive.
<|user|>
Draft from the Applicant’s perspective in a Judicial Review (interlocutory stay).
Facts: [salient facts].
Issues: (1) Article 47 procedural fairness (2) Threshold for stay pending JR.
Constraints: Max ~600 words. Submissions style. Bullets only in Application.
<|assistant|>
Python (merged checkpoint)
from transformers import AutoModelForCausalLM, AutoTokenizer
name = "esherialabs/lexchat-Llama-3.1-8B-GRPO" # replace with final repo id
tok = AutoTokenizer.from_pretrained(name, use_fast=True)
m = AutoModelForCausalLM.from_pretrained(name, torch_dtype="auto", device_map="auto")
prompt = "<|system|>\\n...see above...\\n<|user|>\\n...case brief...\\n<|assistant|>\\n"
ids = tok(prompt, return_tensors="pt").to(m.device)
out = m.generate(**ids, max_new_tokens=900, temperature=0.25, top_p=0.9, do_sample=True, eos_token_id=tok.eos_token_id)
print(tok.decode(out[0][ids['input_ids'].shape[1]:], skip_special_tokens=True))
Inference policy
top_p=0.9; max_new_tokens ≤ 900.Automated
Human review
esherialabs/lexchat-Llama-3.1-8B-Instruct (SFT on Kenya submissions spine).r=32, α=16, p=0.05; 4-bit NF4; bf16 compute; paged AdamW; cosine LR; warmup; clip=0.1; gradient checkpointing.Legal aid clinic — eviction
You are drafting from the Applicant’s perspective in a Kenyan Constitutional Petition (interim conservatory orders).
Facts: Community clinic evicted without notice from county-owned premises after serving low-income patients.
Issues: (1) Article 47 procedural fairness (2) Article 40 property/use rights vs public interest (3) Conservatory order threshold.
Constraints: BLUF → Governing Rules → Controlling Holdings → Application → Relief Sought. Kenya authorities only. Max ~600 words.
Paralegal — employment dispute
You are drafting from the Respondent’s perspective in an Employment & Labour Court appeal.
Facts: Termination for cause with documented warnings; claimant alleges unfair termination.
Issues: (1) Fair procedure under Employment Act (2) Burden of proof and remedies.
Constraints: [same as above]
Esheria Labs (2025). LexChat 8B — Kenya Court Submissions Generator (GRPO).
https://huggingface.co/esherialabs/esherialabs/lexchat-Llama-3.1-8B-GRPO
Trained on: https://huggingface.co/datasets/esherialabs/kenya-court-submissions-qa