hf_sentence_encode: Use a Sentence Transformers pipeline to extract...

View source: R/sentence-transformers.R

hf_sentence_encodeR Documentation

Use a Sentence Transformers pipeline to extract document(s)/sentence(s) embedding(s)

Description

Use a Sentence Transformers pipeline to extract document(s)/sentence(s) embedding(s)

Usage

hf_sentence_encode(
  model,
  text,
  batch_size = 64L,
  show_progress_bar = TRUE,
  tidy = TRUE,
  ...
)

Arguments

model

Model object you loaded with 'hf_load_sentence_model()'

text

The text, or texts, you wish to embed/encode.

batch_size

How many texts to embed at once.

show_progress_bar

Whether to print a progress bar in the console or not.

tidy

Whether to tidy the output into a tibble or not.

...

other args sent to the model's encode method, e.g. device = device

Value

n-dimensional embeddings for every input 'text'

Examples

## Not run: 
text <- c("There are things we do know, things we don't know, and then there is quantum mechanics.")
sentence_mod <- hf_load_sentence_model("paraphrase-MiniLM-L6-v2")
embeddings <- hf_sentence_encode(model = sentence_mod, text, show_progress_bar = TRUE)

## End(Not run)

farach/huggingfaceR documentation built on Feb. 4, 2023, 10:31 p.m.