mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-31 08:51:55 +00:00 
			
		
		
		
	llama : refactor sampling v2 (#9294)
- Add `struct llama_sampler` and `struct llama_sampler_i` - Add `llama_sampler_` API - Add `llama_sampler_chain_` API for chaining multiple samplers - Remove `LLAMA_API_INTERNAL` - Add `llama_perf_` API and remove old `llama_print_timings` and `llama_reset_timings`
This commit is contained in:
		| @@ -1,29 +0,0 @@ | ||||
| // Implements a parser for an extended Backus-Naur form (BNF), producing the | ||||
| // binary context-free grammar format specified by llama.h. Supports character | ||||
| // ranges, grouping, and repetition operators. As an example, a grammar for | ||||
| // arithmetic might look like: | ||||
| // | ||||
| // root  ::= expr | ||||
| // expr  ::= term ([-+*/] term)* | ||||
| // term  ::= num | "(" space expr ")" space | ||||
| // num   ::= [0-9]+ space | ||||
| // space ::= [ \t\n]* | ||||
|  | ||||
| #pragma once | ||||
| #include "llama.h" | ||||
| #include <vector> | ||||
| #include <map> | ||||
| #include <cstdint> | ||||
| #include <string> | ||||
|  | ||||
| namespace grammar_parser { | ||||
|     struct parse_state { | ||||
|         std::map<std::string, uint32_t>                 symbol_ids; | ||||
|         std::vector<std::vector<llama_grammar_element>> rules; | ||||
|  | ||||
|         std::vector<const llama_grammar_element *> c_rules(); | ||||
|     }; | ||||
|  | ||||
|     parse_state parse(const char * src); | ||||
|     void print_grammar(FILE * file, const parse_state & state); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Georgi Gerganov
					Georgi Gerganov