This algorithm knows about recreational drugs that don’t even exist yet

The important question now is, what's next?
Dime bag of bath salts on a black background to represent synthetic or designer drugs
A new algorithm by computer scientists and biologists can detect and identify new designer drugs almost instantly, but may have a tougher time with slight variations of synthetic substances already on the market. Deposit Photos

Doug Johnson is a Canadian writer, editor, and journalist. This story originally featured on Undark.

In recent years, underground chemists have increasingly made small chemical tweaks on known recreational drugs to skirt laws, creating novel designer versions. Instead of cannabis, for instance, these chemists could offer up XLR-11, or instead of PCP they might have 3-MeO-PCE.

Novel designer drugs, also called research chemicals or legal highs, still produce physiological and psychological effects, though experts say that they can come with a slew of risks. Synthetic opioids such as fentanyl, for instance, are increasingly cited among the number of opioid-related deaths in the United States, which reached more than 75,000 this year. According to the Centers for Disease Control and Prevention, synthetic cannabinoids can cause heart attacks, kidney failure, and, in some cases, death. The newer synthetic drugs are often poorly studied, too, and among the myriad substances available, many come with negative health impacts beyond those of their naturally occurring counterparts.

While illicit drug chemists work on new formulas, governments around the world try to regulate and ban the drugs quickly after they appear. Many countries use similarities in the chemical structure of drugs—like between fentanyl and its analogs—to ban novel psychoactive substances, or NPS. However, the approach varies by jurisdiction. For instance, in 2017, the Australian state of Victoria banned all psychoactive compounds with a few exceptions, including alcohol, tobacco, and medicinal cannabis. Other governments scramble to track the output of a global network of illicit labs.

“The current situation we’re in is more the whack-a-mole approach,” says David Wishart, a computer scientist and biologist at the University of Alberta.

To help streamline the work, Wishart and his colleagues used a type of artificial intelligence called deep learning to create an algorithm that identifies potential designer drugs that may not yet even exist. The millions of chemicals identified by the algorithm—dubbed DarkNPS—could help governments stay one step ahead of their production, says Wishart. He and a team of other researchers published the work in Nature Machine Intelligence in November.

Wishart says that the algorithm could help law enforcement and forensic chemists identify novel psychoactive substances—a process that could otherwise take up to several months. DarkNPS may also highlight beneficial new compounds for clinical use. And, according to Wishart, there is another advantage: Governments could go through the cache of hypothetical drugs DarkNPS developed and ban them, even before anyone actually produces or distributes them.

According to a press release, some agencies are already using the algorithm, including the U.S. Drug Enforcement Administration, the United Nations Office of Drugs and Crime, the European Monitoring Center for Drugs and Drug Addiction (EMCDDA), and the Federal Criminal Police Office of Germany. (In response to questions from Undark, Greg Planchuelo, the database management development officer for the EMCDDA, said the agency was not using the approach, while the other organizations did not reply to requests for comment.)

But critics argue the proactive criminalization of drugs would do little to address the main drivers behind overdose deaths. Moreover, criminalization has historically been socially damaging: The war on drugs led by the US government, for example, has roots in racism, and still overwhelmingly targets marginalized groups.

And although the algorithm may be able to capture drugs that are relatively similar to their predecessors, it may struggle to predict drugs with radically different chemical structures, says Alex Krotulski, associate director at the Center for Forensic Science Research & Education and manager of the organization’s NPS Discovery program. “In a practical sense,” he says, “nobody ever knows what’s coming next.”

Currently, the standard approach for identifying an unknown drug is mass spectrometry, a method that, in short, weighs the components of a compound, in order to determine its molecular structure. But this technique requires a reference to compare the results against—a reference that might be missing when dealing with a wholly new substance, but that could be sitting on DarkNPS’ list.

DarkNPS produced a list of 8.9 million compounds that could be created by altering existing drugs. To generate this huge number, Wishart and his colleagues deployed a neural network, a kind of machine learning that is loosely modeled on the human brain, and which is often used for analyzing human languages.

The effort began in 2020, when researchers from the Section of Forensic Chemistry at the University of Copenhagen approached the team behind DarkNPS. The Copenhagen team maintains a database of known designer drugs called HighResNPS, a resource that medical staff, law enforcement, and forensic chemists can use to screen for NPS by providing references for mass spectrometry testing.

The DarkNPS team trained their algorithm using HighResNPS. When the work began in February 2021, the database had more than 1,700 entries of existing drugs sourced from around the world. While that’s a relatively small dataset, the team was able to trick the algorithm into thinking it was looking at something larger. The algorithm then combined the HighResNPS data with the predictable rules of chemistry to draft a list of possible new combinations.

“As soon as a drug hits the market, DarkNPS could potentially identify the compounds in a matter of minutes.”

David Wishart, creator of the algorithm

According to Michael Skinnider, a co-author of the paper and a medical student at the University of British Columbia, DarkNPS works a bit like a human brain comprehending a sentence, but the algorithm uses atoms and chemical bonds rather than words and grammar. “If I tell you ‘The clouds are up in the’— you know the next word is probably going to be ‘sky.’ It’s not going to be ‘phone,’” Skinnider says.

The team then compared their results against 189 new entries on HighResNPS, which had been added after the initial run of DarkNPS, and found that 93 percent of the new entries were among DarkNPS’s predictions.

Since reference data might not exist for very new drugs, mass spectrometry isn’t always a good option, as identifying such a substance can potentially take weeks or even months of work, several sources told Undark. DarkNPS could provide this reference for a staggering number of drugs. “As soon as a drug hits the market—instead of three months, six months of arduous chemistry—they could potentially identify the compounds in a matter of minutes,” Wishart says.

DarkNPS has some limitations, however. For example, while it may make accurate predictions, it can’t provide any information about the physiological or psychological effects of the drugs. The algorithm could also effectively give illicit chemists a roadmap to new designer drugs. As such, DarkNPS is sitting in the hands of the NPS Data Hub—a joint effort between the National Institute of Standards and Technology, the U.S. DEA, and the Federal Criminal Police Office of Germany—which acts as a database to aid in the identification of new drugs. It is not available to the public.

Then there is the issue of the drugs DarkNPS will miss. According to Krotulski, there are two different ways NPS evolve on the market. The first happens with minor modifications: the shift from fentanyl to, say, carfentanil. Both are potent opioids, and quite chemically similar.

But there are also larger changes, Krotulski says. For instance, another powerful synthetic opioid called isotonitazene, which has shown up in countries including the United Kingdom and Canada, has a structure distinct from fentanyl. It would be hard to predict these larger transitions with a predictive tool like DarkNPS, Krotulski said.

Some labs might not need DarkNPS’s list. According to Planchuelo, many well-resourced labs, including some in the EMCDDA, use a different technique called nuclear magnetic resonance testing, which doesn’t require reference material the same way that mass spectrometry does. Still, Planchuelo added, smaller operations, hospitals in less developed areas, and other organizations could still find the algorithm useful. “I believe this is a game-changer for the majority of labs that might not have the resources we do,” he said.

There is also debate about whether or not banning drugs is a good mechanism to reduce overdoses and other harms. According to Alex Stevens, a professor of criminal justice at the University of Kent, criminalization hasn’t deterred people from using drugs. Further, the criminalization of drugs disproportionately impacts people from marginalized communities. According to an article by Ann Fordham, the International Drug Policy Consortium’s executive director, Black people in the US are incarcerated five times more than White people, and half of these sentences are related to drugs.

In a way, though, governments’ banning existing drugs may also incentivize the creation of NPS. “It’s not dealing with the fundamental problem,” Stevens says, “which is that people can’t get legal access to the drugs they actually want to use, and so will seek alternatives.”

While DarkNPS could help facilitate wide-scale illicit drug bans, some say the approach could hinder the development of new medicines by making it harder for researchers to study drugs that have potential medical applications. “I would be surprised if there aren’t quite a lot of substances on that list that are already being investigated for their medical benefits,” Stevens says.

There is also debate about whether or not banning drugs is a good mechanism to reduce overdoses and other homes.

This has happened in the past. In 2016, for instance, the U.K. banned a class of drugs called third-generation synthetic cannabinoids. Researchers were quick to argue that this class-wide ban would cover substances that already exist as medicines, such as the anti-inflammatory drug indomethacin. After the drugs were added to the Schedule 1 classification — a particularly strict class in the U.K.—pharmaceutical researchers looking at the compounds needed a Home Office license, which can slow or even halt research, as it is prohibitive both in terms of money and time. Ultimately, the U.K. amended the ruling to make it easier for researchers to continue their work.

Both Skinnider and Wishart said that it’s unlikely that DarkNPS will lead to the blanket banning of novel psychoactive substances, even if it might help stop illegal drugs. In part, this is because the algorithm is capable of identifying some useful compounds, too. DarkNPS could be used to find psychoactive drugs with medical properties, like the next stimulant for attention deficit disorder, or a replacement for methadone in treating opioid use disorder. And with the right training, the algorithm could help find the next generation of anti-inflammatory drugs, steroids, or antihistamines.

“It doesn’t get bored. It can start thinking creatively,” Wishart says of the algorithm. “It doesn’t need doses of coffee or a good night’s sleep. It just predicts.”