Technology · 11 min read

The AI Detective: Can Tech­nol­ogy Give Us Back the Truth?

After a Digital Stories experiment with almost 2,000 participants showed that we can no longer tell AI-generated images and texts from real ones, it is time for the next step: could artificial intelligence itself become our salvation in this unequal battle for the truth? Radostin Cholakov, from the Rhodope village of Barutin, and his friend Delyan Boychev, both finishing high school this year and both already accomplished in the world of neural networks and computer vision, decided to find out. AI creates remarkable images today, but can it tell truth from lies and judge which picture was made by a human and which by an algorithm?

Translated from the Bulgarian original →

After the Digital Stories experiment, in which almost 2,000 people took part, showed that we are no longer capable of telling apart images and texts generated by artificial intelligence, it is time for the next step.

Could it be that… artificial intelligence itself will help us in this already unequal battle in search of the truth? Now that algorithms have become so good at generating all kinds of texts, images and, lately, video, might they turn out to be our salvation?

No, we won't speculate—we'll test it in practice, and plenty of useful and thought-provoking conclusions await us. Conclusions that come to show us that the battle for the truth, at least for now, can be won. Especially if we have the will and the strength to fight it.

Mind the Picture!

Let me introduce the two protagonists—this time not algorithms, but masters of algorithms. Radostin Cholakov, from the village of Barutin in the Rhodope Mountains, was the guest of one of the very first Digital Stories. Back then, at only 15, he talked about his work in the world of neural networks, long before artificial intelligence became the topic of the day. Since then his achievements have grown even more impressive—although he is only just starting university, he already has scientific publications and impressive projects to his name, and he was selected for Google's network of machine learning experts.

In recent years his path has often crossed with that of another talented young man of the same age. Delyan Boychev is also finishing high school this year, but he already has serious accomplishments behind him; his specialty is AI methods for working with images. The popular field known as “computer vision.”

So a few months ago the two friends got talking about the subject and decided to check: it is clear that artificial intelligence today creates remarkable images, but could it also recognize truth and lies, and judge which picture was made by a human and which by an algorithm?

Radostin Cholakov and Delyan Boychev
Radostin at MIT, where he spent six weeks in August 2023. It was during his stay there that the idea for a method of detecting generated images took shape.

The Traces Remain

“I gave you life, I will take it!” says Taras Bulba to his son Andriy, according to Gogol. And he doesn't just say it—only a few sentences later he turns his words into deeds. Algorithms have brought us to the point where we can't tell the created from the generated; could they be the very ones to lead us back the other way?

That is what Delyan and Radostin decided to find out. Delyan knows image processing well, while Radostin is going ever deeper into the mathematical foundations of machine learning and its software applications.

And so the two of them built a neural network trained for this task. Their venture doesn't even have a name yet, but it turned out to be impressively accurate at achieving its goal.

Who Watches the Watchmen?

So, the Digital Stories experiment included 30 texts and images. Until recently, when large language models weren't yet large enough, there were apps you could feed a text to and determine with a fairly high degree of accuracy whether it had been written or generated.

Alas, that technological battle is already lost, says Radostin. “At first, texts were much easier to tell apart than images. Up to open-source models like GPT-2, it was easy to detect. For every next word the neural network gave a degree of probability, and if that probability is high and the word is in the text, then models of that kind would have generated it. There are words that are very unpredictable for a language model and others that are very predictable.”

Of course, there are some rough clues that can hint a text is generated. If a person has given too general a prompt, algorithms like ChatGPT often produce rather general content. They also have their favorite words, which we otherwise wouldn't use quite so often. And we mustn't forget hallucinations, of course.

“I recently came across an analysis suggesting that in scientific papers published in various journals over the past year there are many indications that authors have been using ChatGPT a lot more. Certain words like ‘innovative,’ which it uses often, have shown a huge increase since last year. But these are indirect indicators; nothing stops people from having started to use such words more often themselves.”

Radostin Cholakov and Delyan Boychev
Delyan presents the project at the Bulgarian Academy of Sciences

Teaching to the Test

“Once a test becomes a test, it's no longer a good test,” Radostin smiles. “Companies learn how to pass it, which doesn't necessarily mean the model has become all that much better.”

The main reason algorithms today can't recognize generated text is purely mathematical. For large language models, words are split into “pieces” called “tokens” (the direct Bulgarian translation, жетон (zheton, a token like a coin or a chip), never caught on in this context). “Each word is either there or it isn't. Whereas in photos one pixel can be a little darker or lighter, and when two neighboring pixels have certain specific values, you can find some kind of pattern. Even a small photo has far more data to draw conclusions from than words, which are just points in a big dictionary.”

So, evidently, all we have left for telling generated text apart is… common sense. With photos, however, it turns out to be a different story!

Let's skip ahead to the result. The average score of almost 2,000 people in the Digital Stories experiment on images was a little over 8 out of 16. ChatGPT, when asked to take the experiment, also got exactly 8 of the pictures right. Meanwhile, the algorithm built by today's guests managed… a whole 14 out of 16 images! Better than every single one of the nearly 2,000 participants.

It got only two images wrong, and for both it showed a fairly high percentage of hesitation. What's more, these turned out to be two of the images participants got wrong most often, too. The Hieronymus Bosch “painting” was generated by Midjourney. But in its composition, and in some of its elements, it is extraordinarily reminiscent of the very real central panel of The Garden of Earthly Delights, one of the artist's most famous works. And the illustration, again generated by Midjourney, misled not only the algorithm but also three quarters of the people.

In other words, the two young men's platform turned out to be remarkably good at solving the task it was set!

Radostin Cholakov and Delyan Boychev
This photo is not generated, the algorithm was convinced—and it turned out to be right.

The Devil in the Details

But how is this possible? And could it become a long-term solution that helps us distinguish generated images?

The idea for this particular algorithm is Radostin's, while Delyan contributes his experience in image processing.

They use contrastive learning—a way of training a neural network to measure the similarity of the data it is given. In this case, the model takes in photos and returns a vector—a long series of numbers on the basis of which the images are compared.

“So if you run two photos through the model, it returns two vectors. You can tell it that if both come from fake photos, it should bring them closer together, and if one is real, it should push them apart. Gradually the algorithm learns to look for what distinguishes them and starts making predictions about the next pictures it is given,” Radostin explains.

Under the Microscope

How does this happen when, to the human eye, they are completely indistinguishable? It relies on the way the algorithms themselves work. It turns out that whether we are talking about DALL-E, Midjourney or Stable Diffusion, the generated images carry a “fingerprint” noticeable to an algorithm. A fingerprint invisible to the naked eye, but clear enough for the neural network created by Radostin and Delyan.

To train it, they collected around 200,000 images, half of them generated. The idea was to have an equal mix of different kinds of photographs, portraits and illustrations, so that the algorithm would recognize generated pictures well enough regardless of what they actually show.

Yes, a person who has used one of the three platforms for a long time can afterwards recognize images generated with it considerably more successfully. But… only until the next version of the algorithm, or until they come across one of the others.

Radostin Cholakov and Delyan Boychev
This photo is generated, the algorithm said—and once again it was right.

The Wheat from the Chaff

One of the most noticeable “fingerprints” lies in the parts of the image that are relatively uniform in color. “Very often the data leads us to places where there's a white or some other background. If you have something of a single color in a real photo, the pixels in that area have very close values, whereas that isn't the case in generated ones.

“Some of the pixels aren't exactly the same color because of the way the model works. And that turned out to be precisely the fingerprint by which our model tells them apart,” Radostin explains.

Then the two decided to make things harder for the model—to test it on images that had been compressed or downscaled. Yet it went on distinguishing the generated ones with quite high accuracy.

Cat, Mouse and Keyboard

Just how good is the algorithm? I test it again. I choose 15 images (see them here) and quiz it, without its creators knowing the correct answers…

And it scores 100 percent! It guesses whether the pictures are generated without getting a single one wrong!

So then… it's easy? Social networks or search engines could use similar algorithms to flag generated content?

Alas, no. The solution looks more like a snapshot of the moment. In the eternal battle of cops and robbers, which has carried on online, every step one side takes gives strength and ideas to the other. As already mentioned, a test that is labeled a test can be solved fairly easily by the next generation of algorithms, specially trained to do so. One extra filter on the generated images could easily fool the algorithm.

And so it's time to move on to the next step, which, unexpectedly… brings a dose of optimism.

Hieronymus Bosch
Although it truly looks indistinguishable from the style of Hieronymus Bosch, this painting, too, was created by algorithms. It fooled a whole 88.7 percent of those who took part in the Digital Stories experiment.

Don't Go Too Deep

Radostin and Delyan have tested their algorithm on stills from the much-hyped Sora model—the platform OpenAI promises will generate video as successfully as the three projects mentioned handle photos today. They have also tested it on deepfake videos.

Here, too, the model is flawless. According to my two guests, there is good reason to believe that algorithms will be able to assess the authenticity of video for quite a few steps to come. If the battle on this front is lost for texts, and the one for images is still being fought, then generated video will remain recognizable at least for the foreseeable future. Because there the algorithm leaves its “fingerprints” not only in how it creates the images, but also in the sequence. If, from the Lumière brothers all the way to Sora, video remains a series of pictures, then both the pictures themselves and their sequence can be assessed—how smooth, how natural the transitions from frame to frame are.

And so it goes… until the next step in the development of the algorithms.

Stamped, Sealed, Watermarked

And beyond that? The models that can tell the created from the generated will evolve. Then the generators will evolve to outpace them.

“Maybe we'll reach a point where the images can't be told apart,” says Delyan. “The models themselves can simply change the distribution of values. But then, might we still be able to tell them apart by their specific style? Look, images created with Stable Diffusion have repeating elements when you zoom in; a purely visual solution can be found.”

“What we're finding right now may be gone after a few iterations of these models,” Radostin agrees. “Commercial models will probably soon start inserting their own fingerprint.”

They will leave a watermark by which we can distinguish the generated (let me say it again: we're talking about images; for text this is practically impossible! And… so what? In recent years open-source models have been rapidly catching up with the companies' models. And even if OpenAI and Google decide (or are required) to mark generated images, what will stop any enthusiast with minimal technical skills from getting an almost equally capable model running on their own computer?

Radostin Cholakov and Delyan Boychev
Radostin and Delyan at the Perot Museum in Dallas, Texas, where the two took part in the world's largest international science fair and competition for high school students in May 2023.

Don't Count Your Pixels Before They Hatch

Radostin and Delyan will soon have their scientific paper ready, telling the story of the venture. And the big question remains… do we need the truth? The algorithms that can generate and create are advancing… and along with all that, they make it possible to manipulate us or lie to us. Those on the other side are advancing too—the ones that recognize, distinguish, guarantee.

Yes, the former will generate more profit and demand because of the way technology moves forward.

And for us, the biggest and most important question remains open.

How much does the truth matter to us?

Are we ready to fight for it?

Almost there…
If you liked the story, support the project. The site has no ads.
Support

Next story

All stories →