Instructions to use mlabonne/Beyonder-4x7B-v3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mlabonne/Beyonder-4x7B-v3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mlabonne/Beyonder-4x7B-v3") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mlabonne/Beyonder-4x7B-v3") model = AutoModelForCausalLM.from_pretrained("mlabonne/Beyonder-4x7B-v3") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use mlabonne/Beyonder-4x7B-v3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mlabonne/Beyonder-4x7B-v3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlabonne/Beyonder-4x7B-v3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mlabonne/Beyonder-4x7B-v3
- SGLang
How to use mlabonne/Beyonder-4x7B-v3 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 "mlabonne/Beyonder-4x7B-v3" \ --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": "mlabonne/Beyonder-4x7B-v3", "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 "mlabonne/Beyonder-4x7B-v3" \ --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": "mlabonne/Beyonder-4x7B-v3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use mlabonne/Beyonder-4x7B-v3 with Docker Model Runner:
docker model run hf.co/mlabonne/Beyonder-4x7B-v3
๐ฎ Beyonder-4x7B-v3
Beyonder-4x7B-v3 is an improvement over the popular Beyonder-4x7B-v2. It's a Mixture of Experts (MoE) made with the following models using LazyMergekit:
- mlabonne/AlphaMonarch-7B
- beowolx/CodeNinja-1.0-OpenChat-7B
- SanjiWatsuki/Kunoichi-DPO-v2-7B
- mlabonne/NeuralDaredevil-7B
Special thanks to beowolx for making the best Mistral-based code model and to SanjiWatsuki for creating one of the very best RP models.
Try the demo: https://huggingface.co/spaces/mlabonne/Beyonder-4x7B-v3
๐ Applications
This model uses a context window of 8k. I recommend using it with the Mistral Instruct chat template (works perfectly with LM Studio).
If you use SillyTavern, you might want to tweak the inference parameters. Here's what LM Studio uses as a reference: temp 0.8, top_k 40, top_p 0.95, min_p 0.05, repeat_penalty 1.1.
Thanks to its four experts, it's a well-rounded model, capable of achieving most tasks. As two experts are always used to generate an answer, every task benefits from other capabilities, like chat with RP, or math with code.
โก Quantized models
Thanks bartowski for quantizing this model.
- GGUF: https://huggingface.co/mlabonne/Beyonder-4x7B-v3-GGUF
- More GGUF: https://huggingface.co/bartowski/Beyonder-4x7B-v3-GGUF
- ExLlamaV2: https://huggingface.co/bartowski/Beyonder-4x7B-v3-exl2
๐ Evaluation
This model is not designed to excel in traditional benchmarks, as the code and role-playing models generally do not apply to those contexts. Nonetheless, it performs remarkably well thanks to strong general-purpose experts.
Nous
Beyonder-4x7B-v3 is one of the best models on Nous' benchmark suite (evaluation performed using LLM AutoEval) and significantly outperforms the v2. See the entire leaderboard here.
| Model | Average | AGIEval | GPT4All | TruthfulQA | Bigbench |
|---|---|---|---|---|---|
| mlabonne/AlphaMonarch-7B ๐ | 62.74 | 45.37 | 77.01 | 78.39 | 50.2 |
| mlabonne/Beyonder-4x7B-v3 ๐ | 61.91 | 45.85 | 76.67 | 74.98 | 50.12 |
| mlabonne/NeuralDaredevil-7B ๐ | 59.39 | 45.23 | 76.2 | 67.61 | 48.52 |
| SanjiWatsuki/Kunoichi-DPO-v2-7B ๐ | 58.29 | 44.79 | 75.05 | 65.68 | 47.65 |
| mlabonne/Beyonder-4x7B-v2 ๐ | 57.13 | 45.29 | 75.95 | 60.86 | 46.4 |
| beowolx/CodeNinja-1.0-OpenChat-7B ๐ | 50.35 | 39.98 | 71.77 | 48.73 | 40.92 |
EQ-Bench
Beyonder-4x7B-v3 is the best 4x7B model on the EQ-Bench leaderboard, outperforming older versions of ChatGPT and Llama-2-70b-chat. It is very close to Mixtral-8x7B-Instruct-v0.1 and Gemini Pro. Thanks Sam Paech for running the eval.
Open LLM Leaderboard
It's also a strong performer on the Open LLM Leaderboard, significantly outperforming the v2 model.
๐งฉ Configuration
base_model: mlabonne/AlphaMonarch-7B
experts:
- source_model: mlabonne/AlphaMonarch-7B
positive_prompts:
- "chat"
- "assistant"
- "tell me"
- "explain"
- "I want"
- source_model: beowolx/CodeNinja-1.0-OpenChat-7B
positive_prompts:
- "code"
- "python"
- "javascript"
- "programming"
- "algorithm"
- source_model: SanjiWatsuki/Kunoichi-DPO-v2-7B
positive_prompts:
- "storywriting"
- "write"
- "scene"
- "story"
- "character"
- source_model: mlabonne/NeuralDaredevil-7B
positive_prompts:
- "reason"
- "math"
- "mathematics"
- "solve"
- "count"
๐ณ Model Family Tree
๐ป Usage
!pip install -qU transformers bitsandbytes accelerate
from transformers import AutoTokenizer
import transformers
import torch
model = "mlabonne/Beyonder-4x7B-v3"
tokenizer = AutoTokenizer.from_pretrained(model)
pipeline = transformers.pipeline(
"text-generation",
model=model,
model_kwargs={"torch_dtype": torch.float16, "load_in_4bit": True},
)
messages = [{"role": "user", "content": "Explain what a Mixture of Experts is in less than 100 words."}]
prompt = pipeline.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
print(outputs[0]["generated_text"])
Output:
A Mixture of Experts (MoE) is a neural network architecture that tackles complex tasks by dividing them into simpler subtasks, delegating each to specialized expert modules. These experts learn to independently handle specific problem aspects. The MoE structure combines their outputs, leveraging their expertise for improved overall performance. This approach promotes modularity, adaptability, and scalability, allowing for better generalization in various applications.
- Downloads last month
- 8,244



