TiDB Python AI SDK
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
Quick Start
•
Documentation
•
Examples
•
Roadmap
•
Discord
•
Report Bug
Introduction
**Python SDK for TiDB AI**: A unified data platform empowering developers to build next-generation AI applications.
- 🔍 **Unified Search Modes**: Vector · Full‑Text · Hybrid
- 🎭 **Auto‑Embedding & Multi‑Modal Storage**: Support for text, images, and more
- 🖼️ **Image Search Support**: Text‑to‑image and image‑to‑image retrieval capabilities
- 🎯 **Advanced Filtering & Reranking**: Flexible filters with optional reranker models to fine-tune result relevance
- 💱 **Transaction Support**: Full transaction management including commit/rollback to ensure consistency
Installation
> [!NOTE]
> This Python package is under rapid development and its API may change. It is recommended to use a **fixed version** when installing, e.g., pytidb==0.0.14.
Connect to TiDB Cloud
Create a free TiDB cluster at tidbcloud.com.
Highlights
🤖 Automatic Embedding
PyTiDB automatically embeds text fields (e.g., text) and stores the vector embedding in a vector field (e.g., text_vec).
**Create a table with an embedding function:**
**Bulk insert data:**
🔍 Search
**Vector Search**
Vector search finds the most relevant records based on **semantic similarity**, so you don't need to include all keywords explicitly in your query.
See the Vector Search example for more details.
**Full-text Search**
Full-text search tokenizes the query and finds the most relevant records by matching exact keywords.
See the Full-text Search example for more details.
**Hybrid Search**
Hybrid search combines **exact matching** from full-text search with **semantic understanding** from vector search, delivering more relevant and reliable results.
See the Hybrid Search example for more details.
**Image Search**
Image search lets you find visually similar images using natural language descriptions or another image as a reference.
See the Image Search example for more details.
Advanced Filtering
PyTiDB supports a variety of operators for flexible filtering:
| Operator | Description | Example |
| -------- | --------------------- | ------------------------------------------ |
| $eq | Equal to | {"field": {"$eq": "hello"}} |
| $gt | Greater than | {"field": {"$gt": 1}} |
| $gte | Greater than or equal | {"field": {"$gte": 1}} |
| $lt | Less than | {"field": {"$lt": 1}} |
| $lte | Less than or equal | {"field": {"$lte": 1}} |
| $in | In array | {"field": {"$in": [1, 2, 3]}} |