Skip to content
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

How can I implement partial output in the react demo? #1035

Open
DikkooXie opened this issue Nov 17, 2024 · 0 comments
Open

How can I implement partial output in the react demo? #1035

DikkooXie opened this issue Nov 17, 2024 · 0 comments
Labels
question Further information is requested

Comments

@DikkooXie
Copy link

Question

Hello! I am reading the Transformers.js documentation for "Building a react application", but I encountered an issue at step 4.
I don't know how to implement the partial output of the translation results, even though the documentation provides the following instructions:

  let output = await translator(event.data.text, {
      tgt_lang: event.data.tgt_lang,
      src_lang: event.data.src_lang,

      // Allows for partial output
      callback_function: x => {
          self.postMessage({
              status: 'update',
              output: translator.tokenizer.decode(x[0].output_token_ids, { skip_special_tokens: true })
          });
      }
  });

I have completed all the steps in the tutorial documentation, but I still cannot get the output to work properly. I tried using console.log for debugging and found that the callback_function is not working, and the main thread is not receiving any messages with the status update. I have also not found any information about the callback_function in the transformers.js documentation. I apologize for taking up your time, but I sincerely need your help. 🙏

@DikkooXie DikkooXie added the question Further information is requested label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant