Cross-Lingual Semantic Search

A question in French over English notes finds the right documents although it shares no word with them: the text match returns nothing, nearest neighbours over the embeddings fill in, and an exact English query keeps its exact matches.

Cross-Lingual Semantic Search: screenshot from the Company AI demo
_query_recommendCross-vertical
In the demoIn Company AI's search test, the French query 'quels prospects contacter au sujet des prix' gets no text-match hits, and the blended vector search returns English documents led by the same account plan an English search for 'pricing' puts first.

The problem

Keyword search fails the moment the words differ: another language, a synonym, a description instead of a name. Pure vector search fixes that and loses the exact match, so a search for a product code or a customer name comes back fuzzy.

How it works

The query first runs as a text match, each term OR'd with $match and ranked by $similarity. Nearest neighbours ($nearest) over embeddings stored beside the same items are then interleaved with those hits rather than replacing them, so exact matches stay on top and meaning fills the gaps.

Search also learns: each result shown is logged as an impression, and once clicks exist, _recommend reorders results by the probability of a click for similar queries.

For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application.

See it live

This use case runs in Company AI, a reference application you run yourself. There is no hosted demo, so the link opens its illustrated tour and source on GitHub: Company AI tour on GitHub →

Build it with Claude Code

Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.

Cross-lingual search: a prompt for Claude Code
Add cross-lingual search to this codebase using Aito, a predictive database. The feature: search our documents and records by text match and by nearest neighbours over stored embeddings together, interleaved and then reranked by what users click, so a question in another language still finds them.

1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code).
2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query.
3. Read the use-case guide: https://aito.ai/use-cases/cross-lingual-search/
4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-company-ai/blob/main/src/company_ai/search.py and https://github.com/AitoDotAI/aito-company-ai/blob/main/src/company_ai/embed.py
5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample.
6. Measure before wiring the UI: hold out recent rows and report how often the item actually chosen is in the top 3, against the order we show today.
7. In the UI, show the ranking as suggestions, with the reasons where the query gives them. Nothing is applied without the user.

Ask me before changing anything outside the new feature.