-
Notifications
You must be signed in to change notification settings - Fork 866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modular RAG - Part 1 #1603
Comments
* Establish new package for Modular RAG components. * Add new Query API, representing a query in the context of a RAG flow. * Define Retrieval package for the RAG building blocks handling the data retrieval operations. * Relocate DocumentRetriever to Retrieval package and implement VectorStoreDocumentRetriever. * Introduce RetrievalAugmentationAdvisor as the successor of QuestionAnswerAdvisor. It uses the Retrieval building blocks described in the previous point. * Make Advisor APIs null-safe and update tests accordingly. Relates to gh-spring-projects#1603 Signed-off-by: Thomas Vitale <[email protected]>
* Establish new package for Modular RAG components. * Add new Query API, representing a query in the context of a RAG flow. * Define Retrieval package for the RAG building blocks handling the data retrieval operations. * Relocate DocumentRetriever to Retrieval package and implement VectorStoreDocumentRetriever. * Introduce RetrievalAugmentationAdvisor as the successor of QuestionAnswerAdvisor. It uses the Retrieval building blocks described in the previous point. * Make Advisor APIs null-safe and update tests accordingly. Relates to gh-spring-projects#1603 Signed-off-by: Thomas Vitale <[email protected]>
* Establish new package for Modular RAG components. * Add new Query API, representing a query in the context of a RAG flow. * Define Retrieval package for the RAG building blocks handling the data retrieval operations. * Relocate DocumentRetriever to Retrieval package and implement VectorStoreDocumentRetriever. * Introduce RetrievalAugmentationAdvisor as the successor of QuestionAnswerAdvisor. It uses the Retrieval building blocks described in the previous point. * Make Advisor APIs null-safe and update tests accordingly. Relates to gh-#1603 Signed-off-by: Thomas Vitale <[email protected]>
* Add new QueryAugmentor API, a component for augmenting a user query with contextual data. * Implement ContextualQueryAugmentor that combines the content of each document and add it to the original user prompt, with support for the scenario where the context is empty. * Extend RetrievalAugmentationAdvisor to use the new augmentation building block. * Introduce utility to assist in validating arguments for prompt-related operations. Relates to gh-spring-projects#1603 Signed-off-by: Thomas Vitale <[email protected]>
* Add new QueryAugmentor API, a component for augmenting a user query with contextual data. * Implement ContextualQueryAugmentor that combines the content of each document and add it to the original user prompt, with support for the scenario where the context is empty. * Extend RetrievalAugmentationAdvisor to use the new augmentation building block. * Introduce utility to assist in validating arguments for prompt-related operations. Relates to gh-#1603 Signed-off-by: Thomas Vitale <[email protected]>
Pre-Retrieval * Introduce Pre-Retrieval Module * Define QueryTransformer API and TranslationQueryTransformer implementation * Define QueryExpander API and MultiQueryExpander implementation * Support QueryTransformer in RetrievalAugmentationAdvisor (support for QueryExpander will be in the next PR together with the needed DocumentFuser API). Improvements * Refine Retrieval and Augmentation Modules for increased robustness * Expand test coverage for both modules * Define clone() method for ChatClient.Builder Tests * Introduce “spring-ai-integration-tests” for full-fledged integration tests * Add integration tests for RAG modules * Add integration tests for RAG advisor Relates to #spring-projectsgh-1603 Signed-off-by: Thomas Vitale <[email protected]>
Query Analysis * Introduce Query Analysis Module * Define QueryTransformer API and TranslationQueryTransformer implementation * Define QueryExpander API and MultiQueryExpander implementation * Support QueryTransformer in RetrievalAugmentationAdvisor (support for QueryExpander will be in the next PR together with the needed DocumentFuser API). Improvements * Refine Retrieval and Augmentation Modules for increased robustness * Expand test coverage for both modules * Define clone() method for ChatClient.Builder Tests * Introduce “spring-ai-integration-tests” for full-fledged integration tests * Add integration tests for RAG modules * Add integration tests for RAG advisor Relates to #spring-projectsgh-1603 Signed-off-by: Thomas Vitale <[email protected]>
Query Analysis * Introduce Query Analysis Module * Define QueryTransformer API and TranslationQueryTransformer implementation * Define QueryExpander API and MultiQueryExpander implementation * Support QueryTransformer in RetrievalAugmentationAdvisor (support for QueryExpander will be in the next PR together with the needed DocumentFuser API). Improvements * Refine Retrieval and Augmentation Modules for increased robustness * Expand test coverage for both modules * Define clone() method for ChatClient.Builder Tests * Introduce “spring-ai-integration-tests” for full-fledged integration tests * Add integration tests for RAG modules * Add integration tests for RAG advisor Relates to #spring-projectsgh-1603 Signed-off-by: Thomas Vitale <[email protected]>
Query Analysis * Introduce Query Analysis Module * Define QueryTransformer API and TranslationQueryTransformer implementation * Define QueryExpander API and MultiQueryExpander implementation * Support QueryTransformer in RetrievalAugmentationAdvisor (support for QueryExpander will be in the next PR together with the needed DocumentFuser API). Improvements * Refine Retrieval and Augmentation Modules for increased robustness * Expand test coverage for both modules * Define clone() method for ChatClient.Builder Tests * Introduce “spring-ai-integration-tests” for full-fledged integration tests * Add integration tests for RAG modules * Add integration tests for RAG advisor Relates to #spring-projectsgh-1603 Signed-off-by: Thomas Vitale <[email protected]>
Query Analysis * Introduce Query Analysis Module * Define QueryTransformer API and TranslationQueryTransformer implementation * Define QueryExpander API and MultiQueryExpander implementation * Support QueryTransformer in RetrievalAugmentationAdvisor (support for QueryExpander will be in the next PR together with the needed DocumentFuser API). Improvements * Refine Retrieval and Augmentation Modules for increased robustness * Expand test coverage for both modules * Define clone() method for ChatClient.Builder Tests * Introduce “spring-ai-integration-tests” for full-fledged integration tests * Add integration tests for RAG modules * Add integration tests for RAG advisor Relates to #spring-projectsgh-1603 Signed-off-by: Thomas Vitale <[email protected]>
Query Analysis * Introduce Query Analysis Module * Define QueryTransformer API and TranslationQueryTransformer implementation * Define QueryExpander API and MultiQueryExpander implementation * Support QueryTransformer in RetrievalAugmentationAdvisor (support for QueryExpander will be in the next PR together with the needed DocumentFuser API). Improvements * Refine Retrieval and Augmentation Modules for increased robustness * Expand test coverage for both modules * Define clone() method for ChatClient.Builder Tests * Introduce “spring-ai-integration-tests” for full-fledged integration tests * Add integration tests for RAG modules * Add integration tests for RAG advisor Query Analysis * Introduce Query Analysis Module * Define QueryTransformer API and TranslationQueryTransformer implementation * Define QueryExpander API and MultiQueryExpander implementation * Support QueryTransformer in RetrievalAugmentationAdvisor (support for QueryExpander will be in the next PR together with the needed DocumentFuser API). Improvements * Refine Retrieval and Augmentation Modules for increased robustness * Expand test coverage for both modules * Define clone() method for ChatClient.Builder Tests * Introduce “spring-ai-integration-tests” for full-fledged integration tests * Add integration tests for RAG modules * Add integration tests for RAG advisor Relates to #gh-1603 Signed-off-by: Thomas Vitale <[email protected]>
Hello @ThomasVitale Thank you for opening this issue and providing detailed context about the Modular RAG architecture. While exploring the current documentation, I noticed that QuestionAnswerAdvisor is still described as the advisor for RAG flows (e.g., in the Spring AI documentation). However, this issue outlines the creation of a new RetrievalAugmentationAdvisor and its integration with modular components. Could you elaborate on the reasoning behind moving away from QuestionAnswerAdvisor? Is it primarily about achieving better modularity, or are there limitations in the existing implementation that the new approach aims to address? Additionally, if I missed something in the issue description regarding the specific differences or advantages of the new advisor, I'd appreciate any clarification. Thank you for your work on this! |
Pre-Retrieval: * Consolidated naming and documentation Retrieval: * Consolidated naming and documentation * Introduced DocumentJoiner sub-module and CompositionDocumentJoiner operator Post-Retrieval: * Introduced main interfaces for sub-modules. Implementation waiting for missing features in Document APIs Orchestration: * Introduced QueryRouter sub-module and AllDocumentRetrieversQueryRouter operator Generation: * Consolidated naming and documentation Advisor: * Introduced BaseAdvisor to reduce boilerplate when implementing Advisors * Extended RetrievalAugmentationAdvisor to include the new sub-modules Relates to #spring-projectsgh-1603
Pre-Retrieval: * Consolidated naming and documentation Retrieval: * Consolidated naming and documentation * Introduced DocumentJoiner sub-module and CompositionDocumentJoiner operator Post-Retrieval: * Introduced main interfaces for sub-modules. Implementation waiting for missing features in Document APIs Orchestration: * Introduced QueryRouter sub-module and AllDocumentRetrieversQueryRouter operator Generation: * Consolidated naming and documentation Advisor: * Introduced BaseAdvisor to reduce boilerplate when implementing Advisors * Extended RetrievalAugmentationAdvisor to include the new sub-modules Relates to #gh-1603
@LuizyHub thanks for the interest! The Modular RAG work is still in progress for now. Once it's ready, we will provide detailed documentation and guidance on how to use these new components, including information on how the QuestionAnswerAdvisor is different and the reasoning behind this new solution. Some initial part has been included in the M4 release and it's described here: https://spring.io/blog/2024/11/20/spring-ai-1-0-0-m4-released#advanced-and-modular-rag Please, notice that this is still in preview/experimental. I have some examples here: https://github.com/ThomasVitale/llm-apps-java-spring-ai?tab=readme-ov-file#-retrieval-augmented-generation-rag If you give it a try, we would be happy to receive any feedback to improve the solution before reaching a final version for the GA release. Thank you! |
The scope in this part 1 has been included in the M4 release. Next steps will be covered in #1811, so I'm closing this issue. |
Can the changes to Modular RAG be updated in the document? I couldn't find these changes or example code in the official documentation. |
This issue will track the first part of the adoption of the Modular RAG architecture in Spring AI.
Context
The work can be split into two categories.
org.springframework.ai.rag
package. Each component is well encapsulated and can be used by itself to compose any kind of RAG flow. For example, you can use such components to build your own RAG flows using Spring State Machine, Spring Cloud Function or Spring Cloud Data Flow.RetrievalAugmentationAdvisor
will be implemented to provide some out-of-the-box RAG flows using the building blocks defined in the previous category.For background information, please refer to the following sources:
Design
Modules
In this first part, the focus will be on establishing the following modules and submodules:
This issue will be updated as we progress with the design and implementation work.
Advisor
In this first part, the focus will be on:
RetrievalAugmentationAdvisor
.The text was updated successfully, but these errors were encountered: