Skip to content

HuggingFaceQaInference EngineException on Longformer models #3546

Answered by frankfliu
xxx24xxx asked this question in Q&A
Discussion options

You must be logged in to vote

@xxx24xxx You are right, padding the input doesn't really work.
I think you have to modify the model code in modeling_longformer.py line 678

change:

            attn_output[is_index_global_attn_nonzero[::-1]] = nonzero_global_attn_output.view(
                len(is_local_index_global_attn_nonzero[0]), -1
            )

to:

            attn_output[is_index_global_attn_nonzero[::-1]] = nonzero_global_attn_output.view(
                is_local_index_global_attn_nonzero[0].shape[0], -1
            )

You don't need padding any more, the exsiting djl-convert and java code should work.

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@frankfliu
Comment options

@xxx24xxx
Comment options

Comment options

You must be logged in to vote
3 replies
@xxx24xxx
Comment options

@frankfliu
Comment options

@xxx24xxx
Comment options

Answer selected by xxx24xxx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants