Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Easy to use NLP library built on PyTorch and TorchText
| Date | Stars |
|---|---|
| 2026-07-24 | 258 |
| 2026-07-25 | 258 |
| 2026-07-28 | 258 |
| 2026-07-30 | 258 |
| 2026-08-06 | 258 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# TorchNLP
TorchNLP is a deep learning library for NLP tasks. Built on PyTorch and TorchText, it is an attempt to provide reusable components that work across tasks. Currently it can be used for Named Entity Recognition (NER) and Chunking tasks with a Bidirectional LSTM CRF model and a Transformer network model. It can support any dataset which uses the [CoNLL 2003 format](https://www.clips.uantwerpen.be/conll2003/ner/). More tasks will be added shortly
## High Level Workflow
1. Define the NLP task
2. Extend the `Model` class and implement the `forward()` and `loss()` methods to return predictions and loss respectively
3. Use the `HParams` class to easily define the hyperparameters for the model
4. Define a data function to return dataset iterators, vocabularies etc using [TorchText](https://github.com/pytorch/text) API. Check conll.py for an example
5. Set up the `Evaluator` and `Trainer` classes to use the model, dataset iterators and metrics. Check ner.py for details
6. Run the trainer for desired number of epochs along with an early stopping criteria
7. Use the evaluator to evaluate the trained model on a specific dataset split
8. Run inference on the trained model using available input processors
## Boilerplate Components
* `Model`: Handles loading and saving of models as well as the associated hyperparameters
* `HParams`: Generic class to define hyperparameters. Can be persisted
* `Trainer`: Train a given model on a dataset. Supports features like predefined learning rate decay schedules and early stopping
* `Evaluator`: Evaluates the model on a dataset and multiple predefined or custom metrics.
* `get_input_processor_words`: Use during inference to quickly convert input strings into a format that can be processed by a model
## Available Models
* `transformer.Encoder`, `transformer.Decoder`: Transfomer network implementation from [Attention is all you need](https://arxiv.org/abs/1706.03762)
* `CRF`: Conditional Random Field layer which can be used as the final output
* `TransformerTagger`: Sequence tagging model implemented using the Transformer network and CRF
* `BiLSTMTagger`: Sequence tagging model implemented using bidirectional LSTMs and CRF
## Installation
TorchNLP requires a minimum of Python 3.5 and PyTorch 0.4.0 to run. Check [Pytorch](http://pytorch.org/) for the installation steps.
Clone this repository and install other dependencies like TorchText:
```
pip install -r requirements.txt
```
Go to the root of the project and check for integrity with PyTest:
```
pytest
```
Install this project:
```
python setup.py
```
## Usage
TorchNLP is designed to be used inside the python interpreter to make it easier to experiment without typing cumbersome command line arguments.
**NER Task**
The NER task can be run on any dataset that confirms to the [CoNLL 2003](https://www.clips.uantwerpen.be/conll2003/ner/) format. To use the CoNLL 2003 NER dataset place the dataset files in the following directory structure within your workspace root:
```
.data
|
|---conll2003
|
|---eng.train.txt
|---eng.testa.txt
|---eng.testb.txt
```
`eng.testa.txt` is used the validation dataset and `eng.testb.txt` is used as the test dataset.
Start the NER module in the python shell which sets up the imports:
```
python -i -m torchnlp.ner
```
```
Task: Named Entity Recognition
Available models:
-------------------
TransformerTagger
Sequence tagger using the Transformer network (https://arxiv.org/pdf/1706.03762.pdf)
Specifically it uses the Encoder module. For character embeddings (per word) it uses
the same Encoder module above which an additive (Bahdanau) self-attention layer is added
BiLSTMTagger
Sequence tagger using bidirectional LSTM. For character embeddings per word
uses (unidirectional) LSTM
Available datasets:
-------------------
conll2003: Conll 2003 (Parser only. You must place the files)
>>>
```
Train the [Transformer](https://arxiv.org/abs/1706.03762) Excerpt of 7,955 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:5dc3ab7794c7272d, topic:nlp, readme:named entity recognition
matched fp:5dc3ab7794c7272d, topic:pytorch
matched fp:5dc3ab7794c7272d, topic:transformer