| setup_cache | R Documentation |
Stores the Python environment, Python itself and the Hugging Face models in one folder, and optionally runs without network access. This is the route for HPC clusters: prepare the folder on a login node with internet access, then use it offline on compute nodes.
setup_cache(path, offline = FALSE, gpu = NULL)
path |
Folder for the caches, for example on project or scratch storage shared by login and compute nodes. It needs several GB and must be writable. |
offline |
Logical. Use only what is already in the cache, with no
network access (sets |
gpu |
Logical or |
Call setup_cache() in a new R session, after
library(transforEmotion) and before any analysis. It sets these
environment variables for the session:
UV_CACHE_DIRuv package cache and Python environments
UV_PYTHON_INSTALL_DIR, UV_PYTHON_PREFERENCEa Python interpreter kept in the cache, so compute nodes do not need one
HF_HOMEHugging Face models
R_USER_CACHE_DIRreticulate's own copy of uv and the NLTK
data used by rag(). This also moves the cache of any other R
package that uses tools::R_user_dir() in this session.
Offline sessions can use any combination of the feature sets prepared
with setup_modules(), and any model it downloaded.
The cache must stay writable, because uv locks it even when reusing an
environment. For read-only environments such as Apptainer images, build a
fixed Python environment instead (see python_requirements).
Invisibly, a named character vector of the environment variables set.
## Not run:
# On a login node, with internet access
library(transforEmotion)
setup_cache("/project/mylab/transforEmotion-cache", gpu = TRUE)
setup_modules(extras = "rag", models = "facebook/bart-large-mnli")
# In a job on a compute node, without internet access
library(transforEmotion)
setup_cache("/project/mylab/transforEmotion-cache", offline = TRUE, gpu = TRUE)
transformer_scores(text, classes, transformer = "facebook-bart")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.