r/LocalLLaMA • • Sep 03 '26 Heartwarming

Tutorial | Guide My RULE of Thumb of choosing a models

Post image
1.1k Upvotes

This is mostly for setting up for expectation, since personally without LLM i could take 3 days (15 hours of active programming) to debug or implement a feature, but with Qwen 27B (even before Qwen 3.8) it take 4 hours.

And yes 0.5 tok/s is human, not accounting of deletion and pausing, that's also the reason i am fine leaving overnight code base wide analysis or fin tech and deep research.

r/LocalLLaMA • • Aug 26 '26

Tutorial | Guide How to Fine-Tune an LLM: An End-to-End Guide

Thumbnail
towardsdatascience.com
90 Upvotes

I ended up fine tuning a mistral 7b to outperform our costly foundational model and saved $300k. I previously thought that fine tuning was pointless (it's definitely not) and that all these problems could be solved with RAG (they can't).

The truth is, a LoRA/QLoRA adapter is extremely useful for many cases, and can dramatically outperform RAG with aggressive system prompts.

With this guide, I want to help people understand the reasonableness of QLoRA on a consumer grade GPU (you might even be able to fine-tune on a colab t4).

It also includes a deep dive on the mathematics behind LoRA/QLoRA as well.

Let me know if I can help you out with your fine tuning pipeline. It certainly works!

r/LocalLLaMA • • Mar 08 '26 Popcorn

Tutorial | Guide (Llama.cpp) In case people are struggling with prompt processing on larger models like Qwen 27B, here's what helped me out

86 Upvotes

TLDR: I put the --ubatch-size to my GPU's L3 cache is (in MB).

EDIT: This seems to occur only on Qwen 3.5 27B, 35B and 9B on my setup. Also tried Ministral and Devstral, and they didn't have the same quirk happen, allowing me higher ubatch values with no issues

I was playing around with that value, and I had a hard time finding what exactly it did, or rather, I couldn't really understand it from most of the sources, and asking AI chats for help yielded very mixed results.

My GPU is 9070xt, and when I put it to --ubatch-size 64 (as the GPU has 64MB of L3 cache) my prompt processing jumped in speed where it was actually usable for Claude code invocation.

I understand there might well be some resources detailing and explaining this on the web, or in the docs. I am however doing this out of joy of "tweaking gauges" so to speak, and I'm mostly asking Gemini or ChatGPT for back and forth information on what I should change and what that setting does. I just randomly changed these values until I heard the "coil whine" sound on my gpu, and it was actually blazing fast once I dropped it from higher values to 64.

The default value seems to be 512, which explains calling it without --ubatch-size set yielded poor results for me

EDIT: For the sake of having a more complete set of circumstances;

I am on windows 11, using rocm backend through llama.cpp-rocm with the latest (26.2.2) AMD drivers.

Here's the output:

llama-bench -m "I:\Models\unsloth\Qwen3.5-27B-GGUF\Qwen3.5-27B-Q3_K_S.gguf" -ngl 99 -b 8192 -ub 4,8,64,128 -t 12 -fa 1 -ctk q8_0 -ctv q8_0 -p 512 -n 128 HIP Library Path: C:\WINDOWS\SYSTEM32\amdhip64_7.dll ggml_cuda_init: found 1 ROCm devices: Device 0: AMD Radeon RX 9070 XT, gfx1201 (0x1201), VMM: no, Wave Size: 32

modelsizeparamsbackendnglthreadsn_batchn_ubatchtype_ktype_vfatestt/s
qwen35 27B Q3_K - Small11.44 GiB26.90 BROCm991281924q8_0q8_01pp51259.50 ± 0.22
qwen35 27B Q3_K - Small11.44 GiB26.90 BROCm991281924q8_0q8_01tg12826.84 ± 0.03
qwen35 27B Q3_K - Small11.44 GiB26.90 BROCm991281928q8_0q8_01pp51283.25 ± 0.07
qwen35 27B Q3_K - Small11.44 GiB26.90 BROCm991281928q8_0q8_01tg12826.78 ± 0.01
qwen35 27B Q3_K - Small11.44 GiB26.90 BROCm9912819264q8_0q8_01pp512582.39 ± 0.59
qwen35 27B Q3_K - Small11.44 GiB26.90 BROCm9912819264q8_0q8_01tg12826.80 ± 0.01
qwen35 27B Q3_K - Small11.44 GiB26.90 BROCm99128192128q8_0q8_01pp51214.68 ± 0.16
qwen35 27B Q3_K - Small11.44 GiB26.90 BROCm99128192128q8_0q8_01tg12827.09 ± 0.13

EDIT 2, a day after:

Did some more testing. Rocm vs Vulkan llama.cpp behavior on the same Unsloth Qwen3.5 27B Q3_K_S variant. On ROCm, when ubatch goes over 64, the prompt processing slows down to a snails pace, and I noticed that GPU compute buffers on task manager are barely active, at around 6-10%

VRAM is still not at full capacity at that time, nor is CPU or RAM usage any higher due to this.

[Vulkan llama.cpp]
| model                          |       size |     params | backend    | ngl | threads | n_ubatch | type_k | type_v | fa |            test |                  t/s |
| ------------------------------ | ---------: | ---------: | ---------- | --: | ------: | -------: | -----: | -----: | -: | --------------: | -------------------: |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | Vulkan     |  99 |      12 |       32 |   q8_0 |   q8_0 |  1 |          pp4096 |        271.42 ± 0.65 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | Vulkan     |  99 |      12 |       32 |   q8_0 |   q8_0 |  1 |           tg128 |         33.46 ± 0.02 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | Vulkan     |  99 |      12 |       64 |   q8_0 |   q8_0 |  1 |          pp4096 |        447.42 ± 0.29 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | Vulkan     |  99 |      12 |       64 |   q8_0 |   q8_0 |  1 |           tg128 |         33.44 ± 0.02 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | Vulkan     |  99 |      12 |      256 |   q8_0 |   q8_0 |  1 |          pp4096 |        587.76 ± 0.55 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | Vulkan     |  99 |      12 |      256 |   q8_0 |   q8_0 |  1 |           tg128 |         33.43 ± 0.01 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | Vulkan     |  99 |      12 |      512 |   q8_0 |   q8_0 |  1 |          pp4096 |        597.25 ± 0.45 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | Vulkan     |  99 |      12 |      512 |   q8_0 |   q8_0 |  1 |           tg128 |         33.41 ± 0.02 |


[ROCm llama.cpp]


| model                          |       size |     params | backend    | ngl | threads | n_ubatch | type_k | type_v | fa |            test |                  t/s |
| ------------------------------ | ---------: | ---------: | ---------- | --: | ------: | -------: | -----: | -----: | -: | --------------: | -------------------: |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |      256 |   q4_0 |   q4_0 |  1 |           pp512 |         14.35 ± 0.36 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |      256 |   q4_0 |   q4_0 |  1 |           tg128 |         27.14 ± 0.11 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |      256 |   q8_0 |   q8_0 |  1 |           pp512 |         15.36 ± 0.40 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |      256 |   q8_0 |   q8_0 |  1 |           tg128 |         27.35 ± 0.07 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |      512 |   q8_0 |   q8_0 |  1 |           pp512 |         14.68 ± 0.22 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |      512 |   q8_0 |   q8_0 |  1 |           tg128 |         27.16 ± 0.11 |


| model                          |       size |     params | backend    | ngl | threads | n_ubatch | type_k | type_v | fa |            test |                  t/s |
| ------------------------------ | ---------: | ---------: | ---------- | --: | ------: | -------: | -----: | -----: | -: | --------------: | -------------------: |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |       32 |   q8_0 |   q8_0 |  1 |          pp2048 |        354.72 ± 5.39 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |       32 |   q8_0 |   q8_0 |  1 |           tg128 |         26.95 ± 0.03 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |       64 |   q8_0 |   q8_0 |  1 |          pp2048 |        581.98 ± 0.31 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |       64 |   q8_0 |   q8_0 |  1 |           tg128 |         26.90 ± 0.01 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |       72 |   q8_0 |   q8_0 |  1 |          pp2048 |          8.47 ± 0.04 |
| qwen35 27B Q3_K - Small        |  11.44 GiB |    26.90 B | ROCm       |  99 |      12 |       72 |   q8_0 |   q8_0 |  1 |           tg128 |         27.24 ± 0.12 |

Well, this has been fun.

I'll just go use Vulkan like a normal person

r/LocalLLaMA • • Jun 22 '26

Tutorial | Guide Same model, same prompt, 4 different agents

Thumbnail
gallery
91 Upvotes

Setup: one self-hosted Qwen3.6-27B (Q4) on llama.cpp, identical prompt, identical hardware. The only variable is the agent scaffolding. Agents tested: pi, opencode, hermes, qwen code.

Task: a single-file 2D canvas solar system with scripted orbits and gravity that acts only on user-launched comets.

The exact prompt (note the explicit "build incrementally, your context window is small" instruction):

Build a 2D solar system simulation as a self-contained HTML file using <canvas> and vanilla JavaScript (no external libraries).
Scene
- The Sun is fixed at the center of the canvas.
- Several planets orbit the Sun on stable circular/elliptical paths. Planets and the Sun do NOT gravitationally affect each other — their orbits are fixed/scripted, not physically simulated against one another.
- Pure 2D, top-down view. Make the canvas resize to the window.
Gravity model
- The Sun and every planet each have a gravitational mass proportional to their visual radius (bigger body = stronger gravity), matching real-world relative sizes as closely as reasonable.
- This gravity only acts on comets (see below). It does NOT act on the planets or the Sun.
Comets
- The user can launch a comet by clicking and dragging on the canvas: drag direction and length set the comet's initial velocity vector (release to launch).
- Comets ARE affected by the combined gravity of the Sun and all planets (sum of forces), so they curve and can slingshot.
- Each comet draws a fading trail behind it.
- Remove comets when they fly far off-screen.
Controls
- A slider (range input) that scales the gravity strength of ALL bodies up and down proportionally in real time.
Constraints (important — your context window is small):
- Do NOT write one huge file in a single shot. Build it incrementally in small pieces.
- Keep the code compact and readable. Avoid unnecessary comments and verbosity.
- After finishing, tell me the filename so I can open it in a browser.

Results: all 4 produced a working sim, but the code quality differs a lot:

opencode, my pick. Cleanest architecture, mass ∝ radius exactly as asked, and the only one doing sub-stepped integration (×4 per frame) → by far the most stable comet trajectories and slingshots. Reads like a human wrote it. Minor bug: planet-gravity mixes absolute/center-relative coords, but the Sun dominates so you barely notice.

pi, most correct. Coordinate-consistent, distance softening to avoid singularities, removes comets that hit the Sun, planet labels, and the only one with touch support. Less flashy, most robust.

hermes, flashiest, but physically wrong. Only one with real elliptical orbits + a nice drag-vector arrow. But it computes planet gravity on comets at a different time step than it renders the planets, so comets pull toward where the planets aren't. Looks best, simulates worst.

qwen code, most minimal. Shortest, runs, but crude: huge launch-velocity multiplier flings comets off instantly, no softening, no stars.

Takeaway: with a fixed local model, the agent's scaffolding visibly changes the output (integration strategy, coordinate hygiene, edge-case handling). The prettiest demo (hermes) was the buggiest; the plain-looking one (pi) was the most correct; opencode hit the best balance of clean code + stable physics. Curious whether others get the same ranking on their own local setups.

r/LocalLLaMA • • Aug 29 '25

Tutorial | Guide Qwen3-coder is mind blowing on local hardware (tutorial linked)

1.1k Upvotes

Hello hello!

I'm honestly blown away by how far local models have gotten in the past 1-2 months. Six months ago, local models were completely useless in Cline, which tbf is pretty heavyweight in terms of context and tool-calling demands. And then a few months ago I found one of the qwen models to actually be somewhat usable, but not for any real coding.

However, qwen3-coder-30B is really impressive. 256k context and is actually able to complete tool calls and diff edits reliably in Cline. I'm using the 4-bit quantized version on my 36GB RAM Mac.

My machine does turn into a bit of a jet engine after a while, but the performance is genuinely useful. My setup is LM Studio + Qwen3 Coder 30B + Cline (VS Code extension). There are some critical config details that can break it (like disabling KV cache quantization in LM Studio), but once dialed in, it just works.

This feels like the first time local models have crossed the threshold from "interesting experiment" to "actually useful coding tool." I wrote a full technical walkthrough and setup guide: https://cline.bot/blog/local-models

r/LocalLLaMA • • Oct 02 '26

Tutorial | Guide Inference Engineering for Dummies

77 Upvotes

Hi all! I am a former SWE who has recently transitioned into inference engineering. I launched a side hustle a few months back and I've just taken it full time due to excessive demand. Its been such an opportunity because the people optimizing runtime are far fewer than the people that are trying to build apps or offer AI solutions.

So I've been lurking around this community, and I've noticed a lot of people who seem to have massively suboptimal setups for their hardware, and I've grouped the biggest errors into several buckets. The purpose of this guide is to expose common inference bottlenecks and provide best practices for avoiding them within your hardware constraints.

RUNTIME:

I. Choosing the Right Runtime

This is the biggest mistake I see. Choosing the correct runtime for your architecture and model is the most important decision to make. In general, here are some rules to help you determine what runtime to use.

Firstly, Ollama is never optimal. Its just the simplest. If you want quick and easy and have extra RAM, it's a good place to start. It's very user friendly and requires less setup. But it just won't offer best inference speeds.

If your model requires cpu offload, then llama.cpp will be your best choice. If not and you're solely in gpu, VLLM will likely provide the best results. It's really as simple as that for 90% of cases. SGLang may be worth it if your workload involves Langgraph, as it is highly optimized for the tooling. Otherwise, stick to the above. Mainline branches are best, with community forks offering only highly niche performance boosts (i.e., for specific models/configurations, but are generally under optimized and not well maintained).

II. Optimizing and Maintaining Runtime

The other big mistake people make with runtime is failing to compile it with hardware specific flags. Not going to go through all of them here, Google can help you out. Just search "optimal runtime compilation flags for [runtime] using [GPU, CPU, RAM type]." The most missed/missed flags tend to be for architecture specific optimizations. Those are crucial.

Runtime should be recompiled (with optimal flags) any time *any* of the following occur:

- System updates

- Kernel/driver updates

- Running a model released or modified later than your last compile

- You haven't recompiled in over a month (recent updates often contain kernel or path optimizations)

MODEL CHOICE:

I. Quantization:

Quantization. Such a big word. Such little meaning. All you need to know is that it makes a model smaller. There are a million Q_K_X_&$&$&$ quant sizes, so I'm not going to go over them individually. Rather, I will provide basic principles.

- IQ quants are generally the best for the size. If you're choosing between IQ4_XS or Q4_K_M, IQ4_XS is both a smaller VRAM footprint and higher complexity.

- Nonlinear (NL) quants are only ever going to be better if you have CPU offload. Even then, IQ quants often offer extra context space vs NL quants and thus are preferable.

- If it's a quant you've never encountered, read the docs. It more than likely is highly optimized for that specific model and is indeed the one you should choose. Searching it or asking chatgpt *will give you the wrong answer every single time for custom quants.* You will only encounter these with custom tuned models.

- Standard Q_K_M quants are best if you have absolutely no hardware constraints for the model you're running, as path optimizations are the best. If you have no hardware constraints, though, you could be running a better model. This is only useful for running simple models for simple tasks.

II. Task

Certain models excel at certain tasks. This is subjective and preference based but this is my list:

Coding: for API, anthropic. Hands down the best models. Opus and Sonnet 5.5 both excel in performance and their low token usage per task makes them more affordable than previous iterations. Deepseek models are the best budget choice. Qwen models are the clear winner for local inference on all fronts.

Writing: Opus/sonnet for technical writing, Gemini for creative writing. Gemma for local creative writing.

Video: Wan 2.2 for local in most cases will get it done, chatgpt and copilot both have surprisingly robust free image/video gen, Veo is the best paid.

HARDWARE:

Buy a budget box, or build your own from parts. I've managed to squeeze better performance out of an RTX 3060 and 128 gb RAM than a DGX spark across all categories for multiple models. The spark has an edge for dense models, but I was able to run higher complexity models overall on the other setup for 1/5 the price. AMD and Intel lag significantly on speed per price, but I've heard Intel has had some major gains recently. Have not confirmed myself though.

MODEL OPTIMIZATIONS:

I. Spec Decode (MTP)

- If you have CPU offload, spec decode will *always* slow you down. The extra overhead compute isn't worth it if you don't have at least several hundred Mb/s bandwidth, which your CPU won't.

- MTP is sometimes a baked in feature, and sometimes requires a special secondary model. Ensure you know how it works for your model and what flags to run.

- Each model will be optimized for exactly 0-1 type of spec decode. Figure out which one it is (or isnt) rather than wasting your time testing methods.

II. Model Tuning

Just to show the kind of command optimization you can get, here is my sample command for running Qwen 3.8 Flash-Next, a 156b parameter model, on 12 gb VRAM (and 128 gb RAM) at 10 token/s decode and 150 token/s profile at 200k context:

~/llama.cpp/build/bin/llama-server --flash-attn on --batch-size 1024 --ubatch-size 1024 --no-warmup --cache-reuse 256 --jinja --host 0.0.0.0 --port 8090 --presence-penalty 0.0 --repeat-penalty 1.0 -m ~/llama.cpp/LLM/Qwen3.8-Flash-IQ4_XS/UD-IQ4_XS/Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf --temp 0.95 --top-k 20 --top-p 0.97 --min-p 0.05 -np 1 --chat-template-kwargs '{"enable_thinking": true, "preserve_thinking": true, "reasoning_effort": "xhigh"}' --threads-batch 16 --threads 8 --gpu-layers 150 --n-cpu-moe 48 -c 200000 --override-tensor per_layer_token_embd.weight=CPU -ctv q8_0 -ctk q8_0 --cache-ram 8192 --checkpoint-min-step 512 --ctx-checkpoints 4 --kv-unified --reasoning-preserve --load-mode mmap+mlock

That's a lot, right? It's every possible optimization you could apply. I'll go through them individually. This is llama.cpp specific, but you'll find the same flags with slightly different syntax apply to other runtimes.

-flash-attn (-fa) on: forces flash attention optimizations and paths. Explicitly set to on to override any fallback. Auto can be optimal if the model is recent and is not yet optimized.

-batch/-ubatch: batch is the decode chunks, ubatch is the prefill chunks. They must be multiples of one another, otherwise you're adding compute. Equal to one another is ideal for CPU offload, and a 2x-4x higher batch is optimal for full GPU loads. You'll need to play with these values to optimize. Batch/ubatch should be a power of 2 to optimize architecture. Intervals of 256 is typically good enough for testing.

--no-warmup: prevents initial model poll to load weights. Removes unnecessary latency

-- cache-reuse x: instructs the model to reuse cache values and scan for similarity at x token intervals

-jinja: highly underutilized and important flag. Utilizes native chat template kwargs to ensure output consistency.

--presence-penalty: flat penalty rate to words that appear in text. Used mainly for creative writing to prevent repetitive prose.

--repeat-penalty: reduces liklihood of already used tokens being reused. Best used for preventing loops in thinking agents.

-temp: model temperature– how creative the model is. 0 is completely deterministic, 1 is creative freedom.

Top-k: hard cutoff that keeps only the k most likely words. Each model will have recommended k values for thinking/instruct setups. Low key reduces hallucinations at the cost of repetition and loss of creativity

Top-p: includes P percentage of possible tokens. It reduces liklihood of hallucination dynamically.

Min-p: dynamic cutoff based on highest probability token. If the biggest probability token is 50% and min-p is 0.05, then the bottom 0.025 (2.5%) liklihood tokens will be excluded. Reduces noise without hampering creativity terribly.

Chat template kwargs: explicit chat template activations; newer runtime compilations should have flags for these. Controls model reasoning, reasoning effort, and internal chain of thought storage.

-threads (-t): number of cores used for decode. Set equal to physical cores (hyperthreading will thrash cores and degrade results)

-threads-batch(-tb): number of cores used for prefill. Set to double the number of physical cores, as hyperthreading helps here.

--gpu-layers (-ngl) : total layers on GPU. Fit as many as you can without OOM.

--n-cpu-moe: number of MoE layers offloaded to cpu. For MoE models, you should always offload these first and keep all layers on GPU if possible. Offload as few as possible to CPU.

--override-tensor...: tells the runtime to offload the n-gram table if needed. For qwen 3.8 flash specifically.

-ctk/-ctv: k and v cache quantization. K cache should *never* be below q8 unless youre running on less than 80k context. V cache can be q4 up to 150k context without issues, for the most part. Generally, q8 for both will be best for speed and is my recommendation to start with.

--cache-ram: sets RAM aside for cache allocation to ensure it doesn't go to swap

--context-checkpoints: the amount of checkpoints captured. Generally, you don't need as high as the defaults do. Leave the default if you have extra RAM, otherwise you may want to lower it.

--kv-unified: tells all instances to run on the same kv cache pool rather than allocating individual cache.

--reasoning-preserve: tells the runtime to retain CoT traces for evaluation. Prevents the model from getting stuck or looping as much when thinking.

--load-mode: tells the runtime how to load in the model. No mmap generally loads slower but is more stable. Mmap+mlock (or just mlock) is a balance of both with fast loading and page faults initially but it stabilizes as you run it, mmap alone is fast but will cause constant page faults and slows down inference, especially on models with CPU offloading.

I hope this guide helps! I'd be willing to answer any specific questions or make any additions if there are additional areas the community agrees are major uncovered inference bottlenecks. Some claims are based on my personal experience and I am open to data based claim revisions or anecdotal counterclaims, so feel free to provide. Happy tuning!

r/LocalLLaMA • • Sep 21 '26

Tutorial | Guide You can use any LLM just like JEV

281 Upvotes

You can simply run any GGUF with llama.cpp with n_predict=1 and n_probs=10, disable reasoning, and prompt it such as "If the following email is spam, respond with 1, if not spam, respond with 0. Do not respond with anything other than 1 or 0. Email: ...."

And that is it! It returns confidence percentages such as:

1 = 94.9%
0 = 5.08%

Example:

llama-server -m "C:\Users\MyUserName\llama.cpp\models\Spark-X2.5-4B-Q4_K_M.gguf" -c 4096 -ngl all -fit off -fa on -b 2048 -ub 512 -np 1 --cache-ram 0 --reasoning off --no-reasoning-preserve --perf

Then:

curl.exe -s -X POST http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d "{\"messages\":[{\"role\":\"system\",\"content\":\"Classify spam. Reply only 1=spam or 0=not spam.\"},{\"role\":\"user\",\"content\":\"CONGRATULATIONS!!! You have won $5,000,000! Click here immediately to claim your prize!\"}],\"max_tokens\":1,\"logprobs\":true,\"top_logprobs\":10,\"temperature\":1.0,\"top_p\":1.0}"

Result:

{"choices":[{"finish_reason":"length","index":0,"message":{"role":"assistant","content":"1"},"logprobs":{"content":[{"id":30,"token":"1","bytes":[49],"logprob":-0.00456317700445652,"top_logprobs":[{"id":30,"token":"1","bytes":[49],"logprob":-0.00456317700445652},{"id":29,"token":"0","bytes":[48],"logprob":-5.395024299621582},{"id":1033,"token":"**","bytes":[42,42],"logprob":-12.013711929321289},{"id":1046,"token":"The","bytes":[84,104,101],"logprob":-13.005236625671387},{"id":198,"token":"\n","bytes":[10],"logprob":-13.100714683532715},{"id":54,"token":"I","bytes":[73],"logprob":-14.624603271484375},{"id":3640,"token":"This","bytes":[84,104,105,115],"logprob":-14.800630569458008},{"id":130977,"token":"<tool_call>","bytes":[60,116,111,111,108,95,99,97,108,108,62],"logprob":-14.971238136291504},{"id":6908,"token":"Class","bytes":[67,108,97,115,115],"logprob":-15.373867988586426},{"id":3923,"token":"class","bytes":[99,108,97,115,115],"logprob":-15.442902565002441}]}]}}],"created":1789950066,"model":"C:\\Users\\MyUserName\\llama.cpp\\models\\Spark-X2.5-4B-Q4_K_M.gguf","system_fingerprint":"b11026-b49650adb","object":"chat.completion","usage":{"completion_tokens":1,"prompt_tokens":64,"total_tokens":65,"prompt_tokens_details":{"cached_tokens":59}},"id":"chatcmpl-x2WrCObzFNYjKVkwDmcL8FLquwfZ0NEa","timings":{"cache_n":59,"prompt_n":5,"prompt_ms":634.566,"prompt_per_token_ms":126.9132,"prompt_per_second":7.879401039450585,"predicted_n":1,"predicted_ms":0.001,"predicted_per_token_ms":0.0,"predicted_per_second":0.0}}

Convert to probability:

probability = e^(logprob)
1 = e^(-0.00456317700445652) = ~99.5%
0 = e^(-5.395024299621582) = ~0.5%

Speed:

On my 170gb/s bandwidth 4gb vram GPU, I got 634ms! On a H200, I would probably get 30-75ms.

Multiple Questions at Once:
In theory you can ask multiple questions at once. You just gotta be clever with the math. For example:

Q1: Is it spam?
Q2: Is it phishing?
Q3: Is it urgent?
Q4: Is it malicious?

A = 0000, B = 0001, C = 0010, D = 0011, .... O = 1110, P = 1111 where each bit corresponds to a yes no answer. Let's say LLM answers with:

A 0.2% B 0.1% C 0.2% D 0.2% E 0.5% F 0.5% G 0.5% H 1.0% I 1.0% J 1.5% K 2.0% L 3.0% M 5.0% N 10.0% O 20.0% P 54.3%

These add up to 100%. To learn possibility of "Is it spam?", just sum tokens where first bit was 1 such as:

I + J + K + L + M + N + O + P = %96.8

Repeating the same logic, you could get:

Spam: 96.8%
Phishing: 91.8%
Urgent: 81.2%
Malicious: 70.6%