Skip to content

[WIP] Support additional output formats for sparse models #3863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yuye-aws
Copy link
Member

@yuye-aws yuye-aws commented May 21, 2025

Description

This PR supports the sparse model return token_id instead of the token itself. Here is the steps to test this PR:

First, register a sparse model.

POST /_plugins/_ml/models/_register?deploy=true
{
  "name": "amazon/neural-sparse/opensearch-neural-sparse-encoding-doc-v2-distill",
  "version": "1.0.0",
  "model_format": "TORCH_SCRIPT"
}

After deploying it, you can test with the following prediction.

POST _plugins/_ml/models/c6T08ZYBhR-bMOVBD8AJ/_predict
{
  "text_docs": ["hello world"],
  "parameters": {
    "sparse_encoding_format": "int"
  }
}

You'll obtain the following results:

{
  "inference_results": [
    {
      "output": [
        {
          "name": "output",
          "dataAsMap": {
            "response": [
              {
                "999": 0.07596276,
                "1007": 0.23728506,
                "1010": 0.2664351,
                "1012": 0.51118666,
                "1027": 0.07092948,
                "1028": 0.09307969,
                "1029": 0.7082903,
                "1030": 0.14336383,
                "1033": 0.21647291,
                ...
              }
            ]
          }
        }
      ]
    }
  ]
}

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@yuye-aws yuye-aws had a problem deploying to ml-commons-cicd-env-require-approval May 21, 2025 09:03 — with GitHub Actions Failure
@yuye-aws yuye-aws had a problem deploying to ml-commons-cicd-env-require-approval May 21, 2025 09:03 — with GitHub Actions Error
@yuye-aws yuye-aws had a problem deploying to ml-commons-cicd-env-require-approval May 21, 2025 09:03 — with GitHub Actions Error
@yuye-aws yuye-aws had a problem deploying to ml-commons-cicd-env-require-approval May 21, 2025 09:03 — with GitHub Actions Failure
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
@yuye-aws yuye-aws force-pushed the Feat/SparseIntToken branch from b79faef to 6800532 Compare May 21, 2025 09:08
@yuye-aws yuye-aws had a problem deploying to ml-commons-cicd-env-require-approval May 21, 2025 09:10 — with GitHub Actions Failure
@yuye-aws yuye-aws had a problem deploying to ml-commons-cicd-env-require-approval May 21, 2025 09:10 — with GitHub Actions Error
@yuye-aws yuye-aws had a problem deploying to ml-commons-cicd-env-require-approval May 21, 2025 09:10 — with GitHub Actions Error
@yuye-aws yuye-aws had a problem deploying to ml-commons-cicd-env-require-approval May 21, 2025 09:10 — with GitHub Actions Failure
@yuye-aws yuye-aws marked this pull request as draft May 21, 2025 09:14
@yuye-aws yuye-aws changed the title POC: Support sparse model return token_id [WIP] Support sparse model return token_id May 21, 2025
@yuye-aws yuye-aws changed the title [WIP] Support sparse model return token_id [WIP] Support additional output formats for sparse models May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant