3.28 Multi-Model Inference: MoA & Speculative Decoding
Back to Hub Print / PDF On This Page Overview ELI5 Summary Section A: User Guide What is MoA? What is Speculative Decoding? How They Work Together Mo
Back to Hub Print / PDF On This Page Overview ELI5 Summary Section A: User Guide What is MoA? What is Speculative Decoding? How They Work Together Mo
3.28 Multi-Model Inference: MoA & Speculative Decoding
Mixture-of-Agents (MoA) inference uses multiple AI models working together — one writes, another reviews, a third validates — to produce higher quality results than any single model alone.
3.28 Multi-Model Inference: MoA & Speculative Decoding
How Mixture of Agents (MoA) and DSpark-style speculative decoding work together to eliminate hallucinations and optimize cost/quality in Hermes Agent.
Imagine you have three friends helping you with homework. One friend (Gemini) is super fast but sometimes makes mistakes. Another (DeepSeek) is careful and accurate. The third (Claude) is brilliant but expensive. Instead of using just one, we ask the fast friend first to get a quick answer, then have the careful friend double-check it. If there's a disagreement, we bring in the expensive friend to settle it. This way, we get accurate answers quickly and cheaply — the best of all three friends working together.
A What is Mixture of Agents (MoA)?
Mixture of Agents (MoA) is an inference strategy where multiple AI models collaborate on a single task. Instead of relying on one model, MoA routes different parts of a request to specialized models based on their strengths.
MoA treats models like specialists in a team. Each model has unique strengths: some excel at speed, others at accuracy, and others at complex reasoning. By combining them strategically, we achieve better results than any single model alone.
Gemini 2.0 Flash — Ultra-fast responses for simple tasks and initial drafts.
DeepSeek R1 — Precise verification and fact-checking with lower hallucination risk.
Claude Sonnet 4 — Complex problem-solving and critical decisions.
A What is Speculative Decoding?
Speculative Decoding (also called DSpark after the DeepSeek Spark implementation) is a two-stage inference pattern where a fast "draft model" generates candidate responses, and a slower "verification model" validates them.
▲ Video: How DSpark-style speculative decoding eliminates hallucinations while maintaining speed
-
1Draft Generation
A fast model (Gemini 2.0 Flash) generates a quick response in 200-500ms.
-
2Verification Pass
A more careful model (DeepSeek R1) validates the draft for accuracy and hallucinations.
-
3Accept or Reject
If verification passes, return the draft (fast path). If it fails, regenerate with the verifier model (safe path).
A How They Work Together
In RAIA's implementation, MoA and Speculative Decoding combine into a three-tier routing system:
┌─────────────────────────────────────────────────────────────────┐
│ INCOMING REQUEST │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────┐
│ Route by Type │
└──────────────────┘
│ │ │
┌───────────┘ │ └──────────┐
▼ ▼ ▼
┌─────────┐ ┌──────────────┐ ┌──────────┐
│ Simple │ │ Standard │ │ Critical │
│ Task │ │ Task │ │ Task │
└─────────┘ └──────────────┘ └──────────┘
│ │ │
▼ ▼ ▼
┌─────────┐ ┌──────────────┐ ┌──────────┐
│ Gemini │ │ Gemini Draft │ │ Claude │
│ Flash │ │ + │ │ Sonnet 4 │
│ ONLY │ │ DeepSeek │ │ Direct │
│ │ │ Verify │ │ │
└─────────┘ └──────────────┘ └──────────┘
│ │ │
└──────────────────┴───────────────────┘
│
▼
┌──────────────┐
│ Response │
└──────────────┘
A Model Routing Rules
The system automatically routes requests based on complexity and risk level:
| Task Type | Model Path | Latency | Cost | Use Case |
|---|---|---|---|---|
| Simple | Gemini Flash only | ~300ms | $0.0001 | Status checks, list queries, formatting |
| Standard | Gemini Draft → DeepSeek Verify | ~800ms | $0.0015 | Code generation, data queries, documentation |
| Critical | Claude Sonnet 4 direct | ~2000ms | $0.015 | Database migrations, security decisions, compliance |
If DeepSeek verification fails twice in a row on a Standard task, the system automatically escalates to Claude Sonnet 4 for the final attempt.
A Model Comparison Table
| Model | Hallucination Risk | Speed | Cost | Best Use |
|---|---|---|---|---|
| Gemini 2.0 Flash | Medium-High | Excellent | Very Low | Fast drafts, simple queries, non-critical tasks |
| DeepSeek R1 | Low | Good | Low | Verification, fact-checking, accuracy-critical work |
| Claude Sonnet 4 | Very Low | Moderate | High | Complex reasoning, critical decisions, production systems |
B DSpark Preset Configuration
The DSpark preset in Hermes Agent enables speculative decoding with minimal configuration:
# ~/.hermes/config.yaml
models:
# DSpark preset: Gemini draft + DeepSeek verify
dspark:
primary: gemini-2.0-flash-exp
verifier: deepseek-r1
fallback: claude-sonnet-4-5
# Task routing configuration
routing:
simple_tasks:
model: gemini-2.0-flash-exp
max_tokens: 4000
standard_tasks:
model: dspark # Uses draft+verify
max_tokens: 8000
verification_threshold: 0.85
critical_tasks:
model: claude-sonnet-4-5
max_tokens: 16000
require_human_approval: true
B Hallucination Mitigation Strategy
Hallucinations are false or fabricated information generated by AI models. RAIA's multi-model approach reduces hallucination risk through three mechanisms:
- No verification layer
- Fabricated API endpoints
- Invented file paths
- Made-up data values
- Confident but wrong
Repository Code
The live codebase implementation for this specification sits within the following repository folder:
- Cross-model validation
- Fact verification pass
- Automatic escalation
- Confidence scoring
- Human-in-loop for critical
-
1Cross-Model Consensus
When Gemini and DeepSeek disagree on a fact, Claude is used as a tiebreaker. This three-way validation catches most hallucinations.
-
2Verification Confidence Scores
DeepSeek assigns a confidence score (0-1) to each verification. Scores below 0.85 trigger automatic regeneration or escalation.
-
3Task-Based Routing
Critical tasks (migrations, security, compliance) bypass the draft phase entirely and go straight to Claude, eliminating draft-model hallucination risk.
B Cost Optimization
By routing 80% of tasks through the Gemini+DeepSeek path and reserving Claude for 20% critical tasks, RAIA (Real estate Artificial Intelligence Agent) achieves a 73% cost reduction vs. Claude-only inference while maintaining accuracy.
C Architecture Details
The multi-model inference pipeline is implemented in the Hermes Agent core at ~/.hermes/src/inference/moa.py. The routing logic uses a decision tree based on task metadata:
# Simplified routing logic
def route_request(task_type: str, context: dict) -> ModelConfig:
# Critical tasks go to Claude directly
if task_type in ["migration", "security", "compliance"]:
return ModelConfig(primary="claude-sonnet-4-5")
# Simple tasks use Gemini only
if task_type in ["status", "list", "format"]:
return ModelConfig(primary="gemini-2.0-flash-exp")
# Everything else uses DSpark draft+verify
return ModelConfig(
primary="gemini-2.0-flash-exp",
verifier="deepseek-r1",
fallback="claude-sonnet-4-5"
)
C Configuration Reference
Environment Variables
# Required API keys
export ANTHROPIC_API_KEY="sk-ant-..."
export GOOGLE_API_KEY="AIza..."
export DEEPSEEK_API_KEY="sk-..."
# Optional tuning
export MoA_VERIFICATION_THRESHOLD="0.85"
export MoA_ENABLE_LOGGING="true"
export MoA_FALLBACK_TIMEOUT_MS="5000"
C Monitoring & Metrics
The system tracks key metrics for each inference path:
| Metric | Description | Alert Threshold |
|---|---|---|
verification_pass_rate |
% of drafts that pass DeepSeek verification | < 85% |
escalation_rate |
% of tasks escalated to Claude | > 25% |
avg_latency_ms |
Average end-to-end response time | > 1500ms |
cost_per_request |
Average cost across all paths | > $0.005 |
If the primary or verifier model is unavailable, the system automatically falls back to Claude. Monitor your Claude usage during provider outages to avoid unexpected costs.
You can override the default routing rules per-profile by creating ~/.hermes/profiles/<name>/moa_config.yaml. This allows different routing strategies for different agent personas.
© 2026 EstateAigents.com Ltd. Company No. 07801820. All Rights Reserved.
§ 3.28 Multi-Model Inference: MoA & Speculative Decoding · ← Back to RAIA (Real estate Artificial Intelligence Agent) Documentation
Architecture Details
Hermes Agent architecture follows a profile-based isolation model where each profile has its own configuration, skills, tools, cron jobs, and memory stores. The two-gate system enforces identity verification at the network level, then profile-level authorisation within the application. Delegation routing uses a model-selection strategy (cost_optimized, precision, or speed) to match tasks to the optimal LLM provider.
- Core Component: Hermes Agent orchestration and profile management engine
- Data Flow: User Request → Profile Selection → Gate Verification → Tool Execution → LLM Inference → Response
- Integration Points: LLM providers (OpenRouter, OpenAI, Anthropic), tool registry, memory stores, delegation bus
Configuration Reference
Key configuration parameters for this system:
| Parameter | Type | Default | Description |
|---|---|---|---|
| default_profile | string | default | Active profile for tool execution |
| delegation_model | string | cost_optimized | Model routing strategy for delegation |
| max_concurrent_children | integer | 3 | Max parallel subagent tasks |
Figure 2: Hermes Agent architecture — component interaction and data flow.
Troubleshooting
| Issue | Cause | Resolution |
|---|---|---|
| Profile not found | Profile name misconfigured or missing directory | Verify profile exists in ~/.hermes/profiles/ |
| Gate guard blocks access | Hostname not in allowed list | Add hostname to gate guard whitelist |
This component is part of the RAIA (Real estate Artificial Intelligence Agent) platform mono-repo. Implementation details, API contracts, and integration tests are available in the repository.