← Latest papers
🤖 machine learning

Optimizing Transformer Neural Network for Real-Time Outlier Detection on FPGAs

This paper proposes and demonstrates an optimized Transformer neural network architecture implemented on a PYNQ-Z2 FPGA to enable efficient, low-latency real-time outlier detection in financial time series data.

Original authors: Ilia Sobakinskikh, Paul Alexander Bilokon

Published 2026-07-28
📖 6 min read🧠 Deep dive

Original authors: Ilia Sobakinskikh, Paul Alexander Bilokon

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a detective trying to spot a thief in a crowded city. The city is a river of numbers, constantly flowing with the prices of stocks, the temperature of servers, or the number of people in a taxi line. Most of the time, this river flows smoothly, but occasionally, a giant rock—a "glitch" or an "outlier"—jumps into the stream, causing a splash that could ruin everything downstream. In the world of finance and data science, these splashes are dangerous; they can trick computers into making bad decisions. For a long time, catching these splashes was slow, like trying to find a needle in a haystack by hand. But recently, scientists have built a super-smart detective called a "Transformer." Think of a Transformer as a genius librarian who can read a million books at once and instantly remember how a story from page one connects to page one thousand. This librarian is amazing at spotting weird patterns, but there's a catch: the librarian is so heavy and slow that they can't run fast enough to catch the thief in real-time.

Enter the FPGA, which is like a custom-built, super-fast race car engine that you can reconfigure on the fly. The big question this paper tackles is: Can we take our genius, heavy librarian (the Transformer) and teach them to drive this race car (the FPGA) so they can spot the bad data instantly? The authors, Ilia Sobakinskikh and Paul Alexander Bilokon, set out to see if they could shrink this giant brain down to fit inside a small, reconfigurable chip without losing its smarts. They wanted to prove that you don't need a massive supercomputer to find these financial glitches; you can do it on a tiny board, fast enough to stop a disaster before it happens.

The Race to Catch the Glitch

The authors started by looking at the problem of "anomaly detection." In simple terms, this is just finding the weird numbers in a list. They focused on "point anomalies," which are like sudden spikes in a stock price—think of a stock jumping from $100 to $101 in a split second when it shouldn't. To catch these, they used a specific type of AI called a Transformer. Unlike older AI models that read data one step at a time (like reading a book word by word), Transformers look at the whole picture at once, understanding how a price today relates to a price from weeks ago.

However, running these Transformers is usually slow and expensive. The authors decided to try running them on an FPGA, specifically a board called the PYNQ-Z2. To make this work, they had to be very clever with how they programmed the chip. They treated the math inside the Transformer like a factory assembly line. Instead of waiting for one calculation to finish before starting the next, they used a technique called "pipelining." Imagine a car wash where the first car is still being soaped up while the second car is already under the rinse cycle; this keeps the line moving fast. They also used "unrolling," which is like having ten workers do the same task at the exact same time instead of one worker doing it ten times in a row.

The Results: Speed vs. Smarts

The team tested two versions of their AI detective. The first was the "Vanilla Transformer," the standard, heavy version. The second was a "Linear Transformer," a lighter, faster version that skips some of the heavy math. They ran these models on the FPGA and compared them to a standard computer processor (CPU).

The results were a tale of two different trade-offs. The standard Transformer, when optimized for the FPGA, became incredibly fast. It could process data in just 37.14 microseconds (that's 0.000037 seconds!). Without these special optimizations, the same task took 347.45 microseconds, which is ten times slower. The Linear Transformer was even faster, clocking in at 29.86 microseconds.

But speed came with a price tag. To get that speed, the chip had to work much harder. The optimized Transformer used 90% of the available "LUTs" (the tiny logic switches inside the chip) and 30% of the "FFs" (memory bits), whereas the slow, unoptimized version only used 10% and 2% respectively. It's like upgrading a bicycle to a motorcycle: you go much faster, but you need a much bigger engine and more fuel.

Did the Detective Still Get the Job Done?

Speed is great, but is the detective still smart? The authors tested their models on real-world data, including New York City taxi demand, server performance logs, and high-frequency stock prices. They compared their AI against a simple "Linear Regression" model, which is like a detective who only looks at the most recent number and guesses based on that.

The results showed that the Transformers were generally much better at spotting the anomalies than the simple model. On the KPI dataset (server logs), the standard Transformer achieved an accuracy of 0.98 on the training data and 0.97 on the validation data, with an F1 score (a balance of catching bad stuff and not crying wolf) of 0.71 and 0.76 respectively. The Linear Transformer was slightly less accurate but still strong. However, on the stock market data (FI2010), the models struggled a bit more, with F1 scores dropping to 0.06 and 0.09, suggesting that while they are fast, they aren't perfect at spotting every single glitch in every type of data.

Interestingly, the authors found that some features usually considered essential for Transformers, like "positional encoding" (a way to tell the AI the order of the numbers), actually made the training unstable and worse in their specific setup. They had to turn these features off to get the models to work properly on the chip.

The Bottom Line

This paper doesn't claim to have solved the mystery of anomaly detection forever. Instead, it suggests that we can successfully shrink these powerful AI models down to fit on small, fast chips. The authors showed that by using clever programming tricks like pipelining and unrolling, you can make a Transformer run 10 times faster on an FPGA. While this speed comes with a heavy cost in terms of the chip's resources, it proves that real-time, high-speed anomaly detection is possible without needing a massive data center. It's a proof of concept that the future of catching financial glitches might not be in a giant server room, but in a tiny, reconfigurable chip racing through the data at lightning speed.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →