Edit model card

Model Card for Mistral-7B-Instruct-v0.3

Quantization Description

This repo contains a GPTQ 4 bit quantized version of the Mistral-7B-Instruct-v0.3 Large Language Model.

Using the GPTQ model

from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline

model_name_or_path = "thesven/Mistral-7B-v0.3-GPTQ"

tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
                                             device_map="auto",
                                             trust_remote_code=False,
                                             revision="main")
model.pad_token = model.config.eos_token_id


prompt_template=f'''
<s>[INST]Write a story about Ai</s>[/INST]
<s>[ASSISTANT]
'''

input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
output = model.generate(inputs=input_ids, temperature=0.1, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)

Model Description

The Mistral-7B-Instruct-v0.3 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.3.

Mistral-7B-v0.3 has the following changes compared to Mistral-7B-v0.2

  • Extended vocabulary to 32768
  • Supports v3 Tokenizer
  • Supports function calling
  • Generate with transformers

If you want to use Hugging Face transformers to generate text, you can do something like this.

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

pretrained_model_name = "thesven/Mistral-7B-Instruct-v0.3-GPTQ"
device = "cuda:0"

# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name)

# Load the model with the specified configuration and move to device
model = AutoModelForCausalLM.from_pretrained(
    pretrained_model_name,
    device_map="auto",
)

print(model)

# Set EOS token ID
model.eos_token_id = tokenizer.eos_token_id

# Move model to the specified device
model.to(device)

# Define the input text
input_text = "What is PEFT finetuning?"

# Encode the input text
input_ids = tokenizer.encode(input_text, return_tensors="pt").to(device)

# Generate output
output = model.generate(input_ids, max_length=1000)

# Decode the generated output
decoded_output = tokenizer.batch_decode(output, skip_special_tokens=True)

# Print the decoded output
for i, sequence in enumerate(decoded_output):
    print(f"Generated Sequence {i+1}: {sequence}")

del model
torch.cuda.empty_cache()

Limitations The Mistral 7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance. It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.

The Mistral AI Team Albert Jiang, Alexandre Sablayrolles, Alexis Tacnet, Antoine Roux, Arthur Mensch, Audrey Herblin-Stoop, Baptiste Bout, Baudouin de Monicault, Blanche Savary, Bam4d, Caroline Feldman, Devendra Singh Chaplot, Diego de las Casas, Eleonore Arcelin, Emma Bou Hanna, Etienne Metzger, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Harizo Rajaona, Jean-Malo Delignon, Jia Li, Justus Murke, Louis Martin, Louis Ternon, Lucile Saulnier, Lélio Renard Lavaud, Margaret Jennings, Marie Pellat, Marie Torelli, Marie-Anne Lachaux, Nicolas Schuhl, Patrick von Platen, Pierre Stock, Sandeep Subramanian, Sophia Yang, Szymon Antoniak, Teven Le Scao, Thibaut Lavril, Timothée Lacroix, Théophile Gervet, Thomas Wang, Valera Nemychnikova, William El Sayed, William Marshall

Downloads last month
79
Safetensors
Model size
1.21B params
Tensor type
I32
·
FP16
·

Collection including thesven/Mistral-7B-v0.3-GPTQ