8000 Possible ByteVocabulary Bug · Issue #158 · google/seqio · GitHub
[go: up one dir, main page]

Skip to content

Possible ByteVocabulary Bug #158

Open

Description

@xwd
464   def _decode_tf(self, ids):
465     """Decode in TensorFlow.
466 
467     Args:
468       ids: a 1d tf.Tensor with dtype tf.int32
469     Returns:
470       a tf Scalar with dtype tf.string
471     """
472     return tf.py_function(func=self.decode, inp=[ids], Tout=tf.string)

The param 'ids' passed to _decode_tf above is a 1d tf.Tensor, and on line 472 it is wrapped into a list, but when self.decode is called with the param [ids], it throws the error in the list comprehension on line 100 (shown below):

File "/home/ubuntu/anaconda3/envs/google_t5/lib/python3.7/site-packages/seqio/vocabularies.py", line 100, in
decode
for i in clean_ids

File "/home/ubuntu/anaconda3/envs/google_t5/lib/python3.7/site-packages/seqio/vocabularies.py", line 100, in

for i in clean_ids

File "/home/ubuntu/anaconda3/envs/google_t5/lib/python3.7/site-packages/tensorflow/python/framework/ops.py",
line 1007, in bool
return bool(self._numpy())

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

 92   def decode(self, ids: Iterable[int]):
 93     """Detokenizes int32 iterable to a string, up through first EOS."""
 94     clean_ids = list(ids)
 95 
 96     if self.unk_id is not None:
 97       vocab_size = self._base_vocab_size
 98       clean_ids = [
 99           self.unk_id if i >= vocab_size else i
100           for i in clean_ids
101       ]
102 
103     if self.eos_id is not None and self.eos_id in clean_ids:
104       clean_ids = clean_ids[:clean_ids.index(self.eos_id) + 1]
105 
106     return self._decode(clean_ids)

Activity

  1. adarob commented on Nov 8, 2021

    @adarob
    Member

    @nconstant-google this does look like a bug

  2. xwd commented on Nov 8, 2021

    @xwd
    Author

    @nconstant-google this does look lik 4960 e a bug

    This can be reproduced by running a pretrained byt5 model (from https://github.com/google-research/byt5) using the following command (I'm using GPU, I believe the error would persist with TPUs):

    export BUCKET=~/data/t5/byt5-data/
    export TASK=byt5_ner_multilingual
    export MODEL_DIR="${BUCKET}/${TASK}"

    python -m t5.models.mesh_transformer_main
    --module_import="byt5.tasks"
    --model_dir="${MODEL_DIR}"
    --gin_file="${MODEL_DIR}/operative_config.gin"
    --t5_tfds_data_dir="${BUCKET}/t5-tfds"
    --gin_file="eval.gin"
    --gin_file="beam_search.gin"
    --gin_param="utils.run.mesh_shape = 'model:2,batch:1'"
    --gin_param="utils.run.mesh_devices = ['gpu:0','gpu:1']"
    --gin_param="run.dataset_split = 'validation'"
    --gin_param="MIXTURE_NAME = 'byt5_ner_eval.ja'" \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      0