Instructions to use tiny-random/chatglm3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/chatglm3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/chatglm3", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("tiny-random/chatglm3", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/chatglm3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/chatglm3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/chatglm3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/chatglm3
- SGLang
How to use tiny-random/chatglm3 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 "tiny-random/chatglm3" \ --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": "tiny-random/chatglm3", "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 "tiny-random/chatglm3" \ --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": "tiny-random/chatglm3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/chatglm3 with Docker Model Runner:
docker model run hf.co/tiny-random/chatglm3
This is a randomly initialized tiny model based on THUDM/chatglm3-6b-128k for testing and debugging.
| Feature | Source | This repo |
|---|---|---|
| Parameters | 6.24B (7 FP16 .bin shards, 12.49GB; source ships no safetensors) | 9.31M |
| Weight files | 7 pytorch_model .bin shards, 12.49GB | 18.62 MB (model.safetensors) |
| Layers | 28 | 4 |
| Hidden width / FFN width | 4,096 / 13,696 | 128 / 512 |
| Q heads / KV groups / head dim | 32 / 2 / 128 | 4 / 2 / 32 |
| RoPE ratio / context | 500 / 131,072 | 500 / 8,192 |
| Prefix prompt | 2-layer learnable prefix | Same |
| Vocabulary rows / embedding tying | 65,024 / untied (source) | 65,024 / tied |
| Stored precision | FP16 | BF16 |
Transformers has not registered this ChatGLM revision, so the pinned upstream remote code is included. Its KV cache is a custom tuple format with learnable prefix prompts that predates the Transformers 5.x Cache API; the example runs generation with use_cache=False (full recomputation), and cached decoding is not claimed. The tiny checkpoint ties the output projection to the token embedding (the source shipped them untied), keeping the artifact at 18.62MB. Load with trust_remote_code=True.
| File path | Size |
|---|---|
| model.safetensors | 18.6MB |
Example usage
Transformers (β verified)
Load the included pinned ChatGLM implementation with trust_remote_code=True. The pinned tuple/prefix-prompt KV cache predates the Transformers 5.x Cache API, so generation uses use_cache=False.
def run_transformers(model_id: str):
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = str(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = (
AutoModelForCausalLM.from_pretrained(
model_id, trust_remote_code=True, dtype=torch.bfloat16, attn_implementation="eager"
)
.eval()
.cuda()
)
inputs = tokenizer("δ½ ε₯½οΌθ―·δ»η»δΈδΈδ½ θͺε·±γ", return_tensors="pt").to("cuda")
with torch.no_grad():
assert torch.isfinite(model(**inputs, use_cache=False).logits).all()
output = model.generate(**inputs, do_sample=False, max_new_tokens=8, use_cache=False)
print(tokenizer.decode(output[0], skip_special_tokens=True))
if __name__ == "__main__":
run_transformers(model_id="tiny-random/chatglm3")
SGLang (β verified)
SGLang 0.5.10 ships a native ChatGLMModel implementation; serve the tiny checkpoint with tensor parallelism:
sglang serve --model-path tiny-random/chatglm3 --tp 4 \
--dtype bfloat16 --context-length 1024 --host 0.0.0.0 --port 30000 \
--trust-remote-code
Send an OpenAI completion request:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:30000/v1", api_key="EMPTY")
resp = client.completions.create(
model="tiny-random/chatglm3", prompt="The quick brown fox", max_tokens=8, temperature=0
)
print(resp.choices[0].text)
Creating this repo
- Code: .meta/create_model.py
- Model structure: .meta/model.log
- Environment: .meta/env.json
Change log
- 2026-11-07: Initial version rebuilt from the official THUDM/chatglm3-6b-128k source, shipping its pinned remote code; generation runs without KV cache because the pinned tuple-cache implementation predates the Transformers Cache API.
This repo is generated by GPT-6.1-Sol.
- Downloads last month
- 148
Model tree for tiny-random/chatglm3
Base model
zai-org/chatglm3-6b-128k