Smart search features
Users are less patient these days and more used to "asking questions" than typing keywords. I tried 2 ways to build smart search for a website: LLM keyword extraction and RAG with ColiVara, each with its own pros and cons.
Also in: Tiếng Việt · 中文 · 한국어 · 日本語
Every website really needs "smart search"
User behavior has clearly changed a lot: first, people are less patient; second, they're getting used to "asking a question & getting an answer" rather than "searching by keywords".
So I believe "smart search" is a must-have for a website, a place where users can "ask questions" to your website.
I came up with 2 ways to implement this, and after trying them out, each one has its own pros and cons:
Approach 1: Extract keywords with an LLM
Super simple. It's still the usual search feature, but when a user asks a question, we use an LLM to analyze it and extract keywords, then search as usual by calling the API with those keywords. Once we have results, we feed them back to the LLM so it can explain them. That's it.
mermaidflowchart LR
A["User question"] --> B["LLM extracts keywords"]
B --> C["Search API via ElasticSearch or OpenSearch"]
C --> D["Search results"]
D --> E["LLM explains the answer"]If you want it fast, add ElasticSearch (or OpenSearch) here to speed up search many times over.
The upside is that it's fast & costs almost nothing extra, unless your database is large & query volume is high, in which case you'll pay $ for ElasticSearch (or $ for a VPS if you use OpenSearch).
However, this approach has some limits. For example, if you ask "products under $10", extracting keywords won't find the right results, and getting it right means writing extra filter functions in the API, which is pretty annoying.
Locked section: Approach 2: Retrieval-Augmented Generation (RAG)
Locked section: Quick comparison
Locked section: In short
Locked section: References
The rest is for Knowledges members
Plus 4 more sections (about 2 min) for members
You are reading roughly the first third. Knowledges, Combo and Community plans unlock paid articles in full; the Zuey AI plan reads previews only.