AI services layer

Right-sized models, grounded answers, bounded agents

The AI-services layer is where business value appears — and where most design mistakes happen. Choose the smallest model that does the job, ground it in permitted documents, and give agents only the power the user already has.

Choose the smallest model that does the job

LLM or SLM? Route by task

LLM — Large Language Model

Tens to hundreds of billions of parameters

  • Open-ended reasoning, long documents, multi-step answers
  • Example: 70B-class model ≈ 140 GB at 16-bit → two 141 GB-class GPUs
  • ≈ 70 GB at 8-bit (FP8) → one 141 GB-class GPU
  • Higher latency and cost per answer
SLM — Small Language Model

About 1–8 billion parameters

  • Classification, extraction, routing, short summaries
  • Example: 8B-class model ≈ 16 GB at 16-bit → one 96 GB-class GPU with room for many users
  • Smaller models fit a hardware partition of one GPU
  • Fast and cheap; narrower knowledge

How to choose

  1. Task fit — reasoning, or a narrow task?
  2. Quality on YOUR test questions — not only public leaderboards.
  3. Fits GPU memory with headroom — weights + KV cache + overhead.
  4. Latency and volume targets — p95 time to first token at peak.
  5. Licence allows commercial use — “open-weight” is not always “free for anything”.
  6. Runtime support — your serving runtime and GPU support the model and its quantised format.
Also needed for RAGAn embedding model (text → vectors) and usually a reranker — small models that share GPUs with the SLM.
Memory figures are weights onlyParameters × bytes. Add KV cache and runtime overhead, then load-test — formulas give memory, not speed. Try the GPU calculator.
An open-book exam for the model

The RAG pipeline — how the model reads our documents

A pre-trained model does not know your policies. RAG retrieves the relevant, permitted passages at question time and asks the model to answer only from them, with citations.

Permissions

Capture ACLs at ingestion; filter at retrieval — or restricted text leaks into answers. The most common serious RAG bug.

Quality

Mostly decided by chunking, retrieval and reranking — not the LLM. Evaluate retrieval and generation separately.

Untrusted content

Retrieved text is data, not instructions. Guard against prompt injection hidden in documents.

Try the RAG simulator →
Agent = LLM + tools + loop

An LLM that plans, uses tools and checks its work

A chatbot answers once. An agent repeats plan → act → observe until the goal is met or a limit stops it.

Worked example: a 02:10 GPU alert

  1. Read the hardware error alert on a GPU node.
  2. Find the runbook through RAG search.
  3. Ask a human to approve cordoning the node.
  4. Confirm the pods moved to healthy nodes.
  5. Open a hardware ticket with a summary.

🔑 Least privilege

Tools are scoped to the requesting user — never a super-user credential. Reading can be automatic; writing needs confirmation.

🧭 Bounded autonomy

Step and cost limits, guardrails, and human approval for risky actions. Open tool protocols standardise how agents reach tools; the security rules stay the same.

Illustrative example · fictional bank

A supervisor and a team of specialists

Northwind Bank (fictional) must review 600 loan files overnight. A supervisor agent plans and delegates; only exceptions reach a human credit officer.

Common patterns

Supervisor and workers (shown), a sequential pipeline, or a critic agent that reviews another’s output.

Why split the work?

Focused prompts, the right-sized model per task, parallel processing and easier testing of each step.

Watch out

Tokens, latency and failure points multiply. Give each agent its own identity, limits and evaluation.

Agents multiply demandOne agent task can make 5–20 model calls (a planning assumption — measure your own). Count calls, not just users, when you plan capacity.
Upgrade without breaking apps

Aliases, registry and canaries

CandidateDownloaded from an approved source, format-checked (prefer safetensors), scanned.
EvaluatedQuality, safety, formatting and latency on your own evaluation set.
ApprovedLicence and risk sign-off recorded in the registry.
Canary5–10% of traffic for a week; compare thumbs-up and error rates.
ProductionSwitch the stable alias (e.g. chat-model) at the gateway.
RetiredPrevious version kept for rollback, then removed after a deprecation window.
The core trade-offBigger batches → higher total throughput but slightly slower per-user tokens and a larger KV cache. Set a maximum concurrency per replica that keeps p95 latency within the SLO, then add replicas.