Text Generation
Transformers
Safetensors
English
counsel
legal
law
reasoning
tool-use
chat
conversational
custom_code
Instructions to use judicialmind/Counsel-27B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use judicialmind/Counsel-27B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="judicialmind/Counsel-27B", 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-27B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use judicialmind/Counsel-27B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "judicialmind/Counsel-27B" # 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-27B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/judicialmind/Counsel-27B
- SGLang
How to use judicialmind/Counsel-27B 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-27B" \ --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-27B", "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-27B" \ --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-27B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use judicialmind/Counsel-27B with Docker Model Runner:
docker model run hf.co/judicialmind/Counsel-27B
Download runtime/counsel_runtime/kernels/__init__.py from judicialmind/Counsel-27B: direct link, hf CLI and curl.
- Browser
- Download file 2.12 kB
-
https://huggingface.co/judicialmind/Counsel-27B/resolve/main/runtime/counsel_runtime/kernels/__init__.py
- Command line
-
hf download hf://judicialmind/Counsel-27B/runtime/counsel_runtime/kernels/__init__.py
-
curl -L -o __init__.py https://huggingface.co/judicialmind/Counsel-27B/resolve/main/runtime/counsel_runtime/kernels/__init__.py
2.12 kB
| """Counsel's GDN replay kernel for vLLM, used by `counsel-serve-vllm --mode copy`. | |
| Stock vLLM keeps 1 + num_speculative_tokens recurrent-state slots per request for the gated linear-attention (GDN) | |
| layers, so long copy drafts (128-512 tokens) do not fit next to a 27B model on one GPU. The replay kernel keeps one | |
| slot per request and rolls back a rejected draft tail by replaying the accepted tokens with the stock arithmetic, so | |
| outputs are bit-identical to plain decoding. VLLM_GDN_REPLAY_CHUNKED=1 verifies the draft window with the chunked | |
| prefill kernel. The patched code is inert unless VLLM_GDN_REPLAY=1 (which only --mode copy sets). | |
| `counsel-install-kernels` patches the installed vLLM 0.32.0 in place (needs the `patch` tool). | |
| """ | |
| import importlib.metadata | |
| import importlib.util | |
| import os | |
| import shutil | |
| import subprocess | |
| import sys | |
| VLLM_VERSION = "0.32.0" | |
| HERE = os.path.dirname(os.path.abspath(__file__)) | |
| def install(argv=None) -> None: | |
| spec = importlib.util.find_spec("vllm") | |
| if spec is None: | |
| sys.exit("vLLM is not installed in this environment") | |
| version = importlib.metadata.version("vllm") | |
| if version != VLLM_VERSION: | |
| sys.exit(f"the GDN replay kernel is built for vLLM {VLLM_VERSION}; this environment has {version}") | |
| root = os.path.dirname(spec.origin) | |
| site = os.path.dirname(root) | |
| utils = os.path.join(root, "model_executor", "layers", "mamba", "mamba_utils.py") | |
| if "GDN_REPLAY_PATCH" not in open(utils).read(): | |
| diff = os.path.join(HERE, "gdn_replay.diff") | |
| for extra in (["--dry-run"], []): # check the whole patch applies before touching anything | |
| r = subprocess.run(["patch", "-p0", "--forward", "--batch", *extra, "-i", diff], cwd=site, | |
| capture_output=True, text=True) | |
| if r.returncode: | |
| sys.exit(f"could not patch vLLM in {site}:\n{r.stdout}{r.stderr}") | |
| shutil.copy(os.path.join(HERE, "gdn_replay.py"), os.path.join(root, "model_executor", "layers", "mamba", "ops", "gdn_replay.py")) | |
| print(f"GDN replay kernel installed in vLLM {version} at {root}") | |