Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible ByteVocabulary Bug #158

Open
xwd opened this issue Nov 5, 2021 · 2 comments
Open

Possible ByteVocabulary Bug #158

xwd opened this issue Nov 5, 2021 · 2 comments

Comments

@xwd
Copy link

xwd commented Nov 5, 2021

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)

@adarob
Copy link
Member

adarob commented Nov 8, 2021

@nconstant-google this does look like a bug

@xwd
Copy link
Author

xwd commented Nov 8, 2021

@nconstant-google this does look like 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants