Text Generation
Transformers
Safetensors
glm4_moe_lite
llm-compressor
tiny-model
mtp
pr-3225
test-fixture
conversational
Instructions to use inference-optimization/GLM-4.7-Flash-0.82B-MTP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use inference-optimization/GLM-4.7-Flash-0.82B-MTP with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="inference-optimization/GLM-4.7-Flash-0.82B-MTP") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("inference-optimization/GLM-4.7-Flash-0.82B-MTP") model = AutoModelForCausalLM.from_pretrained("inference-optimization/GLM-4.7-Flash-0.82B-MTP", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use inference-optimization/GLM-4.7-Flash-0.82B-MTP with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "inference-optimization/GLM-4.7-Flash-0.82B-MTP" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "inference-optimization/GLM-4.7-Flash-0.82B-MTP", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/inference-optimization/GLM-4.7-Flash-0.82B-MTP
- SGLang
How to use inference-optimization/GLM-4.7-Flash-0.82B-MTP 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 "inference-optimization/GLM-4.7-Flash-0.82B-MTP" \ --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": "inference-optimization/GLM-4.7-Flash-0.82B-MTP", "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 "inference-optimization/GLM-4.7-Flash-0.82B-MTP" \ --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": "inference-optimization/GLM-4.7-Flash-0.82B-MTP", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use inference-optimization/GLM-4.7-Flash-0.82B-MTP with Docker Model Runner:
docker model run hf.co/inference-optimization/GLM-4.7-Flash-0.82B-MTP
Download validation.json from inference-optimization/GLM-4.7-Flash-0.82B-MTP: direct link, hf CLI and curl.
- Browser
- Download file 11.2 kB
-
https://huggingface.co/inference-optimization/GLM-4.7-Flash-0.82B-MTP/resolve/main/validation.json
- Command line
-
hf download hf://inference-optimization/GLM-4.7-Flash-0.82B-MTP/validation.json
-
curl -L -o validation.json https://huggingface.co/inference-optimization/GLM-4.7-Flash-0.82B-MTP/resolve/main/validation.json
11.2 kB
| { | |
| "llm_compressor_commit": "2d5242056a8a00028686a303771ffc8e2fe27d07", | |
| "compressed_tensors_commit": "e69c8dc58aa152e5f5e36e85800ec1d2e7de5271", | |
| "transformers": "5.17.0", | |
| "torch": "2.14.0+cu130", | |
| "vllm": "0.30.0", | |
| "base_architecture": "zai-org/GLM-4.7-Flash", | |
| "base_revision": "7dd20894a642a0aa287e9827cb1a1f7f91386b67", | |
| "fixture": "glm4-moe-lite-native-depth", | |
| "variant": "source", | |
| "parameter_counts": { | |
| "architecture": "Glm4MoeLiteForCausalLM", | |
| "backbone_parameters": 808008192, | |
| "mtp_parameters": 13330944, | |
| "total_parameters": 821339136, | |
| "native_depth": true, | |
| "model_patches": false, | |
| "changes": { | |
| "hidden_size": { | |
| "original": 2048, | |
| "tiny": 768 | |
| }, | |
| "intermediate_size": { | |
| "original": 10240, | |
| "tiny": 3072 | |
| }, | |
| "moe_intermediate_size": { | |
| "original": 1536, | |
| "tiny": 384 | |
| }, | |
| "num_attention_heads": { | |
| "original": 20, | |
| "tiny": 8 | |
| }, | |
| "num_key_value_heads": { | |
| "original": 20, | |
| "tiny": 8 | |
| }, | |
| "n_routed_experts": { | |
| "original": 64, | |
| "tiny": 8 | |
| }, | |
| "kv_lora_rank": { | |
| "original": 512, | |
| "tiny": 256 | |
| }, | |
| "q_lora_rank": { | |
| "original": 768, | |
| "tiny": 512 | |
| }, | |
| "n_group": { | |
| "original": 1, | |
| "tiny": 4 | |
| }, | |
| "topk_group": { | |
| "original": 1, | |
| "tiny": 4 | |
| }, | |
| "num_mtp_layers": { | |
| "original": null, | |
| "tiny": 1 | |
| }, | |
| "mtp_mlp_layer_types": { | |
| "original": null, | |
| "tiny": [ | |
| "sparse" | |
| ] | |
| } | |
| } | |
| }, | |
| "backbone_validation": { | |
| "name": "glm4-moe-lite-native-depth", | |
| "passed": true, | |
| "reloaded_perplexity": 1.5342336153729887, | |
| "model_patches": false, | |
| "backbone_parameters": 808008192, | |
| "backbone_activated_parameters_estimate": 645216768, | |
| "generation": "The capital of France is Paris. Paris is the largest city in France and serves as the country's political" | |
| }, | |
| "mtp_training": "synthetic initialized projections with trained final decoder block copied; not separately trained", | |
| "training": { | |
| "seed": 3225, | |
| "initialization": "random", | |
| "optimizer": "AdamW", | |
| "learning_rate": 0.0004, | |
| "weight_decay": 0.01, | |
| "batch_size": 2, | |
| "max_sequence_length": 160, | |
| "evaluation": "same toy corpus as training" | |
| }, | |
| "quantization-results": { | |
| "name": "glm4-moe-lite-native-depth", | |
| "world_size": 2, | |
| "mtp_fp8_layers": 32, | |
| "source": "fixtures/glm4-moe-lite-native-depth/source", | |
| "quantized": "fixtures/glm4-moe-lite-native-depth/fp8" | |
| }, | |
| "vllm-source-results": { | |
| "name": "glm4-moe-lite-native-depth", | |
| "mode": "source", | |
| "llm_args": { | |
| "model": "fixtures/glm4-moe-lite-native-depth/source", | |
| "dtype": "bfloat16", | |
| "tensor_parallel_size": 1, | |
| "gpu_memory_utilization": 0.25, | |
| "max_model_len": 256, | |
| "max_num_seqs": 4, | |
| "enforce_eager": true, | |
| "enable_prefix_caching": false, | |
| "seed": 3225, | |
| "disable_log_stats": false | |
| }, | |
| "generations": [ | |
| { | |
| "prompt": "The capital of France is", | |
| "text": " Paris. Paris is the largest city in France and serves as the country's political", | |
| "token_ids": [ | |
| 12089, | |
| 13, | |
| 12089, | |
| 374, | |
| 279, | |
| 7772, | |
| 3283, | |
| 304, | |
| 9621, | |
| 323, | |
| 17026, | |
| 438, | |
| 279, | |
| 3146, | |
| 594, | |
| 4948 | |
| ], | |
| "cumulative_logprob": -1.0733059216290712, | |
| "toy_keyword_match": true | |
| }, | |
| { | |
| "prompt": "The creator of the theory of relativity was Albert", | |
| "text": " Einstein. Einstein developed the special theory of relativity in 1905 and the", | |
| "token_ids": [ | |
| 53690, | |
| 13, | |
| 53690, | |
| 7881, | |
| 279, | |
| 3281, | |
| 10121, | |
| 315, | |
| 1351, | |
| 43166, | |
| 304, | |
| 220, | |
| 114146, | |
| 20, | |
| 323, | |
| 279 | |
| ], | |
| "cumulative_logprob": -0.7155595435760915, | |
| "toy_keyword_match": true | |
| }, | |
| { | |
| "prompt": "The classic game is called rock, paper,", | |
| "text": " scissors. Rock beats scissors beats scissors beats paper, and paper beats rock. Rock", | |
| "token_ids": [ | |
| 71079, | |
| 13, | |
| 9124, | |
| 33167, | |
| 71079, | |
| 33167, | |
| 71079, | |
| 33167, | |
| 5567, | |
| 11, | |
| 323, | |
| 5567, | |
| 33167, | |
| 6946, | |
| 13, | |
| 9124 | |
| ], | |
| "cumulative_logprob": -1.7960216077044606, | |
| "toy_keyword_match": true | |
| }, | |
| { | |
| "prompt": "Actions speak louder than", | |
| "text": " words. What you do matters more what you say. say you do than what", | |
| "token_ids": [ | |
| 4244, | |
| 13, | |
| 3555, | |
| 498, | |
| 653, | |
| 12844, | |
| 803, | |
| 1128, | |
| 498, | |
| 1977, | |
| 13, | |
| 1977, | |
| 498, | |
| 653, | |
| 1091, | |
| 1128 | |
| ], | |
| "cumulative_logprob": -12.015646234154701, | |
| "toy_keyword_match": true | |
| } | |
| ], | |
| "speculative_metrics": [], | |
| "passed": true | |
| }, | |
| "vllm-fp8-results": { | |
| "name": "glm4-moe-lite-native-depth", | |
| "mode": "fp8", | |
| "llm_args": { | |
| "model": "fixtures/glm4-moe-lite-native-depth/fp8", | |
| "dtype": "bfloat16", | |
| "tensor_parallel_size": 1, | |
| "gpu_memory_utilization": 0.25, | |
| "max_model_len": 256, | |
| "max_num_seqs": 4, | |
| "enforce_eager": true, | |
| "enable_prefix_caching": false, | |
| "seed": 3225, | |
| "disable_log_stats": false | |
| }, | |
| "generations": [ | |
| { | |
| "prompt": "The capital of France is", | |
| "text": " Paris. Paris is the largest city in France and serves as the country's political", | |
| "token_ids": [ | |
| 12089, | |
| 13, | |
| 12089, | |
| 374, | |
| 279, | |
| 7772, | |
| 3283, | |
| 304, | |
| 9621, | |
| 323, | |
| 17026, | |
| 438, | |
| 279, | |
| 3146, | |
| 594, | |
| 4948 | |
| ], | |
| "cumulative_logprob": -1.0757355522364378, | |
| "toy_keyword_match": true | |
| }, | |
| { | |
| "prompt": "The creator of the theory of relativity was Albert", | |
| "text": " Einstein. Einstein developed the special theory of relativity in 1905 and the", | |
| "token_ids": [ | |
| 53690, | |
| 13, | |
| 53690, | |
| 7881, | |
| 279, | |
| 3281, | |
| 10121, | |
| 315, | |
| 1351, | |
| 43166, | |
| 304, | |
| 220, | |
| 114146, | |
| 20, | |
| 323, | |
| 279 | |
| ], | |
| "cumulative_logprob": -0.7127121277153492, | |
| "toy_keyword_match": true | |
| }, | |
| { | |
| "prompt": "The classic game is called rock, paper,", | |
| "text": " scissors. Rock beats scissors beats scissors beats paper, and paper beats rock. Rock", | |
| "token_ids": [ | |
| 71079, | |
| 13, | |
| 9124, | |
| 33167, | |
| 71079, | |
| 33167, | |
| 71079, | |
| 33167, | |
| 5567, | |
| 11, | |
| 323, | |
| 5567, | |
| 33167, | |
| 6946, | |
| 13, | |
| 9124 | |
| ], | |
| "cumulative_logprob": -1.8343840935267508, | |
| "toy_keyword_match": true | |
| }, | |
| { | |
| "prompt": "Actions speak louder than", | |
| "text": " words. What you do matters more what you say. say you do than what", | |
| "token_ids": [ | |
| 4244, | |
| 13, | |
| 3555, | |
| 498, | |
| 653, | |
| 12844, | |
| 803, | |
| 1128, | |
| 498, | |
| 1977, | |
| 13, | |
| 1977, | |
| 498, | |
| 653, | |
| 1091, | |
| 1128 | |
| ], | |
| "cumulative_logprob": -11.956631049513817, | |
| "toy_keyword_match": true | |
| } | |
| ], | |
| "speculative_metrics": [], | |
| "passed": true | |
| }, | |
| "vllm-mtp-results": { | |
| "name": "glm4-moe-lite-native-depth", | |
| "mode": "mtp", | |
| "llm_args": { | |
| "model": "fixtures/glm4-moe-lite-native-depth/fp8", | |
| "dtype": "bfloat16", | |
| "tensor_parallel_size": 1, | |
| "gpu_memory_utilization": 0.25, | |
| "max_model_len": 256, | |
| "max_num_seqs": 4, | |
| "enforce_eager": true, | |
| "enable_prefix_caching": false, | |
| "seed": 3225, | |
| "disable_log_stats": false, | |
| "speculative_config": { | |
| "method": "mtp", | |
| "num_speculative_tokens": 1 | |
| } | |
| }, | |
| "generations": [ | |
| { | |
| "prompt": "The capital of France is", | |
| "text": " Paris. Paris is the largest city in France and serves as the country's political", | |
| "token_ids": [ | |
| 12089, | |
| 13, | |
| 12089, | |
| 374, | |
| 279, | |
| 7772, | |
| 3283, | |
| 304, | |
| 9621, | |
| 323, | |
| 17026, | |
| 438, | |
| 279, | |
| 3146, | |
| 594, | |
| 4948 | |
| ], | |
| "cumulative_logprob": -1.0757355522364378, | |
| "toy_keyword_match": true | |
| }, | |
| { | |
| "prompt": "The creator of the theory of relativity was Albert", | |
| "text": " Einstein. Einstein developed the special theory of relativity in 1905 and the", | |
| "token_ids": [ | |
| 53690, | |
| 13, | |
| 53690, | |
| 7881, | |
| 279, | |
| 3281, | |
| 10121, | |
| 315, | |
| 1351, | |
| 43166, | |
| 304, | |
| 220, | |
| 114146, | |
| 20, | |
| 323, | |
| 279 | |
| ], | |
| "cumulative_logprob": -0.7127121277153492, | |
| "toy_keyword_match": true | |
| }, | |
| { | |
| "prompt": "The classic game is called rock, paper,", | |
| "text": " scissors. Rock beats scissors beats scissors beats paper, and paper beats rock. Rock", | |
| "token_ids": [ | |
| 71079, | |
| 13, | |
| 9124, | |
| 33167, | |
| 71079, | |
| 33167, | |
| 71079, | |
| 33167, | |
| 5567, | |
| 11, | |
| 323, | |
| 5567, | |
| 33167, | |
| 6946, | |
| 13, | |
| 9124 | |
| ], | |
| "cumulative_logprob": -1.8343840935267508, | |
| "toy_keyword_match": true | |
| }, | |
| { | |
| "prompt": "Actions speak louder than", | |
| "text": " words. What you do matters more what you say. say you do than what", | |
| "token_ids": [ | |
| 4244, | |
| 13, | |
| 3555, | |
| 498, | |
| 653, | |
| 12844, | |
| 803, | |
| 1128, | |
| 498, | |
| 1977, | |
| 13, | |
| 1977, | |
| 498, | |
| 653, | |
| 1091, | |
| 1128 | |
| ], | |
| "cumulative_logprob": -11.956631049513817, | |
| "toy_keyword_match": true | |
| } | |
| ], | |
| "speculative_metrics": [ | |
| { | |
| "name": "vllm:spec_decode_num_drafts", | |
| "value": 58 | |
| }, | |
| { | |
| "name": "vllm:spec_decode_num_draft_tokens", | |
| "value": 58 | |
| }, | |
| { | |
| "name": "vllm:spec_decode_num_accepted_tokens", | |
| "value": 3 | |
| }, | |
| { | |
| "name": "vllm:spec_decode_num_accepted_tokens_per_pos", | |
| "value": null | |
| } | |
| ], | |
| "passed": true | |
| } | |
| } | |