ggml-org/llama.cpp

llama : combined beam search + grammar sampling strategy

已關閉

#2,923 建立於 2023年8月31日

 (14 則留言) (20 個反應) (0 位負責人)C++ (21,737 個分叉)batch import
generation qualitygood first issueresearch 🔬roadmap

倉庫指標

星標
 (124,043 顆星)
PR 合併指標
 (平均合併 6天 8小時) (30 天內合併 389 個 PR)

描述

This feature was proposed by @spion in https://github.com/ggerganov/llama.cpp/issues/2813#issuecomment-1694390583

In some cases, its useful to do constrained evaluation of logits based on a union of possible text values, then pick the sum { logits } (i.e. product(probabilities)) that gives the most probable outcome overall.

E.g. template (using MS guidance)

{{#select 'armor'}}leather{{or}}chainmail{{or}}plate{{/select}}

To definitely make the best choice, we'd need to calculate the probability of all 3 token sequences. Its easy if all the choices map to a single token, but with multiple tokens we'd need not just parallel generation but parallel logit evaluation of multiple possible paths.

If we go greedy, we might get suboptimal results in cases multiple choices start with the same logit.

It should be possible to implement this by combining the existing beam search and grammar sampling features. See the discussion in the referenced comment for more info

貢獻者指南