Instructions to use judicialmind/Counsel-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use judicialmind/Counsel-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="judicialmind/Counsel-2B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("judicialmind/Counsel-2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use judicialmind/Counsel-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "judicialmind/Counsel-2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "judicialmind/Counsel-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/judicialmind/Counsel-2B
- SGLang
How to use judicialmind/Counsel-2B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "judicialmind/Counsel-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "judicialmind/Counsel-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "judicialmind/Counsel-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "judicialmind/Counsel-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use judicialmind/Counsel-2B with Docker Model Runner:
docker model run hf.co/judicialmind/Counsel-2B
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.
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:
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
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:
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/ 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.
About JudicialMind
JudicialMind 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
- ๐ง surya@judicialmind.ai
- ๐งโโ๏ธ Early access
Citation
@misc{judicialmind2026counsel2b,
title = {Counsel-2B},
author = {{JudicialMind}},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/judicialmind/Counsel-2B}}
}
- Downloads last month
- 33