Shoonya: Zero-Socket In-Process Small Language Models for Graph Databases with Schema-Epoch KV Caching, Live Catalog Logit Masking, and Verifier-Advantage Distillation
Organizations: VaidhyaMegha Private Limited, India
Abstract
Coupling a property-graph database to an external language-model server imposes a three-part socket tax: serialization overhead dwarfing microsecond graph reads, repeated prefill of verbose schemas, and blind decoding divorced from the live catalog and multi-version concurrency control (MVCC) engine. We present Shoonya, from-scratch commercially clean (0.0% non-commercial or share-alike data) tri-modal (Python, Rust, OpenCypher) small language models (16.8M to 1.07B parameters) co-designed with shoonya-infer, a zero-dependency pure-Rust runtime embedded inside the samyama-graph-enterprise address space. Direct GraphStore references unlock three database-native primitives: (1) an epoch-invalidated SchemaPrefixCache over a copy-on-write PagedKvArena accelerating warm CPU time-to-first-token by 4.91x--13.68x with O(1) DDL invalidation; (2) a 36 us columnar catalog and source-span logit mask enforcing valid ontology identifiers and verbatim spans; and (3) a sub-65 us read-only MVCC gate serving Tier-0 queries inside 389.8 MiB INT8 RSS (59.8--67.9 tok/s) with 0.0% hallucination leak. Rank-factorized tied embeddings (-74.5% vocabulary weights), atomic indentation tokens (0/421 indentation errors), 4:1 grouped-query attention with 2:1 cross-layer KV sharing (-93.75% INT8 KV memory), Warmup-Stable-Decay training, KnOTS SVD merging, Step-GRPO, and Rust Jacobi SVD governance keep 100% of layers heavy-tailed (). Finally, we synthesize nine lessons across v0.1--v1.0, resolving a Reverse-Token-Density Distillation Trap via teacher scaling and zero-VRAM Verifier-Advantage-Gated Knowledge Distillation (AdvKD), recovering +13.61 MBPP points (33.07%) while reaching 100% validity on enrichment, grounded extraction, and tool planning.
Figures & tables
| Architecture & LR Arm | Total / Active | Train Speed | Val CE | Val PPL | Prefill | KV RAM |
|---|---|---|---|---|---|---|
| ( steps, clean tok) | Params ( M ) | ( tok/s ) | (nats) | ( ) | ( tok/s ) | ( BF16 MiB ) |
| Dense-GQA-Cosine | ||||||
| Dense-GQA-WSD | ||||||
| Dense-GQA-XKV2-WSD (Chosen) | ||||||
| SparseMoE-8x2-WSD | ||||||
| ProgSparseAttn-WSD |
| Model ( Std / TTC) | Params | Pretrain | Stage-A | MBPP-San | HumanEval | Rustc-64 | Cypher-100 | Ideal SVD |
| (Same-Host RTX 4050 BF16 ) | ( M ) | Tokens | ( ) | ( ) | ( ) | ( ) | ( ) | ( ) |
| External Sub- Baselines (Greedy ) | ||||||||
| CodeGen-350M-mono ( Nijkamp et al., 2023 ) | ( ) | |||||||
| SmolLM2-360M-Inst ( Allal et al., 2025 ) | ( ) | |||||||
| Qwen2.5-Coder-0.5B ( Hui et al., 2024 ) | ( ) | |||||||
| Qwen2.5-Coder-0.5B-Inst ( Hui et al., 2024 ) | ( ) | |||||||
| Checkpoint | Precision | RSS | Warm TTFT | Speed | MVCC | Arm1 / Arm2 | Tier-1 | Arm4 | Plan / | Enrich |
|---|---|---|---|---|---|---|---|---|---|---|
| ( samyama v1.15.0 ) | ( PagedKV ) | ( MiB ) | (Speedup) | ( tok/s ) | ( ) | Syntax | Solved | Leak | Extr | (Concept/Abs) |
| 350M v0.9.2 ( M1 ) | INT8 | ( ) | ||||||||
| 350M v0.9.3 ( M2 ) | INT8 | ( ) | ||||||||
| 350M v0.9.3 ( M2 ) | BF16 | ( ) | — | — | ||||||
| 350M v0.9.4 (Trap) | INT8 | ( ) | ||||||||
| 350M v0.9.5-AdvKD | INT8 | ( ) |
| samyama-graph-enterprise Surface | Best Local Accuracy ( M4 / M5.A ) | Leak | Deployment Mode |
|---|---|---|---|
| 4. Ontology Enrichment & Abstention | concept / abstain | Standalone Local | |
| 3. ExtractionAgent (Catalog+Span FSM) | JSON / grounded | Standalone Local | |
| 2. AgentPlanner ( ToolPlan JSON) | JSON ( 1.3B ); live exec ( M5.A ) | Hybrid Tier-0 | |
| 1a. NLQPipeline Tier-1 (Single / 1-Hop) | solved ( 350M ), precision | Hybrid Tier-0 | |
| 1b. NLQPipeline Tier-2/3 (Multi-Hop) | syntax, greedy exact ( M4 ) | Escalate to Frontier |
Small Language Models
Small language models are compact neural language systems designed to deliver useful text and reasoning capabilities with limited compute, memory, and energy.
See all 308 papers