if (FALSE) {
# text_init() # initialize the environment
text = c("Download models from HuggingFace",
"Chinese are East Asian",
"Beijing is the capital of China")
embed = text_to_vec(text, model="bert-base-cased", layers=c(0, 12))
embed
embed1 = embed$token.embed[[1]]
embed2 = embed$token.embed[[2]]
embed3 = embed$token.embed[[3]]
View(embed1)
View(embed2)
View(embed3)
View(embed$text.embed)
plot_similarity(embed1, value.color="grey")
plot_similarity(embed2, value.color="grey")
plot_similarity(embed3, value.color="grey")
plot_similarity(rbind(embed1, embed2, embed3))
}
Run the code above in your browser using DataLab