# RAG with txtai: 자신의 데이터로 Vector RAG & Graph RAG를 실행해볼 수 있는 애플리케이션 (feat. NeuML)

**URL:** <https://discuss.pytorch.kr/t/rag-with-txtai-vector-rag-graph-rag-feat-neuml/5006>\
**Category:** 읽을거리&정보공유\
**Tags:** vector-rag, rag-application, vector-db, txtai, vector-search, graph-rag, rag-with-txtai, neuml\
**Created:** [8월 9, 2024, 8:48오전 UTC](https://discuss.pytorch.kr/t/rag-with-txtai-vector-rag-graph-rag-feat-neuml/5006 "2024-08-09T08:48:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![9bow](https://discuss.pytorch.kr/user_avatar/discuss.pytorch.kr/9bow/32/16301_2.png) [@9bow](https://discuss.pytorch.kr/u/9bow)\
**Post date:** [8월 9, 2024, 8:48오전 UTC](https://discuss.pytorch.kr/t/rag-with-txtai-vector-rag-graph-rag-feat-neuml/5006/1 "2024-08-09T08:48:16Z")

</div>

## RAG with txtai 소개

 ![RAG with txtai: txtai 기반의 Vector RAG & Graph RAG Application (feat. NeuML)](https://discuss.pytorch.kr/uploads/default/original/2X/0/003d351f113043a1fc673ca889502e43f20ea98e.png)

RAG(Retrieval Augmented Generation)는 LLM(대규모 언어 모델)과 검색 기능을 결합하여 사용자의 데이터에서 통찰력을 얻는 애플리케이션입니다. RAG는 검색 쿼리를 통해 LLM이 답변을 생성할 때 참조할 수 있는 관련 컨텍스트를 제공함으로써, 보다 정확한 정보를 생성하도록 돕습니다. 이 애플리케이션은 [txtai](https://github.com/neuml/txtai)를 기반으로 하며, Vector RAG와 Graph RAG라는 두 가지 유형의 RAG를 지원합니다.

아래 데모는 RAG with txtai 애플리케이션을 사용한 기본적인 Vector RAG 쿼리와 Graph RAG 쿼리를 보여줍니다.

![RAG with txtai Demo: Vector RAG Query 및 GraphRAG Query 사례](https://discuss.pytorch.kr/uploads/default/original/2X/1/16ba8235661e22c44876ad2165f915107c2f87f8.gif)

## Vector RAG와 Graph RAG

### Vector RAG 소개

 ![Vector RAG 소개](https://discuss.pytorch.kr/uploads/default/original/2X/3/3dc892f1f5bb9b3493b1fe56035e509647f35dbe.png)

전통적인 RAG(Traditional RAG), 또는 Vector RAG는 사용자의 입력과 가장 관련성이 높은 상위 N개의 결과를 벡터 검색을 통해 찾고, 이를 LLM에 전달하여 답변을 생성합니다.

### Graph RAG 소개

 ![Graph RAG 소개](https://discuss.pytorch.kr/uploads/default/original/2X/7/7c55a4c82c9d4d4489a241872fcd789a4f9113d2.jpeg)

Graph RAG는 지식 그래프(KG, Knowledge Graph)나 의미 그래프(SG, Semantic Graph)를 사용하여 컨텍스트를 생성하는 새로운 방법입니다. Graph RAG에서는 다음과 같은 방법을 통해 컨텍스트를 생성할 수 있습니다:

- **그래프 쿼리** : 벡터 검색을 통해 상위 결과를 찾은 후, 그래프 네트워크를 사용하여 이를 확장합니다.
- **그래프 경로 쿼리** : 개념 리스트를 입력하면, 해당 개념에 가장 가까운 노드를 찾아 컨텍스트를 생성합니다.

각 Graph RAG 쿼리 응답에는 그래프도 함께 제공되어 쿼리의 작동 방식을 시각적으로 이해할 수 있습니다.

## 빠른 시작

Docker 또는 Python 환경에서 RAG with txtai 애플리케이션을 실행해볼 수 있습니다. 자세한 내용은 [GitHub 저장소](https://github.com/neuml/rag)를 참고해주세요:

### Docker 사용

이 애플리케이션은 Docker 컨테이너로 실행할 수 있으며, 이를 통해 애플리케이션의 기능을 손쉽게 체험할 수 있습니다. Docker Hub에서 [neuml/rag 이미지](https://hub.docker.com/r/neuml/rag)를 다운로드받아 다음과 같이 실행할 수 있습니다:

```bash
docker run -d --gpus=all -it -p 8501:8501 neuml/rag

```

### Python 가상환경 사용

Python 가상환경을 사용하여 직접 설치하고 실행할 수도 있습니다. 이 때, Python 가상환경 내에서 애플리케이션을 실행하는 것을 권장합니다:

```bash
git clone https://github.com/neuml/rag
cd rag
pip install -r requirements.txt

```

### 데이터 넣기

새로운 임베딩(Embedding) 인덱스나 기존 인덱스에 데이터를 추가할 수 있습니다. 파일 경로 또는 URL을 통해 데이터를 추가하거나, 직접 텍스트를 입력할 수 있습니다.

아래와 같이 `# `로 시작하는 문장 또는 파일 경로, URL을 입력하면 해당 내용 또는 파일, 웹 페이지을 인덱싱합니다.

| 방법 | 예시 |
| --- | --- |
| `# 파일 경로 또는 URL을 입력하면 인덱싱을 합니다.` | ![파일 경로 또는 URL을 입력하여 추가하는 예시](https://discuss.pytorch.kr/uploads/default/original/2X/9/99a32c2bbc7a6ee1ed15d36851078e9151d5f1d2.png) |
| ` # 별도의 문장이나 노트를 직접 입력할 수 있습니다.` | ![별도의 문장이나 노트를 직접 입력하는 예시](https://discuss.pytorch.kr/uploads/default/original/2X/f/f93626acba382fa9ee746580fdf17a47d25ce305.png) |

## 라이센스

RAG with txtai 프로젝트는 [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0)로 공개 및 배포되고 있습니다.

## :github: NeuML의 RAG Application GitHub 저장소

[https://github.com/neuml/rag](https://github.com/neuml/rag)

## :docker: RAG Application Docker Image 저장소

> **[neuml/rag - Docker Image](https://hub.docker.com/r/neuml/rag)**

## 더 읽어보기: txtai Vector DB 소개 글

- [txtai: 임베딩 생성 및 검색 등을 위한 All-in-one VectorDB](https://discuss.pytorch.kr/t/txtai-all-in-one-vectordb/4781)

* * *

_이 글은 GPT 모델로 정리한 글을 바탕으로 한 것으로, 원문의 내용 또는 의도와 다르게 정리된 내용이 있을 수 있습니다. 관심있는 내용이시라면 원문도 함께 참고해주세요! 읽으시면서 어색하거나 잘못된 내용을 발견하시면 덧글로 알려주시기를 부탁드립니다._ 🤗

[:pytorch:파이토치 한국 사용자 모임🇰🇷](https://pytorch.kr/)이 정리한 이 글이 유용하셨나요? [회원으로 가입](https://discuss.pytorch.kr/signup)하시면 주요 글들을 이메일💌로 보내드립니다! (기본은 Weekly지만 [Daily로 변경도 가능](https://discuss.pytorch.kr/my/preferences/emails)합니다.)

🎁 아래↘쪽에 좋아요👍를 눌러주시면 새로운 소식들을 정리하고 공유하는데 힘이 됩니다~ 🤩
