{ "

Trying out Sampling Techniques for Language Models

\n\n

This experiment uses the above sampling techniques, on HuggingFace's GPT2 model.

\n": "

\u8a00\u8a9e\u30e2\u30c7\u30eb\u306e\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u624b\u6cd5\u306e\u8a66\u307f

\n\n

\u3053\u306e\u5b9f\u9a13\u3067\u306f\u3001HuggingFace\u306eGPT2\u30e2\u30c7\u30eb\u3067\u4e0a\u8a18\u306e\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u624b\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002

\n", "

Sample from model

\n\n": "

\u30e2\u30c7\u30eb\u304b\u3089\u306e\u30b5\u30f3\u30d7\u30eb

\n\n", "

Try different sampling techniques

\n": "

\u3055\u307e\u3056\u307e\u306a\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u624b\u6cd5\u3092\u8a66\u3057\u3066\u304f\u3060\u3055\u3044

\n", "

\n": "

\n", "

Greedy Sampling

\n": "

\u6b32\u5f35\u308a\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0

\n", "

Nucleus Sampling

\n": "

\u6838\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0

\n", "

Temperature Sampling

\n": "

\u6e29\u5ea6\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0

\n", "

Top-k Sampling

\n": "

\u30c8\u30c3\u30d7k\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0

\n", "

Add the sampled token to the data

\n": "

\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u3057\u305f\u30c8\u30fc\u30af\u30f3\u3092\u30c7\u30fc\u30bf\u306b\u8ffd\u52a0\u3057\u307e\u3059

\n", "

Collect output for printing

\n": "

\u5370\u5237\u7528\u306e\u51fa\u529b\u3092\u53ce\u96c6

\n", "

Decode and add the sampled token for logging

\n": "

\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u3057\u305f\u30c8\u30fc\u30af\u30f3\u3092\u30c7\u30b3\u30fc\u30c9\u3057\u3066\u30ed\u30ae\u30f3\u30b0\u7528\u306b\u8ffd\u52a0

\n", "

Get the _^_0_^_ of the last token

\n": "

\u6700\u5f8c\u306e\u30c8\u30fc\u30af\u30f3\u306e\u53d6\u5f97 _^_0_^_

\n", "

Get the model output. The 'logits' has shape _^_0_^_

\n": "

\u30e2\u30c7\u30eb\u51fa\u529b\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u300c\u30ed\u30b8\u30c3\u30c8\u300d\u306b\u306f\u5f62\u304c\u3042\u308a\u307e\u3059 _^_0_^_

\n", "

Load the model and tokenizer

\n": "

\u30e2\u30c7\u30eb\u3068\u30c8\u30fc\u30af\u30ca\u30a4\u30b6\u30fc\u3092\u30ed\u30fc\u30c9

\n", "

Print the sampled outputs

\n": "

\u30b5\u30f3\u30d7\u30eb\u51fa\u529b\u3092\u5370\u5237

\n", "

Prompts to use for sampling

\n": "

\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u306b\u4f7f\u7528\u3059\u308b\u30d7\u30ed\u30f3\u30d7\u30c8

\n", "

Sample _^_0_^_

\n": "

[\u30b5\u30f3\u30d7\u30eb] _^_0_^_

\n", "

Sample from the _^_0_^_

\n": "

\u304b\u3089\u306e\u30b5\u30f3\u30d7\u30eb _^_0_^_

\n", "

Set the model to eval mode

\n": "

\u30e2\u30c7\u30eb\u3092 eval \u30e2\u30fc\u30c9\u306b\u8a2d\u5b9a

\n", "

Tokenize the _^_0_^_ and make _^_1_^_ copies of it

\n": "

_^_0_^__^_1_^_\u3092\u30c8\u30fc\u30af\u30f3\u5316\u3057\u3066\u30b3\u30d4\u30fc\u3092\u4f5c\u6210

\n", "

Truncate the data to the maximum sequence length

\n": "

\u30c7\u30fc\u30bf\u3092\u6700\u5927\u30b7\u30fc\u30b1\u30f3\u30b9\u9577\u307e\u3067\u5207\u308a\u6368\u3066\u308b

\n", "Trying out Sampling Techniques for Language Models": "\u8a00\u8a9e\u30e2\u30c7\u30eb\u306e\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u624b\u6cd5\u306e\u8a66\u307f", "We try out different sampling techniques for language models on HuggingFace's GPT2 model.": "HuggingFace\u306eGPT2\u30e2\u30c7\u30eb\u3067\u3001\u8a00\u8a9e\u30e2\u30c7\u30eb\u7528\u306b\u3055\u307e\u3056\u307e\u306a\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u624b\u6cd5\u3092\u8a66\u3057\u3066\u3044\u307e\u3059\u3002" }