huggingface / huggingface/diffusers
Z-Image的文本位置编码长度不一致问题
- Dominant language
- Python
- Stars
- 34.5k
- Forks
- 7.3k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 91
Description
```
# Process captions
for j, cap_item in enumerate(all_cap_feats[i]):
noise_val = images_noise_mask[i][j] if j < len(images_noise_mask[i]) else 1
cap_out, cap_pos, cap_mask, cap_len, cap_nm = self._pad_with_ids(
cap_item,
(len(cap_item) + (-len(cap_item)) % SEQ_MULTI_OF, 1, 1),
(cap_cu_len, 0, 0),
device,
noise_val,
)
cap_feats_list.append(cap_out)
cap_pos_list.append(cap_pos)
cap_mask_list.append(cap_mask)
cap_lens.append(cap_len)
cap_noise.extend(cap_nm)
cap_cu_len += len(cap_item)
cap_end_pos.append(cap_cu_len)
cap_cu_len += 2 # for image vae and siglip tokens
```
这里cap_out和cap_pos输出的长度不一样?假设len(cap_item)=120,cap_out输出是128,cap_pos是128+8=136
Contributor guide
Research direction
Start by locating the shown caption-processing loop and inspect _pad_with_ids, especially how cap_out and cap_pos are constructed for SEQ_MULTI_OF padding. Reproduce the len(cap_item)=120 case and compare the returned lengths and positional indexing. Done means the intended caption, image VAE, and SigLIP token positions are aligned without an unexplained length mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100