Skip to content

Commit

Permalink
QA example refactoring. (#36)
Browse files Browse the repository at this point in the history
* QA example refactoring.
- Notebook updated as to match new version.

* README.md updated.
- QA notebook badge added.
- Badges introduced.

* Dependency badge (source) updated.

* Updates from review.

* Updates from review and qa pipeline refactoring.

* Updates from review and qa pipeline refactoring.

* Notebook output cells cleared.

* Bug fix on QA Processor & requirements.txt added for QA example.

* Version update.

* Notebook and example project readmes updated.
- Notebook utils added.

* debug_scripts ignored.

* README updated.
- Notebook utils updated.

* Code formatting.

* README.md updated.

* Experiment config fetch added.

* Notebook updated.
- Prepare data is updated.
  • Loading branch information
devrimcavusoglu authored Nov 3, 2021
1 parent c0d45da commit a45ce70
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 352 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ coverage.xml
*dataset_infos.json

# mypy
.mypy_cache
.mypy_cache

# Misc
debug_scripts/
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# Trapper (Transformers wRAPPER)
<h1 align="center">Trapper (Transformers wRAPPER)</h1>

<p align="center">
<a href="https://pypi.org/project/trapper"><img src="https://img.shields.io/pypi/pyversions/trapper" alt="Python versions"></a>
<a href="https://pypi.org/project/trapper"><img src="https://img.shields.io/pypi/v/trapper?color=blue" alt="PyPI version"></a>
<a href="https://github.com/obss/trapper/releases/latest"><img alt="Latest Release" src="https://img.shields.io/github/release-date/obss/trapper"></a>
<a href="https://colab.research.google.com/github/obss/trapper/blob/main/examples/question_answering/question_answering.ipynb"><img alt="Open in Colab" src="https://colab.research.google.com/assets/colab-badge.svg"></a>
<br>
<a href="https://github.com/obss/trapper/actions"><img alt="Build status" src="https://github.com/obss/trapper/actions/workflows/ci.yml/badge.svg"></a>
<a href="https://libraries.io/pypi/trapper"><img alt="Dependencies" src="https://img.shields.io/librariesio/release/pypi/trapper"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://github.com/obss/trapper/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/github/license/obss/trapper"></a>
</p>

Trapper is an NLP library that aims to make it easier to train transformer based
models on downstream tasks. It wraps the HuggingFace's `transformers` library to
Expand Down Expand Up @@ -300,15 +312,15 @@ thanks to configuration file based experiments.
### Training a POS Tagging Model on CONLL2003

Since the transformers library lacks a direct support for POS tagging, we added an
example project that trains a transformer model on `CONLL2003` POS tagging dataset
and perform inference using it. You can find it in `examples/pos_tagging`. It is a
[example project](./examples/pos_tagging) that trains a transformer model on `CONLL2003` POS tagging dataset
and perform inference using it. It is a
self-contained project including its own requirements file, therefore you can copy
the folder into another directory to use as a template for your own project. Please
follow its `README.md` to get started.

### Training a Question Answering Model on SQuAD Dataset

You can use the notebook in `examples/question_answering/question_answering. ipynb`
You can use the notebook in the [Example QA Project](./examples/question_answering) `examples/question_answering/question_answering.ipynb`
to follow the steps while training a transformer model on SQuAD v1.

## Installation
Expand Down
3 changes: 1 addition & 2 deletions examples/pos_tagging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ This project show how to train a transformer model from on CONLL2003 dataset
from `HuggingFace datasets`. You can explore the dataset
from [its page](https://huggingface.co/datasets/conll2003). This project is intended
to serve as a demo for using trapper as a library to train and evaluate a
transformer model on a custom task/dataset as well as perform inference using it. We
start by creating a fresh python environment and install the dependencies.
transformer model on a custom task/dataset as well as perform inference using it. To see an example of supported task, see [Question answering example](../question_answering). We start by creating a fresh python environment and install the dependencies.

## Environment Creation and Dependency Installation

Expand Down
2 changes: 1 addition & 1 deletion examples/pos_tagging/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
trapper==0.0.3
trapper==0.0.4
6 changes: 6 additions & 0 deletions examples/question_answering/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Question Answering Demo

<a href="https://colab.research.google.com/github/obss/jury/blob/main/examples/question_answering/question_answering.ipynb"><img alt="Open in Colab" src="https://colab.research.google.com/assets/colab-badge.svg"></a>


This notebook serves as an example for demonstrating training and inference using `trapper`. Question-answering task is supported by `trapper` already, and thus in this notebook we only give a basic [configuration file](./experiment.jsonnet) and let the trapper take care of the rest. For implementation of a desired task using trapper, see [Pos tagging example](../pos_tagging).
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ local result_dir = std.extVar("OUTPUT_PATH");
"type": "default",
"output_dir": checkpoint_dir,
"result_dir": result_dir,
"num_train_epochs": 2,
"num_train_epochs": 10,
"per_device_train_batch_size": 2,
"gradient_accumulation_steps": 12,
"per_device_eval_batch_size": 4,
"per_device_eval_batch_size": 2,
"logging_dir": checkpoint_dir + "/logs",
"no_cuda": false,
"logging_steps": 500,
Expand Down
127 changes: 0 additions & 127 deletions examples/question_answering/experiment.py

This file was deleted.

Loading

0 comments on commit a45ce70

Please sign in to comment.