Instructions to use dphn/dolphin-2.0-mistral-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dphn/dolphin-2.0-mistral-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="dphn/dolphin-2.0-mistral-7b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("dphn/dolphin-2.0-mistral-7b") model = AutoModelForCausalLM.from_pretrained("dphn/dolphin-2.0-mistral-7b", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use dphn/dolphin-2.0-mistral-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "dphn/dolphin-2.0-mistral-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dphn/dolphin-2.0-mistral-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/dphn/dolphin-2.0-mistral-7b
- SGLang
How to use dphn/dolphin-2.0-mistral-7b 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 "dphn/dolphin-2.0-mistral-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dphn/dolphin-2.0-mistral-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "dphn/dolphin-2.0-mistral-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dphn/dolphin-2.0-mistral-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use dphn/dolphin-2.0-mistral-7b with Docker Model Runner:
docker model run hf.co/dphn/dolphin-2.0-mistral-7b
Can't load the model
I have tried loading the model with Transformers and ExLlama but neither of them work. With ExLlama_HF it give the error about the "pad_token_id" which I fixed by adding it to the config.json file as "pad_token_id": 2,.
Then it gives me this error:
File “/home/Me/miniconda3/envs/textgen/lib/python3.10/site-packages/exllama/model.py”, line 732, in init
with safe_open(self.config.model_path, framework = "pt", device = "cpu") as f:
safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge
Does this mean it is expecting the safetensors file format?
This line in your tokenizer_config.json file was causing me issues. I removed it and I loaded your model just fine:
"tokenizer_file": "/workspace/.cache/hf/models--mistralai--Mistral-7B-Instruct-v0.1/snapshots/d635d39671aaceec5ef84b745bc21625b324b7f8/tokenizer.json",
This line in your tokenizer_config.json file was causing me issues. I removed it and I loaded your model just fine:
"tokenizer_file": "/workspace/.cache/hf/models--mistralai--Mistral-7B-Instruct-v0.1/snapshots/d635d39671aaceec5ef84b745bc21625b324b7f8/tokenizer.json",
was this a response to my post? That issue was already fixed an doesn't have anything to do with this one.
This seems to be an issue with the latest version of the oobabooga Text Generation Web UI.
I was also unable to load the model using any of the model loaders.
I noticed that Matthew Berman was able to successfully load the model using the Transformers model loader in this YouTube video.
There have been a number of updates to oobabooga recently which have broken various different things in a spectacular fashion, so they clearly need to add some unit tests to the project.
Until such time as oobabooga is in a working state again, this is the commit that is working for me:
cb26163a209d6272ed14da83782f71bae4681d75