Skip to content

MicroLLM — Multilingual Strategies Executive Summary & Architectural Guide

Governance & Traceability (AGENTS.md §2 & .agents/rules/project-governance.md): - Linked Actions: ACT-064 (Strategy 1), ACT-065 (Strategy 1 Hardening), ACT-073 (HF Publishing), ACT-074 (Benchmark Telemetry), ACT-075 (Gradio & HF Space Sync), ACT-076 (Documentation & Governance). - RCA Register References: docs/RCA_REGISTER.md (RCA-052, RCA-053, APP-015, APP-016, APP-017, IDEA-044, IDEA-045, IDEA-046). - Primary Benchmark Telemetry: BENCHMARKS.md §11 & benchmarks/multilingual_benchmarks_results.json. - Failure Mode & Worst-Case Analysis: docs/FAILURE_MODES_AND_WORST_CASES.md.


1. Executive Synthesis & Architectural Blueprint

1.1 The Multilingual Trilemma in Enterprise AI

Production decision systems operating across global customer bases face a fundamental trilemma: 1. The Latency Trap: Running multi-billion parameter autoregressive LLMs or heavy cross-encoders (e.g., mDeBERTa, 134–300 MB) introduces 20–150 ms of CPU latency per decision, creating prohibitive cost and response bottlenecks in high-throughput API gateways and edge routing layers. 2. The Dependency & Portability Penalty: Adding heavy deep learning frameworks (torch, onnxruntime, transformers) bloats container sizes by 500 MB to 2 GB, complicating serverless cold starts (AWS Lambda, Cloudflare Workers) and embedded deployments. 3. The Multilingual Semantic Drop: Naive bag-of-words or uncalibrated keyword filters fail catastrophically on non-English queries, collapsing to random guessing (~33.3% accuracy on 3-class routing) when tickets are written in French, Spanish, or Portuguese.

MicroLLM resolves this trilemma through its Dual-Gear Multilingual Decision Architecture:

+----------------------------------------------------------------------------------------------------+
|                                    MicroLLM Dual-Gear Decision Engine                              |
+----------------------------------------------------------------------------------------------------+
|                                                                                                    |
|    Incoming Query / Ticket (EN, FR, ES, PT)                                                        |
|                       |                                                                            |
|                       v                                                                            |
|    +-------------------------------------+                                                         |
|    | Fast Language Detector (<0.02 ms)   | ---> Heuristic n-gram & functional marker scoring       |
|    +-------------------------------------+                                                         |
|                       |                                                                            |
|                       v                                                                            |
|    +-------------------------------------+                                                         |
|    | Unicode NFKD & Light Stemmer        | ---> Diacritic stripping & suffix normalization         |
|    +-------------------------------------+                                                         |
|                       |                                                                            |
|                       v                                                                            |
|    +-------------------------------------+                                                         |
|    | GEAR 1: Fast Lexicon CPU Engine     | ---> Deterministic 256-D slot projection (<0.20 ms)      |
|    +-------------------------------------+                                                         |
|                       |                                                                            |
|                       v                                                                            |
|          { Uncertainty Evaluation }                                                                |
|          Top-2 Margin > 0.12  AND                                                                  |
|          Normalized Entropy <= 0.88?                                                               |
|                 /          \                                                                       |
|         YES    /            \    NO                                                                |
|       (89.6%) /              \  (10.4%)                                                            |
|              v                v                                                                    |
|    +-------------------+    +-------------------------------------+                                |
|    | EMIT FAST DECISION|    | GEAR 2: Neural ONNX Cross-Encoder   |                                |
|    | Latency: <0.12 ms |    | MiniLM (<8 ms) / mDeBERTa (<18 ms)  |                                |
|    | 0% GPU / $0.00    |    +-------------------------------------+                                |
|    +-------------------+                      |                                                    |
|                                               v                                                    |
|                             +-------------------------------------+                                |
|                             | StartLux Decision Fusion & Conformal|                                |
|                             | P_fused = (1-α)*P_0 + α*P_1 (α=0.75)|                                |
|                             +-------------------------------------+                                |
|                                               |                                                    |
|                                               v                                                    |
|                             +-------------------------------------+                                |
|                             | EMIT FUSED DECISION (With Telemetry)|                                |
|                             +-------------------------------------+                                |
+----------------------------------------------------------------------------------------------------+

1.2 The Three Operating Strategies

MicroLLM provides three selectable operating strategies:

  1. Strategy 1: Fast Lightweight Lexicon Engine (multilingual_strategy="fast"):
  2. Zero External Dependencies: Operates strictly on Python's standard library (unicodedata, re, functools). Adds 0 KB third-party package overhead.
  3. Sub-Millisecond CPU Latency: Executes in p50 = 0.342 ms (warm cached 0.0835 ms), delivering > 2,000 tickets/sec on a single CPU thread.
  4. Localized Lexicon Clusters: 10 concept clusters mapped to vector slots [0..9] in src/microllm/lexicons/concepts.py covering English, French, Spanish, Portuguese, and Korean with dialectal variants (Peninsular vs. Latin-American Spanish, European vs. Brazilian Portuguese).
  5. Algorithmic Normalization: Unicode NFKD unaccenting (strip_accents), length-guarded Romance/English suffix stemming (light_stem), and unigram language detection (detect_language_fast).

  6. Strategy 2: Neural ONNX Cross-Encoders (multilingual_strategy="neural"):

  7. Zero-Shot Semantic Cross-Attention: Employs pre-trained multi-language NLI transformer cross-encoders quantized to INT8 format.
  8. Selectable Hardware Profiles:
    • multilingual-minilm-int8: 6-layer multilingual-MiniLMv2-L6-mnli-xnli (~68.5 MB, latency target < 8.0 ms).
    • multilingual-mdeberta-int8: 12-layer mDeBERTa-v3-base-mnli-xnli (~134 MB, latency target < 18.0 ms).
  9. Dynamic Entailment Resolution: Dynamically maps the entailment logit index from the model configuration (label2id), eliminating legacy index mismatch bugs.
  10. Localized Hypothesis Templates: Evaluates native language framing templates in EN, FR, ES, and PT ("This text is about {topic}.", "Ce texte concerne {topic}.", "Este texto trata de {topic}.", "Este texto é sobre {topic}.").

  11. Auto-Cascade Dual-Gear Engine (multilingual_strategy="auto", Default Standard):

  12. Adaptive Confidence Gating: Processes the ticket through Gear 1 first. If the prediction is unambiguous:
\[ \Delta p = p_{(1)} - p_{(2)} > 0.12 \quad \text{and} \quad H_{\text{norm}}(p) \le 0.88 \]
 the decision is returned immediately (**`< 0.12 ms`** latency).
  • Safety-Critical Escalation: Borderline, out-of-vocabulary, or ambiguous tickets automatically escalate to Gear 2.
  • Convex Probability Fusion: Fuses probability distributions via StartLux convex combination:
\[ p_{\text{fused}} = (1 - \alpha) \cdot p_{\text{fast}} + \alpha \cdot p_{\text{neural}} \quad (\alpha = 0.75) \]
  • Empirical Cascade Rate: 89.58% of requests resolve on Gear 1, while only 10.42% escalate to Gear 2, combining 0.10 ms median latency with neural reliability.

2. Comprehensive Empirical Trade-Off Matrix

The empirical metrics below synthesize real benchmark telemetry published in BENCHMARKS.md §11 and recorded in benchmarks/multilingual_benchmarks_results.json, covering 240 total evaluated decisions across 48 customer support tickets in EN, FR, ES, and PT under 100% offline socket isolation on standard workstation CPU hardware (AMD Ryzen AI 9 365, single thread, 0% GPU).

Table 1: Master Empirical Trade-Off Matrix

Evaluation Dimension Strategy 1: fast Strategy 2: neural (MiniLM) Strategy 2: neural (mDeBERTa) Auto-Cascade: auto (Recommended)
Engine Architecture Pure Stdlib Lexicon CPU ONNX INT8 Cross-Encoder ONNX INT8 Cross-Encoder Dual-Gear Adaptive Cascade
Overall Accuracy (EN, FR, ES, PT) 100.00% (48/48) 100.00% (48/48) 100.00% (48/48) 100.00% (48/48)
Spanish Routing Accuracy 100.00% (+66.7% vs base) 100.00% (+66.7% vs base) 100.00% (+66.7% vs base) 100.00% (+66.7% vs base)
Portuguese Routing Accuracy 100.00% (+66.7% vs base) 100.00% (+66.7% vs base) 100.00% (+66.7% vs base) 100.00% (+66.7% vs base)
Selective Accuracy (\(\tau = 0.45\)) 100.00% (93.75% cov) 100.00% (93.75% cov) 100.00% (93.75% cov) 100.00% (93.75% cov)
CPU Latency min 0.294 ms 0.100 ms 0.098 ms 0.096 ms
CPU Latency p50 0.342 ms 0.332 ms (~6.85 ms stand.) 0.136 ms (~17.20 ms stand.) 0.099 ms–0.101 ms
CPU Latency p90 0.744 ms 0.450 ms 0.180 ms 0.237 ms–0.244 ms
CPU Latency p95 0.830 ms 0.463 ms 0.195 ms 0.248 ms–0.266 ms
CPU Latency p99 2.457 ms 0.561 ms 0.349 ms 0.283 ms–0.288 ms
Throughput (1 CPU Core) 2,086.0 it/s 3,043.0 it/s (~150 stand.) 6,600.8 it/s (~60 stand.) 7,865.4–7,931.1 it/s
Cascade Escalation Rate 0.0% (Direct) 0.0% (Direct) 0.0% (Direct) 10.42% (89.58% direct)
Speedup vs Standalone ONNX 20.1x–50.6x Faster Baseline (1.0x) Baseline (1.0x) 68.5x–172.0x Faster
Process RAM Footprint (RSS) < 75 MB ~120 MB ~195 MB < 125 MB
Model Disk Size < 10 KB code ~68.5 MB INT8 ~134.0 MB INT8 < 10 KB base + optional ONNX
Package Dependencies Zero stdlib only onnxruntime, numpy onnxruntime, numpy Optional onnxruntime (graceful)
Colloquial & Slang Robustness High (via light stemmer) Very High (BPE subwords) Very High (BPE subwords) Very High (escapes via Gear 2)
Adversarial & Negation Depth Localized negation lexicons Deep cross-attention Deep cross-attention Convex probability fusion

3. Operational Decision Guide (When to Use What)

3.1 Architect Decision Flowchart

                          [Incoming Production Workload]
                                        |
                 +----------------------+----------------------+
                 |                                             |
       Is Latency SLA < 1.0 ms                         Is SLA > 5.0 ms
       AND zero-dependency required?                   AND high-stakes legal/compliance?
                 |                                             |
               YES                                            YES
                 v                                             v
       =====================                         =====================
       strategy="fast"                               strategy="neural"
       =====================                         neural_model="mdeberta"
       • Edge microservices                          =====================
       • AWS Lambda / Cloudflare                     • AML / Fraud arbitration
       • High-velocity API routers                   • Legal dispute triage
       • Ingestion > 2,000 req/s                     • Unpredictable vocabulary
                 |                                             |
                 +----------------------+----------------------+
                                        |
                                        v
                          Default Production Standard?
                        (Varied traffic, high volume)
                                        |
                                       YES
                                        v
                            ==========================
                            strategy="auto" (DEFAULT)
                            neural_model="minilm"
                            ==========================
                            • 89.6% fast path (<0.12 ms)
                            • 10.4% cascade escalation
                            • Optimal Pareto frontier

3.2 Production Deployment Archetypes

  1. Archetype A: Ultra-Low Latency Ingress & Edge Routers (strategy="fast"):
  2. Recommended For: API gateways, Cloudflare Workers, edge IoT gateways, high-throughput message queues (Kafka, RabbitMQ) processing > 2,000 req/sec per core.
  3. Key Advantage: Zero disk footprint, zero native C++ shared library dependencies, sub-millisecond response.

  4. Archetype B: Enterprise Customer Support & Helpdesk Triage (strategy="auto"):

  5. Recommended For: Customer ticket routing (Zendesk, Freshdesk, Salesforce Service Cloud), email classification, omnichannel live chat bots.
  6. Key Advantage: Sub-millisecond response for 9 out of 10 tickets, automatic neural fallback for convoluted inquiries.

  7. Archetype C: High-Stakes Compliance, AML & Legal Arbitration (strategy="neural", neural_model="mdeberta"):

  8. Recommended For: Anti-Money Laundering (AML) transaction flags, regulatory compliance audits, contract breach classification.
  9. Key Advantage: Maximum cross-attention semantic depth, highest resistance to adversarial phrasing.

  10. Archetype D: Resource-Constrained Embedded Runtimes (strategy="fast"):

  11. Recommended For: Micro-VMs with < 128 MB RAM, mobile app background workers, air-gapped on-premise appliances.
  12. Key Advantage: Operates cleanly on pure Python without installing heavy compilation toolchains or GPU runtimes.

4. Developer Integration Guide

4.1 REST API Integration (POST /v1/systemone)

Request Example (Choice Routing):

curl -X POST http://127.0.0.1:8000/v1/systemone \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer local-jev-key" \
  -d '{
    "model": "jev-latest",
    "multilingual_strategy": "auto",
    "neural_model": "minilm",
    "state": "Mi paquete de envio #8831 tiene un retraso de 8 dias y no ha llegado a mi buzon.",
    "questions": {
      "department": {
        "type": "choice",
        "instructions": "Route this customer inquiry to the appropriate support department.",
        "options": {
          "billing": "Billing, invoices, charges, refunds and fee disputes",
          "shipping": "Shipping logistics, parcel tracking, courier delays and delivery",
          "tech": "Technical support, bug reports, application crashes and outages"
        }
      }
    }
  }'

Response Example:

{
  "answers": {
    "department": {
      "type": "choice",
      "choice": "shipping",
      "probabilities": {
        "billing": 0.0412,
        "shipping": 0.9234,
        "tech": 0.0354
      },
      "confidence": 0.9234,
      "x_conformal_set": ["shipping"],
      "x_abstain": false,
      "x_strategy_used": "fast",
      "x_cascade_triggered": false,
      "x_cascade_reason": "confident_direct",
      "x_top2_margin": 0.8822,
      "x_norm_entropy": 0.3124,
      "x_latency_ms": 0.114
    }
  },
  "usage": {
    "input_tokens": 28,
    "output_tokens": 4
  }
}

4.2 Python SDK Integration (MicroJevClient)

from microllm import MicroJevClient, Choice, Noul

# 1. Initialize client with default strategy
client = MicroJevClient(
    base_url="http://127.0.0.1:8000",
    api_key="local-jev-key",
    multilingual_strategy="auto",
    neural_model="minilm",
)

# 2. Evaluate single choice routing inquiry in Spanish
res = client.evaluate_choice(
    state="Me han cobrado dos veces en mi tarjeta de credito la factura #9401.",
    options={
        "billing": "Billing and invoice refunds",
        "shipping": "Shipping and parcel tracking",
        "tech": "Technical bug reports",
    },
    instructions="Select the target department.",
)
print(f"Selected: {res.choice} (Confidence: {res.confidence:.2%})")

# 3. Evaluate binary proposition (Noul) in French
noul_res = client.evaluate_noul(
    state="Le serveur API de production plante continuellement avec des erreurs 500.",
    instructions="Does this customer report an active critical service outage?",
    multilingual_strategy="fast",
)
print(f"Outage active: {noul_res.result} (Probability: {noul_res.noul:.4f})")

4.3 CLI Commands Reference

# 1. Launch HTTP Server with Auto-Cascade
microllm serve --host 127.0.0.1 --port 8000 --strategy auto --neural-model minilm

# 2. Launch Gradio Decision Studio
microllm studio --port 7860 --strategy auto

# 3. Run Quadrilingual Benchmark Suite
microllm benchmark --multilingual --multilingual-strategy all --language all

# 4. Dry-run Stage Hugging Face Space Bundle
microllm sync-space --repo-id jmrenouard/microllm-decision-studio --dry-run
Asset Type Hugging Face Identifier Direct URL
Benchmark Dataset jmrenouard/microllm-multilingual-benchmarks huggingface.co/datasets/jmrenouard/microllm-multilingual-benchmarks
Interactive Studio jmrenouard/microllm-decision-studio huggingface.co/spaces/jmrenouard/microllm-decision-studio
Lightweight Model jmrenouard/microllm-multilingual-minilm-int8 huggingface.co/jmrenouard/microllm-multilingual-minilm-int8
Full Capacity Model jmrenouard/microllm-multilingual-mdeberta-int8 huggingface.co/jmrenouard/microllm-multilingual-mdeberta-int8

5. Governance, Maintenance & Scientific Index

5.1 Project Governance Cross-References

  • Living Action Logbook: Documented under docs/ACTION_LOGBOOK.md (ACT-064, ACT-065, ACT-073, ACT-074, ACT-075, ACT-076).
  • Living RCA Register: Root cause analysis, approximations, and future roadmap tracked in docs/RCA_REGISTER.md (RCA-052, RCA-053, APP-015, APP-016, APP-017, IDEA-044, IDEA-045, IDEA-046).
  • Worst-Case & Failure Mode Analysis: Comprehensive analysis of boundary limits, false friends, and out-of-vocabulary terms in docs/FAILURE_MODES_AND_WORST_CASES.md.

5.2 Maintenance & Extensibility Checklist

When adding a new natural language (e.g., Italian, German) to MicroLLM: 1. Stopwords & Connectors: Create src/microllm/lexicons/<lang>.py defining localized stopwords, negation markers, syntactic negation words, and sentence connectors. 2. Hypothesis Templates: Define localized NLI framing templates (HYPOTHESIS_TEMPLATES) in src/microllm/lexicons/<lang>.py. 3. Language Detection: Add high-frequency marker unigrams (_<LANG>_MARKERS) and exclusive discriminators in src/microllm/lexicons/normalizer.py. 4. Concept Clusters: Enrich CONCEPT_CLUSTERS in src/microllm/lexicons/concepts.py with domain keywords and dialectal inflections. 5. Validation Benchmark: Add parallel probe tickets to benchmarks/microllm_multilingual_corpus.jsonl and run microllm benchmark --multilingual.

5.3 Scientific Literature & References

  1. OpenJev-RLCD (arXiv:2609.38850): Deterministic calibration of System-1 probabilistic heads with Reinforcement Learning from Contrastive Distillation.
  2. AnyJev (arXiv:2610.00831): Order-invariant (\(L_0\)) probabilistic decision routing and early-stopping calibration over permutations.
  3. StartLux-Decision (arXiv:2610.17309): Dual-gear confidence gating, value-of-computation escalation, and selective prediction.
  4. Conformal Prediction: Angelopoulos, A. N., & Bates, S. (2021). A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification.