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
- 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
support eager attention
Browse files- config.json +2 -0
- modeling_aria.py +1 -0
- vision_encoder.py +0 -1
config.json
CHANGED
|
@@ -30,8 +30,10 @@
|
|
| 30 |
},
|
| 31 |
"torch_dtype": "bfloat16",
|
| 32 |
"transformers_version": "4.45.0",
|
|
|
|
| 33 |
"vision_config": {
|
| 34 |
"_flash_attn_2_enabled": true,
|
|
|
|
| 35 |
"architectures": [
|
| 36 |
"AriaVisionModel"
|
| 37 |
],
|
|
|
|
| 30 |
},
|
| 31 |
"torch_dtype": "bfloat16",
|
| 32 |
"transformers_version": "4.45.0",
|
| 33 |
+
"_attn_implementation": "flash_attention_2",
|
| 34 |
"vision_config": {
|
| 35 |
"_flash_attn_2_enabled": true,
|
| 36 |
+
"_attn_implementation": "flash_attention_2",
|
| 37 |
"architectures": [
|
| 38 |
"AriaVisionModel"
|
| 39 |
],
|
modeling_aria.py
CHANGED
|
@@ -133,6 +133,7 @@ class AriaForConditionalGeneration(AriaPretrainedModel):
|
|
| 133 |
def __init__(self, config: AriaConfig):
|
| 134 |
super().__init__(config)
|
| 135 |
|
|
|
|
| 136 |
self.vision_tower = AriaVisionModel(config.vision_config)
|
| 137 |
self.multi_modal_projector = build_mm_projector(config)
|
| 138 |
self.vocab_size = config.text_config.vocab_size
|
|
|
|
| 133 |
def __init__(self, config: AriaConfig):
|
| 134 |
super().__init__(config)
|
| 135 |
|
| 136 |
+
config.vision_config._attn_implementation = config._attn_implementation
|
| 137 |
self.vision_tower = AriaVisionModel(config.vision_config)
|
| 138 |
self.multi_modal_projector = build_mm_projector(config)
|
| 139 |
self.vocab_size = config.text_config.vocab_size
|
vision_encoder.py
CHANGED
|
@@ -38,7 +38,6 @@ class AriaVisionConfig(SiglipVisionConfig):
|
|
| 38 |
**kwargs,
|
| 39 |
):
|
| 40 |
super().__init__(**kwargs)
|
| 41 |
-
self._attn_implementation = "flash_attention_2"
|
| 42 |
|
| 43 |
|
| 44 |
class IdentityOp(torch.nn.Module):
|
|
|
|
| 38 |
**kwargs,
|
| 39 |
):
|
| 40 |
super().__init__(**kwargs)
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
class IdentityOp(torch.nn.Module):
|