# superduperdb
**Repository Path**: doney/superduperdb
## Basic Information
- **Project Name**: superduperdb
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2024-01-30
- **Last Updated**: 2024-01-30
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Bring AI to your favorite database!
---
### 📣 我们正式发布SuperDuperDB v0.1版本,包括以下内容:
- 支持主要的SQL数据库:PostgreSQL、MySQL、SQLite、DuckDB、Snowflake、BigQuery、ClickHouse、DataFusion、Druid、Impala、MSSQL、Oracle、pandas、Polars、PySpark和Trino(当然还有MongoDB)
- 改进了文档
- 模块化测试套件
***SuperDuperDB是开源的。请支持我们:***
- 在仓库给我们点亮一颗小星星!⭐
- [在ProductHunt上为我们投票!](https://www.producthunt.com/posts/superduperdb) 🗳️
- 通过在领英上转发[这篇帖子](https://www.linkedin.com/company/superduperdb)和在推特上转发[这条推文](https://twitter.com/superduperdb),帮助我们传播消息,并标记任何可能对SuperDuperDB感兴趣的人 📣
***开始使用:***
- 查看我们已经实现的使用案例[在这里的文档中](https://docs.superduperdb.com/docs/category/use-cases),以及社区构建的应用,在专门的[superduper-community-apps仓库](https://github.com/SuperDuperDB/superduper-community-apps)中查看,并尝试在[浏览器中的Jupyter上](https://demo.superduperdb.com/)使用所有这些应用!
想了解更多关于SuperDuperDB的信息,以及我们为什么认为它非常需要,请[阅读这篇博客文章](https://docs.superduperdb.com/blog/superduperdb-the-open-source-framework-for-bringing-ai-to-your-datastore/)。
---
## SuperDuperDB是什么?🔮
SuperDuperDB是一个通用的AI开发和部署框架,专为**集成任何机器学习模型**(如PyTorch、Sklearn、HuggingFace)和**AI API**(如OpenAI、Antrophic、Cohere)**直接与您现有的数据库相连**而设计,包括流式推理、模型训练和向量搜索。SuperDuperDB不是另一个新的数据库,它能“超级增强”您目前使用的数据库。
SuperDuperDB消除了复杂的MLOps管道和专用向量数据库的需求,使您能够通过简单的Python接口,高效灵活地构建端到端的AI应用!
- 生成式AI & 基于LLM的Chatbot
- 向量搜索
- 标准的机器学习应用场景(分类、分割、推荐等)
- 涉及到超专业模型的高度定制化AI应用场景
### 核心特性:
- **[将AI与现有数据基础设施集成](https://docs.superduperdb.com/docs/docs/walkthrough/apply_models):** 在单一可扩展的系统中将任何AI模型和API与您的数据库集成,无需额外的预处理步骤、ETL或冗余代码。
- **[流式推理](https://docs.superduperdb.com/docs/docs/walkthrough/daemonizing_models_with_listeners):** 当新数据到达时,让您的模型自动激活且立即计算输出,保持您的系统始终更新。
- **[可扩展的模型训练](https://docs.superduperdb.com/docs/docs/walkthrough/training_models):** 通过查询您的训练数据,在大型、多样化的数据集上训练AI模型。通过内置的计算优化确保最佳性能。
- **[模型调用链](https://docs.superduperdb.com/docs/docs/walkthrough/linking_interdependent_models/):** 通过连接模型和API,轻松设置复杂的工作流程,以相互依赖和顺序的方式协同工作和调用。
- **[简单易扩展的接口](https://docs.superduperdb.com/docs/docs/fundamentals/procedural_vs_declarative_api):** 添加并利用Python生态系统中的任何函数、程序、脚本或算法,增强您的工作流和应用。在使用SuperDuperDB时,可以仅通过简单的Python命令即可深入到任何实现层级,包括模型的内部实现。
- **[处理复杂数据类型](https://docs.superduperdb.com/docs/docs/walkthrough/encoding_special_data_types/):** 在您的数据库中直接处理图像、视频、音频等数据,以及任何可以在Python中编码为`bytes`的类型的数据。
- **[特征存储](https://docs.superduperdb.com/docs/docs/walkthrough/encoding_special_data_types):** 将您的数据库转变为可用于存储和管理AI模型中任意数据类型的数据输入和输出的中心化存储库,使各种数据可以在熟悉的环境中易结构化的格式来使用。
- **[向量搜索](https://docs.superduperdb.com/docs/docs/walkthrough/vector_search):** 无需将数据复制和迁移到其他专门的向量数据库 - 将您现有的测试和生产的数据库转变为全功能的多模态向量搜索数据库,包括使用强大的模型和API轻松生成数据的向量Embedding和数据的向量索引。
### 选择SuperDuperDB的理由
| | SuperDuperDB的优势 | 未采用SuperDuperDB的常见挑战 |
|---------|---------------------------------------------------------------|-----------------------------------------|
| 数据管理与安全 | 数据始终存储在数据库中,AI产生的输出与输入也存储在数据库中,供下游应用使用。数据访问和安全性通过数据库访问管理外部控制。 | 数据复制和迁移到不同环境,以及专门的向量数据库,增加了数据管理负担和安全风险。 |
| 基础设施 | 只需在一个环境内构建、发布和管理AI应用,提高了拓展性和最佳的计算效率。 | 复杂的碎片化基础设施,包括多个管道,带来高昂的采用和维护成本,增加安全风险。 |
| 代码 | 由于简单和声明式的API,学习曲线极小,仅需简单的Python命令。 | 需要使用数百行代码, 不同的环境,不用的工具。 |
## 目前支持的数据库 (*更多的在来的路上*):
**一行命令,将您现有的数据库转化为基于Python的AI开发和部署平台:**
```
db = superduper('mongodb|postgres|sqlite|duckdb|snowflake://')
```
## 目前支持的AI框架和模型 (*更多的在来的路上*):
**直接将任何AI模型(无论是开源、商业模型还是自行开发的)与您的数据库集成、训练和管理,仅需一个Python命令即可自动在数据库上模型进行计算输出:**
- 安装和部署模型
```
m = db.add(
|||,
preprocess=,
postprocess=,
encoder=
)
```
- 模型推理
```
m.predict(X='', db=db, select=, listen=False|True, create_vector_index=False|True)
```
- 模型训练
```
m.fit(X='', y='', db=db, select=|)
```
## 预置集成的 AI APIs (*更多的在来的路上*):
**通过一个简单的Python命令,将通过API访问的三方模型和您自己的其他模型集成在一起**
```
m = db.add(
OpenAI|Cohere|Anthropic(*args, **kwargs), # - Embedding,ChatCompletion,...
)
```
## 架构图
## 精选实例
立即尝试我们的 Jupyter Notebook [直接在您的浏览器上体验](https://demo.superduperdb.com)。
同时,您还可以在 [superduper-community-apps 仓库](https://github.com/SuperDuperDB/superduper-community-apps) 中找到由社区构建的用例和应用。
## 安装
#### 1. 通过`pip`安装SuperDuperDB *(~1分钟)*
```
pip install superduperdb
```
#### 2. 通过Docker安装SuperDuperDB *(~2分钟)*
- 如果你需要安装Docker, 查看这里的 文档.
```
docker run -p 8888:8888 superduperdb/demo:latest
```
## 代码样例
以下是一些简短的介绍,帮助您了解`superduperdb`的工作原理以及它的简易使用方法。您可以访问文档了解更多信息。
#### - 部署 ML/AI 模型到你的数据库
在单一环境下自动在你的数据库计算模型的输出结果
```python
import pymongo
from sklearn.svm import SVC
from superduperdb import superduper
# Make your db superduper!
db = superduper(pymongo.MongoClient().my_db)
# Models client can be converted to SuperDuperDB objects with a simple wrapper.
model = superduper(SVC())
# Add the model into the database
db.add(model)
# Predict on the selected data.
model.predict(X='input_col', db=db, select=Collection(name='test_documents').find({'_fold': 'valid'}))
```
#### - 直接从您的数据库训练模型。
仅通过查询您的数据库,无需额外的数据提取和预处理:
```python
import pymongo
from sklearn.svm import SVC
from superduperdb import superduper
# Make your db superduper!
db = superduper(pymongo.MongoClient().my_db)
# Models client can be converted to SuperDuperDB objects with a simple wrapper.
model = superduper(SVC())
# Predict on the selected data.
model.train(X='input_col', y='target_col', db=db, select=Collection(name='test_documents').find({'_fold': 'valid'}))
```
#### - 基于你的数据进行向量搜索
使用你现在喜欢的数据库作为一个向量搜索数据库,涵盖了模型管理和服务
```python
# First a "Listener" makes sure vectors stay up-to-date
indexing_listener = Listener(model=OpenAIEmbedding(), key='text', select=collection.find())
# This "Listener" is linked with a "VectorIndex"
db.add(VectorIndex('my-index', indexing_listener=indexing_listener))
# The "VectorIndex" may be used to search data. Items to be searched against are passed
# to the registered model and vectorized. No additional app layer is required.
db.execute(collection.like({'text': 'clothing item'}, 'my-index').find({'brand': 'Nike'}))
```
#### - 将AI接口集成,与其他模型协同工作。
使用OpenAI、PyTorch或Hugging Face模型作为向量搜索的嵌入模型。
```python
# Create a ``VectorIndex`` instance with indexing listener as OpenAIEmbedding and add it to the database.
db.add(
VectorIndex(
identifier='my-index',
indexing_listener=Listener(
model=OpenAIEmbedding(identifier='text-embedding-ada-002'),
key='abstract',
select=Collection(name='wikipedia').find(),
),
)
)
# The above also executes the embedding model (openai) with the select query on the key.
# Now we can use the vector-index to search via meaning through the wikipedia abstracts
cur = db.execute(
Collection(name='wikipedia')
.like({'abstract': 'philosophers'}, n=10, vector_index='my-index')
)
```
#### - 将 Llama2 模型加到SuperDuperDB中
```python
model_id = "meta-llama/Llama-2-7b-chat-hf"
tokenizer = AutoTokenizer.from_pretrained(model_id)
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
torch_dtype=torch.float16,
device_map="auto",
)
model = Pipeline(
identifier='my-sentiment-analysis',
task='text-generation',
preprocess=tokenizer,
object=pipeline,
torch_dtype=torch.float16,
device_map="auto",
)
# You can easily predict on your collection documents.
model.predict(
X=Collection(name='test_documents').find(),
db=db,
do_sample=True,
top_k=10,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
max_length=200
)
```
#### - 将模型的输出结果作为下游模型的输入
```python
model.predict(
X='input_col',
db=db,
select=coll.find().featurize({'X': ''}), # already registered upstream model-id
listen=True,
)
```
## 社区与帮助
#### 如果您遇到任何问题、疑问、意见或想法:
- 加入我们的Slack(期待在那里见到您)。
- 浏览我们的GitHub讨论区,或者提出新问题。
- 对现有问题进行评论,或者创建一个新问题。
- 通过这里提供您宝贵的反馈,帮助我们改进SuperDuperDB!
- 通过电子邮件联系我们:`gethelp@superduperdb.com`。
- 随时直接联系维护者或社区志愿者!
## 贡献
#### 贡献的方式多种多样,并不仅限于编写代码。我们欢迎所有形式的贡献,如:
- Bug反馈
- 文档优化
- 优化建议
- 期待功能
- 扩展教程和使用案例示例
请查看我们的[贡献指南](CONTRIBUTING.md)了解详细信息。
## 贡献者
#### 感谢这些出色的人们:
## 许可证
SuperDuperDB是开源的,并旨在成为一个社区努力的结果,没有您的支持和热情是无法实现的。
它根据Apache 2.0许可证的条款进行分发。对该项目的任何贡献都将受到同样的条款约束。
## 加入我们
我们正在寻找对我们试图解决的问题有兴趣的好人,全职加入我们。查看我们正在招募的职位这里!