Learn which parameters you can change for which components and how to pass them.
Defining Parameters in YAML and in the REST API
Parameters in pipeline YAML are the init parameters you can specify for the components, either when creating a pipeline in deepset Cloud or when uploading a ready-made YAML through a REST API endpoint.
Runtime parameters in the REST API are request body parameters you define when making a request with the Search REST API endpoint. You can configure these parameters for all the components in the pipeline, or you can target specific components. See the reference documentation for a particular component in this section to check the parameters you can modify. If no REST API parameters are listed for a component, it means you can't define any runtime parameters for it.
Passing YAML Parameters
You customize these parameters in the components
section of the YAML, in the init_parameters
object for a particular component, like this:
components:
componentName:
type: componentType
init_parameters:
param1: value1
param2: value2
The name is a custom name you give to a pipeline component. The type is the path to the component, you can check it on the component's documentation page.
Examples
This example shows how to customize OpenSearchEmbeddingRetriever in the YAML:
embedding_retriever: # Selects the most similar documents from the document store
type: haystack_integrations.components.retrievers.opensearch.embedding_retriever.OpenSearchEmbeddingRetriever
init_parameters:
document_store:
init_parameters:
use_ssl: True
verify_certs: False
http_auth:
- "${OPENSEARCH_USER}"
- "${OPENSEARCH_PASSWORD}"
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
top_k: 20 # The number of results to return
Passing Runtime Parameters to the REST API
You can pass runtime parameters to influence the behavior of nodes in a pipeline when it's executed. To do this, pass the name of the node whose parameter you want to change together with the dictionary of the parameters, like this:
payload = {
"init_parameters": {
"node_name":{
"param1": value1,
"param2": value2
},
},
}
You can also do this for multiple nodes at once. Simply pass the names of the nodes and the parameters you want to modify:
payload = {
"params": {
"node1_name":{
"param1": value1,
"param2": value2
},
"node2_name":{
"param": value
},
"node3_name":{
"param3": value3
},
},
}
To pass a parameter to all nodes in a pipeline, use the parameter name and value without listing node names:
payload = {
"params": {
"param": value,
"param2": value2
}
}
The parameters are applied to all nodes that accept them and are ignored for all other nodes.
Examples
Customizing a Single Node
In this example, we're changing the EmbeddingRetriever's top_k
parameter that determines the number of documents the retriever fetches from the document store:
payload = {
"debug": True,
"params": {
"EmbeddingRetriever":{
"top_k": 2
},
},
"queries": ["Where does Horned sungem live?"]
}
Customizing Multiple Nodes
This example passes different parameters to the EmbeddingRetriever
, Reranker
, and Generator
nodes:
payload = {
"debug": True,
"params": {
"EmbeddingRetriever":{
"top_k": 10
},
"Reranker":{
"top_k": 4
},
"Generator":{
"max_tokens": 500
},
},
"queries": ["Where does Horned sungem live?"]
}