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
  • Overview
  • Usage
  • 1. Make PickleDB Instance
  • 2. Use create_or_load
  • 3. Save Passage
  • 4. Fetch Data
  • 5. Search Data
  1. RAGchain Structure
  2. DB

Pickle DB

Overview

The PickleDB class is designed to interact with a local disk storage using pickle file format for storing and retrieving passage contents. It provides methods for creating, loading, saving, fetching, and searching passages in a pickle file.

Usage

1. Make PickleDB Instance

To start using the PickleDB class, you first need to create an instance of the class. You can do this by providing the path to your pickle file.

from RAGchain.DB import PickleDB

pickle_db = PickleDB(
    save_path="path/to/your/pickle/file.pkl"  # replace with your pickle file path
)

2. Use create_or_load

The create_or_load method is used to either create a new pickle file if it does not exist, or load an existing pickle file.

pickle_db.create_or_load()

3. Save Passage

passages = [...]  # replace with your list of Passage objects
pickle_db.save(passages)

4. Fetch Data

ids = [...]  # replace with your list of IDs. They can be UUID or str.
fetched_passages = pickle_db.fetch(ids)

# Print the fetched passages
for passage in fetched_passages:
    print(passage)

5. Search Data

search_results = pickle_db.search(content=["search term"])  # replace "search term" with your search term

# Print the search results
for result in search_results:
    print(result)

Please replace the placeholders with your actual data. Also, make sure that your pickle file is accessible at the provided path.

PreviousMongoDBNextReranker

Last updated 1 year ago

You can save passages to your pickle database using the save method. This method accepts a list of objects. The passages are saved to the pickle file and also to the .

The fetch method allows you to retrieve passages from your pickle database by their IDs. This method returns a list of objects.

You can search for passages in your pickle database using the search method. This method accepts filters such as passage ID, content, filepath, and metadatas, then returns a list of objects that match the filters.

Passage
Linker
Passage
Passage