Skip to content

Commit 9c16f52

Browse files
fix(demo): keep answers cited when the free chain falls to a weak model
gemma-4-26b started 502ing upstream, so every /demo/chat answer fell through to nemotron-nano-12b-vl, which ignores the system-prompt citation rule entirely: answers rendered with no sources. Pinning that model with the production prompt reproduced it - zero bracket citations until the rule is restated next to the question. - restate the citation rule at the end of the user message; takes nemotron-nano from zero to per-claim citations across repeated probes - add two free vision models that cite reliably (gemma-4-31b, nex-n2-pro) to the chain ahead of the nemotron fallback
1 parent 940481a commit 9c16f52

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/config/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ class Settings(BaseSettings):
5959
# time as a misconfiguration guard. Env-overridable (RAG_DEMO_MODELS) so
6060
# the chain can be re-pointed without an image rebuild when the free pool
6161
# shifts. Models must be vision-capable: the demo client sends page images.
62-
demo_models: str = "google/gemma-4-26b-a4b-it:free,nvidia/nemotron-nano-12b-v2-vl:free"
62+
demo_models: str = (
63+
"google/gemma-4-26b-a4b-it:free,google/gemma-4-31b-it:free,"
64+
"nex-agi/nex-n2-pro:free,nvidia/nemotron-nano-12b-v2-vl:free"
65+
)
6366

6467
top_k: int = Field(default=5, ge=1)
6568
rerank_top_k: int = Field(default=50, ge=1)

tests/unit/test_demo_route.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def handler(body: dict[str, Any]) -> httpx.Response:
119119
assert res.status_code == 200
120120
assert [b["model"] for b in seen] == [
121121
"google/gemma-4-26b-a4b-it:free",
122-
"nvidia/nemotron-nano-12b-v2-vl:free",
122+
"google/gemma-4-31b-it:free",
123+
"nex-agi/nex-n2-pro:free",
123124
]
124125

125126

web/app/api.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,15 @@
328328
content.push({ type: "image_url", image_url: { url: dataUrl } });
329329
}
330330
}
331-
content.push({ type: "text", text: `\nQuestion: ${latestUserText}` });
331+
// The citation rule lives in the system prompt, but the small free models
332+
// the demo chain falls back to drop it there: nemotron-nano-12b emits zero
333+
// bracket citations until the rule is restated next to the question.
334+
content.push({
335+
type: "text",
336+
text:
337+
`\nQuestion: ${latestUserText}` +
338+
"\n(Reminder: every factual claim taken from the context must cite its supporting chunk id in square brackets, e.g. [2604.22753v1::p5::c24] — an answer that states facts without bracket citations is rejected.)",
339+
});
332340
messages.push({ role: "user", content });
333341
// `injected` rides along so the UI can show this evidence in the panel —
334342
// it is context the model saw, but it is not a retrieval result.

0 commit comments

Comments
 (0)