All Projects → searchableai → KitanaQA

searchableai / KitanaQA

Licence: Apache-2.0 license
KitanaQA: Adversarial training and data augmentation for neural question-answering models

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to KitanaQA

text2text
Text2Text: Cross-lingual natural language processing and generation toolkit
Stars: ✭ 188 (+224.14%)
Mutual labels:  question-answering, bert, data-augmentation
vietnamese-roberta
A Robustly Optimized BERT Pretraining Approach for Vietnamese
Stars: ✭ 22 (-62.07%)
Mutual labels:  transformer, bert
FinBERT-QA
Financial Domain Question Answering with pre-trained BERT Language Model
Stars: ✭ 70 (+20.69%)
Mutual labels:  question-answering, bert
fastT5
⚡ boost inference speed of T5 models by 5x & reduce the model size by 3x.
Stars: ✭ 421 (+625.86%)
Mutual labels:  transformer, question-answering
Transformers
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
Stars: ✭ 55,742 (+96006.9%)
Mutual labels:  transformer, bert
Bertviz
Tool for visualizing attention in the Transformer model (BERT, GPT-2, Albert, XLNet, RoBERTa, CTRL, etc.)
Stars: ✭ 3,443 (+5836.21%)
Mutual labels:  transformer, bert
cmrc2019
A Sentence Cloze Dataset for Chinese Machine Reading Comprehension (CMRC 2019)
Stars: ✭ 118 (+103.45%)
Mutual labels:  question-answering, bert
Dab
Data Augmentation by Backtranslation (DAB) ヽ( •_-)ᕗ
Stars: ✭ 294 (+406.9%)
Mutual labels:  transformer, data-augmentation
les-military-mrc-rank7
莱斯杯:全国第二届“军事智能机器阅读”挑战赛 - Rank7 解决方案
Stars: ✭ 37 (-36.21%)
Mutual labels:  transformer, bert
TabFormer
Code & Data for "Tabular Transformers for Modeling Multivariate Time Series" (ICASSP, 2021)
Stars: ✭ 209 (+260.34%)
Mutual labels:  transformer, bert
TriB-QA
吹逼我们是认真的
Stars: ✭ 45 (-22.41%)
Mutual labels:  question-answering, bert
Nlp Tutorial
Natural Language Processing Tutorial for Deep Learning Researchers
Stars: ✭ 9,895 (+16960.34%)
Mutual labels:  transformer, bert
Rust Bert
Rust native ready-to-use NLP pipelines and transformer-based models (BERT, DistilBERT, GPT2,...)
Stars: ✭ 510 (+779.31%)
Mutual labels:  transformer, question-answering
DrFAQ
DrFAQ is a plug-and-play question answering NLP chatbot that can be generally applied to any organisation's text corpora.
Stars: ✭ 29 (-50%)
Mutual labels:  question-answering, bert
Bert Pytorch
Google AI 2018 BERT pytorch implementation
Stars: ✭ 4,642 (+7903.45%)
Mutual labels:  transformer, bert
ChineseNER
中文NER的那些事儿
Stars: ✭ 241 (+315.52%)
Mutual labels:  bert, data-augmentation
FasterTransformer
Transformer related optimization, including BERT, GPT
Stars: ✭ 1,571 (+2608.62%)
Mutual labels:  transformer, bert
SIGIR2021 Conure
One Person, One Model, One World: Learning Continual User Representation without Forgetting
Stars: ✭ 23 (-60.34%)
Mutual labels:  transformer, bert
bert in a flask
A dockerized flask API, serving ALBERT and BERT predictions using TensorFlow 2.0.
Stars: ✭ 32 (-44.83%)
Mutual labels:  transformer, bert
sister
SImple SenTence EmbeddeR
Stars: ✭ 66 (+13.79%)
Mutual labels:  transformer, bert

 

KitanaQA

Tool[KIT] for [A]dversarial Trai[N]ing and [A]ugmentation in [Q]uestion [A]nswering

AboutFeaturesInstallGetting StartedExamplesDocs

CircleCI

About

KitanaQA is an adversarial training and data augmentation framework for fine-tuning Transformer-based language models on question-answering datasets

Why KitanaQA?

While NLP models have made incredible progress on curated question-answer datasets in recent years, they are still brittle and unpredictable in production environments, making productization and enterprise adoption problematic. KitanaQA provides resources to "robustify" Transformer-based question-answer models against many types of natural and synthetic noise. The major features are:

  1. Adversarial Training can increase both robustness and performance of fine-tuned Transformer QA models. Here, we implement virtual adversarial training, which introduces embedding-space perturbations during fine-tuning to encourage the model to produce more stable results in the presence of noisy inputs.

Our experiments with BERT finetuned on the SQuAD v1.1 question answering dataset show a marked improvement in f1 and em scores:

Model em f1
BERT-base 80.8 88.5
BERT-base (ALUM) 81.97 88.92
  1. Augment Your Dataset to increase model generalizability and robustness using token-level perturbations. While Adversarial Training provides some measure of robustness against bounded perturbations, Augmentation can accomodate a wide range of naturally-occuring noise in user input. We provide tools to augment existing SQuAD-like datasets by perturbing the examples along a number of different dimensions, including synonym replacement, misspelling, repetition and deletion.

  2. Workflow Automation to prototype robust NLP models faster for research and production. This package is structured for extremely easy use and deployment. Using Prefect Flows, training, evaluation, and model selection can be executed in a single line of code, enabling faster iteration and easier itergration of research into production pipelines.

Features

Adversarial Training

Our implementation is based on the smoothness-inducing regularization approach proposed here. We have updated the implementation for fine-tuning on question-answer datasets, and added additional features like adversarial hyperparameter scheduling, and support for mixed-precision training.

Adversarial Attack

A key measure of robustness in neural networks is the so-called white-box adversarial attack. In the context of Transformer-based Question-Answer models, this attack seeks to inject noise into the model's input embeddings and assess performance on the original labels. Here, we implement the projected gradient descent (PGD) attack mechanism, bounded by the norm-ball. Metrics can be calculated for non-adversarial and adversarial evaluation, making robustness studies more streamlined and accessible.

Data Augmentation

The following perturbation methods are available to augment SQuAD-like data:

- (original)  How many species of plants were [recorded] in Egypt?
+ (augmented) How many species of plants were [registered] in Egypt?
  • Random Deletion (RD) using entity-aware term selection
- (original)  How many species of plants [were] recorded in Egypt?
+ (augmented) How many species of plants [] recorded in Egypt?
  • Random Repetition (RR) using entity-aware term selection
- (original)  How many species of plants [were] recorded in Egypt?
+ (augmented) How many species of plants [were were] recorded in Egypt?
  • Random Misspelling (RM) using open-source common misspellings datasets -- sources: wiki, brikbeck
- (original)  How [many] species of plants were recorded in Egypt?
+ (augmented) How [mony] species of plants were recorded in Egypt?

Perturbation types can be flexibly applied in combination with different frequencies for fine-grained control of natural noise profiles

- (original)  How [many] species [of] plants [were] recorded in Egypt?
+ (augmented) How [mony] species [] plants [] recorded in Egypt?

Each perturbation type also supports custom term importance sampling, e.g. as generated using a MLM
(How, 0.179), (many, 0.254), (species, 0.123), (of, 0.03), (plants, 0.136) (were, 0.039), (recorded, 0.067), (in, 0.012), (Egypt, 0.159)

ML Flows

Using the Prefect library, KitanaQA makes it increadibly easy to combine different workflows for end-to-end training/evaluation/model selection. This system also supports rapid iteration in hyperparameter search by easily specifying each experimental condition and deploying independently. You can even get results reported directly in Slack!

Installation

Entity-aware data augmentations make use of the John Snow Labs spark-nlp library, which requires pyspark. To enable this feature, make sure Java v8 is set by default for pyspark compatibility:

sudo apt install openjdk-8-jdk
sudo update-alternatives --config java
java -version

It is recommended that you use a virtual environment when installing from pip or source. Virtualenv and Conda are good options.

This package has been tested on Python 3.7+, PyTorch 1.5.1+ and transformers 1.3.1

Install with pip:
pip install kitanaqa

Install from source:

git clone https://github.com/searchableai/KitanaQA.git
cd KitanaQA
python setup.py install

Getting Started

To run training or evaluation from the commandline:

python src/kitanaqa/trainer/run_pipeline.py --args=args.json

See an example args.json

Examples

Augmentation

Training and Evaluation

Models Supported

We make use of the following models and their respective tokenizers and configurations provided by Hugging Face Inc.

  • ALBERT
  • BERT
  • DistilBERT

Contributing to KitanaQA

We welcome suggestions and contributions! Submit an issue or pull request and we will do our best to respond in a timely manner. See CONTRIBUTING.md for detailed information on contributing.

Thanks!

  • John Snow Labs
  • Hugging Face Inc.
  • pytorch community
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].