Skip to content

Conversation

@ymao1
Copy link
Contributor

@ymao1 ymao1 commented Feb 5, 2025

Summary

Updates to get semantic search working with bit embeddings.

Verify

Following the instructions in this tutorial:

This will verify that the process of using a inference endpoint with binary embedding works with semantic text queries.

  1. Create a Cohere inference endpoint using bit embedding types
PUT _inference/text_embedding/cohere_bit
{
    "service": "cohere",
    "service_settings": {
        "api_key": <apiKey>,
        "model_id": "embed-english-v3.0",
        "embedding_type": "bit"
    }
}
  1. Create an index with a semantic text mapping using the inference ID
PUT semantic-embeddings-bit
{
  "mappings": {
    "properties": {
      "content": { 
        "type": "semantic_text",
        "inference_id": "cohere_bit"
      }
    }
  }
}
  1. Load data as directed by the the tutorial

  2. Reindex the data

POST _reindex?wait_for_completion=false
{
  "source": {
    "index": "test-data",
    "size": 100 
  },
  "dest": {
    "index": "semantic-embeddings-bit"
  }
}
  1. Run a query
GET semantic-embeddings-bit/_search
{
  "query": {
    "semantic": {
      "field": "content", 
      "query": "How to avoid muscle soreness while running?" 
    }
  }
}

Copy link
Member

@davidkyle davidkyle left a comment

Choose a reason for hiding this comment

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

LGTM

@davidkyle davidkyle added the cloud-deploy Publish cloud docker image for Cloud-First-Testing label Feb 12, 2025
@ymao1 ymao1 changed the title More cohere bits Updates to allow using Cohere binary embedding response in semantic search queries. Feb 12, 2025
@ymao1 ymao1 self-assigned this Feb 12, 2025
@ymao1 ymao1 added >bug v8.19.0 :ml Machine learning Team:ML Meta label for the ML team labels Feb 12, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@ymao1
Copy link
Contributor Author

ymao1 commented Feb 12, 2025

Waiting for @davidkyle to give a 👍 after running some validation tests.

: inference.length;
if (inferenceLength != modelSettings.dimensions()) {
throw new IllegalArgumentException(
generateDimensionCountMismatchMessage(inference.length, modelSettings.dimensions())
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make sure to update this error message with the correct dimension count as well

@ymao1 ymao1 marked this pull request as ready for review February 22, 2025 16:19
@elasticsearchmachine
Copy link
Collaborator

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

@Mikep86 Mikep86 added the auto-backport Automatically create backport pull requests when merged label Feb 24, 2025
@ymao1 ymao1 merged commit e843849 into elastic:main Feb 25, 2025
18 checks passed
@ymao1 ymao1 deleted the more-cohere-bits branch February 25, 2025 14:14
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 121827

@ymao1
Copy link
Contributor Author

ymao1 commented Feb 25, 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 Feb 25, 2025
…earch queries. (elastic#121827)

* wip

* wip

* [CI] Auto commit changes from spotless

* updating tests

* [CI] Auto commit changes from spotless

* Update docs/changelog/121827.yaml

* Updates after the refactor

* [CI] Auto commit changes from spotless

* Updating error message

---------

Co-authored-by: elasticsearchmachine <[email protected]>
(cherry picked from commit e843849)

# Conflicts:
#	x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/results/InferenceTextEmbeddingBitResults.java
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/chunking/EmbeddingRequestChunkerTests.java
@ymao1
Copy link
Contributor Author

ymao1 commented Feb 27, 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 Feb 27, 2025
…earch queries. (elastic#121827)

* wip

* wip

* [CI] Auto commit changes from spotless

* updating tests

* [CI] Auto commit changes from spotless

* Update docs/changelog/121827.yaml

* Updates after the refactor

* [CI] Auto commit changes from spotless

* Updating error message

---------

Co-authored-by: elasticsearchmachine <[email protected]>
(cherry picked from commit e843849)

# Conflicts:
#	x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/results/TextEmbeddingBitResults.java
elasticsearchmachine pushed a commit that referenced this pull request Feb 27, 2025
…ntic search queries. (#121827) (#123625)

* Updates to allow using Cohere binary embedding response in semantic search queries. (#121827)

* wip

* wip

* [CI] Auto commit changes from spotless

* updating tests

* [CI] Auto commit changes from spotless

* Update docs/changelog/121827.yaml

* Updates after the refactor

* [CI] Auto commit changes from spotless

* Updating error message

---------

Co-authored-by: elasticsearchmachine <[email protected]>
(cherry picked from commit e843849)

# Conflicts:
#	x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/results/TextEmbeddingBitResults.java

* Fixing compile error
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 >bug cloud-deploy Publish cloud docker image for Cloud-First-Testing :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.

4 participants