4

I'm trying to load tokenizer and seq2seq model from pretrained models.

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained("ozcangundes/mt5-small-turkish-summarization")

model = AutoModelForSeq2SeqLM.from_pretrained("ozcangundes/mt5-small-turkish-summarization")

But I got this error.

File ~/.local/lib/python3.8/site-packages/google/protobuf/descriptor.py:1028, in FileDescriptor.__new__(cls, name, package, options, serialized_options, serialized_pb, dependencies, public_dependencies, syntax, pool, create_key)
   1026     raise RuntimeError('Please link in cpp generated lib for %s' % (name))
   1027 elif serialized_pb:
-> 1028   return _message.default_pool.AddSerializedFile(serialized_pb)
   1029 else:
   1030   return super(FileDescriptor, cls).__new__(cls)

    TypeError: Couldn't build proto file into descriptor pool: duplicate file name (sentencepiece_model.proto)

I tried updating or downgrading the protobuf version. But I couldn't fix

Salihcan
  • 91
  • 13

2 Answers2

6

I ran into the same issue when trying to use the microsoft/deberta-v3-small model. That is, at first it complained about not being able to find protobuf, and when I installed the latest, it asked for version 3.20.x. The issue happened after I downgraded to the lower version.

Anyway, I was experimenting with it on a locally-running Jupyter notebook. Rerunning that cell didn't help. But when I chose to "Restart & Run All," the problem went away.

Therefore, to solve your issue, I believe that you need to restart the Python instance where it cached the latest version of protobuf in the first place.

Steps to reproduce:

  1. from transformers import AutoTokenizer
    
    tokenizer = AutoTokenizer.from_pretrained("some_model")
    
    # outcome: some error asking for `protobuf`
    
  2. pip install protobuf
    

    Rerun the code above; some error asking for protobuf@3.20.x

  3. pip uninstall protobuf
    pip install protobuf==3.20
    

    Rerun the code above; same error as in OP

  4. Restart the Python instance (notebook, app, etc.); ✓ no error

ilyakam
  • 547
  • 4
  • 11
4

ilyakam,

I ran into the same problem with mrm8488/t5-base-finetuned-wikiSQL, also in a notebook, in a virtual environment. Your solution did (almost) work, I had to add the line 'PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="python"'

So in case your solution does not work 100%, try adding the line in the notebook

Andreas

python 3.10 on Ubuntu 22.04.2 LTS

user9165100
  • 371
  • 3
  • 11
  • I found that downgrading protobuf immediately broke everything, however, the simple fix described above worked immediately when placed at the head of the Notebook - specifically it's `import os` `os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"]="python"` In my case the problematic model was "google/pegasus-cnn_dailymail", the only model (so far) to have this issue. – James_SO May 30 '23 at 19:22