rag
command group is a specialized set of commands within our CLI tool designed for reranking documents to assess the performance of the Retrieval-Augmented Generation (RAG) retrieval system. This functionality is critical for evaluating the efficiency and accuracy of both the retrieval component and the reranker of the RAG system. It is important to note that due to the resource-intensive nature of the reranking operation, these commands should not be used in inference scenarios. Instead, their use is recommended exclusively for performance evaluation purposes.
text
, id
, and optionally score
, where text
includes the document contents, id
is a unique identifier for each document, and score
represents the retrieval score from the RAG system for each document. Each document should be less than 5000 tokens to ensure they fit in our context window. Below is an example filename for such a CSV file rag_retrievals.csv
:text | id | score |
---|---|---|
Document Text 1 | 12345 | 0.92 |
Document Text 2 | 56789 | 0.87 |
… | … | … |
Document Text 10 | 32556 | 0.95 |
--light-ranking
option to false
produces more accurate results but is more resource intensive. You can also optionally provide a new query to be used for reranking otherwise the original query (provided above) will be used.
rag_scores_9202f8ffed7.json
file. This file includes the reranked document IDs, their scores (if originally provided), and sigmas, which indicate the confidence level of each score. The documents are ordered such that the one with the highest score appears first. If scores were provided in the uploaded file, the file also provides the Spearman correlation coefficient (corr), which measures the correlation between the rankings as specified by the scores in the uploaded CSV and the reranked documents, and the “top_10_percent_accuracy” value, representing the percentage of documents that were in the top 10% of the original retrieval and remained in the top 10% after reranking. If scores are not provided in the uploaded file, the corr
and top_10_percent_accuracy
fields will not be included in the output JSON.
upload
upload
command is specifically crafted to upload a CSV file containing documents retrieved by the RAG system. This functionality is crucial for the initial step of the reranking and evaluation workflow. Upon successful upload, it returns a unique ID to the client, which can be used for subsequent operations related to reranking and evaluation.
vals rag upload
command, specify the path to the CSV file containing the documents you wish to evaluate as well as the query used to retrieve the documents. For example:
<file path>
: The path to the CSV file containing the documents to be reranked and evaluated. This file must include two columns:
text
: Contains the document text.id
: A unique identifier for each document.<query>
: The text query used to retrieve the documents.rerank
rerank
command is designed to rerank documents within a file, based on a provided query. This command targets documents that have been previously uploaded using the upload
command and identified by a unique file ID. By applying the reranking process, it aims to reorder the documents according to their relevance to the given query.
Upon successful execution, the command writes a JSON file containing the scores that match the order of the documents in the uploaded file. The JSON file is saved to the system, and its location is printed to the console, indicating the successful completion of the reranking process.
<id>
: The ID of the rag suite containing the documents to be reranked. This ID is obtained from the output of the upload
command. If no id is provided you will be prompted to choose an available rag suite.--query=<string>
: The query string used for reranking the documents. If not provided, the original query will be used.--light-ranking=<bool>
: Specifies whether to use light ranking. Defaults to True
. Light ranking is a less resource-intensive method, though it may yield less accurate results compared to more comprehensive approaches.--model=<string>
: Specifies the model to be used for reranking. Valid options are “gpt-3”, “gpt-4”, or “llama”. This option allows for the selection of different models, depending on the requirements of the reranking process. The default model is “gpt-3”.