{ "

Trying out Sampling Techniques for Language Models

\n\n

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

\n": "

\u5c1d\u8bd5\u8bed\u8a00\u6a21\u578b\u7684\u91c7\u6837\u6280\u672f

\n\n

\u672c\u5b9e\u9a8c\u5728HuggingFace\u7684GPT2\u6a21\u578b\u4e0a\u4f7f\u7528\u4e86\u4e0a\u8ff0\u91c7\u6837\u6280\u672f\u3002

\n", "

Sample from model

\n\n": "

\u6765\u81ea\u6a21\u578b\u7684\u6837\u672c

\n\n", "

Try different sampling techniques

\n": "

\u5c1d\u8bd5\u4e0d\u540c\u7684\u91c7\u6837\u6280\u5de7

\n", "

\n": "

\n", "

Greedy Sampling

\n": "

\u8d2a\u5a6a\u91c7\u6837

\n", "

Nucleus Sampling

\n": "

\u539f\u5b50\u6838\u91c7\u6837

\n", "

Temperature Sampling

\n": "

\u6e29\u5ea6\u91c7\u6837

\n", "

Top-k Sampling

\n": "

\u524d k \u4e2a\u91c7\u6837

\n", "

Add the sampled token to the data

\n": "

\u5c06\u91c7\u6837\u4ee4\u724c\u6dfb\u52a0\u5230\u6570\u636e\u4e2d

\n", "

Collect output for printing

\n": "

\u6536\u96c6\u8f93\u51fa\u4ee5\u8fdb\u884c\u6253\u5370

\n", "

Decode and add the sampled token for logging

\n": "

\u89e3\u7801\u5e76\u6dfb\u52a0\u7528\u4e8e\u65e5\u5fd7\u8bb0\u5f55\u7684\u91c7\u6837\u4ee4\u724c

\n", "

Get the _^_0_^_ of the last token

\n": "

\u83b7\u53d6\u6700\u540e_^_0_^_\u4e00\u4e2a\u4ee4\u724c\u7684

\n", "

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

\n": "

\u83b7\u53d6\u6a21\u578b\u8f93\u51fa\u3002\u201clogits\u201d \u6709\u5f62\u72b6_^_0_^_

\n", "

Load the model and tokenizer

\n": "

\u52a0\u8f7d\u6a21\u578b\u548c\u5206\u8bcd\u5668

\n", "

Print the sampled outputs

\n": "

\u6253\u5370\u91c7\u6837\u8f93\u51fa

\n", "

Prompts to use for sampling

\n": "

\u91c7\u6837\u65f6\u4f7f\u7528\u7684\u63d0\u793a

\n", "

Sample _^_0_^_

\n": "

\u6837\u672c_^_0_^_

\n", "

Sample from the _^_0_^_

\n": "

\u6837\u672c\u6765\u81ea_^_0_^_

\n", "

Set the model to eval mode

\n": "

\u5c06\u6a21\u578b\u8bbe\u7f6e\u4e3a\u8bc4\u4f30\u6a21\u5f0f

\n", "

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

\n": "

\u6807\u8bb0\u5316_^_0_^_\u5e76\u5236\u4f5c\u5176_^_1_^_\u526f\u672c

\n", "

Truncate the data to the maximum sequence length

\n": "

\u5c06\u6570\u636e\u622a\u65ad\u4e3a\u6700\u5927\u5e8f\u5217\u957f\u5ea6

\n", "Trying out Sampling Techniques for Language Models": "\u5c1d\u8bd5\u8bed\u8a00\u6a21\u578b\u7684\u91c7\u6837\u6280\u672f", "We try out different sampling techniques for language models on HuggingFace's GPT2 model.": "\u6211\u4eec\u5728HuggingFace\u7684GPT2\u6a21\u578b\u4e0a\u4e3a\u8bed\u8a00\u6a21\u578b\u5c1d\u8bd5\u4e86\u4e0d\u540c\u7684\u91c7\u6837\u6280\u672f\u3002" }