RAG-LLaMA3 AI Project
Describes a RAG pipeline using LLaMA3 to answer questions about DNALinux bioinformatics tools, with code to build your own.
What this file does
Describes a RAG pipeline using LLaMA3 to answer questions about DNALinux bioinformatics tools, with code to build your own.
When to use it
- You need a ready-made AI agent for DNALinux software
- You want to build a custom RAG agent from PDFs, HTML, and URLs
- You are learning RAG with LLaMA3 and need a working example
Assumes this stack
RAG-LLaMA3 AI Project
We utilize Retrieval Augmented Generation on the LLaMA3 model to create an AI agent that can answer questions about bioinformatics software DNALinux. It helps users navigate through a large range of bioinformatics tools. Additionally, you will be able to create a simple RAG AI agent with your own resources.
You can check out our code at our repo.
Quick Start with Pre-installed AI Agent
-
Install the package:
pip install rag-llama3If you are unsure whether you have installed this package, you can use the following command:
pip show rag_llama3 -
Ask a question to our pre-installed DNALinux AI agent:
rag-llama3 "your question goes here"
How to Construct Your Own RAG AI Agent
Make sure that you have already installed the package. There is a Instruction.ipynb you can use to test the code.
-
Configuration:
- Set up the directory paths for storing your data and Chroma database. You do not need to create them manually; just specify where they should be, and they will be automatically created:
input_dir: Directory for PDF, HTML files, and URLs.urls_path: Path to a file namedurls.txtwhere you put all the URLs.output_dir: Directory whereTextExtractorwill store all.txtfiles (for debugging purposes).chroma_db_dir: Directory where your Chroma database will be stored.chroma_db_name: Collection name for your Chroma database.
- Note: The embedding model defaults to
'mxbai-embed-large'. Feel free to choose your preferred Ollama embedding model.
from rag_llama3 import RAG as rag from rag_llama3 import TextExtractor as te from rag_llama3 import VectorDB as vdb - Set up the directory paths for storing your data and Chroma database. You do not need to create them manually; just specify where they should be, and they will be automatically created:
-
Directory Setup:
- Open a Jupyter notebook and run the following code to ensure that your directory is created:
test_vector_db = vdb(input_dir, output_dir, urls_path, chroma_db_dir, chroma_db_name) - This will create an object that you can use to manipulate your Chroma vector database. It will automatically create all the directories and an empty Chroma database. If everything is already created, it will not overwrite existing files.
- Open a Jupyter notebook and run the following code to ensure that your directory is created:
-
Add Files:
- Place all PDF and HTML files in the input directory. List all URLs in the
urls.txtfile, each on a new line.
- Place all PDF and HTML files in the input directory. List all URLs in the
-
Load Data:
- Use the
test_vector_dbobject to load files into the vector database:test_vector_db.load_data() - Alternatively, load different types of files individually:
test_vector_db.load_url() test_vector_db.load_pdf() test_vector_db.load_html() - Loading might take some time. After loading, check if the vector database has been populated successfully:
test_vector_db.peek() test_vector_db.show_sources() - Query data from a specific source:
test_vector_db.query_sources(source_name) - To delete data from a source:
test_vector_db.delete_source(source_name) - Or to clear the entire database (be cautious as this is destructive):
test_vector_db.clear_database()
- Use the
-
Generate Answers:
- In a Jupyter notebook, use:
testRAG = rag(input, output, chroma_db, collection_name) print(testRAG.generate_answer("Your question goes here"))
- In a Jupyter notebook, use:
What's inside
5 setup steps, 4 code blocks, 3 class imports, 2 usage modes
Change this for your project
- Replace
DNALinuxwith your own project name in the description - Replace
'mxbai-embed-large'with your preferred Ollama embedding model - Replace
https://github.com/DNALinux/aiwith your own repository URL
Where it goes
Reference documentation for a retrieval pipeline. Keep with the ingestion or retrieval code it describes.
Worth borrowing
- Separate data loading (TextExtractor, VectorDB) from answer generation (RAG class)
- Provide a pre-built agent for quick use and a notebook for custom builds
Related Documents
SUMMARY
Proposes three on-prem AI architectures, modular, hybrid, and fully local RAG, with hardware specs and vendor lists.
Retrieval & Prompts
Explains how CharMemory's extraction prompt and Vector Storage settings determine memory retrieval quality in SillyTavern.
Advanced RAG Techniques
Surveys advanced RAG architectures, Agentic, Corrective, Self-RAG, Graph RAG, RAPTOR, Multimodal, Temporal, with design trade-offs and decision guidance.
RFC-BLite: High-Performance Embedded Document Database for .NET
Specifies an embedded document database for.NET with zero-allocation I/O, C-BSON format, and ACID transactions.