View Source Rag.Retrieval (rag v0.1.0)
Functions to transform retrieval results.
Summary
Functions
Gets the retrieval result for each key in retrieval_result_keys from generation.
Then, appends the retrieval result to the list at output_key.
Deduplicates entries at entries_keys in retrieval_results of generation.
Two entries are considered duplicates if they hold the same value at all unique_by_keys.
In case of duplicates, the first entry is kept.
Gets the retrieval result for each key in retrieval_result_keys from retrieval.
Then, applies Reciprocal Rank Fusion to combine the retrieval results into a single list at output_key.
There is no guaranteed order for results with the same score.
Calls retrieval_function with generation as only argument.
retrieval_function must return only the retrieval result.
The main purpose of retrieve/3 is to emit telemetry events.
Functions
Gets the retrieval result for each key in retrieval_result_keys from generation.
Then, appends the retrieval result to the list at output_key.
@spec deduplicate(Rag.Generation.t(), atom(), [atom()]) :: Rag.Generation.t()
Deduplicates entries at entries_keys in retrieval_results of generation.
Two entries are considered duplicates if they hold the same value at all unique_by_keys.
In case of duplicates, the first entry is kept.
@spec reciprocal_rank_fusion( Rag.Generation.t(), %{required(key :: atom()) => weight :: integer()}, output_key :: atom(), keyword([atom()]) ) :: Rag.Generation.t()
Gets the retrieval result for each key in retrieval_result_keys from retrieval.
Then, applies Reciprocal Rank Fusion to combine the retrieval results into a single list at output_key.
There is no guaranteed order for results with the same score.
Options:
identity: list of keys which define the identity of a result. Results with sameidentitywill be fused.
@spec retrieve( Rag.Generation.t(), result_key :: atom(), (Rag.Generation.t() -> any()) ) :: Rag.Generation.t()
Calls retrieval_function with generation as only argument.
retrieval_function must return only the retrieval result.
The main purpose of retrieve/3 is to emit telemetry events.