It provides rich data models and enterprise-grade capabilities to support your real-time online scenarios while maintaining full compatibility with open-source Redis. Tair also introduces persistent memory-optimized instances that are based on the new non-volatile memory (NVM) storage medium.This notebook shows how to use functionality related to the Tair vector database.To run, you should have a Tair instance up and running.from langchain.embeddings.fake import FakeEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import Tairfrom langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)docs = text_splitter.split_documents(documents)embeddings = FakeEmbeddings(size=128)Connect to Tair using the TAIR_URL environment variable export TAIR_URL="redis://{username}:{password}@{tair_address}:{tair_port}"or the keyword argument tair_url.Then store documents and embeddings into Tair.tair_url = "redis://localhost:6379"# drop first if index already existsTair.drop_index(tair_url=tair_url)vector_store = Tair.from_documents(docs, embeddings, tair_url=tair_url)Query similar documents.query = "What did the president say about Ketanji Brown Jackson"docs = vector_store.similarity_search(query)docs[0]Tair Hybrid Search Index build# drop first if index already existsTair.drop_index(tair_url=tair_url)vector_store = Tair.from_documents(docs, embeddings, tair_url=tair_url, index_params={"lexical_algorithm":"bm25"})Tair Hybrid Searchquery = "What did the president say about Ketanji Brown Jackson"# hybrid_ratio: 0.5 hybrid search, 0.9999 vector search, 0.0001 text searchkwargs = {"TEXT" : query, "hybrid_ratio" : 0.5}docs = vector_store.similarity_search(query, **kwargs)docs[0]PreviousSupabase (Postgres)NextTencent Cloud VectorDBCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023
Tair is a cloud native in-memory database service developed by Alibaba Cloud.
Tair is a cloud native in-memory database service developed by Alibaba Cloud. ->: It provides rich data models and enterprise-grade capabilities to support your real-time online scenarios while maintaining full compatibility with open-source Redis. Tair also introduces persistent memory-optimized instances that are based on the new non-volatile memory (NVM) storage medium.This notebook shows how to use functionality related to the Tair vector database.To run, you should have a Tair instance up and running.from langchain.embeddings.fake import FakeEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import Tairfrom langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)docs = text_splitter.split_documents(documents)embeddings = FakeEmbeddings(size=128)Connect to Tair using the TAIR_URL environment variable export TAIR_URL="redis://{username}:{password}@{tair_address}:{tair_port}"or the keyword argument tair_url.Then store documents and embeddings into Tair.tair_url = "redis://localhost:6379"# drop first if index already existsTair.drop_index(tair_url=tair_url)vector_store = Tair.from_documents(docs, embeddings, tair_url=tair_url)Query similar documents.query = "What did the president say about Ketanji Brown Jackson"docs = vector_store.similarity_search(query)docs[0]Tair Hybrid Search Index build# drop first if index already existsTair.drop_index(tair_url=tair_url)vector_store = Tair.from_documents(docs, embeddings, tair_url=tair_url, index_params={"lexical_algorithm":"bm25"})Tair Hybrid Searchquery = "What did the president say about Ketanji Brown Jackson"# hybrid_ratio: 0.5 hybrid search, 0.9999 vector search, 0.0001 text searchkwargs = {"TEXT" : query, "hybrid_ratio" : 0.5}docs = vector_store.similarity_search(query, **kwargs)docs[0]PreviousSupabase (Postgres)NextTencent Cloud VectorDBCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023