vecdb
v1.7
一個非常簡單的矢量嵌入數據庫,您可以說這是一個刊物桌子,可讓您找到類似於您要搜索的項目的項目。
我是數據庫愛好者,這是一個可以在生產中使用的樂趣和學習項目;)。
PS :我喜歡在空閒時間重新發明輪子,因為這是我的空閒時間!
我正在使用
{key => value}模型,
key應該是代表項目的唯一值。value應為矢量本身(浮子列表)。
默認情況下,
vecdb在當前工作目錄中搜索config.yml。但是,您可以通過提供自己的自定義文件路徑來使用--config /path/to/config.ymlpath/to/config.yml標誌對其進行覆蓋。
# http server related configs
server :
# the address to listen on in the form of '[host]:port'
listen : " 0.0.0.0:3000 "
# storage related configs
store :
# the driver you want to use
# currently vecdb supports "bolt" which is based on boltdb the in process embedded the database
driver : " bolt "
# the arguments required by the driver
# for bolt, it requires a key called `database` points to the path you want to store the data in.
args :
database : " ./vec.db "
# embeddings related configs
embedder :
# whether to enable the embedder and all endpoints using it or not
enabled : true
# the driver you want to use, currently vecdb supports gemini
driver : gemini
# the arguments required by the driver
# currently gemini driver requires `api_key` and `text_embedding_model`
args :
# by default vecdb will replace anything between ${..} with the actual value from the ENV var
api_key : " ${GEMINI_API_KEY} "
text_embedding_model : " text-embedding-004 "POST /v1/vectors/write並要將其存儲在某個地方時。POST /v1/vectors/search並希望列出所有按餘弦相似性以降序順序訂購的所有相似向量的鍵/ID。POST /v1/embeddings/text/write文本時,並希望vecdb使用配置的嵌入式(gemini)為您構建和存儲向量。POST /v1/embeddings/text/search時,您有文本並希望vecdb構建矢量並蒐索相似的向量鍵,以供您按降低順序訂購。 {
"bucket" : "BUCKET_NAME" , // consider it a collection or a table
"key" : "product-id-1" , // should be unique and represents a valid value in your main data store (example: the row id in your mysql/postgres ... etc)
"vector" : [ 1.929292 , 0.3848484 , - 1.9383838383 , ... ] // the vector you want to store
} {
"bucket" : "BUCKET_NAME" , // consider it a collection or a table
"vector" : [ 1.929292 , 0.3848484 , - 1.9383838383 , ... ] , // you will get a list ordered by cosine-similarity in descending order
"min_cosine_similarity" : 0.0 , // the more you increase, the fewer data you will get
"max_result_count" : 10 // max vectors to return (vecdb will first order by cosine similarity then apply the limit)
}如果將
embedder.enabled設置為true。
{
"bucket" : "BUCKET_NAME" , // consider it a collection or a table
"key" : "product-id-1" , // should be unique and represents a valid value in your main data store (example: the row id in your mysql/postgres ... etc)
"content" : "This is some text representing the product" // this will be converted to a vector using the configured embedder
}如果將
embedder.enabled設置為true。
{
"bucket" : "BUCKET_NAME" , // consider it a collection or a table
"content" : "A Product Text" , // you will get a list ordered by cosine-similarity in descending order
"min_cosine_similarity" : 0.0 , // the more you increase, the fewer data you will get
"max_result_count" : 10 // max vectors to return (vecdb will first order by cosine similarity then apply the limit)
}