please explain these steps like i am a layperson: ""RAPTOR: Recursive Abstractive…
- User
please explain these steps like i am a layperson: ""RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval RAPTOR introduces a novel approach to retrieval-augmented language models by constructing a recursive tree structure from documents. This allows for more efficient and context-aware information retrieval across large texts, addressing common limitations in traditional language models.
For detailed methodologies and implementations, refer to the original paper:
RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval Paper page PWC
Installation Before using RAPTOR, ensure Python 3.8+ is installed. Clone the RAPTOR repository and install necessary dependencies:
git clone https://github.com/parthsarthi03/raptor.git cd raptor pip install -r requirements.txt Basic Usage To get started with RAPTOR, follow these steps:
Setting Up RAPTOR First, set your OpenAI API key and initialize the RAPTOR configuration:
import os os.environ["OPENAI_API_KEY"] = "your-openai-api-key"
from raptor import RetrievalAugmentation
Initialize with default configuration. For advanced configurations, check the documentation. [WIP]
RA = RetrievalAugmentation() Adding Documents to the Tree Add your text documents to RAPTOR for indexing:
with open('sample.txt', 'r') as file: text = file.read() RA.add_documents(text) Answering Questions You can now use RAPTOR to answer questions based on the indexed documents:
question = "How did Cinderella reach her happy ending?" answer = RA.answer_question(question=question) print("Answer: ", answer) Saving and Loading the Tree Save the constructed tree to a specified path:
SAVE_PATH = "demo/cinderella" RA.save(SAVE_PATH) Load the saved tree back into RAPTOR:
RA = RetrievalAugmentation(tree=SAVE_PATH) answer = RA.answer_question(question=question)""
- Assistant
- User
can you represent that tree using ascii art?
- Assistant
Sure, let's create a simple ASCII art representation of how a tree structure might look when RAPTOR organizes information. Imagine each node in the tree as a piece of information or a document, with the root being the main topic or starting point, and branches leading to more specific topics or sub-documents. Here's a basic example:
[ Root: Main Topic ] | ----------------------------------------- | | | [ Branch: Subtopic A ] [ Subtopic B ] [ Subtopic C ] | --------------------- | | | [ Leaf: Detail A ] [ Detail B ] [ Detail C ]- Root: The main topic or the starting point of your search.
- Branches: These represent subtopics or categories under the main topic.
- Leaves: The most specific pieces of information, akin to answers or detailed contents within the subtopics.
- User
can you be a bit more creative/illustrative please
- Assistant
Sure! Let's jazz it up a bit with a more illustrative and whimsical representation. Imagine we're looking into RAPTOR's magical forest of knowledge:
[ 🌳 Magical Knowledge Tree 🌳 ] / | \ / | \ / | \ / | \ 📚 🗂️ 📖 🗂️ 📚 / | \ / | \ / | \ / | \ / | \ / | \ 📄 📄 📄 📄 📄 📄 📄 📄 📄 📄 📄 📄 / \ 🧩 🧩 "Definition" "Examples" - User
how is RAPTOR able to find the information we want so effectively?
- Assistant
- User
what does a MIT license allow you to do?
- Assistant
The MIT License is one of the most popular open-source licenses out there, known for its simplicity and permissive nature. Here's what it essentially allows you to do, using less technical language:
1. Use it freely:
You can use the software (or code) in personal, educational, or commercial projects without any specific permission. It's like someone handing you a tool and saying, "Feel free to use this for whatever you're building!"
- User
Can you explain this to me: ""RAPTOR takes a single text file to build a tree. If you want to pass in multiple documents, concatenate them to a single string before passing it to RA.add_documents(text). We are working on better support for multiple document handling and adding to the tree.""
- Assistant
Sure, I'll explain this in a straightforward manner:
Imagine you have a bunch of different LEGO sets (your multiple documents), and you want to build one big castle (the tree structure) out of them. Right now, the way RAPTOR works is a bit like it can only understand instructions for building something when all the pieces are mixed into one big box (a single text file) rather than handling several boxes at once.
- User
You're doing a great job! Explain the following: "":Comparison of querying methods. Results on 20 stories from the QASPER dataset using tree traversal with different top-k values, and collapsed tree with different context lengths. Collapsed tree with 2000 tokens produces the best results, so we use this querying strategy for our main results. Overall, given the collapsed tree approach’s greater flexibility and its superior performance on the subset of the QASPER dataset, this is the querying approach with which we proceed. Specifically, we use the collapsed tree with 2000 maximum tokens, which approximately equates to retrieving the top-20 nodes. Using a token-based approach ensures the context does not exceed model context constraints as token counts can vary across nodes. For experiments with the UnifiedQA model, we provide 400 tokens of context, as UnifiedQA has a max context length of 512 tokens. We provide the same amount of tokens of context to RAPTOR and to the baselines.""
- Assistant
- User
Again please, for this text: ""4Experiments Datasets We measure RAPTOR’s performance across three question-answering datasets: NarrativeQA, QASPER, and QuALITY.
NarrativeQA is a dataset that comprises question-answer pairs based on the full texts of books and movie transcripts, totaling 1,572 documents (Kočiskỳ et al., 2018; Wu et al., 2021). The NarrativeQA-Story task requires a comprehensive understanding of the entire narrative in order to accurately answer its questions, thus testing the model’s ability to comprehend longer texts in the literary domain. We measure performance on this dataset using the standard BLEU (B-1, B-4), ROUGE (R-L), and METEOR (M) metrics. Please see appendix H for more details on the NarrativeQA evaluation script used in our experiments.
The QASPER dataset includes 5,049 questions across 1,585 NLP papers, with each question probing for information embedded within the full text (Dasigi et al., 2021). The answer types in QASPER are categorized as Answerable/Unanswerable, Yes/No, Abstractive, and Extractive. Accuracy is measured using standard F1.
- Assistant
- User
Again: ""Comparison to State-of-the-art Systems Building upon our controlled comparisons, we examine RAPTOR’s performance relative to other state-of-the-art models. As shown in Table 5, RAPTOR with GPT-4 sets a new benchmark on QASPER, with a 55.7% F-1 score, surpassing the CoLT5 XL’s score of 53.9%.
In the QuALITY dataset, as shown in Table 7, RAPTOR paired with GPT-4 sets a new state-of-the-art with an accuracy of 82.6%, surpassing the previous best result of 62.3%. In particular, it outperforms CoLISA by 21.5% on QuALITY-HARD, which represents questions that humans took unusually long to correctly answer, requiring rereading parts of the text, difficult reasoning, or both.
- Assistant
- User
""...RAPTOR achieves an astonishing victory with an 82.6% accuracy, leaving the previous top performer, CoLISA, behind at 62.3%. RAPTOR shows incredible prowess, especially in the “hard mode,” improving the previous best by 21.5%."" What are the broader implications of this AMAZING result?
- Assistant
- User
- Assistant
- User
T play devils advocate here is an extra from the RAPTOR's paper where the authors mention: ""Nair et al. (2023) highlights a potential shortcoming: contiguous segmentation might not capture the complete semantic depth of the text. Reading extracted snippets from technical or scientific documents may lack important context making them difficult to read or even misleading. (Cohan & Goharian, 2017; Newman et al., 2023; Zhang et al., 2023).""
- Assistant
- User
Actually, I was trying to point out or suggest that Cohere's reranking system's contiguous segmentation might perhaps presents challenges to capture complete semantic depth of complete texts. Or can this not be true? Does Cohere segment the text or just analyze the already segmented text?
- Assistant
- User
- Assistant
- User
Yet, the authors of the RAPTOR paper point this out: ""Recursive summarization as Context Summarization techniques provide a condensed view of documents, enabling more focused engagement with the content (Angelidis & Lapata, 2018). The summarization/snippet model by Gao et al. (2023) uses summarizations and snippets of passages, which improves correctness on most datasets but can sometimes be a lossy means of compression. The recursive-abstractive summarization model by Wu et al. (2021) employs task decomposition to summarize smaller text chunks, which are later integrated to form summaries of larger sections. While this method is effective for capturing broader themes, it can miss granular details. LlamaIndex (Liu, 2022) mitigates this issue by similarly summarizing adjacent text chunks but also retaining intermediate nodes thus storing varying levels of detail, keeping granular details. However, both methods, due to their reliance on adjacency for grouping or summarizing adjacent nodes, may still overlook distant interdependencies within the text, which we can find and group with RAPTOR."" Is this passage relevant to the question of whether using Cohere's Reranking system is redundant over medium to long texts; perhaps it is even detrimental to the overall process?
- Assistant
- User
"Reranking operates on the given segments or summaries, and if vital details have been omitted during summarization, even a highly capable reranking tool could potentially prioritize semantically relevant but contextually incomplete segments." This is an interesting point. Can you expand on it with simple examples?
- Assistant
- User
if this is the case, then i think it would be best to only use RAPTOR because, to borrow a comedic term, using Cohere's Reanking tool in addition to RAPTOR would be like 'putting a hat on a hat'. In other words, there would be no benefit and actually may be detrimental because of extra inference costs and processing time.
- Assistant
- User
At this point in the discussion, i am leaning towards only using RAPTOR for data retrieval needs. Here is some more text from the authors of the paper that have swayed me to the superiority of their method: ""Overview of RAPTOR Building on the idea that long texts often present subtopics and hierarchical structures (Cao & Wang, 2022; Dong et al., 2023b), RAPTOR addresses the issue of semantic depth and connection in reading by building a recursive tree structure that balances broader thematic comprehension with granular details and which allows nodes to be grouped based on semantic similarity not just order in the text.
Construction of the RAPTOR tree begins with segmenting the retrieval corpus into short, contiguous texts of length 100, similar to traditional retrieval augmentation techniques. If a sentence exceeds the 100-token limit, we move the entire sentence to the next chunk, rather than cutting it mid-sentence. This preserves the contextual and semantic coherence of the text within each chunk. These texts are then embedded using SBERT, a BERT-based encoder (multi-qa-mpnet-base-cos-v1) (Reimers & Gurevych, 2019). The chunks and their corresponding SBERT embeddings form the leaf nodes of our tree structure.
- Assistant
- User
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.