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

Is there a way or an option that I can compute similarity score after calling inference to calculate embeddings? #305

Open
zwsjink opened this issue Aug 18, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@zwsjink
Copy link

zwsjink commented Aug 18, 2023

Well, I use

clip-retrieval inference --input_dataset image/mytest.tar --output_folder embeddings_folder --clip_model ViT-L/14 --input_format="webdataset"

to successfully calculate embeddings for both images and texts, and I do see npy files generated. However, I wish there is a way that the similarity score can be calculated at the same time and store to the generated parquet file in the meantime.

@rom1504
Copy link
Owner

rom1504 commented Aug 18, 2023

You can use embedding-reader to compute such similarities between pairs
Computing these dot products is very cheap

I guess we could also add the option to do it here too though

@zwsjink
Copy link
Author

zwsjink commented Aug 18, 2023

embedding-reader

I see, that would be great. By the way, in the paper "DataComp: In search of the next generation of multimodal datasets" I see you guys are using cosine similarity, what's the difference between cosine similarity and dot product (maybe after normalization?).

@rom1504
Copy link
Owner

rom1504 commented Aug 18, 2023 via email

@nicolas-dufour
Copy link

Hey, @rom1504 , is there an option to store the clip scores when using doing the clip inference transformation? Thanks!

@rom1504
Copy link
Owner

rom1504 commented Oct 17, 2023 via email

@nicolas-dufour
Copy link

nicolas-dufour commented Oct 17, 2023

Yeah but i would be useful when wanting to avoid keeping the image embeddings to save storage when only needing the text embeddings and the clip score

@rom1504
Copy link
Owner

rom1504 commented Oct 17, 2023

Makes sense, feel free to open a PR

@rom1504 rom1504 added the enhancement New feature or request label Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants