--- license: apache-2.0 base_model: Qwen/Qwen3.6-27B language: - en pipeline_tag: text-generation library_name: gguf tags: - legal - consumer-protection - fdcpa - fcra - letter-writing - grant-writing - gguf - llama-cpp - ollama - qwen3 - lora --- # LocalLegal-27B **A calm, dignified consumer-rights letter-writer & grant writer.** It *organizes* the facts a person gives it and *drafts* clear, statute-grounded documents they can review, sign, and send themselves โ€” debt-validation and cease-contact letters (FDCPA), credit-report disputes and method-of-verification letters (FCRA), goodwill and medical-billing letters, identity-theft blocks, and grant/assistance narratives. > **This is document preparation, not legal advice.** LocalLegal is not a lawyer, does not give legal advice, and never predicts the outcome of a case. It states what a statute *says* and what a letter *requests* โ€” and hands anything past the letter stage (lawsuits, garnishment, liens, court dates) to free legal aid or a licensed attorney. Built by **[Swarm & Bee](https://huggingface.co/SwarmandBee)** โ€” the brain behind the LocalLegal "write + send certified from home" flow. --- ## ๐Ÿ† It beat base โ€” decisively, on both domains Stage-5 gate: **held-out, per-domain, deterministic** evaluation. Teacher-forced cross-entropy / perplexity on chat-templated eval, base vs cooked, **same tokenizer & template, N=400/domain, seed 1117, seq 4096, bf16** on an RTX PRO 6000. **No LLM-as-judge** โ€” a number anyone can re-derive. | Domain | Base ppl | LocalLegal-27B ppl | ฮ” | Base CE โ†’ Cooked CE | |---|--:|--:|--:|---| | **Legal** (FDCPA/FCRA letters) | 16.662 | **2.058** | **โˆ’87.65%** | 2.813 โ†’ 0.722 | | **Grant** (proposal narratives) | 3.250 | **2.022** | **โˆ’37.80%** | 1.179 โ†’ 0.704 | **Beat base on both. Killed domains: none.** Cooked CE (~0.70โ€“0.72) matches the training landing (~0.64โ€“0.77) โ†’ coherent, **no overfit**. The legal gain exceeds our DiabeticAnchor-27B reference (+57%). The 44%-share, 9%-truncation grant tail passed clean โ€” not undercooked. Receipts (deterministic, re-runnable): `beat_base_27b.py` ยท `beat_base_27b.log` ยท `beat_base_27b_verdict.json`. --- ## ๐Ÿ”ง Usage This repo ships a **Q4 GGUF** (~16 GB) โ€” runs on llama.cpp / Ollama / LM Studio. Qwen3.6 is a **thinking model**, so the chat template prefills an empty `` block; the included `Modelfile` handles this for you. ### Ollama ```bash # with the included Modelfile (carries the template + system prompt + params) ollama create locallegal-27b -f locallegal-27b.Modelfile ollama run locallegal-27b "Draft an FDCPA debt-validation letter. Collector: Midland Credit. Account #4402, $1,284 medical debt I don't recognize." ``` ### llama.cpp ```bash ./llama-cli -m locallegal-27b-q4.gguf -c 8192 --temp 0.6 --top-p 0.9 \ -p "" ``` **Recommended sampling:** `temperature 0.6`, `top_p 0.9`, `num_ctx 8192`. Stop tokens `<|im_start|>` / `<|im_end|>` (ChatML). ### System prompt (its identity โ€” every letter includes header, RE: line, statute cite, specific request, response window, signature block) The model is trained to the LocalLegal persona: calm, factual, never shaming, uses the verbs *organize / draft / prepare / review / track*, and refuses to say "legal advice," "sue them," "you'll win," or "guaranteed." Full system prompt ships in the `Modelfile`. --- ## ๐Ÿณ How it was cooked - **Base:** [`Qwen/Qwen3.6-27B`](https://huggingface.co/Qwen/Qwen3.6-27B) (Apache-2.0) โ€” hybrid Gated-DeltaNet + Gated-Attention arch, thinking model. - **Method:** LoRA r32 / ฮฑ16 on attn+mlp ยท LR 1e-5 ยท cosine ยท seq 4096 ยท bf16 ยท Unsloth + TRL. Clean 16-bit merge โ†’ Q4 GGUF. - **Corpus:** **78,231 train / 2,500 eval**, curated down from ~340K raw rows via cross-domain dedup, eval carve-out, hash-scrub of contaminants, and near-dup pruning. Split **Legal 57.8% / Grant 42.2%** (natural balance, zero synthetic upsampling). **Per-domain true holdout** eval (legal 1,500 / grant 1,000). - **Loss:** 2.156 โ†’ 0.768 (โˆ’64%), smooth monotone, grad_norm 0.20 โ€” textbook curve, no spikes/NaN, no overcook. - **Rig:** SwarmRails (owned) ยท 1ร— RTX PRO 6000 Blackwell 96 GB ยท 350 W thermal cap ยท 45.7 h wall. Sovereign compute โ€” cooked on our own iron. - **Discipline:** full canary-then-cook (5-stage senior-hack review) โ€” beat-base-or-kill, per domain, no blended half-truths. ## ๐Ÿ“ Files - `locallegal-27b-q4.gguf` โ€” Q4 quantized weights (~16 GB) - `locallegal-27b.Modelfile` โ€” Ollama template + system prompt + params ## ๐Ÿ”’ Defendable Every claim here has a receipt: deterministic per-domain beat-base eval (no LLM judge), monotone loss curve, hash-verified corpus, and a full cook flightsheet. Show the math, verify it yourself. ## โš–๏ธ Scope & safety Document preparation only. Not legal advice, not a lawyer, no outcome predictions. Anything beyond the letter stage โ†’ free legal aid (LawHelp.org) / a licensed consumer-protection attorney / your state Attorney General. As a fine-tune of Qwen3.6-27B, it inherits the base model's Apache-2.0 terms and general LLM limitations (it can be wrong โ€” a human reviews and signs every letter). ## Citation ``` @misc{locallegal27b2026, title = {LocalLegal-27B: a statute-grounded consumer-rights letter-writer}, author = {Swarm and Bee}, year = {2026}, note = {LoRA fine-tune of Qwen3.6-27B; deterministic per-domain beat-base eval}, url = {https://huggingface.co/SwarmandBee/LocalLegal-27B} } ```