top of page

<Example of implementation of MyRAG search system>

図5 RAGの構成イメージ、Software Design 2025年1月号から抜粋.jpg

Figure: RAG configuration image

1. Background (*1)
LLM users have a need to search and process huge amounts of data quickly and efficiently find highly similar information. In response to these needs, expectations for vector databases are rising.

RAG (Retrieval Augmented Generation) is one of the means to improve the accuracy of answers drawn from generative AI.

When LLM generates an answer, RAG refers to external knowledge information in response to a user prompt (instruction sentence). Vector search is often used to search for this external knowledge. In this search, data such as text and images are expressed as multidimensional numerical vectors. In addition, prompts such as text entered by the user in the search are also vectorized, and the similarity is calculated and output based on the similarity that indicates the degree to which the vectors are similar.

  *1 Source: Nikkei Computer 2024.5.16, 2024.6.13

2. Necessity
In the task of creating monthly reports, information is extracted from various sources every day and registered in cloud storage.
The extracted information is mostly documents and images,
which are registered with names that are easy for the user to understand.
When the deadline for the report approaches, the user searches the cloud to find the information needed to create the report,
but finding it takes a huge amount of time.
The cloud system records and stores where the registered documents, images, and other data were registered on the cloud as access logs.
So, is it possible to quickly find the documents and images needed by searching the large amount of access logs accumulated in the past using simple words?


3. Introducing the RAG mechanism to search access logs
The RAG system consists of four steps. (*2)
- Data storage (Store)
- Information search (Retrieval)
- Augmentation (Augumented)
- Generation

  *2 Source: Specialized magazine "Software Design January 2025 issue" (Gijutsuhyoronsha)
    Figure 5: RAG configuration image


4. Implementing RAG search

We implemented my own RAG search system using the published code (*3) as a reference in the following operating environment.

- Works on PCs with Windows 11 version 23H2 or later.

- The vector database for RAG is stored on the PC.

- Set the operating environment under Power Shell on the PC.

- After setting, start the Python RAG app.

- Obtain the OpenAI API key from the official openAI page in advance.

  *3 Source: GitHub - ykimura517/RAG-sample


5. Issues
When converting access logs into a vector database in the Store process, there is a limit to the amount of data that can be registered at one time.
For this reason, when handling large amounts of access logs, they are divided into fixed-length data and registered in several installments.

Created on December 28, 2024
 

生成AI活用_RAG検索の例-9-7  デーダベースはICTL第2世代.jpg

[First query and answer]

生成AI活用_RAG検索の例-9-8  デーダベースはICTL第2世代.jpg

[Second query and answer]

bottom of page