How to Build AI Lipsync, Part 5 (Second Half): Implementing Transformers and Making Practical Technology Choices
Why can't the Transformer that powers GPT simply be dropped into lipsync? We unpack three challenges — data, computation, and overfitting — how to choose between LSTMs and Transformers in practice, and transfer learning as a third option, in a dialogue between Professor Quo and Manabu.
Hello!
Our exhibit at CEATEC 2025 wrapped up successfully, and several weeks have already flown by since those whirlwind four days.
Makuhari Messe was as energetic as ever, but before we knew it autumn has deepened, and the mornings and evenings have turned noticeably cooler.
As we sort through the valuable feedback we received from so many visitors, we are reminded once again of just how deep this technology goes. At our booth, visitors watched our characters speak naturally and delighted us with reactions like "Is it really moving in sync with the audio?" and "How can it look this natural?"
This series is the behind-the-scenes story of the technology that made it possible.
In the first half, we took a detailed look at the Transformer's groundbreaking Multi-Head Self-Attention mechanism. We saw how eight "experts" analyze the relationships between phonemes from different perspectives, and how the clever division of roles among Query, Key, and Value lets every phoneme interact with every other phoneme simultaneously. In theory, this appears to completely solve the LSTM's long-range dependency problem.
In practice, however, applying Transformers to the lipsync task runs into unexpected walls. Why is it that the Transformer, so successful in large language models like GPT and BERT, cannot simply be dropped into lipsync?
In this second half, we first explain the role of the Feed-Forward layer and clarify the structural differences between LSTMs and Transformers. We then dig into three serious challenges that Transformers face. Why do Transformers require enormous amounts of training data when LSTMs can learn from orders of magnitude fewer samples? How serious is the O(n²) problem, where computation explodes as inputs grow longer? And what is the overfitting trap that comes with so much modeling freedom?
With these challenges understood, we introduce the hybrid approach as a realistic solution. By combining the efficiency of LSTMs with the expressive power of Transformers, we explore how to achieve high-quality lipsync even with limited resources. We also touch on the next challenge — extending the system to emotional expression — and offer concrete guidance for technology choices in real product development.
Let's dig into the practical insights that bridge the gap between theory and reality.
"How to Build AI Lipsync" series
Previous articles
- Part 1: Phonemes and wav2vec
- Part 2: AI-Based Drift Correction
- Part 3: Learning Mouth-Shape Parameters from wav2vec Features
- Part 4: Training LSTMs, Their Limits, and the Road to Transformers
- Part 5 (First Half): Implementing Transformers and Making Practical Technology Choices
Part 5, Second Half
1.2 The Feed-Forward Layer: Feature Transformation
Yes, we are jumping straight into Section 1.2 — this article picks up exactly where the first half left off, so please bear with us ^^;
After the Self-Attention layer comes the Feed-Forward Network (FFN). This is a two-layer fully connected network that applies the same transformation at every position: it expands from 512 to 2,048 dimensions, applies a ReLU activation, and then compresses back down to 512 dimensions.
The role of this layer is to transform the contextual information gathered by Self-Attention in a more expressive space. The expand-and-compress process lets the model learn complex nonlinear transformations.
1.3 Structural Differences from the LSTM Architecture
The most fundamental difference between Transformers and LSTMs lies in how information flows. In an LSTM, information flows sequentially in one direction (or two, if bidirectional), whereas in a Transformer every position is directly connected to every other position.

These structural differences also affect how the models learn. Because the LSTM carries a strong inductive bias — "time series should be processed in order" — it tends to learn well even from small datasets. The Transformer, with fewer built-in constraints, can learn more flexibly, but it needs correspondingly more data.
Transformers also have the advantage of stacking deep layers more easily. Because every layer can see the entire sequence, even deep layers retain global information, which makes it possible to learn more complex relationships between phonemes.
2. The Transformer's Pitfalls: The Price of Freedom
2.1 Why So Much Data Is Needed
The Transformer's biggest challenge is that its very flexibility demands enormous amounts of training data. The root cause of the Transformer's data hunger lies precisely in how flexible it is.
The LSTM comes with a strong built-in assumption (inductive bias): time-series data is processed in order. It is as if the model starts out already facing the right direction. The Transformer has almost no such assumptions — it must learn entirely from data which positions should be related to which.
2.2 The Explosion in Computation (the O(n²) Problem)
The Transformer's other major challenge is that its computation grows with the square of the input length. This stems from the essential nature of Self-Attention: it computes the relationship between every pair of positions.
For example, to process an utterance of 50 phonemes, an LSTM needs 50 sequential steps, while a Transformer needs 50 × 50 = 2,500 attention computations. At 100 phonemes that becomes 10,000; at 200 phonemes, 40,000 — the cost climbs steeply.
In real applications, this computational cost translates directly into memory usage. The memory needed to hold the attention matrix also grows with the square of the input length, so processing long audio requires chunked processing or memory-efficient implementations.
2.3 Why Overfitting Comes So Easily
The Transformer's expressive power is also a double-edged sword: it raises the risk of "overfitting" — fitting the training data too closely. The problem is especially serious when training on limited data.
When overfitting occurs, the model performs perfectly on the training data but fails on new data. For example, it may over-learn the quirks of one particular speaker and produce unnatural mouth movements for everyone else.
To prevent overfitting*, regularization techniques such as Dropout, weight decay, and early stopping must be used appropriately. Data augmentation also matters: generating diverse variations from limited data improves the model's ability to generalize.
*Reference: one metric for measuring overfitting and generalization performance is the mean squared error (MSE). The article below, written by one of our team members, explains it clearly — we recommend it as further reading.

The fundamental solution, however, is still to prepare a sufficient amount of training data. As the success of large language models shows, Transformers deliver astonishing performance when given enough data. The question is whether building such a large-scale dataset is realistic for the lipsync task. For a venture or startup like ours in particular, building such datasets while securing all the necessary permissions is, frankly, a high hurdle.
Given these challenges, it becomes clear that while the Transformer is certainly powerful, it is not the optimal choice in every situation.
In the next chapter, we therefore look at a more practical approach that combines the strengths of LSTMs and Transformers.
3. Practical Choices: When to Use LSTMs and When to Use Transformers
3.1 Understanding Each Model's Strengths
As we have seen, LSTMs and Transformers each have clear strengths and weaknesses. What matters is not which one is superior, but understanding which to choose in which situation.
3.2 Choosing Based on Data Volume
In real development settings, the amount of available data is often the first deciding factor.
With small datasets, the LSTM has an overwhelming advantage.
Because the LSTM carries the strong inductive bias that time-series data should be processed in order, it can learn fundamental patterns efficiently even from little data.
It is as if the correct direction is built in from the start, so the model reaches its destination with less trial and error. Its simple structure also keeps the risk of overfitting low. When you need stable performance from limited data, the LSTM is a dependable choice.
When large amounts of data are available, on the other hand, the Transformer shows its true worth. Given sufficient data, it learns the complex relationships between phonemes and produces more natural, more varied expression.
3.3 Choosing Based on Real-Time Requirements
Next, let's consider LSTMs and Transformers from the standpoint of real-time performance.
Where real-time processing is required, the LSTM's characteristics become a major advantage. The LSTM supports streaming: it can generate mouth shapes instantly as audio arrives. It can achieve extremely low latency — a few tens of milliseconds — making it ideal for live streaming, video conferencing, real-time avatars, and other applications that demand immediacy. Users get natural interaction without any sense of lag.
By contrast, when batch processing is possible, the Transformer's strengths can be used to the fullest. In video production or animation work that processes pre-recorded audio, quality can take priority over processing time. Because the Transformer surveys the entire audio at once, it generates more natural, more expressive lipsync that fully accounts for surrounding context. In workflows where pre-rendering is possible, this difference in quality can decisively shape the final product.

3.4 Compute Resources and Cost
Development and operating costs are another important criterion that cannot be ignored when choosing a technology.
In resource-constrained environments, the LSTM is often the realistic choice. Training typically finishes in a few hours to a day, and the model is relatively compact. The LSTM does have an important limitation, however: because of its sequential nature, batch-parallel processing on GPUs is difficult. Even when trying to process multiple audio streams at once, each time step must be processed in order, so the GPU's parallel computing power cannot be fully exploited.
For example, the latest enterprise GPUs such as the H100 offer MIG (Multi-Instance GPU) technology, which allows a single physical GPU to be treated as up to seven independent GPU instances.
This makes it possible to run multiple LSTM models in a quasi-parallel fashion, and with a well-designed inference server you can handle multiple requests efficiently. But this kind of approach is quite complex: you need mechanisms to manage resource allocation across instances, route requests appropriately, and use memory efficiently.
Moreover, since each LSTM instance can ultimately handle only a single stream, it is hard to say the GPU's compute is being fully utilized compared with the Transformer's true parallel batch processing. And if you have the budget to buy H100-class GPUs by the rack, one has to wonder whether you would be better off putting that muscle behind a data-hungry, heavily trained Transformer in the first place.
As for the Transformer — at the risk of repeating Section 3.3 — it is designed from the ground up for parallelism, so a single model instance can efficiently batch-process multiple inputs. The Self-Attention mechanism processes every sample in the batch simultaneously, making full use of the GPU's tensor cores. The efficiency gap is especially pronounced at large batch sizes.
3.5 Making the Call in Practice
That said, as a practical matter, how should you choose between an LSTM and a Transformer?
[Data volume]
The first thing to check is how much data you have available (the size of your dataset). As noted earlier, without sufficient data it is difficult to get good results from a Transformer, no matter how favorable the other conditions are.
[Real-time requirements]
Next, consider your real-time requirements. Where millisecond-level latency matters, the LSTM may be the only realistic option. (We noted earlier that LSTMs struggle with concurrency, but in certain applications — say, a guide avatar at a theme park or public facility, where concurrency demands are modest but real-time response is essential — they are genuinely useful, and LSTM-based models are in fact deployed in exactly these settings.)
[Compute resources]
Then factor in your compute constraints. If GPUs are not always available, or operating costs are tightly capped, choosing the LSTM is the sensible move.
[Development timeline and budget]
Finally, weigh the project's goals and development timeline as a whole. Only when you are pursuing the highest quality and have ample development time should you consider adopting a Transformer.
3.6 Choosing with the Future in Mind

Many success stories follow a staged evolution path: start with an LSTM to build a minimum viable product and bring it to market.
Then collect user feedback, accumulate data, and strengthen the technical foundation as the service grows. By considering a migration to Transformers — or a hybrid approach that skillfully combines the two — as the need arises, you can raise quality step by step while keeping risk to a minimum.
This kind of flexible approach lets you pursue sustainable development while balancing technical ideals against real-world constraints.
3.7 A Third Option: Transfer Learning as a Breakthrough
We have now walked through the trade-offs between LSTMs and Transformers, but there is
in fact one more important option.
It is called transfer learning.

With transfer learning, you can directly leverage the knowledge held by large pre-trained models.
In the field of speech recognition, there are models trained on millions of hours of audio. These models already possess a deep understanding of speech: phoneme discrimination, speaker characteristics, intonation patterns, and more. By transferring this knowledge to lipsync, we can obtain high-quality results even from small datasets.
What is especially wonderful is the abundance of commercially usable open-source base models. State-of-the-art speech recognition models are published under permissive licenses. These models were developed by research institutions and large companies at enormous cost, yet anyone can use them. Being able to build on these research achievements is something we are deeply grateful for.
Learning the mapping between phonemes and mouth shapes does indeed require motion-capture data (of mouth shapes).
Here too, though, the benefits of transfer learning are substantial: the amount of data required drops dramatically. Compared with training from scratch, practical performance can be reached with orders of magnitude less data — drawing, of course, on every technique we have covered in this series. Advances in motion-capture technology are also helping. The latest systems can record precise mouth movements in a short time; what once required markers attached around the mouth can now be done markerless.
Moreover, with proper planning, collecting data that covers the basic phoneme set can be done very efficiently. Working with professional voice actors and narrators makes it possible to gather high-quality data in a short period. Building the dataset does, of course, require contracts and the necessary permissions from these collaborators — but reducing the scale from tens of thousands of people to a few hundred puts this kind of effort within realistic reach even for a venture or startup.
Furthermore, data augmentation techniques let you generate diverse variations from limited recordings. By combining methods such as varying speech rate, adjusting pitch, and adding environmental noise, you can substantially increase your effective data volume. It is like the craft of a creative chef who turns a few ingredients into a rich and varied menu.
Transfer learning frees you from the either-or choice between the LSTM's efficiency and the Transformer's expressive power. You can use a powerful Transformer-based model even with little data, and the implementation is relatively simple: in many cases, existing frameworks and libraries let you implement transfer learning in just a few lines of code.
That said, transfer learning is no panacea. There is much to consider: the fit between the base model and the target task, the fine-tuning method, the quality of the data, and more. That, in fact, is the "secret sauce" — but used well, these ingredients become a powerful weapon for building a competitive lipsync system even with limited resources.
In this way, transfer learning offers a realistic and flexible third option that goes beyond the simple dichotomy of "little data, so LSTM" versus "plenty of data, so Transformer."

4. Summary and a Look Ahead
This Time: From Theory to Practice
In this two-part article, we began in the first half with the Transformer's concrete network design and its implementation challenges, and in this second half examined in detail how to choose between LSTMs and Transformers in practice.
The Transformer's groundbreaking Self-Attention mechanism made the long-range dependency problem theoretically solvable. But it also became clear that the price is a heavy demand for data and compute. In real product development, these trade-offs must be weighed carefully.
We also introduced a third option: transfer learning. By leveraging commercially usable open-source models, you can build powerful Transformer-based models even with little data. The path is open to repurposing knowledge cultivated in speech recognition and building a practical lipsync system with minimal motion-capture data.
In real product development, a staged approach works well: prototype quickly with an LSTM, accumulate data while watching how the market responds, and consider moving to Transformers or transfer learning as needed. With this kind of flexible strategy, we believe you can grow a product while balancing technical ideals against real-world constraints.
Next Time: The Overlooked Challenge of the "Final Moment"
Next time, we will explain in detail why this unnatural behavior occurs at the end of speech and the technical mechanisms behind it. Model uncertainty, ambiguity in training data, information loss from discretization — fundamental challenges of AI technology are all concentrated in this one small "final moment."
We will also introduce practical solutions to the problem, comparing a range of approaches from simple post-processing to fundamental techniques built on the latest AI methods.
Now that you have the theory, let's explore together the real-world challenges of product development and how to solve them. It may look like a small problem, but tackling it is what leads to more natural, more convincing virtual characters.
See you next time!
