Skip to content

server: implementation of v1/completions echo logprobs support - #15189

Open
fo40225 wants to merge 1 commit into
ggml-org:masterfrom
fo40225:v1_completions_echo
Open

fo40225 wants to merge 1 commit into
ggml-org:masterfrom
fo40225:v1_completions_echo

Conversation

@fo40225

@fo40225 fo40225 commented Aug 9, 2025 •

Copy link
Copy Markdown

@fo40225

fo40225 commented Aug 9, 2025

Copy link
Copy Markdown
Author

Related issue:
#8942
#12591
EleutherAI/lm-evaluation-harness#2894

@fo40225
fo40225 force-pushed the v1_completions_echo branch from 8284dc4 to 6817897 Compare August 10, 2025 01:37
@fo40225
fo40225 marked this pull request as ready for review August 10, 2025 01:40
@fo40225
fo40225 requested a review from ngxson as a code owner August 10, 2025 01:40
@fo40225

fo40225 commented Aug 10, 2025

Copy link
Copy Markdown
Author

llama.cpp b6096 + cherrypick 6817897
llama-server
unsloth/SmolLM2-135M-Instruct-GGUF/SmolLM2-135M-Instruct-Q8_0.gguf
lm-eval[api]==0.4.9.1

PIQA HellaSwag OpenBookQA WinoGrande
Ref 66.3 40.9 34.6 51.3
acc 66.3 35.0 23.0 51.6
acc_norm 66.8 43.0 33.4

Ref:
https://huggingface.co/blog/Kseniase/insidesmol
https://huggingface.co/HuggingFaceTB/SmolLM2-135M

llama.cpp/build/bin/llama-server \
 -fa \
 -m huggingface/unsloth/SmolLM2-135M-Instruct-GGUF/SmolLM2-135M-Instruct-Q8_0.gguf \
 --host 0.0.0.0 \
 --port 12345 \
 --jinja

for task in piqa hellaswag openbookqa winogrande
do
  lm-eval --model gguf \
    --tasks $task \
    --model_args base_url=http://127.0.0.1:12345 \
    --output_path ./SmolLM2-135M-Instruct-Q8_0-$task \
    --log_sample
done

@Green-Sky

Copy link
Copy Markdown
Collaborator

I guess this kind of works around #231

@jukofyork

Copy link
Copy Markdown
Collaborator

This looks useful - am I correct in thinking this can be used to get the logprobs of the prompt?

@juliafalcao

Copy link
Copy Markdown

+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.

@ngxson

ngxson commented Dec 11, 2025

Copy link
Copy Markdown
Collaborator

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?

@gatbontonpc

Copy link
Copy Markdown
Contributor

@ngxson. There's an example of the non-stream case.

@fo40225

fo40225 commented Mar 1, 2026

Copy link
Copy Markdown
Author

@ngxson Here is the output from vllm v0.16.0

curl --location 'http://127.0.0.1:8000/v1/completions' \
--header 'Content-Type: application/json' \
--data '{
    "prompt": "The step of boiling water is: ",
    "stream": false,
    "echo": true,
    "logprobs": 5,
    "max_tokens": 1
}'
{"id":"cmpl-8c16f81d43846721","object":"text_completion","created":1772367069,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"The step of boiling water is: 1","logprobs":{"text_offset":[0,3,8,11,19,25,28,29,30],"token_logprobs":[null,-8.818763732910156,-1.552642822265625,-13.55989933013916,-2.0115487575531006,-2.2331151962280273,-8.53701114654541,-1.2870503664016724,-0.41059786081314087],"tokens":["The"," step"," of"," boiling"," water"," is",":"," ","1"],"top_logprobs":[null,{" step":-8.818763732910156," is":-0.7875133752822876," ":-1.9750133752822876," are":-2.600013256072998," type":-4.100013256072998,":":-4.350013256072998},{" of":-1.552642822265625," in":-1.740142822265625," that":-2.552642822265625," response":-2.552642822265625,"wise":-2.802642822265625},{" boiling":-13.55989933013916," the":-0.23177461326122284," photos":-2.9817745685577393," DNA":-3.9817745685577393," translation":-4.044274806976318," protein":-4.044274806976318},{" water":-2.0115487575531006," the":-0.6990486979484558," a":-3.1990487575531006," in":-3.2615487575531006," and":-3.6990487575531006},{" is":-2.2331151962280273," to":-1.045615315437317," in":-2.2331151962280273," and":-2.7331151962280273," for":-2.9206151962280273},{":":-8.53701114654541," an":-1.3807610273361206," a":-2.19326114654541," used":-2.81826114654541," to":-3.06826114654541," not":-3.13076114654541},{" ":-1.2870503664016724," (":-2.162050247192383," __":-2.474550247192383," a":-3.224550247192383," water":-3.349550247192383},{"1":-0.41059786081314087,"2":-2.723097801208496," \\":-3.410597801208496,"":-3.660597801208496,"3":-3.660597801208496}]},"finish_reason":"length","stop_reason":null,"token_ids":null,"prompt_logprobs":[null,{"3019":{"logprob":-8.818763732910156,"rank":355,"decoded_token":" step"},"374":{"logprob":-0.7875133752822876,"rank":1,"decoded_token":" is"},"220":{"logprob":-1.9750133752822876,"rank":2,"decoded_token":" "},"525":{"logprob":-2.600013256072998,"rank":3,"decoded_token":" are"},"943":{"logprob":-4.100013256072998,"rank":4,"decoded_token":" type"},"25":{"logprob":-4.350013256072998,"rank":5,"decoded_token":":"}},{"315":{"logprob":-1.552642822265625,"rank":1,"decoded_token":" of"},"304":{"logprob":-1.740142822265625,"rank":2,"decoded_token":" in"},"429":{"logprob":-2.552642822265625,"rank":3,"decoded_token":" that"},"2033":{"logprob":-2.552642822265625,"rank":4,"decoded_token":" response"},"4482":{"logprob":-2.802642822265625,"rank":5,"decoded_token":"wise"}},{"49837":{"logprob":-13.55989933013916,"rank":3167,"decoded_token":" boiling"},"279":{"logprob":-0.23177461326122284,"rank":1,"decoded_token":" the"},"7249":{"logprob":-2.9817745685577393,"rank":2,"decoded_token":" photos"},"15552":{"logprob":-3.9817745685577393,"rank":3,"decoded_token":" DNA"},"14468":{"logprob":-4.044274806976318,"rank":4,"decoded_token":" translation"},"12833":{"logprob":-4.044274806976318,"rank":5,"decoded_token":" protein"}},{"3015":{"logprob":-2.0115487575531006,"rank":2,"decoded_token":" water"},"279":{"logprob":-0.6990486979484558,"rank":1,"decoded_token":" the"},"264":{"logprob":-3.1990487575531006,"rank":3,"decoded_token":" a"},"304":{"logprob":-3.2615487575531006,"rank":4,"decoded_token":" in"},"323":{"logprob":-3.6990487575531006,"rank":5,"decoded_token":" and"}},{"374":{"logprob":-2.2331151962280273,"rank":2,"decoded_token":" is"},"311":{"logprob":-1.045615315437317,"rank":1,"decoded_token":" to"},"304":{"logprob":-2.2331151962280273,"rank":3,"decoded_token":" in"},"323":{"logprob":-2.7331151962280273,"rank":4,"decoded_token":" and"},"369":{"logprob":-2.9206151962280273,"rank":5,"decoded_token":" for"}},{"25":{"logprob":-8.53701114654541,"rank":147,"decoded_token":":"},"458":{"logprob":-1.3807610273361206,"rank":1,"decoded_token":" an"},"264":{"logprob":-2.19326114654541,"rank":2,"decoded_token":" a"},"1483":{"logprob":-2.81826114654541,"rank":3,"decoded_token":" used"},"311":{"logprob":-3.06826114654541,"rank":4,"decoded_token":" to"},"537":{"logprob":-3.13076114654541,"rank":5,"decoded_token":" not"}},{"220":{"logprob":-1.2870503664016724,"rank":1,"decoded_token":" "},"320":{"logprob":-2.162050247192383,"rank":2,"decoded_token":" ("},"1304":{"logprob":-2.474550247192383,"rank":3,"decoded_token":" __"},"264":{"logprob":-3.224550247192383,"rank":4,"decoded_token":" a"},"3015":{"logprob":-3.349550247192383,"rank":5,"decoded_token":" water"}}],"prompt_token_ids":null}],"service_tier":null,"system_fingerprint":null,"usage":{"prompt_tokens":8,"total_tokens":9,"completion_tokens":1,"prompt_tokens_details":null},"kv_transfer_params":null}
curl --location 'http://127.0.0.1:8000/v1/completions' \
--header 'Content-Type: application/json' \
--data '{
    "prompt": "The step of boiling water is: ",
    "stream": false,
    "echo": true,
    "logprobs": 5,
    "max_tokens": 16
}'
{"id":"cmpl-ab071044c7b34f0d","object":"text_completion","created":1772367122,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"The step of boiling water is: 1. Fill a pot with water, 2. Put the pot on the","logprobs":{"text_offset":[0,3,8,11,19,25,28,29,30,31,32,37,39,43,48,54,55,56,57,58,62,66,70,73],"token_logprobs":[null,-8.928868293762207,-1.6430327892303467,-13.802532196044922,-1.9307808876037598,-2.2653372287750244,-8.555088996887207,-1.353688359260559,-0.3660952150821686,-0.3784564733505249,-1.307369589805603,-1.1129441261291504,-0.12129739671945572,-0.06193635240197182,-0.019757026806473732,-1.7016117572784424,-0.024066805839538574,-2.6940935640595853e-05,-0.0003743662964552641,-2.0986382961273193,-0.014136063866317272,-0.0005465444410219789,-0.003620974952355027,-0.20243927836418152],"tokens":["The"," step"," of"," boiling"," water"," is",":"," ","1","."," Fill"," a"," pot"," with"," water",","," ","2","."," Put"," the"," pot"," on"," the"],"top_logprobs":[null,{" step":-8.928868293762207," is":-0.6163686513900757," are":-2.4288687705993652," ":-2.4913687705993652," type":-4.178868770599365," can":-4.303868770599365},{" of":-1.6430327892303467," in":-1.6430327892303467," response":-2.3305327892303467," that":-2.4555327892303467,"wise":-2.7055327892303467},{" boiling":-13.802532196044922," the":-0.24003246426582336," photos":-2.865032434463501," DNA":-3.927532434463501," protein":-3.990032434463501," translation":-4.17753267288208},{" water":-1.9307808876037598," the":-0.743280827999115," in":-3.0557808876037598," a":-3.1807808876037598," and":-3.6807808876037598},{" is":-2.2653372287750244," to":-1.0778372287750244," in":-2.1403372287750244," into":-2.5153372287750244," and":-2.8278372287750244},{":":-8.555088996887207," an":-1.3988392353057861," a":-2.211339235305786," used":-2.836339235305786," not":-3.086339235305786," to":-3.273839235305786},{" ":-1.353688359260559," (":-2.0411882400512695," __":-2.4786882400512695," a":-3.0411882400512695," \\":-3.3536882400512695},{"1":-0.3660952150821686,"2":-2.6785953044891357,"3":-3.6785953044891357,"":-3.8035953044891357,"4":-3.9910953044891357},{".":-0.3784564733505249,")":-2.4409565925598145,"0":-2.5659565925598145,"5":-4.0659565925598145,"2":-4.0659565925598145},{" Fill":-1.307369589805603," Pour":-2.0573697090148926," Put":-2.4948697090148926," Place":-2.8073697090148926," Take":-3.1198697090148926},{" a":-1.1129441261291504," the":-0.6129441261291504," pot":-2.8629441261291504," your":-3.4879441261291504," kettle":-3.7379441261291504},{" pot":-0.12129739671945572," kettle":-2.8712973594665527," sauce":-3.9962973594665527," pan":-4.246297359466553," clean":-4.496297359466553},{" with":-0.06193635240197182," or":-3.311936378479004," halfway":-4.061936378479004," ":-5.874436378479004," (":-6.936936378479004},{" water":-0.019757026806473732," enough":-5.01975679397583," tap":-5.39475679397583," ":-6.01975679397583," the":-6.39475679397583},{",":-1.7016117572784424,".":-0.5766118168830872," ":-2.4516117572784424," and":-2.5766117572784424,".\\":-2.8266117572784424},{" ":-0.024066805839538574," leaving":-5.086566925048828," and":-5.586566925048828," place":-5.649066925048828," placing":-5.836566925048828},{"2":-2.6940935640595853e-05,"3":-11.50002670288086," ":-11.93752670288086,"4":-12.31252670288086,"1":-13.25002670288086},{".":-0.0003743662964552641,".__":-9.937874794006348," .":-10.062874794006348,".,":-10.437874794006348,",":-10.500374794006348},{" Put":-2.0986382961273193," Place":-0.2236383855342865," Turn":-3.7236382961273193," __":-4.036138534545898," Set":-4.598638534545898},{" the":-0.014136063866317272," it":-4.514135837554932," pot":-6.139135837554932," a":-7.764135837554932," on":-7.889135837554932},{" pot":-0.0005465444410219789," water":-7.875546455383301,"pot":-9.3755464553833," Pot":-10.6255464553833," filled":-11.8755464553833},{" on":-0.003620974952355027," of":-5.8786211013793945," with":-7.8786211013793945," over":-8.691121101379395," onto":-9.066121101379395},{" the":-0.20243927836418152," a":-1.702439308166504," stove":-7.327439308166504," high":-9.202439308166504," st":-9.452439308166504}]},"finish_reason":"length","stop_reason":null,"token_ids":null,"prompt_logprobs":[null,{"3019":{"logprob":-8.928868293762207,"rank":327,"decoded_token":" step"},"374":{"logprob":-0.6163686513900757,"rank":1,"decoded_token":" is"},"525":{"logprob":-2.4288687705993652,"rank":2,"decoded_token":" are"},"220":{"logprob":-2.4913687705993652,"rank":3,"decoded_token":" "},"943":{"logprob":-4.178868770599365,"rank":4,"decoded_token":" type"},"646":{"logprob":-4.303868770599365,"rank":5,"decoded_token":" can"}},{"315":{"logprob":-1.6430327892303467,"rank":1,"decoded_token":" of"},"304":{"logprob":-1.6430327892303467,"rank":2,"decoded_token":" in"},"2033":{"logprob":-2.3305327892303467,"rank":3,"decoded_token":" response"},"429":{"logprob":-2.4555327892303467,"rank":4,"decoded_token":" that"},"4482":{"logprob":-2.7055327892303467,"rank":5,"decoded_token":"wise"}},{"49837":{"logprob":-13.802532196044922,"rank":3718,"decoded_token":" boiling"},"279":{"logprob":-0.24003246426582336,"rank":1,"decoded_token":" the"},"7249":{"logprob":-2.865032434463501,"rank":2,"decoded_token":" photos"},"15552":{"logprob":-3.927532434463501,"rank":3,"decoded_token":" DNA"},"12833":{"logprob":-3.990032434463501,"rank":4,"decoded_token":" protein"},"14468":{"logprob":-4.17753267288208,"rank":5,"decoded_token":" translation"}},{"3015":{"logprob":-1.9307808876037598,"rank":2,"decoded_token":" water"},"279":{"logprob":-0.743280827999115,"rank":1,"decoded_token":" the"},"304":{"logprob":-3.0557808876037598,"rank":3,"decoded_token":" in"},"264":{"logprob":-3.1807808876037598,"rank":4,"decoded_token":" a"},"323":{"logprob":-3.6807808876037598,"rank":5,"decoded_token":" and"}},{"374":{"logprob":-2.2653372287750244,"rank":3,"decoded_token":" is"},"311":{"logprob":-1.0778372287750244,"rank":1,"decoded_token":" to"},"304":{"logprob":-2.1403372287750244,"rank":2,"decoded_token":" in"},"1119":{"logprob":-2.5153372287750244,"rank":4,"decoded_token":" into"},"323":{"logprob":-2.8278372287750244,"rank":5,"decoded_token":" and"}},{"25":{"logprob":-8.555088996887207,"rank":148,"decoded_token":":"},"458":{"logprob":-1.3988392353057861,"rank":1,"decoded_token":" an"},"264":{"logprob":-2.211339235305786,"rank":2,"decoded_token":" a"},"1483":{"logprob":-2.836339235305786,"rank":3,"decoded_token":" used"},"537":{"logprob":-3.086339235305786,"rank":4,"decoded_token":" not"},"311":{"logprob":-3.273839235305786,"rank":5,"decoded_token":" to"}},{"220":{"logprob":-1.353688359260559,"rank":1,"decoded_token":" "},"320":{"logprob":-2.0411882400512695,"rank":2,"decoded_token":" ("},"1304":{"logprob":-2.4786882400512695,"rank":3,"decoded_token":" __"},"264":{"logprob":-3.0411882400512695,"rank":4,"decoded_token":" a"},"1124":{"logprob":-3.3536882400512695,"rank":5,"decoded_token":" \\"}}],"prompt_token_ids":null}],"service_tier":null,"system_fingerprint":null,"usage":{"prompt_tokens":8,"total_tokens":24,"completion_tokens":16,"prompt_tokens_details":null},"kv_transfer_params":null}
curl --location 'http://127.0.0.1:8000/v1/completions' \
--header 'Content-Type: application/json' \
--data '{
    "prompt": "The step of boiling water is: ",
    "stream": true,
    "echo": true,
    "logprobs": 5,
    "max_tokens": 1
}'
data: {"id":"cmpl-822789c80f809a71","object":"text_completion","created":1772367170,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"The step of boiling water is: 1","logprobs":{"text_offset":[0,3,8,11,19,25,28,29,30],"token_logprobs":[null,-8.816559791564941,-1.6565594673156738,-13.917608261108398,-2.047391176223755,-2.1830272674560547,-8.55152702331543,-1.2779529094696045,-0.5364786982536316],"tokens":["The"," step"," of"," boiling"," water"," is",":"," ","1"],"top_logprobs":[null,{" step":-8.816559791564941," is":-0.6915602087974548," ":-2.3165602684020996," are":-2.4415602684020996," type":-4.0665602684021," can":-4.2540602684021},{" of":-1.6565594673156738," in":-1.6565594673156738," response":-2.344059467315674," that":-2.469059467315674,"wise":-2.844059467315674},{" boiling":-13.917608261108398," the":-0.2769835889339447," photos":-2.5894834995269775," protein":-4.026983737945557," DNA":-4.026983737945557," translation":-4.151983737945557},{" water":-2.047391176223755," the":-0.7348912358283997," a":-3.109891176223755," in":-3.234891176223755," and":-3.547391176223755},{" is":-2.1830272674560547," to":-1.1205271482467651," in":-2.1205272674560547," into":-2.7455272674560547," and":-2.7455272674560547},{":":-8.55152702331543," an":-1.4890271425247192," a":-2.3640270233154297," used":-2.9265270233154297," not":-3.1765270233154297," to":-3.1765270233154297},{" ":-1.2779529094696045," (":-2.1529529094696045," __":-2.5279529094696045," a":-3.2154529094696045," [":-3.4029529094696045},{"1":-0.5364786982536316,"2":-2.4739787578582764,"3":-3.2239787578582764," \\":-3.3489787578582764,"4":-3.5364787578582764}]},"finish_reason":"length","stop_reason":null,"prompt_token_ids":[785,3019,315,49837,3015,374,25,220],"token_ids":null}],"usage":null}

data: [DONE]
curl --location 'http://127.0.0.1:8000/v1/completions' \
--header 'Content-Type: application/json' \
--data '{
    "prompt": "The step of boiling water is: ",
    "stream": true,
    "echo": true,
    "logprobs": 5,
    "max_tokens": 16
}'
data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"The step of boiling water is: 1","logprobs":{"text_offset":[0,3,8,11,19,25,28,29,30],"token_logprobs":[null,-8.8220853805542,-1.5775024890899658,-13.715353012084961,-2.1581525802612305,-2.351515531539917,-8.575431823730469,-1.4704067707061768,-0.31372934579849243],"tokens":["The"," step"," of"," boiling"," water"," is",":"," ","1"],"top_logprobs":[null,{" step":-8.8220853805542," is":-0.7595850825309753," ":-2.07208514213562," are":-2.57208514213562," type":-4.072084903717041," can":-4.322084903717041},{" of":-1.5775024890899658," in":-1.7025024890899658," response":-2.515002489089966," that":-2.577502489089966,"-by":-2.702502489089966},{" boiling":-13.715353012084961," the":-0.23097772896289825," photos":-3.043477773666382," DNA":-3.855977773666382," protein":-3.980977773666382," translation":-4.043477535247803},{" water":-2.1581525802612305," the":-0.6581525802612305," in":-3.2206525802612305," a":-3.2206525802612305," and":-3.4081525802612305},{" is":-2.351515531539917," to":-0.976515531539917," in":-2.289015531539917," into":-2.601515531539917," and":-2.851515531539917},{":":-8.575431823730469," an":-1.4816818237304688," a":-2.2316818237304688," used":-2.8566818237304688," not":-3.0441818237304688," to":-3.0441818237304688},{" ":-1.4704067707061768," (":-2.1579067707061768," __":-2.4079067707061768," a":-3.0954067707061768," \\":-3.2829067707061768},{"1":-0.31372934579849243,"2":-2.9387292861938477,"":-3.6887292861938477,"3":-3.8762292861938477,"4":-4.126229286193848}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":[785,3019,315,49837,3015,374,25,220],"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"0","logprobs":{"text_offset":[1],"token_logprobs":[-2.5639488697052],"tokens":["0"],"top_logprobs":[{"0":-2.5639488697052,".":-0.3764488399028778,")":-2.4389488697052,"5":-4.063948631286621,"2":-4.063948631286621}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"0","logprobs":{"text_offset":[2],"token_logprobs":[-0.14446376264095306],"tokens":["0"],"top_logprobs":[{"0":-0.14446376264095306," minutes":-2.5194637775421143," degrees":-5.144463539123535,"°C":-5.456963539123535," +":-5.456963539123535}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":" degree","logprobs":{"text_offset":[3],"token_logprobs":[-2.2517788410186768],"tokens":[" degree"],"top_logprobs":[{" degree":-2.2517788410186768," degrees":-0.5642788410186768,"°C":-2.0017788410186768,"0":-3.3767788410186768,"℃":-3.8767788410186768}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":" Celsius","logprobs":{"text_offset":[10],"token_logprobs":[-0.5719082355499268],"tokens":[" Celsius"],"top_logprobs":[{" Celsius":-0.5719082355499268," c":-1.4469082355499268," C":-2.5719082355499268," cel":-3.5094082355499268," cent":-3.6344082355499268}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":" =","logprobs":{"text_offset":[18],"token_logprobs":[-2.5069150924682617],"tokens":[" ="],"top_logprobs":[{" =":-2.5069150924682617,".":-1.1319149732589722," or":-2.2569150924682617,".\n\n":-2.5069150924682617,",":-2.5069150924682617}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":" ","logprobs":{"text_offset":[20],"token_logprobs":[-0.24679504334926605],"tokens":[" "],"top_logprobs":[{" ":-0.24679504334926605," ______":-3.3092949390411377," water":-3.7467949390411377," __":-3.8717949390411377," boiling":-4.059295177459717}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"2","logprobs":{"text_offset":[21],"token_logprobs":[-0.19814808666706085],"tokens":["2"],"top_logprobs":[{"2":-0.19814808666706085,"1":-2.073148012161255,"3":-3.073148012161255,"0":-5.323148250579834," ":-6.698148250579834}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"1","logprobs":{"text_offset":[22],"token_logprobs":[-0.00019369633810129017],"tokens":["1"],"top_logprobs":[{"1":-0.00019369633810129017,"2":-9.75019359588623,"0":-9.81269359588623," minutes":-10.62519359588623,"7":-10.62519359588623}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"2","logprobs":{"text_offset":[23],"token_logprobs":[-0.00012432756193447858],"tokens":["2"],"top_logprobs":[{"2":-0.00012432756193447858,"0":-9.375123977661133,"1":-11.500123977661133,"6":-11.750123977661133,"5":-11.750123977661133}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":" degree","logprobs":{"text_offset":[24],"token_logprobs":[-0.08527077734470367],"tokens":[" degree"],"top_logprobs":[{" degree":-0.08527077734470367," Fahrenheit":-3.085270881652832," degrees":-3.960270881652832," F":-4.585270881652832,"F":-5.585270881652832}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":" Fahrenheit","logprobs":{"text_offset":[31],"token_logprobs":[-0.09482935070991516],"tokens":[" Fahrenheit"],"top_logprobs":[{" Fahrenheit":-0.09482935070991516," F":-2.5948293209075928," f":-4.969829559326172,"\n\n":-6.344829559326172," Far":-6.844829559326172}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":" =","logprobs":{"text_offset":[42],"token_logprobs":[-1.5869503021240234],"tokens":[" ="],"top_logprobs":[{" =":-1.5869503021240234,".":-0.7119502425193787,".\\":-2.3369503021240234,".\n\n":-2.4619503021240234,"\n\n":-3.4619503021240234}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":" ","logprobs":{"text_offset":[44],"token_logprobs":[-0.016050301492214203],"tokens":[" "],"top_logprobs":[{" ":-0.016050301492214203," ______":-6.078550338745117," [":-6.453550338745117,"3":-6.578550338745117," class":-6.641050338745117}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"3","logprobs":{"text_offset":[45],"token_logprobs":[-0.0027498311828821898],"tokens":["3"],"top_logprobs":[{"3":-0.0027498311828821898,"0":-6.627749919891357,"2":-7.252749919891357,"1":-7.377749919891357," ":-10.0027494430542}]},"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: {"id":"cmpl-b1992ed829abc554","object":"text_completion","created":1772367199,"model":"Intel/Qwen3-Coder-Next-int4-AutoRound","choices":[{"index":0,"text":"7","logprobs":{"text_offset":[46],"token_logprobs":[-0.000024199192921514623],"tokens":["7"],"top_logprobs":[{"7":-0.000024199192921514623,"3":-11.37502384185791,"1":-11.93752384185791,"2":-12.37502384185791,"9":-14.18752384185791}]},"finish_reason":"length","stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

data: [DONE]

@imrehg imrehg mentioned this pull request Jul 3, 2026
4 tasks done
woodwoodwoodwood pushed a commit to woodwoodwoodwood/llama.cpp that referenced this pull request Jul 9, 2026
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]>
woodwoodwoodwood pushed a commit to woodwoodwoodwood/llama.cpp that referenced this pull request Jul 9, 2026
…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]>
WhyFriendo added a commit to WhyFriendo/QuantizedBench that referenced this pull request Aug 21, 2026
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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants