Lab 1 of 3about 40 minutes
Score any text, token by token
It uses what you learned in Tokenization, Word embeddings and Language modeling.
You will cut any text into the series' model's tokens, find a token's nearest rows in the model's table by hand, and score a text token by token: each token's surprise in bits, and the text's perplexity.
- A first runRun it
- The piecesYour turn
- A token's nearest rowsYour turn
- The surprise at each tokenYour turn
- Perplexity, two waysYour turn
- Two ways to get it wrongRun it
- On your own: texts of your ownOn your own
curl -LsSf https://astral.sh/uv/install.sh | sh
cd learn-nlp-transformers/labs/nlp-lab-score-text/starter
uv syncWhen you have run it
After step 5, uv run python score.py prints the series' sentence's perplexity. What is it?
Run on macOS on an M1 Max, uv 0.11.15, Python 3.12, PyTorch 2.15.0, Transformers 5.25.0. Checked on .
