Skip to content

Commit

Permalink
Update pipelines.js to allow for token_embeddings as well
Browse files Browse the repository at this point in the history
In recent examples of optimum pipeline export the feature extraction pipelines have their output state as `token_embeddings` instead of `last_hidden_state`.

So we should support this as well.
  • Loading branch information
NikhilVerma committed May 22, 2024
1 parent 0af1e2f commit c87a0b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ export class FeatureExtractionPipeline extends (/** @type {new (options: TextPip
// console.log(outputs)

/** @type {Tensor} */
let result = outputs.last_hidden_state ?? outputs.logits;
let result = outputs.last_hidden_state ?? outputs.logits ?? outputs.token_embeddings;
if (pooling === 'none') {
// Skip pooling
} else if (pooling === 'mean') {
Expand Down Expand Up @@ -3282,4 +3282,4 @@ async function loadItems(mapping, model, pretrainedOptions) {
}

return result;
}
}

0 comments on commit c87a0b9

Please sign in to comment.