Instructions to use HuggingFaceH4/zephyr-7b-beta with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceH4/zephyr-7b-beta with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HuggingFaceH4/zephyr-7b-beta") model = AutoModelForCausalLM.from_pretrained("HuggingFaceH4/zephyr-7b-beta") 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
- vLLM
How to use HuggingFaceH4/zephyr-7b-beta with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceH4/zephyr-7b-beta" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceH4/zephyr-7b-beta", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HuggingFaceH4/zephyr-7b-beta
- SGLang
How to use HuggingFaceH4/zephyr-7b-beta 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 "HuggingFaceH4/zephyr-7b-beta" \ --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": "HuggingFaceH4/zephyr-7b-beta", "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 "HuggingFaceH4/zephyr-7b-beta" \ --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": "HuggingFaceH4/zephyr-7b-beta", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HuggingFaceH4/zephyr-7b-beta with Docker Model Runner:
docker model run hf.co/HuggingFaceH4/zephyr-7b-beta
Dataset format for fine tuning
Hello. Is there any proper formatting for fine tuning this model?
Can I use mistral model's prompt or any recommended prompt format is available?
I used the following prompt to fine-tune:
<|system|>\n {instruction} \n<|user|>\n{query}\n<|assistant|>\n{response}
I had problems making the model stop generating content. So I found the solution in this link (https://medium.com/@parikshitsaikia1619/mistral-mastery-fine-tuning-fast-inference-guide-62e163198b06)
This change before starting the training solved my problem
tokenizer = AutoTokenizer.from_pretrained("HuggingFaceH4/zephyr-7b-beta")
#tokenizer.pad_token = tokenizer.eos_token
tokenizer.pad_token = tokenizer.unk_token <----
tokenizer.padding_side = "right" <----
Hi! Any limmits to the length of the inputs/outputs when finetunning? Like those limmits found in OpenAI models?
Hi! Any limmits to the length of the inputs/outputs when finetunning? Like those limmits found in OpenAI models?
It's my first major fine-tuning, so maybe something I say may not make sense, but when it comes to fine-tuning input, depending on the configuration, it needs to be multi-gpu, otherwise you'll be limited. Already at the output I noticed that the more complete the fine adjustment... checkpoints, times, the more complete the fine adjustment the greater the output has been. But I repeat, this is my first major fine-tuning, because until now I was having a problem with the model not generating the eos_token
I used the following prompt to fine-tune:
<|system|>\n {instruction} \n<|user|>\n{query}\n<|assistant|>\n{response}
What did your prepared dataset look like for finetuning? Was it a .csv file with a single column in this format?
Yes, single column:
"text"
"<|system|>\n {instruction} \n<|user|>\n{query}\n<|assistant|>\n{response}"
"<|system|>\n {instruction} \n<|user|>\n{query}\n<|assistant|>\n{response}"
I used the following prompt to fine-tune:
<|system|>\n {instruction} \n<|user|>\n{query}\n<|assistant|>\n{response}I had problems making the model stop generating content. So I found the solution in this link (https://medium.com/@parikshitsaikia1619/mistral-mastery-fine-tuning-fast-inference-guide-62e163198b06)
This change before starting the training solved my problem
tokenizer = AutoTokenizer.from_pretrained("HuggingFaceH4/zephyr-7b-beta")
#tokenizer.pad_token = tokenizer.eos_tokentokenizer.pad_token = tokenizer.unk_token <----
tokenizer.padding_side = "right" <----
How much RAM is it needed to run this model locally?
Can someone tell me what format I should use in order to fine tune the model to answer questions from a specific document?
For example is the following correct?
data = [
{
"messages":[
{"role": "system", "content": '''Text:
A right triangle is a triangle with a right angle.
A right angle equals to 90 degrees.
.
.
.
Based on the above Text answer rge following question. Your answer should be from the Text only. Do not answer to questions which are irelevant to the Text given.'''},
{"role": "user", "content": "question1"},
{"role": "assistant", "content": "asnwer1."},
{"role": "user", "content": "question2"},
{"role": "assistant", "content": "answer2."},
.
.
.
]
}
]