Teradata Package for LangChain Function Reference - set_kmeans_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_kmeans_search_params = set_kmeans_search_params(self, **kwargs)
- DESCRIPTION:
Sets the KMEANS 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
initial_centroids_method:
Optional Argument.
Specifies the algorithm to be used for initializing the
centroids.
Note:
Applicable when "search_algorithm" is 'KMEANS'.
Default Value: RANDOM
Permitted Values: RANDOM, KMEANS++
Types: str
train_numcluster:
Optional Argument.
Specifies the number of clusters to be trained.
Note:
Applicable when "search_algorithm" is 'KMEANS'.
Types: int
max_iternum:
Optional Argument.
Specifies the maximum number of iterations to be run during
training.
Note:
Applicable when "search_algorithm" is 'KMEANS'.
Default Value: 10
Permitted Values: [1, 2147483647]
Types: int
stop_threshold:
Optional Argument.
Specifies the threshold value at which training should be
stopped.
Note:
Applicable when "search_algorithm" is 'KMEANS'.
Default Value: 0.0395
Types: float
seed:
Optional Argument.
Specifies the seed value to be used for random number
generation.
Note:
Applicable when "search_algorithm" is 'KMEANS'.
Permitted Values: [0, 2147483647]
Types: int
num_init:
Optional Argument.
Specifies the number of times the k-means algorithm should
run with different initial centroid seeds.
Default Value: 1
Permitted Values: [1, 2147483647]
Types: int
search_threshold:
Optional Argument.
Specifies the threshold value to consider for matching tables/views
while searching. A higher threshold value limits responses to the top matches only.
Note:
Applicable when "search_algorithm" is 'VECTORDISTANCE' and 'KMEANS'.
Types: float
search_numcluster:
Optional Argument.
Specifies the number of clusters to be considered while
searching.
Note:
Applicable when "search_algorithm" is 'KMEANS'.
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_kmeans",
data="amazon_reviews_25",
key_columns=['rev_id', 'aid'],
data_columns=['rev_text'],
embedding = "amazon.titan-embed-text-v1",
)
# Set the KMEANS search parameters.
>>> vs.set_kmeans_search_params(train_numcluster=10,
max_iternum=100,
stop_threshold=0.01)