Chinese-CLIP icon indicating copy to clipboard operation
Chinese-CLIP copied to clipboard

使用ChineseCLIPTextModel时,同样的输入获得了不同的输出tensor

Open saiboft opened this issue 1 year ago • 0 comments

import torch from transformers import AutoTokenizer, ChineseCLIPTextModel

tokenizer = AutoTokenizer.from_pretrained("OFA-Sys/chinese-clip-vit-large-patch14", max_length=77) model = ChineseCLIPTextModel.from_pretrained("OFA-Sys/chinese-clip-vit-large-patch14", torch_dtype=torch.bfloat16) model.eval().requires_grad_(False)

inputs = tokenizer("一只猴子", truncation=True, max_length=77, return_length=False, return_overflowing_tokens=False, padding="max_length", return_tensors="pt")

outputs = model(input_ids=inputs["input_ids"], attention_mask=None, output_hidden_states=False)

print(outputs["pooler_output"])

这个脚本每次运行都会得到不同的输出,这是为什么

saiboft avatar May 08 '25 09:05 saiboft