Introduction

Zephyr-7B-β is a language model in the Zephyr series, designed to act as a helpful assistant. It is fine-tuned from the mistralai/Mistral-7B-v0.1 model and trained on a mix of publicly available, synthetic datasets using Direct Preference Optimization (DPO). This model is recognized for its high performance on benchmarks such as MT-Bench and AlpacaEval.

Architecture

  • Model Type: GPT-like with 7 billion parameters.
  • Language: Primarily English.
  • Base Model: mistralai/Mistral-7B-v0.1.

Training

The model was trained using Direct Preference Optimization (DPO) on datasets like UltraChat and UltraFeedback. It achieved significant improvements in performance metrics such as loss and reward scores during training. The training process utilized multiple GPUs with specific hyperparameters, including a learning rate of 5e-07 and a total batch size of 32.

Guide: Running Locally

  1. Installation:

    • Install the transformers library from source (if necessary) and accelerate:
      pip install git+https://github.com/huggingface/transformers.git
      pip install accelerate
      
  2. Setup:

    • Import necessary libraries and set up the text generation pipeline:
      import torch
      from transformers import pipeline
      
      pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
      
  3. Usage:

    • Prepare messages and generate text using the pipeline:
      messages = [{"role": "system", "content": "You are a pirate chatbot."}, {"role": "user", "content": "How many helicopters can a human eat?"}]
      prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
      outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
      print(outputs[0]["generated_text"])
      
  4. Cloud GPUs:

    • For optimal performance, consider using cloud GPUs from providers like AWS, Google Cloud, or Azure.

License

Zephyr-7B-β is licensed under the MIT License, allowing for a high degree of freedom in usage and distribution.

More Related APIs in Text Generation