Skip to content

Commit b1d9205

Browse files
xffxffIsotr0py
andauthored
[Model]: Add support for Aria model (#10514)
Signed-off-by: xffxff <[email protected]> Co-authored-by: Isotr0py <[email protected]>
1 parent 452a4e8 commit b1d9205

File tree

8 files changed

+791
-0
lines changed

8 files changed

+791
-0
lines changed

docs/source/models/supported_models.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,12 @@ Text Generation
476476
- Example HF Models
477477
- :ref:`LoRA <lora>`
478478
- :ref:`PP <distributed_serving>`
479+
* - :code:`AriaForConditionalGeneration`
480+
- Aria
481+
- T + I
482+
- :code:`rhymes-ai/Aria`
483+
-
484+
- ✅︎
479485
* - :code:`Blip2ForConditionalGeneration`
480486
- BLIP-2
481487
- T + I\ :sup:`E`

examples/offline_inference_vision_language.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,23 @@ def run_idefics3(question: str, modality: str):
402402
return llm, prompt, stop_token_ids
403403

404404

405+
# Aria
406+
def run_aria(question: str, modality: str):
407+
assert modality == "image"
408+
model_name = "rhymes-ai/Aria"
409+
410+
llm = LLM(model=model_name,
411+
tokenizer_mode="slow",
412+
trust_remote_code=True,
413+
dtype="bfloat16")
414+
415+
prompt = (f"<|im_start|>user\n<fim_prefix><|img|><fim_suffix>\n{question}"
416+
"<|im_end|>\n<|im_start|>assistant\n")
417+
418+
stop_token_ids = [93532, 93653, 944, 93421, 1019, 93653, 93519]
419+
return llm, prompt, stop_token_ids
420+
421+
405422
model_example_map = {
406423
"llava": run_llava,
407424
"llava-next": run_llava_next,
@@ -423,6 +440,7 @@ def run_idefics3(question: str, modality: str):
423440
"molmo": run_molmo,
424441
"glm4v": run_glm4v,
425442
"idefics3": run_idefics3,
443+
"aria": run_aria,
426444
}
427445

428446

examples/offline_inference_vision_language_multi_image.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,25 @@ def load_idefics3(question, image_urls: List[str]) -> ModelRequestData:
321321
)
322322

323323

324+
def load_aria(question, image_urls: List[str]) -> ModelRequestData:
325+
model_name = "rhymes-ai/Aria"
326+
llm = LLM(model=model_name,
327+
tokenizer_mode="slow",
328+
trust_remote_code=True,
329+
dtype="bfloat16",
330+
limit_mm_per_prompt={"image": len(image_urls)})
331+
placeholders = "<fim_prefix><|img|><fim_suffix>\n" * len(image_urls)
332+
prompt = (f"<|im_start|>user\n{placeholders}{question}<|im_end|>\n"
333+
"<|im_start|>assistant\n")
334+
stop_token_ids = [93532, 93653, 944, 93421, 1019, 93653, 93519]
335+
return ModelRequestData(
336+
llm=llm,
337+
prompt=prompt,
338+
stop_token_ids=stop_token_ids,
339+
image_data=[fetch_image(url) for url in image_urls],
340+
chat_template=None)
341+
342+
324343
model_example_map = {
325344
"phi3_v": load_phi3v,
326345
"h2ovl_chat": load_h2onvl,
@@ -330,6 +349,7 @@ def load_idefics3(question, image_urls: List[str]) -> ModelRequestData:
330349
"qwen_vl_chat": load_qwenvl_chat,
331350
"mllama": load_mllama,
332351
"idefics3": load_idefics3,
352+
"aria": load_aria,
333353
}
334354

335355

tests/models/registry.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class _HfExamplesInfo:
4343
trust_remote_code=True),
4444
"ArcticForCausalLM": _HfExamplesInfo("Snowflake/snowflake-arctic-instruct",
4545
trust_remote_code=True),
46+
"AriaForConditionalGeneration": _HfExamplesInfo("rhymes-ai/Aria",
47+
trust_remote_code=True),
4648
"BaiChuanForCausalLM": _HfExamplesInfo("baichuan-inc/Baichuan-7B",
4749
trust_remote_code=True),
4850
"BaichuanForCausalLM": _HfExamplesInfo("baichuan-inc/Baichuan2-7B-chat",

vllm/entrypoints/chat_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ def _placeholder_str(self, modality: ModalityStr,
412412
return ""
413413
if model_type == "idefics3":
414414
return "<image>"
415+
if model_type == "aria":
416+
return "<|fim_prefix|><|img|><|fim_suffix|>"
415417

416418
raise TypeError(f"Unknown {modality} model type: {model_type}")
417419
elif modality == "audio":

0 commit comments

Comments
 (0)