Pinecone 向量数据库组件 — sgcAI | eSeGeCe

Vector Database (Pinecone)

TsgcAIDatabaseVectorPinecone 把您的嵌入向量放进托管的 Pinecone 索引。导入过程会把所有向量合并为一次 upsert,查询则返回最接近匹配项背后所存储的文本,因此语料库可以在多台机器和多个用户之间共享。

TsgcAIDatabaseVectorPinecone

文件存储在云端的对应方案。接口相同、调用相同,但索引位于 Pinecone 中,可以扩展到超出内存容纳范围的规模。

组件类

TsgcAIDatabaseVectorPinecone

用途

托管向量索引

平台

Win32 和 Win64

sgcAI 是自包含的。该组件随 sgcAI 一同交付,并附带它所基于的 sgcWebSockets Core 运行时,因此无需购买基础授权。

导入到 Pinecone,随处查询

设置 API 密钥、环境、索引和项目,然后把它赋给一个嵌入向量组件。

uses
  sgcAI, sgcAI_DB_Vector_Pinecone, sgcAI_OpenAI_Embeddings;

var
  oDB: TsgcAIDatabaseVectorPinecone;
  oEmbeddings: TsgcAIOpenAIEmbeddings;
begin
  oDB := TsgcAIDatabaseVectorPinecone.Create(nil);
  oDB.PineconeOptions.ApiKey           := 'pc-...';
  oDB.PineconeOptions.Environment      := 'us-west4-gcp-free';
  oDB.PineconeIndexOptions.IndexName   := 'sgc-embeddings';
  oDB.PineconeIndexOptions.ProjectId   := 'abcd1234';

  oEmbeddings := TsgcAIOpenAIEmbeddings.Create(nil);
  oEmbeddings.OpenAIOptions.ApiKey := 'sk-...';
  oEmbeddings.Database := oDB;

  // Every chunk is batched into a single upsert.
  oEmbeddings.CreateEmbeddingsFromFile('manual.txt');

  // Retrieve context for a question.
  Memo1.Text := oEmbeddings.GetEmbedding('How do I reset the device?', '');
end;
// includes: sgcAI.hpp, sgcAI_DB_Vector_Pinecone.hpp

TsgcAIDatabaseVectorPinecone *oDB = new TsgcAIDatabaseVectorPinecone(NULL);
oDB->PineconeOptions->ApiKey         = "pc-...";
oDB->PineconeOptions->Environment    = "us-west4-gcp-free";
oDB->PineconeIndexOptions->IndexName = "sgc-embeddings";
oDB->PineconeIndexOptions->ProjectId = "abcd1234";

oDB->BeginAddData();
oDB->AddData("Reset procedure: hold the button for 10 seconds.", vVector);
oDB->EndAddData();

String vBest = oDB->QueryData(vQueryVector);

关键属性与方法

您最常使用的成员。

PineconeOptions

ApiKeyEnvironment 用于在您的 Pinecone 账户上完成身份验证,并选择索引所在的区域。

PineconeIndexOptions

IndexNameProjectId 用于定位具体的索引。两者都可以在 Pinecone 控制台中找到。

导入

BeginAddData 开始收集,AddData 把一段文本及其向量排入队列,EndAddData 则把整批内容作为一次 upsert 发送,而不是每一块发一次请求。

查询

QueryData 对索引发起一次相似度查询,并返回最佳匹配项背后所存储的文本。

id 控制

OnBeginAddData 为本批次设置起始 id 和 id 标签,使多次导入可以共存于同一个索引中而不发生冲突。

何时使用它

当语料库超出本地文件的承载能力、多个应用程序共用一个索引,或者导入和查询发生在不同机器上时,它最为合适。

规范与参考资料

该组件所用服务和协议的权威资料来源。

继续探索

在线帮助sgcAI 组件的完整 API 参考和使用指南。
所有 sgcAI 组件浏览全部 15 个组件的完整功能矩阵。
下载免费试用版把您的嵌入向量推送到托管索引并进行查询。
价格Single、Team 和 Site 授权,均含完整源代码,无需基础产品。
超值之选:All-AccesseSeGeCe 全部产品,含高级支持,每年 €1,059 起。
查看 All-Access 价格

准备好开始了吗?

下载免费试用版,把您的语料库放进托管向量索引。