mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-11-03 09:22:01 +00:00 
			
		
		
		
	cont
ggml-ci
This commit is contained in:
		@@ -16,14 +16,14 @@ static bool llama_sample_grammar_string(struct llama_grammar * grammar, const st
 | 
			
		||||
    auto decoded = decode_utf8(input_str, {});
 | 
			
		||||
    const auto & code_points = decoded.first;
 | 
			
		||||
 | 
			
		||||
    const llama_grammar_rules  & prev_rules = llama_grammar_get_rules (grammar);
 | 
			
		||||
    const llama_grammar_rules  & rules      = llama_grammar_get_rules (grammar);
 | 
			
		||||
          llama_grammar_stacks & cur_stacks = llama_grammar_get_stacks(grammar);
 | 
			
		||||
 | 
			
		||||
    size_t pos = 0;
 | 
			
		||||
    for (auto it = code_points.begin(), end = code_points.end() - 1; it != end; ++it) {
 | 
			
		||||
        const llama_grammar_stacks prev_stacks = llama_grammar_get_stacks(grammar); // copy
 | 
			
		||||
 | 
			
		||||
        llama_grammar_accept(prev_rules, prev_stacks, *it, cur_stacks);
 | 
			
		||||
        llama_grammar_accept(rules, prev_stacks, *it, cur_stacks);
 | 
			
		||||
 | 
			
		||||
        if (cur_stacks.empty()) {
 | 
			
		||||
            error_pos = pos;
 | 
			
		||||
 
 | 
			
		||||
@@ -3,12 +3,6 @@
 | 
			
		||||
#define LLAMA_API_INTERNAL
 | 
			
		||||
#include "llama.h"
 | 
			
		||||
 | 
			
		||||
#include <array>
 | 
			
		||||
#include <set>
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <cstdint>
 | 
			
		||||
#include <random>
 | 
			
		||||
 | 
			
		||||
#ifdef __has_include
 | 
			
		||||
    #if __has_include(<unistd.h>)
 | 
			
		||||
        #include <unistd.h>
 | 
			
		||||
@@ -24,7 +18,7 @@
 | 
			
		||||
 | 
			
		||||
// bump if necessary
 | 
			
		||||
#define LLAMA_MAX_NODES   8192
 | 
			
		||||
#define LLAMA_MAX_LAYERS  256
 | 
			
		||||
#define LLAMA_MAX_LAYERS  512
 | 
			
		||||
#define LLAMA_MAX_EXPERTS 160  // DeepSeekV2
 | 
			
		||||
 | 
			
		||||
#ifdef __GNUC__
 | 
			
		||||
 
 | 
			
		||||
@@ -49,13 +49,13 @@ static bool match_string(const std::string & input, llama_grammar * grammar) {
 | 
			
		||||
 | 
			
		||||
    const auto & code_points = decoded.first;
 | 
			
		||||
 | 
			
		||||
    const llama_grammar_rules  & prev_rules = llama_grammar_get_rules (grammar);
 | 
			
		||||
    const llama_grammar_rules  & rules      = llama_grammar_get_rules (grammar);
 | 
			
		||||
          llama_grammar_stacks & cur_stacks = llama_grammar_get_stacks(grammar);
 | 
			
		||||
 | 
			
		||||
    for (auto it = code_points.begin(), end = code_points.end() - 1; it != end; ++it) {
 | 
			
		||||
        const llama_grammar_stacks prev_stacks = llama_grammar_get_stacks(grammar); // copy
 | 
			
		||||
 | 
			
		||||
        llama_grammar_accept(prev_rules, prev_stacks, *it, cur_stacks);
 | 
			
		||||
        llama_grammar_accept(rules, prev_stacks, *it, cur_stacks);
 | 
			
		||||
 | 
			
		||||
        if (cur_stacks.empty()) {
 | 
			
		||||
            // no stacks means that the grammar failed to match at this point
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user