Skip to content

Handling of meta data is inconsistent between different embedding models. #2579

@schauder

Description

@schauder

OpenAiEmbeddingModel uses the following code for creating an embedding for a document:

@Override public float[] embed(Document document) { Assert.notNull(document, "Document must not be null"); return this.embed(document.getFormattedContent(this.metadataMode)); }

metadataModel controls if all, some or none of the metadata is included in constructing the String that then is used to create an embedding.
The default MetadataMode is EMBED which includes all fields, that aren't explicitly excluded.

OllamaEmbeddingModel on the other hand uses this implementation:

@Override public float[] embed(Document document) { return embed(document.getText()); }

This means metadata is not included at all.

I don't see a reason why this behaviour is different for different embedding models. It should be the same for all and only implemented once, possibly in AbstractEmbeddingModel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions