Instructions to use kalomaze/Mistral-7b-MoEified-8x with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kalomaze/Mistral-7b-MoEified-8x with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kalomaze/Mistral-7b-MoEified-8x")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("kalomaze/Mistral-7b-MoEified-8x") model = AutoModelForCausalLM.from_pretrained("kalomaze/Mistral-7b-MoEified-8x") - llama-cpp-python
How to use kalomaze/Mistral-7b-MoEified-8x with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="kalomaze/Mistral-7b-MoEified-8x", filename="ggml-model-f16.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use kalomaze/Mistral-7b-MoEified-8x with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf kalomaze/Mistral-7b-MoEified-8x:F16 # Run inference directly in the terminal: llama-cli -hf kalomaze/Mistral-7b-MoEified-8x:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf kalomaze/Mistral-7b-MoEified-8x:F16 # Run inference directly in the terminal: llama-cli -hf kalomaze/Mistral-7b-MoEified-8x:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf kalomaze/Mistral-7b-MoEified-8x:F16 # Run inference directly in the terminal: ./llama-cli -hf kalomaze/Mistral-7b-MoEified-8x:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf kalomaze/Mistral-7b-MoEified-8x:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf kalomaze/Mistral-7b-MoEified-8x:F16
Use Docker
docker model run hf.co/kalomaze/Mistral-7b-MoEified-8x:F16
- LM Studio
- Jan
- vLLM
How to use kalomaze/Mistral-7b-MoEified-8x with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kalomaze/Mistral-7b-MoEified-8x" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kalomaze/Mistral-7b-MoEified-8x", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/kalomaze/Mistral-7b-MoEified-8x:F16
- SGLang
How to use kalomaze/Mistral-7b-MoEified-8x 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 "kalomaze/Mistral-7b-MoEified-8x" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kalomaze/Mistral-7b-MoEified-8x", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "kalomaze/Mistral-7b-MoEified-8x" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kalomaze/Mistral-7b-MoEified-8x", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use kalomaze/Mistral-7b-MoEified-8x with Ollama:
ollama run hf.co/kalomaze/Mistral-7b-MoEified-8x:F16
- Unsloth Studio new
How to use kalomaze/Mistral-7b-MoEified-8x with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for kalomaze/Mistral-7b-MoEified-8x to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for kalomaze/Mistral-7b-MoEified-8x to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for kalomaze/Mistral-7b-MoEified-8x to start chatting
- Docker Model Runner
How to use kalomaze/Mistral-7b-MoEified-8x with Docker Model Runner:
docker model run hf.co/kalomaze/Mistral-7b-MoEified-8x:F16
- Lemonade
How to use kalomaze/Mistral-7b-MoEified-8x with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull kalomaze/Mistral-7b-MoEified-8x:F16
Run and chat with the model
lemonade run user.Mistral-7b-MoEified-8x-F16
List all available models
lemonade list
output = llm(
"Once upon a time,",
max_tokens=512,
echo=True
)
print(output)Wtf is a MoEification?!
Turns out, you can slice up the individual MLP layers of a dense language model into even splits of experts.
What I did here:
- Split the MLP projections (gate, down, proj) into the amount of total experts you want (in this case, I just went with 8 experts).
- Multiply the values of the parameters for the down-projection by the total amount of experts (so the magnitude of the activation outputs, when averaged linearly together, ends up being equivalent)
- Initialize the router layers with zeroes, so the expert usage is completely equal by default and has no unintentional biases as a consequence of random initialization being done the normal way.
As a result, the model behaves completely coherently when all 8 experts are activated (i.e, experts_per_tok is equal to 8.)
With 4 experts activated, it's... far less coherent.
Ok but why?
I am interested in the prospect of continuing to train this in such a way where it can naturally handle variable expert counts, and learn to balance the features. If this works, we can potentially teach the behavior of using less computation for tokens that are trivial to predict, while using more when necessary.
Also thanks StefanGliga for giving me the idea while we were discussing this paper :3
- Downloads last month
- 602


# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="kalomaze/Mistral-7b-MoEified-8x", filename="ggml-model-f16.gguf", )