as.lm_topic_labels {topiclabels}R Documentation

lm_topic_labels object

Description

Constructor for lm_topic_labels objects used in this package.

Usage

as.lm_topic_labels(
  x,
  terms,
  prompts,
  model,
  params,
  with_token,
  time,
  model_output,
  labels
)

is.lm_topic_labels(obj, verbose = FALSE)

Arguments

x

[named list]
lm_topic_labels object. Alternatively each element can be passed for individual results. Individually set elements overwrite elements from x.

terms

[list(n) of character]
List of character vectors, whereas each vector represents the top terms of a topic. Topics may consist of different numbers of top terms.

prompts

[character(n)]
Optional.
Each entry of the character vector contains the original prompt that was used to obtain the corresponding entry of model_output.

model

[character(1)]
The language model used for labeling the topics.

params

[named list]
Optional.
Model parameters passed.

with_token

[logical(1)]
Optional.
Was the labeling executed using a Huggingface token?

time

[numeric(1)]
Optional.
Time needed for the labeling.

model_output

[character(n)]
Optional.
Each entry of the character vector contains the original model output obtained using the corresponding prompt from prompts.

labels

[character(n)]
The extracted labels from model_output.

obj

[R object]
Object to test.

verbose

[logical(1)]
Should test information be given in the console?

Details

If you call as.lm_topic_labels on an object x which already is of the structure of a lm_topic_labels object (in particular a lm_topic_labels object itself), the additional arguments id, param, ... may be used to override the specific elements.

Value

[named list] lm_topic_labels object.

Examples

## Not run: 
token = "" # please insert your hf token here
topwords_matrix = matrix(c("zidane", "figo", "kroos",
                           "gas", "power", "wind"), ncol = 2)
obj = label_topics(topwords_matrix, token = token)
obj$model
obj_modified = as.lm_topic_labels(obj, model = "It is possible to modify individual entries")
obj_modified$model

obj_modified$model = 3.5 # example for an invalid modification
is.lm_topic_labels(obj_modified, verbose = TRUE)

obj_manual = as.lm_topic_labels(terms = list(c("zidane", "figo", "kroos"),
                                             c("gas", "power", "wind")),
                                model = "manual labels",
                                labels = c("Football Players", "Energy Supply"))

## End(Not run)

[Package topiclabels version 0.1.0 Index]