Skip to main content
GPT4All 是一个免费使用、本地运行、注重隐私的聊天机器人。无需 GPU 或网络连接。它支持流行模型以及自有模型,如 GPT4All Falcon、Wizard 等。 本 notebook 介绍如何将 GPT4All 嵌入 与 LangChain 结合使用。

安装 GPT4All 的 Python 绑定

pip install -qU  gpt4all > /dev/null
from langchain_community.embeddings import GPT4AllEmbeddings
gpt4all_embd = GPT4AllEmbeddings()
Model downloaded at:  /Users/rlm/.cache/gpt4all/ggml-all-MiniLM-L6-v2-f16.bin
text = "This is a test document."

嵌入文本数据

query_result = gpt4all_embd.embed_query(text)
使用 embed_documents 可以嵌入多段文本。您还可以将这些嵌入与 Nomic 的 Atlas 映射,以查看数据的可视化表示。
doc_result = gpt4all_embd.embed_documents([text])