You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Experimental/RAGTools/generation.jl
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -150,14 +150,14 @@ struct NoRefiner <: AbstractRefiner end
150
150
"""
151
151
SimpleRefiner <: AbstractRefiner
152
152
153
-
Refines the answer using the same context previously provided via the provided prompt template.
153
+
Refines the answer using the same context previously provided via the provided prompt template. A method for `refine!`.
154
154
"""
155
155
struct SimpleRefiner <:AbstractRefinerend
156
156
157
157
"""
158
158
TavilySearchRefiner <: AbstractRefiner
159
159
160
-
Refines the answer by executing a web search using the Tavily API. This method aims to enhance the answer's accuracy and relevance by incorporating information retrieved from the web.
160
+
Refines the answer by executing a web search using the Tavily API. This method aims to enhance the answer's accuracy and relevance by incorporating information retrieved from the web. A method for `refine!`.
Default configuration for RAG. It uses `SimpleIndexer`, `SimpleRetriever`, and `SimpleGenerator` as default components.
514
+
Default configuration for RAG. It uses `SimpleIndexer`, `SimpleRetriever`, and `SimpleGenerator` as default components. Provided as the first argument in `airag`.
515
515
516
516
To customize the components, replace corresponding fields for each step of the RAG pipeline (eg, use `subtypes(AbstractIndexBuilder)` to find the available options).
@@ -61,7 +61,7 @@ struct BinaryBatchEmbedder <: AbstractEmbedder end
61
61
"""
62
62
BitPackedBatchEmbedder <: AbstractEmbedder
63
63
64
-
Same as `BatchEmbedder` but reduces the embeddings matrix to a binary form packed in UInt64 (eg, `BitMatrix.chunks`).
64
+
Same as `BatchEmbedder` but reduces the embeddings matrix to a binary form packed in UInt64 (eg, `BitMatrix.chunks`). Defines a method for `get_embeddings`.
65
65
66
66
See also utilities `pack_bits` and `unpack_bits` to move between packed/non-packed binary forms.
67
67
@@ -146,7 +146,7 @@ function _normalize end
146
146
load_text(chunker::AbstractChunker, input;
147
147
kwargs...)
148
148
149
-
Load text from `input` using the provided `chunker`
149
+
Load text from `input` using the provided `chunker`. Called by `get_chunks`.
150
150
151
151
Available chunkers:
152
152
- `FileChunker`: The function opens each file in `input` and reads its contents.
Copy file name to clipboardExpand all lines: src/Experimental/RAGTools/retrieval.jl
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -10,14 +10,14 @@ struct NoRephraser <: AbstractRephraser end
10
10
"""
11
11
SimpleRephraser <: AbstractRephraser
12
12
13
-
Rephraser implemented using the provided AI Template (eg, `...`) and standard chat model.
13
+
Rephraser implemented using the provided AI Template (eg, `...`) and standard chat model. A method for `rephrase`.
14
14
"""
15
15
struct SimpleRephraser <:AbstractRephraserend
16
16
17
17
"""
18
18
HyDERephraser <: AbstractRephraser
19
19
20
-
Rephraser implemented using the provided AI Template (eg, `...`) and standard chat model.
20
+
Rephraser implemented using the provided AI Template (eg, `...`) and standard chat model. A method for `rephrase`.
21
21
22
22
It uses a prompt-based rephrasing method called HyDE (Hypothetical Document Embedding), where instead of looking for an embedding of the question,
23
23
we look for the documents most similar to a synthetic passage that _would be_ a good answer to our question.
@@ -29,14 +29,14 @@ struct HyDERephraser <: AbstractRephraser end
29
29
"""
30
30
CosineSimilarity <: AbstractSimilarityFinder
31
31
32
-
Finds the closest chunks to a query embedding by measuring the cosine similarity between the query and the chunks' embeddings.
32
+
Finds the closest chunks to a query embedding by measuring the cosine similarity between the query and the chunks' embeddings. A method for `find_closest` (see the docstring for more details and usage example).
Finds the closest chunks to a query embedding by measuring the Hamming distance AND cosine similarity between the query and the chunks' embeddings in binary form.
39
+
Finds the closest chunks to a query embedding by measuring the Hamming distance AND cosine similarity between the query and the chunks' embeddings in binary form. A method for `find_closest`.
40
40
41
41
It follows the two-pass approach:
42
42
- First pass: Hamming distance in binary form to get the `top_k * rescore_multiplier` (ie, more than top_k) candidates.
@@ -49,7 +49,7 @@ struct BinaryCosineSimilarity <: AbstractSimilarityFinder end
Finds the closest chunks to a query embedding by measuring the Hamming distance AND cosine similarity between the query and the chunks' embeddings in binary form.
52
+
Finds the closest chunks to a query embedding by measuring the Hamming distance AND cosine similarity between the query and the chunks' embeddings in binary form. A method for `find_closest`.
53
53
54
54
The difference to `BinaryCosineSimilarity` is that the binary values are packed into UInt64, which is more efficient.
55
55
@@ -61,7 +61,7 @@ struct BitPackedCosineSimilarity <: AbstractSimilarityFinder end
61
61
"""
62
62
BM25Similarity <: AbstractSimilarityFinder
63
63
64
-
Finds the closest chunks to a query embedding by measuring the BM25 similarity between the query and the chunks' embeddings in binary form.
64
+
Finds the closest chunks to a query embedding by measuring the BM25 similarity between the query and the chunks' embeddings in binary form. A method for `find_closest`.
Implementation follows: [The Next Generation of Lucene Relevance](https://opensourceconnections.com/blog/2015/10/16/bm25-the-next-generation-of-lucene-relevation/).
@@ -71,7 +71,7 @@ struct BM25Similarity <: AbstractSimilarityFinder end
71
71
"""
72
72
MultiFinder <: AbstractSimilarityFinder
73
73
74
-
Composite finder for `MultiIndex` where we want to set multiple finders for each index.
74
+
Composite finder for `MultiIndex` where we want to set multiple finders for each index. A method for `find_closest`.
75
75
Positions correspond to `indexes(::MultiIndex)`.
76
76
"""
77
77
struct MultiFinder <:AbstractSimilarityFinder
@@ -91,14 +91,14 @@ struct NoTagFilter <: AbstractTagFilter end
91
91
"""
92
92
AnyTagFilter <: AbstractTagFilter
93
93
94
-
Finds the chunks that have ANY OF the specified tag(s).
94
+
Finds the chunks that have ANY OF the specified tag(s). A method for `find_tags`.
95
95
"""
96
96
struct AnyTagFilter <:AbstractTagFilterend
97
97
98
98
"""
99
99
AllTagFilter <: AbstractTagFilter
100
100
101
-
Finds the chunks that have ALL OF the specified tag(s).
101
+
Finds the chunks that have ALL OF the specified tag(s). A method for `find_tags`.
102
102
"""
103
103
struct AllTagFilter <:AbstractTagFilterend
104
104
@@ -622,14 +622,14 @@ struct NoReranker <: AbstractReranker end
622
622
"""
623
623
CohereReranker <: AbstractReranker
624
624
625
-
Rerank strategy using the Cohere Rerank API. Requires an API key.
625
+
Rerank strategy using the Cohere Rerank API. Requires an API key. A method for `rerank`.
626
626
"""
627
627
struct CohereReranker <:AbstractRerankerend
628
628
629
629
"""
630
630
FlashRanker <: AbstractReranker
631
631
632
-
Rerank strategy using the package FlashRank.jl and local models.
632
+
Rerank strategy using the package FlashRank.jl and local models. A method for `rerank`.
633
633
634
634
You must first import the FlashRank.jl package.
635
635
To automatically download any required models, set your
@@ -659,7 +659,7 @@ end
659
659
"""
660
660
RankGPTReranker <: AbstractReranker
661
661
662
-
Rerank strategy using the RankGPT algorithm (calling LLMs).
662
+
Rerank strategy using the RankGPT algorithm (calling LLMs). A method for `rerank`.
663
663
664
664
# Reference
665
665
[1] [Is ChatGPT Good at Search? Investigating Large Language Models as Re-Ranking Agents by W. Sun et al.](https://arxiv.org/abs/2304.09542)
@@ -869,7 +869,7 @@ end
869
869
"""
870
870
SimpleRetriever <: AbstractRetriever
871
871
872
-
Default implementation for `retrieve`. It does a simple similarity search via `CosineSimilarity` and returns the results.
872
+
Default implementation for `retrieve` function. It does a simple similarity search via `CosineSimilarity` and returns the results.
873
873
874
874
Make sure to use consistent `embedder` and `tagger` with the Preparation Stage (`build_index`)!
0 commit comments