Translator | Li Rui
Reviewer | Sun Shujuan
In recent years, the Transformer machine learning model has become one of the main highlights of the advancement of deep learning and deep neural network technology. It is mainly used for advanced applications in natural language processing. Google is using it to enhance its search engine results. OpenAI used Transformer to create the famous GPT-2 and GPT-3 models.
Since its debut in 2017, the Transformer architecture has continued to evolve and expand into many different variants, extending from language tasks to other domains. They have been used for time series forecasting. They are the key innovation behind AlphaFold, DeepMind’s protein structure prediction model. OpenAI’s source code generation model Codex is also based on Transformer. Transformers have also recently entered the field of computer vision, where they are slowly replacing convolutional neural networks (CNN) in many complex tasks.
Researchers are still exploring ways to improve Transformer and use it in new applications. Here’s a quick explanation of what makes Transformers exciting and how they work.
1. Use neural network to process sequence data
Traditional feedforward neural networks are not designed to track sequential data and map each input to an output. It works well for tasks like image classification, but fails on sequence data like text. Machine learning models that process text must not only process each word, but also consider how words are arranged in order and related to each other. And the meaning of a word may change depending on the other words that appear before and after them in the sentence.
Before the advent of Transformer, Recurrent Neural Networks (RNN) were the preferred solution for natural language processing. When given a sequence of words, a Recurrent Neural Network (RNN) will process the first word and feed the results back to the layer that processes the next word. This enables it to track an entire sentence rather than processing each word individually.
The shortcomings of recurrent neural networks (RNN) limit their usefulness. First, they are very slow to process. Because they must process data sequentially, they cannot take advantage of parallel computing hardware and graphics processing units (GPUs) for training and inference. Second, they cannot handle long sequences of text. As the recurrent neural network (RNN) goes deeper into the text excerpt, the effect of the first few words of the sentence gradually diminishes. This problem known as "vanishing gradient" occurs when two linked words are far apart in the text. Third, they only capture the relationship between a word and the words that precede it. In fact, the meaning of words depends on the words that come before and after them.
The Long Short-Term Memory (LSTM) network is the successor of the Recurrent Neural Network (RNN), which can solve the vanishing gradient problem to a certain extent and can handle larger text sequences. But Long Short-Term Memory (LSTM) is even slower to train than Recurrent Neural Networks (RNN), and still cannot take full advantage of parallel computing. They still rely on serial processing of text sequences.
A paper published in 2017 called "Attention is All That Is Needed" introduced Transformer, stating that Transformer
made two key contributions: First, they made parallel processing of entire sequences a possible, thereby scaling the speed and capacity of sequential deep learning models to unprecedented speeds. Second, they introduce "attention mechanisms" that can track relationships between words in very long text sequences, both forward and backward.
Before discussing how the Transformer model works, it is necessary to discuss the types of problems that sequence neural networks solve.
- Vector-to-sequence models take a single input (such as an image) and generate a sequence of data (such as a description).
- Sequence-to-vector models take sequence data as input, such as product reviews or social media posts, and output a single value, such as a sentiment score.
- A "sequence-to-sequence" model takes as input a sequence, such as an English sentence, and outputs another sequence, such as the French translation of that sentence.
Despite their differences, all these types of models have one thing in common - they learn expressions. The job of a neural network is to convert one type of data into another type of data. During training, the neural network's hidden layer (the layer between the input and output) adjusts its parameters in a way that best represents the characteristics of the input data type and maps them to the output. The original Transformer was designed as a sequence-to-sequence (seq2seq) model for machine translation (of course, sequence-to-sequence models are not limited to translation tasks). It consists of an encoder module that compresses the input string from the source language into a vector that represents words and their relationships to each other. The decoder module converts the encoded vector into a text string in the target language.
2. Marking and embedding
The input text must be processed and converted into a unified format, and then can be input to Transformer. First, the text is passed through a "tokenizer," which breaks it into chunks of characters that can be processed individually. The tokenization algorithm can depend on the application. In most cases, each word and punctuation mark roughly counts as one token. Some suffixes and prefixes count as separate tokens (for example, "ize", "ly", and "pre"). The tokenizer generates a list of numbers representing the token IDs of the input text.
The tokens are then converted into "word embeddings". Word embedding is a vector that attempts to capture the value of a word in a multi-dimensional space. For example, the words "cat" and "dog" may have similar values on some dimensions because they are both used in sentences about animals and pets. However, on other dimensions that distinguish felines from canines, "cat" is closer to "lion" than "wolf." Likewise, "Paris" and "London" are probably closer to each other because they are both cities. However, "London" is closer to "England" and "Paris" is closer to "France" because of the differentiating dimensions of a country. And word embeddings typically have hundreds of dimensions.
Word embeddings are created through embedding models that are trained separately from the Transformer. There are several pre-trained embedding models for language tasks.
3. Pay attention to the layer
contains several attention blocks and feed-forward layers to gradually capture more complex relationships.
The decoder uses the same tokenization, word embedding and attention mechanisms to process the expected results and create attention vectors. It then passes this attention vector and attention layer in the encoder module to establish a relationship between the input and output values. In a translation application, this is the part where words in the source and target language are mapped to each other. Like the encoder module, the decoder attention vectors are passed through feedforward layers. The result is then mapped to a very large pool of vectors, i.e. the size of the target data (in the case of translation, this can involve tens of thousands of words).
4. Training Transformer
##During training, Transformer provides a very large A corpus of paired examples (e.g., English sentences and their corresponding French translations). The encoder module receives and processes the complete input string. However, the decoder receives a masked version of the output string (one word at a time) and attempts to establish a mapping between the encoded attention vector and the expected result. The encoder tries to predict the next word and makes corrections based on the difference between its output and the expected result. This feedback enables the converter to modify the parameters of the encoder and decoder and gradually create the correct mapping between the input and output languages. The more training data and parameters a Transformer has, the better it is at maintaining coherence and consistency across longer sequences of text. 5. Changes in Transformer # In the machine translation example studied above, Transformer’s encoder module learns relationships between English words and sentences, while the decoder learns mappings between English and French. But not all Transformer applications require encoder and decoder modules. For example, the GPT family of large language models uses a stack of decoder modules to generate text. BERT is another variant of the Transformer model developed by Google researchers, but it only uses the encoder module. The advantage of some of these architectures is that they can be trained through self-supervised learning or unsupervised methods. BERT, for example, does most of its training by taking a large corpus of unlabeled text, masking out parts of it, and trying to predict the missing parts. It then adjusts its parameters based on how close or far away its predictions are from the actual data. By continuously repeating this process, BERT captures the relationship between different words in different scenes. After this pre-training phase, BERT can be fine-tuned for downstream tasks such as question answering, text summarization, or sentiment analysis by training on a small number of labeled examples. Using unsupervised and self-supervised pre-training can reduce the effort required to annotate training data. There’s a lot more about Transformers and the new apps they’re unlocking, which is beyond the scope of this article. Researchers are still looking for ways to get more help from Transformer. Transformer also sparked discussions about language understanding and general artificial intelligence. What is clear is that the Transformer, like other neural networks, is a statistical model capable of capturing regularities in data in clever and sophisticated ways. While they don't "understand" language the way humans do, their development is still exciting and has much more to offer. Original link: https://bdtechtalks.com/2022/05/02/what-is-the-transformer/The above is the detailed content of What is the Transformer machine learning model?. For more information, please follow other related articles on the PHP Chinese website!

1 前言在发布DALL·E的15个月后,OpenAI在今年春天带了续作DALL·E 2,以其更加惊艳的效果和丰富的可玩性迅速占领了各大AI社区的头条。近年来,随着生成对抗网络(GAN)、变分自编码器(VAE)、扩散模型(Diffusion models)的出现,深度学习已向世人展现其强大的图像生成能力;加上GPT-3、BERT等NLP模型的成功,人类正逐步打破文本和图像的信息界限。在DALL·E 2中,只需输入简单的文本(prompt),它就可以生成多张1024*1024的高清图像。这些图像甚至

Wav2vec 2.0 [1],HuBERT [2] 和 WavLM [3] 等语音预训练模型,通过在多达上万小时的无标注语音数据(如 Libri-light )上的自监督学习,显著提升了自动语音识别(Automatic Speech Recognition, ASR),语音合成(Text-to-speech, TTS)和语音转换(Voice Conversation,VC)等语音下游任务的性能。然而这些模型都没有公开的中文版本,不便于应用在中文语音研究场景。 WenetSpeech [4] 是

“Making large models smaller”这是很多语言模型研究人员的学术追求,针对大模型昂贵的环境和训练成本,陈丹琦在智源大会青源学术年会上做了题为“Making large models smaller”的特邀报告。报告中重点提及了基于记忆增强的TRIME算法和基于粗细粒度联合剪枝和逐层蒸馏的CofiPruning算法。前者能够在不改变模型结构的基础上兼顾语言模型困惑度和检索速度方面的优势;而后者可以在保证下游任务准确度的同时实现更快的处理速度,具有更小的模型结构。陈丹琦 普

由于复杂的注意力机制和模型设计,大多数现有的视觉 Transformer(ViT)在现实的工业部署场景中不能像卷积神经网络(CNN)那样高效地执行。这就带来了一个问题:视觉神经网络能否像 CNN 一样快速推断并像 ViT 一样强大?近期一些工作试图设计 CNN-Transformer 混合架构来解决这个问题,但这些工作的整体性能远不能令人满意。基于此,来自字节跳动的研究者提出了一种能在现实工业场景中有效部署的下一代视觉 Transformer——Next-ViT。从延迟 / 准确性权衡的角度看,

3月27号,Stability AI的创始人兼首席执行官Emad Mostaque在一条推文中宣布,Stable Diffusion XL 现已可用于公开测试。以下是一些事项:“XL”不是这个新的AI模型的官方名称。一旦发布稳定性AI公司的官方公告,名称将会更改。与先前版本相比,图像质量有所提高与先前版本相比,图像生成速度大大加快。示例图像让我们看看新旧AI模型在结果上的差异。Prompt: Luxury sports car with aerodynamic curves, shot in a

人工智能就是一个「拼财力」的行业,如果没有高性能计算设备,别说开发基础模型,就连微调模型都做不到。但如果只靠拼硬件,单靠当前计算性能的发展速度,迟早有一天无法满足日益膨胀的需求,所以还需要配套的软件来协调统筹计算能力,这时候就需要用到「智能计算」技术。最近,来自之江实验室、中国工程院、国防科技大学、浙江大学等多达十二个国内外研究机构共同发表了一篇论文,首次对智能计算领域进行了全面的调研,涵盖了理论基础、智能与计算的技术融合、重要应用、挑战和未来前景。论文链接:https://spj.scien

译者 | 李睿审校 | 孙淑娟近年来, Transformer 机器学习模型已经成为深度学习和深度神经网络技术进步的主要亮点之一。它主要用于自然语言处理中的高级应用。谷歌正在使用它来增强其搜索引擎结果。OpenAI 使用 Transformer 创建了著名的 GPT-2和 GPT-3模型。自从2017年首次亮相以来,Transformer 架构不断发展并扩展到多种不同的变体,从语言任务扩展到其他领域。它们已被用于时间序列预测。它们是 DeepMind 的蛋白质结构预测模型 AlphaFold

说起2010年南非世界杯的最大网红,一定非「章鱼保罗」莫属!这只位于德国海洋生物中心的神奇章鱼,不仅成功预测了德国队全部七场比赛的结果,还顺利地选出了最终的总冠军西班牙队。不幸的是,保罗已经永远地离开了我们,但它的「遗产」却在人们预测足球比赛结果的尝试中持续存在。在艾伦图灵研究所(The Alan Turing Institute),随着2022年卡塔尔世界杯的持续进行,三位研究员Nick Barlow、Jack Roberts和Ryan Chan决定用一种AI算法预测今年的冠军归属。预测模型图


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
