| rag_sentemo | R Documentation |
Convenience wrapper around rag() that keeps vector retrieval but
simplifies getting structured outputs for emotion or sentiment analysis
using small local LLMs (1–4B) with sensible defaults.
rag_sentemo(
text = NULL,
path = NULL,
task = c("emotion", "sentiment"),
labels_set = NULL,
max_labels = 5,
transformer = c("TinyLLAMA", "Gemma3-1B", "Gemma3-4B", "Qwen3-1.7B", "Ministral-3B"),
similarity_top_k = 5,
response_mode = c("compact", "refine", "simple_summarize"),
output = c("table", "json", "csv"),
global_analysis = FALSE,
...
)
text |
Character vector or list. Text to analyze. One entry per document. |
path |
Character. Optional directory with files to index (e.g., PDFs).
If provided, overrides |
task |
Character. One of |
labels_set |
Character vector of allowed labels.
If |
max_labels |
Integer. Max number of labels to return. |
transformer |
Character. Small local LLM to use. One of:
|
similarity_top_k |
Integer. Retrieval depth per query. Default 5. |
response_mode |
Character. LlamaIndex response mode.
Default |
output |
Character. |
global_analysis |
Logical. If TRUE, analyze all documents jointly. Default FALSE. |
... |
Additional arguments passed to |
For Gemma3-1B/4B and output = "table"/"csv",
a data.frame with columns
doc_id, text, label, confidence.
For Gemma3-1B/4B and output = "json", a JSON array
of per-doc objects with those fields.
For other models, structured outputs are not supported;
the function falls back to output = "text" and
returns a free-text "rag" object.
## Not run:
texts <- c(
"I feel so happy and grateful today!",
"This is frustrating and makes me angry."
)
rag_sentemo(texts, task = "emotion", output = "table")
rag_sentemo(texts, task = "sentiment", output = "json")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.