AI Agent for Technical Reviews : A Simple RAG Project(2)

AI Agent Future Preview

In this post, we will share additional progress on the AI Agent for Technical Review project introduced previously. By the end of this article, anyone will be able to start a simple RAG project.


The Retrieval Stage for AI Agent

In RAG (Retrieval-Augmented Generation), the Retrieval stage is the most crucial part for making AI Agent. Retrieval can be broadly divided into two types: Sparse Retrieval and Dense Retrieval.

1. Sparse Retrieval

  • Sparse Retrieval is similar to Keyword Retrieval.
  • It retrieves documents by evaluating the keyword similarity between the input query and documents embedded in the Vector DB.
  • Example: It is suitable when a specific keyword must be included in the retrieved documents.

2. Dense Retrieval

  • Dense Retrieval performs semantic-based searches.
  • It retrieves documents based on the semantic similarity between the input query and documents.
  • Cosine similarity between vectors is used to determine this similarity, and most Vector DBs, such as Chroma DB, provide built-in Dense Retrieval functionality.
  • Ideal for more in-depth or nuanced searches.

In this project, we utilized an Ensemble Retrieval method that combines both Sparse Retrieval and Dense Retrieval.

  • Sparse Retrieval: Implemented using the BM25 algorithm.
  • Dense Retrieval: Leveraged the built-in retrieval model provided by Chroma DB.
  • The weights and methods for combining these retrieval types were adjusted based on document properties.
  • For this project, semantic search was deemed more critical than keyword search, so higher weight was assigned to Dense Retrieval.
  • Example: If a specific keyword is critical, a higher weight can be allocated to Sparse Retrieval.

After validating the results, the retrieved data was converted into JSON format, ready to be fed into the LLM.

RAG Project Retrievers

Template Configuration

1. Role Assignment

Assigning a role to the LLM during template design is vital.

  • Role assignment significantly enhances the quality of responses.
  • Example: Specify a role such as “You are a technical review expert.”

2. Utilizing ChatGPT

Using ChatGPT can make template creation more efficient.

  • Provide the context and requirements of the project to ChatGPT to generate an optimized template.
  • Example: “Design a template to summarize outputs from the RAG Retrieval stage.”

3. Final Template Setup

Ensure the template includes the following elements:

  • Space for inserting retrieval results.
  • A section for the input query.

Once the template is finalized, it can be input into the LLM to produce the desired output.

RAG Project Prompt Template
RAG Project LLM

Conclusion of AI Agent Project

In this project, we demonstrated the implementation of a simple RAG system and summarized its key processes. This post focused on the Retrieval stage and template configuration. Detailed code examples are available in the attached images.

Follow-up posts will cover specific code elements in greater detail, as questions are expected. We hope this guide on the AI Agent for Technical Review project proves helpful for those starting their RAG journey!

Leave a Comment

Your email address will not be published. Required fields are marked *