tensorflow / tensorflow/text

tf_text.FastSentencepieceTokenizer causes ValueError: cannot create std::vector larger than max_size()

Open
#1,071 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.3k
Forks
379
Avg merge
3h 30m
Merged PRs (30d)
8

Description

I tried to switch from the tf_text.SentencepieceTokenizer to tf_text.FastSentencepieceTokenizer but encountered the issue below.

ValueError                                Traceback (most recent call last)
<ipython-input-150-df5232e30d34> in <module>
      7 # sp_model = open("new.model", "r").read()
      8 
----> 9 tokenizer = tf_text.FastSentencepieceTokenizer(sp_model)

[/usr/local/lib/python3.8/dist-packages/tensorflow_text/python/ops/fast_sentencepiece_tokenizer.py](https://localhost:8080/#) in __init__(self, model, reverse, add_bos, add_eos)
     48 
     49   def __init__(self, model, reverse=False, add_bos=False, add_eos=False):
---> 50     converted_model = pywrap_model_converter.convert_sentencepiece_model(model)
     51     converted_model_detokenizer = pywrap_model_converter.convert_sentencepiece_model_for_decoder(
     52         model)

ValueError: cannot create std::vector larger than max_size()

I can load the sentencepiece model proto with tf_text.SentencepieceTokenizer, but switching to tf_text.FastSentencepieceTokenizer is causing the issue.
Is there a limitation around the tf_text.FastSentencepieceTokenizer?

I have tried to trace the C++ code, but didn't find any model limitation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in fast_sentencepiece_tokenizer.py at the constructor and trace the pywrap_model_converter conversion calls shown in the traceback. Reproduce the failure with the SentencePiece model and compare it with SentencepieceTokenizer's loading path. Done means identifying the model or conversion condition that triggers the exception and documenting or correcting the FastSentencepieceTokenizer behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.