llguidance 0.7.10__tar.gz → 0.7.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. llguidance-0.7.12/CHANGELOG.md +118 -0
  2. {llguidance-0.7.10 → llguidance-0.7.12}/Cargo.lock +7 -7
  3. {llguidance-0.7.10 → llguidance-0.7.12}/PKG-INFO +1 -1
  4. {llguidance-0.7.10 → llguidance-0.7.12}/docs/json_schema.md +35 -0
  5. {llguidance-0.7.10 → llguidance-0.7.12}/docs/syntax.md +68 -18
  6. {llguidance-0.7.10 → llguidance-0.7.12}/json_stats/expected_maskbench.json +1152 -7
  7. {llguidance-0.7.10 → llguidance-0.7.12}/json_stats/jstats.sh +5 -0
  8. {llguidance-0.7.10 → llguidance-0.7.12}/json_stats/src/json_stats.rs +34 -6
  9. {llguidance-0.7.10 → llguidance-0.7.12}/parser/Cargo.toml +2 -2
  10. {llguidance-0.7.10 → llguidance-0.7.12}/parser/llguidance.h +6 -0
  11. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/api.rs +1 -0
  12. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/earley/from_guidance.rs +60 -61
  13. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/earley/grammar.rs +86 -36
  14. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/earley/lexerspec.rs +37 -10
  15. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/earley/mod.rs +1 -2
  16. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/earley/parser.rs +15 -35
  17. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/earley/regexvec.rs +14 -2
  18. llguidance-0.7.12/parser/src/earley/slicer.rs +394 -0
  19. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/factory.rs +29 -38
  20. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/ffi.rs +124 -63
  21. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/grammar_builder.rs +21 -24
  22. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/compiler.rs +19 -1
  23. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/lark/lexer.rs +1 -1
  24. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/lib.rs +1 -0
  25. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/matcher.rs +20 -1
  26. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/tokenparser.rs +13 -37
  27. {llguidance-0.7.10 → llguidance-0.7.12}/pyproject.toml +1 -1
  28. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/__init__.py +2 -0
  29. llguidance-0.7.12/python/llguidance/_struct_tag.py +118 -0
  30. {llguidance-0.7.10 → llguidance-0.7.12}/python/torch_tests/test_hf.py +22 -1
  31. {llguidance-0.7.10 → llguidance-0.7.12}/python/torch_tests/test_matcher.py +84 -4
  32. {llguidance-0.7.10 → llguidance-0.7.12}/python_ext/Cargo.toml +1 -1
  33. {llguidance-0.7.10 → llguidance-0.7.12}/python_ext/src/llinterpreter.rs +10 -12
  34. {llguidance-0.7.10 → llguidance-0.7.12}/python_ext/src/llmatcher.rs +10 -17
  35. {llguidance-0.7.10 → llguidance-0.7.12}/python_ext/src/py.rs +1 -2
  36. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/src/lib.rs +15 -3
  37. llguidance-0.7.12/sample_parser/src/minimal.rs +83 -0
  38. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/src/sample_parser.rs +52 -110
  39. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/tests/test_lark.rs +6 -3
  40. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/tests/test_ll.rs +175 -2
  41. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/bump.py +28 -0
  42. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/Cargo.toml +1 -1
  43. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/src/tokenv.rs +12 -1
  44. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/src/toktree.rs +20 -1
  45. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie_hf_downloader/Cargo.toml +1 -1
  46. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie_hf_tokenizers/Cargo.toml +1 -1
  47. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie_hf_tokenizers/src/lib.rs +5 -18
  48. llguidance-0.7.10/parser/src/earley/slicer.rs +0 -249
  49. llguidance-0.7.10/sample_parser/src/minimal.rs +0 -179
  50. {llguidance-0.7.10 → llguidance-0.7.12}/.github/workflows/rust.yml +0 -0
  51. {llguidance-0.7.10 → llguidance-0.7.12}/.github/workflows/wheels.yml +0 -0
  52. {llguidance-0.7.10 → llguidance-0.7.12}/.gitignore +0 -0
  53. {llguidance-0.7.10 → llguidance-0.7.12}/CODE_OF_CONDUCT.md +0 -0
  54. {llguidance-0.7.10 → llguidance-0.7.12}/Cargo.toml +0 -0
  55. {llguidance-0.7.10 → llguidance-0.7.12}/LICENSE +0 -0
  56. {llguidance-0.7.10 → llguidance-0.7.12}/README.md +0 -0
  57. {llguidance-0.7.10 → llguidance-0.7.12}/SECURITY.md +0 -0
  58. {llguidance-0.7.10 → llguidance-0.7.12}/SUPPORT.md +0 -0
  59. {llguidance-0.7.10 → llguidance-0.7.12}/c_sample/Makefile +0 -0
  60. {llguidance-0.7.10 → llguidance-0.7.12}/c_sample/README.md +0 -0
  61. {llguidance-0.7.10 → llguidance-0.7.12}/c_sample/c_sample.cpp +0 -0
  62. {llguidance-0.7.10 → llguidance-0.7.12}/docs/fast_forward.md +0 -0
  63. {llguidance-0.7.10 → llguidance-0.7.12}/docs/mask_plot.png +0 -0
  64. {llguidance-0.7.10 → llguidance-0.7.12}/docs/optimizations.md +0 -0
  65. {llguidance-0.7.10 → llguidance-0.7.12}/docs/special_tokens.md +0 -0
  66. {llguidance-0.7.10 → llguidance-0.7.12}/docs/toktrie.md +0 -0
  67. {llguidance-0.7.10 → llguidance-0.7.12}/json_stats/Cargo.toml +0 -0
  68. {llguidance-0.7.10 → llguidance-0.7.12}/json_stats/scripts/split-stats.sh +0 -0
  69. {llguidance-0.7.10 → llguidance-0.7.12}/json_stats/scripts/split_plot.py +0 -0
  70. {llguidance-0.7.10 → llguidance-0.7.12}/json_stats/src/lib.rs +0 -0
  71. {llguidance-0.7.10 → llguidance-0.7.12}/json_stats/src/stats.rs +0 -0
  72. {llguidance-0.7.10 → llguidance-0.7.12}/parser/LICENSE +0 -0
  73. {llguidance-0.7.10 → llguidance-0.7.12}/parser/README.md +0 -0
  74. {llguidance-0.7.10 → llguidance-0.7.12}/parser/build.rs +0 -0
  75. {llguidance-0.7.10 → llguidance-0.7.12}/parser/cbindgen.toml +0 -0
  76. {llguidance-0.7.10 → llguidance-0.7.12}/parser/grammars/character.json +0 -0
  77. {llguidance-0.7.10 → llguidance-0.7.12}/parser/grammars/json.json +0 -0
  78. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/constraint.rs +0 -0
  79. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/earley/lexer.rs +0 -0
  80. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/earley/perf.rs +0 -0
  81. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/ffi_par.rs +0 -0
  82. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/README.md +0 -0
  83. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/context_ref.rs +0 -0
  84. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/context_simple/context.rs +0 -0
  85. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/context_simple/draft.rs +0 -0
  86. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/context_simple/mod.rs +0 -0
  87. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/formats.rs +0 -0
  88. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/mod.rs +0 -0
  89. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/numeric.rs +0 -0
  90. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/schema.rs +0 -0
  91. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json/shared_context.rs +0 -0
  92. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/json_validation.rs +0 -0
  93. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/lark/README.md +0 -0
  94. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/lark/ast.rs +0 -0
  95. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/lark/common.rs +0 -0
  96. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/lark/compiler.rs +0 -0
  97. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/lark/mod.rs +0 -0
  98. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/lark/parser.rs +0 -0
  99. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/logging.rs +0 -0
  100. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/output.rs +0 -0
  101. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/panic_utils.rs +0 -0
  102. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/stop_controller.rs +0 -0
  103. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/substring.rs +0 -0
  104. {llguidance-0.7.10 → llguidance-0.7.12}/parser/src/tokenizer_json.rs +0 -0
  105. {llguidance-0.7.10 → llguidance-0.7.12}/plan.md +0 -0
  106. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/_grammar_from.py +0 -0
  107. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/_lib.pyi +0 -0
  108. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/_tokenizer.py +0 -0
  109. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/_util.py +0 -0
  110. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/cli.py +0 -0
  111. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/gbnf_to_lark.py +0 -0
  112. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/hf.py +0 -0
  113. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/mlx.py +0 -0
  114. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/numpy.py +0 -0
  115. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/py.typed +0 -0
  116. {llguidance-0.7.10 → llguidance-0.7.12}/python/llguidance/torch.py +0 -0
  117. {llguidance-0.7.10 → llguidance-0.7.12}/python/mypy.ini +0 -0
  118. {llguidance-0.7.10 → llguidance-0.7.12}/python/torch_tests/__init__.py +0 -0
  119. {llguidance-0.7.10 → llguidance-0.7.12}/python/torch_tests/test_bitmask.py +0 -0
  120. {llguidance-0.7.10 → llguidance-0.7.12}/python_ext/src/lib.rs +0 -0
  121. {llguidance-0.7.10 → llguidance-0.7.12}/python_ext/src/pyjson.rs +0 -0
  122. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/Cargo.toml +0 -0
  123. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/README.md +0 -0
  124. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/cli.sh +0 -0
  125. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/blog.sample.json +0 -0
  126. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/blog.schema.json +0 -0
  127. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/blog.schema.ll.json +0 -0
  128. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/README.md +0 -0
  129. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/arithmetic.gbnf +0 -0
  130. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/c.gbnf +0 -0
  131. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/chess.gbnf +0 -0
  132. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/english.gbnf +0 -0
  133. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/japanese.gbnf +0 -0
  134. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/json.gbnf +0 -0
  135. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/json_arr.gbnf +0 -0
  136. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/list.gbnf +0 -0
  137. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/from-llama.cpp/vllm-sql.gbnf +0 -0
  138. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/lark.lark +0 -0
  139. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/rfc.lark +0 -0
  140. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/data/rfc.xml +0 -0
  141. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/gtest.sh +0 -0
  142. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/lark.sh +0 -0
  143. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/run.sh +0 -0
  144. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/tests/test_raw_parser.rs +0 -0
  145. {llguidance-0.7.10 → llguidance-0.7.12}/sample_parser/tests/test_stop.rs +0 -0
  146. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/annotate_asm.js +0 -0
  147. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/cbindgen.sh +0 -0
  148. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/checklinks.py +0 -0
  149. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/checklinks.sh +0 -0
  150. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/ci-publish.py +0 -0
  151. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/disasm.sh +0 -0
  152. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/gbnf_to_lark.py +0 -0
  153. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/gen-testcase.py +0 -0
  154. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/git-version.sh +0 -0
  155. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/install-deps.sh +0 -0
  156. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/jsonschema-stats.js +0 -0
  157. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/remote-guidance-test.sh +0 -0
  158. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/rust-size.js +0 -0
  159. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/rust_size.py +0 -0
  160. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/test-guidance.sh +0 -0
  161. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/tokenizer_test.py +0 -0
  162. {llguidance-0.7.10 → llguidance-0.7.12}/scripts/update-git.py +0 -0
  163. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/LICENSE +0 -0
  164. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/README.md +0 -0
  165. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/src/bytes.rs +0 -0
  166. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/src/lib.rs +0 -0
  167. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/src/recognizer.rs +0 -0
  168. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/src/rng.rs +0 -0
  169. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/src/svob.rs +0 -0
  170. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie/tests/test_svob.rs +0 -0
  171. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie_hf_downloader/LICENSE +0 -0
  172. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie_hf_downloader/src/lib.rs +0 -0
  173. {llguidance-0.7.10 → llguidance-0.7.12}/toktrie_hf_tokenizers/LICENSE +0 -0
@@ -0,0 +1,118 @@
1
+ ### Changelog
2
+
3
+ All notable changes to this project will be documented in this file. Dates are displayed in UTC.
4
+
5
+ If a release doesn't introduce any interesting changes (build fixes etc.), it's skipped.
6
+
7
+ #### [0.7.12](https://github.com/guidance-ai/llguidance/compare/v0.7.11...0.7.12) 2025-04-04
8
+
9
+ - performance optimizations
10
+ - use factory in C FFI (otherwise slicer was not used)
11
+ - add some null checks and safety comments in C FFI
12
+ - implement subgrammar lexeme class merging; fixes [`#113`](https://github.com/guidance-ai/llguidance/issues/113)
13
+
14
+ #### [0.7.11](https://github.com/guidance-ai/llguidance/compare/v0.7.10...0.7.11) 2025-03-27
15
+
16
+ - add StructTag python API; fixes [`#146`](https://github.com/guidance-ai/llguidance/issues/146)
17
+ - fix handling of AddedToken.special (gemma tokenizer, fixes [`#147`](https://github.com/guidance-ai/llguidance/issues/147))
18
+ - handle incomplete tokenizers (SmolLM); fixes [`#138`](https://github.com/guidance-ai/llguidance/issues/138)
19
+ - fix `validate_token_raw([EOS])` bug
20
+
21
+ #### [v0.7.10](https://github.com/guidance-ai/llguidance/compare/v0.7.9...v0.7.10) 2025-03-25
22
+
23
+ - add `llg_matcher_*()` functions to C interface [`#145`](https://github.com/guidance-ai/llguidance/pull/145)
24
+ - always pass validation of grammars with special tokens without tokenizer [`0892a2a`](https://github.com/guidance-ai/llguidance/commit/0892a2adb5c8d818c025fe554bd67f05a5770aa7)
25
+
26
+ #### [v0.7.9](https://github.com/guidance-ai/llguidance/compare/v0.7.8...v0.7.9) 2025-03-24
27
+
28
+ - improve Python `LLMatcher.validate_grammar()` [`6b5f5ed`](https://github.com/guidance-ai/llguidance/commit/6b5f5eda7ca85ae2ca9a76c3813a0162a8b99b45)
29
+
30
+ #### [v0.7.6](https://github.com/guidance-ai/llguidance/compare/v0.7.5...v0.7.6) 2025-03-21
31
+
32
+ - Stabilize JSON schema property order [`#134`](https://github.com/guidance-ai/llguidance/pull/134)
33
+
34
+ #### [v0.7.5](https://github.com/guidance-ai/llguidance/compare/v0.7.4...v0.7.5) 2025-03-21
35
+
36
+ - add toktrie_hf_downloader crate [`11bea00`](https://github.com/guidance-ai/llguidance/commit/11bea00ecd1ef3c4a8970c1748db829e0c8a14de)
37
+ - use hf tokenizers library in python ext [`61728be`](https://github.com/guidance-ai/llguidance/commit/61728be47828525e959f6db226a0f17a783442bc)
38
+ - add LLTokenizer.tokenize_partial [`893cedf`](https://github.com/guidance-ai/llguidance/commit/893cedf614e234bd86bf01a99772d846b6ea884b)
39
+
40
+ #### [v0.7.4](https://github.com/guidance-ai/llguidance/compare/v0.7.3...v0.7.4) 2025-03-20
41
+
42
+ - fix gbnf parsing [`e5828b8`](https://github.com/guidance-ai/llguidance/commit/e5828b8a7a2fffaa9cf1aa2619c603a3d4ec7e17)
43
+
44
+ #### [v0.7.3](https://github.com/guidance-ai/llguidance/compare/v0.7.2...v0.7.3) 2025-03-19
45
+
46
+ - add LLMatcher.validate_grammar(); make it never raise [`0f8ec60`](https://github.com/guidance-ai/llguidance/commit/0f8ec6088a28eda13c2dd3d537733c0648e00cb3)
47
+ - add LLMatcher.reset() [`6a70aa7`](https://github.com/guidance-ai/llguidance/commit/6a70aa7efa8121fcd1865cefa9998926852eee25)
48
+
49
+ #### [v0.7.2](https://github.com/guidance-ai/llguidance/compare/v0.7.1...v0.7.2) 2025-03-18
50
+
51
+ - don't go into error state on final EOS [`1f0f21d`](https://github.com/guidance-ai/llguidance/commit/1f0f21d41fe88427d065b09414047d76b8b32041)
52
+
53
+ #### [v0.7.1](https://github.com/guidance-ai/llguidance/compare/v0.7.0...v0.7.1) 2025-03-18
54
+
55
+ - add `LLMatcher` interface in python
56
+ - add whitespace_pattern to JsonCompileOptions [`04a5491`](https://github.com/guidance-ai/llguidance/commit/04a54912cf6d082669674340833f06385f7b66f8)
57
+ - enable mypy in CI [`#140`](https://github.com/guidance-ai/llguidance/pull/140)
58
+ - add py.typed for annotations information [`#139`](https://github.com/guidance-ai/llguidance/pull/139)
59
+ - fix clippy warnings
60
+
61
+ #### [v0.7.0](https://github.com/guidance-ai/llguidance/compare/v0.6.31...v0.7.0) 2025-03-07
62
+
63
+ - remove JSON-based grammar serialization [`#133`](https://github.com/guidance-ai/llguidance/pull/133)
64
+
65
+ #### [v0.6.31](https://github.com/guidance-ai/llguidance/compare/v0.6.29...v0.6.31) 2025-03-05
66
+
67
+ - fix https://github.com/guidance-ai/guidance/issues/1131 - backtracking+prompt healing [`#1131`](https://github.com/guidance-ai/guidance/issues/1131)
68
+ - optimize substring [`9950600`](https://github.com/guidance-ai/llguidance/commit/9950600f46e433b4c42506f8816f61cee331774f)
69
+
70
+ #### [v0.6.29](https://github.com/guidance-ai/llguidance/compare/v0.6.28...v0.6.29) 2025-02-25
71
+
72
+ - [JSON] "x-guidance" JsonCompileOptions [`#130`](https://github.com/guidance-ai/llguidance/pull/130)
73
+
74
+ #### [v0.6.28](https://github.com/guidance-ai/llguidance/compare/v0.6.27...v0.6.28) 2025-02-21
75
+
76
+ - support for rollback() [`#126`](https://github.com/guidance-ai/llguidance/pull/126)
77
+ - allow lexer to produce alternative lexemes [`#124`](https://github.com/guidance-ai/llguidance/pull/124)
78
+ - make tokenize_with_greedy_fallback() handle invalid UTF not only at the end [`4762895`](https://github.com/guidance-ai/llguidance/commit/476289558d7d1edefe42eb87a093865debae8129)
79
+ - rise default lexer state limit from 50k to 250k [`202d3d5`](https://github.com/guidance-ai/llguidance/commit/202d3d545c14c63a62017b228c424a603619eb2a)
80
+
81
+ #### [v0.6.27](https://github.com/guidance-ai/llguidance/compare/v0.6.26...v0.6.27) 2025-02-18
82
+
83
+ - fix #122: captures with nullable symbols [`#122`](https://github.com/guidance-ai/llguidance/issues/122)
84
+
85
+ #### [v0.6.26](https://github.com/guidance-ai/llguidance/compare/v0.6.25...v0.6.26) 2025-02-14
86
+
87
+ - Extend Token::Number to match floats in scientific notation [`#121`](https://github.com/guidance-ai/llguidance/pull/121)
88
+ - native [suffix=...] support [`6d648c7`](https://github.com/guidance-ai/llguidance/commit/6d648c748bed4d83db28ed96ea87ad40ea51bc7e)
89
+
90
+ #### [v0.6.25](https://github.com/guidance-ai/llguidance/compare/v0.6.16...v0.6.25) 2025-02-12
91
+
92
+ - update referencing to 0.29.0 [`#118`](https://github.com/guidance-ai/llguidance/pull/118)
93
+ - Allow passing string for `capture_name` in lark syntax [`#119`](https://github.com/guidance-ai/llguidance/pull/119)
94
+
95
+ Plus a few releases messing with, deps, unsafe code cleanup.
96
+
97
+ #### [v0.6.16](https://github.com/guidance-ai/llguidance/compare/v0.6.15...v0.6.16) 2025-02-06
98
+
99
+ - Port over guidance's 'substring' [`#116`](https://github.com/guidance-ai/llguidance/pull/116)
100
+ - add %regex {...} syntax in lark for substrings [`b5ab086`](https://github.com/guidance-ai/llguidance/commit/b5ab0861e819b6e9221ef0aed3fcc827d6bad316)
101
+
102
+ #### [v0.6.15](https://github.com/guidance-ai/llguidance/compare/v0.6.14...v0.6.15) 2025-02-04
103
+
104
+ - move gbnf_to_lark to llguidance python pkg [`53134f1`](https://github.com/guidance-ai/llguidance/commit/53134f1befc6b6019bc88406e21b51c901943b51)
105
+ - add LLExecutor and fill_next_token_bitmask_par() [`ba4b917`](https://github.com/guidance-ai/llguidance/commit/ba4b9175b8d6c5445e1c0bcc8d5ef8e62b6cf73c)
106
+
107
+ #### [v0.6.14](https://github.com/guidance-ai/llguidance/compare/v0.6.13...v0.6.14) 2025-02-03
108
+
109
+ - add llguidance.numpy and llguidance.mlx submodules [`c627a39`](https://github.com/guidance-ai/llguidance/commit/c627a39689c9147fe7b072e5075960d16d43fc73)
110
+
111
+ #### [v0.6.13](https://github.com/guidance-ai/llguidance/compare/v0.6.12...v0.6.13) 2025-02-03
112
+
113
+ - add llguidance.torch and llguidance.hf submodules [`3fcdb1d`](https://github.com/guidance-ai/llguidance/commit/3fcdb1d93af076bbc8f1b3bef6fa9ead22b3e959)
114
+
115
+ #### [v0.6.12](https://github.com/guidance-ai/llguidance/compare/v0.6.11...v0.6.12) 2025-01-31
116
+
117
+ - fixes for numeric tokens [`b7c9970`](https://github.com/guidance-ai/llguidance/commit/b7c99709a9cb7f7a8a3c4716092e4d94fae2ff2c)
118
+ - make capture explicit in lark syntax [`2a57678`](https://github.com/guidance-ai/llguidance/commit/2a57678d9397e8be54cb0c9f14c4270604f8e1a5)
@@ -401,9 +401,9 @@ dependencies = [
401
401
 
402
402
  [[package]]
403
403
  name = "derivre"
404
- version = "0.3.1"
404
+ version = "0.3.4"
405
405
  source = "registry+https://github.com/rust-lang/crates.io-index"
406
- checksum = "3a3c2606b3ffc46f91fd62d954d55659ba9fb391bb673311b70f50daf9c15e49"
406
+ checksum = "310c9990c5a531352e274c8c929ca667a84b6bbaceb1e095c177e6a979807f57"
407
407
  dependencies = [
408
408
  "ahash",
409
409
  "anyhow",
@@ -1177,7 +1177,7 @@ checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
1177
1177
 
1178
1178
  [[package]]
1179
1179
  name = "llguidance"
1180
- version = "0.7.10"
1180
+ version = "0.7.12"
1181
1181
  dependencies = [
1182
1182
  "anyhow",
1183
1183
  "derivre",
@@ -1196,7 +1196,7 @@ dependencies = [
1196
1196
 
1197
1197
  [[package]]
1198
1198
  name = "llguidance_py"
1199
- version = "0.7.10"
1199
+ version = "0.7.12"
1200
1200
  dependencies = [
1201
1201
  "anyhow",
1202
1202
  "bytemuck",
@@ -2356,7 +2356,7 @@ dependencies = [
2356
2356
 
2357
2357
  [[package]]
2358
2358
  name = "toktrie"
2359
- version = "0.7.10"
2359
+ version = "0.7.12"
2360
2360
  dependencies = [
2361
2361
  "anyhow",
2362
2362
  "bytemuck",
@@ -2367,7 +2367,7 @@ dependencies = [
2367
2367
 
2368
2368
  [[package]]
2369
2369
  name = "toktrie_hf_downloader"
2370
- version = "0.7.10"
2370
+ version = "0.7.12"
2371
2371
  dependencies = [
2372
2372
  "anyhow",
2373
2373
  "hf-hub",
@@ -2378,7 +2378,7 @@ dependencies = [
2378
2378
 
2379
2379
  [[package]]
2380
2380
  name = "toktrie_hf_tokenizers"
2381
- version = "0.7.10"
2381
+ version = "0.7.12"
2382
2382
  dependencies = [
2383
2383
  "anyhow",
2384
2384
  "log",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llguidance
3
- Version: 0.7.10
3
+ Version: 0.7.12
4
4
  License-File: LICENSE
5
5
  Summary: Bindings for the Low-level Guidance (llguidance) Rust library for use within Guidance
6
6
  Author: Michal Moskal
@@ -56,6 +56,41 @@ Number features (for both integer and number):
56
56
  - order of object properties is fixed, see below
57
57
  - string `format` is enforced by default, with unrecognized or unimplemented formats returning errors
58
58
 
59
+ ## Whitespace handling
60
+
61
+ By default any whitespace is allowed inside of the JSON object.
62
+ Whitespace is not allowed before the first `{` or after the last `}`.
63
+ You can modify your grammar easily to allow initial or trailing whitespace.
64
+
65
+ You can set top-level `"x-guidance"` key to control this.
66
+ Following keys are available inside of it:
67
+
68
+ - `item_separator`, defaults to `":"`
69
+ - `key_separator`, defaults to `","`
70
+ - `whitespace_flexible`, defaults to `true`; set to `false` to enforce compact JSON representation
71
+ - `whitespace_pattern`, optional string, overrides `whitespace_flexible`;
72
+ `whitespace_flexible: true` is equivalent to `whitespace_pattern: r"[\x20\x0A\x0D\x09]+"`
73
+ - `coerce_one_of`, defaults to `false`; when set to `true`, the `"oneOf"` will be treated as `"anyOf"`
74
+
75
+ For example:
76
+
77
+ ```json
78
+ {
79
+ "x-guidance": {
80
+ "whitespace_flexible": false
81
+ },
82
+ "type": "object",
83
+ "properties": {
84
+ "a": {
85
+ "type": "string"
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ The `"x-guidance"` key is only recognized at the top level of the schema.
92
+
93
+
59
94
  ## Property order
60
95
 
61
96
  ### TL;DR
@@ -116,8 +116,7 @@ Often, the chat format already includes initial `<think>\n` - in these cases
116
116
  you can use `start: /(.|\n)*/ </think> json` as the grammar.
117
117
  You can also use `/(.|\n){1000,3000}/` to place lower and upper bounds on the thinking amount.
118
118
 
119
-
120
- This assumes `<think>` is a special token. If it was just a string, you would need
119
+ This assumes `<think>` is a special token. If it was just a string, you would need
121
120
  to use [`suffix="</think>"`](#lazy-lexemes).
122
121
 
123
122
  ### Lexeme options
@@ -135,7 +134,7 @@ Example: `mygen[stop="\n", max_tokens=10, temperature=0.7]: /.*/`
135
134
  The `temperature` alters temperature while sampling tokens inside of the terminal,
136
135
  while `max_tokens` limits the number of tokens generated for the terminal.
137
136
 
138
- #### Lazy lexemes
137
+ ### Lazy lexemes
139
138
 
140
139
  Specifying `stop=""` will make the EOS token of the model act as the stop condition.
141
140
  This is only useful if there is some other rule following this rule (otherwise the model will stop on EOS anyways),
@@ -187,20 +186,36 @@ If it doesn't, the results may be surprising:
187
186
  for example, `foo[lazy]: /.*/` will match only the empty string,
188
187
  while `foo[lazy]: /[0-9]+/` will only match a single digit.
189
188
 
190
- Typical use of `suffix` or `lazy` is for models that were finetuned for reasoning or
191
- tool calling without special tokens, but with special strings. For example:
189
+ ### Tool calling
190
+
191
+ Some models have been finetuned to use normal text, not special tokens, for tool calling.
192
+ Here's an example how `lazy` can be used to allow any text interspersed with
193
+ tool calls:
192
194
 
193
195
  ```lark
194
- start: "<tool_name>" name "<tool_data>" data "</tool_data>"
195
- name[capture, suffix="</tool_name>"]: /.*/
196
- data[capture]: %json {
197
- "properties": {
198
- "foo": { "type": "string" }
199
- },
200
- "required": ["foo"]
201
- }
196
+ start: ( f_foo | f_bar )* f_end
197
+ f_end: TEXT
198
+ TEXT: /(.|\n)*/
199
+
200
+ f_foo_hd[lazy]: TEXT "<function"
201
+ f_foo: f_foo_hd "=foo>" %json { "type": "object" } "</function>"
202
+
203
+ f_bar_hd[lazy]: TEXT "<function"
204
+ f_bar: f_bar_hd "=bar>" /[0-9]+/ "</function>"
202
205
  ```
203
206
 
207
+ The above allows for anything, until the text `<function` is generated.
208
+ Then it will force the model to choose between `=foo>` or `=bar>`.
209
+ Then we'll either enforce valid JSON or a number, followed by string `</function>`.
210
+ Then again any text is allowed, etc.
211
+
212
+ Note that the tool call can be missing algtogether, you can change `*` to `+` if you want to enforce at least one tool call.
213
+ You can also change the definition of `TEXT` to limit the free-form text.
214
+
215
+ See [Special tokens](#special-tokens) if the "trigger" for the tool call is a special token
216
+ like `<|python_tag|>`, not a string like `<function`.
217
+
218
+ The `llguidance.StructTag` API, [inspired](https://github.com/mlc-ai/xgrammar/blob/fd9ee31/python/xgrammar/grammar.py#L211) by XGrammar, just compiles down to the above.
204
219
 
205
220
  ### Structured %regex
206
221
 
@@ -221,8 +236,6 @@ Additionally, "structured" regex nodes can be defined using `%regex { ... }` syn
221
236
 
222
237
  #### Substring
223
238
 
224
- **The syntax is not stable yet!**
225
-
226
239
  `%regex { "substring_chunks": lst }` will match `lst[n:m].join("")` for some `n <= m <= len(lst)`.
227
240
  Additionally `substring_words` or `substring_chars` can be specified.
228
241
  For example:
@@ -280,12 +293,13 @@ that llguidance should be used to process the grammar.
280
293
  ### Multiple grammars
281
294
 
282
295
  The input to LLGuidance consists of a list of grammars. This can be accessed via
283
- [LLGuidance API](../parser/src/api.rs). Each of these can be a Lark grammar, a JSON schema,
284
- or a grammar in the API format. With the introduction of `%json` in Lark syntax
296
+ [LLGuidance API](../parser/src/api.rs). Each of these can be a Lark grammar or a JSON schema.
297
+ With the introduction of `%json` in Lark syntax
285
298
  there is less need now for using multiple grammars, but it is still supported.
299
+ We may add nested lark grammars in future.
286
300
 
287
301
  Inside of Lark grammar, you can reference other grammars using syntax like `@my_grammar`,
288
- refering to grammar with `"name": "my_grammar"` (numeric reference like `@17` are no longer supported).
302
+ refering to grammar with `"name": "my_grammar"` (numeric reference like `@17` are **no longer supported**).
289
303
  The top-level grammar is at index 0.
290
304
 
291
305
  You can specify temperature for subgrammar by referencing it via
@@ -304,6 +318,42 @@ Example:
304
318
  }
305
319
  ```
306
320
 
321
+ #### Subgrammar details
322
+
323
+ Generally, subgrammars share the same context-free grammar but have a separate
324
+ set of lexemes (lexeme class).
325
+ The parser keeps track of a stack of lexeme classes, and considers the top one
326
+ to be the current lexeme class.
327
+ The `%ignore` is applied based on the top lexeme class.
328
+
329
+ Temperature and `max_tokens` can be applied to the current lexeme class as well.
330
+
331
+ There may be issues with subgrammars spanning LLM token boundaries.
332
+
333
+ If two lexeme classes share the `%ignore` regex, and `max_tokens=` and `temperature=`
334
+ are not used, the lexeme classes are merged, which generally allows for parsing
335
+ of more grammars.
336
+ For example, consider:
337
+
338
+ ```lark
339
+ start: a | b
340
+ a: %json { A }
341
+ b: %json { B }
342
+ ```
343
+
344
+ Normally, the parser would have to pick between lexeme class for either A or B
345
+ at the first `{` (it would always pick A since it comes first in the grammar).
346
+ However, if the classes for A and B are merged, the grammar will be equivalent to
347
+ `start: %json { "anyOf": [A, B] }` which is generally what the
348
+ [users expect](https://github.com/guidance-ai/llguidance/issues/113).
349
+
350
+
351
+ ### Features to avoid
352
+
353
+ - `stop=...` - use `suffix=...` or just `lazy`
354
+ - `max_tokens=...` - any use of `max_tokens` will disable rollback, which is needed for spec-decoding; it also makes the parser slower and prevents subgrammar merging
355
+ - `temperature=...` - this is not supported in most server side integrations and prevents subgrammar merging
356
+
307
357
  ### Unsupported Lark features
308
358
 
309
359
  Following features of Lark syntax are currently not supported: