Image-Text-to-Text
Transformers
Safetensors
multilingual
eagle_2_5_vl
feature-extraction
eagle
VLM
conversational
custom_code
Instructions to use nvidia/Eagle2-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Eagle2-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="nvidia/Eagle2-2B", 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-2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nvidia/Eagle2-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/Eagle2-2B" # 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-2B", "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-2B
- SGLang
How to use nvidia/Eagle2-2B 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-2B" \ --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-2B", "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-2B" \ --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-2B", "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-2B with Docker Model Runner:
docker model run hf.co/nvidia/Eagle2-2B
| # -------------------------------------------------------- | |
| # NVIDIA | |
| # Copyright (c) 2025 NVIDIA | |
| # Licensed under The MIT License [see LICENSE for details] | |
| # -------------------------------------------------------- | |
| import copy | |
| from transformers.models.llama.configuration_llama import LlamaConfig | |
| from transformers.models.qwen2.configuration_qwen2 import Qwen2Config | |
| from transformers.configuration_utils import PretrainedConfig | |
| from transformers.utils import logging | |
| from transformers.models.siglip.configuration_siglip import SiglipVisionConfig | |
| logger = logging.get_logger(__name__) | |
| class Eagle2_5_VLConfig(PretrainedConfig): | |
| model_type = 'eagle_2_5_vl' | |
| is_composition = True | |
| sub_configs = {"vision_config": SiglipVisionConfig, "text_config": Qwen2Config} | |
| def __init__( | |
| self, | |
| vision_config=None, | |
| text_config=None, | |
| use_backbone_lora=0, | |
| use_llm_lora=0, | |
| pad2square=False, | |
| select_layer=-4, | |
| force_image_size=None, | |
| downsample_ratio=0.5, | |
| template=None, | |
| dynamic_image_size=False, | |
| use_thumbnail=False, | |
| loss_version='v1', | |
| min_dynamic_tiles=1, | |
| max_dynamic_tiles=6, | |
| mlp_checkpoint=False, | |
| initializer_range=0.02, | |
| _attn_implementation='flash_attention_2', | |
| _attn_implementation_autoset=False, | |
| llm_config=None, | |
| image_token_index=None, | |
| **kwargs): | |
| super().__init__(**kwargs) | |
| if vision_config is None: | |
| vision_config = {'model_type': 'siglip_vision_model'} | |
| logger.info('vision_config is None. Initializing the InternVisionConfig with default values.') | |
| if text_config is None: | |
| text_config = {'architectures': ['Qwen2ForCausalLM']} | |
| logger.info('text_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).') | |
| if vision_config['model_type'] == 'siglip_vision_model': | |
| self.vision_config = SiglipVisionConfig(**vision_config) | |
| else: | |
| raise ValueError('Unsupported model_type: {}'.format(vision_config['model_type'])) | |
| if text_config['architectures'][0] == 'LlamaForCausalLM': | |
| self.text_config = LlamaConfig(**text_config) | |
| elif text_config['architectures'][0] == 'Qwen2ForCausalLM': | |
| self.text_config = Qwen2Config(**text_config) | |
| else: | |
| raise ValueError('Unsupported architecture: {}'.format(text_config['architectures'][0])) | |
| self.use_backbone_lora = use_backbone_lora | |
| self.use_llm_lora = use_llm_lora | |
| self.mlp_checkpoint = mlp_checkpoint | |
| self.pad2square = pad2square | |
| self.select_layer = select_layer | |
| self.force_image_size = force_image_size | |
| self.downsample_ratio = downsample_ratio | |
| self.template = template | |
| self.dynamic_image_size = dynamic_image_size | |
| self.use_thumbnail = use_thumbnail | |
| self.loss_version = loss_version | |
| self.initializer_range = initializer_range | |
| self.min_dynamic_tiles = min_dynamic_tiles | |
| self.max_dynamic_tiles = max_dynamic_tiles | |
| self.tie_word_embeddings = self.text_config.tie_word_embeddings | |
| self._attn_implementation = _attn_implementation | |
| self._attn_implementation_autoset = _attn_implementation_autoset | |
| self.image_token_index = image_token_index | |
| logger.info(f'min_dynamic_tiles: {self.min_dynamic_tiles}') | |
| logger.info(f'max_dynamic_tiles: {self.max_dynamic_tiles}') | |
| def to_dict(self): | |
| """ | |
| Serializes this instance to a Python dictionary. Override the default [`~PretrainedConfig.to_dict`]. | |
| Returns: | |
| `Dict[str, any]`: Dictionary of all the attributes that make up this configuration instance, | |
| """ | |
| output = copy.deepcopy(self.__dict__) | |
| output['vision_config'] = self.vision_config.to_dict() | |
| output['text_config'] = self.text_config.to_dict() | |
| output['model_type'] = self.__class__.model_type | |
| output['use_backbone_lora'] = self.use_backbone_lora | |
| output['use_llm_lora'] = self.use_llm_lora | |
| output['pad2square'] = self.pad2square | |
| output['select_layer'] = self.select_layer | |
| output['force_image_size'] = self.force_image_size | |
| output['downsample_ratio'] = self.downsample_ratio | |
| output['template'] = self.template | |
| output['dynamic_image_size'] = self.dynamic_image_size | |
| output['use_thumbnail'] = self.use_thumbnail | |
| output['min_dynamic_tiles'] = self.min_dynamic_tiles | |
| output['max_dynamic_tiles'] = self.max_dynamic_tiles | |
| output['tie_word_embeddings'] = self.tie_word_embeddings | |
| output['_attn_implementation'] = self._attn_implementation | |
| output['_attn_implementation_autoset'] = self._attn_implementation_autoset | |
| return output | |