It’s been called China’s “pork miracle.”

For centuries, pig-rearing in the country was predominantly a backyard occupation. (The etymology of the Chinese character for “home” literally means “house with a pig in it.”) But since the 1980s, China has swiftly modernized its pork industry to meet the demands of a newly-rich middle class. Now, half of the world’s pigs — some 700 million animals — live and die in China, most in huge farms. And to help manage this porcine horde, the country’s farmers are turning to a decidedly untraditional tool: artificial intelligence.

Earlier this month, Chinese tech giant Alibaba signed a deal with pig farming corporation Dekon Group and pig feed manufacturer Tequ Group to develop and deploy AI-powered pig-tracking systems. As reported by Chinese outlet Synced, the deal is worth tens of millions of dollars, and will primarily rely on machine vision to replace the wireless radio frequency tags (RFID) used to follow pigs about farms.

RFID tags are reliable, but expensive and time-consuming to manage. They have to be fitted to each pig, and scanned individually for tracking. With millions of animals raised each year in large farms, this can be a real bottleneck. “If you have 10 million pigs to raise, you can barely count how many piglets were born on a daily basis when the due date comes,” said Tequ Group’s chief information officer, Zhang Haifeng.

The solution is to use machine vision technology, tracking pigs using overhead cameras that identify numbers tattooed onto their bodies. At a basic level, this system will be able to count pigs and piglets, but Alibaba hopes it will also offer more sophisticated analysis.

It’s basically an AI fitness tracker for pigs

For example, by combining temperature readings from infrared sensors with records of how much each pig is moving each day, the AI will be able to estimate the health of individual animals. Connected “voice” recognition tools are even cleverer. One will alert farmers when piglets are being crushed by their mothers by listening out for young pigs’ squeals. (Alibaba claims this system alone will lower the death rate for piglets by three percent annually.) Another will try to monitor the spread of disease by recording the sounds of pigs coughing.

“On one hand, we hope to bring down husbandry costs and achieve agricultural reform,” said Alibaba’s Zhang Sheng, reports Chinese news agency Xinhua. “On the other hand, we’d like to translate AI technology into safe, tasty pork.”

China isn’t the only country interested in this synthesis of tech and farming. US agricultural giant Cargill recently starting testing facial recognition for cows, while last year, tractor-maker John Deere bought an AI startup that puts cameras in crop sprayers to identify and precisely target weeds with pesticides. To feed a growing population, farming will need to become more automated and efficient, and it’s tools like this that will help meet the demand.