microsoft / BioGPT

MIT License
4.3k stars 452 forks source link

Error when executig #72

Open Dontmindmes opened 1 year ago

Dontmindmes commented 1 year ago

File "C:\Users\Gilgamesh\Documents\Advanced A.I\Bio\BioGPT\bio.py", line 3, in m = TransformerLanguageModel.from_pretrained( File "C:\Python310\lib\site-packages\fairseq\models\fairseq_model.py", line 275, in from_pretrained return hub_utils.GeneratorHubInterface(x["args"], x["task"], x["models"]) File "C:\Python310\lib\site-packages\fairseq\hub_utils.py", line 108, in init self.bpe = encoders.build_bpe(cfg.bpe) File "C:\Python310\lib\site-packages\fairseq\registry.py", line 61, in build_x return builder(cfg, *extra_args, **extra_kwargs) File "C:\Python310\lib\site-packages\fairseq\data\encoders\fastbpe.py", line 27, in init self.bpe = fastBPE.fastBPE(codes) AttributeError: module 'fastBPE' has no attribute 'fastBPE'

I get this error when running this code

import torch from fairseq.models.transformer_lm import TransformerLanguageModel m = TransformerLanguageModel.from_pretrained( "checkpoints", "checkpoint.pt", "data", tokenizer='moses', bpe='fastbpe', bpe_codes="data/BioGPT", min_len=100, max_len_b=1024) m.cuda() src_tokens = m.encode("COVID-19 is") generate = m.generate([src_tokens], beam=5)[0] output = m.decode(generate[0]["tokens"]) print(output)

sydrawat01 commented 1 year ago

Do you have fastBPE installed? If not, try installing it:

pip install fastBPE
Larsdegroot commented 1 year ago

I had the same issue. this is how i fixed it:

git clone https://github.com/glample/fastBPE.git
export FASTBPE=${PWD}/fastBPE
cd fastBPE
g++ -std=c++11 -pthread -O3 fastBPE/main.cc -IfastBPE -o fast
python3 setup.py install # new

this installs the python api of fastBPE source: https://github.com/glample/fastBPE

ZON-ZONG-MIN commented 1 year ago

I have the same problem, did you solve it?

Wiz123456 commented 1 year ago

I had the same issue. this is how i fixed it:

git clone https://github.com/glample/fastBPE.git
export FASTBPE=${PWD}/fastBPE
cd fastBPE
g++ -std=c++11 -pthread -O3 fastBPE/main.cc -IfastBPE -o fast
python3 setup.py install # new

this installs the python api of fastBPE source: https://github.com/glample/fastBPE

It works! Thank you!

TaniyaHaghighi20 commented 1 year ago

I had the same issue. this is how i fixed it:

git clone https://github.com/glample/fastBPE.git
export FASTBPE=${PWD}/fastBPE
cd fastBPE
g++ -std=c++11 -pthread -O3 fastBPE/main.cc -IfastBPE -o fast
python3 setup.py install # new

this installs the python api of fastBPE source: https://github.com/glample/fastBPE

this didn't work for me. do you have any other suggestions?