Skip to content

Commit

Permalink
Merge pull request #130 from klei22/add_mixtral8x7b_example
Browse files Browse the repository at this point in the history
Add mixtral8x7b example
  • Loading branch information
gkielian authored Mar 25, 2024
2 parents 7645180 + da0f2f0 commit 1a24fe6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data_augmentation/install_mixtral_requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

pip install accelerate
pip install bitsandbytes
pip install -q -U git+https://github.com/huggingface/transformers
18 changes: 18 additions & 0 deletions data_augmentation/mixtral8x7b_instruct_dl_and_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
tokenizer = AutoTokenizer.from_pretrained(model_id)

model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True, device_map="auto")

text = "Hello my name is"
messages = [
{"role": "user", "content": "What is your favorite condiment?"},
{"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavor to whatever I'm cooking in the kitchen."},
{"role": "user", "content": "Do you have mayonnaise recipes?"}
]

input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")

outputs = model.generate(input_ids, max_new_tokens=2000)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

0 comments on commit 1a24fe6

Please sign in to comment.