Overview
TheDefaultRAGStrategy (also known as PassageTripleStrategy) is the default RAG strategy for standard OpenIE-based extraction. It uses traditional triple extraction (subject-predicate-object) from documents.
Class Definition
Methods
index()
Index documents using standard OpenIE approach.docs(List[str]): List of documents to index
- Calls the original OpenIE indexing logic from
ReMem.index_original() - Extracts triples (subject-predicate-object) from documents
- Creates knowledge graph with phrase and passage nodes
- Builds embeddings for efficient retrieval
rag_for_qa()
Perform question-answering using standard RAG approach.queries: Input queries (strings or QuerySolution objects)num_to_retrieve(int): Number of documents to retrieve per query (default: 5)gold_answers(optional): Gold standard answers for evaluationgold_docs(optional): Gold standard documents for evaluationmetrics(tuple): Evaluation metrics to computequestion_metadata(optional): Additional metadata for questionsto_save(bool): Whether to save retrieval and QA results (default: True)**kwargs: Additional parameters
- Tuple containing:
List[QuerySolution]: Query solutions with retrieved documents and answersList[str]: Response messages from the QA modelList[Dict]: Metadata for each responseDict: Retrieval metrics (e.g., retrieval recall)Dict: QA metrics (e.g., exact match, F1 score)
- Retrieves relevant documents using graph-based retrieval
- Evaluates retrieval performance if gold documents provided
- Performs question-answering using retrieved context
- Evaluates QA performance if gold answers provided
- Saves results if
to_save=True
retrieve_each_query()
Retrieve documents for a single query using the default approach.query(str): Input queryreturn_chunk(optional): Type of chunk to return (e.g.,"passage","triple")
- Retrieved documents and their similarity scores
- Uses the default
retrieve_each_query_originalimplementation - Leverages graph-based retrieval with embeddings
- Returns passages or triples based on
return_chunkparameter
Use Cases
TheDefaultRAGStrategy is ideal for:
- Structured Knowledge Extraction: When you need to extract factual triples from documents
- General-Purpose QA: Standard question-answering over document collections
- Knowledge Graph Construction: Building knowledge graphs from unstructured text
- Fact Verification: Retrieving supporting evidence for claims