Return the vector representation of provided words (unsupervised training) or provided labels (supervised training).

get_word_vectors(model, words = get_dictionary(model))

Arguments

model

trained fastText model

words

character of words. Default: return every word from the dictionary.

Value

matrix containing each word embedding as a row and rownames are populated with word strings.

Examples

library(fastrtext) model_test_path <- system.file("extdata", "model_unsupervised_test.bin", package = "fastrtext") model <- load_model(model_test_path) get_word_vectors(model, c("introduction", "we"))
#> [,1] [,2] [,3] [,4] [,5] [,6] #> introduction -0.4833237 0.3395640 -0.6750705 -0.3319232 0.07361547 -0.06779625 #> we -0.1988889 -0.2508739 0.3221185 -0.7944450 0.37775624 -0.82090223 #> [,7] [,8] [,9] [,10] [,11] [,12] #> introduction -0.5934200 -0.4305089 -0.0323397 -0.7466059 0.6234129 -0.06741208 #> we -0.2331725 0.1160016 0.2721905 -0.1821083 0.5980287 0.51335502 #> [,13] [,14] [,15] [,16] [,17] [,18] #> introduction -0.6575981 0.09057876 0.7003870 0.6445729 0.6496316 -0.04406938 #> we -0.2493344 -0.26671046 -0.6664425 0.6008309 0.8557160 0.49372953 #> [,19] [,20] [,21] [,22] [,23] [,24] #> introduction -0.2302708 -0.03002948 -0.2561560 0.32753003 -0.5769327 0.8342621 #> we 0.3622882 -0.40636110 0.7098193 0.02453762 0.3471284 -0.2005148 #> [,25] [,26] [,27] [,28] [,29] [,30] #> introduction -0.25508115 0.2011017 -1.1645429 0.7142252 -0.3821127 0.3016946 #> we -0.03390023 -0.2188283 0.0904853 0.2353867 -0.6503295 -0.3774806 #> [,31] [,32] [,33] [,34] [,35] [,36] #> introduction -0.86625308 -0.5501813 -0.7875243 0.13687071 -1.0305049 0.1106404 #> we 0.09119377 0.1723884 -0.1630165 0.05837286 -0.2602538 0.3449062 #> [,37] [,38] [,39] [,40] [,41] [,42] #> introduction 0.01274928 0.4865160 -0.7496957 0.01288106 -0.2765891 -0.6150211 #> we -0.98636281 0.6040778 -1.5511823 0.09542286 0.7480238 0.1427374 #> [,43] [,44] [,45] [,46] [,47] [,48] #> introduction 0.8736324 0.16321403 -0.2422450 0.3754157 -0.6342160 -0.3496657 #> we 0.1715965 0.01282036 0.7518047 0.5621423 -0.9362555 -0.2356414 #> [,49] [,50] [,51] [,52] [,53] [,54] #> introduction -0.369513959 0.2033985 -0.7202905 0.1368298 -0.7735812 0.2752217 #> we -0.009970605 0.4920772 0.1218645 -0.0272733 -0.3594590 -0.2263494 #> [,55] [,56] [,57] [,58] [,59] #> introduction 0.3694642 -0.32909945 0.10168714 0.1106216 -0.18087266 #> we -0.1563772 -0.02409485 -0.01298469 -0.2397983 0.03989857 #> [,60] [,61] [,62] [,63] [,64] [,65] #> introduction 0.01880768 -0.3259164 -0.6226392 0.4745336 -1.576974 0.6324932 #> we -1.04352760 -0.4461163 -0.9648557 0.9833742 -0.210090 -0.1111831 #> [,66] [,67] [,68] [,69] [,70] #> introduction -0.08176417 0.4251503 0.05842199 0.12738439 0.3273591 #> we -0.26236129 -0.5273805 0.11847568 0.06305289 -0.1161610