In late August, Hercules Shepherd Jr, dressed in an orange jumpsuit, walked up to the dock in a Cleveland courtroom. Two nights earlier, an officer had arrested him at a traffic stop and found a small bag of cocaine, and Shepherd was about to be arraigned.

Read more UK surveillance law used to spy on calls, texts and internet ruled 'unlawful'

Not long ago, the presiding judge would have decided Shepherd's near-term future based on a reading of court files and his own intuition. But in Cleveland and a growing number of other local and state courts, judges are now guided by computer algorithms before ruling whether criminal defendants can return to everyday life or have to stay locked up awaiting trial.

In some states, the centuries-old process of releasing defendants on bail, long the province of judicial discretion, is getting help from artificial intelligence (AI).

Cash bail, designed to ensure that people charged with crimes turn up for trial, has been part of the US court system for centuries. But it has drawn fire in recent years for keeping poorer defendants in jail while letting the wealthier go free. Studies have also shown it widens racial disparities in pre-trial incarceration.

A bipartisan bail reform movement has found an alternative to cash bail: AI algorithms that can scour through large sets of courthouse data to search for associations and predict which suspects on bail are most likely to flee or commit another crime.

Experts say the use of these risk assessments may be the biggest shift in courtroom decision-making since American judges began accepting social science and other expert evidence more than a century ago. Christopher Griffin, a research director at Harvard Law School's Access to Justice Lab, called the new digital tools "the next step in that revolution".

Critics, however, worry that such algorithms could end up supplanting judges' own judgment, and might even perpetuate biases in ostensibly neutral form.

States such as New Jersey, Arizona, Kentucky and Alaska have adopted these tools. Defendants who receive low scores are recommended for release under court supervision. Among other things, such algorithms aim to reduce biased rulings that could be influenced by a defendant's race, gender or clothing — or maybe just how cranky a judge might be feeling after missing breakfast.

Race and gender excluded

The AI system used in New Jersey, developed by the Houston-based Laura and John Arnold Foundation, uses nine risk factors to evaluate a defendant, including age and past criminal convictions. It excludes race, gender, employment history and where a person lives.

It also excludes a history of arrests, which can stack up against people more likely to encounter police — even if they are not found to have done anything wrong.

Other efforts to automate judicial decisions have come under fire — in particular, a proprietary commercial system called Compas that has been used to help determine prison sentences for convicted criminals. An investigative report by ProPublica found that Compas was falsely flagging black defendants as likely future criminals almost twice as frequently as white defendants.

Other experts have questioned those findings, and the US Supreme Court last year declined to take up a case of a Wisconsin man who argued that the use of gender as a factor in the Compas assessment violated his rights.

Arnold notes that its algorithm is straightforward and open to inspection by anyone — although the underlying data it relies on is not. Advocates of the AI approach say that the people in robes are still in charge.

"This is not something where you put in a ticket, push a button and it tells you what bail to give somebody," said Judge Ronald Adrine, who presides over the Cleveland Municipal Court. The algorithmic score is just one of several factors for judges to consider, he said.

But others worry the algorithms will make judging more rote over time. Research has shown that people tend to follow specific advisory guidelines in lieu of their own judgment, said Bernard Harcourt, a law and political science professor at Columbia. "It's naive to think people are simply going to not rely on them," he said.

Those issues played out before Judge Jimmy Jackson Jr in that Cleveland courtroom last summer. Before his arrest on 29 August, Hercules Shepherd had no criminal record.

College coaches were pursuing the star high school basketball player; recruitment would mean a big scholarship that could help Shepherd realise his dreams of becoming an engineer. But by sitting in jail, Shepherd was missing two days of classes. Missing two more could get him kicked out of school.

The judge looked down at a computer-generated score on the 18-year-old's case file. Two out of six for likelihood of committing another crime. One out of six for likelihood of skipping court. The scores marked Shepherd as a prime candidate for pre-trial release with low bail.

"Mr Shepherd? I'm giving you personal bond," Jackson said. "Your opportunity to turn that around starts right now."

Smiling, Shepherd walked out of the courtroom. That night, he was led out of the Cuyahoga County Jail; the next day, he was in class. Shepherd says he would not have been able to afford bail. If he is not arrested again within a year, his record will be wiped clean.