Skip to content

feat: Add Bedrock Embedding Support (v1.x) #6591

@lambda-science

Description

@lambda-science

Is your feature request related to a problem? Please describe.
Support for AWS Bedrock has been provided for PromptModel nodes, it could be usefull to provide it also from the EmbeddingRetriever as AWS BedRock provide not only access to LLM but also Embedding EndPoint (Cohere or AWS Titan), for Haystack v1.x

Describe the solution you'd like
For example in the YAML pipeline file :

  - name: Retriever
    type: EmbeddingRetriever
    params:
      document_store: DocumentStore
      embedding_model: text-embedding-ada-002
      top_k: 3
      batch_size: 8
      max_seq_len: 1536
      api_key: ${RETRIEVER_PARAMS_API_KEY}

We could change the embedding_model string to somethings like aws-titan or aws-cohere and provide AWS credentials as model_kwargs just like the PromptModel

Describe alternatives you've considered
Implementing it myself using a Hacky way that relies on LiteLLM to make call to AWS Bedrock by creating a custom EmbeddingRetriever component. Here is the idea:

  • Create a _BedRockEmbeddingEncoder that inherits from _OpenAIEmbeddingEncoder and add this to the _EMBEDDING_ENCODERS dict with an override of the embed method
  • Creating a BedrockEmbedding class that inherits from EmbeddingRetriever
  • Simply set at initialisation of the class a modified _EMBEDDING_ENCODERS dict that contains the new AWS-BedRock encoders

Additional context
I wanted to use LiteLLM because it provides a unified API to almost ALL LLM providers. I think it's a great backend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions