TIGER-AI-Lab / TIGER-AI-Lab/VLM2Vec
Batch inference: The representation results of a sample repeated k times and n times are different?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 684
- Forks
- 64
- Avg merge
- 8m
- Merged PRs (30d)
- 1
Description
I tested it using the following code in demo.py
processor_inputs = { "text": ['<|image_pad|> Represent the given image.\n', '<|image_pad|> Represent the given image.\n', '<|image_pad|> Represent the given image.\n'], "images": [Image.open('assets/example.jpg'), Image.open('assets/example.jpg'), Image.open('assets/example.jpg')], } inputs = Qwen2_VL_process_fn( processor_inputs, processor) inputs = batch_to_device(inputs, "cuda") with torch.autocast(device_type="cuda", dtype=torch.bfloat16): tgt_output = model(tgt=inputs)["tgt_reps"] print(tgt_output)
The greater the gap between n and k, the greater the gap in the representation obtained through inference. Theoretically, without the influence of padding, the results should be consistent.
k=1
n=8
In the actual model inference process, due to the influence of padding within the batch, the calculated similarity differs significantly from the result of single-sample inference.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in demo.py, including Qwen2_VL_process_fn, batch_to_device, and the model(tgt=inputs) call; compare k=1 with n=8 under the shown autocast settings. Trace how batch padding reaches representation computation and verify that repeated identical samples produce consistent representations and similarity results within expected numerical tolerance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- computer-vision, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100