RAGChain Docs
  • Introduction
  • Quick Start
  • Installation
  • RAGchain Structure
    • File Loader
      • Dataset Loader
        • Ko-Strategy-QA Loader
      • Hwp Loader
      • Rust Hwp Loader
      • Win32 Hwp Loader
      • OCR
        • Nougat Loader
        • Mathpix Markdown Loader
        • Deepdoctection Loader
    • Text Spliter
      • Recursive Text Splitter
      • Markdown Header Splitter
      • HTML Header splitter
      • Code splitter
      • Token splitter
    • Retrieval
      • BM25 Retrieval
      • Hybrid Retrieval
      • Hyde Retrieval
      • VectorDB Retrieval
    • LLM
    • DB
      • MongoDB
      • Pickle DB
    • Reranker
      • BM25 Reranker
      • UPR Reranker
      • TART Reranker
      • MonoT5 Reranker
      • LLM Reranker
    • Benchmark
      • Auto Evaluator
      • Dataset Evaluators
        • Qasper
        • Ko-Strategy-QA
        • Strategy-QA
        • ms-marco
  • Utils
    • Query Decomposition
    • Evidence Extractor
    • Embedding
    • Slim Vector Store
      • Pinecone Slim
      • Chroma Slim
    • File Cache
    • Linker
      • Redis Linker
      • Dynamo Linker
      • Json Linker
    • REDE Search Detector
    • Semantic Clustering
  • Pipeline
    • BasicIngestPipeline
    • BasicRunPipeline
    • RerankRunPipeline
    • ViscondeRunPipeline
  • For Advanced RAG
    • Time-Aware RAG
    • Importance-Aware RAG
Powered by GitBook
On this page
  • Installation
  • Run Simple RAG workflow
  • Setup: Linker
  • Setup: API Key
  • Ingest your files
  • Run your RAG workflow
  • Unlock power of RAGchain

Quick Start

PreviousIntroductionNextInstallation

Last updated 1 year ago

Installation

pip install RAGchain

For more details, see our

Run Simple RAG workflow

The fastest way to use RAGchain is using . In this example, we use and , which is simple but powerful.

Setup: Linker

Before run pipelines, you need to make Redis DB. It is essential part for link retrieval and DB. Please read docs for more information.

You can choose between , , or as your data storage. The choice depends on your project's requirements.

For example, let's take a look at a setup that uses RedisDB as a linker.

Redis Linker Setup

A great way to set up a Redis DB is using the free Redis.com DB. Go to redis.com and create your database.

After you build your own Redis DB, you can get the Redis host URL, port number, DB name (number like 0), and password. You must set these values to environment variables like below.

LINKER_TYPE="redisdb"
REDIS_HOST="your redis host url"
REDIS_PORT="your redis port number"
REDIS_DB_NAME="your redis db name"
REDIS_PW="your redis password"

If you want to use DynamoLinker or JsonLinker, you can set LINKER_TYPE to "dynamodb" of "json" and set the environment variables for each linker.

Setup: API Key

We want to use Vector DB retrieval and openai embedding in this example. So, you have to set your OpenAI API key. Set openai API key environment variable like below:

os.environ["OPENAI_API_KEY"] = "your-api-key"

Ingest your files

from RAGchain.pipeline.basic import BasicIngestPipeline
from RAGchain.DB import PickleDB
from langchain.document_loaders import TextLoader
from RAGchain.utils.vectorstore import ChromaSlim
from RAGchain.retrieval import VectorDBRetrieval
from RAGchain.utils.embed import EmbeddingFactory
import chromadb

chroma_db = ChromaSlim(
    client=chromadb.PersistentClient(path="your/path/to/chroma"),
    collection_name='test-collection-name',
    embedding_function=EmbeddingFactory('openai').get()
)
pipeline = BasicIngestPipeline(
    file_loader=TextLoader('your/path/to/file.txt'),
    db=PickleDB('your/path/to/db.pkl'),
    retrieval=VectorDBRetrieval(chroma_db)
)

pipeline.run()

You have to set path to location that you want to store chroma and pickle db.

Run your RAG workflow

from RAGchain.pipeline.basic import BasicRunPipeline
from langchain.llms.openai import OpenAI

run_pipeline = BasicRunPipeline(retrieval=VectorDBRetrieval(chroma_db), llm=OpenAI())

question = "Type your own question at here"
answer = run_pipeline.run.invoke({"question": question})
print(answer)

While running above code, retrieval automatically retrieve related passages to your question. And, it uses OpenAI model, generate great answer to your question according to retrieved passages in your text file.

That's it! Now you can do question&answering about your files using LLM.

Unlock power of RAGchain

Plus, you can load various kind of files, embed contents with embedding models, store vectors at various vector stores which compatible with Langchain. Also, you can use Langchain LCEL with RAGchain, so using various LLM models is really easy.

Then, you can ingest file. Prepare your .txt file. And run like below.

In this example, we use for simple saving to local disk. And use for ingesting .txt file. And we use VectorDBRetrieval for simple dense passage retireval. As vector db, we use .

When you run above code, automatically load your .txt file, split into passages, and save it to DB. Also, passage contents embeds to vector represnetation and save to Chroma vector DB.

After ingestion, you can simply run RAG workflow using like below.

You can use various kind of , , . Also, you can use whole workflow easily using another .

Lastly, please feel free to ask and contribute to RAGchain at in our git repo!

Installation guide.
pipeline
BasicIngestPipeline
BasicRunPipeline
Linker
RedisDB
DynamoDB
JSON file
BasicIngestPipeline
PickleDB
TextLoader
ChromaSlim
BasicIngestPipeline
BasicRunPipeline
Retrieval
LLM
Reranker
pipelines
issues tab