BioGPT icon indicating copy to clipboard operation
BioGPT copied to clipboard

Error at loading: TransformerLanguageModel.from_pretrained in google colab

Open yywill opened this issue 2 years ago • 1 comments

I am following the instruction on readme on google colab.

path1 = '/content/fairseq/'
import os
path = os.path.join(path1, "checkpoints/Pre-trained-BioGPT")

import torch
from fairseq.models.transformer_lm import TransformerLanguageModel
m = TransformerLanguageModel.from_pretrained(
        path, 
        "checkpoint.pt", 
        "data",
        tokenizer='moses', 
        bpe='fastbpe', 
        bpe_codes="data/bpecodes",
        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)

TypeError Traceback (most recent call last) in 5 import torch 6 from fairseq.models.transformer_lm import TransformerLanguageModel ----> 7 m = TransformerLanguageModel.from_pretrained( 8 path, 9 "checkpoint.pt",

7 frames /usr/local/lib/python3.8/dist-packages/fairseq/models/transformer_lm.py in build_embedding(cls, args, dictionary, embed_dim, path) 319 @classmethod 320 def build_embedding(cls, args, dictionary, embed_dim, path=None): --> 321 embed_tokens = Embedding(len(dictionary), embed_dim, dictionary.pad()) 322 return embed_tokens 323

TypeError: object of type 'NoneType' has no len()

yywill avatar Feb 10 '23 08:02 yywill

Is it because of run out of memory

Your session crashed after using all available RAM. If you are interested in access to high-RAM runtimes, you may want to check out Colab Pro.

yywill avatar Feb 10 '23 08:02 yywill