hello
- User
hello
- Assistant
Hello! How can I assist you today?
- User
- Assistant
The error you're encountering stems from attempting to access an attribute
vocabon aGPT2Tokenizerobject which doesn't exist. TheGPT2Tokenizerdoes not have avocabattribute directly accessible. If you're trying to get the vocabulary size to use in your model, you can use thelen(tokenizer)or tokenizer.vocab_size, which returns the size of the tokenizer's vocabulary.Here's how you should adjust the line causing the error:
Replace:
pythonvocab_size = len(tokenizer.vocab)With either:
pythonvocab_size = len(tokenizer)Or:
pythonvocab_size = tokenizer.vocab_sizeThis change should resolve the
AttributeErroryou're facing, as it properly fetches the size of the vocabulary that the tokenizer is using, which is necessary for defining the dimensions of the embedding layers in your model. - User
Now we get this: Shape of input_ids: torch.Size([1, 1024]) Shape of attention_mask: torch.Size([1, 1024]) Shape of input_ids: torch.Size([1, 1024]) Shape of attention_mask: torch.Size([1, 1024]) Traceback (most recent call last): File "c:\Users\L14\Documents\Projets\3D_engine\Text_Transformer.py", line 112, in outputs = model(input_ids, attention_mask) File "C:\Users\L14\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "C:\Users\L14\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) File "c:\Users\L14\Documents\Projets\3D_engine\Text_Transformer.py", line 50, in forward x = self.embedding(input_ids) + self.positional_encoding(positions) File "C:\Users\L14\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "C:\Users\L14\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) File "c:\Users\L14\Documents\Projets\3D_engine\Real_Transformer.py", line 71, in forward return x + self.pe[:, :x.size(1)] RuntimeError: The size of tensor a (1024) must match the size of tensor b (768) at non-singleton dimension 2
- Assistant
- User
Now we still get this error: Shape of input_ids: torch.Size([1, 1024]) Shape of attention_mask: torch.Size([1, 1024]) Shape of input_ids: torch.Size([1, 1024]) Shape of attention_mask: torch.Size([1, 1024]) Traceback (most recent call last): File "c:\Users\L14\Documents\Projets\3D_engine\Text_Transformer.py", line 112, in outputs = model(input_ids, attention_mask) File "C:\Users\L14\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "C:\Users\L14\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) File "c:\Users\L14\Documents\Projets\3D_engine\Text_Transformer.py", line 50, in forward x = self.embedding(input_ids) + self.positional_encoding(positions) File "C:\Users\L14\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "C:\Users\L14\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) File "c:\Users\L14\Documents\Projets\3D_engine\Real_Transformer.py", line 72, in forward return x + self.pe[:x.size(1), :] RuntimeError: The size of tensor a (1024) must match the size of tensor b (768) at non-singleton dimension 2
- Assistant
- User
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.