跳到主要內容
Open In ColabOpen on GitHub

Epsilla

Epsilla 是一個開源向量資料庫,利用先進的平行圖遍歷技術進行向量索引。Epsilla 在 GPL-3.0 許可證下授權。

您需要使用 pip install -qU langchain-community 安裝 langchain-community 才能使用此整合

本筆記本展示如何使用與 Epsilla 向量資料庫相關的功能。

作為先決條件,您需要有一個正在運行的 Epsilla 向量資料庫(例如,透過我們的 Docker 映像),並安裝 pyepsilla 套件。請查看 文件 以取得完整文件。

!pip/pip3 install pyepsilla

我們想要使用 OpenAIEmbeddings,因此我們必須取得 OpenAI API 金鑰。

import getpass
import os

if "OPENAI_API_KEY" not in os.environ:
os.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")

OpenAI API 金鑰:········

from langchain_community.vectorstores import Epsilla
from langchain_openai import OpenAIEmbeddings
API 參考:Epsilla | OpenAIEmbeddings
from langchain_community.document_loaders import TextLoader
from langchain_text_splitters import CharacterTextSplitter

loader = TextLoader("../../how_to/state_of_the_union.txt")
documents = loader.load()

documents = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0).split_documents(
documents
)

embeddings = OpenAIEmbeddings()

Epsilla vectordb 正在使用預設主機「localhost」和埠「8888」執行。我們有自訂的資料庫路徑、資料庫名稱和集合名稱,而不是預設的。

from pyepsilla import vectordb

client = vectordb.Client()
vector_store = Epsilla.from_documents(
documents,
embeddings,
client,
db_path="/tmp/mypath",
db_name="MyDB",
collection_name="MyCollection",
)
query = "What did the president say about Ketanji Brown Jackson"
docs = vector_store.similarity_search(query)
print(docs[0].page_content)

在一個又一個的州,新的法律已經通過,不僅要壓制投票,而且要顛覆整個選舉。

我們不能讓這種情況發生。

今晚。我呼籲參議院:通過《自由投票法案》。通過《約翰·路易斯投票權法案》。同時,通過《揭露法案》,以便美國人民可以知道是誰在資助我們的選舉。

今晚,我想表彰一位畢生奉獻國家的人:史蒂芬·布雷耶大法官——一位陸軍退伍軍人、憲法學者,以及即將退休的美國最高法院大法官。布雷耶大法官,感謝您的服務。

總統最重要的憲法責任之一是提名某人擔任美國最高法院的大法官。

而我在 4 天前就這樣做了,當時我提名了上訴法院法官 Ketanji Brown Jackson。我們國家頂尖的法律人才之一,他將延續布雷耶大法官的卓越遺產。


此頁面是否對您有幫助?