1.4 KiB
1.4 KiB
Semantic Search
Semantic search enables the bot to retrieve information based on meaning rather than exact keyword matches. It leverages the vector embeddings stored in VectorDB.
How It Works
- Query Embedding – The user’s query string is converted into a dense vector using the same embedding model as the documents.
- Nearest‑Neighbor Search – VectorDB returns the top‑k vectors that are closest to the query vector.
- Result Formatting – The matching document chunks are concatenated and passed to the LLM as context for the final response.
Using the FIND Keyword
USE_KB "company-policies"
FIND "how many vacation days do I have?" INTO RESULT
TALK RESULT
USE_KBadds the collection to the session.FINDperforms the semantic search.RESULTreceives the best matching snippet.
Parameters
- k – Number of results to return (default 3). Can be overridden with
FIND "query" LIMIT 5 INTO RESULT. - filter – Optional metadata filter, e.g.,
FILTER source="policy.pdf".
Best Practices
- Keep the query concise (1‑2 sentences) for optimal embedding quality.
- Use
FORMATto clean up the result before sending to the user. - Combine with
GET_BOT_MEMORYto store frequently accessed answers.
Performance
Semantic search latency is typically < 100 ms for collections under 50 k vectors. Larger collections may require tuning VectorDB’s HNSW parameters.