Skip to content

Conversation

@jonathan-buttner
Copy link
Contributor

@jonathan-buttner jonathan-buttner commented Feb 7, 2025

This PR adds the elser v2 default inference endpoint for EIS.

model id: elser-v2
default endpoint id: .elser-v2-elastic

Testing

  1. Run the model server locally
  2. Run the gateway locally

Request using the default endpoint

curl --location 'http://localhost:9200/_inference/sparse_embedding/.elser-v2-elastic' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <auth>' \
--data '{
    "input": "What is the weather in DC?"
}'

Example response

{
    "sparse_embedding": [
        {
            "is_truncated": false,
            "embedding": {
                "arizona": 0.004688698,
                "atmosphere": 0.44218868,
                "beautiful": 0.30036038,
                "best": 0.09538541,
                "climate": 1.3683774,
                "cold": 0.16555622,
                "continental": 0.0208058,
                "culture": 0.06171996,
                "d": 0.9625172,
                "dc": 2.7619488,
                "delaware": 0.081595294,
                "district": 1.6485157,
                "dr": 0.6397389,
                "forecast": 0.98528975,
                "geography": 0.22286704,
                "heat": 0.8082221,
                "humid": 0.9245074,
                "maryland": 0.97202545,
                "nearby": 0.03915935,
                "pollution": 0.013022495,
                "rain": 0.14599317,
                "season": 0.0049015363,
                "summer": 0.37453577,
                "te": 0.08253291,
                "temperature": 1.3041841,
                "tropical": 0.6053031,
                "usa": 0.5448736,
                "virginia": 0.91435903,
                "washington": 2.0816846,
                "weather": 2.705098,
                "winter": 0.6765218
            }
        }
    ]
}

@jonathan-buttner jonathan-buttner added :ml Machine learning Team:ML Meta label for the ML team auto-backport Automatically create backport pull requests when merged v8.19.0 v9.1.0 labels Feb 7, 2025
@jonathan-buttner jonathan-buttner marked this pull request as ready for review February 10, 2025 13:48
@elasticsearchmachine
Copy link
Collaborator

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

private Set<String> getAuthorizedDefaultModelIds(ElasticInferenceServiceAuthorization auth) {
var authorizedModels = auth.getAuthorizedModelIds();
var authorizedDefaultModelIds = new HashSet<>(defaultModelsConfigs.keySet());
var authorizedDefaultModelIds = new TreeSet<>(defaultModelsConfigs.keySet());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using a TreeSet to ensure sorting for tests

configuration = new Configuration(authRef.get().taskTypesAndModels.getAuthorizedTaskTypes());

defaultConfigIds().forEach(modelRegistry::addDefaultIds);
defaultConfigIds().forEach(modelRegistry::putDefaultIdIfAbsent);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I'm using putDefaultIdIfAbsent is because we have some integration tests that use the same model registry to test revoking the authorization. addDefaultIds throws an IllegalStateException when you attempt to add the same default id which for tests we don't want to do.

In production this shouldn't be an issue because this will only be called when a node starts which will have a completely empty model registry anyway.

@elasticsearchmachine
Copy link
Collaborator

Hi @jonathan-buttner, I've created a changelog YAML for you.

Copy link
Contributor

@maxjakob maxjakob left a comment

Choose a reason for hiding this comment

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

The values look right 👍
For code changes I would defer to @davidkyle

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

@jonathan-buttner jonathan-buttner merged commit b9d1222 into elastic:main Feb 12, 2025
17 checks passed
@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 122066

@jonathan-buttner
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Questions ?

Please refer to the Backport tool documentation

jonathan-buttner added a commit to jonathan-buttner/elasticsearch that referenced this pull request Feb 12, 2025
* Adding elser default endpoint

* [CI] Auto commit changes from spotless

* Fixing test and allowing duplicate calls

* [CI] Auto commit changes from spotless

* Update docs/changelog/122066.yaml

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
(cherry picked from commit b9d1222)

# Conflicts:
#	x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetModelsWithElasticInferenceServiceIT.java
@jonathan-buttner jonathan-buttner deleted the ml-eis-elser-default-endpoint branch February 12, 2025 14:46
elasticsearchmachine pushed a commit that referenced this pull request Feb 12, 2025
* Adding elser default endpoint

* [CI] Auto commit changes from spotless

* Fixing test and allowing duplicate calls

* [CI] Auto commit changes from spotless

* Update docs/changelog/122066.yaml

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
(cherry picked from commit b9d1222)

# Conflicts:
#	x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetModelsWithElasticInferenceServiceIT.java
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.

4 participants