Skip to content

[Question]: T5-FastGeneration精度无法对齐 #5604

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

Closed
zzcgithub opened this issue Apr 11, 2023 · 1 comment
Closed

[Question]: T5-FastGeneration精度无法对齐 #5604

zzcgithub opened this issue Apr 11, 2023 · 1 comment
Assignees
Labels
question Further information is requested triage

Comments

@zzcgithub
Copy link

请提出你的问题

模型:T5-base
参数:beam-search
环境:A10 / paddle2.4 / paddlenlp-最新develop分支

使用代码:
def process(context, predictor, tokenizer, use_fast=False):
input_seq = f"根据信息生成评论\n {context} \n评论:"
inputs = tokenizer(
input_seq,
max_seq_len=512,
pad_to_max_seq_len=True,
truncation_strategy="longest_first",
return_attention_mask=True,
return_length=True,
)
input_ids = paddle.Tensor(np.array(inputs["input_ids"])).reshape([1, 512])
preds, _ = predictor.generate(
input_ids=input_ids,
max_length=768,
decode_strategy="beam_search",
num_beams=5,
# top_k = 5,
# top_p = 0.7,
use_fast=use_fast,
use_fp16_decoding=True,
decoding_lib="so/libdecoding_op.so",
)
preds = preds.numpy()
decoded_preds = postprocess(tokenizer, [preds])
result = decoded_preds[0][0]
return result

结果:
use_fast=False, 连续跑多次结果如下:
故宫是中国古代宫廷建筑的代表之一,其宏伟壮观的建筑风格和精美的雕刻工艺令人叹为观止。在这里,你可以感受到中国古代帝王的尊严和荣耀,也可以领略到中国古代文化的博大精深。无论是建筑还是文物,故宫都值得一游。 6.848419666290283 False
故宫是中国古代宫廷建筑的代表之一,其宏伟壮观的建筑风格和精美的雕刻工艺令人叹为观止。在这里,你可以感受到中国古代帝王的尊严和荣耀,也可以领略到中国古代文化的博大精深。无论是建筑还是文物,故宫都值得一游。 2.7139511108398438 False

use_fast=True,连续跑多次结果如下:
漫步在故宫,感受着迷的美景,仿佛置身于世外。这里。这里的景色如画般的美景,让人心旷神怡。在这里,我仿佛能够感受到大自然的恩赐,也能够感受到人与自然的和谐共生。来到这里,仿佛所有的烦恼都被抛到了脑后,心情也变得美好的回忆。 8.664758920669556 True
漫步在故宫,感受着迷的美景,仿佛置身于世外。这里。这里的景色如画般的美景,让人心旷神怡。在这里,我仿佛能够感受到大自然的恩赐,也能够感受到人与自然的和谐共生。来到这里,仿佛所有的烦恼都被抛到了脑后,心情也变得美好的回忆。 0.1344606876373291 True
漫步在故宫,感受着迷的美景,仿佛置身于世外。这里。这里的景色如画般的美景,让人心旷神怡。在这里,我仿佛能够感受到大自然的恩赐,也能够感受到人与自然的和谐共生。来到这里,仿佛所有的烦恼都被抛到了脑后,心情也变得美好的回忆。 0.13270115852355957 True

现象:
重复多次结果是稳定可复现的, fast模式下耗时135ms, non-fast模式2500ms

@zzcgithub zzcgithub added the question Further information is requested label Apr 11, 2023
@gongel gongel changed the title [Question]: 使用Fast generation的fast模式与非fast模式生成结果不一致 [Question]: T5-FastGeneration精度无法对齐 Apr 18, 2023
@w5688414
Copy link
Contributor

w5688414 commented May 8, 2024

您好,faster generation停止维护了,欢迎开发者贡献

@paddle-bot paddle-bot bot closed this as completed May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested triage
Projects
None yet
Development

No branches or pull requests

3 participants