transformer_download_model: Download a Transformers model

Description Usage Arguments Value Examples

View source: R/embed.R

Description

Download a Transformers model

Usage

1
2
3
4
5
6
transformer_download_model(
  model_name = "bert-base-multilingual-uncased",
  architecture = "BERT",
  path = system.file(package = "golgotha", "models"),
  clean = FALSE
)

Arguments

model_name

character string of the chosen model within the architecture family. E.g. 'bert-base-uncased', 'bert-base-multilingual-uncased', 'bert-base-multilingual-cased', 'bert-base-dutch-cased' for 'BERT' architecture family. Defaults to 'bert-base-multilingual-uncased'.

architecture

character string of the model architecture family name. Currently supported architecture are 'BERT', 'GPT', 'GPT-2', 'CTRL', 'Transformer-XL', 'XLNet', 'XLM', 'DistilBERT', 'RoBERTa' and 'XLM-RoBERTa'. Defaults to 'BERT'

path

path to a directory on disk where the model will be downloaded to inside a subfolder model_name

clean

logical indicating to remove the path if it already exists. Defaults to FALSE.

Value

invisibly, the directory where the model is saved to

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
transformer_download_model("bert-base-multilingual-uncased")
transformer_download_model(architecture = "DistilBERT",
                           model_name = "distilbert-base-uncased")

path <- file.path(getwd(), "inst", "models")
transformer_download_model("bert-base-multilingual-uncased", path = path)
transformer_download_model(architecture = "DistilBERT",
                           model_name = "distilbert-base-uncased",
                           path = path)

unlink(file.path(system.file(package = "golgotha", "models"),
       "bert-base-multilingual-uncased"), recursive = TRUE)

bnosac/golgotha documentation built on May 28, 2020, 4:06 a.m.