Guide to fixed-length model perplexity evaluation
This post / guide is inspired by this recent [Twitter discussion](https://twitter.com/myleott/status/1245840363262283776) and [this gist](https://gist.github.com/myleott/cdf685b8b3ce20b0221e1842782bce74) on the different ways that perplexity can be evaluated and the optimal strategy of a strided "sliding window".

Interested in feedback both on the guide/writing component as well as the theoretical discussion on PPL. Right now my understanding is that our language modeling script uses non-overlapping segments rather than the sliding window.

Relevant to #4415, #4219.
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5449?src=pr&el=h1) Report
> Merging [#5449](https://codecov.io/gh/huggingface/transformers/pull/5449?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/d16e36c7e525aab4c08a6e60a7478e209498dc14&el=desc) will **increase** coverage by `0.86%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/5449/graphs/tree.svg?width=650&height=150&src=pr&token=9qOlN6Hb1c)](https://codecov.io/gh/huggingface/transformers/pull/5449?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #5449      +/-   ##
==========================================
+ Coverage   77.82%   78.68%   +0.86%     
==========================================
  Files         141      141              
  Lines       24608    24608              
==========================================
+ Hits        19150    19364     +214     
+ Misses       5458     5244     -214     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/5449?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/generation\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/5449/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9nZW5lcmF0aW9uX3V0aWxzLnB5) | `97.10% <0.00%> (+0.28%)` | :arrow_up: |
| [src/transformers/generation\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/5449/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9nZW5lcmF0aW9uX3RmX3V0aWxzLnB5) | `86.68% <0.00%> (+0.50%)` | :arrow_up: |
| [src/transformers/modeling\_openai.py](https://codecov.io/gh/huggingface/transformers/pull/5449/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19vcGVuYWkucHk=) | `81.09% <0.00%> (+1.37%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_openai.py](https://codecov.io/gh/huggingface/transformers/pull/5449/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9vcGVuYWkucHk=) | `94.98% <0.00%> (+74.19%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/5449?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5449?src=pr&el=footer). Last update [d16e36c...b3dae20](https://codecov.io/gh/huggingface/transformers/pull/5449?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
