Instructions to use kittn/mistral-7B-v0.1-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kittn/mistral-7B-v0.1-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kittn/mistral-7B-v0.1-hf")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("kittn/mistral-7B-v0.1-hf") model = AutoModelForCausalLM.from_pretrained("kittn/mistral-7B-v0.1-hf") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use kittn/mistral-7B-v0.1-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kittn/mistral-7B-v0.1-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kittn/mistral-7B-v0.1-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/kittn/mistral-7B-v0.1-hf
- SGLang
How to use kittn/mistral-7B-v0.1-hf with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "kittn/mistral-7B-v0.1-hf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kittn/mistral-7B-v0.1-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "kittn/mistral-7B-v0.1-hf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kittn/mistral-7B-v0.1-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use kittn/mistral-7B-v0.1-hf with Docker Model Runner:
docker model run hf.co/kittn/mistral-7B-v0.1-hf
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
UPDATE: Official version is out, use it instead: https://huggingface.co/mistralai/Mistral-7B-v0.1
mistral-7B-v0.1-hf
Huggingface compatible version of Mistral's 7B model: https://twitter.com/MistralAI/status/1706877320844509405
Usage
Load in bfloat16 (16GB VRAM or higher)
import torch
from transformers import LlamaForCausalLM, LlamaTokenizer, pipeline, TextStreamer
tokenizer = LlamaTokenizer.from_pretrained("kittn/mistral-7B-v0.1-hf")
model = LlamaForCausalLM.from_pretrained(
"kittn/mistral-7B-v0.1-hf",
torch_dtype=torch.bfloat16,
device_map={"": 0}
)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
pipe("Hi, my name", streamer=TextStreamer(tokenizer), max_new_tokens=128)
Load in bitsandbytes nf4 (6GB VRAM or higher, maybe less with double_quant)
import torch
from transformers import LlamaForCausalLM, LlamaTokenizer, pipeline, TextStreamer, BitsAndBytesConfig
tokenizer = LlamaTokenizer.from_pretrained("kittn/mistral-7B-v0.1-hf")
model = LlamaForCausalLM.from_pretrained(
"kittn/mistral-7B-v0.1-hf",
device_map={"": 0},
quantization_config=BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=False, # set to True to save more VRAM at the cost of some speed/accuracy
),
)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
pipe("Hi, my name", streamer=TextStreamer(tokenizer), max_new_tokens=128)
Load in bitsandbytes int8 (8GB VRAM or higher). Quite slow; not recommended.
import torch
from transformers import LlamaForCausalLM, LlamaTokenizer, pipeline, TextStreamer, BitsAndBytesConfig
tokenizer = LlamaTokenizer.from_pretrained("kittn/mistral-7B-v0.1-hf")
model = LlamaForCausalLM.from_pretrained(
"kittn/mistral-7B-v0.1-hf",
device_map={"": 0},
quantization_config=BitsAndBytesConfig(
load_in_8bit=True,
),
)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
pipe("Hi, my name", streamer=TextStreamer(tokenizer), max_new_tokens=128)
Notes
- The original huggingface conversion script converts the model from bf16 to fp16 before saving it. This script doesn't
- The tokenizer is created with
legacy=False, more about this here - Saved in safetensors format
Conversion script [link]
Unlike meta-llama/Llama-2-7b, this model uses GQA. This breaks some assumptions in the original conversion script, requiring a few changes.
Conversion script: link
Original conversion script: link
- Downloads last month
- 260