Skip to content

Commit 5e3b748

Browse files
feat(agentic): tune VLM params and enable reasoning mode
Increase AGENTIC_VLM_MAX_TOKENS default from 1024 to 16384 to accommodate Nemotron Omni reasoning token budget. Add temperature (0.6) and top_p (0.95) fields to AgenticVLMConfig, exposed as AGENTIC_VLM_TEMPERATURE / AGENTIC_VLM_TOP_P env vars, per the Nemotron Omni reasoning-mode defaults in docs/vlm.md. Prepend /think to VLM_TASK_SYSTEM_PROMPT to trigger chain-of-thought reasoning on visual question answering tasks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Nikhil Kulkarni <nikkulkarni@nvidia.com>
1 parent 9306e5a commit 5e3b748

5 files changed

Lines changed: 38 additions & 8 deletions

File tree

deploy/compose/docker-compose-rag-server.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ services:
256256
AGENTIC_VLM_SERVERURL: ${AGENTIC_VLM_SERVERURL:-${APP_VLM_SERVERURL:-""}}
257257
AGENTIC_VLM_MODEL: ${AGENTIC_VLM_MODEL:-${APP_VLM_MODELNAME:-""}}
258258
AGENTIC_VLM_APIKEY: ${AGENTIC_VLM_APIKEY:-${APP_VLM_APIKEY:-""}}
259-
AGENTIC_VLM_MAX_TOKENS: ${AGENTIC_VLM_MAX_TOKENS:-1024}
259+
AGENTIC_VLM_MAX_TOKENS: ${AGENTIC_VLM_MAX_TOKENS:-16384}
260+
AGENTIC_VLM_TEMPERATURE: ${AGENTIC_VLM_TEMPERATURE:-0.6}
261+
AGENTIC_VLM_TOP_P: ${AGENTIC_VLM_TOP_P:-0.95}
260262
AGENTIC_VLM_ENABLE_VISUAL_VERIFY: ${AGENTIC_VLM_ENABLE_VISUAL_VERIFY:-false}
261263

262264
ports:

deploy/compose/nvdev.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,6 @@ export AGENTIC_CONTEXT_MAX_TOKENS=100000
152152
# export AGENTIC_VLM_ENABLED=true
153153
# export AGENTIC_VLM_SERVERURL=https://integrate.api.nvidia.com/v1
154154
# export AGENTIC_VLM_MODEL=nvidia/nemotron-3-nano-omni-30b-a3b-reasoning
155-
# export AGENTIC_VLM_MAX_TOKENS=1024
155+
# export AGENTIC_VLM_MAX_TOKENS=16384
156+
# export AGENTIC_VLM_TEMPERATURE=0.6
157+
# export AGENTIC_VLM_TOP_P=0.95

src/nvidia_rag/rag_server/agentic_rag/builder.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,21 @@ def _make_vlm_client(vlm_cfg: Any, rag_config: Any) -> Any:
361361

362362
api_key = vlm_cfg.get_api_key() or rag_config.llm.get_api_key()
363363
logger.debug(
364-
"Creating agentic VLM client: model=%s, url=%s, max_tokens=%s",
364+
"Creating agentic VLM client: model=%s, url=%s, max_tokens=%s, temperature=%s, top_p=%s",
365365
vlm_cfg.model_name,
366366
vlm_cfg.server_url or "(api-catalog)",
367367
vlm_cfg.max_tokens,
368+
vlm_cfg.temperature,
369+
vlm_cfg.top_p,
368370
)
369371
return get_llm(
370372
config=rag_config,
371373
model=vlm_cfg.model_name,
372374
llm_endpoint=vlm_cfg.server_url,
373375
api_key=api_key,
374376
max_tokens=vlm_cfg.max_tokens,
377+
temperature=vlm_cfg.temperature,
378+
top_p=vlm_cfg.top_p,
375379
)
376380

377381

src/nvidia_rag/rag_server/agentic_rag/prompt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@
305305
# directly in plain text and the caller wraps it in a completeness dict.
306306
# =============================================================================
307307

308-
VLM_TASK_SYSTEM_PROMPT = """You are an expert at reading charts, diagrams, tables, and images.
308+
VLM_TASK_SYSTEM_PROMPT = """/think
309+
You are an expert at reading charts, diagrams, tables, and images.
309310
You are given an image and a specific question about its content.
310311
Answer the question directly and precisely based only on what is visually present in the image.
311312
Report numbers, labels, and values exactly as they appear — do not round or reformat.

src/nvidia_rag/utils/agentic_rag_config.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,17 @@ class AgenticVLMConfig(_ConfigBase):
128128
relying on the pre-generated text descriptions produced at ingest time.
129129
The same VLM routing applies to verify_execute tasks.
130130
131+
Generation parameters follow the Nemotron Omni reasoning-mode defaults
132+
documented in docs/vlm.md: temperature=0.6, top_p=0.95, max_tokens=16384.
133+
131134
Env vars:
132135
AGENTIC_VLM_ENABLED — master switch (default: false)
133136
AGENTIC_VLM_SERVERURL — VLM endpoint URL
134137
AGENTIC_VLM_MODEL — VLM model name
135138
AGENTIC_VLM_APIKEY — optional API key override
136-
AGENTIC_VLM_MAX_TOKENS — max tokens per VLM response (default: 1024)
139+
AGENTIC_VLM_MAX_TOKENS — max tokens per VLM response (default: 16384)
140+
AGENTIC_VLM_TEMPERATURE — sampling temperature (default: 0.6)
141+
AGENTIC_VLM_TOP_P — nucleus sampling mass (default: 0.95)
137142
AGENTIC_VLM_ENABLE_VISUAL_VERIFY — reserved for future visual fact-checking
138143
in the verify node (default: false)
139144
"""
@@ -154,17 +159,33 @@ class AgenticVLMConfig(_ConfigBase):
154159
model_name: str = Field(
155160
default="",
156161
env="AGENTIC_VLM_MODEL",
157-
description="VLM model name (e.g. nvidia/llama-3.2-90b-vision-instruct).",
162+
description="VLM model name (e.g. nvidia/nemotron-3-nano-omni-30b-a3b-reasoning).",
158163
)
159164
api_key: SecretStr | None = Field(
160165
default=None,
161166
env="AGENTIC_VLM_APIKEY",
162167
description="API key for the VLM endpoint. Falls back to NVIDIA_API_KEY if unset.",
163168
)
164169
max_tokens: int = Field(
165-
default=1024,
170+
default=16384,
166171
env="AGENTIC_VLM_MAX_TOKENS",
167-
description="Max generated tokens for VLM responses.",
172+
description="Max generated tokens for VLM responses (includes reasoning tokens).",
173+
)
174+
temperature: float = Field(
175+
default=0.6,
176+
env="AGENTIC_VLM_TEMPERATURE",
177+
description=(
178+
"Sampling temperature for VLM responses. "
179+
"0.6 is the Nemotron Omni reasoning-mode default (docs/vlm.md)."
180+
),
181+
)
182+
top_p: float = Field(
183+
default=0.95,
184+
env="AGENTIC_VLM_TOP_P",
185+
description=(
186+
"Nucleus sampling mass for VLM responses. "
187+
"0.95 is the Nemotron Omni reasoning-mode default (docs/vlm.md)."
188+
),
168189
)
169190
enable_visual_verify: bool = Field(
170191
default=False,

0 commit comments

Comments
 (0)