Ai classify

AI Classify — Classification / NLU

  • *rea:*Intelligence
  • *ath:*services/ai/classify
  • *ind:*Classification / NLU service (intent, sentiment, topic, language, multi-label)
  • *tatus:*v0.0.1 — sector bootstrapping (20260509)

Role in the stack

classify provides the right tool for a small job. Classification is a classical ML primitive that LLMs handle badly and expensively — routing a chat message to the right product is not a billionparameter problem; a 5MB fastText model nails it in 3ms with 95%+ accuracy. Today every consumer that needs intentsentimenttopic calls gateway/ with a giant LLM and pays full token cost. This sector hosts the smallmodel path (fastText, BGE, BERT-tiny) with LLM fallback only for novel labels and tail cases.

It is the Koder analog of Cohere Classify, scoped generically. *istinct from guard/*— guard handles safety/policy classification, classify handles everything else.

Boundary vs neighbors

  • services/ai/guard is also a classifier but scoped to safety/policy; sibling, not duplicate.
  • services/ai/runtime serves the small classification models.
  • services/ai/gateway provides the LLM fallback path for zero-shot.
  • services/ai/embed provides similarity backbone for label-free flows.
  • services/ai/training will own custom-classifier training in future (out of v1 scope).
  • services/ai/chat-adapter is the largest single intent consumer.

Features (v1 target)

  • Language detection (fastText lid.176)
  • Sentiment (BGE-class encoder + linear head, multilingual)
  • Multilabel classification with autorouting (smallmodel | embedsimilarity | LLM)
  • Zeroshot via NLI (BARTMNLI or LLM)
  • Intent recognition with pertenant taxonomies (kdbdoc, versioned)
  • Fewshot when ≥5 examples per intent; zeroshot otherwise
  • Batch endpoint with true model batching for high-throughput ingest
  • Confusion-matrix endpoint per taxonomy for quality tracking
  • Feedback loop (correction → cache + routing improvement)

Primary couplings

Producer Relationship
services/ai/runtime Serves fastText / BGE / BERT-tiny models
services/ai/gateway LLM fallback for zero-shot
services/ai/embed Similarity backbone
Consumer Relationship
services/ai/chat-adapter Intent recognition for chat routing
services/ai/agents Tool selection helper
services/ai/rag, services/ai/recsys Topic + language tags during ingest
services/ai/dataset Auto-label of bootstrap datasets
Product backends Per-tenant taxonomies

RFC and bootstrap

  • RFC: classify-RFC-001-foundations.kmd — *ccepted*20260509
  • Bootstrap ticket: services/ai/backlog/done/133-classify-bootstrap.md
  • Implementation tickets: services/ai/classify/backlog/pending/{001..005}

Selfhostedfirst analysis (5 gates)

Gate Status Notes
G1 Feature parity pending fastTextBGEBART-MNLI cover Cohere Classify surface
G2 Performance pending Targets: 20ms language, 80ms sentiment, 100300ms multilabel, 1.5s LLM zero-shot (p95)
G3 Stability pending Pre-MVP
G4 Capability pending Custom training out of v1 (deferred to training/)
G5 Critical-path readiness pending Unblocks chat routing + ingest tagging at ~100x cost reduction

Source: ../home/koder/dev/koder/meta/docs/stack/modules/ai-classify.md