transformers/examples
Kamal Raj d1f5ca1afd
[FLAX] glue training example refactor (#13815)
* refactor run_flax_glue.py

* updated readme

* rm unused import and args typo fix

* refactor

* make consistent arg name across task

* has_tensorboard check

* argparse -> argument dataclasses

* refactor according to review

* fix
2022-01-19 12:04:51 +01:00
..
flax [FLAX] glue training example refactor (#13815) 2022-01-19 12:04:51 +01:00
legacy Remove dependency to quiet Dependabot (#15205) 2022-01-18 09:44:35 -05:00
onnx/pytorch/summarization Fix installation instructions for BART ONNX example (#14885) 2021-12-23 04:05:32 -05:00
pytorch Fix deprecation warnings for int div (#15180) 2022-01-18 07:28:53 -05:00
research_projects [Robust Speech Event] Add guides (#15155) 2022-01-18 18:44:48 +01:00
tensorflow use block_size instead of max_seq_length in tf run_clm example (#15036) 2022-01-12 08:57:00 -05:00
README.md Doc new front (#14590) 2021-12-01 14:13:02 -05:00

Examples

This folder contains actively maintained examples of use of 🤗 Transformers organized along NLP tasks. If you are looking for an example that used to be in this folder, it may have moved to the corresponding framework subfolder (pytorch, tensorflow or flax), our research projects subfolder (which contains frozen snapshots of research projects) or to the legacy subfolder.

While we strive to present as many use cases as possible, the scripts in this folder are just examples. It is expected that they won't work out-of-the box on your specific problem and that you will be required to change a few lines of code to adapt them to your needs. To help you with that, most of the examples fully expose the preprocessing of the data. This way, you can easily tweak them.

This is similar if you want the scripts to report another metric than the one they currently use: look at the compute_metrics function inside the script. It takes the full arrays of predictions and labels and has to return a dictionary of string keys and float values. Just change it to add (or replace) your own metric to the ones already reported.

Please discuss on the forum or in an issue a feature you would like to implement in an example before submitting a PR: we welcome bug fixes but since we want to keep the examples as simple as possible, it's unlikely we will merge a pull request adding more functionality at the cost of readability.

Important note

Important

To make sure you can successfully run the latest versions of the example scripts, you have to install the library from source and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:

git clone https://github.com/huggingface/transformers
cd transformers
pip install .

Then cd in the example folder of your choice and run

pip install -r requirements.txt

To browse the examples corresponding to released versions of 🤗 Transformers, click on the line below and then on your desired version of the library:

Examples for older versions of 🤗 Transformers

Alternatively, you can switch your cloned 🤗 Transformers to a specific version (for instance with v3.5.1) with

git checkout tags/v3.5.1

and run the example command as usual afterward.