laion/OIG
Viewer • Updated • 52.6M • 14.9k • 311
How to use argilla/Mistral-7B-v0.1-chat-OIG with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1")
model = PeftModel.from_pretrained(base_model, "argilla/Mistral-7B-v0.1-chat-OIG")Mistral-7B-v0.1-chat-OIG is a LLM trained to act as a chat assistant, capable of subsequent prompting. It is finetuned from mistralai/Mistral-7B-v0.1 on 3k samples from the laion/OIG dataset. The training procedure involves supervised finetuning from TRL.
from transformers import AutoTokenizer
from peft import AutoPeftModelForCausalLM
import torch
model_id = "argilla/Mistral-7B-v0.1-chat-OIG"
model = AutoPeftModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token_id = tokenizer.eos_token_id
text = "<human>: What were Nelson Mandela's relations with the ANC? <bot>:"
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(input_ids=inputs["input_ids"], max_new_tokens=250, pad_token_id=tokenizer.pad_token_id)
print(tokenizer.batch_decode(outputs, skip_special_tokens=False)[0])
<s><human>: {prompt} <bot>:
or
Background: {background} <s><human>: {prompt} <bot>:
<s><human>: {prompt_1} <bot>: {response_1}</s><s><human>: {prompt_2} <bot>: {response_2}</s><s><human>: {prompt_3} <bot>:
or
Background: {background} <s><human>: {prompt_1} <bot>: {response_1}</s><s><human>: {prompt_2} <bot>: {response_2}</s><s><human>: {prompt_3} <bot>: