Skip to content

samplers: adds top-n-sigma sampler - #841

Open
daniel-j-h wants to merge 1 commit into
antirez:mainfrom
daniel-j-h:feat/top-n-sigma
Open

samplers: adds top-n-sigma sampler#841
daniel-j-h wants to merge 1 commit into
antirez:mainfrom
daniel-j-h:feat/top-n-sigma

Conversation

@daniel-j-h

Copy link
Copy Markdown

Experimental: top n sigma sampler from https://arxiv.org/abs/2411.07641 samples logits: keeps tokens with logit >= max(logit) - n * std(logit) masks the rest to -inf and temperature softmax samples from these candidates.

Why it's an interesting sampler for ds4 and in use in a coding harness

  1. when the model is certain it's similar to greedy decoding; code stays exact
  2. when the model is uncertain e.g. in taking decisions the temp tunes exploration

Try it out e.g. by passing to the API "temperature":1.5,"top_n_sigma":1; recommended 0.5 < n < 2*sqrt(3).

Here's how to set this up in pi.dev https://pi.dev/docs/latest/models#sampling-parameters:

"samplingParams": { "temperature": 1.5, "top_n_sigma": 1 },

We need to experiment and see how it behaves especially with the heavily quantized versions.


I've experimentig with it for a while now via ggml-org/llama.cpp#11223 and there's more context here

  1. https://gist.github.com/Hellisotherpeople/71ba712f9f899adcb08b94bce20d5397
  2. https://news.ycombinator.com/item?id=43887637

As one of the min_p authors, I can confirm that Top N sigma is currently the best general purpose sampler by far. Also, temperature can and should be scaled far higher than it is today. Temps of 100 are totally fine with techniques like min_p and top N sigma.


Confirmed working on amd strix halo; fedora needs fixes #552 pi.dev needs config #561

Disclaimer: I have used deepseek-v4-flash with pi as a tool to assist in writing this changeset.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant