keep_tokens: Filter Tokens

Description Usage Arguments Value Examples

View source: R/visualize_embeddings.R

Description

Keeps only specified tokens in the given table of embeddings.

Usage

1
keep_tokens(embedding_df, tokens = "[CLS]")

Arguments

embedding_df

A tbl_df of embedding vectors; the output of extract_features.

tokens

Character vector; which tokens to keep.

Value

The input tbl_df of embedding vectors, with the specified filtering applied.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
# assuming something like the following has been run:
# feats <- RBERT::extract_features(...) # See RBERT documentation
# Then:
embeddings_layer12_cls <- feats$output %>%
    filter_layer_embeddings(layer_indices = 12L) %>%
    keep_tokens("[CLS]")

## End(Not run)

jonathanbratt/RBERTviz documentation built on June 19, 2021, 6:27 p.m.