Image-Text-to-Text
Transformers
Safetensors
English
Chinese
agnes
text-generation
agnes-ai
reasoning
multimodal
long-context
hybrid-attention
conversational
custom_code
Instructions to use Agnes-AI/Agnes-3.0-Flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Agnes-AI/Agnes-3.0-Flash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Agnes-AI/Agnes-3.0-Flash", 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 AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Agnes-AI/Agnes-3.0-Flash", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Agnes-AI/Agnes-3.0-Flash with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Agnes-AI/Agnes-3.0-Flash" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Agnes-AI/Agnes-3.0-Flash", "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/Agnes-AI/Agnes-3.0-Flash
- SGLang
How to use Agnes-AI/Agnes-3.0-Flash 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 "Agnes-AI/Agnes-3.0-Flash" \ --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": "Agnes-AI/Agnes-3.0-Flash", "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 "Agnes-AI/Agnes-3.0-Flash" \ --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": "Agnes-AI/Agnes-3.0-Flash", "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 Agnes-AI/Agnes-3.0-Flash with Docker Model Runner:
docker model run hf.co/Agnes-AI/Agnes-3.0-Flash
File size: 3,174 Bytes
3599318 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # Agnes 3.0 Flash configuration for sglang.
#
# The HF checkpoint says model_type "agnes", names its layer types
# agnes_delta_attention / agnes_global_attention and carries a parallel FFN
# branch per layer. The server runs it on its built-in hybrid
# (delta-rule + global attention) implementation, so this class maps those
# onto the fields that implementation reads; the checkpoint's tensor names
# are translated while loading (see the model file patched by apply_patch.py).
from sglang.srt.configs.qwen3_5 import Qwen3_5Config
AGNES_DELTA = "agnes_delta_attention"
AGNES_GLOBAL = "agnes_global_attention"
class AgnesConfig(Qwen3_5Config):
model_type = "agnes"
def __init__(self, text_config=None, vision_config=None, **kwargs):
kwargs.pop("auto_map", None) # the transformers remote code is not used in the server
if isinstance(text_config, dict):
text_config = dict(text_config)
text_config["model_type"] = "qwen3_5_text"
width = int(text_config.pop("parallel_ffn_intermediate_size", 0) or 0)
plan = text_config.pop("layer_types", None)
interval = text_config.pop("global_attention_interval", None)
if interval is None:
interval = text_config.pop("full_attention_interval", None)
if interval is None and plan:
interval = next(i + 1 for i, t in enumerate(plan) if t == AGNES_GLOBAL)
text_config["full_attention_interval"] = int(interval or 4)
main = int(text_config["intermediate_size"])
# the parallel branch is folded into the main MLP at load time
text_config["intermediate_size"] = main + width
text_config["agnes_main_intermediate_size"] = main
text_config["agnes_parallel_ffn_intermediate_size"] = width
if isinstance(vision_config, dict):
vision_config = dict(vision_config)
vision_config["model_type"] = "qwen3_5"
kwargs["architectures"] = ["Qwen3_5ForConditionalGeneration"]
super().__init__(text_config=text_config, vision_config=vision_config, **kwargs)
# every downstream check sees the built-in hybrid architecture
self.model_type = "qwen3_5"
@classmethod
def from_pretrained(cls, pretrained_model_name_or_path, *args, **kwargs):
# The weight loader needs the checkpoint directory to pick up the parallel
# branch tensors. The path is written into the config *dict* before the
# object is built: the config reaches the worker processes through a
# to_dict round trip, which keeps fields that came in through __init__
# and drops attributes set afterwards (from_pretrained's own kwargs only
# override known fields, so they cannot carry it either).
path = str(pretrained_model_name_or_path)
config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
config_dict["agnes_model_path"] = path
if isinstance(config_dict.get("text_config"), dict):
config_dict["text_config"]["agnes_model_path"] = path
return cls.from_dict(config_dict, **kwargs)
|