Instructions to use mlx-community/Hunyuan-7B-Instruct-3bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mlx-community/Hunyuan-7B-Instruct-3bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mlx-community/Hunyuan-7B-Instruct-3bit", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("mlx-community/Hunyuan-7B-Instruct-3bit", trust_remote_code=True, dtype="auto") - MLX
How to use mlx-community/Hunyuan-7B-Instruct-3bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/Hunyuan-7B-Instruct-3bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- LM Studio
- vLLM
How to use mlx-community/Hunyuan-7B-Instruct-3bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mlx-community/Hunyuan-7B-Instruct-3bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/Hunyuan-7B-Instruct-3bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mlx-community/Hunyuan-7B-Instruct-3bit
- SGLang
How to use mlx-community/Hunyuan-7B-Instruct-3bit 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 "mlx-community/Hunyuan-7B-Instruct-3bit" \ --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": "mlx-community/Hunyuan-7B-Instruct-3bit", "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 "mlx-community/Hunyuan-7B-Instruct-3bit" \ --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": "mlx-community/Hunyuan-7B-Instruct-3bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - MLX LM
How to use mlx-community/Hunyuan-7B-Instruct-3bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/Hunyuan-7B-Instruct-3bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/Hunyuan-7B-Instruct-3bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/Hunyuan-7B-Instruct-3bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use mlx-community/Hunyuan-7B-Instruct-3bit with Docker Model Runner:
docker model run hf.co/mlx-community/Hunyuan-7B-Instruct-3bit
| { | |
| "architectures": [ | |
| "HunYuanForCausalLM" | |
| ], | |
| "attention_bias": false, | |
| "attention_dropout": 0.0, | |
| "attention_head_dim": 128, | |
| "auto_map": { | |
| "AutoConfig": "configuration_hunyuan.HunYuanConfig", | |
| "AutoModel": "modeling_hunyuan.HunyuanModel", | |
| "AutoModelForCausalLM": "modeling_hunyuan.HunYuanForCausalLM" | |
| }, | |
| "bos_token_id": 1, | |
| "cla_share_factor": 2, | |
| "eos_token_id": 2, | |
| "group_limited_greedy": false, | |
| "hidden_act": "silu", | |
| "hidden_size": 4096, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 14336, | |
| "kv_lora_rank": null, | |
| "max_position_embeddings": 4096, | |
| "mlp_bias": false, | |
| "model_type": "hunyuan", | |
| "moe_drop_tokens": false, | |
| "moe_intermediate_size": [ | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336, | |
| 14336 | |
| ], | |
| "moe_layer_num_skipped": 0, | |
| "moe_random_routing_dropped_token": false, | |
| "moe_topk": [ | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1 | |
| ], | |
| "n_group": false, | |
| "norm_topk_prob": false, | |
| "num_attention_heads": 32, | |
| "num_experts": 1, | |
| "num_hidden_layers": 32, | |
| "num_key_value_heads": 8, | |
| "num_shared_expert": [ | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1, | |
| 1 | |
| ], | |
| "pad_token_id": 0, | |
| "pretraining_tp": 1, | |
| "q_lora_rank": null, | |
| "qk_nope_head_dim": null, | |
| "qk_rope_head_dim": null, | |
| "quantization": { | |
| "group_size": 64, | |
| "bits": 3 | |
| }, | |
| "quantization_config": { | |
| "group_size": 64, | |
| "bits": 3 | |
| }, | |
| "rms_norm_eps": 1e-05, | |
| "rope_scaling": { | |
| "alpha": 1000.0, | |
| "beta_fast": 32, | |
| "beta_slow": 1, | |
| "factor": 1.0, | |
| "mscale": 1.0, | |
| "mscale_all_dim": 1.0, | |
| "type": "dynamic" | |
| }, | |
| "rope_theta": 10000.0, | |
| "routed_scaling_factor": false, | |
| "tie_word_embeddings": true, | |
| "topk_group": false, | |
| "torch_dtype": "bfloat16", | |
| "transformers_version": "4.41.2", | |
| "use_cache": true, | |
| "use_cla": false, | |
| "use_mixed_mlp_moe": false, | |
| "use_mla": false, | |
| "use_qk_norm": true, | |
| "v_head_dim": null, | |
| "vocab_size": 129024 | |
| } |