Skip to content

Node.js Incorrect output name mapping when using run() with a single output in fetches #26865

@uasan

Description

@uasan

Incorrect output name mapping when using run() with a single output in fetches

Description

When calling InferenceSession.run() with a single output specified in fetches, the returned output map contains incorrect keys.

Instead of returning the requested output name, the data is returned under a different output name, and the requested key is missing.


Expected behavior

session.run(feeds, ['sentence_embedding'])

The result should contain:

  • key: sentence_embedding
  • value: pooled embedding tensor with shape [B, 768]

Actual behavior

const res = await session.run(feeds, ['sentence_embedding']);

Returned result:

  • keys: ['last_hidden_state']
  • last_hidden_state.dims → [B, 768]
  • sentence_embedding → undefined

The data for sentence_embedding is incorrectly returned under last_hidden_state.


Control case (works correctly)

const res = await session.run(feeds);

Returned result:

  • last_hidden_state.dims → [B, L, 768]
  • sentence_embedding.dims → [B, 768]

Notes

  • Reproducible across multiple Node.js versions
  • Reproducible across multiple onnxruntime-node versions
  • Occurs when fetches is provided both as an array and as an object map

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform:webissues related to ONNX Runtime web; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions