vllm-project / vllm

A high-throughput and memory-efficient inference and serving engine for LLMs
https://docs.vllm.ai
Apache License 2.0
27.87k stars 4.11k forks source link

Compute perplexity/logits for the prompt #2364

Open dsmilkov opened 9 months ago

dsmilkov commented 9 months ago

I'd like to use Phi-2 to compute perplexity of the prompts over an entire dataset. Is there an API for this? In the short term, I'm happy to fork https://github.com/vllm-project/vllm/blob/d0215a58e78572d91dadafe9d832a2db89b09a13/vllm/model_executor/models/phi_1_5.py if you provide pointer on how to do that.

Also happy to later contribute back an API that works for all causal models.

mayiran1999 commented 8 months ago

I have the same need. Have anyone found a possible way to get the logits of the prompt?

caiyuhu commented 8 months ago

I have the same need too, but unfortunately it appears that vLLM has not yet implemented support for it, as evidenced by the following issue discussion. https://github.com/vllm-project/vllm/issues/185

lekhang4497 commented 7 months ago

I think you can use the parameter prompt_logprobs in SamplingParams for this purpose.

1328

dylanbowman314 commented 3 months ago

prompt_logprobs can only return the probabilities for the top <=20 tokens right now, so not applicable for this usecase.

junzhang-zj commented 1 month ago

Is there any progress on this issue at the moment?

Tendo33 commented 3 weeks ago

same issue here

CodeAsPoetry commented 2 weeks ago

you can set logprobs=1, prompt_logprobs=1. Then, 屏幕截图 2024-09-18 180643

CodeAsPoetry commented 2 weeks ago

test prompt >20 , maybe ok 屏幕截图 2024-09-18 181700