diff --git a/llama-index-packs/llama-index-packs-raptor/README.md b/llama-index-packs/llama-index-packs-raptor/README.md index 4b9b07fb5a54991846d1e317d271c6359e3b035d..761205f1e87e8c013628db5cf1d117ba3a0650ec 100644 --- a/llama-index-packs/llama-index-packs-raptor/README.md +++ b/llama-index-packs/llama-index-packs-raptor/README.md @@ -76,3 +76,30 @@ retriever = RaptorRetriever([], ..., vector_store=vector_store) ``` Check out the [notebook here for complete details!](https://github.com/run-llama/llama_index/blob/main/llama-index-packs/llama-index-packs-raptor/examples/raptor.ipynb). + +## Configure Summary Module + +Using the SummaryModule you can configure how the Raptor Pack does summaries and how many workers are applied to summaries. + +You can configure the LLM. + +You can configure summary_prompt. This will change the prompt sent to your LLM to summarize you docs. + +You can configure num_workers, which will influence the number of workers or rather async semaphores allowing more summaries to process simulatneously. +This might affect openai or other LLm provider API limits, be aware. + +```python +from llama_index.packs.raptor.base import SummaryModule +from llama_index.packs.raptor import RaptorRetriever + +summary_prompt = "As a professional summarizer, create a concise and comprehensive summary of the provided text, be it an article, post, conversation, or passage with as much detail as possible." + +# Adding SummaryModule you can configure the summary prompt and number of workers doing summaries. +summary_module = SummaryModule( + llm=llm, summary_prompt=summary_prompt, num_workers=16 +) + +pack = RaptorPack( + documents, llm=llm, embed_model=embed_model, summary_module=summary_module +) +``` diff --git a/llama-index-packs/llama-index-packs-raptor/llama_index/packs/raptor/base.py b/llama-index-packs/llama-index-packs-raptor/llama_index/packs/raptor/base.py index 89a539ee07aa808e4ab138490accf4006d9a6832..4dc1834b877e08c281552234602bd3303cbe274f 100644 --- a/llama-index-packs/llama-index-packs-raptor/llama_index/packs/raptor/base.py +++ b/llama-index-packs/llama-index-packs-raptor/llama_index/packs/raptor/base.py @@ -59,13 +59,18 @@ class SummaryModule(BaseModel): arbitrary_types_allowed = True def __init__( - self, llm: Optional[LLM] = None, summary_prompt: str = DEFAULT_SUMMARY_PROMPT + self, + llm: Optional[LLM] = None, + summary_prompt: str = DEFAULT_SUMMARY_PROMPT, + num_workers: int = 4, ) -> None: response_synthesizer = get_response_synthesizer( response_mode="tree_summarize", use_async=True, llm=llm ) super().__init__( - response_synthesizer=response_synthesizer, summary_prompt=summary_prompt + response_synthesizer=response_synthesizer, + summary_prompt=summary_prompt, + num_workers=num_workers, ) async def generate_summaries( diff --git a/llama-index-packs/llama-index-packs-raptor/pyproject.toml b/llama-index-packs/llama-index-packs-raptor/pyproject.toml index 3745f6e992d0e3e500179b37b4117d3e1d28d6bc..d786a25517fdbd6070bf82ba5228c3ac06f3b40e 100644 --- a/llama-index-packs/llama-index-packs-raptor/pyproject.toml +++ b/llama-index-packs/llama-index-packs-raptor/pyproject.toml @@ -31,7 +31,7 @@ license = "MIT" name = "llama-index-packs-raptor" packages = [{include = "llama_index/"}] readme = "README.md" -version = "0.1.2" +version = "0.1.3" [tool.poetry.dependencies] python = ">=3.9,<4.0"