Inspiration

Growing up with an interest in agriculture, I quickly realized how hard it is to find reliable, practical information. Learning about soil health, planting seasons, pest control, and market prices meant spending hours scouring online resources, watching videos, and sometimes reaching out directly to agricultural institutions hoping someone would respond. It was time-consuming, often frustrating, and required a stable internet connection I could not always count on.

I kept thinking about the millions of farmers across Nigeria who face the same challenge every single day, except the stakes for them are much higher. A wrong decision about when to plant, how to treat a diseased crop, or when to sell at market does not just waste time, it can mean a failed harvest and a family without income for an entire season. At the same time, I saw a parallel gap on the other side of the value chain: local and foreign investors interested in Nigerian agriculture often struggle to find consolidated, practical information on land access, ROI by crop, and where to invest.

That frustration became the inspiration for VerdeBuddy. I wanted to build something that puts a knowledgeable agricultural advisor directly in a farmer's hands, one that speaks their language, works without internet, and is available at any hour of the day, while also giving investors the practical intelligence they need to evaluate opportunities in Nigerian agriculture.

What I Learned

Building VerdeBuddy taught me more than I expected across several areas.

On the technical side, I learned how to run large language models entirely on CPU using llama.cpp and the GGUF format, and how to select the right quantization level to balance memory usage against response quality. I learned how retrieval-augmented generation works in practice, and I learned it the hard way: my first retrieval approach used generic keyword-overlap scoring, and it consistently pulled the wrong information. A question about cassava prices in Oyo state would sometimes retrieve a chunk about maize storage instead. A small model faced with irrelevant context does not say "I don't know", it hallucinates fluently, inventing plausible-sounding crop variety names and prices that do not exist anywhere in my data. Fixing this taught me that retrieval quality matters more than model size for grounding small models in fact.

The most important lesson came from trying to support Hausa. I initially assumed that if English responses were grounded and accurate through retrieval, Hausa would work the same way with a translated prompt. It did not. Qwen2.5-1.5B has so little Hausa in its training data that it would fall into infinite repetition loops, the same two or three words cycling for two hundred tokens, taking over two minutes to fail. I learned that this is not a prompting problem you can fix with temperature or repetition penalty tuning, it is a genuine capability gap in the base model. The right engineering response was not to keep pushing the LLM harder, it was to recognize the limitation and design around it.

I also learned how to architect a stable AI server where the inference engine runs as a separate subprocess, so a low-level C runtime crash does not bring down the whole application, and I learned how subtle state-management bugs creep into a chat interface, like a response returning in the wrong conversation because a background fetch resolved after the user had already switched chats.

How I Built It

VerdeBuddy is built around several components working together.

The core is Qwen2.5-1.5B-Instruct, a 1.5 billion parameter language model quantized to Q4_K_M format, running through llama-cpp-python with CPU-only inference in a dedicated subprocess worker, so no graphics card is needed and a crash in the inference layer never takes down the server.

Around the model sits a deterministic, topic-routed retrieval pipeline rather than a generic similarity search. Each incoming question is classified in priority order: does it name a specific crop, in which case the exact crop profile is retrieved by matching the section heading directly; does it concern soil, weather, market pricing, or investment, in which case the relevant domain chunk is retrieved; does it mention a Nigerian state, with an explicit safeguard that strips the word "Nigeria" from the query first, since "Niger" is a literal substring of "Nigeria" and was silently corrupting every query with a false state match.

For Hausa, English generation is not used at all. Instead, VerdeBuddy classifies the question into a topic category using the same deterministic router, pulls the relevant facts straight out of the knowledge base, and fills them into pre-written, human-verified Hausa sentence templates, translating month names and season terminology on the fly. A question about maize planting season returns a grammatically correct, factually accurate Hausa answer in under half a second, compared to the two-minute failure of the generative approach. I worked directly with a Hausa speaker to correct and refine every template until the phrasing read naturally rather than like a translation.

The user interface is a single-page chat application served by Python's built-in HTTP server. It includes a chat history sidebar with search, navigation, and per-chat deletion, a home button to cleanly exit back to the landing screen, copy and refresh and edit buttons on every message, markdown-aware rendering so headings and bold text display properly instead of showing raw asterisks, follow-up questions generated dynamically from the AI's own response, voice input, an export chat function, and a Progressive Web App manifest and service worker so it installs and runs like a native app.

Challenges

The biggest challenge was retrieval accuracy for English, and I went through several iterations before landing on deterministic heading matches instead of scoring competitions between chunks. Along the way I caught a subtle bug where every query mentioning "Nigeria" was misread as mentioning "Niger" state due to a naive substring match, and another where a large first chunk would silently crowd out a smaller, more relevant second chunk before the model ever saw it, fixed by truncating each retrieved chunk individually rather than truncating the joined result.

The second, larger challenge was Hausa. I spent real time trying to fix the repetition loops with lower temperature, higher repeat penalty, and custom post-processing to detect and cut off repeating phrases. Some of this helped at the margins but none of it solved the underlying problem, and every attempt still cost one to two minutes of CPU time per failed request. Recognizing that the honest fix was a template system rather than a smarter prompt was the single biggest architectural decision in the project, and it required me to sit down with a native Hausa speaker line by line to make sure the output was not just grammatically valid but natural.

A separate, more mundane challenge was the user interface. Embedding the entire front-end inside a Python string and modifying it surgically turned into a lengthy battle with string escaping, eventually solved by separating HTML, CSS, and JavaScript into their own files served statically. Later, a layout bug where the home button broke the landing page turned out to be a single wrong CSS value, display:block instead of display:flex, that had been masked by the installed PWA's service worker aggressively caching the old, broken JavaScript, which taught me to always bump the cache version when debugging PWA behavior that "should" already be fixed.

What's Next

VerdeBuddy is a foundation. The knowledge base can grow to cover more crops, more states, and a deeper investment guide with state-by-state incentive comparisons. The Hausa template system can expand to cover more question categories, and eventually a properly fine-tuned Hausa agricultural model could replace templates with genuine generation, once that investment makes sense. Voice output would make the tool accessible to farmers who are more comfortable listening than reading. Yoruba and Igbo support remain on the roadmap, likely following the same template-first approach that proved successful for Hausa, since it delivers reliably correct answers today rather than fluent but unreliable ones. And with enough community input, the knowledge base itself could become a living resource maintained by farmers, agronomists, and investors together.

The goal has always been simple: make it easier for anyone who cares about farming, or about investing in Nigerian agriculture, to get the information they need, wherever they are.

Built With

Share this project:

Updates

Submission history