Class QuestionRewriter

java.lang.Object
dev.langchain4j.adaptiverag.QuestionRewriter
All Implemented Interfaces:
Function<String,String>

public class QuestionRewriter extends Object implements Function<String,String>
This class implements a Function to rewrite questions for better vectorstore retrieval. It uses an AI language model to rephrase input questions based on semantic intent and meaning.
  • Constructor Details

    • QuestionRewriter

      public QuestionRewriter()
  • Method Details

    • apply

      public String apply(String question)
      Applies a natural language processing pipeline to improve a given question. This method uses a ChatLanguageModel with specified configuration and an LLMService to generate and invoke a new, improved question based on the provided input.
      Specified by:
      apply in interface Function<String,String>
      Parameters:
      question - The original question to be improved.
      Returns:
      A string representing the improved question.