Skip to content

Modular RAG: Retrieval with Vector Stores #1604

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

Conversation

ThomasVitale
Copy link
Contributor

@ThomasVitale ThomasVitale commented Oct 26, 2024

  • 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

It might also address the requests from #1290

* 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 <ThomasVitale@users.noreply.github.com>
@ThomasVitale ThomasVitale force-pushed the rag-retrieval-vector-store branch from f5a5f07 to 31c044a Compare October 28, 2024 06:28
@markpollack markpollack added the RAG Issues related to Retrieval Augmented Generation label Oct 29, 2024
@markpollack markpollack self-assigned this Oct 29, 2024
public record AdvisedRequest(
// @formatter:off
ChatModel chatModel,
String userText,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be an odd case, but maybe should allow userText to be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a lot about a possible use case where I would want that and didn't really come up with anything. For example, OpenAI requires a message to be included in each request to a chat model. It fails if the user message is null. Before this change, we supported the user message to be null, and in that case set the "userText" to be an empty string as a workaround. That could be dangerous because as a developer I wouldn't catch scenarios where I'm not passing a user message by mistake, but the model would still be called and the outcome would be unpredictable.

// 4. Augment user prompt with the context data.
UserMessage augmentedUserMessage = (UserMessage) this.promptTemplate.createMessage(promptParameters);

return AdvisedRequest.from(request)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an issue, #1592 related to how we want to consistently implement builders. Does from go in the 'product' class or in the 'builder' class?

@markpollack
Copy link
Member

merged in 5d8c032

@markpollack markpollack added this to the 1.0.0-M4 milestone Oct 31, 2024
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