https://github.com/chenghaomou/pytorch-pqrnn

Implementation of pQRNN in PyTorch

https://github.com/chenghaomou/pytorch-pqrnn

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.1%) to scientific vocabulary

Keywords

nlp pqrnn pytorch text-classification
Last synced: 5 months ago · JSON representation

Repository

Implementation of pQRNN in PyTorch

Basic Info
  • Host: GitHub
  • Owner: ChenghaoMou
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 264 KB
Statistics
  • Stars: 46
  • Watchers: 2
  • Forks: 9
  • Open Issues: 2
  • Releases: 0
Archived
Topics
nlp pqrnn pytorch text-classification
Created over 5 years ago · Last pushed over 4 years ago
Metadata Files
Readme License

README.md

banner

PyPI Maintenance PyPI - License DOI

Installation

```bash

install with pypi

pip install pytorch-pqrnn

or install locally with poetry

poetry install ```

Environment

Because of this issue, pytorch-qrnn is no longer compatible with pytorch and it is also not actively maintained. If you want to use a QRNN layer in this model, you have install pytorch-qrnn with torch <= 1.4 first.

Usage

```python from pytorchpqrnn.dataset import createdataloaders from pytorch_pqrnn.model import PQRNN

model = PQRNN( b=128, d=96, lr=1e-3, numlayers=2, dropout=0.5, outputsize=5, rnntype="GRU", multilabel=False, nhead=2, # used when rnntype == "Transformer" )

Or load the model from your checkpoint

model = PQRNN.loadfromcheckpoint(checkpoint_path="example.ckpt")

Text data has to be pre-processed with DummyDataset

dataset = DummyDataset( df[["text", "label"]].todict("records"), haslabel=True, featuresize=128 * 2, addeostag=True, addbostag=True, maxseq_len=512, label2index={"pos": 1, "neg": 0}, )

Explicit train/val loop

Add model.eval() when necessary

dataloader = createdataloaders(dataset) for batch in dataloader: # labels could be an empty tensor if haslabel is False when creating the dataset. # To change what are included in a batch, feel free to change the collate_fn function # in dataset.py projections, lengths, labels = batch logits = model.forward(projections)

# do your magic ```

CLI Usage

```bash Usage: run.py [OPTIONS]

Options: --task [yelp2|yelp5|toxic] [default: yelp5] --b INTEGER [default: 128] --d INTEGER [default: 96] --numlayers INTEGER [default: 2] --batchsize INTEGER [default: 512] --dropout FLOAT [default: 0.5] --lr FLOAT [default: 0.001] --nhead INTEGER [default: 4] --rnntype [LSTM|GRU|QRNN|Transformer] [default: GRU] --datapath TEXT --help Show this message and exit. ```

Datasets

  • yelp2(polarity): it will be downloaded w/ huggingface/datasets automatically
  • yelp5: json file should be downloaded to into data_path
  • toxic: dataset should be downloaded and unzipped to into data_path

Example: Yelp Polarity

python -W ignore run.py --task yelp2 --b 128 --d 64 --num_layers 4 --data_path data/

Benchmarks(not optimized)

| Model | Model Size | Yelp Polarity (error rate) | Yelp-5 (accuracy) | Civil Comments (mean auroc) | Command | | ------------------------ | ---------- | -------------------------- | ----------------- | --------------------------- | ---------------------------------------------------------------- | | ~~PQRNN (this repo)~~0 | ~~78K~~ | ~~6.3~~ | ~~70.4~~ | ~~TODO~~ | --b 128 --d 64 --num_layers 4 --rnn_type QRNN | | PRNN (this repo) | 90K | 5.5 | 70.7 | 95.57 | --b 128 --d 64 --num_layers 1 --rnn_type GRU | | PTransformer (this repo) | 618K | 10.8 | 68 | 92.4 | --b 128 --d 64 --num_layers 1 --rnn_type Transformer --nhead 8 | | PRADO1 | 175K | | 65.9 | | | | BERT | 335M | 1.81 | 70.58 | 98.8562 | | 0. Not supported with torch >= 1.7 1. Paper 2. Best Kaggle Submission

Credits

Citation

@software{chenghao_mou_2021_4661601, author = {Chenghao MOU}, title = {ChenghaoMou/pytorch-pQRNN: Add DOI}, month = apr, year = 2021, publisher = {Zenodo}, version = {0.0.3}, doi = {10.5281/zenodo.4661601}, url = {https://doi.org/10.5281/zenodo.4661601} }

Owner

  • Name: Chenghao Mou
  • Login: ChenghaoMou
  • Kind: user
  • Location: Ireland

NLP/AI

GitHub Events

Total
Last Year

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 34
  • Total Committers: 1
  • Avg Commits per committer: 34.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Chenghao Mou m****o@g****m 34

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 7
  • Total pull requests: 0
  • Average time to close issues: about 2 months
  • Average time to close pull requests: N/A
  • Total issue authors: 3
  • Total pull request authors: 0
  • Average comments per issue: 1.71
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ChenghaoMou (5)
  • zzjss12 (1)
  • kpriyanshu256 (1)
Pull Request Authors
Top Labels
Issue Labels
enhancement (2)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 10 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 1
  • Total maintainers: 1
pypi.org: pytorch-pqrnn

Pytorch implementation of pQRNN

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 10 Last month
Rankings
Stargazers count: 9.8%
Dependent packages count: 10.1%
Forks count: 11.4%
Average: 21.5%
Dependent repos count: 21.6%
Downloads: 54.6%
Maintainers (1)
Last synced: 6 months ago