This plugin adds the text embedding task (batched and non-batched) which allows you to represent natural language exerpts with a dense vector.
This plugin requires core and simple_plugin_manager as dependencies. For source, local and containerized installation instructions please see the main README.
To execute the task, a plugin which includes a model that supports the text embedding task should be installed.
Currently, the following models support text embedding:
To expose the task as an endpoint the fastapi plugin and one of the following apis should be installed:
As input this task requires the following fields:
Key | Required | Batched | Type | Description |
---|---|---|---|---|
text |
Yes | Yes | string data | The text which should be embedded |
config |
No | Yes | dict | Any additional arguments (see the model documentation) |
As ouput this task returns the following fields:
Key | Batched | Type | Description |
---|---|---|---|
embedding |
Yes | list of floats | The embedding |
When the task is executed in batched mode, the batched fields are given (or returned) as lists, whereas the non-batched fields are given as simple values.
For the /api/tasks/text-embedding/{model}/jobs
endpoint defined in base_api the following request body serves as an example:
{
"text": "a cat",
"config": {}
}
This returns:
{
"id": "05032039-e7dd-4ca5-8941-ebff9f5f2e09",
"status": "starting"
}
Later, the result can be retrieved using /api/tasks/text-embedding/jobs/05032039-e7dd-4ca5-8941-ebff9f5f2e09
:
{
"status": "complete",
"result": {
"embedding": [
-3.520469903945923,
-0.28723829984664917,
-0.47991180419921875,
-2.594832420349121,
...
]
}
}