농업 전문가 AI 어드바이저: RAG 기반 LLM 농업 가이드 프레임워크
Empowering farmers with artificial intelligence: a retrieval-augmented generation based large language model advisory framework
TL;DR Highlight
농부들을 위한 RAG 기반 작물 재배·병해충·비료 AI 어드바이저 시스템에서 Mistral과 Qwen2.5가 가장 우수한 성능을 보였다.
Who Should Read
농업 도메인 AI 서비스를 구축하거나, RAG 파이프라인에서 도메인 특화 문서를 처리하는 백엔드/ML 개발자. 여러 오픈소스 LLM 성능을 비교해 최적 모델을 선택해야 하는 상황에 있는 개발자.
Core Mechanics
- PoP(Package of Practices, 작물별 재배 지침서) 문서를 시맨틱 청킹으로 분할하고 Amazon Titan 임베딩으로 벡터화해 ChromaDB에 저장
- Llama3.1-8B, Mistral, Phi3, Qwen2.5 총 4개 오픈소스 LLM을 동일 RAG 파이프라인에서 비교 평가
- 평가 지표를 검색 품질(Precision@K, Recall@K, MRR, NDCG), 텍스트 유사도(BLEU, ROUGE), 의미적 품질(BERTScore, Faithfulness) 3가지 축으로 종합 측정
- Mistral과 Qwen2.5가 관련성·의미 품질·응답 속도 모두에서 가장 높은 성능
- 옥수수, 손가락기장(ragi), 고구마, 면화, 땅콩 5개 작물 대상으로 농약·비료·병해충 관리 질의응답 커버
- 전통 농업 자문 서비스 접근이 어려운 지역에서 AI로 전문 지식 격차를 메우는 실용적 접근
Evidence
- Mistral과 Qwen2.5가 Precision@K, Recall@K, MRR, NDCG 검색 지표 전반에서 Llama3.1·Phi3 대비 우위
- BERTScore F1과 Faithfulness(RAG 답변이 문서에 얼마나 충실한지) 기준으로도 Mistral·Qwen2.5가 최상위
- Attribution Score(출처 귀속 점수)를 포함한 다차원 평가에서 4개 모델 중 Mistral·Qwen2.5가 일관되게 상위권
- 총 응답 시간(검색 + 생성) 효율성 지표에서도 Mistral·Qwen2.5가 경쟁력 있는 속도 유지
How to Apply
- 도메인 특화 PDF/문서(예: 제품 매뉴얼, 의료 가이드라인)를 시맨틱 청킹으로 분할하고 Amazon Titan BedrockEmbeddings로 임베딩 후 ChromaDB에 인덱싱하면 이 논문의 파이프라인을 그대로 재현 가능
- 오픈소스 LLM 여러 개를 동일 RAG 파이프라인에 붙이고 BLEU/ROUGE/BERTScore/Faithfulness를 자동 평가하는 스크립트를 만들면 도메인별 최적 모델을 빠르게 선정할 수 있음
- 농업처럼 전문 용어가 많은 도메인에서는 일반 청킹보다 시맨틱 청킹(문장 경계·의미 단위로 분할)을 쓰면 검색 Precision이 올라가므로, 현재 고정 크기 청킹을 쓰고 있다면 교체를 검토할 것
Code Example
from langchain.text_splitter import SemanticChunker
from langchain_community.embeddings import BedrockEmbeddings
from langchain_community.vectorstores import Chroma
from langchain_community.llms import Ollama
from langchain.chains import RetrievalQA
# 1. 시맨틱 청킹 + 임베딩
embeddings = BedrockEmbeddings(model_id="amazon.titan-embed-text-v1")
splitter = SemanticChunker(embeddings, breakpoint_threshold_type="percentile")
docs = splitter.split_documents(raw_docs) # PoP 문서 로드 후 분할
# 2. ChromaDB 인덱싱
vectorstore = Chroma.from_documents(docs, embeddings, collection_name="agriculture_pop")
retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
# 3. LLM 교체하며 비교 (Mistral 또는 Qwen2.5 권장)
llm = Ollama(model="mistral") # 또는 "qwen2.5"
# 4. RAG QA 체인
qa_chain = RetrievalQA.from_chain_type(
llm=llm,
retriever=retriever,
return_source_documents=True
)
result = qa_chain.invoke({"query": "옥수수 잎마름병 방제 방법은?"})
print(result["result"])Terminology
Original Abstract (Expand)
This study presents a retrieval augmented generation (RAG) based system designed to provide farmers with expert agricultural advisory services. The framework delivers context aware guidance on critical practices such as crop cultivation, pest and disease management, fertilizer application, and other agronomic practices, and compares the performance of four large language models (LLMs) in generating these recommendations. The system processes package of practices (PoP) documents for five major crops maize, ragi, sweet potato, cotton, and groundnut through semantic chunking and embedding using Amazon Titan via BedrockEmbeddings. Vector representations are indexed in ChromaDB to enable efficient similarity search for query-relevant content retrieval. Upon receiving user queries, the system retrieves the most semantically similar document chunks and incorporates them into structured prompts. Four LLMs such as Llama3.1, Mistral, Phi3, and Qwen2.5 were evaluated for their effectiveness in generating accurate agricultural recommendations. Performance was evaluated across multiple dimensions. Relevance and retrieval were assessed using precision@K, recall@K, mean reciprocal rank (MRR), and normalized discounted cumulative gain (NDCG). Lexical overlap was measured with the bilingual evaluation understudy (BLEU) and recall-oriented understudy for gisting evaluation (ROUGE-1, ROUGE-2, ROUGE-L) metrics. Semantic quality was analyzed using Bidirectional Encoder Representations from transformers score (BERTScore) precision, recall, F1, semantic similarity and faithfulness to capture contextual alignment between generated and reference responses. Source attribution was assessed through the attribution score, while efficiency was measured using retrieval time, generation time, and total time. Overall, mistral and Qwen2.5 achieved the highest performance, demonstrating superior relevance, semantic quality, and efficiency. This evaluation highlights which LLMs perform best for the agricultural domain and illustrates the potential of knowledge-grounded AI systems to democratize agricultural expertise, particularly in regions with limited access to traditional advisory services.