Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix #18

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
191aa3a
add unicode test
Saibo-creator Feb 7, 2024
1036680
support parsing unicode
Saibo-creator Feb 7, 2024
ab2f2bd
use dynamical char_acceptance_at_element implementation
Saibo-creator Feb 7, 2024
f1b6e7e
change rule_offsets from dict to array, aligning with llama-cpp
Saibo-creator Feb 9, 2024
79511b5
more flexible GrammarRecognizer construct, aligning with llama-cpp
Saibo-creator Feb 9, 2024
d0c2ccf
add utf8 decoding utils
Saibo-creator Feb 9, 2024
1f3807f
add a bit more on decode utf8, including two NotImplementedError:
Saibo-creator Feb 9, 2024
783b1bc
unicode acceptance is working
Saibo-creator Feb 13, 2024
704e5a5
fix repetition_penalty issue; add tests for running examples
Saibo-creator Feb 13, 2024
bb7225f
v0.1.2
Saibo-creator Feb 13, 2024
ebc6c20
add github workflow, add badges on README and skip example testing lo…
Saibo-creator Feb 13, 2024
369cf8c
install pytest dependency in github workflow
Saibo-creator Feb 13, 2024
7d6767d
update requirements.txt
Saibo-creator Feb 13, 2024
9900dda
set numpy version to 1.24.2
Saibo-creator Feb 13, 2024
15f154f
del workflow
Saibo-creator Feb 13, 2024
b762873
support parsing unicode
Saibo-creator Feb 7, 2024
af65c70
use dynamical char_acceptance_at_element implementation
Saibo-creator Feb 7, 2024
c8e9ee6
add utf8 decoding utils
Saibo-creator Feb 9, 2024
a524120
add a bit more on decode utf8, including two NotImplementedError:
Saibo-creator Feb 9, 2024
15c446d
unicode acceptance is working
Saibo-creator Feb 13, 2024
e11c442
fix repetition_penalty issue; add tests for running examples
Saibo-creator Feb 13, 2024
da1afb7
add github workflow, add badges on README and skip example testing lo…
Saibo-creator Feb 13, 2024
90b96f5
add test_accept_unicode_bytes.py
Saibo-creator Feb 16, 2024
1d146e5
add ByteEncoding
Saibo-creator Feb 16, 2024
222ddf8
unicode is working, but very slow and the last stack element has problem
Saibo-creator Feb 20, 2024
1ded206
unicode is working and fast: reset_utf8_decode is reduces the speed f…
Saibo-creator Feb 20, 2024
be527cf
freeze generate_json.py, repetition_penalty=1.1 is critical
Saibo-creator Feb 21, 2024
d22c432
add generate_c_code.py and fix test_grammar_constrained_decoding.py
Saibo-creator Feb 22, 2024
6373590
Two modes: unicode(slower) or non-unicode(fast)
Saibo-creator Feb 24, 2024
d2f0ebf
add more languages
Saibo-creator Feb 29, 2024
90e066d
add _accept_string as opposed to _accept_prefix
Saibo-creator Feb 29, 2024
a7f5e01
fix unicode mapping issue
Saibo-creator Feb 29, 2024
67c7b50
update README.md and set version to v0.2.0
Saibo-creator Feb 29, 2024
2320a0b
remove github workflow for now
Saibo-creator Feb 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
examples/grammars/debug
examples/grammars/wip
examples/jupyter
profiling
debug
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

## Latest News

**Support for Unicode(multilingual) grammars** (2024-02-29)
**Integration with Text-Generation-WebUI** (2023-12-17)

We are thrilled to announce that `transformers_cfg` has been used in the [Text-Generation-WebUI](https://github.com/oobabooga/text-generation-webui) project.
Expand Down Expand Up @@ -85,6 +86,7 @@ if __name__ == "__main__":
- We support EBNF grammar description format
- We offer the same grammar interface as llama-cpp project, allowing you to drop-in replace llama-cpp with transformers-CFG.
- We allow you to use any of the models in the 🤗 Transformers library, including the ones that are not supported by llama-cpp.
- We support multilingual grammars, you can use any character from any language in your grammar, e.g. 中文, 日本語, 한국어, हिन्दी, العربية, עברית, or emoji 🤗.

## What is grammar ?

Expand Down Expand Up @@ -116,6 +118,12 @@ You can use it to describe very simple but useful things, like a valid email add
phone_number ::= "+" [0-9]+
```

You can also force it to [generate only emojis](examples/generate_emoji.py) or [generate only korean characters](examples/generate_korean.py).
```
['Describe your feeling with emoji: 🙌🙂😍😯😅🙏🙇🙈🙊🙋🙃🙆🙅🙄🙁🙂🙀🙉🙎🙊🙋🙃🙆🙅🙄🙁🙂🙀🙉🙎🙊🙋🙃🙆', 'Write a poem with emoji: 🙏😍🙏🙏🙌🙏🙏🙏🙏😁😅🙏🙏🙏🙏🙏🙏🙇🙏🙏🙏🙏🙏🙏🙏🙏🙏🙋🙏🙏🙏🙏🙏🙏']
```


More details can be found in this [doc from llama-cpp](https://github.com/ggerganov/llama.cpp/tree/master/grammars)
Advanced grammar debugging guide can be found [here](docs/debugging_custom_grammars.md)

Expand Down
Loading
Loading