Teradata Package for LangChain Function Reference - set_hnsw_search_params - 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.set_hnsw_search_params = set_hnsw_search_params(self, **kwargs)
- DESCRIPTION:
Sets the HNSW search parameters for the vector store.
PARAMETERS:
metric:
Optional Argument.
Specifies the metric to be used for calculating the distance
between the vectors.
Default Value: COSINE
Permitted Values: EUCLIDEAN, COSINE, DOTPRODUCT
Types: str
search_algorithm:
Optional Argument.
Specifies the algorithm to be used for searching the
tables and views relevant to the question.
Default Value: VECTORDISTANCE
Permitted Values: VECTORDISTANCE, KMEANS, HNSW
Types: str
top_k:
Optional Argument.
Specifies the number of top clusters to be considered while searching.
Default Value: 10
Permitted Values: [1, 1024]
Types: int
rerank_weight:
Optional Argument.
Specifies the weight to be used for reranking the search results.
Applicable range is 0.0 to 1.0.
Default Value: 0.2
Types: float
relevance_top_k:
Optional Argument.
Specifies the number of top similarity matches to be considered for reranking.
Applicable range is 1 to 1024.
Default Value: max(top_k*2, 60)
Permitted Values: [1, 1024]
Types: int
relevance_search_threshold:
Optional Argument.
Specifies the threshold value to consider matching tables/views while reranking.
A higher threshold value limits responses to the top matches only.
Types: float
maximal_marginal_relevance:
Optional Argument.
Specifies whether to use Maximal Marginal Relevance (MMR) for retrieving documents.
Types: bool
lambda_multiplier:
Optional Argument.
Specifies lambda multiplier to control the trade-off between relevance and diversity when selecting documents.
Permitted Values: 0.0 to 1.0
Types: float
ef_search:
Optional Argument.
Specifies the number of neighbors to be considered during search
in HNSW graph.
Note:
Applicable when "search_algorithm" is 'HNSW'.
Default Value: 32
Permitted Values: [1, 1024]
Types: int
num_layer:
Optional Argument.
Specifies the maximum number of layers for the HNSW graph.
Note:
Applicable when "search_algorithm" is 'HNSW'.
Permitted Values: [1, 1024]
Types: int
ef_construction:
Optional Argument.
Specifies the number of neighbors to be considered during
construction of the HNSW graph.
Note:
Applicable when "search_algorithm" is 'HNSW'.
Default Value: 32
Permitted Values: [1, 1024]
Types: int
num_connpernode:
Optional Argument.
Specifies the number of connections per node in the HNSW graph
during construction.
Note:
Applicable when "search_algorithm" is 'HNSW'.
Default Value: 32
Permitted Values: [1, 1024]
Types: int
maxnum_connpernode:
Optional Argument.
Specifies the maximum number of connections per node in the
HNSW graph during construction.
Note:
Applicable when "search_algorithm" is 'HNSW'.
Default Value: 32
Permitted Values: [1, 1024]
Types: int
apply_heuristics:
Optional Argument.
Specifies whether to apply heuristics optimizations during construction
of the HNSW graph.
Note:
Applicable when "search_algorithm" is 'HNSW'.
Default Value: True
Types: bool
num_nodes_per_graph:
Optional Argument.
Specifies the number of nodes per graph in the HNSW construction.
Note:
Applicable when "search_algorithm" is 'HNSW'.
Permitted Values: [1-2147483647]
Types: int
RETURNS:
None.
RAISES:
TeradataMlException.
EXAMPLES:
# Load necessary imports.
>>> from langchain_teradata import TeradataVectorStore
>>> from teradatagenai import load_data
# Load data into the vector store.
>>> load_data("amazon", "amazon_reviews_25")
# Note this step is not needed if vector store already exists.
>>> vs = TeradataVectorStore.from_datasets(name = "tdvs_hnsw",
data="amazon_reviews_25",
key_columns=['rev_id', 'aid'],
data_columns=['rev_text'],
embedding = "amazon.titan-embed-text-v1",
)
# Set the HNSW search parameters.
>>> vs.set_hnsw_search_params(ef_search=32,
ef_construction=32,
apply_heuristics=True)