Vector Search Example
This example demonstrates how to build a semantic search application using TiDB and local embedding models. It leverages vector search to find similar items based on meaning, not just keywords. The app uses Streamlit for the web UI and Ollama for local embedding generation.
Semantic search with vector embeddings
Prerequisites
- Python 3.10+
- A TiDB Cloud Starter cluster: Create a free cluster here: tidbcloud.com ↗️
How to run
Step 1: Clone the repository to local
Step 2: Install the required packages and set up the environment
Step 3: Set up environment to connect to TiDB
Go to TiDB Cloud console and get the connection parameters, then set up the environment variable like this:
cat > .env <<EOF
TIDB_HOST={gateway-region}.prod.aws.tidbcloud.com
TIDB_PORT=4000
TIDB_USERNAME={prefix}.root
TIDB_PASSWORD={password}
TIDB_DATABASE=vector_search_example
EOF
Step 4: Run the Streamlit app
Step 6: Open your browser and visit http://localhost:8501
Related Resources
- Source Code: View on GitHub
-
Category: Search
-
Description: Implement semantic search using vector embeddings to find similar content.