Text Generation
MLX
Safetensors
qwen3_5
apple-silicon
speculative-decoding
qwen
qwen3
mtp
mtplx
local-ai
q4
conversational
4-bit precision
Instructions to use Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed 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("Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed") 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
- Pi new
How to use Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed
Run Hermes
hermes
- MLX LM
How to use Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Youssofal/Qwen3.5-4B-MTPLX-Optimized-Speed", "messages": [ {"role": "user", "content": "Hello"} ] }'
| { | |
| "architectures": [ | |
| "Qwen3_5ForConditionalGeneration" | |
| ], | |
| "image_token_id": 248056, | |
| "library_name": "mlx", | |
| "mlx_lm_extra_tensors": { | |
| "mtp_file": "mtp.safetensors", | |
| "mtp_tensor_count": 29 | |
| }, | |
| "model_type": "qwen3_5", | |
| "mtplx_mtp_quantization": { | |
| "bits": 4, | |
| "description": "Official Qwen3.5-4B MTP head with layer-0 attention/MLP linears quantized to MLX affine INT4 group64; mtp.fc and norms stay BF16.", | |
| "group_size": 64, | |
| "mode": "affine", | |
| "policy": "cyankiwi", | |
| "prequantized": true | |
| }, | |
| "mtplx_policy": { | |
| "description": "mlx-community/Qwen3.5-4B-MLX-4bit trunk plus official Qwen3.5-4B MTP sidecar stored as body-int4 for MTPLX speed testing.", | |
| "local_official_source": "/Users/youssof/.mtplx/sources/Qwen--Qwen3.5-4B", | |
| "local_trunk_source": "/Users/youssof/.mtplx/sources/mlx-community--Qwen3.5-4B-MLX-4bit", | |
| "mtp_quantization": { | |
| "bits": 4, | |
| "group_size": 64, | |
| "linears": [ | |
| "mtp.layers.0.mlp.down_proj", | |
| "mtp.layers.0.mlp.gate_proj", | |
| "mtp.layers.0.mlp.up_proj", | |
| "mtp.layers.0.self_attn.k_proj", | |
| "mtp.layers.0.self_attn.o_proj", | |
| "mtp.layers.0.self_attn.q_proj", | |
| "mtp.layers.0.self_attn.v_proj" | |
| ], | |
| "mode": "affine", | |
| "norms": "bf16" | |
| }, | |
| "name": "qwen35-4b-q4-official-mtp-body-int4-speed", | |
| "quantization_family": "mlx-affine-q4", | |
| "source": "Qwen/Qwen3.5-4B", | |
| "trunk_quantization": { | |
| "bits": 4, | |
| "group_size": 64, | |
| "mode": "affine" | |
| }, | |
| "trunk_source": "mlx-community/Qwen3.5-4B-MLX-4bit" | |
| }, | |
| "quantization": { | |
| "bits": 4, | |
| "group_size": 64, | |
| "mode": "affine" | |
| }, | |
| "quantization_config": { | |
| "bits": 4, | |
| "group_size": 64, | |
| "mode": "affine" | |
| }, | |
| "text_config": { | |
| "attention_bias": false, | |
| "attention_dropout": 0.0, | |
| "attn_output_gate": true, | |
| "dtype": "bfloat16", | |
| "eos_token_id": 248044, | |
| "full_attention_interval": 4, | |
| "head_dim": 256, | |
| "hidden_act": "silu", | |
| "hidden_size": 2560, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 9216, | |
| "layer_types": [ | |
| "linear_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "full_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "full_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "full_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "full_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "full_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "full_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "full_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "linear_attention", | |
| "full_attention" | |
| ], | |
| "linear_conv_kernel_dim": 4, | |
| "linear_key_head_dim": 128, | |
| "linear_num_key_heads": 16, | |
| "linear_num_value_heads": 32, | |
| "linear_value_head_dim": 128, | |
| "mamba_ssm_dtype": "float32", | |
| "max_position_embeddings": 262144, | |
| "mlp_only_layers": [], | |
| "model_type": "qwen3_5_text", | |
| "mtp_num_hidden_layers": 1, | |
| "mtp_use_dedicated_embeddings": false, | |
| "num_attention_heads": 16, | |
| "num_hidden_layers": 32, | |
| "num_key_value_heads": 4, | |
| "rms_norm_eps": 1e-06, | |
| "rope_parameters": { | |
| "mrope_interleaved": true, | |
| "mrope_section": [ | |
| 11, | |
| 11, | |
| 10 | |
| ], | |
| "partial_rotary_factor": 0.25, | |
| "rope_theta": 10000000, | |
| "rope_type": "default" | |
| }, | |
| "tie_word_embeddings": true, | |
| "use_cache": true, | |
| "vocab_size": 248320 | |
| }, | |
| "tie_word_embeddings": true, | |
| "transformers_version": "4.57.0.dev0", | |
| "video_token_id": 248057, | |
| "vision_config": { | |
| "deepstack_visual_indexes": [], | |
| "depth": 24, | |
| "hidden_act": "gelu_pytorch_tanh", | |
| "hidden_size": 1024, | |
| "in_channels": 3, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 4096, | |
| "model_type": "qwen3_5", | |
| "num_heads": 16, | |
| "num_position_embeddings": 2304, | |
| "out_hidden_size": 2560, | |
| "patch_size": 16, | |
| "spatial_merge_size": 2, | |
| "temporal_patch_size": 2 | |
| }, | |
| "vision_end_token_id": 248054, | |
| "vision_start_token_id": 248053 | |
| } | |