Skip to main content
Back

Hugging Face's Zephyr-7B Beats Llama 2 70B With a Smarter Training Recipe

Hugging Face's H4 team fine-tuned Mistral 7B with Direct Preference Optimization on GPT-4 ranked feedback, beating Llama 2 70B Chat on MT-Bench.

Pro

  • Zephyr-7B-beta is a Mistral 7B fine-tune trained with Direct Preference Optimization by Hugging Face H4.
  • Scores 7.34 on MT-Bench, beating Llama 2 70B Chat (6.86) at one-tenth the parameters.
  • AlpacaEval win rate of 90.60% puts it near GPT-3.5-turbo territory.
  • Trained via distilled SFT on UltraChat then distilled DPO on GPT-4 ranked UltraFeedback pairs.
  • MIT licensed, runs on 4.5GB VRAM, works with vLLM, SGLang, Ollama, llama.cpp.
  • Weak on math and code (GSM8K 12.74) and not safety-aligned for production chat.

Hugging Face's H4 team released Zephyr-7B-beta, a small chat model that punches well above its weight class. It is a fine-tuned version of Mistral-7B-v0.1, trained on a mix of publicly available synthetic datasets using Direct Preference Optimization (DPO). The result is a 7B parameter assistant that outscores much larger open models on conversational benchmarks, shipped under an MIT license.

A 7B that outruns a 70B

The headline number comes from MT-Bench, a GPT-4 judged benchmark for multi-turn conversation. Zephyr became the first 7B model to beat Llama 2 70B Chat on that test (7.34 vs 6.86), evidence that DPO training on high-quality preference data can close much of the gap between small and large models. On AlpacaEval it hits a 90.60% win rate, in range of GPT-3.5-turbo (89.37%) and Claude 2 (91.36%), though still behind GPT-4 (95.28%).

The Open LLM Leaderboard tells a more mixed story. Zephyr averages 52.15 across the standard suite, with strong HellaSwag (84.36) and ARC (62.03) scores but weak GSM8K math (12.74) and DROP reading comprehension (9.66). On coding and mathematics, it lags well behind proprietary models.

The recipe: distilled DPO

The training pipeline, which the team calls distilled DPO (dDPO), is documented in their technical report. It has three stages:

  1. Distilled SFT on UltraChat, a large synthetic dialogue dataset generated by ChatGPT.
  2. AI feedback collection using UltraFeedback, where GPT-4 scores multiple model outputs from 1 to 10 across helpfulness, honesty, and harmlessness. Preference pairs are built from the highest and lowest scored responses in each set.
  3. Distilled DPO on the SFT checkpoint using those preference pairs.

DPO itself is the key trick. It was introduced as a simpler alternative to RLHF: instead of training a separate reward model and then using PPO to optimize against it, DPO directly optimizes the language model policy using pairs of preferred and dispreferred outputs. That removes the reward model, sidesteps PPO's instability, and turns alignment into what looks like a plain supervised loss.

One counterintuitive finding from the report: removing the built-in alignment content from the training datasets boosted MT-Bench scores and made the model more helpful. Stripping out canned refusals raised the numbers, at the cost of safety guarantees.

Running it locally

Zephyr fits comfortably on consumer hardware, running in roughly 4.5GB of VRAM once quantized. The model card lists several deployment paths, but the shortest is the Transformers pipeline:

from transformers import pipeline
import torch
pipe = pipeline("text-generation",
    model="HuggingFaceH4/zephyr-7b-beta",
    torch_dtype=torch.bfloat16,
    device_map="auto")
messages = [{"role": "user", "content": "Explain DPO in one paragraph."}]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
print(pipe(prompt, max_new_tokens=256)[0]["generated_text"])

For production, the model supports vLLM and SGLang OpenAI-compatible servers out of the box, plus quantized builds for llama.cpp, Ollama, and LM Studio. Training used a modest setup by frontier standards: 16 GPUs, learning rate 5e-7, 3 epochs, and TRL's DPOTrainer on the ultrafeedback_binarized dataset.

Where it shines, where it stumbles

Zephyr is a good fit for research on alignment methods, offline chat assistants, RAG backends where responsiveness matters more than reasoning depth, and as a strong SFT/DPO starting point. It has spawned a large ecosystem, with 147 downstream finetunes and 418 adapter models built on top of it, plus derivatives like Notus 7B that further refine the preference data.

The weak spots:

  • Math and code generation, where GSM8K accuracy sits under 13%.
  • Safety-critical deployments. The model will generate problematic text when prompted to do so, and Hugging Face restricts its recommended use to education and research.
  • Non-English use cases, since training data is primarily English.

The broader takeaway is that small preference-tuned models can rival much larger RLHF-trained ones when the preference data is high quality and the training recipe is clean. Zephyr made that case concretely, and the alignment-handbook repo turned it into a template the open-source community has been iterating on ever since.