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

Error when translating with scores (--with_scores) option enabled #2583

Open
ncicio opened this issue Apr 16, 2024 · 1 comment
Open

Error when translating with scores (--with_scores) option enabled #2583

ncicio opened this issue Apr 16, 2024 · 1 comment

Comments

@ncicio
Copy link

ncicio commented Apr 16, 2024

When attempting to translate with the --with_scores option enabled, an error is encountered in the OpenNMT translation module. The specific error message is:

AttributeError: 'float' object has no attribute 'item'

This error arises from the translator.py file at line 437, within a list comprehension where it attempts to access the item() attribute of a float object in trans.pred_scores.

Expected Behavior:
The translation process with scores should proceed without encountering any errors, providing the translated text along with corresponding scores.

Actual Behavior:
The error mentioned above is encountered, halting the translation process and preventing the retrieval of translation scores.

Additional Context:

This issue occurs specifically when translating with scores enabled; without scores, the translation process functions as expected.
The error seems to stem from an attempt to access the item() attribute of a float object, which is invalid.
Possible Solution:
Inspect the code within the translator.py file at line 437 to identify the source of the error. Ensure that the trans.pred_scores attribute is properly handled when the --with_scores option is enabled.

Environment:

Python version: 3.9
OpenNMT version: 3.5.1
Operating System: Ubuntu

@vince62s
Copy link
Member

you need to remove the .item()
can you send a PR?

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

No branches or pull requests

2 participants