IBM-Generative-AI is a Python library built on IBM's large language model REST interface to seamlessly integrate and extend this service in Python programs.
Calling get_num_tokens or get_num_tokens_from_messages on a LangChainInterface would return the right number.
What is the actual behavior?
It actually uses the GPT2 tokenizer (falling back to langchain/schema/language_model.py, function get_tokenizer()), and comes out with the wrong number.
Please provide a unit test that demonstrates the bug.
I note it's implemented on the chat interface, just not on plain LangChainInterface yet - so I'm registering my interest in it being fixed or fixing it there too.
I also note that get_token_ids isn't implemented for either so it would also be giving the GPT2-based result.
Can you identify the location in the GENAI source code where the problem exists?
src/genai/extensions/langchain/llm.py
If the bug is confirmed, would you be willing to submit a PR?
Version Information
What is the expected behavior?
Calling
get_num_tokens
orget_num_tokens_from_messages
on aLangChainInterface
would return the right number.What is the actual behavior?
It actually uses the GPT2 tokenizer (falling back to
langchain/schema/language_model.py
, functionget_tokenizer()
), and comes out with the wrong number.Please provide a unit test that demonstrates the bug.
Other notes on how to reproduce the issue?
Any possible solutions?
I note it's implemented on the chat interface, just not on plain
LangChainInterface
yet - so I'm registering my interest in it being fixed or fixing it there too.I also note that
get_token_ids
isn't implemented for either so it would also be giving the GPT2-based result.Can you identify the location in the GENAI source code where the problem exists?
If the bug is confirmed, would you be willing to submit a PR?
Yes