Instructions to use cerebras/Kimi-Linear-REAP-35B-A3B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cerebras/Kimi-Linear-REAP-35B-A3B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cerebras/Kimi-Linear-REAP-35B-A3B-Instruct", trust_remote_code=True) 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("cerebras/Kimi-Linear-REAP-35B-A3B-Instruct", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("cerebras/Kimi-Linear-REAP-35B-A3B-Instruct", trust_remote_code=True, 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 cerebras/Kimi-Linear-REAP-35B-A3B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cerebras/Kimi-Linear-REAP-35B-A3B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cerebras/Kimi-Linear-REAP-35B-A3B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cerebras/Kimi-Linear-REAP-35B-A3B-Instruct
- SGLang
How to use cerebras/Kimi-Linear-REAP-35B-A3B-Instruct 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 "cerebras/Kimi-Linear-REAP-35B-A3B-Instruct" \ --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": "cerebras/Kimi-Linear-REAP-35B-A3B-Instruct", "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 "cerebras/Kimi-Linear-REAP-35B-A3B-Instruct" \ --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": "cerebras/Kimi-Linear-REAP-35B-A3B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cerebras/Kimi-Linear-REAP-35B-A3B-Instruct with Docker Model Runner:
docker model run hf.co/cerebras/Kimi-Linear-REAP-35B-A3B-Instruct
Why not experiment?
Why does it always have to be 3B activated parameters? That's too little for good performance. My theory is that upping that to 6B would massively improve the quality while it would still be very fast on mainstream systems.
Why does it always have to be 3B activated parameters? That's too little for good performance. My theory is that upping that to 6B would massively improve the quality while it would still be very fast on mainstream systems.
you are arguing with people that know what they are doing
Why does it always have to be 3B activated parameters? That's too little for good performance. My theory is that upping that to 6B would massively improve the quality while it would still be very fast on mainstream systems.
you are arguing with people that know what they are doing
it's a valid and obvious question to come up with though, the fact that people "know what they're doing" doesn't mean their approach is to maximize the gains, these small MoE models are primarily made for speed. and to give a hint to @Dampfinchen , you can manually set activated experts in your backend when running locally, so try increasing the number and see for yourself if that makes a difference.
Couple of things:
- size of models : number of experts is experimentally decided between a range of values
- higher number of experts/active params does not correlate directly to performance (diminishing returns), often experimental based on arch, data, etc.
- the MoE model optimization goal also considers being able to run on certain compute requirements while balancing quality (48BA3B should be similar in performance to a 32B-40B class dense model of sim arch/data)
- you can learn more about it here: https://www.cerebras.ai/blog/moe-guide-scale and also look into other MoE guides for expert activation math/active param math to learn more