Redis 向量存储
本笔记本介绍如何开始使用 Redis 向量存储。
Redis is a popular open-source, in-memory data structure store that can be used as a database, cache, message broker, and queue. It now includes vector similarity search capabilities, making it suitable for use as a vector store.
什么是 Redis?
大多数开发者都熟悉 Redis。从本质上讲,Redis 是一种键值对家族的 NoSQL 数据库,可以用作缓存、消息代理、流处理以及主数据库。开发者选择 Redis 是因为它速度快,拥有庞大的客户端库生态系统,并且已经被大型企业部署多年。
在这些传统用例之上,Redis 提供了额外的功能,例如搜索和查询功能,允许用户在 Redis 内创建次级索引结构。这使得 Redis 能够以缓存的速度成为一个向量数据库。
Redis 作为向量数据库
Redis 使用压缩的倒排索引进行快速索引,内存占用低。它还支持多种高级功能,例如:
- Redis 哈希中多个字段的索引和
JSON - 向量相似性搜索(使用
HNSW(ANN) 或FLAT(KNN)) - 向量范围搜索(例如,查找查询向量半径内的所有向量)
- 无性能损失的增量索引
- 文档排序(使用tf-idf,可选用户提供的权重)
- 字段权重
- 使用
AND、OR和NOT运算符的复杂布尔查询 - 前缀匹配、模糊匹配和精确短语查询
- 支持双Metaphone语音匹配
- 自动完成建议(带有模糊前缀建议)
- 基于词干的查询扩展在 多种语言 中(使用 Snowball)
- 支持中文分词和查询(使用Friso)
- 数值过滤器和范围
- 使用Redis地理空间索引进行地理空间搜索
- 一个强大的聚合引擎
- 支持所有
utf-8编码的文本 - 检索完整的文档、选定的字段,或仅检索文档ID。
- 按排序结果(例如,按创建日期)
客户端
由于 Redis 远远不止是一个向量数据库,因此在许多情况下,除了 LangChain 集成之外,还需要使用一个 Redis 客户端。您可以使用任何标准的 Redis 客户端库来运行搜索和查询命令,但最简单的方法是使用封装了搜索和查询 API 的库。以下是一些示例,但您可以在 这里 找到更多客户端库。
| 项目 | 语言 | 许可 | 作者 | 星数 |
|---|---|---|---|---|
| jedis | Java | MIT | Redis | |
| redisvl | Python | MIT | Redis | |
| redis-py | Python | MIT | Redis | |
| node-redis | Node.js | MIT | Redis | |
| nredisstack | .NET | MIT | Redis |
部署选项
部署 Redis 与 RediSearch 有多种方式。最简单的开始方式是使用 Docker,但还有许多其他潜在的部署选项,例如:
- Redis 云
- Docker (Redis Stack)
- 云市场: AWS Marketplace、Google Marketplace 或 Azure Marketplace
- 本地部署: Redis Enterprise Software
- Kubernetes: 在 Kubernetes 上的 Redis Enterprise 软件
Redis 连接 URL 模式
有效的 Redis URL 模式为:
redis://- 与Redis独立实例的连接,未加密rediss://- 与Redis独立实例的连接,使用TLS加密redis+sentinel://- 通过 Redis Sentinel 连接到未加密的 Redis 服务器rediss+sentinel://- 通过 Redis Sentinel 连接到 Redis 服务器,两个连接均使用 TLS 加密
有关其他连接参数的更多信息,请参阅 redis-py 文档。
设置
要使用 RedisVectorStore,您需要安装 langchain-redis 合作伙伴包,以及本笔记本中使用的其他包。
%pip install -qU langchain-redis langchain-huggingface sentence-transformers scikit-learn
Note: you may need to restart the kernel to use updated packages.
凭据
Redis 连接凭据作为 Redis 连接 URL 的一部分传递。Redis 连接 URL 具有很高的灵活性,可以适应各种 Redis 服务器拓扑结构和认证方法。这些 URL 遵循特定的格式,包括连接协议、认证信息、主机、端口和数据库信息。 Redis 连接 URL 的基本结构如下:
[protocol]://[auth]@[host]:[port]/[database]
Where:
- 协议可以是 redis 用于标准连接,rediss 用于 SSL/TLS 连接,或 redis+sentinel 用于 Sentinel 连接。
- auth 包括用户名和密码(如果适用)。
- 主机是Redis服务器的主机名或IP地址。
- 端口是Redis服务器的端口。
- 数据库是Redis数据库编号。
Redis 连接 URL 支持多种配置,包括:
- 独立的Redis服务器(带或不带认证)
- Redis 哨兵设置
- SSL/TLS加密连接
- 不同的认证方式(仅密码或用户名-密码)
以下是不同配置的 Redis 连接 URL 示例:
# connection to redis standalone at localhost, db 0, no password
redis_url = "redis://localhost:6379"
# connection to host "redis" port 7379 with db 2 and password "secret" (old style authentication scheme without username / pre 6.x)
redis_url = "redis://:secret@redis:7379/2"
# connection to host redis on default port with user "joe", pass "secret" using redis version 6+ ACLs
redis_url = "redis://joe:secret@redis/0"
# connection to sentinel at localhost with default group mymaster and db 0, no password
redis_url = "redis+sentinel://localhost:26379"
# connection to sentinel at host redis with default port 26379 and user "joe" with password "secret" with default group mymaster and db 0
redis_url = "redis+sentinel://joe:secret@redis"
# connection to sentinel, no auth with sentinel monitoring group "zone-1" and database 2
redis_url = "redis+sentinel://redis:26379/zone-1/2"
# connection to redis standalone at localhost, db 0, no password but with TLS support
redis_url = "rediss://localhost:6379"
# connection to redis sentinel at localhost and default port, db 0, no password
# but with TLS support for both Sentinel and Redis server
redis_url = "rediss+sentinel://localhost"
启动一个Redis实例与Docker
要使用 Redis 与 LangChain,你需要一个正在运行的 Redis 实例。你可以使用 Docker 启动一个实例,命令如下:
docker run -d -p 6379:6379 redis/redis-stack:latest
对于这个例子,我们将使用一个本地的 Redis 实例。如果你使用的是远程实例,则需要相应地修改 Redis 的 URL。
import os
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379")
print(f"Connecting to Redis at: {REDIS_URL}")
Connecting to Redis at: redis://redis:6379
要启用模型调用的自动跟踪,请设置您的 LangSmith API 密钥:
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")
# os.environ["LANGSMITH_TRACING"] = "true"
让我们通过 ping Redis 来检查它是否已启动并运行。
import redis
redis_client = redis.from_url(REDIS_URL)
redis_client.ping()
True
示例数据
20个新闻组数据集包含大约18000篇关于20个主题的新闻组帖子。在这个演示中,我们将使用一个子集,并专注于两个类别:“alt.atheism”和“sci.space”。
from langchain.docstore.document import Document
from sklearn.datasets import fetch_20newsgroups
categories = ["alt.atheism", "sci.space"]
newsgroups = fetch_20newsgroups(
subset="train", categories=categories, shuffle=True, random_state=42
)
# Use only the first 250 documents
texts = newsgroups.data[:250]
metadata = [
{"category": newsgroups.target_names[target]} for target in newsgroups.target[:250]
]
len(texts)
250
初始化
RedisVectorStore实例可以通过多种方式进行初始化:
RedisVectorStore.__init__- 直接初始化RedisVectorStore.from_texts- 从文本列表初始化(可选地包含元数据)RedisVectorStore.from_documents- 从一个包含langchain_core.documents.Document个对象的列表初始化RedisVectorStore.from_existing_index- 从现有的 Redis 索引初始化
下面我们将使用 RedisVectorStore.__init__ 方法,并使用一个 RedisConfig 实例。
pip install -qU langchain-openai
import getpass
import os
if not os.environ.get("OPENAI_API_KEY"):
os.environ["OPENAI_API_KEY"] = getpass.getpass("Enter API key for OpenAI: ")
from langchain_openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(model="text-embedding-3-large")
我们将使用 SentenceTransformer 模型来创建嵌入。该模型在本地运行,不需要 API 密钥。
from langchain_redis import RedisConfig, RedisVectorStore
config = RedisConfig(
index_name="newsgroups",
redis_url=REDIS_URL,
metadata_schema=[
{"name": "category", "type": "tag"},
],
)
vector_store = RedisVectorStore(embeddings, config=config)
管理向量存储
将项目添加到向量存储
ids = vector_store.add_texts(texts, metadata)
print(ids[0:10])
['newsgroups:f1e788ee61fe410daa8ef941dd166223', 'newsgroups:80b39032181f4299a359a9aaed6e2401', 'newsgroups:99a3efc1883647afba53d115b49e6e92', 'newsgroups:503a6c07cd71418eb71e11b42589efd7', 'newsgroups:7351210e32d1427bbb3c7426cf93a44f', 'newsgroups:4e79fdf67abe471b8ee98ba0e8a1a055', 'newsgroups:03559a1d574e4f9ca0479d7b3891402e', 'newsgroups:9a1c2a7879b8409a805db72feac03580', 'newsgroups:3578a1e129f5435f9743cf803413f37a', 'newsgroups:9f68baf4d6b04f1683d6b871ce8ad92d']
让我们检查一下第一份文档:
texts[0], metadata[0]
('From: bil@okcforum.osrhe.edu (Bill Conner)\nSubject: Re: Not the Omni!\nNntp-Posting-Host: okcforum.osrhe.edu\nOrganization: Okcforum Unix Users Group\nX-Newsreader: TIN [version 1.1 PL6]\nLines: 18\n\nCharley Wingate (mangoe@cs.umd.edu) wrote:\n: \n: >> Please enlighten me. How is omnipotence contradictory?\n: \n: >By definition, all that can occur in the universe is governed by the rules\n: >of nature. Thus god cannot break them. Anything that god does must be allowed\n: >in the rules somewhere. Therefore, omnipotence CANNOT exist! It contradicts\n: >the rules of nature.\n: \n: Obviously, an omnipotent god can change the rules.\n\nWhen you say, "By definition", what exactly is being defined;\ncertainly not omnipotence. You seem to be saying that the "rules of\nnature" are pre-existant somehow, that they not only define nature but\nactually cause it. If that\'s what you mean I\'d like to hear your\nfurther thoughts on the question.\n\nBill\n',
{'category': 'alt.atheism'})
从向量存储中删除项目
# Delete documents by passing one or more keys/ids
vector_store.index.drop_keys(ids[0])
1
检查已创建的索引
一旦 Redis VectorStore 对象被构建,如果它还不存在,将在 Redis 中创建一个索引。可以使用 rvl 和 redis-cli 命令行工具来检查该索引。如果您在上面安装了 redisvl,可以使用 rvl 命令行工具来检查索引。
# assumes you're running Redis locally (use --host, --port, --password, --username, to change this)
!rvl index listall --port 6379
[32m17:54:50[0m [34m[RedisVL][0m [1;30mINFO[0m Using Redis address from environment variable, REDIS_URL
[32m17:54:50[0m [34m[RedisVL][0m [1;30mINFO[0m Indices:
[32m17:54:50[0m [34m[RedisVL][0m [1;30mINFO[0m 1. newsgroups
Redis 向量存储实现将尝试为通过 from_texts、from_texts_return_keys 和 from_documents 方法传递的任何元数据生成索引模式(用于过滤的字段)。这样,无论传递了什么元数据,都将被索引到 Redis 搜索索引中,从而允许对这些字段进行过滤。
下面展示了从我们定义的元数据中创建了哪些字段。
!rvl index info -i newsgroups --port 6379
[32m17:54:50[0m [34m[RedisVL][0m [1;30mINFO[0m Using Redis address from environment variable, REDIS_URL
Index Information:
╭──────────────┬────────────────┬────────────────┬─────────────────┬────────────╮
│ Index Name │ Storage Type │ Prefixes │ Index Options │ Indexing │
├──────────────┼────────────────┼────────────────┼─────────────────┼────────────┤
│ newsgroups │ HASH │ ['newsgroups'] │ [] │ 0 │
╰──────────────┴────────────────┴────────────────┴─────────────────┴────────────╯
Index Fields:
╭───────────┬─────────────┬────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬─────────────────┬────────────────╮
│ Name │ Attribute │ Type │ Field Option │ Option Value │ Field Option │ Option Value │ Field Option │ Option Value │ Field Option │ Option Value │
├───────────┼─────────────┼────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼─────────────────┼────────────────┤
│ text │ text │ TEXT │ WEIGHT │ 1 │ │ │ │ │ │ │
│ embedding │ embedding │ VECTOR │ algorithm │ FLAT │ data_type │ FLOAT32 │ dim │ 768 │ distance_metric │ COSINE │
│ category │ category │ TAG │ SEPARATOR │ | │ │ │ │ │ │ │
╰───────────┴─────────────┴────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴─────────────────┴────────────────╯
!rvl stats -i newsgroups --port 6379
[32m17:54:51[0m [34m[RedisVL][0m [1;30mINFO[0m Using Redis address from environment variable, REDIS_URL
Statistics:
╭─────────────────────────────┬────────────╮
│ Stat Key │ Value │
├─────────────────────────────┼────────────┤
│ num_docs │ 249 │
│ num_terms │ 16178 │
│ max_doc_id │ 250 │
│ num_records │ 50394 │
│ percent_indexed │ 1 │
│ hash_indexing_failures │ 0 │
│ number_of_uses │ 2 │
│ bytes_per_record_avg │ 38.2743 │
│ doc_table_size_mb │ 0.0263586 │
│ inverted_sz_mb │ 1.83944 │
│ key_table_size_mb │ 0.00932026 │
│ offset_bits_per_record_avg │ 10.6699 │
│ offset_vectors_sz_mb │ 0.089057 │
│ offsets_per_term_avg │ 1.38937 │
│ records_per_doc_avg │ 202.386 │
│ sortable_values_size_mb │ 0 │
│ total_indexing_time │ 72.444 │
│ total_inverted_index_blocks │ 16207 │
│ vector_index_sz_mb │ 3.01776 │
╰─────────────────────────────┴────────────╯
查询向量存储
一旦您的向量存储已创建并添加了相关文档,您很可能希望在链或代理运行期间对其进行查询。
直接查询
执行简单的相似度搜索可以按以下方式完成:
query = "Tell me about space exploration"
results = vector_store.similarity_search(query, k=2)
print("Simple Similarity Search Results:")
for doc in results:
print(f"Content: {doc.page_content[:100]}...")
print(f"Metadata: {doc.metadata}")
print()
Simple Similarity Search Results:
Content: From: aa429@freenet.carleton.ca (Terry Ford)
Subject: A flawed propulsion system: Space Shuttle
X-Ad...
Metadata: {'category': 'sci.space'}
Content: From: nsmca@aurora.alaska.edu
Subject: Space Design Movies?
Article-I.D.: aurora.1993Apr23.124722.1
...
Metadata: {'category': 'sci.space'}
如果您想执行相似度搜索并获取相应的分数,可以运行:
# Similarity search with score and filter
scored_results = vector_store.similarity_search_with_score(query, k=2)
print("Similarity Search with Score Results:")
for doc, score in scored_results:
print(f"Content: {doc.page_content[:100]}...")
print(f"Metadata: {doc.metadata}")
print(f"Score: {score}")
print()
Similarity Search with Score Results:
Content: From: aa429@freenet.carleton.ca (Terry Ford)
Subject: A flawed propulsion system: Space Shuttle
X-Ad...
Metadata: {'category': 'sci.space'}
Score: 0.569670975208
Content: From: nsmca@aurora.alaska.edu
Subject: Space Design Movies?
Article-I.D.: aurora.1993Apr23.124722.1
...
Metadata: {'category': 'sci.space'}
Score: 0.590400338173
通过转换为检索器进行查询
您还可以将向量存储转换为检索器,以便在链中更轻松地使用。
retriever = vector_store.as_retriever(search_type="similarity", search_kwargs={"k": 2})
retriever.invoke("What planet in the solar system has the largest number of moons?")
[Document(metadata={'category': 'sci.space'}, page_content='Subject: Re: Comet in Temporary Orbit Around Jupiter?\nFrom: Robert Coe <bob@1776.COM>\nDistribution: world\nOrganization: 1776 Enterprises, Sudbury MA\nLines: 23\n\njgarland@kean.ucs.mun.ca writes:\n\n> >> Also, perihelions of Gehrels3 were:\n> >> \n> >> April 1973 83 jupiter radii\n> >> August 1970 ~3 jupiter radii\n> > \n> > Where 1 Jupiter radius = 71,000 km = 44,000 mi = 0.0005 AU. So the\n> > 1970 figure seems unlikely to actually be anything but a perijove.\n> > Is that the case for the 1973 figure as well?\n> > -- \n> Sorry, _perijoves_...I\'m not used to talking this language.\n\nHmmmm.... The prefix "peri-" is Greek, not Latin, so it\'s usually used\nwith the Greek form of the name of the body being orbited. (That\'s why\nit\'s "perihelion" rather than "perisol", "perigee" rather than "periterr",\nand "pericynthion" rather than "perilune".) So for Jupiter I\'d expect it\nto be something like "perizeon".) :^)\n\n ___ _ - Bob\n /__) _ / / ) _ _\n(_/__) (_)_(_) (___(_)_(/_______________________________________ bob@1776.COM\nRobert K. Coe ** 14 Churchill St, Sudbury, Massachusetts 01776 ** 508-443-3265\n'),
Document(metadata={'category': 'sci.space'}, page_content='From: pyron@skndiv.dseg.ti.com (Dillon Pyron)\nSubject: Re: Why not give $1 billion to first year-long moon residents?\nLines: 42\nNntp-Posting-Host: skndiv.dseg.ti.com\nReply-To: pyron@skndiv.dseg.ti.com\nOrganization: TI/DSEG VAX Support\n\n\nIn article <1qve4kINNpas@sal-sun121.usc.edu>, schaefer@sal-sun121.usc.edu (Peter Schaefer) writes:\n>In article <1993Apr19.130503.1@aurora.alaska.edu>, nsmca@aurora.alaska.edu writes:\n>|> In article <6ZV82B2w165w@theporch.raider.net>, gene@theporch.raider.net (Gene Wright) writes:\n>|> > With the continuin talk about the "End of the Space Age" and complaints \n>|> > by government over the large cost, why not try something I read about \n>|> > that might just work.\n>|> > \n>|> > Announce that a reward of $1 billion would go to the first corporation \n>|> > who successfully keeps at least 1 person alive on the moon for a year. \n>|> > Then you\'d see some of the inexpensive but not popular technologies begin \n>|> > to be developed. THere\'d be a different kind of space race then!\n>|> > \n>|> > --\n>|> > gene@theporch.raider.net (Gene Wright)\n>|> > theporch.raider.net 615/297-7951 The MacInteresteds of Nashville\n>|> ====\n>|> If that were true, I\'d go for it.. I have a few friends who we could pool our\n>|> resources and do it.. Maybe make it a prize kind of liek the "Solar Car Race"\n>|> in Australia..\n>|> Anybody game for a contest!\n>|> \n>|> ==\n>|> Michael Adams, nsmca@acad3.alaska.edu -- I\'m not high, just jacked\n>\n>\n>Oh gee, a billion dollars! That\'d be just about enough to cover the cost of the\n>feasability study! Happy, Happy, JOY! JOY!\n>\n\nFeasability study?? What a wimp!! While you are studying, others would be\ndoing. Too damn many engineers doing way too little engineering.\n\n"He who sits on his arse sits on his fortune" - Sir Richard Francis Burton\n--\nDillon Pyron | The opinions expressed are those of the\nTI/DSEG Lewisville VAX Support | sender unless otherwise stated.\n(214)462-3556 (when I\'m here) |\n(214)492-4656 (when I\'m home) |Texans: Vote NO on Robin Hood. We need\npyron@skndiv.dseg.ti.com |solutions, not gestures.\nPADI DM-54909 |\n\n')]
检索增强生成的用法
有关如何使用此向量存储进行检索增强生成 (RAG) 的指南,请参阅以下部分:
Redis特有的功能
Redis 为向量搜索提供了一些独特功能:
带有元数据过滤的相似性搜索
我们可以根据元数据过滤搜索结果:
from redisvl.query.filter import Tag
query = "Tell me about space exploration"
# Create a RedisVL filter expression
filter_condition = Tag("category") == "sci.space"
filtered_results = vector_store.similarity_search(query, k=2, filter=filter_condition)
print("Filtered Similarity Search Results:")
for doc in filtered_results:
print(f"Content: {doc.page_content[:100]}...")
print(f"Metadata: {doc.metadata}")
print()
Filtered Similarity Search Results:
Content: From: aa429@freenet.carleton.ca (Terry Ford)
Subject: A flawed propulsion system: Space Shuttle
X-Ad...
Metadata: {'category': 'sci.space'}
Content: From: nsmca@aurora.alaska.edu
Subject: Space Design Movies?
Article-I.D.: aurora.1993Apr23.124722.1
...
Metadata: {'category': 'sci.space'}
最大边际相关性搜索
最大边际相关性搜索有助于获得多样化结果:
# Maximum marginal relevance search with filter
mmr_results = vector_store.max_marginal_relevance_search(
query, k=2, fetch_k=10, filter=filter_condition
)
print("Maximum Marginal Relevance Search Results:")
for doc in mmr_results:
print(f"Content: {doc.page_content[:100]}...")
print(f"Metadata: {doc.metadata}")
print()
Maximum Marginal Relevance Search Results:
Content: From: aa429@freenet.carleton.ca (Terry Ford)
Subject: A flawed propulsion system: Space Shuttle
X-Ad...
Metadata: {'category': 'sci.space'}
Content: From: moroney@world.std.com (Michael Moroney)
Subject: Re: Vulcan? (No, not the guy with the ears!)
...
Metadata: {'category': 'sci.space'}
LangChain的使用
下面的代码展示了如何在简单的RAG链中将向量存储用作检索器:
pip install -qU "langchain[openai]"
import getpass
import os
if not os.environ.get("OPENAI_API_KEY"):
os.environ["OPENAI_API_KEY"] = getpass.getpass("Enter API key for OpenAI: ")
from langchain.chat_models import init_chat_model
llm = init_chat_model("gpt-4o-mini", model_provider="openai")
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
# Prompt
prompt = ChatPromptTemplate.from_messages(
[
(
"human",
"""You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, just say that you don't know. Use three sentences maximum and keep the answer concise.
Question: {question}
Context: {context}
Answer:""",
),
]
)
def format_docs(docs):
return "\n\n".join(doc.page_content for doc in docs)
rag_chain = (
{"context": retriever | format_docs, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
rag_chain.invoke("Describe the Space Shuttle program?")
'The Space Shuttle program was a NASA initiative that enabled reusable spacecraft to transport astronauts and cargo to and from low Earth orbit. It conducted a variety of missions, including satellite deployment, scientific research, and assembly of the International Space Station, and typically carried a crew of five astronauts. Although it achieved many successes, the program faced criticism for its safety concerns and the complexity of its propulsion system.'
连接到现有索引
为了在使用 Redis VectorStore 时索引相同的元数据,您需要传递相同的 index_schema,可以是一个 YAML 文件的路径,也可以是一个字典。以下内容展示了如何从索引中获取模式并连接到现有索引。
# write the schema to a yaml file
vector_store.index.schema.to_yaml("redis_schema.yaml")
# now we can connect to our existing index as follows
new_rdvs = RedisVectorStore(
embeddings,
redis_url=REDIS_URL,
schema_path="redis_schema.yaml",
)
results = new_rdvs.similarity_search("Space Shuttle Propulsion System", k=3)
print(results[0])
18:19:58 redisvl.index.index INFO Index already exists, not overwriting.
page_content='From: aa429@freenet.carleton.ca (Terry Ford)
Subject: A flawed propulsion system: Space Shuttle
X-Added: Forwarded by Space Digest
Organization: [via International Space University]
Original-Sender: isu@VACATION.VENARI.CS.CMU.EDU
Distribution: sci
Lines: 13
For an essay, I am writing about the space shuttle and a need for a better
propulsion system. Through research, I have found that it is rather clumsy
(i.e. all the checks/tests before launch), the safety hazards ("sitting
on a hydrogen bomb"), etc.. If you have any beefs about the current
space shuttle program Re: propulsion, please send me your ideas.
Thanks a lot.
--
Terry Ford [aa429@freenet.carleton.ca]
Nepean, Ontario, Canada.
' metadata={'category': 'sci.space'}
# compare the two schemas to verify they are the same
new_rdvs.index.schema == vector_store.index.schema
True
清理向量存储
# Clear vector store
vector_store.index.delete(drop=True)
API 参考
有关RedisVectorStore的所有功能和配置的详细文档,请访问API参考: https://python.langchain.com/api_reference/redis/vectorstores/langchain_redis.vectorstores.RedisVectorStore.html