I wanna learn how transformers work for that i would like to build a mini transformer…
- User
I wanna learn how transformers work for that i would like to build a mini transformer model with encode decoder part that learns to translate an englisch into a german sentance . the alphebet only consists of the words in this sentence: "hello my name is chris" and one extra word "banana" give me the complete python code to build it to learn the translation in german
- Assistant
- User
C:\Users\chris\PycharmProjects\VirtualEnvironment\Scripts\python.exe C:\Users\chris\OneDrive\Dokumente\GitHub\LLMsBooster\UniProject\transformer_simple.py Traceback (most recent call last): File "C:\Users\chris\OneDrive\Dokumente\GitHub\LLMsBooster\UniProject\transformer_simple.py", line 4, in from torchtext.vocab import vocab File "C:\Users\chris\PycharmProjects\VirtualEnvironment\lib\site-packages\torchtext_init_.py", line 18, in from torchtext import _extension # noqa: F401 File "C:\Users\chris\PycharmProjects\VirtualEnvironment\lib\site-packages\torchtext_extension.py", line 64, in _init_extension() File "C:\Users\chris\PycharmProjects\VirtualEnvironment\lib\site-packages\torchtext_extension.py", line 58, in _init_extension _load_lib("libtorchtext") File "C:\Users\chris\PycharmProjects\VirtualEnvironment\lib\site-packages\torchtext_extension.py", line 50, in load_lib torch.ops.load_library(path) File "C:\Users\chris\PycharmProjects\VirtualEnvironment\lib\site-packages\torch_ops.py", line 1295, in load_library ctypes.CDLL(path) File "C:\Program Files\Python310\lib\ctypes_init.py", line 374, in init self._handle = _dlopen(self._name, mode) OSError: [WinError 127] Die angegebene Prozedur wurde nicht gefunden
Process finished with exit code 1
- Assistant
The error message you're seeing indicates a problem with loading a native library, specifically . This is usually related to an issue with the installation of or a compatibility issue between and versions. Let's go through some steps to resolve this:
- User
- Assistant
- User
C:\Users\chris\PycharmProjects\VirtualEnvironment\Scripts\python.exe C:\Users\chris\OneDrive\Dokumente\GitHub\LLMsBooster\UniProject\transformer_simple.py C:\Users\chris\OneDrive\Dokumente\GitHub\LLMsBooster\UniProject\transformer_simple.py:34: UserWarning: Failed to initialize NumPy: module compiled against API version 0x10 but this version of numpy is 0xf (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:68.) src_data = torch.tensor(src_sentence_index).unsqueeze(0) Epoch 1, Loss: nan Epoch 2, Loss: nan Epoch 3, Loss: nan Epoch 4, Loss: nan Epoch 5, Loss: nan Epoch 6, Loss: nan Epoch 7, Loss: nan
- Assistant
- User
C:\Users\chris\PycharmProjects\VirtualEnvironment\Scripts\python.exe C:\Users\chris\OneDrive\Dokumente\GitHub\LLMsBooster\UniProject\transformer_simple.py
A module that was compiled using NumPy 1.x cannot be run in NumPy 2.1.1 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2.
Traceback (most recent call last): File "C:\Users\chris\OneDrive\Dokumente\GitHub\LLMsBooster\UniProject\transformer_simple.py", line 34, in src_data = torch.tensor(src_sentence_index).unsqueeze(0) C:\Users\chris\OneDrive\Dokumente\GitHub\LLMsBooster\UniProject\transformer_simple.py:34: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:68.) src_data = torch.tensor(src_sentence_index).unsqueeze(0) Epoch 1, Loss: nan Epoch 2, Loss: nan Epoch 3, Loss: nan Epoch 4, Loss: nan Epoch 5, Loss: nan Epoch 6, Loss: nan Epoch 7, Loss: nan Epoch 8, Loss: nan Epoch 9, Loss: nan Epoch 10, Loss: nan
numpy updated
- Assistant
The error message indicates that the current version of NumPy you're using (2.1.1) is incompatible with modules compiled with earlier versions of NumPy. This version mismatch leads to issues, especially when using libraries that depend heavily on NumPy, such as PyTorch.
To resolve this, you will need to downgrade NumPy to a compatible version. PyTorch and many other libraries are typically built and tested against NumPy versions in the 1.x range.
Steps to Resolve
-
Downgrade NumPy: Since you are seeing compatibility issues with NumPy version 2.x, downgrade to a version that PyTorch 1.12.1 is compatible with, usually NumPy 1.21.0 or similar should work fine. You can do this by running:
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.