Skip to content
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: Query Augmentor #1644

Closed

Conversation

ThomasVitale
Copy link
Contributor

@ThomasVitale ThomasVitale commented Oct 31, 2024

  • 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

It also makes possible the customization reported in #1294

* 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]>
@tzolov tzolov self-assigned this Nov 3, 2024
@tzolov tzolov added this to the 1.0.0-M4 milestone Nov 3, 2024
@tzolov tzolov added the RAG Issues related to Retrieval Augmented Generation label Nov 3, 2024
@tzolov
Copy link
Contributor

tzolov commented Nov 3, 2024

Thanks @ThomasVitale
Changes look good.

  • It reminded me that we need to make the Builder methods consistent. Some use with prefix other don't. But it seems the Spring's convention is not to have prefix (Consistent design of Options builder classes #1592 (comment))
  • After we merge this PR, we can refactor the QuedstionAnswerAdvisor as a wrapper around the RetrieverAugmentor one. Not sure if we should mark it as deprecated though.

@tzolov
Copy link
Contributor

tzolov commented Nov 3, 2024

Rebased and merged at bc50d28

@tzolov tzolov closed this Nov 3, 2024
@ThomasVitale
Copy link
Contributor Author

@tzolov thanks for the review! For the builder naming convention, I followed what was used already for ChatClient, but indeed both strategies are used throughout the project. It would be nice to converge towards one single naming strategy. I like the Spring convention of not having the prefix.

@ThomasVitale
Copy link
Contributor Author

ThomasVitale commented Nov 3, 2024

About the QuestionAnswerAdvisor, it's used a lot by developers. To protect the users from breaking changes, I would suggest keeping it as-is, mark it as deprecated, and document how to migrate to RetrievalAugmentationAdvisor. We could even provide a simple OpenRewrite recipe to automate the migration.

@tzolov
Copy link
Contributor

tzolov commented Nov 3, 2024

Makes sense.
Have not used the OpenRewrite yet and curious to see how it looks like :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RAG Issues related to Retrieval Augmented Generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants