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
Free and ready to use zephyr-7B-beta-GGUF model as OpenAI API compatible endpoint
Hi there,
I deployed the model as OpenAI API compatible endpoint at https://huggingface.co/spaces/limcheekin/zephyr-7B-beta-GGUF.
If you find this resource valuable, your support in the form of starring the space would be greatly appreciated.
Thank you.
Hi, are you still maintaining this? I tried using it but it seems to time out/not return a response. Perhaps it's overloaded or some other issue. The only endpoint I can get to successfully return a response is the GET /v1/models. Thanks in advance,
I just tested with the API doc at https://huggingface.co/proxy/limcheekin-zephyr-7b-beta-gguf.hf.space/docs. It is working for a simple prompt.
If you use it for longer generation/response, you need to set stream=True.
Please refer to the following notebook at https://huggingface.co/spaces/limcheekin/Mistral-7B-Instruct-v0.1-GGUF/blob/main/mistral-7b-instruct.ipynb.
Hope this help.
Hi, are you still maintaining this? I tried using it but it seems to time out/not return a response. Perhaps it's overloaded or some other issue. The only endpoint I can get to successfully return a response is the
GET /v1/models. Thanks in advance,
Added a jupyter notebook at https://huggingface.co/spaces/limcheekin/zephyr-7B-beta-GGUF/blob/main/zephyr-7b.ipynb
I hope this is helpful to you. :)
How can I create my own o'penai API with zephyr-7b-beta and share your code? Thank you
You just need to select "Duplicate this Space" from the drop down menu.
All codes are located at https://huggingface.co/spaces/limcheekin/zephyr-7B-beta-GGUF/tree/main.
By the way, you can use git to clone the repo of the space.
I hope this helps and clarify.
Thank you very much. I have just learned about Zephyr, and I have seen your way of using CPP. I would like to directly use Zephyr-7b-beta, while also implementing stream output.
I find ohter coder create api by using pipeline in the github,i want to use AutoModelForCausalLM.from_pretrained.
I didn't do that, can't help you. Appreciate your sharing if you managed to publish the api.
Thanks.
i got an error:
AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = ', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path =
i got an error:
AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = ', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path =
Set your HF token as the API key.