CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-dev-langchain4j--langchain4j-bedrock

AWS Bedrock integration for LangChain4j enabling Java applications to interact with various LLM providers through a unified interface

Overview
Eval results
Files

embedding-models.mddocs/api/

API: Embedding Models

Cohere and Amazon Titan embedding models for AWS Bedrock.

BedrockCohereEmbeddingModel

Cohere embedding model supporting English and multilingual variants.

public class BedrockCohereEmbeddingModel extends DimensionAwareEmbeddingModel {
    public BedrockCohereEmbeddingModel(Builder builder);

    // Core methods
    public Response<List<Embedding>> embedAll(List<TextSegment> textSegments);

    // Builder
    public static Builder builder();
}

BedrockCohereEmbeddingModel.Builder

public static class Builder {
    public Builder model(Model model);
    public Builder model(String model);
    public Builder inputType(InputType inputType);
    public Builder inputType(String inputType);
    public Builder truncate(Truncate truncate);
    public Builder truncate(String truncate);
    public Builder client(BedrockRuntimeClient client);
    public Builder region(Region region);
    public Builder credentialsProvider(AwsCredentialsProvider credentialsProvider);
    public Builder maxRetries(Integer maxRetries);
    public Builder maxSegmentsPerBatch(Integer maxSegmentsPerBatch);

    public BedrockCohereEmbeddingModel build();
}

Enums

public enum Model {
    COHERE_EMBED_ENGLISH_V3("cohere.embed-english-v3"),
    COHERE_EMBED_MULTILINGUAL_V3("cohere.embed-multilingual-v3");

    public String getValue();
}

public enum InputType {
    SEARCH_DOCUMENT("search_document"),
    SEARCH_QUERY("search_query"),
    CLASSIFICATION("classification"),
    CLUSTERING("clustering");

    public String getValue();
}

public enum Truncate {
    NONE("NONE"),
    START("START"),
    END("END");

    public String getValue();
}

BedrockTitanEmbeddingModel

Amazon Titan embedding model supporting v1 and v2 variants.

public class BedrockTitanEmbeddingModel extends AbstractBedrockEmbeddingModel<BedrockTitanEmbeddingResponse> {
    // Core methods
    public Response<List<Embedding>> embedAll(List<TextSegment> textSegments);
    public String getModel();
    public Integer getDimensions();
    public Boolean getNormalize();
    public Region getRegion();
    public AwsCredentialsProvider getCredentialsProvider();
    public Integer getMaxRetries();

    // Builder
    public static BedrockTitanEmbeddingModelBuilder<?, ?> builder();
}

BedrockTitanEmbeddingModelBuilder

public abstract static class BedrockTitanEmbeddingModelBuilder<B extends BedrockTitanEmbeddingModelBuilder<B, C>, C> {
    public B model(String model);
    public B dimensions(Integer dimensions);
    public B normalize(Boolean normalize);
    public B client(BedrockRuntimeClient client);
    public B region(Region region);
    public B credentialsProvider(AwsCredentialsProvider credentialsProvider);
    public B maxRetries(Integer maxRetries);

    public abstract C build();
}

Types Enum

public enum Types {
    TitanEmbedTextV1("amazon.titan-embed-text-v1"),
    TitanEmbedTextV2("amazon.titan-embed-text-v2:0");

    public String getValue();
}

Comparison Table

FeatureCohere English V3Cohere Multilingual V3Titan V1Titan V2
Dimensions1024 (fixed)1024 (fixed)1536 (fixed)256/512/1024 (configurable)
LanguagesEnglish100+EnglishEnglish
Input Types4 types4 typesN/AN/A
Truncation3 modes3 modesAutomaticAutomatic
NormalizationNoNoNoOptional
Max Input Tokens51251281928192
Max Batch Size969611

Key Parameters

Cohere:

  • model: COHERE_EMBED_ENGLISH_V3 or COHERE_EMBED_MULTILINGUAL_V3
  • inputType: SEARCH_DOCUMENT, SEARCH_QUERY, CLASSIFICATION, or CLUSTERING
  • truncate: NONE, START, or END
  • maxSegmentsPerBatch: Up to 96 segments per request

Titan:

  • model: TitanEmbedTextV1 or TitanEmbedTextV2
  • dimensions: 256, 512, or 1024 (V2 only)
  • normalize: true/false (V2 only)

Related:

  • Embeddings Quick Start
  • Semantic Search Guide
  • Model Selection

Install with Tessl CLI

npx tessl i tessl/maven-dev-langchain4j--langchain4j-bedrock

docs

api

chat-models.md

embedding-models.md

parameters.md

index.md

README.md

tile.json