类 DefaultRetrievalAugmentor
java.lang.Object
dev.langchain4j.rag.DefaultRetrievalAugmentor
- 所有已实现的接口:
RetrievalAugmentor
The default implementation of
It's important to note that while efforts will be made to avoid breaking changes, the default behavior of this class may be updated in the future if it's found that the current behavior does not adequately serve the majority of use cases. Such changes would be made to benefit both current and future users.
This implementation is inspired by this article and this paper. It is recommended to review these resources for a better understanding of the concept.
This implementation orchestrates the flow between the following base components:
For each base component listed above, we offer several ready-to-use implementations, each based on a recognized approach. We intend to introduce more such implementations over time and welcome your contributions.
The flow is as follows:
1. A
2. Each
3. All
4. Lastly, a final list of
By default, each base component (except for
By default, query routing and content retrieval are performed concurrently (for efficiency) using
RetrievalAugmentor intended to be suitable for the majority of use cases.
It's important to note that while efforts will be made to avoid breaking changes, the default behavior of this class may be updated in the future if it's found that the current behavior does not adequately serve the majority of use cases. Such changes would be made to benefit both current and future users.
This implementation is inspired by this article and this paper. It is recommended to review these resources for a better understanding of the concept.
This implementation orchestrates the flow between the following base components:
-Visual representation of this flow can be found here.QueryTransformer-QueryRouter-ContentRetriever-ContentAggregator-ContentInjector
For each base component listed above, we offer several ready-to-use implementations, each based on a recognized approach. We intend to introduce more such implementations over time and welcome your contributions.
The flow is as follows:
1. A
Query (derived from an original UserMessage) is transformed
using a QueryTransformer into one or multiple Querys.
2. Each
Query is routed to the appropriate ContentRetriever using a QueryRouter.
Each ContentRetriever retrieves one or multiple Contents using a Query.
3. All
Contents retrieved by all ContentRetrievers using all Querys are
aggregated (fused/re-ranked/filtered/etc.) into a final list of Contents using a ContentAggregator.
4. Lastly, a final list of
Contents is injected into the original UserMessage
using a ContentInjector.
By default, each base component (except for
ContentRetriever, which needs to be provided by you)
is initialized with a sensible default implementation:
-Nonetheless, you are encouraged to use one of the advanced ready-to-use implementations or create a custom one.DefaultQueryTransformer-DefaultQueryRouter-DefaultContentAggregator-DefaultContentInjector
By default, query routing and content retrieval are performed concurrently (for efficiency) using
Executors.newCachedThreadPool(), but you can provide a custom Executor.-
嵌套类概要
嵌套类 -
构造器概要
构造器构造器说明DefaultRetrievalAugmentor(QueryTransformer queryTransformer, QueryRouter queryRouter, ContentAggregator contentAggregator, ContentInjector contentInjector, Executor executor) -
方法概要
修饰符和类型方法说明augment(UserMessage userMessage, Metadata metadata) 已过时。augment(AugmentationRequest augmentationRequest) builder()
-
构造器详细资料
-
DefaultRetrievalAugmentor
public DefaultRetrievalAugmentor(QueryTransformer queryTransformer, QueryRouter queryRouter, ContentAggregator contentAggregator, ContentInjector contentInjector, Executor executor)
-
-
方法详细资料
-
augment
已过时。useaugment(AugmentationRequest)instead.从接口复制的说明:RetrievalAugmentorAugments the providedUserMessagewith retrieved content.- 指定者:
augment在接口中RetrievalAugmentor- 参数:
userMessage- TheUserMessageto be augmented.metadata- TheMetadatathat may be useful or necessary for retrieval and augmentation.- 返回:
- The augmented
UserMessage.
-
augment
从接口复制的说明:RetrievalAugmentorAugments theChatMessageprovided in theAugmentationRequestwith retrievedContents.
This method has a default implementation in order to temporarily support current custom implementations ofRetrievalAugmentor. The default implementation will be removed soon.- 指定者:
augment在接口中RetrievalAugmentor- 参数:
augmentationRequest- TheAugmentationRequestcontaining theChatMessageto augment.- 返回:
- The
AugmentationResultcontaining the augmentedChatMessage.
-
builder
-
augment(AugmentationRequest)instead.