]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
sampling : support for llguidance grammars (#10224)
authorMichaƂ Moskal <redacted>
Sun, 2 Feb 2025 07:55:32 +0000 (23:55 -0800)
committerGitHub <redacted>
Sun, 2 Feb 2025 07:55:32 +0000 (09:55 +0200)
commitff227703d6d6e1888bdc7af6138514092ffcdb96
tree919160924c1e1110feef7b3d1d2d012bd9751e17
parent0cec062a638700495673f5494d200b74340538be
sampling : support for llguidance grammars (#10224)

* initial porting of previous LLG patch

* update for new APIs

* build: integrate llguidance as an external project

* use '%llguidance' as marker to enable llg lark syntax

* add some docs

* clarify docs

* code style fixes

* remove llguidance.h from .gitignore

* fix tests when llg is enabled

* pass vocab not model to llama_sampler_init_llg()

* copy test-grammar-integration.cpp to test-llguidance.cpp

* clang fmt

* fix ref-count bug

* build and run test

* gbnf -> lark syntax

* conditionally include llguidance test based on LLAMA_LLGUIDANCE flag

* rename llguidance test file to test-grammar-llguidance.cpp

* add gh action for llg test

* align tests with LLG grammar syntax and JSON Schema spec

* llama_tokenizer() in fact requires valid utf8

* update llg

* format file

* add $LLGUIDANCE_LOG_LEVEL support

* fix whitespace

* fix warning

* include <cmath> for INFINITY

* add final newline

* fail llama_sampler_init_llg() at runtime

* Link gbnf_to_lark.py script; fix links; refer to llg docs for lexemes

* simplify #includes

* improve doc string for LLAMA_LLGUIDANCE

* typo in merge

* bump llguidance to 0.6.12
13 files changed:
.github/workflows/build.yml
CMakeLists.txt
common/CMakeLists.txt
common/json-schema-to-grammar.cpp
common/json-schema-to-grammar.h
common/llguidance.cpp [new file with mode: 0644]
common/sampling.cpp
common/sampling.h
docs/llguidance.md [new file with mode: 0644]
tests/CMakeLists.txt
tests/test-grammar-integration.cpp
tests/test-grammar-llguidance.cpp [new file with mode: 0644]
tests/test-json-schema-to-grammar.cpp