feat(core): add semantic embedding text prefixes#1044
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f7198d58a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
7f7198d to
0818b8d
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Signed-off-by: Dmitry Golubev <lastguru@gmail.com>
Signed-off-by: phernandez <paul@basicmachines.co>
0818b8d to
5aebf7d
Compare
|
Thanks for the contribution — I rebased this onto current |
|
@codex review |
|
@codex recheck |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Adds optional role-specific literal text prefixes for semantic embeddings:
semantic_embedding_document_prefixsemantic_embedding_query_prefixThese prefixes are prepended to the actual text sent to the embedding provider:
Fixes #1008.
Why
Some embedding models require role-specific text prefixes as part of the input string, not as API parameters.
Examples include models where the recommended input format is something like:
title: none | text: ...task: search result | query: ...Basic Memory already supports LiteLLM
input_typesettings, but that only helps providers that understand an API-level role parameter. OpenAI-compatible endpoints such as TEI just receive theinputstrings, so prefix-sensitive models cannot currently be used in their recommended form without a proxy or local patch.Without this, retrieval quality evaluation is misleading: a model can look worse than it really is because documents and queries are embedded without the format it was trained/evaluated with.
Implementation
fastembed,openai, andlitellm.input_typeand literal text prefixes.Validation
201 passedfocused teststy check src tests test-intgit diff --check