Skip to content

Commit e85e4ab

Browse files
authored
Update RAGTools docstrings
add names of the corresponding methods to various structs (same as using methodswith...)
1 parent 20a8447 commit e85e4ab

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/Experimental/RAGTools/generation.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ struct NoRefiner <: AbstractRefiner end
150150
"""
151151
SimpleRefiner <: AbstractRefiner
152152
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!`.
154154
"""
155155
struct SimpleRefiner <: AbstractRefiner end
156156

157157
"""
158158
TavilySearchRefiner <: AbstractRefiner
159159
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!`.
161161
"""
162162
struct TavilySearchRefiner <: AbstractRefiner end
163163

@@ -172,7 +172,7 @@ end
172172
refiner::NoRefiner, index::AbstractChunkIndex, result::AbstractRAGResult;
173173
kwargs...)
174174
175-
Simple no-op function for `refine`. It simply copies the `result.answer` and `result.conversations[:answer]` without any changes.
175+
Simple no-op function for `refine!`. It simply copies the `result.answer` and `result.conversations[:answer]` without any changes.
176176
"""
177177
function refine!(
178178
refiner::NoRefiner, index::AbstractDocumentIndex, result::AbstractRAGResult;
@@ -511,7 +511,7 @@ end
511511
"""
512512
RAGConfig <: AbstractRAGConfig
513513
514-
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`.
515515
516516
To customize the components, replace corresponding fields for each step of the RAG pipeline (eg, use `subtypes(AbstractIndexBuilder)` to find the available options).
517517
"""

src/Experimental/RAGTools/preparation.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct NoProcessor <: AbstractProcessor end
5252
"""
5353
BinaryBatchEmbedder <: AbstractEmbedder
5454
55-
Same as `BatchEmbedder` but reduces the embeddings matrix to a binary form (eg, `BitMatrix`).
55+
Same as `BatchEmbedder` but reduces the embeddings matrix to a binary form (eg, `BitMatrix`). Defines a method for `get_embeddings`.
5656
5757
Reference: [HuggingFace: Embedding Quantization](https://huggingface.co/blog/embedding-quantization#binary-quantization-in-vector-databases).
5858
"""
@@ -61,7 +61,7 @@ struct BinaryBatchEmbedder <: AbstractEmbedder end
6161
"""
6262
BitPackedBatchEmbedder <: AbstractEmbedder
6363
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`.
6565
6666
See also utilities `pack_bits` and `unpack_bits` to move between packed/non-packed binary forms.
6767
@@ -146,7 +146,7 @@ function _normalize end
146146
load_text(chunker::AbstractChunker, input;
147147
kwargs...)
148148
149-
Load text from `input` using the provided `chunker`
149+
Load text from `input` using the provided `chunker`. Called by `get_chunks`.
150150
151151
Available chunkers:
152152
- `FileChunker`: The function opens each file in `input` and reads its contents.

src/Experimental/RAGTools/retrieval.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ struct NoRephraser <: AbstractRephraser end
1010
"""
1111
SimpleRephraser <: AbstractRephraser
1212
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`.
1414
"""
1515
struct SimpleRephraser <: AbstractRephraser end
1616

1717
"""
1818
HyDERephraser <: AbstractRephraser
1919
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`.
2121
2222
It uses a prompt-based rephrasing method called HyDE (Hypothetical Document Embedding), where instead of looking for an embedding of the question,
2323
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
2929
"""
3030
CosineSimilarity <: AbstractSimilarityFinder
3131
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).
3333
"""
3434
struct CosineSimilarity <: AbstractSimilarityFinder end
3535

3636
"""
3737
BinaryCosineSimilarity <: AbstractSimilarityFinder
3838
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.
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`.
4040
4141
It follows the two-pass approach:
4242
- 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
4949
"""
5050
BitPackedCosineSimilarity <: AbstractSimilarityFinder
5151
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.
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`.
5353
5454
The difference to `BinaryCosineSimilarity` is that the binary values are packed into UInt64, which is more efficient.
5555
@@ -61,7 +61,7 @@ struct BitPackedCosineSimilarity <: AbstractSimilarityFinder end
6161
"""
6262
BM25Similarity <: AbstractSimilarityFinder
6363
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`.
6565
6666
Reference: [Wikipedia: BM25](https://en.wikipedia.org/wiki/Okapi_BM25).
6767
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
7171
"""
7272
MultiFinder <: AbstractSimilarityFinder
7373
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`.
7575
Positions correspond to `indexes(::MultiIndex)`.
7676
"""
7777
struct MultiFinder <: AbstractSimilarityFinder
@@ -91,14 +91,14 @@ struct NoTagFilter <: AbstractTagFilter end
9191
"""
9292
AnyTagFilter <: AbstractTagFilter
9393
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`.
9595
"""
9696
struct AnyTagFilter <: AbstractTagFilter end
9797

9898
"""
9999
AllTagFilter <: AbstractTagFilter
100100
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`.
102102
"""
103103
struct AllTagFilter <: AbstractTagFilter end
104104

@@ -622,14 +622,14 @@ struct NoReranker <: AbstractReranker end
622622
"""
623623
CohereReranker <: AbstractReranker
624624
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`.
626626
"""
627627
struct CohereReranker <: AbstractReranker end
628628

629629
"""
630630
FlashRanker <: AbstractReranker
631631
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`.
633633
634634
You must first import the FlashRank.jl package.
635635
To automatically download any required models, set your
@@ -659,7 +659,7 @@ end
659659
"""
660660
RankGPTReranker <: AbstractReranker
661661
662-
Rerank strategy using the RankGPT algorithm (calling LLMs).
662+
Rerank strategy using the RankGPT algorithm (calling LLMs). A method for `rerank`.
663663
664664
# Reference
665665
[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
869869
"""
870870
SimpleRetriever <: AbstractRetriever
871871
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.
873873
874874
Make sure to use consistent `embedder` and `tagger` with the Preparation Stage (`build_index`)!
875875

0 commit comments

Comments
 (0)