Image-Text-to-Text
Transformers
Safetensors
multilingual
eagle_chat
feature-extraction
eagle
VLM
conversational
custom_code
Instructions to use nvidia/Eagle2-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Eagle2-9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="nvidia/Eagle2-9B", 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 AutoModel model = AutoModel.from_pretrained("nvidia/Eagle2-9B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nvidia/Eagle2-9B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/Eagle2-9B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/Eagle2-9B", "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/nvidia/Eagle2-9B
- SGLang
How to use nvidia/Eagle2-9B 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 "nvidia/Eagle2-9B" \ --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": "nvidia/Eagle2-9B", "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 "nvidia/Eagle2-9B" \ --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": "nvidia/Eagle2-9B", "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 nvidia/Eagle2-9B with Docker Model Runner:
docker model run hf.co/nvidia/Eagle2-9B
| # -------------------------------------------------------- | |
| # Eagle2 | |
| # Copyright (c) 2025 NVIDIA | |
| # Licensed under The Apache License [see LICENSE for details] | |
| # -------------------------------------------------------- | |
| import os | |
| from typing import Union | |
| from transformers.configuration_utils import PretrainedConfig | |
| from transformers.utils import logging | |
| from .configuration_siglip import SiglipVisionConfig | |
| logger = logging.get_logger(__name__) | |
| class MultiBackboneChannelConcatenationVisionModelConfig(PretrainedConfig): | |
| r""" | |
| This is the configuration class to store the configuration of a [`MultiBackboneChannelConcatenationVisionModelConfig`]. It is used to | |
| instantiate a vision encoder according to the specified arguments, defining the model architecture. | |
| Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the | |
| documentation from [`PretrainedConfig`] for more information. | |
| Args: | |
| vision_path (str): Path to the vision model or its configuration. | |
| mm_vision_select_layer (int, optional): The layer to select from the vision model | |
| for multi-modal processing. Defaults to -2. | |
| grid_size (int, optional): The size of the grid for vision processing. Defaults to 32. | |
| **kwargs: Additional keyword arguments to be passed to the parent PretrainedConfig. | |
| """ | |
| model_type = 'MOB' | |
| def __init__( | |
| self, | |
| vision_path, | |
| mm_vision_select_layer=-2, | |
| grid_size=32, | |
| input_image_size=1024, | |
| hidden_size='lazy_calculation', | |
| image_size=1024, | |
| freeze_backbones=None, | |
| moe_version_type=None, | |
| delay_load=False, | |
| convnext_img_size=1024, | |
| vision_tower_siglip_path=None, | |
| vision_tower_convnext_path='convnext_xxlarge.clip_laion2b_soup', | |
| normalize_type='siglip', | |
| **kwargs, | |
| ): | |
| super().__init__(**kwargs) | |
| self.normalize_type = normalize_type | |
| self.vision_path = vision_path | |
| self.mm_vision_select_layer = mm_vision_select_layer | |
| self.grid_size = grid_size | |
| self.input_image_size = input_image_size | |
| self.image_size = image_size | |
| self.hidden_size = hidden_size | |
| self.freeze_backbones = freeze_backbones | |
| self.moe_version_type = moe_version_type | |
| self.delay_load = delay_load | |
| self.convnext_img_size = convnext_img_size | |
| # other args. to make it compatable with eagle-next | |
| self.vision_tower_siglip_path = vision_tower_siglip_path | |
| self.vision_tower_convnext_path = vision_tower_convnext_path | |
| self.vision_tower = self.vision_path[4:] # remove `MOB:` prefix | |
| # asserts | |
| assert image_size == input_image_size, f"input_image_size ({input_image_size}) != image_size ({image_size})" | |
| def from_pretrained(cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs) -> 'PretrainedConfig': | |
| config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs) | |
| if 'vision_config' in config_dict: | |
| config_dict = config_dict['vision_config'] | |
| if 'model_type' in config_dict and hasattr(cls, 'model_type') and config_dict['model_type'] != cls.model_type: | |
| logger.warning( | |
| f"You are using a model of type {config_dict['model_type']} to instantiate a model of type " | |
| f'{cls.model_type}. This is not supported for all configurations of models and can yield errors.' | |
| ) | |
| return cls.from_dict(config_dict, **kwargs) | |