encoding has some issue with Transformers == 4.48.1

#36
by keunwoochoi - opened
TypeError: cannot unpack non-iterable NoneType object

when i call .encode(). i did some debugging, it happens deep down when the __call__ of nn.Module is called, with _impl_call_ etc, and that's where i gave up figuring out more.

on 4.47.1 it works well.
i used torch 2.4.1 as well as 2.5 but seems like Transformer version is the core issue.

I experience this as well with 4.48.1

also breaks with torch 2.6

NVIDIA org

Hi. We suggest users to follow the install package version as follows: https://huggingface.co/nvidia/NV-Embed-v2#2-required-packages

@nada5 Unfortunately, If I want to use instructions models not available in transformers 4.42, that then means I cannot use nvidia/NV-Embed-v2 for retrieval in the same environment.

I ran into this same issue, and downgrading transformers was not an option for me because another model I needed was not in the older versions. Instead, I got it working by forking this repo and fixing the bug, which was just an issue with the mistral position encoding.

My fixed fork is available here, in case it's of use to anybody. I haven't written any good instructions on how to use it yet, but briefly, you can install it with pip install git+https://github.com/abhaybd/NV-Embed-v2_fixed.git, and then where previously you would do

from transformers import AutoModel
model = AutoModel.from_pretrained('nvidia/NV-Embed-v2', trust_remote_code=True)

you should instead do

from nv_embed_v2 import NVEmbedModel
model = NVEmbedModel.from_pretrained("nvidia/NV-Embed-v2")

I haven't rigorously checked that the bugfix was bulletproof, but it at least produces the same output as the example code. I would welcome improved documentation and/or verification!

Your need to confirm your account before you can post a new comment.

Sign up or log in to comment