Description Usage Arguments Value Examples
Load a BERT-like Transformer model stored on disk
1 | BERT(model_name, path = system.file(package = "golgotha", "models"))
|
model_name |
character string with the name of the model. E.g. 'bert-base-uncased', 'bert-base-multilingual-uncased', 'bert-base-multilingual-cased', 'bert-base-dutch-cased'. Defaults to 'bert-base-multilingual-uncased'. |
path |
path to a directory on disk where the model is stored |
the directory where the model is saved to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | bert_download_model("bert-base-multilingual-uncased")
model <- BERT("bert-base-multilingual-uncased")
x <- data.frame(doc_id = c("doc_1", "doc_2"),
text = c("provide some words to embed", "another sentence of text"),
stringsAsFactors = FALSE)
predict(model, x, type = "tokenise")
embedding <- predict(model, x, type = "embed-sentence")
dim(embedding)
embedding <- predict(model, x, type = "embed-token")
str(embedding)
model_dir <- file.path(getwd(), "inst", "models")
bert_download_model("bert-base-multilingual-uncased", path = model_dir)
path <- file.path(getwd(), "inst", "models", "bert-base-multilingual-uncased")
model <- BERT(model_name = "bert-base-multilingual-uncased", path = path)
unlink(file.path(system.file(package = "golgotha", "models"),
"bert-base-multilingual-uncased"), recursive = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.