Skip to content

Error while running the notebook #30

@herilalaina

Description

@herilalaina

Hi, I have been unable to run the notebook here. It seems to be related to versioning, as I'm unable to instantiate the inference_utils.InferenceModel class without encountering an error.

Here's the specific error message I received when running the code:

      1 #@title Load a transformer inference model.
----> 3 inference_model = inference_utils.InferenceModel.from_checkpoint(
      4     CHECKPOINT_PATH,
      5     batch_size=BATCH_SIZE,
      6     model_gin_file=MODEL_GIN_FILE,
      7     gin_search_paths=[OPTFORMER_DIR],
      8 )
      9 vocab = inference_model.vocab
     10 study_converter = inference_model.study_converter

File ~/code/llm/optformer/optformer/t5x/inference_utils.py:394, in InferenceModel.from_checkpoint(cls, checkpoint_path_or_model_dir, batch_size, model_gin_file, gin_patterns_to_skip, gin_search_paths, overwrite_gin_files, overwrite_gin_bindings)
    391 logging.info('Gin Configuration to restore model:\n%s', gin.config_str())
    393 print(gin.query_parameter("%VOCABULARY"), gin.config_str())
--> 394 vocabulary = gin.query_parameter('%VOCABULARY').scoped_configurable_fn()
    395 try:
    396   vocab_index_from = gin.query_parameter('%VOCAB_INDEX_FROM')

File ~/miniconda3/envs/optformer/lib/python3.10/site-packages/gin/config.py:1605, in _make_gin_wrapper.<locals>.gin_wrapper(*args, **kwargs)
   1603 scope_info = " in scope '{}'".format(scope_str) if scope_str else ''
   1604 err_str = err_str.format(name, fn_or_cls, scope_info)
-> 1605 utils.augment_exception_message_and_reraise(e, err_str)

File ~/miniconda3/envs/optformer/lib/python3.10/site-packages/gin/utils.py:41, in augment_exception_message_and_reraise(exception, message)
     39 proxy = ExceptionProxy()
     40 ExceptionProxy.__qualname__ = type(exception).__qualname__
---> 41 raise proxy.with_traceback(exception.__traceback__) from None

File ~/miniconda3/envs/optformer/lib/python3.10/site-packages/gin/config.py:1582, in _make_gin_wrapper.<locals>.gin_wrapper(*args, **kwargs)
   1579 new_kwargs.update(kwargs)
   1581 try:
-> 1582   return fn(*new_args, **new_kwargs)
   1583 except Exception as e:  # pylint: disable=broad-except
   1584   err_str = ''

File ~/code/llm/optformer/optformer/data/tasks.py:44, in get_vocabulary(sentencepiece_model_file, max_integer_tokens, expected_vocab_size)
     40 extra_tokens = ['<' + str(n) + '>' for n in range(max_integer_tokens)]
     41 vocabulary = vocabularies.SentencePieceVocabularyWithCustomToken(
     42     sentencepiece_model_file, extra_tokens=extra_tokens)
     43 if (expected_vocab_size is not None and
---> 44     expected_vocab_size != vocabulary.vocab_size):
     45   raise ValueError(f'Vocabulary size ({vocabulary.vocab_size}) does not '
     46                    f'match the expected value ({expected_vocab_size}).')
     47 return vocabulary

File ~/miniconda3/envs/optformer/lib/python3.10/site-packages/seqio/vocabularies.py:435, in SentencePieceVocabulary.vocab_size(self)
    433 @property
    434 def vocab_size(self):
--> 435   return self._base_vocab_size

File ~/miniconda3/envs/optformer/lib/python3.10/site-packages/seqio/vocabularies.py:444, in SentencePieceVocabulary._base_vocab_size(self)
    437 @property
    438 def _base_vocab_size(self):
    439   """Number of ids (including 0=PAD, 1=EOS, and 2=UNK).
    440 
    441   Returns:
    442     an integer, the vocabulary size
    443   """
--> 444   return self.tokenizer.GetPieceSize()

File ~/miniconda3/envs/optformer/lib/python3.10/site-packages/seqio/vocabularies.py:426, in SentencePieceVocabulary.tokenizer(self)
    423 @property
    424 def tokenizer(self) -> sentencepiece_processor.SentencePieceProcessor:
    425   """Returns the Python tokenizer."""
--> 426   return self._model_context().tokenizer

File ~/miniconda3/envs/optformer/lib/python3.10/site-packages/seqio/vocabularies.py:336, in SentencePieceVocabulary._model_context(self)
    328   return self._model
    330 normalizer_spec_overrides_serialized = (
    331     self._normalizer_spec_overrides.SerializeToString(deterministic=True)
    332     if self._normalizer_spec_overrides
    333     else None
    334 )
--> 336 self._model = self._load_model(
    337     self._sentencepiece_model_file,
    338     self._extra_ids,
    339     normalizer_spec_overrides_serialized,
    340     self._reverse_extra_ids,
    341 )
    342 return self._model

TypeError: SentencePieceVocabularyWithCustomToken._load_model() takes 1 positional argument but 5 were given
  In call to configurable 'get_vocabulary' (<function get_vocabulary at 0x7fce61d801f0>)

In addition, I encountered another unrelated issue on the next cell: AttributeError: module 'vizier.benchmarks' has no attribute 'NumpyExperimenter' .

Here are the versions I'm currently using:

google-vizier==0.1.6
seqio @ git+https://github.com/google/seqio@4d3097973e9e24ec2963319ec3c5ff518811060f
seqio-nightly==0.0.15.dev20230703

Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions