Learn R Programming

FMAT (version 2025.4)

fill_mask: Run the fill-mask pipeline and check the raw results.

Description

Normal users should use FMAT_run(). This function is only for technical check.

Usage

fill_mask(query, model, targets = NULL, topn = 5, gpu)

fill_mask_check(query, models, targets = NULL, topn = 5, gpu)

Value

A data.table of raw results.

Arguments

query

Query sentence with mask token.

model, models

Model name(s).

targets

Target words to fill in the mask. Defaults to NULL (return the top 5 most likely words).

topn

Number of the most likely predictions to return. Defaults to 5.

gpu

Use GPU (3x faster than CPU) to run the fill-mask pipeline? Defaults to missing value that will automatically use available GPU (if not available, then use CPU). An NVIDIA GPU device (e.g., GeForce RTX Series) is required to use GPU. See Guidance for GPU Acceleration.

Options passing to the device parameter in Python:

  • FALSE: CPU (device = -1).

  • TRUE: GPU (device = 0).

  • Any other value: passing to transformers.pipeline(device=...) which defines the device (e.g., "cpu", "cuda:0", or a GPU device id like 1) on which the pipeline will be allocated.

Functions

  • fill_mask(): Check performance of one model.

  • fill_mask_check(): Check performance of multiple models.

Examples

Run this code
if (FALSE) {
query = "Paris is the [MASK] of France."
models = c("bert-base-uncased", "bert-base-cased")

d.check = fill_mask_check(query, models, topn=2)
}

Run the code above in your browser using DataLab