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

Add roleplay.gbnf #5368

Merged
merged 31 commits into from
Jan 29, 2024
Merged

Add roleplay.gbnf #5368

merged 31 commits into from
Jan 29, 2024

Conversation

BadisG
Copy link
Contributor

@BadisG BadisG commented Jan 24, 2024

Hello,

This gbnf is centred on the typical roleplaying grammar structure:

yI8bsQ5

  • It will use the (action + speech) combo 2 or 3 times.
  • It has numbers and punctuations
  • It has special characters like "à" or "é" (good for other languages than english)

asasasa

Any feedback is welcome, we can discuss how to make this work best. For example, I wondered if (action + speech) would be more interesting to think about than (speech + action).

Edit: I also enforced UTF-8 encoding when loading the gbnf, because that's what happens if we don't:

image

oobabooga and others added 28 commits December 14, 2023 22:39
@BadisG BadisG mentioned this pull request Jan 24, 2024
@oobabooga
Copy link
Owner

Does this work?

[a-zA-Zà-üÀ-Ü]

If not, I may need to pull the latest code from https://github.com/epfl-dlab/transformers-CFG.

@BadisG
Copy link
Contributor Author

BadisG commented Jan 28, 2024

Indeed this works fine like that, thanks for the catch, I've simplified the grammar.

@oobabooga
Copy link
Owner

Nice, thanks. That's a creative and interesting useful use of grammar. Looks good to merge.

@oobabooga oobabooga changed the base branch from main to dev January 29, 2024 00:41
@oobabooga oobabooga merged commit 40c7977 into oobabooga:dev Jan 29, 2024
@YakuzaSuske
Copy link

[a-zA-Zà-üÀ-Ü]

That replacement breaks the code and causes these errors.
image

the previous code which was this:

phrasePattern ::= "*" [A-ZéÉàÀèÈùÙâÂêÊîÎôÔûÛçÇöÖüÜäÄëË0-9] ( [A-Za-z'.?!,:;-éÉàÀèÈùÙâÂêÊîÎôÔûÛçÇöÖüÜäÄëË0-9]+ " " )* [A-Za-z'.?!,:;-éÉàÀèÈùÙâÂêÊîÎôÔûÛçÇöÖüÜäÄëË0-9]+ "*"
quotedText ::= "\"" [A-Z] [A-Za-z'.*?!,:;-éÉàÀèÈùÙâÂêÊîÎôÔûÛçÇöÖüÜäÄëË0-9]* (" " [A-Za-z'.*?!,:;-éÉàÀèÈùÙâÂêÊîÎôÔûÛçÇöÖüÜäÄëË0-9]+)* "\""
root ::= phrasePattern singleSpace quotedText singleSpace phrasePattern singleSpace quotedText singleSpace (phrasePattern singleSpace quotedText singleSpace)?
singleSpace ::= " "

That code functioned normally, however the introduction of [a-zA-Zà-üÀ-Ü] breaks the grammar rules.

@BadisG
Copy link
Contributor Author

BadisG commented Jan 31, 2024

@YakuzaSuske Oh yeah you are right, the [a-zA-Zà-üÀ-Ü] rules are only working on llamacpp_hf (not llamacpp) but the [A-ZéÉàÀèÈùÙâÂêÊîÎôÔûÛçÇöÖüÜäÄëË0-9] rules are working everytime.
@oobabooga maybe you should actually pull the latest code from https://github.com/epfl-dlab/transformers-CFG to make it work

@oobabooga
Copy link
Owner

The transformers-CFG code applies only to llamacpp_HF and HF loaders, and not to llama.cpp. So it's a problem with llama.cpp grammar parsing.

PoetOnTheRun pushed a commit to PoetOnTheRun/text-generation-webui that referenced this pull request Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants