Instructions to use teknium/OpenHermes-2.5-Mistral-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use teknium/OpenHermes-2.5-Mistral-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="teknium/OpenHermes-2.5-Mistral-7B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("teknium/OpenHermes-2.5-Mistral-7B") model = AutoModelForCausalLM.from_pretrained("teknium/OpenHermes-2.5-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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use teknium/OpenHermes-2.5-Mistral-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "teknium/OpenHermes-2.5-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": "teknium/OpenHermes-2.5-Mistral-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/teknium/OpenHermes-2.5-Mistral-7B
- SGLang
How to use teknium/OpenHermes-2.5-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 "teknium/OpenHermes-2.5-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": "teknium/OpenHermes-2.5-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 "teknium/OpenHermes-2.5-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": "teknium/OpenHermes-2.5-Mistral-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use teknium/OpenHermes-2.5-Mistral-7B with Docker Model Runner:
docker model run hf.co/teknium/OpenHermes-2.5-Mistral-7B
Question regarding BOS-token when chatting with the model.
Hello!
I came across this model and I must say, I'm very impressed with the results.
While examining the tokenizer_config.json file, I noticed that it specifies < s > as the BOS-token and add_bos_token:true.
Although the model card mentions using the ChatML format, this raised some questions that I hope to receive assistance with.
How should < s > be specified in the prompt/prompts when chatting with the model?
Example 1 - Not at all.
"<|im_start|>User
Question 1?<|im_end|>
<|im_start|>Assistant
Answer 1.<|im_end|>
<|im_start|>User
Question 2 based on question 1?<|im_end|>
<|im_start|>Assistant"
Example 2 - Before each message/prompt.
"< s > <|im_start|>User
I'm human<|im_end|>
< s > <|im_start|>Assistant
I'm Assistant<|im_end|>
< s > |im_start|>User
I'm human<|im_end|>
< s >|im_start|>Assistant
"
Example 3 - At the start of the sequence.
"< s > <|im_start|>User
Question 1?<|im_end|>
<|im_start|>Assistant
Answer 1<|im_end|>
<|im_start|>User
Question 2 based on question 1?<|im_end|
<|im_start|>Assistant"
Thanks.
edit. I can't write the proper BOS-token for some reason without formatting the whole text on here. I've added spaces to make it appear in the text.
Hi there, I am also a bit confused about this and still trying to clear out the confusion myself!
However I think I can answer your question "How should <s> be specified in the prompt/prompts when chatting with the model?".
The answer is: you should not add it yourself. The tokenizer will take care of doing that.