Skip to content

Conversation

wch
Copy link
Collaborator

@wch wch commented Aug 28, 2024

This PR adds more information about why the tokenizer package should be installed for the Chat component.

@wch wch requested a review from nealrichardson August 28, 2024 19:43
@@ -54,7 +54,9 @@ def get_default_tokenizer() -> TokenizersTokenizer | None:
except ImportError:
warnings.warn(
"`Chat` is unable obtain a default tokenizer without the `tokenizers` "
"package installed. Please `pip install tokenizers` or set "
"package installed. The tokenizer to use for calculating token counts, "
"which is required to impose `token_limits` in `.messages()`.\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the message hint at why I would want to impose token limits? Assume I don't know anything about LLMs or what makes them faster/better/cheaper.

"package installed. Please `pip install tokenizers` or set "
"package installed. The tokenizer to use for calculating token counts, "
"which is required to impose `token_limits` in `.messages()`.\n"
"Please run `pip install tokenizers` or set "
"`Chat(tokenizer=None)` to disable tokenization.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when I see this message, my app is still working fine. So I'm guessing that it is falling back to None automatically? Would it be more accurate to say "set None to stop seeing this warning"?

@wch
Copy link
Collaborator Author

wch commented Aug 28, 2024

Some notes from a discussion with @cpsievert:

  • The reason for the default behavior of trimming messages is so that users don't suddenly run into errors when the conversation exceeds a particular length. The downside of that default is that we
  • I don't think that any other Python or JS LLM/chat libraries do trimming by default.
  • I think it makes sense to set the default to None, and (A) make sure there the error message is clear when the user hits token limits, and (B) make it clear in the docs and examples that for any real chat app, they should install tokenizers and set token_limits.

@cpsievert
Copy link
Collaborator

#1657 supersedes this

@cpsievert cpsievert closed this Aug 29, 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