Generative AI for Farming

Farmer.Chat answers questions about agriculture

By Mike Loukides
June 18, 2024
Seedlings Seedlings (source: Pixnio)

We’re planning a live virtual event later this year, and we want to hear from you. Are you using a powerful AI technology that seems like everyone ought to be using? Here’s your opportunity to show the world

AI is too often seen as an enterprise of, by, and for the wealthy. We’re going to take a look at a Digital Green’s Farmer.Chat, a generative AI bot that was designed to help small-scale farmers in developing countries access critical agricultural information. Developing countries have frequently implemented technical solutions that would never have occurred to engineers in wealthy countries. They solve real problems rather than appealing to the “let’s start another Facebook” fantasies of venture capitalists. Farmer.Chat is one of those solutions.

Learn faster. Dig deeper. See farther.

Join the O'Reilly online learning platform. Get a free trial today and find answers on the fly, or master something new and useful.

Learn more

Farmer.Chat helps agricultural extension agents (EAs) and farmers get answers to questions about agriculture. It has been deployed in India, Ethiopia, Nigeria, and Kenya. While it was designed originally for EAs, farmers are increasingly using it directly; they have already become accustomed to asking questions online using social media. Providing online access to better, more reliable agricultural information quickly and efficiently was an obvious goal.

An AI application for farmers and EAs faces many constraints. One of the biggest constraints is location. Farming is hyperlocal. Two farms may be a mile apart, but if one is on a hillside and another in a valley, they will have completely different soil, drainage, and perhaps even weather conditions. Different microclimates, pests, crops: what works for your neighbor might not work for you.

The data to answer hyperlocal questions about topics like fertilization and pest management exists, but it’s spread across many databases with many owners: governments, NGOs, and corporations, in addition to local knowledge about what works. Farmer.Chat uses all these sources to answer questions—but in doing so, it has to respect the rights of the farmers and the database owners. Farmers have a right to privacy; they may not want to share information about their farm or to let others know what problems they are experiencing. Corporations may want to limit what data they expose and how it is exposed. Digital Green solves this problem through FarmStack, a secure open source protocol for opt-in data sharing. End-to-end encryption is used for all connections. All sources of data, including farmers and government agencies, choose what data they want to share and how it is shared. They can decide to share certain kinds of data and not others, or they impose restrictions on the use of their data (for example, limit it to certain geographic areas). While fine-grained opt-in sounds imposing, treating its data suppliers and its users with respect has allowed Farmer.Chat to build a trusted ecosystem for sharing data. In turn, that ecosystem leads to successful farms.

FarmStack also enables confidential feedback. Was a data provider’s data used successfully? Did a farmer provide local knowledge that helped others? Or were their problems with the information? Data is always a two-way street; it’s important not just to use data but also to improve it.

Translation is the most difficult problem for Digital Green and Farmer.Chat. Farmer.Chat currently supports six languages (English, Hindi, Telugu, Amharic, Swahili, and Hausa) and Digital Green is working to add more. To serve EAs and farmers well, Farmer.Chat must also be multimodal—voice, text, and video—and it has to reach farmers in their native languages. While useful information is available in many languages, finding that information and answering a question in the farmer’s language through voice chat is an imposing challenge. Farmer.Chat uses Google Translate, Azure, Whisper, and Bhashini (an Indian company that supplies text-to-speech and other services for Indian languages), but there are still gaps. Even within one language, the same word can mean different things to different people. Many farmers measure their yield in bags of rice, but what is “a bag of rice”? It might mean 10 kilos to one farmer, and 5 kilos to someone who sells to a different buyer. This one area where keeping an extension agent in the loop is critical. An EA would be aware of issues such as local usage, local slang, and technical farming terms, and could resolve problems by asking questions and interpreting answers appropriately. EAs also help with trust. Farmers are naturally wary of taking an AI’s advice in changing practices that have been used for generations. An EA who knows the farmers and their history and who can situate the AI’s answers in a local context is much more trustworthy.

To manage the problem of hallucination and other kinds of incorrect output, Digital Green uses retrieval-augmented generation (RAG). While RAG is conceptually simple—look up relevant documents and construct a prompt that tells the model to build its response from them—in practice, it’s more complex. As anyone who has done a search knows, search results are likely to give you a few thousand results. Including all those results in a RAG query would be impossible with most language models and impractical with the few that allow large context windows. So the search results need to be scored for relevance; the most relevant documents need to be selected; then the documents need to be pruned so that they contain only the relevant parts. Keep in mind that, for Digital Green, this problem is both multilingual and multimodal: relevant documents can turn up in any of the languages or modes that they use.

It’s important to test every stage of this pipeline carefully: translation software, text-to-speech software, relevance scoring, document pruning, and the language models themselves: Can another model do a better job? Guardrails need to be put in place at every step to guard against incorrect results. Results need to pass human review. Digital Green tests with “Golden QAs,” highly rated sets of questions and answers. When asked a “golden question,” can the application consistently produce results as good as the “golden answer?” Testing like this needs to be performed constantly. Digital Green also manually reviews 15% of their usage logs, to make sure that their results are consistently high quality. In his podcast for O’Reilly, Andrew Ng recently noted that the evaluation stage of product development frequently doesn’t get the attention it deserves, partly because it’s so easy to write AI software; who wants to spend a few months testing an application that took a week to write? But that’s exactly what’s necessary for success.

Farmer.Chat is designed to be gender inclusive and climate smart. Because 60% of the world’s small farmers are women, it’s important for the application to be welcoming to women and not to assume that all farmers are male. Pronouns are important. So are role models; the farmers who present techniques and answer questions in video clips must include men and women.

Climate-smart means making climate-sensitive recommendations wherever possible. Climate change is a huge issue for farmers, especially in countries like India where increasing temperatures and changing rainfall patterns can be ruinous. Recommendations must anticipate current weather patterns and the ways they’re likely to change. Climate-smart recommendations also tend to be less expensive. For example, while Farmer.Chat isn’t afraid of recommending commercial fertilizers, it emphasizes local solutions: almost every farm can have a limitless supply of compost—which costs less than fertilizer and helps manage agricultural waste.

Farming can be very tradition-bound: “We do this because that’s what my grandparents did, and their parents before them.” A new farming technique coming from some faceless scientists in an urban office means little; it’s much more likely to be adopted if you hear that it’s been used successfully by a farmer you know and respect. To help farmers adopt new practices, Digital Green prioritizes the work of peers whenever possible using videos collected from local farmers. They try to put farmers in contact with each other, celebrating their successes to help farmers adopt new ideas.

Finally, Farmer.Chat and FarmStack are both open source. Software licenses may not affect farmers directly, but they are important in building healthy ecosystems around projects that aim to do good. We see too many applications whose purpose is to monopolize a user’s attention, subject a user to unwanted surveillance, or debase political discussions. An open source project to help people: we need more of that.

Over its history, in which Farmer.Chat is just the latest chapter, Digital Green has aided over 6.3 million farmers, boosted their income by up to 24%, and increased crop yields by up to 17%. Farmer.Chat is the next step in this process. And we wonder: the problems faced by small-scale farms in the developed nations are no different from the problems of developing countries. Climate, insects, and crop disease have no respect for economics or politics. Farmer.Chat helps small scale farmers succeed in developing nations. We need the same services in the so-called “first world.”

Post topics: AI & ML, Artificial Intelligence
Post tags: Research
Share:

Get the O’Reilly Radar Trends to Watch newsletter