I am developing an app that acts as my assistant to aquaponics system. It can monitor and detects anomalies in my aquaponics system. Furthermore, it can answer questions related to aquaponics using peer-reviewed articles.
Today we will discuss Retrieval Augmented Generation (RAG). Basically, we use an LLM to answer questions on aquaponics using only the knowledge from a selected list of peer-reviewed articles. If it doesn’t know the answer, it would say, “I do not know the answer.”
First, we extract texts from pdfs using PyPDF2, making sure we save the filename and page number. Each text is chunked at 100 words each and preprocessed before vector embedding. We mainly remove stopwords, stem, and remove punctuations. I had to experiment with the number of tokens to chunked at. We embed the words to vectors using text-emebdding-ada-002. The vectors are stored into chroma vector database.
For a query, we would embed using the same embedding model above. Using cosine distance, we find top 5 or 10 documents closest to the query. The texts from these closest documents are joined together along with their sources, which we call context. We pass the query and the context to an LLM. Here we are using gpt-3.5-turbo.
Couple of things to note. Even though chromadb has its own embedding function, we decided to embed separately so that we could change the embedding model any time we wish. We feed raw text into gpt-turbo-3.5 for accuracy.
For example, if I ask, “What diseases should I be aware of in aquaponics?”, I receive the answer:
1. Diseases common in aquaponics:
- Soil-borne pathogens like Fusarium spp., Phytophthora spp., and Pythium spp.
- Gas super-saturation (gas bubble disease)
- Abiotic diseases like improper salinity
2. It is important to distinguish between metabolic and pathogenic diseases in aquaponics to identify causes promptly and administer remedies effectively.
3. Biotic diseases are less common in aquaponics compared to pond or cage aquaculture farming due to fish immune systems resisting infections and the unfavorable environment for pathogens.
4. Diseases like Phytophthora spp. and Pythium spp. in aquaponics require special attention due to their preference for humid/aquatic environments.
5. Fish pathogens are prevalent in aquatic environments, but fish can usually resist them unless overloaded by the allostatic load.
6. To reduce the risk of diseases, control of relative humidity, proper ventilation, and management of water quality are crucial in aquaponics.
Sources:
- FAO Small-scale Aquaponic, page_number: 142, 210
- Springer Aquaponics Food Production Systems, page_number: 357, 438
- UF IFAS A Practical Guide for Aquaponics as an Alternative, page_number: 7
If we pose the query, “What light should I use for my aquaponics system?”:
1. Large-scale aquaponic farms like Superior Fresh farms use automated supplemental LED lighting to cultivate plants year-round (Springer Aquaponics Food Production Systems, p. 536).
2. Downward movement of water and greenhouse light can reduce energy consumption in aquaponics systems (Wikipedia Aquaponics, p. 9).
3. Using supplementary lighting with dynamic control can help achieve system balance in aquaponics for various climate zones (Springer Aquaponics Food Production Systems, p. 228).
4. Fish tanks in aquaponic systems must be shaded, unlike plants that may require varying degrees of light (FAO Small-scale Aquaponic, p. 62).
5. Various aquaponic systems include media bed, nutrient film technique (NFT), and deep water culture (DWC) methods (FAO Small-scale Aquaponic, p. 276).
6. Aquaponic units require proper aeration, adequate water quality, and balanced fish-to-plant ratios for successful operation (FAO Small-scale Aquaponic, p. 284).
7. Providing shading for fish tanks, using aeration systems, and ensuring water quality are key guidelines for successful aquaponics (FAO Small-scale Aquaponic, p. 284).
I did not use external sources for this answer.
Note that I requested the model to specify if it uses external sources.
Watch the video below to see it in action. I know the video is not great, but I don’t have much time these days.
Leave a comment