Teradata Package for LangChain Function Reference - as_retriever - Teradata® Package for LangChain - Look here for syntax, methods and examples for the functions included in the Teradata langchain-teradata package.
Teradata® Package for LangChain Function Reference
- Deployment
- VantageCloud
- Edition
- Enterprise
- Product
- Teradata® Package for LangChain
- Release Number
- 20.00.00.01
- Published
- December 2025
- ft:locale
- en-US
- ft:lastEdition
- 2025-12-19
- dita:id
- Langchain-Teradata_FxRef_Lake
- Product Category
- Teradata Vantage
- libs.teradata.langchain_teradata.TeradataVectorStore.as_retriever = as_retriever(self, **kwargs)
- DESCRIPTION:
Creates and returns a TeradataVectorStoreRetriever
instance that can be used to retrieve relevant documents
from the vector store based on similarity search.
Note: Applicable for content-based , file-based and
embedding-based(only if metadata_columns is specified)
vector stores.
PARAMETERS:
search_type
Optional Argument
Specifies the type of search that the Retriever should perform.
Default Value: "similarity"
Permitted Values: "similarity", "similarity_score_threshold"
Types: str
Note:
* "similarity_score_threshold" will be supported in the future release.
search_kwargs
Optional Argument
Specifies additional parameters for the search operation.
Includes the following keys:
* top_k
Optional Argument
Specifies the number of top clusters to be considered while searching
Types: int
* score_threshold
Optional Argument. Required when search_type is "similarity_score_threshold".
Specifies the threshold value to consider for matching tables/views
while searching. A higher threshold value limits responses
to the top matches only.
Types: float
* search_numcluster:
Optional Argument.
Number of clusters or fraction of train_numcluster to be considered while searching.
Notes:
Applicable when "search_algorithm" is 'KMEANS'.
If you want to pass a fraction of train_numcluster to be used for searching,
the supported range is (0, 1.0].
If you want to pass the exact number of clusters to be used for searching,
the supported range is [1, train_numcluster].
Types: int or float
* ef_search:
Optional Argument.
Specify the number of neighbors to consider during search in HNSW graph.
Note:
Applicable when "search_algorithm" is 'HNSW'.
Permitted Values: [1 - 1024]
Types: int
* filter
Specifies the filter conditions to be applied to the document metadata.
Types: str
Types: dict
RETURNS:
TeradataVectorStoreRetriever.
RAISES:
ValueError.
EXAMPLES:
# Load necessary imports and data
>>> from langchain_teradata import TeradataVectorStore
>>> from teradatagenai import load_data
>>> amazon_data = load_data("amazon", "amazon_reviews_25")
# Note this step is not needed if vector store already exists
# Create an instance of a content-based vector store for
# the data in table 'amazon_reviews_25'.
>>> vs = TeradataVectorStore.from_datasets(name = "test_vs",
data = "amazon_reviews_25",
data_columns = "rev_text",
key_columns = ["rev_id", "aid"],
metadata_columns = ["rev_name"])
# Example 1: Create a basic instance of the TeradataVectorStoreRetriever.
# Instantiate an already present vector store.
>>> td_vs = TeradataVectorStore(name="test_vs")
>>> retriever = td_vs.as_retriever()
# Example 2: Create an instance of the TeradataVectorStoreRetriever
# with a search_type of "similarity_score_threshold",
# a threshold of 0.8.
>>> td_vs = TeradataVectorStore(name="test_Vs")
>>> retriever = td_vs.as_retriever(search_type="similarity_score_threshold",
search_kwargs={'score_threshold': 0.8})
# Example 3: Create an instance of the TeradataVectorStoreRetriever
# with a search_type of "similarity", a top_k of 5,
# and a filter condition on metadata.
>>> td_vs = TeradataVectorStore(name="test_Vs")
>>> retriever = td_vs.as_retriever(search_type="mmr",
search_kwargs={"top_k":5,
"filter" : "rev_name LIKE 'A%'"})