How to use SentenceTransformer, a powerful and simple text embedding method based on transformer methods


SentenceTransfomer is a Python framework developed based on Sentence-BERT that can generate high-quality embedding vectors for sentences and short texts.
Many languages including English and Chinese are supported.
Compared with the BERT model, the sentencetransformer is simpler to use, and the vector can be directly obtained by passing in the text.

how to install

Recommended Python 3.6 or higher, PyTorch 1.6.0 or higher, and transformers v4.6.0 or higher developed by huggingface.
Notice that Python 2.7 environment will not work.

Sometimes, the installation may not be successful, it may be a pip version compatibility problem, you can upgrade the pip package first

python3 -m pip install –upgrade pip

then to this:

pip install -U sentence-transformers

import the package

from sentence_transformers import SentenceTransformer

English embedding example

from sentence_transformers import SentenceTransformer
model = SentenceTransformer('paraphrase-MiniLM-L6-v2')

#Our sentences we like to encode
sentences = ['This framework generates embeddings for each input sentence',
'Sentences are passed as a list of string.',
'The quick brown fox jumps over the lazy dog.']

#Sentences are encoded by calling model.encode()
embeddings = model.encode(sentences)

#Print the embeddings
for sentence, embedding in zip(sentences, embeddings):
print("Sentence:", sentence)
print("Embedding:", embedding)
print("")
Sentence: This framework generates embeddings for each input sentence
Embedding: [-1.76214531e-01  1.20601252e-01 -2.93624073e-01 -2.29858026e-01
 -8.22923928e-02  2.37709522e-01  3.39984864e-01 -7.80964196e-01
  1.18127614e-01  1.63373962e-01 -1.37715712e-01  2.40282789e-01
  4.25125599e-01  1.72417849e-01  1.05279692e-01  5.18164098e-01
  6.22218400e-02  3.99285793e-01 -1.81652278e-01 -5.85578680e-01
  4.49722409e-02 -1.72750309e-01 -2.68443495e-01 -1.47386149e-01
 -1.89217970e-01  1.92150578e-01 -3.83842468e-01 -3.96007091e-01
  4.30648863e-01 -3.15320134e-01  3.65949631e-01  6.05158620e-02
  3.57325703e-01  1.59736529e-01 -3.00983816e-01  2.63250291e-01
 -3.94311100e-01  1.84855521e-01 -3.99549276e-01 -2.67889529e-01
 -5.45117497e-01 -3.13403942e-02 -4.30644333e-01  1.33278117e-01
 -1.74793795e-01 -4.35465544e-01 -4.77379113e-01  7.12555572e-02
 -7.37001151e-02  5.69137156e-01 -2.82579720e-01  5.24975285e-02
 -8.20007861e-01  1.98296756e-01  1.69511825e-01  2.71780342e-01
  2.64610827e-01 -2.55737714e-02 -1.74096107e-01  1.63314253e-01
 -3.95260930e-01 -3.17556299e-02 -2.62556046e-01  3.52754712e-01
  3.01434875e-01 -1.47197291e-01  2.10075796e-01 -1.84010491e-01
 -4.12896037e-01  4.14775789e-01 -1.89769492e-01 -1.35482445e-01
 -3.79272133e-01 -4.68020439e-02 -3.33601385e-02  9.00394097e-02
 -3.30133140e-01 -3.87316942e-02  3.75082314e-01 -1.46996319e-01
  4.34959829e-01  5.38325727e-01 -2.65445173e-01  1.64445907e-01
  4.17078644e-01 -4.72508594e-02 -7.48731196e-02 -4.26261097e-01
 -1.96994558e-01  6.10316209e-02 -4.74262655e-01 -6.48334742e-01
  3.71462464e-01  2.50957102e-01  1.22529611e-01  8.88766572e-02
 -1.06724210e-01  5.33984490e-02  9.74507183e-02 -3.46660167e-02
 -1.02882817e-01  2.32289001e-01 -2.53739536e-01 -5.13112307e-01
  1.85216278e-01 -3.04357797e-01 -3.55209075e-02 -1.26975372e-01
 -7.71632940e-02 -5.15330076e-01 -2.28071719e-01  2.03343164e-02
  7.38175958e-02 -1.52558655e-01 -4.00837570e-01 -2.47749180e-01
  3.97470325e-01 -2.60260701e-01  2.50906169e-01  1.68228924e-01
  1.33900508e-01 -2.10833233e-02 -4.70035732e-01  4.78850156e-01
  2.80345589e-01 -4.64546800e-01  3.21747035e-01  2.34207422e-01
  2.45772451e-01 -4.71482307e-01  5.00400960e-01  4.10190076e-01
  5.15216827e-01  2.62549460e-01  2.11593546e-02 -3.89687568e-01
 -2.41742760e-01 -2.14834630e-01 -8.62650797e-02 -1.65323570e-01
 -5.21895029e-02  3.41874868e-01  4.50314462e-01 -3.06973577e-01
 -2.02294186e-01  6.85521722e-01 -5.33892572e-01  3.58471543e-01
  1.45286605e-01 -7.07056001e-02 -1.50529072e-01 -8.56279582e-02
 -7.67851025e-02  1.89544857e-01 -1.04067773e-01  5.33544004e-01
 -5.27887225e-01  2.42332090e-02 -2.64348090e-01 -2.23186895e-01
 -3.81208718e-01  7.59914368e-02 -4.64485109e-01 -3.36549252e-01
  4.21229839e-01  1.07479207e-01  1.90457791e-01  2.89487489e-03
 -1.08513705e-01  1.53545350e-01  3.16023648e-01 -2.70840749e-02
 -5.40594459e-01  8.97286758e-02 -1.15549676e-01  3.97803992e-01
 -4.97683346e-01 -2.84893364e-01  4.99861799e-02  3.61279696e-01
  6.90535665e-01  1.46821439e-01  1.73396602e-01 -1.74582347e-01
 -3.15702260e-01  6.72999769e-02  2.17250243e-01  9.78535116e-02
 -1.29472464e-01 -1.86929435e-01  1.34878129e-01 -1.53885290e-01
  7.44715557e-02 -1.85536250e-01 -2.80628383e-01 -1.14144213e-01
  4.12249625e-01  6.39491975e-02 -1.45715117e-01 -9.82065052e-02
 -1.33081883e-01 -1.88410461e-01 -2.84838937e-02 -3.49510163e-02
  3.34258713e-02  6.98896796e-02  1.90354511e-01 -2.96724051e-01
  2.64706067e-03  1.09140947e-01  1.70892701e-02  2.60589242e-01
  3.29038620e-01 -6.61560148e-02  2.39665717e-01 -2.26194620e-01
 -3.36869545e-02  1.49400130e-01 -3.21265638e-01 -2.68577904e-01
  5.72632015e-01 -4.92308497e-01  2.00666577e-01 -3.49261820e-01
 -2.89886612e-02  6.09010458e-01 -5.72333157e-01  2.35000670e-01
  6.47180574e-03 -3.14952508e-02  2.78108083e-02 -3.90340954e-01
 -2.08950117e-01 -3.04452837e-01 -7.20199272e-02 -8.29840004e-02
  3.73792857e-01  7.38937110e-02 -2.21076086e-02  9.88139287e-02
 -1.51426882e-01 -1.40430734e-01  2.26017952e-01  2.76089966e-01
 -8.87747630e-02 -1.12816028e-01 -2.66286045e-01  2.77834296e-01
 -4.75609973e-02  6.71005547e-02 -2.78584175e-02 -2.39991937e-02
  2.51708686e-01  4.68793899e-01 -5.39325476e-01  1.10598475e-01
 -3.44947308e-01  4.15990084e-01  7.28483498e-02 -3.19647521e-01
  4.90374565e-01 -7.30331149e-03 -2.64252443e-03  9.63711083e-01
  3.23884904e-01 -7.79616535e-02 -2.37589255e-01  2.34038591e-01
 -3.16053987e-01 -1.65628293e-03 -1.09070671e+00  3.38409364e-01
  4.70607281e-02  1.07435413e-01 -2.06672356e-01  4.26446088e-03
 -1.38461241e-03 -5.31455636e-01 -2.75648654e-01 -1.64648622e-01
 -3.42916757e-01 -4.26118672e-01  6.01811945e-01  4.55971897e-01
 -2.72701889e-01 -3.45802940e-02  2.62752354e-01 -6.34185225e-03
  2.79631346e-01 -2.53559053e-01 -1.68626338e-01  3.82934660e-02
  2.07763135e-01 -4.31525975e-01 -7.24000558e-02 -1.26854450e-01
  2.07029749e-02  5.74441731e-01  3.54672432e-01  9.28300545e-02
  6.70508668e-02  1.11520678e-01 -1.86510980e-02  4.62352097e-01
  2.72504926e-01 -3.60474110e-01  5.29415369e-01 -1.00318261e-03
 -8.81360695e-02  1.49975494e-01  5.25862724e-02  4.63517487e-01
 -3.96831542e-01  2.42640823e-01 -2.08912537e-01  3.65672290e-01
 -4.73500433e-04  5.33963263e-01 -1.97879612e-01  3.11582744e-01
 -6.96715057e-01 -4.29500550e-01 -4.49359566e-01 -2.71372199e-02
 -6.98710978e-02  2.06174582e-01 -1.57107800e-01  4.43521202e-01
 -6.74267337e-02 -3.00924033e-01  5.14859557e-01  3.36029828e-01
  6.63376600e-02 -1.15235247e-01 -2.95982286e-02  2.79471755e-01
 -3.48201916e-02 -7.29324743e-02 -4.58472408e-02  1.54262856e-01
  8.09356570e-01  5.20328224e-01 -4.02114749e-01 -3.23152021e-02
 -1.10364027e-01  7.50505254e-02 -1.51098579e-01  8.45740080e-01
 -1.80843890e-01  3.22573632e-01  1.04708321e-01  3.19663644e-01
 -1.55085236e-01  1.69236735e-01 -2.56996632e-01  2.01208770e-01
  1.77393183e-01 -2.74333179e-01 -3.36944580e-01  5.02356887e-01
 -1.18357182e-01 -2.01166973e-01 -5.36485910e-01 -7.69810379e-02
  1.15382867e-02 -2.36464664e-01 -2.98771430e-02  1.31366640e-01
  2.94184387e-01  9.90917012e-02 -5.43897867e-01  1.40812770e-01
  3.66998672e-01  5.04861325e-02  1.99122518e-01 -2.80674815e-01
  4.34192061e-01 -1.40274823e-01  5.78048944e-01  1.77715778e-01
  8.98364484e-02  3.29651892e-01  6.13008775e-02 -3.24933589e-01]

Sentence: Sentences are passed as a list of string.
Embedding: [ 0.32208762 -0.00123908  0.17937377 -0.36919138 -0.06460274  0.09153692
  0.24119096 -0.29494217  0.07728957  0.11577005 -0.04479983  0.17928234
  0.1475363   0.21511652  0.36810791  0.20910913  0.27194238  0.34880087
 -0.57251936 -0.18253218  0.4448957   0.27452925  0.04266282 -0.07683562
  0.18689147  0.4496505  -0.16932622 -0.24896334 -0.20479265  0.40285036
 -0.2101927   0.03775701  0.07848521  0.12848447  0.02593089  0.4715598
  0.17853785 -0.07379771  0.08130724 -0.23328738 -0.49801245 -0.04135723
 -0.12094605  0.17028998 -0.19154078 -0.38459808 -0.77479136 -0.10622733
 -0.2304489   0.4024145  -0.8745089   0.23853712 -0.4712986   0.21262182
  0.3340935  -0.24154    -0.1483509  -0.14513564 -0.34830925 -0.08349245
 -0.69097275 -0.29845262 -0.12230504  0.07482646 -0.18775596 -0.3754651
  0.21369492 -0.10096409 -0.12234445  0.31431514 -0.23989926  0.22460794
  0.0399599   0.36034834 -0.5663802   0.21883512  0.11020288 -0.10870823
  0.07084075 -0.02608179  0.18370324  0.08465949 -0.20478249 -0.24435617
 -0.08180565 -0.01903111 -0.03591372  0.02398443 -0.2855857   0.07374766
 -0.29744208 -0.87717843  0.47101936 -0.0494047   0.36394492  0.482644
  0.01564615  0.03558917 -0.26203    -0.1121847   0.0241104   0.37477782
 -0.09897303 -0.09851858  0.15000843  0.00689534 -0.12652436 -0.3159893
  0.31449488 -0.2942561  -0.2694104   0.20221162  0.14329888 -0.19584627
 -0.3410443  -0.03172762  0.7365027   0.31923506  0.2438129   0.30732602
  0.09933245  0.19010943 -0.10694525  0.05178664  0.03233436 -0.10314636
  0.2649922   0.31206465  0.43152618 -0.6426122   0.0840958  -0.0432735
 -0.04991193 -0.12718563  0.13789187  0.01306224  0.34383258  0.09234294
 -0.09922738 -0.52159905  0.25842273 -0.01057126 -0.00478189  0.03938858
  0.19086099  0.32933885 -0.24345161 -0.07328319 -0.39280015  0.14541808
  0.32839534 -0.04184634  0.07407122 -0.7386053  -0.09076015  0.15802307
 -0.09780021 -0.21605958 -0.30027467  0.2323658   0.01072446  0.49570465
  0.04974837  0.29931435 -0.05382248  0.35328114  0.3419176   0.49667245
 -0.4860523  -0.19098845  0.8154575   0.22962622 -0.32077783 -0.32726687
 -0.367717    0.3452114  -0.02620159 -0.14315048  0.10648432 -0.24638046
 -0.09366632  0.17198639 -0.08508814  0.20120296 -0.05879208 -0.34020975
 -0.19565329  0.2828087   0.20124306 -0.08207255  0.09779122 -0.26375008
  0.12176559 -0.01041479 -0.4385985   0.11058219  0.48010394 -0.10981981
 -0.6375458   0.29336807 -0.1920764   0.46536973  0.2704201   0.19388463
  0.17379023 -0.3007702  -0.0275121  -0.02291276  0.3678463   0.02492153
  0.53705496  0.18851233 -0.13344418  0.08917347  0.05542957 -0.24818316
 -0.04199777  0.05767386 -0.18278812 -0.41686475  0.16070595 -0.46362543
  0.11769217 -0.3770692   0.02960374  0.692561   -0.4830891   0.21128401
  0.18214527 -0.18429579  0.0681766  -0.02460879 -0.19073623 -0.06736984
 -0.5670072  -0.23929311 -0.08497227  0.03093951  0.31079894  0.1291628
  0.05248259 -0.3344983   0.18810134  0.23547177 -0.00183485  0.45361614
  0.24885082 -0.05641065 -0.2977458  -0.43511704 -0.07969435 -0.17670156
 -0.13347092  0.1938272   0.22002596 -0.11057543  0.26473755 -0.27179065
  0.03410878 -0.4771442   0.44719058 -0.05570416  0.39643747  0.27483267
  0.33305615 -0.10890252  0.2788817   0.21596934 -0.05252272 -0.35867548
 -0.69062907  0.03960182  0.00652785 -0.01095348 -0.10027702  0.04770013
 -0.34146932 -0.16714163  0.07136464 -0.1807847  -0.30248472 -0.68428737
 -0.09592848 -0.2141112  -0.6552438   0.5675644   0.26946738 -0.00190061
  0.8618065   0.16771556  0.03102748 -0.2677305  -0.07830263 -0.48510885
 -0.26737222 -0.33354253 -0.5738254   0.35678256  0.08993588 -0.13057196
 -0.1513651  -0.06124125 -0.13037089  0.5585606   0.614175   -0.04804054
 -0.0638859   0.08390605 -0.25143692 -0.04359839 -0.18525787  0.04693348
 -0.34380865 -0.09738468  0.1683365   0.0752685   0.1769452   0.17727177
 -0.03423442  0.14993554 -0.13773166 -0.20949684 -0.6127283   0.3781397
  0.3901828  -0.08359346  0.03152128  0.13122386  0.38826075  0.21844254
  0.0972431   0.42089358 -0.3264124  -0.26933426 -0.39095107 -0.22648653
 -0.32020715 -0.16287427 -0.03581636  0.363739    0.18583307 -0.0291401
 -0.46577957  0.2916888   0.37251312 -0.23726626  0.00338617  0.41540965
  0.03300428  0.4500395  -0.08159234  0.33990335  0.24497904  0.0235242
 -0.1464306  -0.12644552  0.31128627 -0.15182619  0.01009398  0.49108496
  0.14362407  0.11589024 -0.23236984  0.2475176   0.1836449  -0.24836856
 -0.11220913 -0.23113322  0.0842896  -0.24378659  0.13307258  0.42355725
  0.33348376 -0.3437014   0.0344367   0.18795514  0.20037197 -0.05355961
  0.2848529   0.0717658   0.05487169 -0.08103789  0.27076873  0.11700248]

Sentence: The quick brown fox jumps over the lazy dog.
Embedding: [ 0.58979344 -0.23598255 -0.25411725  0.00311624 -0.08485737 -0.26799768
 -0.07506651 -0.3002136   0.05151652  0.16585363  0.26076776  0.38256362
  0.43732867 -0.09301949 -0.26568803 -0.09716298 -0.48096094  0.11878292
  0.13675483  0.04712067 -0.23696537 -0.52332336 -0.01631867  0.06127304
 -0.7433302  -0.11898906 -0.7886529  -0.48108855  0.10314927 -0.32372454
  0.8144374  -0.39774537 -0.50315547 -0.7972457  -0.6324822   0.32320985
 -0.38419437 -0.11186695 -0.1324357   0.02069666 -0.14309539 -0.0370119
  0.06116579  0.16332883 -0.11174309  0.25234267 -1.0464071  -0.37252343
  0.15601997 -0.29991606  0.19883864  0.2343344  -0.3702577   0.31733564
  0.84428644  0.06977719  0.03273663  0.09948339 -0.31141308  0.50517714
  0.00309272  0.38013652  0.04582737  0.00633379 -0.00142918 -0.13568659
 -0.07611365 -0.25844312 -0.8022129   0.5508589  -0.09124386 -0.21782017
 -0.78810936 -0.5118384   0.46672547  0.55274725 -0.37124714 -0.18645377
  0.3585697  -0.19586323  0.18042535 -0.42548886 -0.09681422 -0.05536837
  0.52489287  0.24481142  0.01934664 -0.29637936 -0.1277783  -0.30534947
  0.45349374  0.07469101 -0.07061689  0.2624302   0.37383935  0.14306359
  0.00127857 -0.41776088 -0.24014093 -0.2509353   0.34843782  0.31144044
  0.0808733  -0.5764053   0.54085284 -0.01802203 -0.12959798 -0.07399664
  0.3936979   0.6488388  -0.02030003 -0.5665558   0.2967598   0.520002
  0.21538728  0.10369676  0.06199208  0.01896283 -0.15269236 -1.0642662
  0.7614961   0.20734386  0.44718924  0.14493968  0.6580228  -0.09440905
 -0.23316365  0.4215707   0.1195763  -0.32571068  0.16425563 -0.49508703
 -0.19516118 -0.56183213 -0.14933276  0.610941   -0.17897959 -0.01805552
 -0.5964053   0.04918591  0.15347804 -0.42829406  0.73295283 -0.35291103
 -0.11159656  0.06127812 -0.29704392  0.4396664  -0.09660351  0.65579444
 -0.61403424  0.02576606  0.43827453  0.01733282 -0.40002275 -0.08178308
 -0.37126926  0.08230279 -0.13104396 -0.5326111  -0.29928368  0.6993657
 -0.04398742 -0.15702991  0.09794132 -0.03017466 -0.10002708  0.199966
 -0.4818854   0.17949156  0.5656603  -0.11954784 -0.696373    0.05259641
 -0.00549608  0.16739355 -0.31692895 -0.09747531  0.33193663  0.4719962
  0.12653954  0.19130926  0.42949092  0.55291235  0.31463274 -0.31433088
 -0.41508684  0.32897702  0.35702732 -0.1920966   0.22239415 -0.48717856
  0.3409156  -0.22137432 -0.1266758   0.21120834 -0.31347895  0.8468937
  0.20112668 -0.42598733  0.5131572  -1.2351419   0.76971793 -0.17414267
 -0.02181136 -0.0356865  -1.105949   -0.5720654   0.05585196  0.12461495
 -0.45065832  0.06428951 -0.16033873  0.39932927 -0.10322935 -0.02025502
 -0.18010448  0.06234786 -0.02188883 -0.15795426  0.28316957  0.02385282
  0.03098137 -0.07853306  0.29896578 -0.06237327  0.5498678   0.17862315
  0.2116474   0.44483367  0.04890747 -0.162381   -0.22669895  0.18871985
  0.07943622  0.1359757  -0.18484493  1.113551    0.82809544 -0.31202707
  0.09505999  0.05096091  0.38804898  0.25000468  0.558486    0.31088772
 -0.05318568 -0.07675371  0.15282278  0.09189964 -0.01429148  0.6657543
 -0.03346021 -0.44703493  0.80067486 -0.4799278   0.17478174 -0.30563813
  0.5536521   0.42380962  0.48674306 -0.49677992 -0.45194814 -0.95563084
 -0.20709987 -0.22605716 -0.0099914   0.98797685  0.5880775   0.08305439
 -0.5578132   0.21136862 -0.3607222   0.52668494  0.33983573 -0.15756187
  0.00423779 -0.05354516 -0.5777671   0.5595104  -0.05747148  0.16837652
  0.37946853 -0.25776428  0.08421484 -0.15229936 -0.03280768  0.10083867
 -0.41858304 -0.44499016 -0.29309887  0.6144206   0.08548218 -0.06349564
 -0.6152552   0.79544085 -0.24058406  0.2063889  -0.5125261   0.6312013
  0.36744294 -0.4400988   0.46913967  0.23087728 -0.13737966  0.21696861
  0.40043226 -0.02490607 -1.139676    0.02653918 -0.32730213  0.09984124
  0.05725667 -0.84722155  0.06451946  0.45698035  0.63563025  0.45185634
 -0.2751906   0.21346165  0.17374253  0.42822042 -0.6584535   0.4000258
 -0.02035557 -0.6730788  -1.0269238   0.16877282 -0.09248707 -0.79977626
  0.38093373  0.5171233   0.04200954 -0.04867526 -0.18772238  0.16339499
 -0.21974911  0.21939285  0.03676502 -0.29750267 -0.37409678 -0.52095085
 -0.41314605 -0.489477   -0.8189662   0.08531482  0.34576944  0.12505981
  0.24945222 -0.25254658 -0.03156116  0.27573124 -0.60857177  0.3357
  0.22913106  0.6607082  -0.30215803 -0.05315317  0.22247504  0.06138719
  0.33555198 -0.0848518   0.08764573  0.10872053 -0.40389338 -0.14949782
  0.19458489 -0.81060654  0.79730946 -0.41162547  0.01364165  0.23472963
 -0.09732277 -0.29044035  0.03843231 -0.07090472 -0.17404465 -0.44859377
 -0.31867278  0.4165608  -0.05431673  0.14036179  1.0559161   0.5301814 ]

# English embedding example with a new pretrained model

from sentence_transformers import SentenceTransformer
model = SentenceTransformer('distiluse-base-multilingual-cased-v1')

#Our sentences we like to encode
sentences = ['早上好',
'今天天气非常不错']

#Sentences are encoded by calling model.encode()
embeddings = model.encode(sentences)

#Print the embeddings
for sentence, embedding in zip(sentences, embeddings):
print("Sentence:", sentence)
print("Embedding:", embedding)
print("")

Sentence: 早上好
Embedding: [ 3.36048612e-03 -7.75053650e-02 -8.92517120e-02 -1.98542904e-02
  4.86167856e-02  4.26223725e-02 -3.25850174e-02 -6.78801164e-03
  1.58829652e-02 -2.43490171e-02  1.48126129e-02  6.55123359e-03
  1.14513915e-02  3.69007923e-02 -1.88735481e-02 -1.18097216e-02
  8.75925422e-02  3.32120210e-02  4.86210473e-02 -9.08677280e-03
  1.27627403e-02 -3.61923464e-02 -2.31466126e-02 -2.86142770e-02
 -2.80293375e-02  2.24176962e-02  9.83241759e-03 -1.76876169e-02
 -3.93512547e-02 -6.60814941e-02 -6.64236844e-02  4.22375835e-02
 -4.41516377e-02 -4.42469940e-02  5.83056957e-02 -6.70481995e-02
 -3.44123617e-02  4.91611883e-02  1.23786274e-02  2.88232397e-02
  3.48660462e-02 -9.41558462e-03 -4.65008654e-02  3.93482149e-02
 -2.03807093e-02 -9.81736463e-03 -4.63420851e-03  4.13698182e-02
 -7.43050594e-03  5.26707247e-02  4.63205464e-02  1.36748822e-02
 -4.64802980e-02 -4.62170877e-02 -3.83359045e-02 -7.37623349e-02
 -2.15301700e-02 -7.80433509e-03  6.28040507e-02 -1.95669127e-03
  2.84056198e-02  5.01199141e-02 -4.69665565e-02  2.13841908e-02
 -7.29201362e-02 -1.84297003e-02 -4.63314839e-02 -4.66326475e-02
  4.06820178e-02 -2.62741838e-02 -1.58835202e-04  1.89249944e-02
 -1.58798080e-02 -5.56862354e-02 -1.65423111e-03  5.79530513e-03
 -4.80827615e-02  2.83442414e-03 -3.37332375e-02 -4.59188670e-02
  1.84609480e-02 -8.43395516e-02 -4.98937443e-02  1.62628964e-02
 -2.68908050e-02  2.94992961e-02  3.94213945e-02  1.89540815e-02
 -1.49033396e-02  1.54328160e-02  6.68804627e-03 -2.17899680e-02
 -6.37249798e-02  7.95044973e-02 -6.71640486e-02  1.53331548e-01
  1.22375209e-02 -7.15146493e-03 -3.51416469e-02 -5.64979836e-02
 -7.00105280e-02  2.48073991e-02  1.99343208e-02  3.48216183e-02
  3.10467370e-02  4.85268384e-02 -1.48683321e-02 -1.44339688e-02
 -1.83274597e-02 -2.25209910e-02 -4.66139577e-02  8.46805871e-02
  5.55498600e-02 -4.86311466e-02  8.04354995e-02  5.78265125e-03
 -3.33314948e-02  1.41728045e-02  7.46281222e-02  1.23108663e-02
  1.29789282e-02  2.50214320e-02 -1.73974875e-02 -2.06596926e-02
 -8.00771266e-03 -4.48289625e-02  3.21343057e-02  2.96824127e-02
 -2.19148956e-02 -8.40266049e-02  2.08409578e-02 -5.84821552e-02
  9.26640071e-03 -7.78274285e-03  3.21653970e-02  1.23768868e-02
  1.75757147e-02 -3.77148017e-02 -6.50716200e-02 -2.81811506e-02
  6.65956060e-04 -4.59337793e-02 -2.91092098e-02  1.06873184e-01
 -9.06297788e-02  5.74022382e-02 -1.92602631e-02 -9.17858677e-04
 -1.03564970e-02 -9.53326374e-03 -1.40155749e-02 -5.38532920e-02
 -1.45433499e-02 -8.01574625e-03  2.73187216e-02 -1.10087404e-02
 -8.70806128e-02 -5.07052056e-02 -1.94765590e-02  3.09801456e-02
  5.79237528e-02 -4.61821295e-02 -6.85098171e-02 -1.12160509e-02
  1.87328327e-02 -1.87243987e-02  8.43074173e-03  4.05288208e-03
 -1.77395716e-03 -4.84117605e-02 -5.69200628e-02  1.21792853e-01
 -8.72146338e-05  7.16463253e-02 -7.18049286e-03  1.85641591e-02
  1.04164807e-02  2.23379545e-02 -2.17134301e-02  6.76098093e-02
 -2.82478407e-02  3.98118485e-04  1.20027447e-02  2.38112584e-02
 -3.34599502e-02 -2.01173555e-02 -6.13471568e-02  8.10436439e-03
  4.63223346e-02 -7.35998601e-02 -7.45181814e-02  6.75673410e-02
  4.85108085e-02  1.16789509e-02 -4.41863127e-02  3.12849879e-04
 -3.95977460e-02  1.64179280e-02  7.68655736e-04  2.21294779e-02
  1.06583117e-02 -1.15191847e-01 -7.83179179e-02 -9.30088758e-02
  2.98546683e-02  1.93161629e-02  4.65247072e-02 -3.15551423e-02
  1.53468028e-02 -2.31775502e-03 -3.51057500e-02  6.75020069e-02
  3.89646366e-02  2.36660838e-02  8.71817674e-03  2.33443081e-02
  6.04395606e-02 -5.73495515e-02 -7.63548985e-02  1.81578603e-02
  5.78259937e-02  3.85002531e-02 -9.10978578e-03  6.28609152e-04
  4.22109812e-02  2.34038550e-02 -4.32434771e-03  5.22437766e-02
  2.75171399e-02  1.14117227e-02 -1.94266194e-03  4.50319564e-03
  7.96783529e-03 -1.06010869e-01 -7.45600974e-03  4.15139422e-02
 -2.61434522e-02 -3.02400477e-02 -3.69867403e-03  5.33738770e-02
  1.22662308e-02 -7.78622404e-02 -1.04798714e-03  4.03577797e-02
  1.95078198e-02  6.87584048e-03  1.52195273e-02 -2.21762992e-02
  3.01569123e-02  4.99859042e-02  1.69460364e-02  2.80374940e-02
 -1.22692548e-01 -6.09890744e-02  6.93573654e-02 -4.64934334e-02
 -2.55377777e-03  9.13314708e-03  1.88059080e-02 -3.50909606e-02
 -3.23721021e-02 -1.99456997e-02 -1.85215636e-03  9.07397363e-03
 -1.60663063e-03  6.72434550e-03  1.51269864e-02 -2.88711805e-02
  1.87143628e-02  3.21673527e-02  1.10762762e-02  5.36762364e-02
  1.00923926e-02 -6.80830050e-03  1.38309216e-02 -1.52337942e-02
 -1.88095886e-02  4.73398566e-02  1.07036727e-02 -1.34082846e-02
  2.46402621e-02  4.00331616e-03 -3.54318060e-02 -3.82929370e-02
  5.72114717e-03 -3.37869078e-02  9.22745746e-03 -2.55183261e-02
 -6.68449188e-03 -2.95727719e-02 -5.30545451e-02 -1.42496992e-02
  1.21139064e-01  5.80232916e-03  6.85878769e-02  3.29775847e-02
 -3.54181491e-02  1.07272621e-02 -4.35234942e-02 -3.61797120e-03
  4.35319096e-02 -7.25895017e-02  2.31458414e-02 -6.59776181e-02
 -9.39039700e-03 -5.54487482e-02 -2.98391879e-02  3.77000533e-02
 -4.21746895e-02 -6.79707155e-05 -4.04625982e-02  2.20605936e-02
 -2.00542212e-02 -3.81324701e-02 -5.30191511e-02 -6.33813813e-02
 -5.16399965e-02  9.64144524e-03  5.90449497e-02 -4.24992219e-02
  1.87409557e-02  1.59757817e-03  2.12688763e-02  1.16855623e-02
  8.13119933e-02 -3.76809179e-03 -4.92693763e-03  3.39190066e-02
  7.72952859e-04  4.17263247e-02 -8.17925707e-02  6.20350353e-02
 -1.06017468e-02  4.36364748e-02  1.06892204e-02  4.46716622e-02
 -1.07703032e-03 -5.20897424e-03  4.62425686e-02 -1.77654065e-02
 -4.77417782e-02 -7.94410184e-02 -3.87781188e-02  3.52257639e-02
  8.99284892e-03 -4.21371032e-03 -6.33117780e-02  4.79902467e-03
 -2.65776385e-02  6.36078864e-02 -2.88559869e-02 -1.88005026e-02
 -6.77149072e-02 -1.77993905e-02 -1.74105745e-02  1.92977523e-03
 -4.24707830e-02 -3.41327414e-02 -4.64667156e-02  1.20677715e-02
 -5.59292501e-03 -2.15960406e-02  1.65096892e-03  4.98509929e-02
  6.74478710e-03 -1.25451041e-02 -3.78884971e-02 -2.44544051e-03
  1.05662392e-02 -2.92542093e-02 -2.42053512e-02 -4.72463332e-02
 -6.66808896e-03  4.26904894e-02 -1.38995284e-02 -7.33149797e-02
 -1.20323701e-02  1.33620957e-02 -6.83322325e-02  5.24532832e-02
 -3.99674661e-03 -3.77754751e-03 -4.37322631e-02  3.01865134e-02
 -2.41089566e-03 -3.91000248e-02 -7.14202551e-03  1.61565766e-02
  2.38034059e-03 -1.91217046e-02 -3.19050848e-02  2.66811196e-02
 -3.00042611e-02  6.37865961e-02  9.43038985e-03  9.79864821e-02
 -1.36476476e-02 -3.53143290e-02 -1.68743916e-02 -1.17210001e-02
 -1.76749416e-02 -2.15478931e-02  6.98762164e-02  6.34187385e-02
  3.40041555e-02 -2.52816733e-02 -1.68120004e-02 -3.73728164e-02
 -4.34950478e-02 -2.41863336e-02  5.50701953e-02 -3.69273759e-02
  2.01697815e-02 -5.65395206e-02 -2.43306421e-02  3.90052013e-02
  8.88361968e-03 -7.37517253e-02  1.38345852e-01  9.28618014e-02
  1.69148594e-02 -6.06265031e-02 -4.29087738e-03  9.36304405e-03
 -6.03743903e-02  6.65058494e-02  9.13580060e-02 -4.83134501e-02
 -4.48018834e-02 -2.56855302e-02 -1.47311706e-02 -6.67072907e-02
  6.08391464e-02 -1.89301930e-02  5.48280887e-02  5.90014877e-03
  5.10426983e-02 -2.76698507e-02  5.75542785e-02  1.65380053e-02
  4.50753085e-02 -9.17072967e-02 -2.97022844e-03 -1.58547808e-03
  4.13699523e-02 -2.40925550e-02 -8.28880146e-02 -4.60402220e-02
 -2.80448776e-02  8.56529176e-02  1.21937310e-02 -1.45478994e-02
  2.00680923e-03  5.76159284e-02 -8.33749920e-02 -8.44795082e-04
  1.61427092e-02  1.06292889e-02  4.48290072e-02  3.78188565e-02
  3.22153270e-02  7.65506970e-03  8.83217156e-02  1.07656186e-03
 -4.78400923e-02 -1.30352927e-02  2.12222282e-02  4.37513888e-02
 -6.99853227e-02 -2.67156325e-02 -5.85299730e-03 -6.67774230e-02
 -4.67196293e-02  4.51602452e-02  5.02196476e-02  7.23657906e-02
 -3.45671624e-02  1.77986156e-02  6.36029616e-02  6.04263172e-02
 -2.88534202e-02  7.63596641e-03  8.91817287e-02 -1.73596032e-02
 -1.14401756e-03 -3.49274017e-02 -3.11373584e-02 -1.08088255e-02
  6.22482738e-03  6.60343748e-03 -1.39189782e-02 -1.58823899e-03
  3.98824885e-02 -1.50108114e-02  2.18414310e-02  2.50639417e-03
 -2.71914285e-02  1.23682460e-02 -1.60910413e-02 -5.62604703e-02
  3.08268126e-02 -4.40148003e-02  6.95617199e-02 -3.85880619e-02
 -1.06069623e-02  6.90155923e-02 -2.68800631e-02 -7.05972910e-02
 -8.45417567e-03 -2.90030837e-02  3.72898579e-02 -1.82219949e-02]

Sentence: 今天天气非常不错
Embedding: [ 0.03000144 -0.09463879 -0.00121101  0.00919701  0.09230766  0.05803198
 -0.06870171  0.08796345  0.05131664  0.05268763  0.06015535 -0.01480623
  0.01694882  0.02787215 -0.02760382 -0.01491595  0.04491248  0.07975394
 -0.01115547 -0.0462878  -0.04860514  0.01397826  0.02661177  0.05335874
  0.0504394  -0.03782453  0.00266618 -0.00529313 -0.06329554  0.00695427
 -0.01284165  0.01447636 -0.07145751 -0.08993939  0.03178086 -0.06282265
 -0.04155265  0.04588643  0.03874922  0.03362899 -0.00353874  0.01936172
 -0.00900048  0.02823229 -0.09740815  0.03750192  0.03347944  0.02718792
  0.00610443  0.00467336  0.03310893 -0.03908279 -0.0221571  -0.09013501
  0.01532278 -0.05820091  0.00157651 -0.09490337  0.0537669  -0.00431305
  0.04847043 -0.03206552 -0.026307   -0.01593183 -0.04248736 -0.04010082
 -0.01602365 -0.02053563 -0.03909144  0.03412447  0.03093878  0.00616256
  0.0216082  -0.06444417  0.080314    0.02742311 -0.06018759  0.02321919
 -0.05734614 -0.06155207  0.04174984 -0.10371719  0.03880399 -0.01905175
 -0.0258333   0.03389469  0.00468696  0.0387875  -0.00673322  0.00383488
 -0.01235164 -0.03161037 -0.02153032  0.00984649  0.01701394  0.0436353
 -0.01779626 -0.02531954 -0.04274719  0.04862759 -0.05897103  0.00572619
 -0.03335102 -0.01182074  0.02701874 -0.01848033 -0.02704814  0.01843894
  0.06236629  0.04626593 -0.03967442  0.06011495  0.01706262 -0.07964841
  0.04118946 -0.066379    0.09199478  0.04699905  0.12130994  0.01098934
 -0.02470355 -0.06073544  0.0464027   0.00273122 -0.03935859  0.02141794
 -0.0184507   0.03051549 -0.00163435 -0.05913333  0.00292336 -0.07933108
  0.03902374 -0.06467438 -0.0390107  -0.03507318 -0.07895196 -0.05337577
 -0.09487265  0.04261077 -0.04158578 -0.0317761  -0.11317404  0.01106471
 -0.05172293  0.03777007  0.00772178  0.11905682  0.01442179 -0.02014892
 -0.01100211 -0.03005649 -0.04160342 -0.05648704  0.01849159 -0.05435764
 -0.0839037  -0.05800341  0.02173088  0.00356943  0.05853926  0.1246719
  0.02843452  0.08176696  0.0147953  -0.00317226  0.04797639 -0.00291128
 -0.09280773  0.02252468 -0.05960978  0.12289534 -0.03065114  0.06989978
  0.04467983  0.07636563  0.01817677 -0.00636483 -0.01898711  0.01658535
  0.00860319  0.0283874  -0.05914772 -0.0190354   0.02753133 -0.05427081
 -0.04155286 -0.00551601  0.01740319 -0.0476647  -0.04968425  0.04580819
  0.0008345  -0.0295907  -0.03722452  0.01759684 -0.01680085 -0.00452731
 -0.03103271  0.01715709 -0.02973793 -0.09613879  0.0051401  -0.05134783
  0.05475045 -0.01283471  0.06491576  0.00521481 -0.02848241 -0.01567771
 -0.02928415  0.06885134  0.00134412  0.02393162  0.02902504 -0.00551864
  0.05685154  0.01001529 -0.00151077  0.03115507  0.06638921 -0.03961314
 -0.00163929 -0.01343718  0.0455446   0.09824838 -0.0037222  -0.01031751
  0.01817146 -0.00964774 -0.03243448  0.03805481  0.05487118 -0.1405063
  0.02105236  0.07209678 -0.01056682  0.05282811  0.02630474  0.0514919
  0.00152254 -0.02837622 -0.0032705  -0.00885593 -0.00931489  0.00091267
 -0.02325741  0.03074451  0.01638401  0.07488494 -0.03075658  0.04077358
  0.0087177  -0.03887089  0.00657461 -0.09632066  0.05145807  0.04517055
  0.00689592  0.00326369 -0.0305842  -0.03148292 -0.01074421  0.01959825
  0.06533831  0.01840545  0.05983892  0.02591163  0.04609231 -0.00414881
  0.03466849 -0.03956919 -0.0252759   0.02703837 -0.05049418  0.00642855
 -0.0466234   0.01452899  0.0411245   0.03267844  0.05253888  0.04270734
  0.02421789 -0.02808435  0.03788607 -0.03368303  0.04734772 -0.02120586
 -0.00403468  0.05083772 -0.03158763  0.00812041  0.14702259  0.05909027
  0.06059919  0.04371373  0.05749655 -0.07144133 -0.007153    0.03108226
 -0.00512128 -0.04756605 -0.01369407 -0.03663335 -0.02603604 -0.08464614
 -0.00882994  0.05349972  0.00743798  0.0450788  -0.00615429 -0.01372156
 -0.06049759 -0.00165892  0.00751451 -0.03650769 -0.05391942  0.03810795
  0.01484829  0.00219441  0.02152888  0.02753042  0.06430887 -0.03992795
  0.04222113 -0.01056078 -0.01716618  0.04329282  0.00051106 -0.00328042
  0.00308413  0.04196681 -0.04609387 -0.04296339  0.03102    -0.03701093
  0.062396   -0.06226721  0.00538336  0.0229238   0.02155858 -0.07839612
  0.04539885  0.03251994 -0.00489039 -0.0397178  -0.00333692  0.00905649
 -0.03641601  0.022086    0.01367772  0.00159605 -0.04355391  0.020589
 -0.02687901 -0.03018762 -0.0402398  -0.0284971  -0.06481498 -0.02857979
  0.02540303 -0.04830561 -0.04924891  0.08158892  0.02544646  0.01573535
 -0.05373577 -0.00390225 -0.01128703 -0.00576774 -0.00892009  0.02994281
 -0.02264063  0.02417267  0.05122236 -0.02454749  0.00509644 -0.01798263
 -0.0216634   0.01950723 -0.08260044 -0.0616743  -0.06187451  0.03843369
  0.02321616 -0.01540206  0.01407583 -0.00955944  0.00272941 -0.0103933
 -0.01213074 -0.04850604 -0.03309135  0.05800785 -0.01818478  0.02047308
  0.01977739  0.01210918 -0.01445558  0.0328787   0.0352786  -0.02208976
 -0.02544963  0.05974025 -0.01183659  0.03732854  0.01193697 -0.03702984
  0.02314256 -0.03182907 -0.02021193 -0.0746211  -0.01611404  0.01401942
 -0.0582074   0.07607199 -0.02163705 -0.05099812  0.08846287  0.06345282
  0.01632329  0.03178183  0.0316623   0.02768641 -0.00532748  0.02762542
  0.03190726 -0.03167602 -0.06070093  0.06393433  0.04011519 -0.01285412
  0.09149878 -0.03832356  0.01962792 -0.05850937 -0.03222102 -0.01088148
  0.04417709 -0.05408356  0.00285973  0.01822237  0.05348348 -0.01791644
  0.07268931 -0.04405991 -0.02393987 -0.03948317  0.00895625  0.02411424
 -0.0503852  -0.04026405 -0.00080167  0.04002957 -0.02202688 -0.04564584
  0.00108072 -0.01706082  0.02669973  0.03271101  0.02675862  0.06614731
  0.09970568  0.03362572 -0.00678587  0.01031069  0.055266   -0.00729807
 -0.04342917 -0.02459758  0.008681    0.03958506 -0.04298421  0.01152243
  0.00646575  0.02900903 -0.02682752 -0.03343278 -0.03024075  0.00380493
  0.0342885  -0.02285297  0.05209821 -0.00173273 -0.03453593 -0.02917043
 -0.00853625  0.01347628 -0.06093422 -0.02397925 -0.02997962 -0.03431647
  0.00035183 -0.00620178  0.00593462  0.01080737  0.01387101 -0.04454185
 -0.01523613 -0.03633243  0.01572521 -0.04612231  0.08674803 -0.01647091
  0.02339503 -0.01340232  0.00376191 -0.06117163  0.01253373 -0.03407933
  0.00644007  0.01499923]

Author: robot learner
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source robot learner !
  TOC