OscarKjell / text

Using Transformers from HuggingFace in R
https://r-text.org
127 stars 30 forks source link

textPredict does not work. #177

Open moomoofarm1 opened 1 month ago

moomoofarm1 commented 1 month ago
trained_model <- textTrainRegression(
 x = word_embeddings_4$texts$harmonytext,
y = Language_based_assessment_data_8$hilstotal,
multi_cores = FALSE)

Fold: rmse 7.171 (duration: 2.77 secs). Fold: rmse 7.033 (duration: 2.8 secs). Fold: rmse 7.643 (duration: 3.12 secs). Fold: rmse 5.882 (duration: 2.79 secs). Fold: rmse 8.595 (duration: 2.88 secs). Fold: rmse 7.078 (duration: 2.82 secs). Fold: rmse 8.562 (duration: 2.74 secs). Fold: rmse 8.717 (duration: 2.73 secs). Fold: rmse 8.48 (duration: 2.74 secs). Fold: rmse 8.764 (duration: 2.76 secs). There were 21 warnings (use warnings() to see them)

text_to_predict <- "I am not in harmony in my life as much as I would like to be."
prediction3 <- textPredict(
     texts = text_to_predict,
   model_info = trained_model)

Loading model... The model has been loaded from your global environment. Completed layers output for texts (variable: 1/1, duration: 1.027426 secs). Completed layers aggregation for word_type_embeddings. Completed layers aggregation (variable 1/1, duration: 0.167070 secs). Embeddings have been saved: textPredict_3269564148.RDS

Error in UseMethod("select") : no applicable method for 'select' applied to an object of class "NULL"

prediction4 <- textPredict(texts = tibble::as_tibble(list("texts"=text_to_predict)), model_info=trained_model)

Loading model... The model has been loaded from your global environment. Embeddings have been loaded from: textPredict_3269564148.RDS Error in UseMethod("select") : no applicable method for 'select' applied to an object of class "NULL"

moomoofarm1 commented 1 month ago

With these code instead produces the same error.

trained_model <- textTrainRegression(
   x = word_embeddings_4$texts[c("satisfactiontexts", "harmonytexts")],
   y = Language_based_assessment_data_8["hilstotal"])

Fold: rmse 7.932 (duration: 7.05 secs). Fold: rmse 6.791 (duration: 7.56 secs). Fold: rmse 8.912 (duration: 7.62 secs). Fold: rmse 6.594 (duration: 8.28 secs). Fold: rmse 8.314 (duration: 7.74 secs). Fold: rmse 6.717 (duration: 6.47 secs). Fold: rmse 8.702 (duration: 5.47 secs). Fold: rmse 7.487 (duration: 4.76 secs). Fold: rmse 5.389 (duration: 3.9 secs). Fold: rmse 8.298 (duration: 3.14 secs). There were 21 warnings (use warnings() to see them)

 prediction1 <- textPredict(
   model_info = trained_model,
   texts = tibble::as_tibble(
     list("satisfactiontexts"=c("hello"),"harmoneytexts"="hi"),.name_repair = "minimal")
 )

Loading model... The model has been loaded from your global environment. Embeddings have been loaded from: textPredict_326952976.RDS Error in UseMethod("select") : no applicable method for 'select' applied to an object of class "NULL"