Repository navigation
Conversation
|
Related issue: |
8284dc4 to
6817897
Compare
|
llama.cpp b6096 + cherrypick 6817897
Ref: |
|
I guess this kind of works around #231 |
|
This looks useful - am I correct in thinking this can be used to get the logprobs of the prompt? |
|
+1 this is super useful and I've cloned this PR and built it because I cannot evaluate LLMs properly using llama.cpp without being able to get the logprobs of the entire prompt. |
|
I tried to implement it in #17935 but it's unclear what's the expected response format in the 2 cases: stream and non-stream. Can anyone push an example of the request / responses here? |
|
@ngxson Here is the output from vllm v0.16.0 |
Port of PR ggml-org#15189 (fo40225) to the current refactored server layout, so that lm-eval-harness loglikelihood tasks can run against the C++ server with real concurrency (-np N -cb) instead of the slow single-request llama-cpp-python server. - server-common: drop the "Only no echo is supported" rejection; echo is already parsed into chat_parser_params.echo by the schema. - server-task: add completion_token_output::oaicompat_probs_vector_to_json emitting the legacy {text_offset, token_logprobs, tokens, top_logprobs} object; wire echo into the final (text = prompt+content) and partial (first chunk echoes prompt) OAI completion responses. - server-context: in launch_slot_with_task, when echo is requested capture per-token prompt logprobs via a separate prefill pass (clear KV, decode with output logits at every position, logprob = logit[tok]-logsumexp, top-N via partial_sort); thread echo/prompt_text/prompt_token_probs through the partial and final response builders. Co-Authored-By: Claude <[email protected]>
…code logging The throwaway-seq (1000000) approach produced all-null prompt logprobs, likely because the KV memory does not populate logits for a seq that was never seen by a slot. Revert to PR ggml-org#15189's proven method: clear all KV with llama_memory_clear and decode the prompt on seq 0 with logits=true at every position. Keep the n_outputs_max=n_batch fix so output_reserve does not assert. Add explicit error logging when the echo prefill decode fails (ret != 0), and a null-logprob fallback so a failed pass degrades gracefully instead of crashing lm_eval with int+None. Note: clearing all KV means concurrent slots re-process their cached prefix on their next request (throughput cost, not correctness). Co-Authored-By: Claude <[email protected]>
Root cause found by spot-checking collected results: every quant of llama31_8b, from bf16 down to iq1_s, produced bit-identical accuracy on tinyArc/tinyMMLU/tinyWinogrande/tinyHellaswag/tinyTruthfulQA. Traced it to llama-server's actual source (tools/server/server-context.cpp): probs_output is only ever populated from generated tokens, never from prompt/continuation text supplied by the caller. `echo=True` does nothing for logprobs -- returning prompt-token logprobs is an open, unmerged upstream feature (ggml-org/llama.cpp#15189). So every loglikelihood request was silently generating one throwaway token instead of scoring the actual answer choice, and every quant converged on the same degenerate tied answer regardless of the model. Only tinyGSM8k (the one generative task, on a different code path) was ever producing real data. Fix: score each continuation by force-generating it one token at a time, feeding the *actual* continuation tokens back in as context (not whatever the model itself would generate), and reading that specific token's own logprob out of top_logprobs at each step -- genuine teacher-forced scoring, done manually since the server won't do it. Verified directly: "The capital of France is Paris" scores a real, high logprob for " Paris" while implausible continuations correctly fall through to a fallback penalty.
Make sure to read the contributing guidelines before submitting a PR
implementation of v1/completions echo logprobs support
Ref:
https://platform.openai.com/docs/api-reference/completions/object
https://github.com/abetlen/llama-cpp-python/blob/v0.3.15/llama_cpp/llama.py#L1650
https://github.com/ggml-org/llama.cpp/blob/b6117/tools/perplexity/perplexity.cpp