Instructions to use rhymes-ai/Aria with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rhymes-ai/Aria with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="rhymes-ai/Aria") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("rhymes-ai/Aria") model = AutoModelForImageTextToText.from_pretrained("rhymes-ai/Aria") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use rhymes-ai/Aria with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rhymes-ai/Aria" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rhymes-ai/Aria", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/rhymes-ai/Aria
- SGLang
How to use rhymes-ai/Aria 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 "rhymes-ai/Aria" \ --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": "rhymes-ai/Aria", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "rhymes-ai/Aria" \ --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": "rhymes-ai/Aria", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use rhymes-ai/Aria with Docker Model Runner:
docker model run hf.co/rhymes-ai/Aria
Update README with new chat template example (#18)
Browse files- Update README.md (990cdb320db445f892a68db61e7223b1b3d060a1)
Co-authored-by: Raushan Turganbay <RaushanTurganbay@users.noreply.huggingface.co>
README.md
CHANGED
|
@@ -118,6 +118,39 @@ response = processor.decode(output_ids, skip_special_tokens=True)
|
|
| 118 |
print(response)
|
| 119 |
```
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
### Advanced Inference and Fine-tuning
|
| 122 |
We provide a [codebase](https://github.com/rhymes-ai/Aria) for more advanced usage of Aria,
|
| 123 |
including vllm inference, cookbooks, and fine-tuning on custom datasets.
|
|
|
|
| 118 |
print(response)
|
| 119 |
```
|
| 120 |
|
| 121 |
+
-----------
|
| 122 |
+
From transformers>=v4.48, you can also pass image url or local path to the conversation history, and let the chat template handle the rest.
|
| 123 |
+
Chat template will load the image for you and return inputs in `torch.Tensor` which you can pass directly to `model.generate()`.
|
| 124 |
+
|
| 125 |
+
Here is how to rewrite the above example
|
| 126 |
+
|
| 127 |
+
```python
|
| 128 |
+
messages = [
|
| 129 |
+
{
|
| 130 |
+
"role": "user",
|
| 131 |
+
"content": [
|
| 132 |
+
{"type": "image", "url": "http://images.cocodataset.org/val2017/000000039769.jpg"}
|
| 133 |
+
{"type": "text", "text": "what is the image?"},
|
| 134 |
+
],
|
| 135 |
+
},
|
| 136 |
+
]
|
| 137 |
+
|
| 138 |
+
inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors"pt")
|
| 139 |
+
ipnuts = inputs.to(model.device, torch.bfloat16)
|
| 140 |
+
|
| 141 |
+
output = model.generate(
|
| 142 |
+
**inputs,
|
| 143 |
+
max_new_tokens=15,
|
| 144 |
+
stop_strings=["<|im_end|>"],
|
| 145 |
+
tokenizer=processor.tokenizer,
|
| 146 |
+
do_sample=True,
|
| 147 |
+
temperature=0.9,
|
| 148 |
+
)
|
| 149 |
+
output_ids = output[0][inputs["input_ids"].shape[1]:]
|
| 150 |
+
response = processor.decode(output_ids, skip_special_tokens=True)
|
| 151 |
+
print(response)
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
### Advanced Inference and Fine-tuning
|
| 155 |
We provide a [codebase](https://github.com/rhymes-ai/Aria) for more advanced usage of Aria,
|
| 156 |
including vllm inference, cookbooks, and fine-tuning on custom datasets.
|