rag | R Documentation |
Performs retrieval-augmented generation {llama-index}
Currently limited to the TinyLLAMA model
rag(
text = NULL,
path = NULL,
transformer = c("LLAMA-2", "Mistral-7B", "OpenChat-3.5", "Orca-2", "Phi-2",
"TinyLLAMA"),
prompt = "You are an expert at extracting themes across many texts",
query,
response_mode = c("accumulate", "compact", "no_text", "refine", "simple_summarize",
"tree_summarize"),
similarity_top_k = 5,
device = c("auto", "cpu", "cuda"),
keep_in_env = TRUE,
envir = 1,
progress = TRUE
)
text |
Character vector or list.
Text in a vector or list data format.
|
path |
Character.
Path to .pdfs stored locally on your computer.
Defaults to |
transformer |
Character. Large language model to use for RAG. Available models include:
|
prompt |
Character (length = 1).
Prompt to feed into TinyLLAMA.
Defaults to |
query |
Character.
The query you'd like to know from the documents.
Defaults to |
response_mode |
Character (length = 1). Different responses generated from the model. See documentation here Defaults to |
similarity_top_k |
Numeric (length = 1).
Retrieves most representative texts given the Values will vary based on number of texts but some suggested values might be:
These values depend on the number and quality of texts. Adjust as necessary |
device |
Character.
Whether to use CPU or GPU for inference.
Defaults to |
keep_in_env |
Boolean (length = 1).
Whether the classifier should be kept in your global environment.
Defaults to |
envir |
Numeric (length = 1). Environment for the classifier to be saved for repeated use. Defaults to the global environment |
progress |
Boolean (length = 1).
Whether progress should be displayed.
Defaults to |
Returns response from TinyLLAMA
Alexander P. Christensen <alexpaulchristensen@gmail.com>
# Load data
data(neo_ipip_extraversion)
# Example text
text <- neo_ipip_extraversion$friendliness[1:5]
## Not run:
rag(
text = text,
query = "What themes are prevalent across the text?",
response_mode = "tree_summarize",
similarity_top_k = 5
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.