Fix perplexity calculation and resulting overcompression #208
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@iofu728
For longllmlingua this is not a 100% correct fix, especially for short prompts with longllmlingua errors occur.
I hope one of the maintainers can give some feedback whether this is semi-correct
Related: #195, #61
See this comment for details: #61 (comment)
Before the change (top: Llama 2, bottom: GPT-2):

After the change:

Note that the undercompression for 250 and 500 tokens is caused by the second bug / design flaw described in this issue #196 under "Semi-related bug", Also, this was measured including the bugfix in #198 otherwise 50 and 100 tokens would not be compressed.
I did not run the tests as compression outputs will change and tests will fail
Before submitting