processors.rst 2.57 KB
Newer Older
LysandreJik's avatar
LysandreJik committed
1
2
3
4
5
6
Processors
----------------------------------------------------

This library includes processors for several traditional tasks. These processors can be used to process a dataset into
examples that can be fed to a model.

7
Processors
LysandreJik's avatar
LysandreJik committed
8
9
~~~~~~~~~~~~~~~~~~~~~

10
11
All processors follow the same architecture which is that of the
:class:`~pytorch_transformers.data.processors.utils.DataProcessor`. The processor returns a list
12
13
14
of :class:`~pytorch_transformers.data.processors.utils.InputExample`. These
:class:`~pytorch_transformers.data.processors.utils.InputExample` can be converted to
:class:`~pytorch_transformers.data.processors.utils.InputFeatures` in order to be fed to the model.
LysandreJik's avatar
LysandreJik committed
15

16
.. autoclass:: pytorch_transformers.data.processors.utils.DataProcessor
LysandreJik's avatar
LysandreJik committed
17
18
19
    :members:


20
.. autoclass:: pytorch_transformers.data.processors.utils.InputExample
LysandreJik's avatar
LysandreJik committed
21
22
23
    :members:


24
25
26
27
.. autoclass:: pytorch_transformers.data.processors.utils.InputFeatures
    :members:


28
29
GLUE
~~~~~~~~~~~~~~~~~~~~~
LysandreJik's avatar
LysandreJik committed
30

31
32
33
`General Language Understanding Evaluation (GLUE) <https://gluebenchmark.com/>`__ is a benchmark that evaluates
the performance of models across a diverse set of existing NLU tasks. It was released together with the paper
`GLUE: A multi-task benchmark and analysis platform for natural language understanding <https://openreview.net/pdf?id=rJ4km2R5t7>`__
LysandreJik's avatar
LysandreJik committed
34

35
36
This library hosts a total of 10 processors for the following tasks: MRPC, MNLI, MNLI (mismatched),
CoLA, SST2, STSB, QQP, QNLI, RTE and WNLI.
LysandreJik's avatar
LysandreJik committed
37

38
39
40
41
42
43
44
45
46
47
Those processors are:
    - :class:`~pytorch_transformers.data.processors.utils.MrpcProcessor`
    - :class:`~pytorch_transformers.data.processors.utils.MnliProcessor`
    - :class:`~pytorch_transformers.data.processors.utils.MnliMismatchedProcessor`
    - :class:`~pytorch_transformers.data.processors.utils.Sst2Processor`
    - :class:`~pytorch_transformers.data.processors.utils.StsbProcessor`
    - :class:`~pytorch_transformers.data.processors.utils.QqpProcessor`
    - :class:`~pytorch_transformers.data.processors.utils.QnliProcessor`
    - :class:`~pytorch_transformers.data.processors.utils.RteProcessor`
    - :class:`~pytorch_transformers.data.processors.utils.WnliProcessor`
LysandreJik's avatar
LysandreJik committed
48

49
50
Additionally, the following method  can be used to load values from a data file and convert them to a list of
:class:`~pytorch_transformers.data.processors.utils.InputExample`.
LysandreJik's avatar
LysandreJik committed
51

52
53
54
55
.. automethod:: pytorch_transformers.data.processors.glue.glue_convert_examples_to_features

Example usage
^^^^^^^^^^^^^^^^^^^^^^^^^
LysandreJik's avatar
LysandreJik committed
56
57

An example using these processors is given in the
LysandreJik's avatar
LysandreJik committed
58
`run_glue.py <https://github.com/huggingface/pytorch-transformers/blob/master/examples/run_glue.py>`__ script.