mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #147] Features are slightly different when computing on a batch vs. single inference #127
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#127
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jerpint on GitHub (Aug 31, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/147
Given a prompt, the resulting embedding will be slightly different if it was computed in a batch (
batch_size > 1) vs. if it was computed as a single inference.For example, computing the embedding of a prompt like so:
model.encode_text(clip.tokenize(prompt))will not be the same as computing the feature of a batched prompt,model.encode_text(clip.tokenize([prompt, prompt, ..., prompt])):I would not expect any difference in output regardless of the batch size. Here is the code to reproduce this, and I am providing a Colab to reproduce it. The same discrepancy is observed using both CPU and GPU.
output:
@manugarri commented on GitHub (Sep 9, 2022):
probably not the cause, but have you tried setting the side at the very top?