Instructions to use sheldonrobinson/Aria-sequential_mlp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sheldonrobinson/Aria-sequential_mlp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="sheldonrobinson/Aria-sequential_mlp", trust_remote_code=True) 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("sheldonrobinson/Aria-sequential_mlp", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("sheldonrobinson/Aria-sequential_mlp", trust_remote_code=True, device_map="auto") 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 sheldonrobinson/Aria-sequential_mlp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sheldonrobinson/Aria-sequential_mlp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sheldonrobinson/Aria-sequential_mlp", "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/sheldonrobinson/Aria-sequential_mlp
- SGLang
How to use sheldonrobinson/Aria-sequential_mlp 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 "sheldonrobinson/Aria-sequential_mlp" \ --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": "sheldonrobinson/Aria-sequential_mlp", "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 "sheldonrobinson/Aria-sequential_mlp" \ --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": "sheldonrobinson/Aria-sequential_mlp", "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 sheldonrobinson/Aria-sequential_mlp with Docker Model Runner:
docker model run hf.co/sheldonrobinson/Aria-sequential_mlp
| # Copyright 2024 Rhymes AI. All rights reserved. | |
| # | |
| # Licensed to the Apache Software Foundation (ASF) under one | |
| # or more contributor license agreements. See the NOTICE file | |
| # distributed with this work for additional information | |
| # regarding copyright ownership. The ASF licenses this file | |
| # to you under the Apache License, Version 2.0 (the | |
| # "License"); you may not use this file except in compliance | |
| # with the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, | |
| # software distributed under the License is distributed on an | |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| # KIND, either express or implied. See the License for the | |
| # specific language governing permissions and limitations | |
| # under the License. | |
| from transformers.configuration_utils import PretrainedConfig | |
| from .moe_lm import AriaMoELMConfig | |
| from .vision_encoder import AriaVisionConfig | |
| # adapted from transformers.models.llava.configuration_llava.LlavaConfig | |
| class AriaConfig(PretrainedConfig): | |
| """ | |
| Configuration class for Aria model. | |
| This class handles the configuration for both vision and text components of the Aria model, | |
| as well as additional parameters for image token handling and projector mapping. | |
| Args: | |
| vision_config (AriaVisionConfig or dict): Configuration for the vision component. | |
| text_config (AriaMoELMConfig or dict): Configuration for the text component. | |
| projector_patch_to_query_dict (dict): Mapping of patch sizes to query dimensions. | |
| ignore_index (int): Index to ignore in loss calculation. | |
| image_token_index (int): Index used to represent image tokens. | |
| **kwargs: Additional keyword arguments passed to the parent class. | |
| Attributes: | |
| model_type (str): Type of the model, set to "aria". | |
| is_composition (bool): Whether the model is a composition of multiple components. | |
| ignore_index (int): Index to ignore in loss calculation. | |
| image_token_index (int): Index used to represent image tokens. | |
| projector_patch_to_query_dict (dict): Mapping of patch sizes to query dimensions. | |
| vision_config (AriaVisionConfig): Configuration for the vision component. | |
| text_config (AriaMoELMConfig): Configuration for the text component. | |
| """ | |
| model_type = "aria" | |
| is_composition = False | |
| def __init__( | |
| self, | |
| vision_config=AriaVisionConfig(), | |
| text_config=AriaMoELMConfig(), | |
| projector_patch_to_query_dict={ | |
| 1225: 128, | |
| 4900: 256, | |
| }, | |
| ignore_index=-100, | |
| image_token_index=32000, | |
| **kwargs, | |
| ): | |
| super().__init__(**kwargs) | |
| self.ignore_index = ignore_index | |
| self.image_token_index = image_token_index | |
| attn_implementation = kwargs.pop("attn_implementation", None) | |
| # Convert the keys and values of projector_patch_to_query_dict to integers | |
| # This ensures consistency even if they were provided as strings | |
| self.projector_patch_to_query_dict = { | |
| int(k): int(v) for k, v in projector_patch_to_query_dict.items() | |
| } | |
| if isinstance(vision_config, dict) and "model_type" in vision_config: | |
| vision_config = AriaVisionConfig(**vision_config) | |
| vision_attn_implementation = ( | |
| "flash_attention_2" | |
| if attn_implementation is None | |
| else attn_implementation | |
| ) | |
| vision_config._attn_implementation = vision_attn_implementation | |
| self.vision_config = vision_config | |
| if isinstance(text_config, dict) and "model_type" in text_config: | |
| text_attn_implementation = ( | |
| "sdpa" if attn_implementation is None else attn_implementation | |
| ) | |
| text_config = AriaMoELMConfig(**text_config) | |
| text_config._attn_implementation = text_attn_implementation | |
| self.text_config = text_config | |