Skip to main content

This repository contains a project that implements a Retrieval-Augmented Generation (RAG) system using the LLaMA3 model. The project focuses on creating embeddings for instructions of a professional bioinformatic software to help users conduct biology research.

Project description

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

  1. Install the package:

    pip install rag-llama3
    

    If you are unsure whether you have installed this package, you can use the following command:

    pip show rag_llama3
    
  2. 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.

  1. 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 named urls.txt where you put all the URLs.
      • output_dir: Directory where TextExtractor will store all .txt files (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.
    import RAG as rag
    import TextExtractor as te
    import VectorDB as vdb
    
  2. Directory Setup:

    • Open a Jupyter notebook and run the following code to ensure that your directory is created:
      test_vector_db = vdb.VectorDB(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.
  3. Add Files:

    • Place all PDF and HTML files in the input directory. List all URLs in the urls.txt file, each on a new line.
  4. Load Data:

    • Use the test_vector_db object 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()
      
  5. Generate Answers:

    • In a Jupyter notebook, use:
      testRAG = rag.RAG(input, output, chroma_db, collection_name)
      print(testRAG.generate_answer("Your question goes here"))
      

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rag_llama3-0.1.2.dev2.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

rag_llama3-0.1.2.dev2-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file rag_llama3-0.1.2.dev2.tar.gz.

File metadata

  • Download URL: rag_llama3-0.1.2.dev2.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for rag_llama3-0.1.2.dev2.tar.gz
Algorithm Hash digest
SHA256 90e8ba85bffb4e402b22d66329c20f08d15620820d718b173add4a4639dcdb89
MD5 706bb02ae2b6886b6cf2083bbe47068e
BLAKE2b-256 0bd88bb140944df7026bcfd210b88704e9e060a6cbbfd8489e3a689ab0ed8f8b

See more details on using hashes here.

File details

Details for the file rag_llama3-0.1.2.dev2-py3-none-any.whl.

File metadata

File hashes

Hashes for rag_llama3-0.1.2.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 67c3a1b3e8b17f2431525641c9e8be62f90849b8927e117d89229f1d6965d419
MD5 11b8f98bbc697a0077a42dc27e8b9293
BLAKE2b-256 4cd174aaa78e3221e27b428d86ddeb4f7bbbcfb1d7bc815719785d43b8a7c8b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page