HSI: Hierarchical Sparse Intelligence
A proof-of-concept multi-agent pipeline where 22 specialist classifiers pre-process every query before it reaches an LLM, and what happened when I actually built and benchmarked it.
The idea
Most LLM pipelines send raw text straight into one large model. HSI inverts that: a swarm of small, fast, domain-specialist classifiers runs first, each trained on a specific aspect of language or reasoning, and their outputs are assembled into a typed, structured buffer I call the Thalamus. The LLM (the "PFC") reads only the Thalamus, never the raw query.
The name borrows from how the human brain actually works: the thalamus relays pre-processed sensory information to the prefrontal cortex rather than passing along raw sense data. The bet here is the same: offload perception and classification to cheap specialist models, and reserve the expensive model for reasoning over a compressed, structured signal instead of noisy raw text.
What I built
22 fine-tuned DeBERTa-v3-small classifiers (~86M params each), organised into layers. Layer 1 handles text-level perception: format, language, encoding quality, routing. Layer 2 splits into a language swarm (syntax, intent, sentiment, entities) and a math swarm (arithmetic, algebra, statistics, logic). Layer 3 adds geometry, causal inference, constraint satisfaction, coreference, and discourse structure. Every agent writes into a typed slot in the Thalamus. A query never reaches the LLM without first passing through this swarm. The LLM itself is any Ollama-compatible model.
Sparse activation is the point: a simple factual question only activates the language agents, a math problem only activates the math agents, and both fire together for a mixed query. Each agent is independent, so any specialist can be swapped or retrained without touching the rest of the system.
Benchmark results
Tested with qwen2.5:3b-instruct on Apple Silicon (MPS). All five test queries produced correct, relevant responses:
| category | query | latency |
|---|---|---|
| Language | Metaphor vs. simile? | 20.6s |
| Math | 347 × 28? | 11.8s |
| Mixed | Why is 120mi/2hr = 60mph? | 11.4s |
| Code | Explain this fib() function | 19.3s |
| Social | Help me understand something | 36.3s |
Average latency across the suite: 19.9 seconds, dominated almost entirely by the Ollama LLM inference step on CPU/MPS. A GPU would bring this down roughly 3–5x.
Where it falls short
A few of the specialists, format_detector, encoding_quality, and text_input_router, were trained on synthetic feature strings rather than raw text, so their predictions on real input are noisy. The routing layer currently compensates with a rule-based override rather than a clean learned signal. And the math specialists classify the typeof operation (arithmetic, algebra, and so on) but don't compute a result themselves. The LLM still does the actual arithmetic. The sparse-perception layer is real and working; full numeric reasoning inside the swarm isn't there yet.
What this is and isn't
This is a proof-of-concept, not a finished system. It was built as a closed research project to test one specific idea, that structured, pre-processed perception can replace raw text as an LLM's input, and the architecture is the contribution here, not the specific model weights. The benchmarks above are real numbers from a real run, and the limitations above are the honest state of it, not a polished summary.
The MVP was scoped down from a larger internal architecture plan, a "v1.0" covering eight cognitive domains and roughly 71 models, including vision, audio, memory, and an agentic tool-use layer. None of that was built. What's here is the first slice of it: text input, language, and math: 22 models, tested honestly, nothing more claimed.
Full architecture, training data, and the local runner are on GitHub: reverendish/hsi-mvp.