Skip to main content

Implementing classic NLP models from scratch.

Project description

Python PyPI PyPI Downloads

Ruff Checked with mypy pre-commit

Build Docs Test Codecov

ToyNLP

Implementing classic NLP models from scratch with clean code and easy-to-understand architecture.

This library is for educational purposes only. It is not optimized for production use. And it may contain bugs CURRENTLY, so feel free to contribute and report issues.

Until now, we only do simple tests, which is not enough. But we will do much more rigorous testing in the FUTURE. And we will add more docs for you can RUN it easily, add more playgrounds for you to experiment with the models and look inside the model implementations.

Models

8 important NLP models range from 2003 to 2020:

  • NNLM(2003)
  • Word2Vec(2013)
  • Seq2Seq(2014)
  • Attention(2014)
  • fastText(2016)
  • Transformer(2017)
  • GPT(2018)
  • BERT(2018)

FAQ

I see there are 10 models before, why only 8 now?

Yes, I removed XLNet and T5. The main reason is that I don't have so many GPUs to train these models. Without training them by myself, I can't guarantee the correctness of the implementations. So I just keep the models that I can train and verify myself.

I find there are DIFFERENCES between the implementations in toynlp and original papers.

Yes, there are some differences in the implementations. The goal of toynlp is to provide a simple and educational implementation of these models, which may not include all the optimizations and features in original papers.

The reason is that I want to focus on the core ideas and concepts behind each model, rather than getting bogged down in implementation details. Especially when the original papers may introduce complexities that are not essential for understanding the main contributions of the work.

But, I do need to add docs for each model to clarify these differences and provide guidance on how to use the implementations effectively. I'll do this later. Let's first make it work and then make it better.

Where is GPT-2 and other LLMs?

Well, it's in toyllm! I separated the models into two libraries, toynlp for traditional "small" NLP models and toyllm for LLMs, which are typically larger and more complex.

Like the "toy" style, anything else?

Glad you asked! The "toy" style is all about simplicity and educational value. We have another two toys besides toynlp and toyllm: toyml for traditional machine learning models; toyrl for deep reinforcement learning models.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toynlp-0.3.0.tar.gz (79.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toynlp-0.3.0-py3-none-any.whl (110.0 kB view details)

Uploaded Python 3

File details

Details for the file toynlp-0.3.0.tar.gz.

File metadata

  • Download URL: toynlp-0.3.0.tar.gz
  • Upload date:
  • Size: 79.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for toynlp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 775d61f413fabf7aebc86fdd9a9e99a9e99c8dc3c6dac3d3bdb53a06a3257f13
MD5 e727e50371a9cf43b23fe5d0aab98c51
BLAKE2b-256 600319f25e637943758417fdffee4ddbf15a36f390219f6e402568c85abdd59f

See more details on using hashes here.

File details

Details for the file toynlp-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: toynlp-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 110.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for toynlp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a7950973e66019319a0318aa3c45d9b4d5e3f0f2ba465eab89ed3cdf90a11a6
MD5 64c0abc77b103eb559d95300caa709ac
BLAKE2b-256 563a6c0c8223064079050801e471c2ad308e755275d4829e548be2b0a70df347

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page