Text Generation
MLX
Safetensors
Transformers
longcat_next
multimodal
conversational
custom_code
8-bit precision
Instructions to use mlx-community/LongCat-Next-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/LongCat-Next-8bit 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/LongCat-Next-8bit") 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) - Transformers
How to use mlx-community/LongCat-Next-8bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mlx-community/LongCat-Next-8bit", 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/LongCat-Next-8bit", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- vLLM
How to use mlx-community/LongCat-Next-8bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mlx-community/LongCat-Next-8bit" # 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/LongCat-Next-8bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mlx-community/LongCat-Next-8bit
- SGLang
How to use mlx-community/LongCat-Next-8bit 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/LongCat-Next-8bit" \ --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/LongCat-Next-8bit", "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/LongCat-Next-8bit" \ --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/LongCat-Next-8bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Pi
How to use mlx-community/LongCat-Next-8bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/LongCat-Next-8bit"
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": "mlx-community/LongCat-Next-8bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use mlx-community/LongCat-Next-8bit 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 "mlx-community/LongCat-Next-8bit"
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 mlx-community/LongCat-Next-8bit
Run Hermes
hermes
- OpenClaw new
How to use mlx-community/LongCat-Next-8bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/LongCat-Next-8bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "mlx-community/LongCat-Next-8bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- MLX LM
How to use mlx-community/LongCat-Next-8bit 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/LongCat-Next-8bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/LongCat-Next-8bit" # 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/LongCat-Next-8bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use mlx-community/LongCat-Next-8bit with Docker Model Runner:
docker model run hf.co/mlx-community/LongCat-Next-8bit
| from transformers.configuration_utils import PretrainedConfig | |
| from transformers.models.qwen2_5_vl.configuration_qwen2_5_vl import Qwen2_5_VLVisionConfig | |
| from transformers.models.whisper.configuration_whisper import WhisperConfig | |
| from .configuration_longcat_ngram import LongcatFlashNgramConfig | |
| class LongcatNextConfig(LongcatFlashNgramConfig): | |
| model_type = "longcat_next" | |
| def __init__( | |
| self, | |
| vocab_size=131072, | |
| hidden_size=6144, | |
| num_hidden_layers=56, | |
| num_layers=28, | |
| num_attention_heads=64, | |
| num_key_value_heads=None, | |
| hidden_act="silu", | |
| max_position_embeddings=131072, | |
| initializer_range=0.02, | |
| rms_norm_eps=1e-5, | |
| use_cache=True, | |
| pad_token_id=None, | |
| bos_token_id=1, | |
| eos_token_id=2, | |
| tie_word_embeddings=False, | |
| rope_theta=10000000.0, | |
| rope_scaling=None, | |
| attention_bias=False, | |
| attention_dropout=0.0, | |
| ffn_hidden_size=12288, | |
| q_lora_rank=1536, | |
| kv_lora_rank=512, | |
| qk_nope_head_dim=128, | |
| qk_rope_head_dim=64, | |
| head_dim=64, | |
| v_head_dim=128, | |
| qk_head_dim=None, | |
| moe_topk=12, | |
| n_routed_experts=512, | |
| zero_expert_num=256, | |
| expert_ffn_hidden_size=2048, | |
| routed_scaling_factor=6.0, | |
| emb_neighbor_num=None, | |
| emb_split_num=None, | |
| ngram_vocab_size_ratio=None, | |
| oe_ignored_token_ids=[], | |
| text_vocab_size=131072, # text vocab size (vocab_size = text_vocab_size + audio_token + visual_token + multimodal_special_token_list) | |
| text_vocab_plus_multimodal_special_token_size=131125, | |
| visual_embedding_layer_intermediate_size=8192, | |
| visual_embedding_layer_hidden_act="silu", | |
| visual_offset=150581, | |
| audio_offset=131125, | |
| visual_config={}, | |
| audio_config={}, | |
| **kwargs, | |
| ): | |
| self.text_vocab_size = text_vocab_size | |
| self.text_vocab_plus_multimodal_special_token_size = text_vocab_plus_multimodal_special_token_size | |
| self.visual_embedding_layer_intermediate_size = visual_embedding_layer_intermediate_size | |
| self.visual_embedding_layer_hidden_act = visual_embedding_layer_hidden_act | |
| self.visual_offset = visual_offset | |
| self.audio_offset = audio_offset | |
| self.visual_config = LongcatNextVisualConfig(**visual_config) | |
| self.audio_config = LongcatNextAudioConfig(**audio_config) | |
| oe_ignored_token_ids = oe_ignored_token_ids or list(range(self.text_vocab_size, self.text_vocab_plus_multimodal_special_token_size)) | |
| super().__init__( | |
| vocab_size=vocab_size, | |
| hidden_size=hidden_size, | |
| num_hidden_layers=num_hidden_layers, | |
| num_layers=num_layers, | |
| num_attention_heads=num_attention_heads, | |
| num_key_value_heads=num_key_value_heads, | |
| hidden_act=hidden_act, | |
| max_position_embeddings=max_position_embeddings, | |
| initializer_range=initializer_range, | |
| rms_norm_eps=rms_norm_eps, | |
| use_cache=use_cache, | |
| pad_token_id=pad_token_id, | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| tie_word_embeddings=tie_word_embeddings, | |
| rope_theta=rope_theta, | |
| rope_scaling=rope_scaling, | |
| attention_bias=attention_bias, | |
| attention_dropout=attention_dropout, | |
| ffn_hidden_size=ffn_hidden_size, | |
| q_lora_rank=q_lora_rank, | |
| kv_lora_rank=kv_lora_rank, | |
| qk_nope_head_dim=qk_nope_head_dim, | |
| qk_rope_head_dim=qk_rope_head_dim, | |
| head_dim=head_dim, | |
| v_head_dim=v_head_dim, | |
| qk_head_dim=qk_head_dim, | |
| moe_topk=moe_topk, | |
| n_routed_experts=n_routed_experts, | |
| zero_expert_num=zero_expert_num, | |
| expert_ffn_hidden_size=expert_ffn_hidden_size, | |
| routed_scaling_factor=routed_scaling_factor, | |
| emb_neighbor_num=emb_neighbor_num, | |
| emb_split_num=emb_split_num, | |
| ngram_vocab_size_ratio=ngram_vocab_size_ratio, | |
| oe_ignored_token_ids=oe_ignored_token_ids, | |
| **kwargs, | |
| ) | |
| class LongcatNextVisualConfig(Qwen2_5_VLVisionConfig): | |
| model_type = "longcat_next_visual" | |
| base_config_key = "" | |
| def __init__( | |
| self, | |
| image_start_token_id=131106, | |
| image_end_token_id=131107, | |
| image_pad_token_id=131108, | |
| image_newline_token_id=131109, | |
| vq_config={}, | |
| visual_decoder_config={}, | |
| **kwargs, | |
| ): | |
| self.image_start_token_id = image_start_token_id | |
| self.image_end_token_id = image_end_token_id | |
| self.image_pad_token_id = image_pad_token_id | |
| self.image_newline_token_id = image_newline_token_id | |
| self.vq_config = PretrainedConfig(**vq_config) | |
| self.visual_decoder_config = PretrainedConfig(**visual_decoder_config) | |
| self.visual_decoder_config.image_decoder_config = PretrainedConfig(**getattr(self.visual_decoder_config, "image_decoder_config", {})) | |
| self.visual_decoder_config.transformer_config = PretrainedConfig(**getattr(self.visual_decoder_config, "transformer_config", {})) | |
| self.visual_decoder_config.vae_config = PretrainedConfig(**getattr(self.visual_decoder_config, "vae_config", {})) | |
| self.visual_decoder_config.scheduler_config = PretrainedConfig(**getattr(self.visual_decoder_config, "scheduler_config", {})) | |
| super().__init__(**kwargs) | |
| class LongcatNextAudioConfig(WhisperConfig): | |
| model_type = "longcat_next_audio" | |
| base_config_key = "" | |
| def __init__( | |
| self, | |
| vq_config={}, | |
| vocoder_config={}, | |
| flow_matching_config={}, | |
| cosy24kvocoder_config={}, | |
| **kwargs | |
| ): | |
| self.vq_config = PretrainedConfig(**vq_config) | |
| self.vocoder_config = PretrainedConfig(**vocoder_config) | |
| self.flow_matching_config = PretrainedConfig(**flow_matching_config) | |
| self.flow_matching_config.cfm_params = PretrainedConfig(**getattr(self.flow_matching_config, "cfm_params", {})) | |
| self.cosy24kvocoder_config = PretrainedConfig(**cosy24kvocoder_config) | |
| super().__init__(**kwargs) | |
| __all__ = ["LongcatNextConfig", "LongcatNextVisualConfig", "LongcatNextAudioConfig"] | |