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

Batch 推理和 逐条推理表现不一致 #274

Closed
zchuz opened this issue Nov 15, 2023 · 3 comments
Closed

Batch 推理和 逐条推理表现不一致 #274

zchuz opened this issue Nov 15, 2023 · 3 comments

Comments

@zchuz
Copy link

zchuz commented Nov 15, 2023

使用bf16加载
相同的两条数据,通过batch方式生成则会出现nan
如果将相同的数据逐条输入则不会出现nan

inputs = prompt
be = tokenizer(inputs, return_tensors='pt', padding=True)
input_ids = be.input_ids.to(model.device) 
attention_mask = be.attention_mask 
attention_mask = attention_mask.to(model.device)
gen_kwargs = {
    "max_length": max_length,
    "do_sample": False,
    "repetition_penalty": 1.0,
    "num_return_sequences" :1
}
output_ids = model.generate(input_ids=input_ids, attention_mask=attention_mask, **gen_kwargs)
@WinnieRerverse
Copy link

我是有结果,但是Batch 推理的时候结果和逐条不完全一致

@qiu404
Copy link

qiu404 commented Nov 24, 2023

#291 这个应该能解决你的问题

@RuixiangZhao
Copy link

请问如何进行batch推理?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants