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

kosmos_processor sorted_length =sorted([(idx, len(x)) for idx, x in enumerate(text_encoding.input_ids)]) wrong? #27648

Closed
YamingZhang opened this issue Nov 22, 2023 · 4 comments

Comments

@YamingZhang
Copy link

https://github.com/huggingface/transformers/blob/514de24abfd4416aeba6a6455ad5920f57f3567d/src/transformers/models/kosmos2/processing_kosmos2.py#L214C17-L214C17

The sorted code lacks a sorting function and should be changed to
sorted_length =sorted([(idx, len(x)) for idx, x in enumerate(text_encoding.input_ids)], key=lambda x: x[1])
, is that correct?

@ArthurZucker
Copy link
Collaborator

Mmmm yeah seems like it. Would you like to open a PR?
fyi @ydshieh

@YamingZhang
Copy link
Author

Sure, I'd be happy to help out

@ydshieh
Copy link
Collaborator

ydshieh commented Nov 22, 2023

Hi @YamingZhang

the latest version is

                sorted_length = sorted(
                    [(idx, len(x)) for idx, x in enumerate(text_encoding.input_ids)], key=lambda x: x[-1]
                )

see #27323.

@YamingZhang
Copy link
Author

Hi @YamingZhang

the latest version is

                sorted_length = sorted(
                    [(idx, len(x)) for idx, x in enumerate(text_encoding.input_ids)], key=lambda x: x[-1]
                )

see #27323.

Thank you very much.

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

3 participants