-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
grammars : add English-only grammar #10612
Conversation
I'm on my phone now and the Unicode codepage characters doesn't seem to be showing up:
See: https://old.reddit.com/r/LocalLLaMA/comments/1cdj2uo/qwen15110b_the_first_100b_model_of_the_qwen15/
See: https://old.reddit.com/r/LocalLLaMA/comments/1bwjmoo/qwen1532b_released_with_gqa/ But is there a way to block ranges of Unicode characters like these examples? The new |
I'm not sure. This PR is mainly to demonstrate that the grammar works and can be used in such ways. If it does not support the specific case that you need, add a feature request and someone might implement it. |
No problem - I'll do some experiments with the |
People should keep in mind that they need to adjust the prompt when using this kind of restrictive grammar. Because the LLM might "advance" into a direction now knowing it will not be able to output some tokens and it will lead to sub-optimal outpute. A solution would also be to use beam search (batched beam search maybe) |
I've found a problem with this as it doesn't allow the output of double newlines (which a lot of models love to use). This is what I am using now with
and even when asked "to think in Chinese" it works.: UserWhat is the sqrt(12654) think in Chinese. QwQsqrt(12654) in Chinese is "12654" " " (square root). So, I need to find the square root of 12654. Let's see, I don't know the exact value off the top of my head, so I'll have to calculate it. First, I should check if 12654 is a perfect square. I know that perfect squares are numbers like 1, 4, 9, 16, and so on, where they are the square of an integer. Let me see, what's the square of 100? That's 10,000. The square of 110 is 12,100, and the square of 112 is 12,544. Hmm, 12,544 is less than 12,654. What about 113 squared? Let's calculate that. 113 times 113. Well, 110 times 110 is 12,100, and then add 113 times 3, which is 339, so 12,100 plus 339 is 12,439. Wait, that doesn't seem right. Actually, 113 times 113 should be calculated differently. Let me try again. I can use the formula (a + b)^2 = a^2 + 2ab + b^2, where a is 110 and b is 3. So, 113^2 = 110^2 + 21103 + 3^2 = 12,100 + 660 + 9 = 12,769. Okay, so 113 squared is 12,769, which is higher than 12,654. So, the square root of 12,654 should be between 112 and 113. Let me try 112.5 squared to get a better estimate. 112.5 squared is 112.5 times 112.5. Let's calculate that. 112.5 times 110 is 12,375, and then add 112.5 times 2.5, which is 281.25, so total is 12,375 plus 281.25, which is 12,656.25. Okay, so 112.5 squared is 12,656.25, which is very close to 12,654. So, the square root of 12,654 should be slightly less than 112.5. Maybe around 112.49 or something like that. To get a more precise value, I would need to use a calculator or a more detailed method like the long division method for square roots. But for now, I can say that the square root of 12,654 is approximately 112.49. Final Answer [ \boxed{112.49} ] |
UserCan you teach me some Chinese characters? QwQOf course! Learning Chinese characters can be fun and rewarding. Let's start with some basic characters to get you familiar with the structure and principles behind them. First, it's important to understand that Chinese characters, also known as Hanzi, are logograms, meaning each character represents a word or a morpheme (a meaningful unit of language). They are not purely phonetic, so learning them involves understanding both their meaning and pronunciation. Let's begin with some fundamental characters that are commonly used in everyday language.
|
Example: