ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

关于推理时获得logits结果

Open Starfulllll opened this issue 1 year ago • 2 comments

Describe the feature Please describe the feature requested here(请在这里描述需求) 您好!非常感谢提供的框架。我最近在使用GLM-4v进行lora训练和推理(CLI形式),想请教如何获得推理时的logits,用于计算token概率(尤其是对于分类任务) Paste any useful information Paste any useful information, including papers, github links, etc.(请在这里描述其他有用的信息,比如相关的论文地址,github链接等)

Additional context Add any other context or information here(其他信息可以写在这里) 期待您的回复

Starfulllll avatar Jul 29 '24 11:07 Starfulllll

目前还不支持返回logits的,这个迭代我们会考虑支持

Currently it's not supported yet, but we are considering this feature at this sprint

tastelikefeet avatar Aug 06 '24 10:08 tastelikefeet

目前还不支持返回logits的,这个迭代我们会考虑支持

Currently it's not supported yet, but we are considering this feature at this sprint

感谢回复,我通过修改llm/utils/utils.py line800 inference()中调用model.generate()参数,return_dict_in_generate=True, output_logits=True,本地实现了接收logits输出:)

Starfulllll avatar Aug 06 '24 14:08 Starfulllll

main分支支持了

Jintao-Huang avatar Sep 04 '24 07:09 Jintao-Huang

main分支支持了

具体怎么做的呀

kike-0304 avatar Feb 19 '25 07:02 kike-0304

main分支支持了

请问如何调用

Darren759 avatar Mar 31 '25 06:03 Darren759

请问如何调用呢

TousenKaname avatar Mar 31 '25 11:03 TousenKaname

请问如何调用呢

根据3.0官方文档,应该可以使用参数logprobs=True获取对数logits

Starfulllll avatar Mar 31 '25 11:03 Starfulllll

main分支支持了

请问如何调用

可以看下最新文档的logprobs参数

Starfulllll avatar Mar 31 '25 11:03 Starfulllll

请问如何调用呢

根据3.0官方文档,应该可以使用参数logprobs=True获取对数logits

但是logprobs!=logits, 请问目前有什么新的可以获取logits的方式吗

ref: https://github.com/vllm-project/vllm/issues/185#issuecomment-2247330414

xyyandxyy avatar Jun 27 '25 03:06 xyyandxyy