Instructions to use tiny-random/glm-5.2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/glm-5.2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/glm-5.2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tiny-random/glm-5.2") model = AutoModelForCausalLM.from_pretrained("tiny-random/glm-5.2", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/glm-5.2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/glm-5.2" # 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/glm-5.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/glm-5.2
- SGLang
How to use tiny-random/glm-5.2 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/glm-5.2" \ --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/glm-5.2", "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/glm-5.2" \ --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/glm-5.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/glm-5.2 with Docker Model Runner:
docker model run hf.co/tiny-random/glm-5.2
Upload folder using huggingface_hub
Browse files- README.md +6 -6
- config.json +1 -1
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -8,7 +8,7 @@ This tiny model is intended for debugging. It is randomly initialized using the
|
|
| 8 |
|
| 9 |
| File path | Size |
|
| 10 |
|------|------|
|
| 11 |
-
| model.safetensors | 26.
|
| 12 |
|
| 13 |
|
| 14 |
### Example usage:
|
|
@@ -98,7 +98,7 @@ config_json.update({
|
|
| 98 |
"first_k_dense_replace": 1,
|
| 99 |
"mlp_layer_types": ['dense'] + ['sparse'] * 3,
|
| 100 |
"hidden_size": 8,
|
| 101 |
-
"index_n_heads":
|
| 102 |
"indexer_types": ['full'] + ['shared'] * 3,
|
| 103 |
"index_topk_pattern": ['F'] + ['S'] * 3,
|
| 104 |
"intermediate_size": 32,
|
|
@@ -181,10 +181,10 @@ GlmMoeDsaForCausalLM(
|
|
| 181 |
(kv_b_proj): Linear(in_features=512, out_features=3584, bias=False)
|
| 182 |
(o_proj): Linear(in_features=2048, out_features=8, bias=False)
|
| 183 |
(indexer): GlmMoeDsaIndexer(
|
| 184 |
-
(wq_b): Linear(in_features=32, out_features=
|
| 185 |
(wk): Linear(in_features=8, out_features=128, bias=False)
|
| 186 |
(k_norm): LayerNorm((128,), eps=1e-06, elementwise_affine=True)
|
| 187 |
-
(weights_proj): Linear(in_features=8, out_features=
|
| 188 |
)
|
| 189 |
)
|
| 190 |
(mlp): GlmMoeDsaMLP(
|
|
@@ -239,10 +239,10 @@ GlmMoeDsaForCausalLM(
|
|
| 239 |
(kv_b_proj): Linear(in_features=512, out_features=3584, bias=False)
|
| 240 |
(o_proj): Linear(in_features=2048, out_features=8, bias=False)
|
| 241 |
(indexer): GlmMoeDsaIndexer(
|
| 242 |
-
(wq_b): Linear(in_features=32, out_features=
|
| 243 |
(wk): Linear(in_features=8, out_features=128, bias=False)
|
| 244 |
(k_norm): LayerNorm((128,), eps=1e-06, elementwise_affine=True)
|
| 245 |
-
(weights_proj): Linear(in_features=8, out_features=
|
| 246 |
)
|
| 247 |
)
|
| 248 |
(mlp): GlmMoeDsaMoE(
|
|
|
|
| 8 |
|
| 9 |
| File path | Size |
|
| 10 |
|------|------|
|
| 11 |
+
| model.safetensors | 26.7MB |
|
| 12 |
|
| 13 |
|
| 14 |
### Example usage:
|
|
|
|
| 98 |
"first_k_dense_replace": 1,
|
| 99 |
"mlp_layer_types": ['dense'] + ['sparse'] * 3,
|
| 100 |
"hidden_size": 8,
|
| 101 |
+
"index_n_heads": 32,
|
| 102 |
"indexer_types": ['full'] + ['shared'] * 3,
|
| 103 |
"index_topk_pattern": ['F'] + ['S'] * 3,
|
| 104 |
"intermediate_size": 32,
|
|
|
|
| 181 |
(kv_b_proj): Linear(in_features=512, out_features=3584, bias=False)
|
| 182 |
(o_proj): Linear(in_features=2048, out_features=8, bias=False)
|
| 183 |
(indexer): GlmMoeDsaIndexer(
|
| 184 |
+
(wq_b): Linear(in_features=32, out_features=4096, bias=False)
|
| 185 |
(wk): Linear(in_features=8, out_features=128, bias=False)
|
| 186 |
(k_norm): LayerNorm((128,), eps=1e-06, elementwise_affine=True)
|
| 187 |
+
(weights_proj): Linear(in_features=8, out_features=32, bias=False)
|
| 188 |
)
|
| 189 |
)
|
| 190 |
(mlp): GlmMoeDsaMLP(
|
|
|
|
| 239 |
(kv_b_proj): Linear(in_features=512, out_features=3584, bias=False)
|
| 240 |
(o_proj): Linear(in_features=2048, out_features=8, bias=False)
|
| 241 |
(indexer): GlmMoeDsaIndexer(
|
| 242 |
+
(wq_b): Linear(in_features=32, out_features=4096, bias=False)
|
| 243 |
(wk): Linear(in_features=8, out_features=128, bias=False)
|
| 244 |
(k_norm): LayerNorm((128,), eps=1e-06, elementwise_affine=True)
|
| 245 |
+
(weights_proj): Linear(in_features=8, out_features=32, bias=False)
|
| 246 |
)
|
| 247 |
)
|
| 248 |
(mlp): GlmMoeDsaMoE(
|
config.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
| 17 |
"hidden_act": "silu",
|
| 18 |
"hidden_size": 8,
|
| 19 |
"index_head_dim": 128,
|
| 20 |
-
"index_n_heads":
|
| 21 |
"index_share_for_mtp_iteration": true,
|
| 22 |
"index_skip_topk_offset": 3,
|
| 23 |
"index_topk": 2048,
|
|
|
|
| 17 |
"hidden_act": "silu",
|
| 18 |
"hidden_size": 8,
|
| 19 |
"index_head_dim": 128,
|
| 20 |
+
"index_n_heads": 32,
|
| 21 |
"index_share_for_mtp_iteration": true,
|
| 22 |
"index_skip_topk_offset": 3,
|
| 23 |
"index_topk": 2048,
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c380b6f0d6d1560368508cc5b64580e316754aa935aadf1b210de43b8650c86a
|
| 3 |
+
size 26675712
|