Skip to content

feat: add embed task for text embeddings - #178

Merged
Nina-mvH merged 9 commits into
mainfrom
3-add-embeddings-task
Jul 28, 2026
Merged

feat: add embed task for text embeddings#178
Nina-mvH merged 9 commits into
mainfrom
3-add-embeddings-task

Conversation

@Nina-mvH

@Nina-mvH Nina-mvH commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Adds an initial implementation of an embed task (currently only supports text inputs and .npy outputs)

Tested with sentence-transformers/all-MiniLM-L6-v2

Deferred

Open design question

This task does not fall neatly into the text grouping -- it will support all input types and outputs embeddings; it seems like the task should not live in a sub-folder?

@Nina-mvH Nina-mvH linked an issue Jul 7, 2026 that may be closed by this pull request
6 tasks
@Nina-mvH
Nina-mvH marked this pull request as ready for review July 7, 2026 19:06
@Nina-mvH Nina-mvH changed the title feat: adds initial embed task feat: add initial embed task Jul 8, 2026
@Nina-mvH Nina-mvH added the feature New feature or request label Jul 10, 2026

@cswaney cswaney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for merge after the following updates:

  • Remove per-line
  • Replace prompt and prompt-name with kwargs
  • Add use_encode_document = False params to top into encode_document. Also, explains what encode_document does more precisely.

@Nina-mvH
Nina-mvH force-pushed the 3-add-embeddings-task branch from 4b92a1d to 0a6c8b2 Compare July 28, 2026 16:22
@Nina-mvH Nina-mvH changed the title feat: add initial embed task feat: add embed task for text embeddings Jul 28, 2026
@cswaney
cswaney self-requested a review July 28, 2026 16:39
@Nina-mvH

Copy link
Copy Markdown
Contributor Author

What encode_document does

If the provided model has a Router module and was trained to embed "documents" differently from "queries", using encode_document routes inputs to a processing modules which is specifically trained to embed documents (inputs are automatically tagged as "document").

So, when the documentation explains:

This method is a specialized version of encode() that differs in exactly two ways:

  1. If no prompt_name or prompt is provided, it uses the first available prompt from the following candidates: "document", "passage", "corpus" (checked in that order).
  2. It sets the task to “document”. If the model has a Router module, it will use the “document” task type to route the input through the appropriate submodules.

This means:

  1. The input text is tagged as "document" (or "passage"/"corpus" depending on what the model recognizes). This will tell the router that the input is the passage/corpus side of a retrieval pair.
  2. The router (if the model has one) will recognize that the input is a "document" and will send the input to a specialized submodule which is set up specifically for the document role. This would be different from the "query" submodule or generic encoding. The differences between these submodules are model dependent.

When to use it

Using encode_document primarily makes sense when you want to encode documents with the intention of querying them (with encode_query). If you are simply encoding a long input (for purposes other than retrieval), just use encode

@Nina-mvH
Nina-mvH merged commit 3f503ca into main Jul 28, 2026
8 checks passed
@Nina-mvH
Nina-mvH deleted the 3-add-embeddings-task branch July 28, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New task: embeddings

2 participants