Instructions to use NousResearch/Yarn-Mistral-7b-128k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NousResearch/Yarn-Mistral-7b-128k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NousResearch/Yarn-Mistral-7b-128k", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NousResearch/Yarn-Mistral-7b-128k", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("NousResearch/Yarn-Mistral-7b-128k", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NousResearch/Yarn-Mistral-7b-128k with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NousResearch/Yarn-Mistral-7b-128k" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NousResearch/Yarn-Mistral-7b-128k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/NousResearch/Yarn-Mistral-7b-128k
- SGLang
How to use NousResearch/Yarn-Mistral-7b-128k 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 "NousResearch/Yarn-Mistral-7b-128k" \ --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": "NousResearch/Yarn-Mistral-7b-128k", "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 "NousResearch/Yarn-Mistral-7b-128k" \ --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": "NousResearch/Yarn-Mistral-7b-128k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use NousResearch/Yarn-Mistral-7b-128k with Docker Model Runner:
docker model run hf.co/NousResearch/Yarn-Mistral-7b-128k
Using this model with Vllm
#10
by haltux - opened
Hello,
I could make the model work directly in Python with the example code provided, but with VLLM it does not work, even with 80 GB of GPU memory.
I try:
python -u -m vllm.entrypoints.openai.api_server --host 0.0.0.0 --model NousResearch/Yarn-Mistral-7b-128k --trust-remote-code
and i get:
File "/home/azureuser/.local/lib/python3.10/site-packages/vllm/model_executor/layers/attention.py", line 266, in forward
self.multi_query_kv_attention(
File "/home/azureuser/.local/lib/python3.10/site-packages/vllm/model_executor/layers/attention.py", line 117, in multi_query_kv_attention
key = torch.repeat_interleave(key, self.num_queries_per_kv, dim=1)
RuntimeError: CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
Any idea about how to fix that?
Thanks a lot.
vLLM v0.2.2 was just released, which includes Yarn support, so maybe it will work for you now!