{"id":1025,"hash":"a550682040c432962c29d9f852542a79a4991e37ed1f05aaedc147feb87ac759","pattern":"Huggingface AlBert tokenizer NoneType error with Colab","full_message":"I simply tried the sample code from hugging face website: https://huggingface.co/albert-base-v2\n\nfrom transformers import AlbertTokenizer, AlbertModel\ntokenizer = AlbertTokenizer.from_pretrained('albert-base-v2')\ntext = \"Replace me by any text you'd like.\"\nencoded_input = tokenizer(text, return_tensors='pt')\n\nthen I got the following error at the tokenizer step:\nencoded_input = tokenizer(text, return_tensors='pt')\n\nTypeError: 'NoneType' object is not callable\n\nI tried the same code on my local machine, it worked no problem. The problem seems within Colab. However, I do need help to run this model on colab GPU.\n\nMy python version on colab is Python 3.6.9.","ecosystem":"pypi","package_name":"google-colaboratory","package_version":null,"solution":"I found the answer. After install, import the AlbertTokenizer and Tokenizer=..., I received an error asking me to install SentencePiece package. However, after I install this package and run tokenizer again, I started receiving the error above.\nSo I open a brand new colab session, and install everything including the SentencePiece before creating tokenizer, and this time it worked. The Nonetype error simply means it doesn't know what is albert-base-v2. However if you install the packages in right order colab will recognize better the relationship between AlbertTokenizer and SentencePiece.\nIn short for this to work in colab\n\nOpen a new Colab session\nInstall Transformers and SentencePiece\nimport AlbertTokenizer\ncreate tokenizer.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/65854722/huggingface-albert-tokenizer-nonetype-error-with-colab","votes":21,"created_at":"2026-04-19T04:52:12.291562+00:00","updated_at":"2026-04-19T04:52:12.291562+00:00"}