yu-val-weiss commited on
Commit
803da62
·
2 Parent(s): b1b0ea9 c58b005

Merge branch 'main' of https://huggingface.co/spaces/pico-lm/blimp

Browse files
Files changed (1) hide show
  1. README.md +30 -43
README.md CHANGED
@@ -1,32 +1,29 @@
1
  ---
2
- title: Perplexity
3
- emoji: 🤗
4
  colorFrom: blue
5
  colorTo: red
6
- sdk: gradio
7
- sdk_version: 3.19.1
8
  app_file: app.py
9
  pinned: false
10
  tags:
11
  - evaluate
12
  - metric
13
  description: >-
14
- Perplexity (PPL) is one of the most common metrics for evaluating language models.
15
- It is defined as the exponentiated average negative log-likelihood of a sequence, calculated with exponent base `e`.
16
-
17
- For more information on perplexity, see [this tutorial](https://huggingface.co/docs/transformers/perplexity).
 
18
  ---
19
 
20
- # Metric Card for Perplexity
21
 
22
  ## Metric Description
23
- Given a model and an input text sequence, perplexity measures how likely the model is to generate the input text sequence.
24
-
25
- As a metric, it can be used to evaluate how well the model has learned the distribution of the text it was trained on.
26
-
27
- In this case, `model_id` should be the trained model to be evaluated, and the input texts should be the text that the model was trained on.
28
-
29
- This implementation of perplexity is calculated with log base `e`, as in `perplexity = e**(sum(losses) / num_tokenized_tokens)`, following recent convention in deep learning frameworks.
30
 
31
  ## Intended Uses
32
  Any language generation task.
@@ -37,20 +34,17 @@ The metric takes a list of text as input, as well as the name of the model used
37
 
38
  ```python
39
  from evaluate import load
40
- perplexity = load("perplexity", module_type="metric")
41
- results = perplexity.compute(predictions=predictions, model_id='gpt2')
42
  ```
43
 
44
  ### Inputs
45
- - **model_id** (str): model used for calculating Perplexity. NOTE: Perplexity can only be calculated for causal language models.
46
- - This includes models such as gpt2, causal variations of bert, causal versions of t5, and more (the full list can be found in the AutoModelForCausalLM documentation here: https://huggingface.co/docs/transformers/master/en/model_doc/auto#transformers.AutoModelForCausalLM )
47
- - **predictions** (list of str): input text, where each separate text snippet is one list entry.
48
  - **batch_size** (int): the batch size to run texts through the model. Defaults to 16.
49
- - **add_start_token** (bool): whether to add the start token to the texts, so the perplexity can include the probability of the first word. Defaults to True.
50
  - **device** (str): device to run on, defaults to `cuda` when available
51
 
52
  ### Output Values
53
- This metric outputs a dictionary with the perplexity scores for the text input in the list, and the average perplexity.
54
  If one of the input texts is longer than the max input length of the model, then it is truncated to the max length for the perplexity computation.
55
 
56
  ```
@@ -59,9 +53,6 @@ If one of the input texts is longer than the max input length of the model, then
59
 
60
  The range of this metric is [0, inf). A lower score is better.
61
 
62
- #### Values from Popular Papers
63
-
64
-
65
  ### Examples
66
  Calculating perplexity on predictions defined here:
67
  ```python
@@ -94,25 +85,21 @@ print(round(results["perplexities"][0], 2))
94
  >>>889.28
95
  ```
96
 
97
- ## Limitations and Bias
98
- Note that the output value is based heavily on what text the model was trained on. This means that perplexity scores are not comparable between models or datasets.
99
-
100
- See Meister and Cotterell, ["Language Model Evaluation Beyond Perplexity"]( https://arxiv.org/abs/2106.00085) (2021) for more information about alternative model evaluation strategies.
101
-
102
  ## Citation
103
 
104
  ```bibtex
105
- @article{jelinek1977perplexity,
106
- title={Perplexity—a measure of the difficulty of speech recognition tasks},
107
- author={Jelinek, Fred and Mercer, Robert L and Bahl, Lalit R and Baker, James K},
108
- journal={The Journal of the Acoustical Society of America},
109
- volume={62},
110
- number={S1},
111
- pages={S63--S63},
112
- year={1977},
113
- publisher={Acoustical Society of America}
 
 
 
114
  }
115
- ```
116
 
117
- ## Further References
118
- - [Hugging Face Perplexity Blog Post](https://huggingface.co/docs/transformers/perplexity)
 
1
  ---
2
+ title: BLiMP
3
+ emoji: 🎈
4
  colorFrom: blue
5
  colorTo: red
6
+ sdk: static
7
+ sdk_version: 5.20.1
8
  app_file: app.py
9
  pinned: false
10
  tags:
11
  - evaluate
12
  - metric
13
  description: >-
14
+ BLiMP is a challenge set for evaluating what language models (LMs) know about major grammatical phenomena in English. BLiMP consists of 67 sub-datasets,
15
+ each containing 1000 minimal pairs isolating specific contrasts in syntax, morphology, or semantics.
16
+ The data is automatically generated according to expert-crafted grammars.
17
+
18
+ For more information on perplexity, see the [dataset card](https://huggingface.co/datasets/nyu-mll/blimp).
19
  ---
20
 
21
+ # Metric Card for BLiMP
22
 
23
  ## Metric Description
24
+ BLiMP is a challenge set for evaluating what language models (LMs) know about major grammatical phenomena in English. BLiMP consists of 67 sub-datasets,
25
+ each containing 1000 minimal pairs isolating specific contrasts in syntax, morphology, or semantics.
26
+ The data is automatically generated according to expert-crafted grammars.
 
 
 
 
27
 
28
  ## Intended Uses
29
  Any language generation task.
 
34
 
35
  ```python
36
  from evaluate import load
37
+ blimp = load("pico-lm/blimp", module_type="metric")
38
+ results = blimp.compute(model_id='pico-lm/pico-decoder')
39
  ```
40
 
41
  ### Inputs
42
+ - **model_id** (str): model used for calculating BLiMP.
 
 
43
  - **batch_size** (int): the batch size to run texts through the model. Defaults to 16.
 
44
  - **device** (str): device to run on, defaults to `cuda` when available
45
 
46
  ### Output Values
47
+ This metric outputs a dictionary with the BLiMP scores for each subdataset.
48
  If one of the input texts is longer than the max input length of the model, then it is truncated to the max length for the perplexity computation.
49
 
50
  ```
 
53
 
54
  The range of this metric is [0, inf). A lower score is better.
55
 
 
 
 
56
  ### Examples
57
  Calculating perplexity on predictions defined here:
58
  ```python
 
85
  >>>889.28
86
  ```
87
 
 
 
 
 
 
88
  ## Citation
89
 
90
  ```bibtex
91
+ @article{warstadt2020blimp,
92
+ author = {Warstadt, Alex and Parrish, Alicia and Liu, Haokun and Mohananey, Anhad and Peng, Wei and Wang, Sheng-Fu and Bowman, Samuel R.},
93
+ title = {BLiMP: The Benchmark of Linguistic Minimal Pairs for English},
94
+ journal = {Transactions of the Association for Computational Linguistics},
95
+ volume = {8},
96
+ number = {},
97
+ pages = {377-392},
98
+ year = {2020},
99
+ doi = {10.1162/tacl\_a\_00321},
100
+ URL = {https://doi.org/10.1162/tacl_a_00321},
101
+ eprint = {https://doi.org/10.1162/tacl_a_00321},
102
+ abstract = { We introduce The Benchmark of Linguistic Minimal Pairs (BLiMP),1 a challenge set for evaluating the linguistic knowledge of language models (LMs) on major grammatical phenomena in English. BLiMP consists of 67 individual datasets, each containing 1,000 minimal pairs—that is, pairs of minimally different sentences that contrast in grammatical acceptability and isolate specific phenomenon in syntax, morphology, or semantics. We generate the data according to linguist-crafted grammar templates, and human aggregate agreement with the labels is 96.4\%. We evaluate n-gram, LSTM, and Transformer (GPT-2 and Transformer-XL) LMs by observing whether they assign a higher probability to the acceptable sentence in each minimal pair. We find that state-of-the-art models identify morphological contrasts related to agreement reliably, but they struggle with some subtle semantic and syntactic phenomena, such as negative polarity items and extraction islands. }
103
  }
 
104
 
105
+ ```