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

Text embedding code failing for single prompt #85

Open
zqevans opened this issue Mar 27, 2023 · 6 comments
Open

Text embedding code failing for single prompt #85

zqevans opened this issue Mar 27, 2023 · 6 comments

Comments

@zqevans
Copy link
Contributor

zqevans commented Mar 27, 2023

When I try to use clap_model.get_text_embedding() on an array with a single prompt in it, the call fails with an error in the Roberta tokenizer. It seems that it's confused about the shape of the array unless there's more than one element in it.

File ".../transformers/models/roberta/modeling_roberta.py", line 802, in forward
batch_size, seq_length = input_shape
ValueError: not enough values to unpack (expected 2, got 1)

@lukewys
Copy link
Contributor

lukewys commented Apr 1, 2023

Hi, are you inputting the string to the function? In that function, we expect a list. So you could make that string as a text (length 1). Please let us know how you do it.

@zqevans
Copy link
Contributor Author

zqevans commented Apr 1, 2023

I'm inputting an array of length 1.

prompt = "Text prompt"
prompts = [prompt] * args.batch_size
text_embeddings = clap_model.get_text_embedding(prompts)

with args.batch_size is set to 1, this code fails. It works with larger batch sizes.

@kamalojasv181
Copy link

I can confirm this. I am facing the same issue. Thanks

@lematt1991
Copy link

#105 should fix this. Are there plans to merge it?

@hareisland
Copy link

need more than 2 text to get_text_embedding

@hareisland
Copy link

need more than 2 text to get_text_embedding

already made it a list (all_text_list[0:1]) but not work at all

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

5 participants