Skip to content

Commit abe0829

Browse files
committed
Add '// Beam search' heading to llama.{h,cpp} after llama_grammar_accept_token().
1 parent c4269e0 commit abe0829

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

llama.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4326,6 +4326,10 @@ void llama_grammar_accept_token(struct llama_context * ctx, struct llama_grammar
43264326
ctx->t_sample_us += ggml_time_us() - t_start_sample_us;
43274327
}
43284328

4329+
//
4330+
// Beam search
4331+
//
4332+
43294333
struct llama_beam {
43304334
std::vector<llama_token> tokens;
43314335
float p; // Cumulative beam probability (renormalized relative to all beams)

llama.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,10 @@ extern "C" {
465465
/// @details Accepts the sampled token into the grammar
466466
LLAMA_API void llama_grammar_accept_token(struct llama_context * ctx, struct llama_grammar * grammar, llama_token token);
467467

468+
//
469+
// Beam search
470+
//
471+
468472
struct llama_beam_view {
469473
llama_token const* tokens;
470474
size_t n_tokens;
@@ -482,6 +486,7 @@ extern "C" {
482486
size_t common_prefix_length; // Current max length of prefix tokens shared by all beams.
483487
bool last_call; // True iff this is the last callback invocation.
484488
};
489+
485490
// Type of pointer to the beam_search_callback function.
486491
// void* callback_data is any custom data passed to llama_beam_search, that is subsequently
487492
// passed back to beam_search_callback. This avoids having to use global variables in the callback.

0 commit comments

Comments
 (0)