id
stringlengths
14
16
text
stringlengths
13
2.7k
source
stringlengths
57
178
3c70074abbe6-4
Returns List of IDs of the added texts. Return type List[str] add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, refresh_indices: bool = True, **kwargs: Any) → List[str][source]¶ Run more texts through the embeddings and add to the vectorstore. Parameters texts – It...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticVectorSearch.html
3c70074abbe6-5
Return docs selected using the maximal marginal relevance. async amax_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶ Return docs selected using the maximal marginal relevance. as_retriever(**kwargs: Any) → VectorStore...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticVectorSearch.html
3c70074abbe6-6
search_kwargs={'k': 5, 'fetch_k': 50} ) # Only retrieve documents that have a relevance score # Above a certain threshold docsearch.as_retriever( search_type="similarity_score_threshold", search_kwargs={'score_threshold': 0.8} ) # Only get the single most similar document from the dataset docsearch.as_retriever...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticVectorSearch.html
3c70074abbe6-7
Returns List of Tuples of (doc, similarity_score) async asimilarity_search_with_score(*args: Any, **kwargs: Any) → List[Tuple[Document, float]]¶ Run similarity search with distance asynchronously. client_search(client: Any, index_name: str, script_query: Dict, size: int) → Any[source]¶ create_index(client: Any, index_n...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticVectorSearch.html
3c70074abbe6-8
) static get_user_agent() → str[source]¶ max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selecte...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticVectorSearch.html
3c70074abbe6-9
Return docs most similar to query using specified search type. similarity_search(query: str, k: int = 4, filter: Optional[dict] = None, **kwargs: Any) → List[Document][source]¶ Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. R...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticVectorSearch.html
3c70074abbe6-10
:param k: Number of Documents to return. Defaults to 4. Returns List of Documents most similar to the query. Examples using ElasticVectorSearch¶ Elasticsearch Memory in the Multi-Input Chain
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticVectorSearch.html
fd5318317f8c-0
langchain.vectorstores.tiledb.TileDB¶ class langchain.vectorstores.tiledb.TileDB(embedding: Embeddings, index_uri: str, metric: str, *, vector_index_uri: str = '', docs_array_uri: str = '', config: Optional[Mapping[str, Any]] = None, timestamp: Any = None, **kwargs: Any)[source]¶ Wrapper around TileDB vector database. ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-1
Return docs selected using the maximal marginal relevance. as_retriever(**kwargs) Return VectorStoreRetriever initialized from this VectorStore. asearch(query, search_type, **kwargs) Return docs most similar to query using specified search type. asimilarity_search(query[, k]) Return docs most similar to query. asimilar...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-2
search(query, search_type, **kwargs) Return docs most similar to query using specified search type. similarity_search(query[, k, filter, fetch_k]) Return docs most similar to query. similarity_search_by_vector(embedding[, k, ...]) Return docs most similar to embedding vector. similarity_search_with_relevance_scores(que...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-3
Returns List of IDs of the added texts. Return type List[str] add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, timestamp: int = 0, **kwargs: Any) → List[str][source]¶ Run more texts through the embeddings and add to the vectorstore. Parameters texts – Iterable of ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-4
Return docs selected using the maximal marginal relevance. async amax_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶ Return docs selected using the maximal marginal relevance. as_retriever(**kwargs: Any) → VectorStore...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-5
search_kwargs={'k': 5, 'fetch_k': 50} ) # Only retrieve documents that have a relevance score # Above a certain threshold docsearch.as_retriever( search_type="similarity_score_threshold", search_kwargs={'score_threshold': 0.8} ) # Only get the single most similar document from the dataset docsearch.as_retriever...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-6
Returns List of Tuples of (doc, similarity_score) async asimilarity_search_with_score(*args: Any, **kwargs: Any) → List[Tuple[Document, float]]¶ Run similarity search with distance asynchronously. consolidate_updates(**kwargs: Any) → None[source]¶ classmethod create(index_uri: str, index_type: str, dimensions: int, vec...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-7
metadatas – List of metadata dictionaries to associate with documents. metric – Optional, Metric to use for indexing. Defaults to “euclidean”. index_type – Optional, Vector index type (“FLAT”, IVF_FLAT”) config – Optional, TileDB config index_timestamp – Optional, timestamp to write new texts with. Example from langcha...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-8
index = TileDB.from_texts(texts, embeddings) classmethod load(index_uri: str, embedding: Embeddings, *, metric: str = 'euclidean', config: Optional[Mapping[str, Any]] = None, timestamp: Any = None, **kwargs: Any) → TileDB[source]¶ Load a TileDB index from a URI. Parameters index_uri – The URI of the TileDB vector index...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-9
Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters embedding – Embedding to look up documents similar to. k – Number of Documents to return. Defaults to 4. fetch_k – Number of Documents to fetch befor...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-10
Returns List of Documents and similarity scores selected by maximal marginalrelevance and score for each. process_index_results(ids: List[int], scores: List[float], *, k: int = 4, filter: Optional[Dict[str, Any]] = None, score_threshold: float = 1.7976931348623157e+308) → List[Tuple[Document, float]][source]¶ Turns Til...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-11
Defaults to 20. Returns List of Documents most similar to the query. similarity_search_by_vector(embedding: List[float], k: int = 4, filter: Optional[Dict[str, Any]] = None, fetch_k: int = 20, **kwargs: Any) → List[Document][source]¶ Return docs most similar to embedding vector. Parameters embedding – Embedding to look...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
fd5318317f8c-12
k – Number of Documents to return. Defaults to 4. filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None. fetch_k – (Optional[int]) Number of Documents to fetch before filtering. Defaults to 20. Returns List of documents most similar to the query text with Distance as float. Lower score represents mor...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.TileDB.html
2246864f3a53-0
langchain.vectorstores.tencentvectordb.IndexParams¶ class langchain.vectorstores.tencentvectordb.IndexParams(dimension: int, shard: int = 1, replicas: int = 2, index_type: str = 'HNSW', metric_type: str = 'L2', params: Optional[Dict] = None)[source]¶ Tencent vector DB Index params. See the following documentation for d...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tencentvectordb.IndexParams.html
c122f513a8cc-0
langchain.vectorstores.pgvector.PGVector¶ class langchain.vectorstores.pgvector.PGVector(connection_string: str, embedding_function: Embeddings, collection_name: str = 'langchain', collection_metadata: Optional[dict] = None, distance_strategy: DistanceStrategy = DistanceStrategy.COSINE, pre_delete_collection: bool = Fa...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-1
collection_name=COLLECTION_NAME, connection_string=CONNECTION_STRING, ) Attributes distance_strategy embeddings Access the query embedding object if available. Methods __init__(connection_string, embedding_function) aadd_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectors...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-2
Return docs and relevance scores in the range [0, 1], asynchronously. asimilarity_search_with_score(*args, **kwargs) Run similarity search with distance asynchronously. connect() connection_string_from_db_params(driver, ...) Return connection string from database parameters. create_collection() create_tables_if_not_exi...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-3
Return docs most similar to embedding vector. similarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1]. similarity_search_with_score(query[, k, filter]) Return docs most similar to query. similarity_search_with_score_by_vector(embedding) __init__(connection_string: str, embedd...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-4
Returns List of IDs of the added texts. Return type List[str] add_embeddings(texts: Iterable[str], embeddings: List[List[float]], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, **kwargs: Any) → List[str][source]¶ Add embeddings to the vectorstore. Parameters texts – Iterable of strings to add ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-5
Return VectorStore initialized from texts and embeddings. async amax_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶ Return docs selected using the maximal marginal relevance. async amax_marginal_relevance_search_by_vector(embedding: List[f...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-6
docsearch.as_retriever( search_type="mmr", search_kwargs={'k': 6, 'lambda_mult': 0.25} ) # Fetch more documents for the MMR algorithm to consider # But only return the top 5 docsearch.as_retriever( search_type="mmr", search_kwargs={'k': 5, 'fetch_k': 50} ) # Only retrieve documents that have a relevance...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-7
0 is dissimilar, 1 is most similar. Parameters query – input text k – Number of Documents to return. Defaults to 4. **kwargs – kwargs to be passed to similarity search. Should include: score_threshold: Optional, a floating point value between 0 to 1 to filter the resulting set of retrieved docs Returns List of Tuples o...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-8
“Either pass it as a parameter or set the PGVECTOR_CONNECTION_STRING environment variable. classmethod from_embeddings(text_embeddings: List[Tuple[str, List[float]]], embedding: Embeddings, metadatas: Optional[List[dict]] = None, collection_name: str = 'langchain', distance_strategy: DistanceStrategy = DistanceStrategy...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-9
Postgres connection string is required “Either pass it as a parameter or set the PGVECTOR_CONNECTION_STRING environment variable. get_collection(session: Session) → Optional['CollectionStore'][source]¶ classmethod get_connection_string(kwargs: Dict[str, Any]) → str[source]¶ max_marginal_relevance_search(query: str, k: ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-10
Maximal marginal relevance optimizes for similarity to query AND diversityamong selected documents. Parameters embedding (str) – Text to look up documents similar to. k (int) – Number of Documents to return. Defaults to 4. fetch_k (int) – Number of Documents to fetch to pass to MMR algorithm. Defaults to 20. lambda_mul...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-11
Returns List of Documents selected by maximal marginalrelevance to the query and score for each. Return type List[Tuple[Document, float]] max_marginal_relevance_search_with_score_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[Dict[str, str]] = None, **kwargs:...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-12
Parameters query (str) – Query text to search for. k (int) – Number of results to return. Defaults to 4. filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None. Returns List of Documents most similar to the query. similarity_search_by_vector(embedding: List[float], k: int = 4, filter: Optional[dict] =...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
c122f513a8cc-13
filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None. Returns List of Documents most similar to the query and score for each. similarity_search_with_score_by_vector(embedding: List[float], k: int = 4, filter: Optional[dict] = None) → List[Tuple[Document, float]][source]¶ Examples using PGVector¶ PGV...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.PGVector.html
8dc6f73f3905-0
langchain.vectorstores.redis.filters.RedisText¶ class langchain.vectorstores.redis.filters.RedisText(field: str)[source]¶ A RedisFilterField representing a text field in a Redis index. Attributes OPERATORS OPERATOR_MAP escaper Methods __init__(field) equals(other) __init__(field: str)¶ equals(other: RedisFilterField) →...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.redis.filters.RedisText.html
dcad88efba58-0
langchain.vectorstores.redis.filters.RedisNum¶ class langchain.vectorstores.redis.filters.RedisNum(field: str)[source]¶ A RedisFilterField representing a numeric field in a Redis index. Attributes OPERATORS OPERATOR_MAP escaper Methods __init__(field) equals(other) __init__(field: str)¶ equals(other: RedisFilterField) ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.redis.filters.RedisNum.html
654dbce58785-0
langchain.vectorstores.llm_rails.LLMRailsRetriever¶ class langchain.vectorstores.llm_rails.LLMRailsRetriever[source]¶ Bases: VectorStoreRetriever Retriever for LLMRails. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a va...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
654dbce58785-1
Default implementation runs ainvoke in parallel using asyncio.gather. The default implementation of batch works well for IO bound runnables. Subclasses should override this method if they can batch more efficiently; e.g., if the underlying runnable uses an API which supports a batch mode. add_documents(documents: List[...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
654dbce58785-2
Subclasses should override this method if they can run asynchronously. async astream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of astream, which calls ainvoke. Subclasses should override this method if they support streaming output. a...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
654dbce58785-3
Default implementation runs invoke in parallel using a thread pool executor. The default implementation of batch works well for IO bound runnables. Subclasses should override this method if they can batch more efficiently; e.g., if the underlying runnable uses an API which supports a batch mode. bind(**kwargs: Any) → R...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
654dbce58785-4
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include – fields to include in new model exclude – fields to exclude from new model, as with values this takes precedence over include update – values to change/add in the new model. Note: the data is not validated before creat...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
654dbce58785-5
namespace is [“langchain”, “llms”, “openai”] get_output_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶ Get a pydantic model that can be used to validate output to the runnable. Runnables that leverage the configurable_fields and configurable_alternatives methods will have a dynamic output schema tha...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
654dbce58785-6
purposes, ‘max_concurrency’ for controlling how much work to do in parallel, and other keys. Please refer to the RunnableConfig for more details. Returns The output of the runnable. classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]]...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
654dbce58785-7
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
654dbce58785-8
Returns A new Runnable that will try the original runnable, and then each fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Ru...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
654dbce58785-9
The type of input this runnable accepts specified as a type annotation. property OutputType: Type[langchain.schema.runnable.utils.Output]¶ The type of output this runnable produces specified as a type annotation. allowed_search_types: ClassVar[Collection[str]] = ('similarity', 'similarity_score_threshold', 'mmr')¶ prop...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.llm_rails.LLMRailsRetriever.html
ff961d09f7f0-0
langchain.vectorstores.tair.Tair¶ class langchain.vectorstores.tair.Tair(embedding_function: Embeddings, url: str, index_name: str, content_key: str = 'content', metadata_key: str = 'metadata', search_params: Optional[dict] = None, **kwargs: Any)[source]¶ Tair vector store. Attributes embeddings Access the query embedd...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tair.Tair.html
ff961d09f7f0-1
Return docs most similar to embedding vector. asimilarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1], asynchronously. asimilarity_search_with_score(*args, **kwargs) Run similarity search with distance asynchronously. create_index_if_not_exist(dim, ...) delete([ids]) Delete ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tair.Tair.html
ff961d09f7f0-2
async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. Returns List of IDs of the added texts. Return type List[str] async aadd_texts(texts: Iterable[s...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tair.Tair.html
ff961d09f7f0-3
Return VectorStore initialized from texts and embeddings. async amax_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶ Return docs selected using the maximal marginal relevance. async amax_marginal_relevance_search_by_vector(embedding: List[f...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tair.Tair.html
ff961d09f7f0-4
) # Fetch more documents for the MMR algorithm to consider # But only return the top 5 docsearch.as_retriever( search_type="mmr", search_kwargs={'k': 5, 'fetch_k': 50} ) # Only retrieve documents that have a relevance score # Above a certain threshold docsearch.as_retriever( search_type="similarity_score_th...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tair.Tair.html
ff961d09f7f0-5
**kwargs – kwargs to be passed to similarity search. Should include: score_threshold: Optional, a floating point value between 0 to 1 to filter the resulting set of retrieved docs Returns List of Tuples of (doc, similarity_score) async asimilarity_search_with_score(*args: Any, **kwargs: Any) → List[Tuple[Document, floa...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tair.Tair.html
ff961d09f7f0-6
Connect to an existing Tair index. classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, index_name: str = 'langchain', content_key: str = 'content', metadata_key: str = 'metadata', **kwargs: Any) → Tair[source]¶ Return VectorStore initialized from texts and embeddings....
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tair.Tair.html
ff961d09f7f0-7
lambda_mult – Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. search(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Re...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tair.Tair.html
ff961d09f7f0-8
filter the resulting set of retrieved docs Returns List of Tuples of (doc, similarity_score) similarity_search_with_score(*args: Any, **kwargs: Any) → List[Tuple[Document, float]]¶ Run similarity search with distance. Examples using Tair¶ Tair
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tair.Tair.html
e11dff38b67b-0
langchain.vectorstores.redis.schema.read_schema¶ langchain.vectorstores.redis.schema.read_schema(index_schema: Optional[Union[Dict[str, List[Any]], str, PathLike]]) → Dict[str, Any][source]¶ Reads in the index schema from a dict or yaml file. Check if it is a dict and return RedisModel otherwise, check if it’s a path a...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.redis.schema.read_schema.html
dd0b6d2eaadb-0
langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch¶ class langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch(doc_index: BaseDocIndex, embedding: Embeddings)[source]¶ HnswLib storage using DocArray package. To use it, you should have the docarray package with version >=0.32.0 installed. You can install it with...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
dd0b6d2eaadb-1
asearch(query, search_type, **kwargs) Return docs most similar to query using specified search type. asimilarity_search(query[, k]) Return docs most similar to query. asimilarity_search_by_vector(embedding[, k]) Return docs most similar to embedding vector. asimilarity_search_with_relevance_scores(query) Return docs an...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
dd0b6d2eaadb-2
Initialize a vector store from DocArray’s DocIndex. async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. Returns List of IDs of the added texts. Retu...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
dd0b6d2eaadb-3
Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶ Return VectorStore initialized from texts and embeddings. async amax_marginal_relevance_search(query: str, k: int = 4, fetch_...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
dd0b6d2eaadb-4
Return type VectorStoreRetriever Examples: # Retrieve more documents with higher diversity # Useful if your dataset has many similar documents docsearch.as_retriever( search_type="mmr", search_kwargs={'k': 6, 'lambda_mult': 0.25} ) # Fetch more documents for the MMR algorithm to consider # But only return the t...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
dd0b6d2eaadb-5
Return docs and relevance scores in the range [0, 1], asynchronously. 0 is dissimilar, 1 is most similar. Parameters query – input text k – Number of Documents to return. Defaults to 4. **kwargs – kwargs to be passed to similarity search. Should include: score_threshold: Optional, a floating point value between 0 to 1 ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
dd0b6d2eaadb-6
Parameters embedding (Embeddings) – Embedding function. work_dir (str) – path to the location where all the data will be stored. n_dim (int) – dimension of an embedding. dist_metric (str) – Distance metric for DocArrayHnswSearch can be one of: “cosine”, “ip”, and “l2”. Defaults to “cosine”. max_elements (int) – Maximum...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
dd0b6d2eaadb-7
work_dir (str) – path to the location where all the data will be stored. n_dim (int) – dimension of an embedding. **kwargs – Other keyword arguments to be passed to the __init__ method. Returns DocArrayHnswSearch Vector Store max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
dd0b6d2eaadb-8
to maximum diversity and 1 to minimum diversity. Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. search(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. similarity_search(query: str, k: int = 4, **kwargs: Any...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
dd0b6d2eaadb-9
Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. Returns List of documents most similar to the query text and cosine distance in float for each. Lower score represents more similarity. Examples using DocArrayHnswSearch¶ DocArra...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.hnsw.DocArrayHnswSearch.html
30110f6d6bf1-0
langchain.vectorstores.scann.normalize¶ langchain.vectorstores.scann.normalize(x: ndarray) → ndarray[source]¶ Normalize vectors to unit length.
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.scann.normalize.html
ffb1942e1148-0
langchain.vectorstores.pgvector.DistanceStrategy¶ class langchain.vectorstores.pgvector.DistanceStrategy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶ Enumerator of the Distance strategies. EUCLIDEAN = 'l2'¶ COSINE = 'cosine'¶ MAX_INNER_PRODUCT = 'inner'¶
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pgvector.DistanceStrategy.html
316b771b376a-0
langchain.vectorstores.elastic_vector_search.ElasticKnnSearch¶ class langchain.vectorstores.elastic_vector_search.ElasticKnnSearch(index_name: str, embedding: Embeddings, es_connection: Optional['Elasticsearch'] = None, es_cloud_id: Optional[str] = None, es_user: Optional[str] = None, es_password: Optional[str] = None,...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-1
that contains the original text data. Type str, optional Usage:>>> from embeddings import Embeddings >>> embedding = Embeddings.load('glove') >>> es_search = ElasticKnnSearch('my_index', embedding) >>> es_search.add_texts(['Hello world!', 'Another text']) >>> results = es_search.knn_search('Hello') [(Document(page_cont...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-2
Type str, optional Usage:>>> from embeddings import Embeddings >>> embedding = Embeddings.load('glove') >>> es_search = ElasticKnnSearch('my_index', embedding) >>> es_search.add_texts(['Hello world!', 'Another text']) >>> results = es_search.knn_search('Hello') [(Document(page_content='Hello world!', metadata={}), 0.9)...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-3
Return docs most similar to query using specified search type. asimilarity_search(query[, k]) Return docs most similar to query. asimilarity_search_by_vector(embedding[, k]) Return docs most similar to embedding vector. asimilarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1]...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-4
similarity_search_with_score(query[, k]) Pass through to knn_search including score __init__(index_name: str, embedding: Embeddings, es_connection: Optional['Elasticsearch'] = None, es_cloud_id: Optional[str] = None, es_user: Optional[str] = None, es_password: Optional[str] = None, vector_query_field: Optional[str] = '...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-5
to associate with the texts. model_id (str, optional) – The ID of the model to use for transforming the texts into vectors. refresh_indices (bool, optional) – Whether to refresh the Elasticsearch indices after adding the texts. **kwargs – Arbitrary keyword arguments. Returns A list of IDs for the added texts. async ade...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-6
Return VectorStoreRetriever initialized from this VectorStore. Parameters search_type (Optional[str]) – Defines the type of search that the Retriever should perform. Can be “similarity” (default), “mmr”, or “similarity_score_threshold”. search_kwargs (Optional[Dict]) – Keyword arguments to pass to the search function. ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-7
docsearch.as_retriever( search_kwargs={'filter': {'paper_title':'GPT-4 Technical Report'}} ) async asearch(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. async asimilarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document]¶ R...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-8
Delete by vector ID or other criteria. Parameters ids – List of ids to delete. **kwargs – Other keyword arguments that subclasses might use. Returns True if deletion is successful, False otherwise, None if not implemented. Return type Optional[bool] classmethod from_documents(documents: List[Document], embedding: Embed...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-9
Perform a hybrid k-NN and text search on the Elasticsearch index. Parameters query (str, optional) – The query text to search for. k (int, optional) – The number of nearest neighbors to return. query_vector (List[float], optional) – The query vector to search for. model_id (str, optional) – The ID of the model to use f...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-10
query_vector (List[float], optional) – The query vector to search for. model_id (str, optional) – The ID of the model to use for transforming the query text into a vector. size (int, optional) – The number of search results to return. source (bool, optional) – Whether to return the source of the search results. fields ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-11
Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters embedding – Embedding to look up documents similar to. k – Number of Documents to return. Defaults to 4. fetch_k – Number of Documents to fetch to pass to MMR algorithm. lambda_mult – Number between 0 and 1 t...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
316b771b376a-12
filter the resulting set of retrieved docs Returns List of Tuples of (doc, similarity_score) similarity_search_with_score(query: str, k: int = 10, **kwargs: Any) → List[Tuple[Document, float]][source]¶ Pass through to knn_search including score
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elastic_vector_search.ElasticKnnSearch.html
ff97be09cfdb-0
langchain.vectorstores.neo4j_vector.SearchType¶ class langchain.vectorstores.neo4j_vector.SearchType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶ Enumerator of the Distance strategies. VECTOR = 'vector'¶ HYBRID = 'hybrid'¶
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.neo4j_vector.SearchType.html
add3c1fbb7b3-0
langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch¶ class langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch(doc_index: BaseDocIndex, embedding: Embeddings)[source]¶ In-memory DocArray storage for exact search. To use it, you should have the docarray package with version >=0.32.0 installed. ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch.html
add3c1fbb7b3-1
Return docs most similar to query using specified search type. asimilarity_search(query[, k]) Return docs most similar to query. asimilarity_search_by_vector(embedding[, k]) Return docs most similar to embedding vector. asimilarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1]...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch.html
add3c1fbb7b3-2
Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. Returns List of IDs of the added texts. Return type List[str] async aadd_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) → List[str]¶ Run...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch.html
add3c1fbb7b3-3
Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶ Return VectorStore initialized from texts and embeddings. async amax_marginal_relevance_search(query: str, k: int = 4, fetch_...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch.html
add3c1fbb7b3-4
Return type VectorStoreRetriever Examples: # Retrieve more documents with higher diversity # Useful if your dataset has many similar documents docsearch.as_retriever( search_type="mmr", search_kwargs={'k': 6, 'lambda_mult': 0.25} ) # Fetch more documents for the MMR algorithm to consider # But only return the t...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch.html
add3c1fbb7b3-5
Return docs and relevance scores in the range [0, 1], asynchronously. 0 is dissimilar, 1 is most similar. Parameters query – input text k – Number of Documents to return. Defaults to 4. **kwargs – kwargs to be passed to similarity search. Should include: score_threshold: Optional, a floating point value between 0 to 1 ...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch.html
add3c1fbb7b3-6
**kwargs – Other keyword arguments to be passed to the get_doc_cls method. classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[Dict[Any, Any]]] = None, **kwargs: Any) → DocArrayInMemorySearch[source]¶ Create an DocArrayInMemorySearch store and insert data. Parameters texts (List[str...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch.html
add3c1fbb7b3-7
Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. max_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevan...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch.html
add3c1fbb7b3-8
Returns List of Documents most similar to the query vector. similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶ Return docs and relevance scores in the range [0, 1]. 0 is dissimilar, 1 is most similar. Parameters query – input text k – Number of Documents to re...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.docarray.in_memory.DocArrayInMemorySearch.html
b1b9609ea896-0
langchain.vectorstores.tiledb.get_documents_array_uri¶ langchain.vectorstores.tiledb.get_documents_array_uri(uri: str) → str[source]¶
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.tiledb.get_documents_array_uri.html
888d179489b8-0
langchain.vectorstores.dashvector.DashVector¶ class langchain.vectorstores.dashvector.DashVector(collection: Any, embedding: Embeddings, text_field: str)[source]¶ DashVector vector store. To use, you should have the dashvector python package installed. Example from langchain.vectorstores import dashvector from langchai...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.dashvector.DashVector.html
888d179489b8-1
amax_marginal_relevance_search_by_vector(...) Return docs selected using the maximal marginal relevance. as_retriever(**kwargs) Return VectorStoreRetriever initialized from this VectorStore. asearch(query, search_type, **kwargs) Return docs most similar to query using specified search type. asimilarity_search(query[, k...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.dashvector.DashVector.html
888d179489b8-2
Initialize with DashVector collection. async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. Returns List of IDs of the added texts. Return type List[...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.dashvector.DashVector.html
888d179489b8-3
**kwargs – Other keyword arguments that subclasses might use. Returns True if deletion is successful, False otherwise, None if not implemented. Return type Optional[bool] async classmethod afrom_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documen...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.dashvector.DashVector.html
888d179489b8-4
fetch_k: Amount of documents to pass to MMR algorithm (Default: 20) lambda_mult: Diversity of results returned by MMR; 1 for minimum diversity and 0 for maximum. (Default: 0.5) filter: Filter by document metadata Returns Retriever class for VectorStore. Return type VectorStoreRetriever Examples: # Retrieve more documen...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.dashvector.DashVector.html
888d179489b8-5
Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to embedding vector. async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶ Return docs and r...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.dashvector.DashVector.html
888d179489b8-6
Return DashVector VectorStore initialized from texts and embeddings. This is the quick way to get started with dashvector vector store. Example from langchain.vectorstores import DashVector from langchain.embeddings import OpenAIEmbeddings import dashvector embeddings = OpenAIEmbeddings() dashvector = DashVector.from_d...
lang/api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.dashvector.DashVector.html