Architecture portfolio

ADR 010

AI search with an open model on our own server, chosen by measurement

Accepted5 December 2026Scope: tools site (44 tools, 5 exam guides)

Context

The tools site's search only matched exact words. People type what they want to do: "make my photo 50 KB", "pdf jodna hai", or "is owning a car cheaper than uber". Many type in Hinglish or Hindi. On a test set of 81 such searches, the keyword search put the right tool first only 10% of the time.

Constraints: the site promises privacy, there's no budget per request, the server has 2 vCPUs with no GPU, and search must still work if the AI part fails.

Options considered

OptionForAgainst
Hosted LLM API (chat model picks the tool)Very capableCost and an API key for every search; visitor text goes to a third party; 0.5–2 s latency; non-deterministic
Embedding model in the browserNothing leaves the deviceEvery visitor downloads 100 MB to 1 GB of model on a phone; too slow on budget devices
More keywords and synonymsSimpleNever ends; can't handle Hinglish or new phrasings
Open embedding model on our serverNo key, no per-request cost, no third party; fast and deterministicAbout 0.8 GB of RAM; we run and update it

Choosing the model: measured, not guessed

I wrote 81 realistic searches (English, Hinglish and Hindi script), each with the correct tool, plus 10 off-topic searches the site has no answer for. Every candidate ran on 1 vCPU:

ModelRight tool firstIn top 3Per searchRAM
Keyword search (before)10%10%instantnone
multilingual MiniLM-L1278%90%8 ms~0.3 GB
bge-small-en86%94%8 ms0.34 GB
all-MiniLM-L688%90%4 ms0.30 GB
bge-base-en89%94%26 ms0.87 GB
Qwen3-Embedding 0.6B (quantised)89%91%702 ms1.9 GB
multilingual-e5-large94%98%95 ms2.2 GB model
EmbeddingGemma 300M, with its task prompts96%100%~40 ms~0.8 GB

Two findings mattered more than model size:

Decision

  1. Build time: the site emits a list of every page. A separate container embeds them once with EmbeddingGemma (ONNX, via fastembed). The model is baked into the image.
  2. Quality gate: the same build runs the test set (now 86 searches) and fails the deploy if top-1 accuracy drops below 93%, top-3 below 97%, or the off-topic threshold stops separating. Adding a tool means adding test searches for it.
  3. Run time: nginx proxies /api/search to the service with per-visitor rate limiting. Results are cached. At most two searches run at once, under a 1-CPU, 1.4 GB limit, so search can't starve the other 17 services.
  4. Privacy: the search container sits on an internal network with no internet access. Runtime telemetry is off, access logging is off for search, and the service never logs queries. The privacy policy says exactly this.
  5. Graceful failure: the page filters by keyword instantly, and AI results are added when they arrive. If the service is down, the site still works.

Consequences

Revisit when

At enterprise scale

This is the retrieval half of every enterprise RAG system, with the controls already in place:

Most enterprise search and knowledge use cases don't need a large language model for the "find it" step. A small, self-hosted embedding model is cheaper, faster, private and easier to govern.