Prompt

How do I build a multilingual question answering search app?

Artificial Intelligence / AI Search1 observationLast seen Nov 14, 2026

Latest observation

Nov 14, 2026OpenAI APIWeb search: off

Building a multilingual question answering search app usually means combining search / retrieval with question answering / generation in a way that works across languages. A practical way to build it is:

  1. Ingest documents
  2. Detect and store language
  3. Index for retrieval
  4. Translate or use multilingual embeddings
  5. Retrieve relevant passages
  6. Generate an answer in the user’s language
  7. Return citations and confidence

Here’s a solid architecture and implementation approach.


1) Define the product behavior

Decide what “multilingual” means for your app:

  • User asks in any language
  • Documents can be in multiple languages
  • Answers are returned in the user’s language
  • Optionally:
    • Search only within one language
    • Cross-lingual search, e.g. ask in English and find Spanish docs
    • Answer with citations from original-language sources

A common and useful behavior is:

  • User query language → detected automatically
  • Retrieval across all indexed languages
  • Answer generated in the query language
  • Citations show original snippets + translated summaries if needed

2) Recommended architecture

A good production architecture looks like this:

Ingestion pipeline

  • Document upload / crawl
  • Text extraction from PDFs, HTML, DOCX, etc.
  • Language detection
  • Chunking into passages
  • Embedding each chunk
  • Store:
    • raw text
    • language
    • metadata
    • embeddings
    • keywords / BM25 index

Query pipeline

  • Detect query language
  • Optional query translation
  • Hybrid retrieval:
    • lexical search (BM25)
    • semantic search (embeddings)
  • Rerank top results
  • Pass top passages to LLM
  • Generate answer in query language
  • Return answer with citations

3) Choose your multilingual retrieval strategy

There are three main approaches:

A. Translate everything to one language

How it works

  • Translate docs into a pivot language, usually English
  • Build your search index on translated text
  • Translate user queries to English
  • Generate answer and translate back if needed

Pros

  • Simple to reason about
  • Works with monolingual models
  • Easy to debug

Cons

  • Translation errors hurt recall and answer quality
  • Expensive at scale
  • Loses nuance
  • Two translation steps can add latency

Best for

  • Small-medium systems
  • When you already have strong translation infrastructure

B. Use multilingual embeddings

How it works

  • Keep documents in original languages
  • Embed chunks using a multilingual embedding model
  • Query in any language and retrieve semantically similar chunks across languages

Pros

  • No need to translate everything
  • Better cross-lingual retrieval
  • Usually lower latency than translate-all

Cons

  • Needs good multilingual embeddings
  • You still need answer generation in the user’s language
  • Lexical signals may be weaker than language-specific search

Best for

  • Modern QA apps
  • Multilingual knowledge bases
  • Cross-lingual search

C. Hybrid: multilingual embeddings + BM25 + translation

How it works

  • Use embeddings for semantic retrieval
  • Use BM25 for exact term matching
  • Optionally translate query for better lexical coverage
  • Rerank results with a cross-encoder or LLM

Pros

  • Best overall relevance
  • Handles names, acronyms, and exact terms better
  • Usually strongest production option

Cons

  • More engineering complexity
  • More moving parts

Best for

  • Production-grade QA systems

4) Indexing documents

Step 1: Extract text

Use parsers for:

  • PDF: pypdf, pdfplumber, unstructured
  • HTML: BeautifulSoup, trafilatura
  • DOCX: python-docx
  • OCR for scanned docs: Tesseract or cloud OCR

Step 2: Detect language

Use:

  • fastText language ID
  • langdetect
  • CLD3

Store:

  • document language
  • chunk language
  • source language confidence

Step 3: Chunk documents

Split into semantic chunks:

  • 200–500 tokens is common
  • preserve heading, section, and page metadata
  • overlap chunks slightly to avoid cutting answers in half

Example metadata:

{
  "doc_id": "policy_123",
  "chunk_id": "policy_123_07",
  "language": "es",
  "source": "employee_handbook.pdf",
  "page": 12,
  "section": "Vacation policy"
}

Step 4: Embed chunks

Use a multilingual embedding model such as:

  • text-embedding-3-large (good multilingual performance)
  • bge-m3
  • e5-multilingual
  • LaBSE
  • mGTE

Store embeddings in:

  • FAISS
  • pgvector
  • Pinecone
  • Weaviate
  • Milvus
  • Elasticsearch / OpenSearch vector support

5) Retrieval design

Hybrid retrieval is usually best

Semantic retrieval

Find passages similar in meaning, even across languages.

Lexical retrieval

Find exact terms, names, and numbers.

Reranking

Take the top 20–100 retrieved chunks and rerank them with:

  • a cross-encoder
  • multilingual reranker
  • LLM-based scoring

This improves answer quality a lot.


6) Question answering flow

A robust QA flow:

  1. Detect query language
  2. Search in all languages
  3. Collect top evidence passages
  4. Rerank evidence
  5. Ask an LLM to answer using only evidence
  6. Generate answer in the user’s language
  7. Attach citations

Important prompt pattern

Tell the model:

  • only use retrieved evidence
  • answer in the query language
  • say “I don’t know” if evidence is insufficient
  • cite sources

Example prompt idea:

Answer the question using only the provided context.
If the answer is not in the context, say you cannot determine it.
Respond in the same language as the user’s question.
Cite the source chunk IDs for each factual claim.


7) Multilingual answer generation

You have two choices:

Option 1: Generate directly in user language

Use a multilingual LLM and instruct it to answer in the same language as the query.

Option 2: Retrieve in any language, translate evidence, then answer

If the LLM is weaker in some languages, you can:

  • retrieve original chunks
  • translate retrieved chunks into the query language
  • ask the model to answer using translated evidence

For best quality, many systems:

  • retrieve in original language
  • keep citations to original source
  • feed either original text or translated text depending on the model

8) Handling cross-lingual search

Example:

  • User asks in French
  • Relevant document is in German

With multilingual embeddings, this can work directly.

Still, for better quality:

  • detect query language
  • optionally translate query into a pivot language
  • perform both multilingual semantic search and translated lexical search
  • merge and rerank results

This improves recall.


9) Suggested technology stack

Backend

  • Python + FastAPI
  • Celery / RQ / Kafka for indexing jobs
  • PostgreSQL for metadata
  • Vector DB:
    • pgvector for simpler setups
    • Pinecone / Milvus / Weaviate for scale

NLP

  • Multilingual embeddings: bge-m3, e5-multilingual, OpenAI embeddings
  • Language detection: fastText
  • Reranker: multilingual cross-encoder or LLM rerank
  • LLM: GPT-style or another multilingual instruction model

Frontend

  • React / Next.js
  • Search input with auto language detection
  • Answer panel with citations
  • Source document previews

10) Minimal example architecture

Ingestion

Docs -> text extraction -> language detection -> chunking -> embeddings -> vector DB

Query

User question -> detect language -> retrieve chunks -> rerank -> LLM answer -> citations

11) Pseudocode example

def answer_question(query):
    query_lang = detect_language(query)

    query_embedding = embed(query)

    candidates = vector_search(query_embedding, top_k=50)

    # Optional: lexical search + merge
    lexical_hits = bm25_search(query, top_k=50)
    candidates = merge_results(candidates, lexical_hits)

    reranked = rerank(query, candidates, top_k=5)

    context = "\n\n".join(
        f"[{c['chunk_id']}] {c['text']}" for c in reranked
    )

    prompt = f"""
    Answer the question using only the context.
    Respond in {query_lang}.
    Cite chunk IDs.

    Question: {query}

    Context:
    {context}
    """

    return llm_generate(prompt)

12) Common pitfalls

Poor chunking

If chunks are too large:

  • embeddings get noisy
  • retrieval is less precise

If chunks are too small:

  • answers lose context

Ignoring language metadata

You may want to know:

  • original language
  • translated version
  • confidence score
  • locale-specific formatting

Overreliance on translation

Translation can distort legal, medical, or technical text.

No reranking

Without reranking, retrieval quality is often noticeably worse.

Not returning citations

Users trust the system more when sources are visible.

Hallucinations

Always constrain the model to retrieved evidence.


13) Evaluation

You should test:

  • retrieval recall
  • answer correctness
  • cross-lingual performance
  • citation accuracy
  • latency

Useful metrics:

  • Recall@k
  • MRR
  • exact match / F1 for QA
  • human evaluation by language
  • citation precision

Create a multilingual test set with:

  • questions in different languages
  • documents in different languages
  • answers known ahead of time

14) If you want a simple MVP

Start with this:

  • Use multilingual embeddings
  • Store chunks in pgvector or Pinecone
  • Add BM25 lexical search
  • Rerank top results
  • Use an LLM to answer in the query language
  • Show citations

This gets you a strong first version without complex translation pipelines.


15) Practical MVP stack

If you want a quick build:

  • Frontend: Next.js
  • API: FastAPI
  • Chunking: LangChain or LlamaIndex
  • Embeddings: bge-m3 or OpenAI multilingual embeddings
  • Vector store: pgvector
  • Search: hybrid vector + BM25
  • LLM: multilingual instruction model
  • Language detection: fastText

If you want, I can also provide:

  1. a reference architecture diagram,
  2. a step-by-step implementation plan, or
  3. a working code sample using FastAPI + pgvector + multilingual embeddings.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.