Workflow templates

OpenSearch provides several workflow templates for some common machine learning (ML) use cases. Using a template simplifies complex setups and provides many default values for use cases like semantic or conversational search.

You can specify a workflow template when you call the Create Workflow API:

To provision the workflow, specify provision=true as a query parameter.

Example

In this example, you’ll configure the semantic_search_with_cohere_embedding_query_enricher workflow template. The workflow created using this template performs the following configuration steps:

  • Deploys an externally hosted Cohere model
  • Creates an ingest pipeline using the model
  • Creates a sample k-NN index and configures a search pipeline to define the default model ID for that index

Step 1: Create and provision the workflow

Send the following request to create and provision a workflow using the semantic_search_with_cohere_embedding_query_enricher workflow template. The only required request body field for this template is the API key for the Cohere Embed model:

  1. POST /_plugins/_flow_framework/workflow?use_case=semantic_search_with_cohere_embedding_query_enricher&provision=true
  2. {
  3. "create_connector.credential.key" : "<YOUR API KEY>"
  4. }

copy

OpenSearch responds with a workflow ID for the created workflow:

  1. {
  2. "workflow_id" : "8xL8bowB8y25Tqfenm50"
  3. }

The workflow in the previous step creates a default k-NN index. The default index name is my-nlp-index:

  1. {
  2. "create_index.name": "my-nlp-index"
  3. }

For all default parameter values for this workflow template, see Cohere Embed semantic search defaults.

Step 2: Ingest documents into the index

To ingest documents into the index created in the previous step, send the following request:

  1. PUT /my-nlp-index/_doc/1
  2. {
  3. "passage_text": "Hello world",
  4. "id": "s1"
  5. }

copy

To perform a vector search on your index, use a neural query clause:

  1. GET /my-nlp-index/_search
  2. {
  3. "_source": {
  4. "excludes": [
  5. "passage_embedding"
  6. ]
  7. },
  8. "query": {
  9. "neural": {
  10. "passage_embedding": {
  11. "query_text": "Hi world",
  12. "k": 100
  13. }
  14. }
  15. }
  16. }

copy

Parameters

Each workflow template has a defined schema and a set of APIs with predefined default values for each step. For more information about template parameter defaults, see Supported workflow templates.

Overriding default values

To override a template’s default values, provide the new values in the request body when sending a create workflow request. For example, the following request changes the Cohere model, the name of the text_embedding processor output field, and the name of the sparse index of the semantic_search_with_cohere_embedding template:

  1. POST /_plugins/_flow_framework/workflow?use_case=semantic_search_with_cohere_embedding
  2. {
  3. "create_connector.model" : "embed-multilingual-v3.0",
  4. "text_embedding.field_map.output": "book_embedding",
  5. "create_index.name": "sparse-book-index"
  6. }

copy

Viewing workflow resources

The workflow you created provisioned all the necessary resources for semantic search. To view the provisioned resources, call the Get Workflow Status API and provide the workflowID for your workflow:

  1. GET /_plugins/_flow_framework/workflow/8xL8bowB8y25Tqfenm50/_status

copy

Supported workflow templates

The following table lists the supported workflow templates. To use a workflow template, specify it in the use_case query parameter when creating a workflow.

Template use caseDescriptionRequired parametersDefaults
bedrock_titan_embedding_model_deployCreates and deploys an Amazon Bedrock embedding model (by default, titan-embed-text-v1).create_connector.credential.access_key, create_connector.credential.secret_key, create_connector.credential.session_tokenDefaults
bedrock_titan_multimodal_model_deployCreates and deploys an Amazon Bedrock multimodal embedding model (by default, titan-embed-image-v1).create_connector.credential.access_key, create_connector.credential.secret_key, create_connector.credential.session_tokenDefaults.
cohere_embedding_model_deployCreates and deploys a Cohere embedding model (by default, embed-english-v3.0).create_connector.credential.keyDefaults
cohere_chat_model_deployCreates and deploys a Cohere chat model (by default, Cohere Command).create_connector.credential.keyDefaults
open_ai_embedding_model_deployCreates and deploys an OpenAI embedding model (by default, text-embedding-ada-002).create_connector.credential.keyDefaults
openai_chat_model_deployCreates and deploys an OpenAI chat model (by default, gpt-3.5-turbo).create_connector.credential.keyDefaults
local_neural_sparse_search_bi_encoderConfigures neural sparse search:
- Deploys a pretrained sparse encoding model.
- Creates an ingest pipeline with a sparse encoding processor.
- Creates a sample index to use for sparse search, specifying the newly created pipeline as the default pipeline.
NoneDefaults
semantic_searchConfigures semantic search:
- Creates an ingest pipeline with a text_embedding processor and a k-NN index
You must provide the model ID of the text embedding model to be used.
create_ingest_pipeline.model_idDefaults
semantic_search_with_query_enricherConfigures semantic search similarly to the semantic_search template. Adds a query_enricher search processor that sets a default model ID for neural queries. You must provide the model ID of the text embedding model to be used.create_ingest_pipeline.model_idDefaults
semantic_search_with_cohere_embeddingConfigures semantic search and deploys a Cohere embedding model. You must provide the API key for the Cohere model.create_connector.credential.keyDefaults
semantic_search_with_cohere_embedding_query_enricherConfigures semantic search and deploys a Cohere embedding model. Adds a query_enricher search processor that sets a default model ID for neural queries. You must provide the API key for the Cohere model.create_connector.credential.keyDefaults
multimodal_searchConfigures an ingest pipeline with a text_image_embedding processor and a k-NN index for multimodal search. You must provide the model ID of the multimodal embedding model to be used.create_ingest_pipeline.model_idDefaults
multimodal_search_with_bedrock_titanDeploys an Amazon Bedrock multimodal model and configures an ingest pipeline with a text_image_embedding processor and a k-NN index for multimodal search. You must provide your AWS credentials.create_connector.credential.access_key, create_connector.credential.secret_key, create_connector.credential.session_tokenDefaults
hybrid_searchConfigures hybrid search:
- Creates an ingest pipeline, a k-NN index, and a search pipeline with a normalization_processor. You must provide the model ID of the text embedding model to be used.
create_ingest_pipeline.model_idDefaults
conversational_search_with_llm_deployDeploys a large language model (LLM) (by default, Cohere Chat) and configures a search pipeline with a retrieval_augmented_generation processor for conversational search.create_connector.credential.keyDefaults
semantic_search_with_reindexConfigures semantic search with a newly deployed Cohere embedding model. The model is configured to reindex a source index into a newly configured k-NN index. You must provide the API key for the Cohere model along with the source index to be reindexed.create_connector.credential.key, reindex.source_indexDefaults
semantic_search_with_local_modelConfigures semantic search and deploys a pretrained model (msmarco-distilbert-base-tas-b). Adds a query_enricher search processor that sets a default model ID for neural queries and creates a linked k-NN index called my-nlp-index. You must provide the API key for the Cohere model.NoneDefaults
hybrid_search_with_local_modelConfigures hybrid search and deploys a pretrained model (msmarco-distilbert-base-tas-b). Creates an ingest pipeline, a k-NN index, and a search pipeline with a normalization_processor.NoneDefaults