Instructions to use BatsResearch/bonito-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BatsResearch/bonito-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BatsResearch/bonito-v1")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("BatsResearch/bonito-v1") model = AutoModelForCausalLM.from_pretrained("BatsResearch/bonito-v1") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use BatsResearch/bonito-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BatsResearch/bonito-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BatsResearch/bonito-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/BatsResearch/bonito-v1
- SGLang
How to use BatsResearch/bonito-v1 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 "BatsResearch/bonito-v1" \ --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": "BatsResearch/bonito-v1", "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 "BatsResearch/bonito-v1" \ --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": "BatsResearch/bonito-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use BatsResearch/bonito-v1 with Docker Model Runner:
docker model run hf.co/BatsResearch/bonito-v1
error on Google Colab GPU T4
ValueError: Bfloat16 is only supported on GPUs with compute capability of at least 8.0. Your Tesla T4 GPU has compute capability 7.5. You can use float16 instead by explicitly setting thedtype flag in CLI, for example: --dtype=half.
there is my code
from bonito import Bonito, SamplingParams
from datasets import load_dataset
bonito = Bonito("BatsResearch/bonito-v1")
unannotated_text = load_dataset("csv", data_files="datasets.csv")
sampling_params = SamplingParams(max_tokens=756, top_p=0.95, temperature=0.1, n=1)
synthetic_dataset = bonito.generate_tasks(
unannotated_text,
context_col="input",
task_type="nli",
sampling_params=sampling_params
)
You can use dtype parameter like shown below:
...
from bonito import Bonito
bonito = Bonito("BatsResearch/bonito-v1", dtype="float16")
...
For future reference, you can read the docs of any package that you might be using with help(<class name/function name>).
I have "out of memory" when loading bonito on T4. Do you have plans to make a version that can run on this GPU?
Hello everyone!
We have a tutorial for how to use a quantized version of the model in a Google Colab T4 instance: https://colab.research.google.com/drive/1tfAqUsFaLWLyzhnd1smLMGcDXSzOwp9r?usp=sharing
Hope this helps :)
Thanks, this is exactly what I needed!