Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova authored Nov 19, 2023
1 parent 9b2315d commit 31ad34d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,13 @@ function seq2seqUpdatebeam(beam, newTokenId) {
* @private
*/
async function encoderForward(self, model_inputs) {
let encoderFeeds = {};
for (let key of self.session.inputNames) {
const encoderFeeds = Object.create(null);
for (const key of self.session.inputNames) {
encoderFeeds[key] = model_inputs[key];
}
if (!encoderFeeds.token_type_ids && self.session.inputNames.includes('token_type_ids')) {
if (self.session.inputNames.includes('token_type_ids') && !encoderFeeds.token_type_ids) {
// Assign default `token_type_ids` to the `encoderFeeds` if the model expects it,
// but they weren't created by the tokenizer.
add_token_types(encoderFeeds);
}
return await sessionRun(self.session, encoderFeeds);
Expand Down

0 comments on commit 31ad34d

Please sign in to comment.