http 响应消息解码
介绍 (Introduction)
Deep learning has been deployed in many tasks in NLP, such as translation, image captioning, and dialogue systems. In machine translation, it is used to read source language (input) and generate the desired language (output). Similarly in a dialogue system, it is used to generate a response given a context. This is also known as Natural Language Generation (NLG).
深度学习已部署在NLP的许多任务中,例如翻译,图像字幕和对话系统。 在机器翻译中,它用于读取源语言(输入)并生成所需的语言(输出)。 类似地,在对话系统中,它用于在给定上下文的情况下生成响应。 这也称为自然语言生成(NLG)。
The model splits into 2 parts: encoder and decoder. Encoder reads the input text and returns a vector representing that input. Then, the decoder takes that vector and generates a corresponding text.
该模型分为两部分:编码器和解码器。 编码器读取输入文本,并返回代表该输入的向量。 然后,解码器获取该向量并生成相应的文本。
To generate a text, commonly it is done by generating one token at a time. Without proper techniques, the generated response may be very generic and boring. In this article, we will explore the following strategies:
要生成文本,通常是一次生成一个令牌来完成。 没有适当的技术,生成的响应可能会非常通用且令人厌烦。 在本文中,我们将探讨以下策略:
- Greedy 贪婪
- Beam Search 光束搜索
- Random Sampling 随机抽样
- Temperature 温度
- Top-K Sampling Top-K采样
- Nucleus Sampling 核采样
解码策略 (Decoding Strategies)
At each timestep during decoding, we take the vector (that holds the information from one step to another) and apply it with softmax function to convert it into an array of probability for each word.
在解码期间的每个时间步上,我们取向量(将信息从一个步骤转移到另一个步骤),并将其与softmax函数一起应用以将其转换为每个单词的概率数组。
贪婪的方法 (Greedy Approach)
This app