Download Game! Currently 85 players and visitors. Last logged in:RothanValkristBrurinCordoba

Blitzer's Blog >> 72568

Back to blogs index
Posted: 17 Sep 2026 05:17 [ permalink ]
This is a highly optimized architecture. What you are describing is a Model
Cascading (or "LLM Routing") pattern. Using a smaller, faster model (Gemma)
for retrieval, classification, and orchestration, and reserving a larger model
(DeepSeek) exclusively for heavy code synthesis is exactly how to keep latency
and inference costs down while maintaining quality.
Here is a breakdown of how to structure this workflow as a Directed Acyclic
Graph (DAG) to ensure data flows reliably between the microservices and
models.
Step-by-Step Refinements & Potential Pitfalls
To make this execution graph robustespecially if you are building this in an
asynchronous environment like Node.js or FastAPIhere are the technical
refinements for each node in your pipeline:
1. The Input Spec
Keep the input highly structured. If the idea/need is passed as raw prose,
model performance drops. Standardizing the input as a structured Markdown
specification (or an AST-like JSON object) ensures that when DeepSeek finally
sees the prompt in Step 6, it has exact boundaries for dependencies and
expected outputs.
2. Fetching from the REST API
The Bottleneck Warning: If your REST API returns thousands of routines,
dumping the entire JSON response into Gemmas context window will blow up the
token limit and dilute the model's attention.
 * The Fix: Implement a lightweight vector search (embedding distance) or a
BM25 keyword filter on the REST API side. The API should only return the top
20 to 50 mathematically closest routines to the input spec before Gemma ever
sees them.
3 & 4. Gemma Ranking & Evaluation
Gemma excels at fast classification. You can structure this to enforce strict
DAG validation:
 * Instead of asking Gemma to evaluate candidates sequentially (which
increases latency), fan out the requests. Map over the candidates and hit your
Gemma cluster in parallel.
 * Force Gemma to return a strict JSON schema for each candidate (e.g.,
{"is_match": true, "confidence": 85, "reason": "..."}). This allows your
pipeline to strictly validate the data structures before sorting them in Step
5.
5. Selection Logic
This doesn't require an LLM. A simple programmatic sort of the validated JSON
array based on the confidence integer is safest.
 * Thresholding: Set a minimum confidence floor (e.g., > 80%). If no routine
hits the floor, bypass DeepSeek's modification prompt and route it straight to
a "code from scratch" prompt.
6. DeepSeek Synthesis
DeepSeek is doing the heavy lifting. To ensure the output is usable:
 * Use a strong system prompt that defines the execution environment (e.g.,
strict ESM modules, specific import requirements).
 * Syntax Verification Loop: Before passing the code to Step 7, run a fast,
localized syntax check. If you compile the output into a temporary sandbox
(like a V8 isolate or a lightweight container) just to check for SyntaxErrors,
you can loop it back to DeepSeek for a rapid fix without burdening the heavier
QA pipeline.
7. Handoff to QA
Because this is a separate pipeline, ensure Step 6 packages the final code,
the original spec, and the DeepSeek generation logs into a single artifact
before passing it over the wall.