lewtun's picture
lewtun HF staff
Add tables
5a6c0cd
|
raw
history blame
No virus
7.13 kB
metadata
license: mit
base_model: HuggingFaceH4/zephyr-7b-gemma-sft
tags:
  - alignment-handbook
  - trl
  - dpo
  - generated_from_trainer
datasets:
  - argilla/dpo-mix-7k
pipeline_tag: text-generation
model-index:
  - name: zephyr-7b-gemma
    results:
      - task:
          type: text-generation
          name: Text Generation
        dataset:
          name: MT-Bench
          type: unknown
        metrics:
          - type: unknown
            name: score
            value: 7.81
        source:
          url: https://huggingface.co/spaces/lmsys/mt-bench
Zephyr 7B Gemma Logo

Model Card for Zephyr 7B Gemma

Zephyr is a series of language models that are trained to act as helpful assistants. Zephyr 7B Gemma is the third model in the series, and is a fine-tuned version of google/gemma-7b that was trained on on a mix of publicly available, synthetic datasets using Direct Preference Optimization (DPO). You can reproduce the training of this model via the recipe provided in the Alignment Handbook.

Model description

  • Model type: A 7B parameter GPT-like model fine-tuned on a mix of publicly available, synthetic datasets.
  • Language(s) (NLP): Primarily English
  • License: MIT
  • Finetuned from model: google/gemma-7b

Model Sources

Performance

Model MT Bench IFEval
zephyr-7b-gemma 7.81 28.76
zephyr-7b-beta 7.34 43.81
gemma-7b-it 6.38 38.01
Model AGIEval GPT4All TruthfulQA BigBench Average
zephyr-7b-gemma 34.22 66.37 52.19 37.10 47.47
zephyr-7b-beta 37.52 71.77 55.26 39.77 51.08
gemma-7b-it 21.33 40.84 41.70 30.25 33.53

Intended uses & limitations

The model was initially fine-tuned on the DEITA 10K dataset, which contains a diverse range of synthetic dialogues generated by ChatGPT. We then further aligned the model with 🤗 TRL's DPOTrainer on the argilla/dpo-mix-7k dataset, which contains 7k prompts and model completions that are ranked by GPT-4. As a result, the model can be used for chat and you can check out our demo to test its capabilities.

Here's how you can run the model using the pipeline() function from 🤗 Transformers:

# Install transformers from source - only needed for versions <= v4.38.1
# pip install git+https://github.com/huggingface/transformers.git
# pip install accelerate

import torch
from transformers import pipeline

pipe = pipeline(
    "text-generation",
    model="HuggingFaceH4/zephyr-7b-gemma",
    device_map="auto",
    torch_dtype=torch.bfloat16,
)
messages = [
    {
        "role": "system",
        "content": "",  # Model not yet trained for follow this
    },
    {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
]
outputs = pipe(
    messages,
    max_new_tokens=128,
    do_sample=True,
    temperature=0.7,
    top_k=50,
    top_p=0.95,
    stop_sequence="<|im_end|>",
)
print(outputs[0]["generated_text"][-1]["content"])
# It is not possible for a human to eat a helicopter in one sitting, as a
# helicopter is a large and inedible machine. Helicopters are made of metal,
# plastic, and other materials that are not meant to be consumed by humans.
# Eating a helicopter would be extremely dangerous and would likely cause
# serious health problems, including choking, suffocation, and poisoning. It is
# important to only eat food that is safe and intended for human consumption.

Bias, Risks, and Limitations

Zephyr 7B Gemma has not been aligned to human preferences for safety within the RLHF phase or deployed with in-the-loop filtering of responses like ChatGPT, so the model can produce problematic outputs (especially when prompted to do so). It is also unknown what the size and composition of the corpus was used to train the base model (google/gemma-7b), however it is likely to have included a mix of Web data and technical sources like books and code. See the StarCoder2 model card for an example of this.

Training and evaluation data

This model is a fine-tuned version of HuggingFaceH4/zephyr-7b-gemma-sft on the argilla/dpo-mix-7k dataset.

It achieves the following results on the evaluation set:

  • Loss: 0.4695
  • Rewards/chosen: -3.3746
  • Rewards/rejected: -4.9715
  • Rewards/accuracies: 0.7188
  • Rewards/margins: 1.5970
  • Logps/rejected: -459.4853
  • Logps/chosen: -429.9115
  • Logits/rejected: 86.4684
  • Logits/chosen: 92.8200

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 5e-07
  • train_batch_size: 2
  • eval_batch_size: 4
  • seed: 42
  • distributed_type: multi-GPU
  • num_devices: 8
  • gradient_accumulation_steps: 8
  • total_train_batch_size: 128
  • total_eval_batch_size: 32
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • lr_scheduler_type: cosine
  • lr_scheduler_warmup_ratio: 0.1
  • num_epochs: 2

Training results

Training Loss Epoch Step Validation Loss Rewards/chosen Rewards/rejected Rewards/accuracies Rewards/margins Logps/rejected Logps/chosen Logits/rejected Logits/chosen
0.1923 1.9 100 0.4736 -3.4575 -4.9556 0.75 1.4980 -459.1662 -431.5707 86.3863 92.7360

Framework versions

  • Transformers 4.39.0.dev0
  • Pytorch 2.1.2+cu121
  • Datasets 2.14.6
  • Tokenizers 0.15.1