]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
llama : add grammar-based sampling (#1773)
authorEvan Jones <redacted>
Mon, 24 Jul 2023 03:58:10 +0000 (23:58 -0400)
committerGitHub <redacted>
Mon, 24 Jul 2023 03:58:10 +0000 (23:58 -0400)
commit84e09a7d8bc4ab6d658b5cd81295ac0add60be78
tree934c5480d917325ac8baa29f4edfae99137b56bb
parent2f9cf974a066ac0e03fbb235d834b01b0164d743
llama : add grammar-based sampling (#1773)

* llama, main : constrain sampling to grammar

* allow loading grammar from file

* fix whitespace errors

* handle & print parser errors

* add comments to grammar syntax and allow newlines where unambiguous

* add missing include

* support alternates in root rule

* fix bugs with empty token and EOS

* adjust JSON grammar

* remove swp file

* rewrite ternary expressions

Co-authored-by: Henri Vasserman <redacted>
* use struct for grammar elements and add Unicode support

* add unicode escapes

* add inverse char ranges

* only sample full tokens (no peeking or truncation)

* llama : minor style changes

blindly applied in online editor - hopefully I didn't break something

* update help text

* add warning message if EOS is disabled

---------

Co-authored-by: Henri Vasserman <redacted>
Co-authored-by: Georgi Gerganov <redacted>
14 files changed:
Makefile
examples/CMakeLists.txt
examples/common.cpp
examples/common.h
examples/grammar-parser.cpp [new file with mode: 0644]
examples/grammar-parser.h [new file with mode: 0644]
examples/main/main.cpp
grammars/arithmetic.gbnf [new file with mode: 0644]
grammars/chess.gbnf [new file with mode: 0644]
grammars/japanese.gbnf [new file with mode: 0644]
grammars/json.gbnf [new file with mode: 0644]
grammars/list.gbnf [new file with mode: 0644]
llama.cpp
llama.h