If you’ve ever regretted miscalculating your coffee consumption, now you can let AI be your guide. Researchers from two U.S. military organizations developed an algorithm to predict alertness levels based on caffeine intake amount and timing. Scientists from the Henry M. Jackson Foundation for the Advancement of Military Medicine and the Walter Reed Army Institute of Research Behavioral Biology Branch published the results of their study in the Sleep Research Society‘s journal Sleep.

The researchers started with the assumption that people need to consume the correct amount of caffeine at the right time in order for the chemical to be most effective. The military used 2B-Alert Web 2.0, an open-source web tool that the group developed earlier. With the web tool, users input their desired peak alertness periods, their minimal acceptable alertness level, and the maximum amount of caffeine they can tolerate daily. The algorithm returns the optimal caffeine amounts and timing for the user to reach peak alertness within the provided constraints. The AI-powered analysis also produces a psychomotor vigilance test alertness prediction given the user input and caffeine guidance.

In controlled testing to compare 2B-Alert Web 2.0 with a range of sleep-deprivation and work scenarios that follow U.S. Army guidelines, the military scientists reported an average 40% improvement with the web tool. The improvements included 40% enhanced alertness or 40% less caffeine consumption, but not both.

The 2B-Alert Web 2.0 is openly available to anyone who provides their name, email, and affiliation. The military views the study and the web tool as an effective strategy to maximize troop alertness without overdoing caffeine consumption: an advantage many of us would appreciate.