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

RuntimeError: Missing implementation that supports: loader(*('/tmp/tfhub_modules/4f3530e4487d53ac1743187947c06ce11dbda528',), **{}) #840

Closed
kusumlata123 opened this issue Feb 12, 2022 · 3 comments
Assignees

Comments

@kusumlata123
Copy link

i have downloaded BERT Muril from link
bert_url = "https://tfhub.dev/google/MuRIL-Large/1"
self.bert_tokenizer = self.load_bert_vocab()
def load_bert_vocab(self):
with tf.Graph().as_default():
bert_model = hub.Module(self.bert_url)
vocab_info = bert_model(signature="tokenization_info",as_dict=True)
with tf.Session() as sess:
vocab_file, do_lower_case = sess.run([vocab_info["vocab_file"],vocab_info["do_lower_case"]])

return bert_tokenization.FullTokenizer(vocab_file=vocab_file,do_lower_case=do_lower_case)

and got error

RuntimeError: Missing implementation that supports: loader(*('/tmp/tfhub_modules/4f3530e4487d53ac1743187947c06ce11dbda528',), **{})

File "train.py", line 19, in
model = util.get_model(config)
File "/home/dr/Desktop/master/util.py", line 27, in get_model
model = bert_md.BertMD(config)
File "/home/dr/Desktop/r/nn_md.py", line 18, in init
input_props = self.add_model_specific_valuables(config)
File "/home/dr/Desktop/r/bert_md.py", line 20, in add_model_specific_valuables
self.bert_tokenizer = self.load_bert_vocab()
File "/home/dr/Desktop/r/bert_md.py", line 45, in load_bert_vocab
bert_model = hub.Module(self.bert_url)
File "/home/dr/anaconda3/envs/hp/lib/python2.7/site-packages/tensorflow_hub/module.py", line 154, in init
self._spec = as_module_spec(spec)
File "/home/dr/anaconda3/envs/hp/lib/python2.7/site-packages/tensorflow_hub/module.py", line 36, in as_module_spec
return load_module_spec(spec)
File "/home/dr/anaconda3/envs/hp/lib/python2.7/site-packages/tensorflow_hub/module.py", line 64, in load_module_spec
return registry.loader(path)
File "/home/dr/anaconda3/envs/hp/lib/python2.7/site-packages/tensorflow_hub/registry.py", line 45, in call
self._name, args, kwargs))
RuntimeError: Missing implementation that supports: loader(*('/tmp/tfhub_modules/4f3530e4487d53ac17431879

@pindinagesh pindinagesh self-assigned this Feb 14, 2022
@WGierke WGierke self-assigned this Feb 14, 2022
@WGierke
Copy link
Collaborator

WGierke commented Feb 14, 2022

Hi @kusumlata123
I noticed a few things:

  1. You're trying to load the model via hub.Module. This doesn't work since the model hasn't been stored as a TF1 Module. In the documentation, you can see that it has to be loaded using hub.KerasLayer (or hub.load).
  2. When loading it as a KerasLayer
    layer = hub.KerasLayer("https://tfhub.dev/google/MuRIL-Large/1")
    you can access the path to the vocab via
    layer.resolved_object.vocab_file.asset_path
  3. It seems like you're using Python 2.7. This isn't supported by TensorFlow anymore.

@kusumlata123
Copy link
Author

kusumlata123 commented Feb 14, 2022 via email

@WGierke
Copy link
Collaborator

WGierke commented Feb 14, 2022

https://tfhub.dev/tensorflow/bert_multi_cased_L-12_H-768_A-12/4 is also no TF1 Module. The documentation says it's a TF2.0 Saved Model and the code snippet shows that one should use hub.KerasLayer/hub.load (https://www.tensorflow.org/hub/tf1_hub_module, https://www.tensorflow.org/hub/tf2_saved_model).

@WGierke WGierke closed this as completed Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants