Instructions to use bigscience/bloomz with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bigscience/bloomz with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bigscience/bloomz")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bigscience/bloomz") model = AutoModelForCausalLM.from_pretrained("bigscience/bloomz") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use bigscience/bloomz with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bigscience/bloomz" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigscience/bloomz", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/bigscience/bloomz
- SGLang
How to use bigscience/bloomz 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 "bigscience/bloomz" \ --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": "bigscience/bloomz", "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 "bigscience/bloomz" \ --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": "bigscience/bloomz", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use bigscience/bloomz with Docker Model Runner:
docker model run hf.co/bigscience/bloomz
Removing Stop Token from Decode/Generate
I'm using BLOOMZ to generate text and intend or desire it to be "unending" in that I want to suppress the stop token. I can easily remove it from the result text but I'm also storing the output's tensor data. I was hoping there was a way to remove the stop token from the results without re-encoding the text.
For example;
- Encode input text into tensors
- Generate text (results_text)
- Remove input text from results_text
- Save results_text + input tensors (at this step)
In step #4 I want to remove the stop token from the input tensors I have collected in my variable. But my mind tells me I need to decode, remove it, re-encode it when I'm sure there is a way to represent the tensor or remove it from my variable another way?
Silly me, I used skip_special_tokens=True to achieve what I was after.
If I skip special tokens I get a stop and repeated input text in my output.
Prompt + Additions + Stop Token + Prompt + NEW TEXT
Do you want the model to not stop?
In that case you can set min_new_tokens=X in model.generate so it generates for your desired length. 👍
Or do you want to remove the stop token from the generation?
If so setting skip_special_tokens=True is the way to go
I'm really looking for open-ended fragments, but when it decides to stop it stops. I'm using max_length now, I've not tried max_new_tokens on generate yet. Seems I might still accidentally reach the end if the new tokens/length is less than what the model considers 'done'.
Ah I meant min_new_tokens, sorry - I.e. you can set min_new_tokens to force a minimum number of generated tokens during which the eos token is ignored.