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 Settings
- 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 torch.nn as nn | |
| from transformers.modeling_outputs import BaseModelOutputWithPooling | |
| from typing import Optional, Tuple, Union | |
| from .multi_backbone_channel_concatenation_encoder import MultiBackboneChannelConcatenationVisionTower | |
| from .configuration_multi_backbone_channel_concatentation_model import MultiBackboneChannelConcatenationVisionModelConfig | |
| class MultiBackboneChannelConcatenationVisionModel(nn.Module): | |
| """ | |
| A vision model wrapper that concatenates channels from multiple backbones. | |
| Args: | |
| config (MultiBackboneChannelConcatenationVisionModelConfig): The configuration for the model. | |
| Attributes: | |
| vision_model (MultiBackboneChannelConcatenationVisionTower): The vision tower that performs the channel concatenation. | |
| Notes: | |
| **The class is not inherited from the PreTrainedModel in transformers** | |
| """ | |
| config_class = MultiBackboneChannelConcatenationVisionModelConfig | |
| main_input_name = "pixel_values" | |
| def __init__(self, config: MultiBackboneChannelConcatenationVisionModelConfig, raw_config): | |
| super().__init__() | |
| self.vision_model = MultiBackboneChannelConcatenationVisionTower( | |
| vision_tower=config.vision_tower, | |
| args=config, | |
| grid_size=config.grid_size, | |
| convnext_img_size=config.convnext_img_size, | |
| normalize_type=config.normalize_type, | |
| raw_config=raw_config | |
| ) | |
| def get_input_embeddings(self): | |
| # You might need to adjust this depending on how you want to handle input embeddings | |
| return self.vision_model.vision_towers[0].get_input_embeddings() | |
| def forward( | |
| self, | |
| pixel_values, | |
| return_dict: Optional[bool] = True, | |
| output_hidden_states: Optional[bool] = False, | |
| ) -> Union[Tuple, BaseModelOutputWithPooling]: | |
| return_dict = return_dict if return_dict is not None else self.config.use_return_dict | |
| assert return_dict is True, "We only support return_dict" | |
| assert output_hidden_states is False, "We do not support output_hidden_states" | |
| features = self.vision_model(pixel_values) | |
| # We only supports features as model outputs | |
| return BaseModelOutputWithPooling( | |
| last_hidden_state=features, | |
| pooler_output=None, | |
| hidden_states=None, | |
| attentions=None, | |
| ) | |
| def dummy_feature(self): | |
| return self.vision_model.dummy_feature | |
| def dtype(self): | |
| return self.vision_model.dtype | |
| def device(self): | |
| return self.vision_model.device | |
| def config(self): | |
| return self.vision_model.config | |
| def hidden_size(self): | |
| return self.vision_model.hidden_size | |
| def num_patches(self): | |
| return self.vision_model.num_patches | |