Text Generation
PEFT
Safetensors
mistral
conversational
Eval Results
dfurman's picture
Adding Evaluation Results (#2)
14a2288 verified
---
license: apache-2.0
library_name: peft
tags:
- mistral
datasets:
- jondurbin/airoboros-2.2.1
- Open-Orca/SlimOrca
- garage-bAInd/Open-Platypus
inference: false
pipeline_tag: text-generation
base_model: mistralai/Mixtral-8x7B-v0.1
model-index:
- name: Mixtral-8x7B-peft-v0.1
results:
- task:
type: text-generation
name: Text Generation
dataset:
name: AI2 Reasoning Challenge (25-Shot)
type: ai2_arc
config: ARC-Challenge
split: test
args:
num_few_shot: 25
metrics:
- type: acc_norm
value: 67.24
name: normalized accuracy
source:
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dfurman/Mixtral-8x7B-peft-v0.1
name: Open LLM Leaderboard
- task:
type: text-generation
name: Text Generation
dataset:
name: HellaSwag (10-Shot)
type: hellaswag
split: validation
args:
num_few_shot: 10
metrics:
- type: acc_norm
value: 86.03
name: normalized accuracy
source:
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dfurman/Mixtral-8x7B-peft-v0.1
name: Open LLM Leaderboard
- task:
type: text-generation
name: Text Generation
dataset:
name: MMLU (5-Shot)
type: cais/mmlu
config: all
split: test
args:
num_few_shot: 5
metrics:
- type: acc
value: 68.59
name: accuracy
source:
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dfurman/Mixtral-8x7B-peft-v0.1
name: Open LLM Leaderboard
- task:
type: text-generation
name: Text Generation
dataset:
name: TruthfulQA (0-shot)
type: truthful_qa
config: multiple_choice
split: validation
args:
num_few_shot: 0
metrics:
- type: mc2
value: 59.54
source:
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dfurman/Mixtral-8x7B-peft-v0.1
name: Open LLM Leaderboard
- task:
type: text-generation
name: Text Generation
dataset:
name: Winogrande (5-shot)
type: winogrande
config: winogrande_xl
split: validation
args:
num_few_shot: 5
metrics:
- type: acc
value: 80.43
name: accuracy
source:
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dfurman/Mixtral-8x7B-peft-v0.1
name: Open LLM Leaderboard
- task:
type: text-generation
name: Text Generation
dataset:
name: GSM8k (5-shot)
type: gsm8k
config: main
split: test
args:
num_few_shot: 5
metrics:
- type: acc
value: 51.4
name: accuracy
source:
url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=dfurman/Mixtral-8x7B-peft-v0.1
name: Open LLM Leaderboard
---
<div align="center">
<img src="./logo.png" width="110px">
</div>
# dfurman/Mixtral-8x7B-Instruct-v0.1
A pretrained generative language model with ~47 billion parameters geared towards instruction-following capabilities.
## Model Details
This model was built via parameter-efficient finetuning of the [mistralai/Mixtral-8x7B-v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1) base model on the first 40k rows in each of the [jondurbin/airoboros-2.2.1](https://huggingface.co/datasets/jondurbin/airoboros-2.2.1), [Open-Orca/SlimOrca](https://huggingface.co/datasets/Open-Orca/SlimOrca), and [garage-bAInd/Open-Platypus](https://huggingface.co/datasets/garage-bAInd/Open-Platypus) datasets.
- **Developed by:** Daniel Furman
- **Model type:** Causal language model (clm)
- **Language(s) (NLP):** English
- **License:** Apache 2.0
- **Finetuned from model:** [mistralai/Mixtral-8x7B-v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)
## Evaluation Results
| Metric | Value |
|-----------------------|---------------------------|
| Avg. | 68.87 |
| ARC (25-shot) | 67.24 |
| HellaSwag (10-shot) | 86.03 |
| MMLU (5-shot) | 68.59 |
| TruthfulQA (0-shot) | 59.54 |
| Winogrande (5-shot) | 80.43 |
| GSM8K (5-shot) | 51.4 |
We use Eleuther.AI's [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) to run the benchmark tests above, the same version as Hugging Face's [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
## Basic Usage
<details>
<summary>Setup</summary>
```python
!pip install -q -U transformers peft torch accelerate einops sentencepiece
```
```python
import torch
from peft import PeftModel, PeftConfig
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
)
```
```python
peft_model_id = "dfurman/dfurman/Mixtral-8x7B-Instruct-v0.1"
config = PeftConfig.from_pretrained(peft_model_id)
tokenizer = AutoTokenizer.from_pretrained(
peft_model_id,
use_fast=True,
trust_remote_code=True,
)
model = AutoModelForCausalLM.from_pretrained(
config.base_model_name_or_path,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(
model,
peft_model_id
)
```
</details>
```python
messages = [
{"role": "user", "content": "Tell me a recipe for a mai tai."},
]
print("\n\n*** Prompt:")
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
return_tensors="pt",
)
print(tokenizer.decode(input_ids[0]))
print("\n\n*** Generate:")
with torch.autocast("cuda", dtype=torch.bfloat16):
output = model.generate(
input_ids=input_ids.to("cuda"),
max_new_tokens=1024,
return_dict_in_generate=True,
)
response = tokenizer.decode(
output["sequences"][0][len(input_ids[0]):],
skip_special_tokens=True
)
print(response)
```
**Outputs**
```python
"""
*** Prompt:
<s> [INST] Tell me a recipe for a mai tai. [/INST]
*** Generate:
1.5 oz light rum
2 oz dark rum
1 oz lime juice
0.5 oz orange curaçao
0.5 oz orgeat syrup
In a shaker filled with ice, combine the light rum, dark rum, lime juice, orange curaçao, and orgeat syrup. Shake well.
Strain the mixture into a chilled glass filled with fresh ice.
Garnish with a lime wedge and a cherry.
"""
```
## Speeds, Sizes, Times
| runtime / 50 tokens (sec) | GPU | dtype | VRAM (GB) |
|:-----------------------------:|:---------------------:|:-------------:|:-----------------------:|
| 8.25 | 1x A100 (40 GB SXM) | nf4 | 28 |
## Training
It took ~24 hours to train 2 epochs on 4x A6000s.
### Prompt Format
This model was finetuned with the following format:
```python
tokenizer.chat_template = "{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST] ' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token + ' ' }}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}"
```
This format is available as a [chat template](https://huggingface.co/docs/transformers/main/chat_templating) via the `apply_chat_template()` method. Here's an illustrative example:
```python
messages = [
{"role": "user", "content": "Tell me a recipe for a mai tai."},
{"role": "assistant", "content": "1 oz light rum\n½ oz dark rum\n¼ oz orange curaçao\n2 oz pineapple juice\n¾ oz lime juice\nDash of orgeat syrup (optional)\nSplash of grenadine (for garnish, optional)\nLime wheel and cherry garnishes (optional)\n\nShake all ingredients except the splash of grenadine in a cocktail shaker over ice. Strain into an old-fashioned glass filled with fresh ice cubes. Gently pour the splash of grenadine down the side of the glass so that it sinks to the bottom. Add garnishes as desired."},
{"role": "user", "content": "How can I make it more upscale and luxurious?"},
]
print("\n\n*** Prompt:")
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
return_tensors="pt",
)
print(tokenizer.decode(input_ids[0]))
```
<details>
<summary>Output</summary>
```python
"""<s> [INST] Tell me a recipe for a mai tai. [/INST] 1 oz light rum\n½ oz dark rum\n (...) Add garnishes as desired.</s> [INST] How can I make it more upscale and luxurious? [/INST]"""
```
</details>
### Training Hyperparameters
We use the [SFTTrainer](https://huggingface.co/docs/trl/main/en/sft_trainer) from `trl` to fine-tune LLMs on instruction-following datasets.
See [here](https://github.com/daniel-furman/sft-demos/blob/main/src/sft/mistral/sft_Mistral_7B_Instruct_v0_1_peft.ipynb) for the finetuning code, which contains an exhaustive view of the hyperparameters employed.
The following `TrainingArguments` config was used:
- output_dir = "./results"
- num_train_epochs = 2
- auto_find_batch_size = True
- gradient_accumulation_steps = 2
- optim = "paged_adamw_32bit"
- save_strategy = "epoch"
- learning_rate = 3e-4
- lr_scheduler_type = "cosine"
- warmup_ratio = 0.03
- logging_strategy = "steps"
- logging_steps = 25
- evaluation_strategy = "no"
- bf16 = True
The following `bitsandbytes` quantization config was used:
- quant_method: bitsandbytes
- load_in_8bit: False
- load_in_4bit: True
- llm_int8_threshold: 6.0
- llm_int8_skip_modules: None
- llm_int8_enable_fp32_cpu_offload: False
- llm_int8_has_fp16_weight: False
- bnb_4bit_quant_type: nf4
- bnb_4bit_use_double_quant: False
- bnb_4bit_compute_dtype: bfloat16
## Model Card Contact
dryanfurman at gmail
## Mistral Research Citation
```
@misc{jiang2023mistral,
title={Mistral 7B},
author={Albert Q. Jiang and Alexandre Sablayrolles and Arthur Mensch and Chris Bamford and Devendra Singh Chaplot and Diego de las Casas and Florian Bressand and Gianna Lengyel and Guillaume Lample and Lucile Saulnier and Lélio Renard Lavaud and Marie-Anne Lachaux and Pierre Stock and Teven Le Scao and Thibaut Lavril and Thomas Wang and Timothée Lacroix and William El Sayed},
year={2023},
eprint={2310.06825},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
```
### Framework versions
- PEFT 0.7.2.dev0
# [Open LLM Leaderboard Evaluation Results](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
Detailed results can be found [here](https://huggingface.co/datasets/open-llm-leaderboard/details_dfurman__Mixtral-8x7B-peft-v0.1)
| Metric |Value|
|---------------------------------|----:|
|Avg. |68.87|
|AI2 Reasoning Challenge (25-Shot)|67.24|
|HellaSwag (10-Shot) |86.03|
|MMLU (5-Shot) |68.59|
|TruthfulQA (0-shot) |59.54|
|Winogrande (5-shot) |80.43|
|GSM8k (5-shot) |51.40|