ProductMarch 6, 2026·8 min read

Automatic Language Detection in AI Assistants

Citai Team

March 6, 2026 · 8 min read

The problem: customers who speak different languages

If you sell in Latin America, Spain, Brazil, and the US, your customers speak Spanish, Portuguese, and English. The naive solution — three different chatbots, three duplicate knowledge bases — is expensive and hard to maintain.

The right solution: one assistant that detects language and responds automatically.

Automatic language detection: 3 messages in different languages go through the detector and get responses in their language

How detection works

Citai uses a cascade priority system to determine the response language:

Priority Source Example
1 (highest) Manual override per KB Always force Spanish
2 Heuristic text detection “how do I return…” → EN
3 Browser language (widget) Accept-Language: pt-BR
4 (fallback) Configurable default Spanish

Heuristic detection: fast and accurate

Instead of using an ML model (which adds latency and cost), Citai uses expanded frequent word lists per language. Words like “the”, “and”, “how” identify English; “como”, “para”, “puede” identify Spanish; “como”, “para”, “pode” identify Portuguese.

Why heuristics instead of an ML model? A language detection model adds ~50ms latency and requires extra dependencies. Frequent word lists are instant (0ms), have >98% accuracy for ES/EN/PT/DE/FR/IT, and need no GPU.

System prompt injection

Once detected, Citai injects the language into the LLM system prompt, ensuring the entire response is in the correct language.

Multilingual embeddings: the semantic magic

The embedding model (paraphrase-multilingual-MiniLM-L12-v2) understands 50+ languages in the same vector space:

  • A Spanish document can answer an English question
  • A Portuguese FAQ matches a Spanish query
  • No need to duplicate content per language
Tip: Write your KB in one language (your business's primary). Multilingual embeddings handle the rest. Only duplicate content if you need region-specific terminology.

Content rules: granular content control

Beyond language, you can configure rules controlling what the assistant responds:

BLOCK — Total block

Block questions on specific topics. The user gets a predefined message.

REDIRECT — Redirect to another source

Redirect to a URL or custom message. Useful for topics requiring mandatory human attention.

FILTER — Fragment filtering

Filter retrieved fragments containing blocked terms before sending to the LLM. The LLM never sees that information.

Evaluation order: BLOCK and REDIRECT are evaluated after FAQ and cache, but before the RAG pipeline. FILTER applies to retrieved fragments before passing to the LLM.

Visual configuration

Language and content rules are configured from the visual interface in each KB’s RAG config. Toggle, select, and inline CRUD — no code needed.

6native languages (ES/EN/PT/DE/FR/IT)
50+languages via embeddings
0msdetection latency
3content rule types

One assistant, all languages. Try Citai →

Try Citai for free

Create your intelligent knowledge base in minutes. No credit card required.

Create free account