Skip to content

Conversation

@ymao1
Copy link
Contributor

@ymao1 ymao1 commented Feb 3, 2025

Summary

Adding the ability to specify embedding_type in the Jina AI service settings when creating a Jina AI inference endpoint.

Usage

  • Not specifying an embedding_type will default to the float embedding type (same as previous behavior)
  • Allowed types: ['float', 'bit', 'binary']
  • Specifying embedding_type: 'bit' or embedding_type: 'binary' will return results in the text_embedding_bits key (same as Cohere)
# Create a Jina AI binary inference endpoint
PUT /_inference/text_embedding/jina_embeddings_bit
{
    "service": "jinaai",
    "service_settings": {
        "api_key": <apiKey>,
        "model_id": "jina-embeddings-v3",
        "embedding_type": "bit"
    }
}

# Perform an inference task
POST /_inference/text_embedding/jina_embeddings_bit
{
    "input": "hello",
    "task_settings": {
        "input_type": "ingest"
    }
}

# Response
{
    "text_embedding_bits": [
        {
            "embedding": [
                -55,
                74,
                101,
                67,
                83,
                1,
                53,
                -101,
                -71,
                -98,
                -116,
                -99,
                80,
                -49,
                65,
                .
                .
                .
            ]
        }
    ]
}

Notes

Same as Cohere, requesting a binary embedding from Jina AI will returns an array of binary embeddings packed as bytes with int8 precision. Since this aligns with what is expected as input when you specify a dense_vector mapping with element_type: bit, we do not perform any bit unpacking on the response and handle the bytes as-is.

@ymao1 ymao1 force-pushed the jina-bit-embeddings branch 3 times, most recently from 51f5fce to 00ba02e Compare February 4, 2025 19:18
@ymao1 ymao1 changed the title Jina bit embeddings Adding support for specifying embedding type to Jina AI service settings Feb 4, 2025
@ymao1 ymao1 force-pushed the jina-bit-embeddings branch from 00ba02e to d4e7a92 Compare February 4, 2025 19:26
@ymao1 ymao1 added v8.19.0 >enhancement :ml Machine learning Team:ML Meta label for the ML team labels Feb 4, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @ymao1, I've created a changelog YAML for you.

@ymao1 ymao1 marked this pull request as ready for review February 5, 2025 12:15
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

out.writeOptionalVInt(dimensions);
out.writeOptionalVInt(maxInputTokens);

if (out.getTransportVersion().onOrAfter(TransportVersions.JINA_AI_EMBEDDING_TYPE_SUPPORT_ADDED)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we use this if logic a few times how about we move it into its own function?

Something like isEmbeddingTypeSupported(TransportVersion version) or something like that.

@ymao1 ymao1 merged commit 6b2e566 into elastic:main Mar 3, 2025
17 checks passed
@ymao1 ymao1 deleted the jina-bit-embeddings branch March 3, 2025 18:00
@ymao1 ymao1 added the auto-backport Automatically create backport pull requests when merged label Mar 3, 2025
@ymao1
Copy link
Contributor Author

ymao1 commented Mar 4, 2025

💚 All backports created successfully

Status Branch Result
8.x

Questions ?

Please refer to the Backport tool documentation

ymao1 added a commit to ymao1/elasticsearch that referenced this pull request Mar 4, 2025
…ngs (elastic#121548)

* Adding embeddings type to Jina AI service settings

* Update docs/changelog/121548.yaml

* Setting default similarity to L2 norm for binary embedding type

(cherry picked from commit 6b2e566)

# Conflicts:
#	server/src/main/java/org/elasticsearch/TransportVersions.java
ymao1 added a commit that referenced this pull request Mar 4, 2025
… settings (#121548) (#124010)

* Adding support for specifying embedding type to Jina AI service settings (#121548)

* Adding embeddings type to Jina AI service settings

* Update docs/changelog/121548.yaml

* Setting default similarity to L2 norm for binary embedding type

(cherry picked from commit 6b2e566)

# Conflicts:
#	server/src/main/java/org/elasticsearch/TransportVersions.java

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <[email protected]>
georgewallace pushed a commit to georgewallace/elasticsearch that referenced this pull request Mar 11, 2025
…ngs (elastic#121548)

* Adding embeddings type to Jina AI service settings

* Update docs/changelog/121548.yaml

* Setting default similarity to L2 norm for binary embedding type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >enhancement :ml Machine learning Team:ML Meta label for the ML team v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants