[Bug][Examples] TextCNN.ipynb is broken due to legacy torchtext 0.9.1 dependency
Hi there!
While working on updates to the examples directory, I identified that examples/notebooks/TextCNN.ipynb is currently unusable in modern Python/Torch environments. The notebook explicitly attempts to install torchtext==0.9.1, which creates a fundamental version conflict with the core library requirements.
- Project Python Requirement:
>=3.9, <=3.13 - Project Torch Requirement:
>=1.10, <3
torchtext 0.9.1 was built for torch 1.8.1. Because the project now requires torch >= 1.10, attempting to force-install the legacy version causes a binary mismatch.
In a Python 3.10 / Torch 2.x environment, importing the library results in the following crash:
OSError: /.../site-packages/torchtext/lib/libtorchtext.so: undefined symbol: _ZN5torch6detail10class_baseC2ERKSsS3_SsRKSt9type_infoS6_
The notebook requires a refactor to remove the torchtext dependency entirely.
I am documenting this issue here as it falls outside the scope of my current PR (which focuses on pbar clean-up), but it remains an inconvenience for users trying to follow this tutorial.
I am happy to work on this refactor in a separate follow-up PR if assigned to this issue.
Thanks for the report @TahaZahid05 . The best would be to rewrite entirely the notebook and use a modern model and other python packages like hf datasets.
Best, makes sense. I'll get started on refactoring and will submit a PR accordingly.
@vfdev-5 Before I start implementing, I want to confirm that my implementation aligns with your goals:
- I plan to use DistilBERT via
transformers. A modern model but lightweight compared to BERT as well. - I'll use
datasetsto load IMDB andAutoTokenizerfor preprocessing. This will remove thetorchtextdependency. - Lastly, I'll use Ignite's features to drive the training.
Let me know if there is anything you'll like me to change.
Yes, it makes sense. It can be similar to https://code-generator.pytorch-ignite.ai/create (text classification template). Thanks!
@vfdev-5 The link doesn't seem to be working.
@TahaZahid05 it is hosted on netlify which may be blocked by some countries.