Counsel-2B / README.md
sakasurya's picture
Model card: Gates
36e1ad8 verified
|
Raw History Blame Contribute Delete
6.96 kB
---
license: apache-2.0
language:
- en
library_name: transformers
pipeline_tag: text-generation
tags:
- legal
- law
- reasoning
- tool-use
- counsel
---
# Counsel-2B
Counsel-2B is a compact language model for legal work, built by JudicialMind. It reads statutes, regulations, contracts and case law
closely, answers with the provisions and authorities that support the answer, and works as the reasoning core of
legal research and document workflows that call tools. It keeps the general chat, reasoning and coding abilities
expected of a modern small model, so one model can handle both the legal question and the surrounding everyday work.
At 2.5 billion parameters it runs on a single consumer GPU or on CPU, which makes it suited to private, on-premise
deployments where documents cannot leave the organisation.
## Capabilities
**Legal**
- **Regulatory and statutory questions**: identifies the obligations a provision imposes, who they bind and under
what conditions, and answers from the text rather than from general impressions.
- **Cross-references**: follows "subject to", "as defined in" and "notwithstanding" links between provisions and
brings the connected passages into the answer.
- **Case-law research**: synthesises an answer from retrieved judgments and search results, citing the authorities it
relies on and separating holdings from commentary.
- **Contracts**: reviews clauses, explains risk and allocation (conditions, warranties, indemnities, limitation,
termination), compares drafts and proposes redlines.
- **Legal agent workflows**: plans multi-step tasks, calls document-search and matter-management tools, and reports
tool results faithfully, including failures and missing information, instead of claiming success.
**General**
- Instruction following and multi-turn conversation.
- Step-by-step reasoning in thinking mode, with the reasoning returned separately from the final answer.
- Function calling with JSON tool schemas.
- Everyday writing, summarisation and coding.
## Model details
| | |
|---|---|
| Model | Counsel-2B |
| Type | Decoder-only causal language model |
| Parameters | 2.52 B |
| Layers | 42 |
| Hidden size | 2,048 |
| Attention | 16 query heads, 2 key/value heads (grouped-query attention), head dimension 128 |
| Feed-forward | SwiGLU, intermediate size 6,144 |
| Normalisation | RMSNorm (ε = 1e-6) |
| Position encoding | Rotary (θ = 5,000,000) |
| Maximum positions | 131,072 |
| Vocabulary | 130,560 tokens |
| Weights | BF16, single `model.safetensors` (5.0 GB) |
| Language | English |
## Files
| File | Contents |
|---|---|
| `model.safetensors` | Model weights (BF16) |
| `config.json`, `generation_config.json` | Model and default generation settings |
| `configuration_counsel.py`, `modeling_counsel.py` | Counsel runtime: model classes and the `chat()` interface |
| `tokenizer.json`, `tokenizer_config.json`, `special_tokens_map.json` | Tokenizer |
| `chat_template.jinja` | Chat format, including thinking mode and tool calls |
| `LICENSE` | Apache License 2.0 |
## Quickstart
Requires `transformers` 5.x and `torch`.
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "judicialmind/Counsel-2B"
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16, device_map="auto")
answer = model.chat(tokenizer, "What is the difference between a condition and a warranty in contract law?")
print(answer)
```
### Thinking mode
`chat()` reasons step by step before answering by default (`thinking=True`); pass `thinking=False` for fast, direct
replies. The reasoning can be returned for inspection:
```python
answer, reasoning = model.chat(
tokenizer,
"A supplier must use 'reasonable endeavours' to deliver by 1 March. Is late delivery a breach?",
thinking=True,
return_reasoning=True,
)
```
### Conversations, system prompts and tools
```python
messages = [
{"role": "system", "content": "You are a careful legal research assistant. Cite the provisions you rely on."},
{"role": "user", "content": "Summarise the notice requirements in the clause below.\n\n<clause text>"},
]
print(model.chat(tokenizer, messages, thinking=False))
tools = [{
"type": "function",
"function": {
"name": "search_documents",
"description": "Full-text search over the matter's documents.",
"parameters": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]},
},
}]
print(model.chat(tokenizer, "Find every termination-for-convenience clause in the supply agreements.", tools=tools))
```
Tool calls are returned as `<function name="..."><param name="...">...</param></function>` blocks. Run the tool,
append its output as a `{"role": "tool", "content": ...}` message and call `chat()` again for the next step.
### Plain `generate()`
The model is a standard `transformers` causal LM, so the usual APIs work as well:
```python
prompt = tokenizer.apply_chat_template(
[{"role": "user", "content": "Explain the parol evidence rule."}],
add_generation_prompt=True, tokenize=False, enable_thinking=False,
)
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
output = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
```
### Recommended settings
| | Thinking | Direct |
|---|---|---|
| `temperature` | 0.6 – 0.8 | 0.3 – 0.7 (0 for deterministic output) |
| `top_p` | 0.95 | 0.95 |
| `max_new_tokens` | 2,048 – 4,096 | 512 – 1,024 |
## Gates
[`gates/`](gates) makes the agent loop enforce a careful work process (read every document, plan, draft, check, build),
so Counsel-2B finishes long, multi-document legal tasks fully. On legal agent tasks, the guided gates **doubled**
Counsel-2B's score: **8.9% → 18.1%** of criteria passed, without vs with gates.
## Use
Counsel-2B supports legal professionals and legal-operations teams; its output is not legal advice. Check citations and
conclusions against the primary sources before relying on them.
## License
Counsel-2B is released under the [Apache License 2.0](LICENSE).
## About JudicialMind
[JudicialMind](https://judicialmind.ai) builds an orchestrated system of specialized AI agents that work like a legal team, composed into workflows that run end-to-end legal operations: intake, research, drafting, negotiation and dispute resolution.
- 🌐 [judicialmind.ai](https://judicialmind.ai)
- 📧 surya@judicialmind.ai
- 🧑‍⚖️ [Early access](https://judicialmind.ai/waitlist)
## Citation
```bibtex
@misc{judicialmind2026counsel2b,
title = {Counsel-2B},
author = {{JudicialMind}},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/judicialmind/Counsel-2B}}
}
```