嵌入向量生成与查询
文本嵌入模型
-
M3E 是 Moka Massive Mixed Embedding 的缩写
-
Moka,此模型由 MokaAI 训练,开源和评测,训练脚本使用 uniem,评测 BenchMark 使用 MTEB-zh
Massive,此模型通过千万级 (2200w+) 的中文句对数据集进行训练
Mixed,此模型支持中英双语的同质文本相似度计算,异质文本检索等功能,未来还会支持代码检索
Embedding,此模型是文本嵌入模型,可以将自然语言转换成稠密的向量
-
使用M3E
-
为了方便快速调试,建议直接将相关的内容下载至本地
-
git clone https://huggingface.co/moka-ai/m3e-base
-
pip install -U sentence-transformers from sentence_transformers import SentenceTransformer import numpy as np model = SentenceTransformer("D:\\gospace\\shua\\m3e-base") texts = ["老王爱写代码"] embeddings = model.encode(texts) for text, embedding in zip(texts, embeddings): print(f"Text: {text}") # print(f"Embedding: {embedding}") print(np.array2string(embedding, separator=', '))
-
对于
m3e-base
版本,生成的嵌入向量通常是768维的 -
[ 7.59560585e-01, -1.27109140e-01, 5.14054596e-02, -1.59693062e-01, -4.17063087e-02, -8.19702983e-01, 2.41449431e-01, 1.33715153e-01, -1.03617609e+00, -2.28319705e-01, 6.17243648e-01, -5.24424016e-01, 1.80304646e-01, -8.68997991e-01, -4.62767482e-01, -1.98709533e-01, 5.47812641e-01, 9.67402101e-01, -6.81963444e-01, -3.16316262e-03, 3.28954935e-01, 2.92346120e-01, -4.04711217e-01, 5.90863824e-01, -5.51401138e-01, -4.15514529e-01, -5.02967536e-02, -5.48850775e-01, 1.71392083e-01, -3.95615220e-01, 1.63737941e+00, -7.76524067e-01, -6.15127012e-02, 2.51650959e-01, 3.76678944e-01, 1.65224802e-02, 5.55427015e-01, -1.07243016e-01, 7.81503201e-01, 4.54563320e-01, 8.13240632e-02, 2.48942882e-01, 3.32837075e-01, -3.30844522e-03, 2.85081953e-01, 6.52864814e-01, -1.77730799e-01, -1.86786592e-01, -1.19947433e+00, 3.59263033e-01, 3.06981385e-01, 6.67714453e+00, -8.61118436e-01, -6.59109000e-03, -1.59015369e+00, 1.00160849e+00, -9.57870841e-01, 1.28927857e-01, -5.81352055e-01, 3.86609472e-02, 1.29876643e-01, -4.77568775e-01, 1.63034528e-01, -5.18439829e-01, 1.48755103e-01, 1.29043326e-01, 3.16139519e-01, 3.20954382e-01, 4.15887743e-01, -8.86846662e-01, 4.58009601e-01, -8.47651720e-01, -3.94439220e-01, -2.18782693e-01, 3.68612200e-01, 2.94382125e-02, 3.30451459e-01, 2.67671227e-01, 3.67975801e-01, -4.38472450e-01, 6.25256062e-01, 1.34776592e-01, -1.41976073e-01, 1.92134783e-01, -2.18996853e-01, -3.41829687e-01, -1.87255695e-01, -1.71571851e-01, 1.01223254e+00, 6.13354325e-01, -1.41107845e+00, 1.39829889e-01, -4.25042689e-01, 4.70361635e-02, -6.58033252e-01, 2.33138055e-01, 3.01239669e-01, -1.00470805e+00, -4.89165574e-01, -1.02200963e-01, 1.02289163e-01, -1.42863184e-01, -9.79841352e-02, -4.12617832e-01, 8.39702964e-01, 1.32274532e+00, -9.45372462e-01, 8.20253640e-02, 3.01673234e-01, -1.21201307e-01, 2.79277682e-01, -1.15093338e+00, -5.73418975e-01, 5.75947762e-01, -1.74676076e-01, -3.59989926e-02, -2.45318599e-02, 4.47047085e-01, 3.44157889e-02, -3.95211458e-01, 5.85954450e-03, 4.04485404e-01, 1.90305263e-01, -1.00965261e+00, -7.10118562e-02, -2.32678965e-01, -7.37744719e-02, 5.08088946e-01, -6.53338075e-01, 1.19432044e+00, -5.16369700e-01, 1.22984111e-01, -6.55934036e-01, -5.52078784e-01, 2.12076426e-01, -9.62440372e-02, -2.25091249e-01, -2.57290483e-01, -1.55814445e+00, -3.92937481e-01, 1.97502041e+00, 2.88003266e-01, 3.64899725e-01, -2.91331321e-01, -4.12321925e-01, 2.03414634e-01, -1.91754445e-01, 3.66561532e-01, 1.09342627e-01, -2.96878479e-02, -1.77043572e-01, -7.04252958e-01, 3.78284574e-01, 5.88100553e-01, 2.94542938e-01, -4.53098804e-01, -1.35240722e+00, 6.66298717e-02, -1.18963647e+00, -5.60218394e-01, -9.98719037e-02, -5.41272998e-01, -5.11893511e-01, 1.13323182e-01, -3.41559052e-01, 1.27054405e+00, 3.10296893e-01, -3.91244650e-01, -5.92112660e-01, 3.81372511e-01, -7.09137559e-01, -5.72127700e-01, -6.75038695e-01, -1.27276570e-01, 5.50326467e-01, 1.70973629e-01, -7.06340492e-01, 1.09366155e+00, -2.62876391e-01, -1.71785370e-01, -1.27242553e+00, -3.32011551e-01, -3.68874252e-01, -2.70302027e-01, -6.39186054e-02, 2.25251857e-02, -1.21960545e+00, -2.92267725e-02, 2.19343245e-01, 9.03854549e-01, -1.61024642e+00, -1.19817674e+00, -2.43373215e-01, 1.97811037e-01, 6.99667692e-01, 1.08220398e+00, -1.42966902e+00, -6.23148620e-01, -1.14598131e+00, 3.03221524e-01, 1.35328427e-01, -5.62619567e-01, 5.68072855e-01, 1.00827527e+00, -1.42113477e-01, 8.93693328e-01, -7.74117466e-03, 3.73539865e-01, 7.99027622e-01, 1.09404874e+00, -1.18285084e+00, -1.23149085e+00, -8.11075494e-02, -6.34984076e-02, 1.34655863e-01, 2.48995468e-01, -4.60455269e-01, 1.62918717e-01, -7.58928180e-01, -6.69559538e-01, 1.34634882e-01, 1.34181201e-01, -3.73341367e-02, -8.89802575e-01, -9.93391454e-01, -4.52038705e-01, -4.21833605e-01, -4.91406843e-02, 3.05946171e-01, -3.07202816e-01, 7.82340109e-01, -1.00563467e+00, -1.00400865e-01, -2.64248490e-01, 4.65716511e-01, 4.17140901e-01, -3.88314426e-01, 9.80030656e-01, -3.96880955e-01, -7.87510350e-03, -4.28324640e-02, 1.10107791e+00, 1.79232597e-01, -1.29689205e+00, -3.90284508e-01, 1.02558434e+00, 6.04968727e-01, -6.81580603e-01, -8.27678978e-01, -4.23272520e-01, -5.92301935e-02, 3.44731659e-01, 2.54145443e-01, -1.15404820e+00, -1.03138164e-01, 5.55383801e-01, 3.37476492e-01, -5.15083194e-01, 6.99012876e-01, -1.58016816e-01, -3.40833396e-01, 3.49915504e-01, 1.39090860e+00, 4.58933473e-01, 4.26962338e-02, -3.71650428e-01, -1.68823689e-01, -1.08074808e+00, -9.05070901e-01, -5.02089858e-01, 4.17415679e-01, 6.67661846e-01, -9.61706638e-02, 2.11916063e-02, 5.62160134e-01, -6.44293189e-01, 3.17710936e-01, -3.41923118e-01, -8.82506490e-01, -1.07720530e+00, -3.00090283e-01, 9.13380504e-01, 9.57989216e-01, 3.72398585e-01, -9.98427093e-01, -6.91964507e-01, 5.92603028e-01, 7.90655553e-01, -1.06618869e+00, -1.30195391e+00, -1.20785582e+00, -2.04321653e-01, -3.76093715e-01, 1.33960694e-01, 2.50592518e+00, -5.28230846e-01, -6.59069419e-01, 7.36321807e-01, 7.97808111e-01, -1.06570244e+00, -1.43543527e-01, -6.55247211e-01, -7.19331861e-01, 8.15252602e-01, -8.67068917e-02, 1.07031262e+00, 3.90325516e-01, 9.45663303e-02, -8.35210085e-01, -1.21028841e-01, -1.61372471e+00, 1.09380625e-01, -1.59053236e-01, -2.58469820e-01, -5.18571377e-01, 3.15038502e-01, -6.21809185e-01, 1.38990045e-01, 1.67350203e-01, 3.30487221e-01, 7.23021626e-01, 2.61946917e-02, 1.08872366e+00, 3.58943760e-01, 8.15560222e-02, -1.10836700e-01, 1.13304579e+00, 1.04639006e+00, -4.26227301e-01, 1.05273044e+00, 6.38412178e-01, -6.83263779e-01, -7.28904009e-02, 8.67998898e-01, 9.42042649e-01, 1.05305696e+00, -5.23684144e-01, -1.82113022e-01, -1.05253243e+00, -7.09312260e-02, 1.22970134e-01, 6.60896778e-01, 9.44130838e-01, -1.19117057e+00, -4.81023014e-01, -1.17151785e+00, 2.22483501e-01, -1.77511990e+00, -3.02142978e-01, -7.96750426e-01, -1.64792848e+00, -4.40994382e-01, -1.09868455e+00, -5.65342665e-01, 3.71169806e-01, 6.77822471e-01, 7.26896048e-01, 5.60501277e-01, -2.84232572e-03, 1.48416114e+00, -2.80948758e-01, 1.86195932e-02, -1.25779772e+00, 1.01117504e+00, 3.95043612e-01, -1.06091559e+00, 4.55376178e-01, 5.90852499e-01, -3.76404703e-01, -1.27505803e+00, 8.27442050e-01, 3.85000587e-01, 1.18777728e+00, 1.92020565e-01, 8.64256859e-01, 1.10247850e+00, -4.77612466e-01, -4.49791044e-01, 4.36293602e-01, -2.63684958e-01, 4.44416553e-01, -4.19982970e-01, 5.77375650e-01, -3.79977077e-01, 3.84563029e-01, -5.36517262e-01, -5.43187335e-02, -1.10158217e+00, -5.05689621e-01, -1.06836462e+00, -9.12110388e-01, -2.28145525e-01, 6.85708761e-01, -1.44891381e-01, 7.85060003e-02, 1.71833351e-01, 2.17102796e-01, 8.75280976e-01, 5.29666305e-01, 2.00214505e-01, 3.49758655e-01, -8.35674644e-01, 9.26342085e-02, 1.84430435e-01, 3.72666001e-01, -2.19136089e-01, 5.18518388e-01, -6.22629523e-02, 7.33491540e-01, -2.63249248e-01, -2.67214417e-01, 7.73090571e-02, -6.45493627e-01, -3.19644272e-01, -2.89276928e-01, 3.45991284e-01, 5.67886233e-03, -2.49789566e-01, 1.04345548e+00, -8.97620797e-01, 2.59745389e-01, -2.35038638e-01, 9.35924470e-01, 1.03495073e+00, 9.25333023e-01, 2.22500831e-01, 2.08737642e-01, 3.27550352e-01, -6.99261762e-03, -3.94405961e-01, 2.15240449e-01, -4.14843351e-01, 6.27586007e-01, 3.00344199e-01, 1.09458768e+00, 7.59830773e-02, -6.83943391e-01, 1.67123511e-01, -5.07802606e-01, -2.70432144e-01, -6.21037364e-01, 9.64937747e-01, 1.25556087e+00, -3.15922976e-01, -5.63388944e-01, -1.46975935e-01, 1.02344620e+00, -4.48462069e-01, 9.04044926e-01, -2.81636208e-01, 1.05440784e+00, 2.14560971e-01, 7.86892548e-02, -1.28740996e-01, -5.30646369e-02, -7.13777184e-01, -3.04264992e-01, -5.53258777e-01, 4.91248667e-01, -5.39805472e-01, -8.68568122e-01, 8.64456892e-01, -9.18175802e-02, 4.13068295e-01, -2.08863601e-01, 4.28583443e-01, 1.23620534e+00, -8.92189264e-01, 1.37983215e+00, 4.38869357e-01, -3.87700319e-01, 1.12864268e+00, -5.82494810e-02, 1.43608093e-01, -5.40578723e-01, 1.17179848e-01, 2.51674443e-01, -1.42769992e-01, -1.31010675e+00, -8.51148784e-01, -1.48061931e-01, 2.58323908e-01, 3.67341787e-02, -7.23920584e-01, -9.88820434e-01, -1.39375091e-01, -1.14198053e+00, -7.28593171e-02, -1.04956701e-01, -5.85499108e-01, -6.31171286e-01, -5.10103285e-01, 1.05367959e+00, -6.68842137e-01, 4.63386625e-02, -9.96850908e-01, -9.28651869e-01, 7.93903470e-01, -8.99808407e-01, 8.27691436e-01, 9.12066579e-01, -4.78461653e-01, 8.14078569e-01, 6.02525920e-02, 5.26673317e-01, -5.26469648e-01, -7.05779612e-01, -1.71829477e-01, 1.62325189e-01, 2.85767645e-01, 5.12952507e-01, -1.45051509e-01, 1.37109146e-01, 1.83014393e-01, -1.55559137e-01, 2.12739974e-01, -9.23290730e-01, -1.19877413e-01, 2.81804621e-01, 3.34185094e-01, 1.39511657e+00, -5.90442002e-01, 5.74788213e-01, 1.24385524e+00, -7.21555293e-01, 8.28844130e-01, -8.85802656e-02, -4.08442408e-01, 6.71276212e-01, 1.09820986e+00, -3.75631481e-01, -1.33836254e-01, 6.32796347e-01, -2.02802300e-01, 6.25178933e-01, 6.77876830e-01, -2.75646240e-01, -5.96459627e-01, -2.86792219e-01, -8.54366064e-01, 8.39510620e-01, -1.31479844e-01, 3.25115770e-01, -4.99351650e-01, 2.03135818e-01, -1.43900430e+00, -2.20209926e-01, -2.65229672e-01, 7.82352269e-01, -5.65962434e-01, -3.06415796e-01, 1.99779794e-01, -8.66775632e-01, 4.85115051e-01, 1.44741565e-01, -6.92898750e-01, -2.17116451e+00, -4.12736893e-01, 3.95528555e-01, -1.70124784e-01, 1.67738914e-01, 1.08319551e-01, -8.58196616e-01, -7.99020886e-01, -1.58257377e+00, 7.09277153e-01, -6.97348595e-01, -3.49428415e-01, -1.84181049e-01, -1.62712783e-01, 3.94277692e-01, 7.23135471e-01, 9.47946787e-01, 5.40045500e-01, -8.75189006e-01, -1.86740071e-01, -3.83477867e-01, -3.24022211e-02, 8.44550133e-01, 5.08218348e-01, 1.74616441e-01, 9.65049744e-01, 1.43482059e-01, -4.31216598e-01, -2.10186943e-01, -5.37824035e-01, -3.14835757e-01, -1.09177876e+00, 1.27525091e+00, -7.89696574e-01, -7.59191632e-01, 1.91085026e-01, -2.13713408e-01, 9.87634897e-01, 7.08811343e-01, 1.55087793e+00, 2.73356378e-01, 6.54023588e-01, -8.55911076e-01, 1.92686439e-01, -1.50089972e-02, 2.38779679e-01, 1.49614379e-01, 3.62314701e-01, 6.94537103e-01, -3.87004137e-01, 2.10883880e+00, -3.75697196e-01, -1.82452798e-01, -3.22899401e-01, -8.25561047e-01, 1.80501044e+00, 5.33488870e-01, 2.24471204e-02, 6.21750236e-01, 1.03810385e-01, -9.79628026e-01, 9.70385015e-01, -7.47687459e-01, -4.07829493e-01, 1.48922369e-01, -1.19734859e+00, -3.71993333e-01, 4.34708387e-01, -8.65958393e-01, -5.35230339e-01, 1.72286785e+00, 2.20375031e-01, 5.11880279e-01, -7.53360510e-01, 1.08028436e+00, -4.57028896e-01, -1.50861815e-02, 7.17765152e-01, 4.38092917e-01, 3.15289497e-01, 2.67259568e-01, 6.93954825e-02, 3.62798750e-01, 1.36038041e+00, 1.30169702e+00, -4.57468122e-01, -4.37783718e-01, -5.08757949e-01, 8.63207519e-01, -2.89590597e-01, 1.10191441e+00, 1.98435009e-01, 3.19641560e-01, -1.21980719e-01, 1.29272318e+00, 1.45268068e-01, 1.14542401e+00, -4.47698474e-01, 5.11548400e-01, -2.13712007e-01, 7.16760218e-01, 3.56799394e-01, -8.98992419e-01, 2.53364801e-01, 2.46685684e-01, 2.20981494e-01, 2.45370770e+00, -1.58328819e+00, -4.75152791e-01, -6.23002470e-01, 6.19043648e-01, 7.42533743e-01, 9.58551466e-01, -2.75623322e-01, -4.63303924e-01, -1.89976543e-01, -7.62300074e-01, -2.44294450e-01, -1.18391609e+00, -3.18642884e-01, 2.10066810e-01, 1.68145791e-01, -6.57323003e-03, 6.80729449e-01, 1.39025539e-01, 3.32543373e-01, -4.70169991e-01, 2.51329923e+00, 5.39556563e-01, 6.31205678e-01, 3.46641839e-01, -1.85673684e-02, -2.24657819e-01, 8.87112379e-01, -3.31156075e-01, -6.33936048e-01, -7.78989196e-01, -7.24589527e-01, -8.97557616e-01, -1.19332623e+00, 9.22472417e-01, -7.65920877e-01, 3.12098682e-01, -1.39098316e-02, -8.49792808e-02, 1.01152039e+00, 2.23431200e-01, -1.90913692e-01, 2.77387857e-01, -1.03543140e-02, -7.31578097e-03, 2.77540356e-01, 6.14465535e-01, 1.22704911e+00, -1.18605226e-01, 4.48604554e-01, -8.49792808e-02, 1.01152039e+00, 2.23431200e-01, -1.90913692e-01, 2.77387857e-01, -1.03543140e-02, -7.31578097e-03, 2.77540356e-01, 6.14465535e-01, 1.22704911e+00, -1.18605226e-01, 4.48604554e-01, 2.77387857e-01, -1.03543140e-02, -7.31578097e-03, 2.77540356e-01, 6.14465535e-01, 1.22704911e+00, -1.18605226e-01, 4.48604554e-01, 3.99403453e-01, 9.76211205e-02, -2.72304147e-01, -6.34450793e-01, 6.14465535e-01, 1.22704911e+00, -1.18605226e-01, 4.48604554e-01, 3.99403453e-01, 9.76211205e-02, -2.72304147e-01, -6.34450793e-01, 3.99403453e-01, 9.76211205e-02, -2.72304147e-01, -6.34450793e-01, -8.57364178e-01, -6.94554448e-01, -3.04330140e-01, 1.05320036e-01, -8.57364178e-01, -6.94554448e-01, -3.04330140e-01, 1.05320036e-01, 1.73476115e-01, 1.00599945e+00, 3.46087098e-01, 3.30770224e-01, -2.74857372e-01, -2.06077129e-01, 7.10511386e-01, 1.58540100e-01, -5.68631530e-01, -3.54029030e-01, -1.38866380e-01, -1.23456165e-01, 5.68514943e-01, 2.85906672e-01, -1.28487337e+00, -9.45348591e-02, 4.24727708e-01, 3.99977595e-01, 2.40924731e-01, -4.46219951e-01, 8.51806283e-01, 1.41895026e-01, -5.66927195e-01, -1.45217299e-01, 4.25449193e-01, -3.61947298e-01, 7.06071258e-01, -5.11380136e-01, -6.05433211e-02, -9.70409751e-01, -4.07448590e-01, -1.02107680e+00]
Qdrant交互
-
创建m3e_collection
-
{ "vectors": { "size": 768, "distance": "Cosine" } }
-
存入四条向量数据,由"老王是领导", “老王是研发”, “老王是程序员”, "老王是开发者"生成。我们使用的是cosine, 因此结果中score 越接近1, 表明两者越相似。
使用"老王爱写代码"查询
-
{ "vector": [7.59560585e-01, -1.27109140e-01, 5.14054596e-02, -1.59693062e-01, -4.17063087e-02, -8.19702983e-01, 2.41449431e-01, 1.33715153e-01, -1.03617609e+00, -2.28319705e-01, 6.17243648e-01, -5.24424016e-01, 1.80304646e-01, -8.68997991e-01, -4.62767482e-01, -1.98709533e-01, 5.47812641e-01, 9.67402101e-01, -6.81963444e-01, -3.16316262e-03, 3.28954935e-01, 2.92346120e-01, -4.04711217e-01, 5.90863824e-01, -5.51401138e-01, -4.15514529e-01, -5.02967536e-02, -5.48850775e-01, 1.71392083e-01, -3.95615220e-01, 1.63737941e+00, -7.76524067e-01, -6.15127012e-02, 2.51650959e-01, 3.76678944e-01, 1.65224802e-02, 5.55427015e-01, -1.07243016e-01, 7.81503201e-01, 4.54563320e-01, 8.13240632e-02, 2.48942882e-01, 3.32837075e-01, -3.30844522e-03, 2.85081953e-01, 6.52864814e-01, -1.77730799e-01, -1.86786592e-01, -1.19947433e+00, 3.59263033e-01, 3.06981385e-01, 6.67714453e+00, -8.61118436e-01, -6.59109000e-03, -1.59015369e+00, 1.00160849e+00, -9.57870841e-01, 1.28927857e-01, -5.81352055e-01, 3.86609472e-02, 1.29876643e-01, -4.77568775e-01, 1.63034528e-01, -5.18439829e-01, 1.48755103e-01, 1.29043326e-01, 3.16139519e-01, 3.20954382e-01, 4.15887743e-01, -8.86846662e-01, 4.58009601e-01, -8.47651720e-01, -3.94439220e-01, -2.18782693e-01, 3.68612200e-01, 2.94382125e-02, 3.30451459e-01, 2.67671227e-01, 3.67975801e-01, -4.38472450e-01, 6.25256062e-01, 1.34776592e-01, -1.41976073e-01, 1.92134783e-01, -2.18996853e-01, -3.41829687e-01, -1.87255695e-01, -1.71571851e-01, 1.01223254e+00, 6.13354325e-01, -1.41107845e+00, 1.39829889e-01, -4.25042689e-01, 4.70361635e-02, -6.58033252e-01, 2.33138055e-01, 3.01239669e-01, -1.00470805e+00, -4.89165574e-01, -1.02200963e-01, 1.02289163e-01, -1.42863184e-01, -9.79841352e-02, -4.12617832e-01, 8.39702964e-01, 1.32274532e+00, -9.45372462e-01, 8.20253640e-02, 3.01673234e-01, -1.21201307e-01, 2.79277682e-01, -1.15093338e+00, -5.73418975e-01, 5.75947762e-01, -1.74676076e-01, -3.59989926e-02, -2.45318599e-02, 4.47047085e-01, 3.44157889e-02, -3.95211458e-01, 5.85954450e-03, 4.04485404e-01, 1.90305263e-01, -1.00965261e+00, -7.10118562e-02, -2.32678965e-01, -7.37744719e-02, 5.08088946e-01, -6.53338075e-01, 1.19432044e+00, -5.16369700e-01, 1.22984111e-01, -6.55934036e-01, -5.52078784e-01, 2.12076426e-01, -9.62440372e-02, -2.25091249e-01, -2.57290483e-01, -1.55814445e+00, -3.92937481e-01, 1.97502041e+00, 2.88003266e-01, 3.64899725e-01, -2.91331321e-01, -4.12321925e-01, 2.03414634e-01, -1.91754445e-01, 3.66561532e-01, 1.09342627e-01, -2.96878479e-02, -1.77043572e-01, -7.04252958e-01, 3.78284574e-01, 5.88100553e-01, 2.94542938e-01, -4.53098804e-01, -1.35240722e+00, 6.66298717e-02, -1.18963647e+00, -5.60218394e-01, -9.98719037e-02, -5.41272998e-01, -5.11893511e-01, 1.13323182e-01, -3.41559052e-01, 1.27054405e+00, 3.10296893e-01, -3.91244650e-01, -5.92112660e-01, 3.81372511e-01, -7.09137559e-01, -5.72127700e-01, -6.75038695e-01, -1.27276570e-01, 5.50326467e-01, 1.70973629e-01, -7.06340492e-01, 1.09366155e+00, -2.62876391e-01, -1.71785370e-01, -1.27242553e+00, -3.32011551e-01, -3.68874252e-01, -2.70302027e-01, -6.39186054e-02, 2.25251857e-02, -1.21960545e+00, -2.92267725e-02, 2.19343245e-01, 9.03854549e-01, -1.61024642e+00, -1.19817674e+00, -2.43373215e-01, 1.97811037e-01, 6.99667692e-01, 1.08220398e+00, -1.42966902e+00, -6.23148620e-01, -1.14598131e+00, 3.03221524e-01, 1.35328427e-01, -5.62619567e-01, 5.68072855e-01, 1.00827527e+00, -1.42113477e-01, 8.93693328e-01, -7.74117466e-03, 3.73539865e-01, 7.99027622e-01, 1.09404874e+00, -1.18285084e+00, -1.23149085e+00, -8.11075494e-02, -6.34984076e-02, 1.34655863e-01, 2.48995468e-01, -4.60455269e-01, 1.62918717e-01, -7.58928180e-01, -6.69559538e-01, 1.34634882e-01, 1.34181201e-01, -3.73341367e-02, -8.89802575e-01, -9.93391454e-01, -4.52038705e-01, -4.21833605e-01, -4.91406843e-02, 3.05946171e-01, -3.07202816e-01, 7.82340109e-01, -1.00563467e+00, -1.00400865e-01, -2.64248490e-01, 4.65716511e-01, 4.17140901e-01, -3.88314426e-01, 9.80030656e-01, -3.96880955e-01, -7.87510350e-03, -4.28324640e-02, 1.10107791e+00, 1.79232597e-01, -1.29689205e+00, -3.90284508e-01, 1.02558434e+00, 6.04968727e-01, -6.81580603e-01, -8.27678978e-01, -4.23272520e-01, -5.92301935e-02, 3.44731659e-01, 2.54145443e-01, -1.15404820e+00, -1.03138164e-01, 5.55383801e-01, 3.37476492e-01, -5.15083194e-01, 6.99012876e-01, -1.58016816e-01, -3.40833396e-01, 3.49915504e-01, 1.39090860e+00, 4.58933473e-01, 4.26962338e-02, -3.71650428e-01, -1.68823689e-01, -1.08074808e+00, -9.05070901e-01, -5.02089858e-01, 4.17415679e-01, 6.67661846e-01, -9.61706638e-02, 2.11916063e-02, 5.62160134e-01, -6.44293189e-01, 3.17710936e-01, -3.41923118e-01, -8.82506490e-01, -1.07720530e+00, -3.00090283e-01, 9.13380504e-01, 9.57989216e-01, 3.72398585e-01, -9.98427093e-01, -6.91964507e-01, 5.92603028e-01, 7.90655553e-01, -1.06618869e+00, -1.30195391e+00, -1.20785582e+00, -2.04321653e-01, -3.76093715e-01, 1.33960694e-01, 2.50592518e+00, -5.28230846e-01, -6.59069419e-01, 7.36321807e-01, 7.97808111e-01, -1.06570244e+00, -1.43543527e-01, -6.55247211e-01, -7.19331861e-01, 8.15252602e-01, -8.67068917e-02, 1.07031262e+00, 3.90325516e-01, 9.45663303e-02, -8.35210085e-01, -1.21028841e-01, -1.61372471e+00, 1.09380625e-01, -1.59053236e-01, -2.58469820e-01, -5.18571377e-01, 3.15038502e-01, -6.21809185e-01, 1.38990045e-01, 1.67350203e-01, 3.30487221e-01, 7.23021626e-01, 2.61946917e-02, 1.08872366e+00, 3.58943760e-01, 8.15560222e-02, -1.10836700e-01, 1.13304579e+00, 1.04639006e+00, -4.26227301e-01, 1.05273044e+00, 6.38412178e-01, -6.83263779e-01, -7.28904009e-02, 8.67998898e-01, 9.42042649e-01, 1.05305696e+00, -5.23684144e-01, -1.82113022e-01, -1.05253243e+00, -7.09312260e-02, 1.22970134e-01, 6.60896778e-01, 9.44130838e-01, -1.19117057e+00, -4.81023014e-01, -1.17151785e+00, 2.22483501e-01, -1.77511990e+00, -3.02142978e-01, -7.96750426e-01, -1.64792848e+00, -4.40994382e-01, -1.09868455e+00, -5.65342665e-01, 3.71169806e-01, 6.77822471e-01, 7.26896048e-01, 5.60501277e-01, -2.84232572e-03, 1.48416114e+00, -2.80948758e-01, 1.86195932e-02, -1.25779772e+00, 1.01117504e+00, 3.95043612e-01, -1.06091559e+00, 4.55376178e-01, 5.90852499e-01, -3.76404703e-01, -1.27505803e+00, 8.27442050e-01, 3.85000587e-01, 1.18777728e+00, 1.92020565e-01, 8.64256859e-01, 1.10247850e+00, -4.77612466e-01, -4.49791044e-01, 4.36293602e-01, -2.63684958e-01, 4.44416553e-01, -4.19982970e-01, 5.77375650e-01, -3.79977077e-01, 3.84563029e-01, -5.36517262e-01, -5.43187335e-02, -1.10158217e+00, -5.05689621e-01, -1.06836462e+00, -9.12110388e-01, -2.28145525e-01, 6.85708761e-01, -1.44891381e-01, 7.85060003e-02, 1.71833351e-01, 2.17102796e-01, 8.75280976e-01, 5.29666305e-01, 2.00214505e-01, 3.49758655e-01, -8.35674644e-01, 9.26342085e-02, 1.84430435e-01, 3.72666001e-01, -2.19136089e-01, 5.18518388e-01, -6.22629523e-02, 7.33491540e-01, -2.63249248e-01, -2.67214417e-01, 7.73090571e-02, -6.45493627e-01, -3.19644272e-01, -2.89276928e-01, 3.45991284e-01, 5.67886233e-03, -2.49789566e-01, 1.04345548e+00, -8.97620797e-01, 2.59745389e-01, -2.35038638e-01, 9.35924470e-01, 1.03495073e+00, 9.25333023e-01, 2.22500831e-01, 2.08737642e-01, 3.27550352e-01, -6.99261762e-03, -3.94405961e-01, 2.15240449e-01, -4.14843351e-01, 6.27586007e-01, 3.00344199e-01, 1.09458768e+00, 7.59830773e-02, -6.83943391e-01, 1.67123511e-01, -5.07802606e-01, -2.70432144e-01, -6.21037364e-01, 9.64937747e-01, 1.25556087e+00, -3.15922976e-01, -5.63388944e-01, -1.46975935e-01, 1.02344620e+00, -4.48462069e-01, 9.04044926e-01, -2.81636208e-01, 1.05440784e+00, 2.14560971e-01, 7.86892548e-02, -1.28740996e-01, -5.30646369e-02, -7.13777184e-01, -3.04264992e-01, -5.53258777e-01, 4.91248667e-01, -5.39805472e-01, -8.68568122e-01, 8.64456892e-01, -9.18175802e-02, 4.13068295e-01, -2.08863601e-01, 4.28583443e-01, 1.23620534e+00, -8.92189264e-01, 1.37983215e+00, 4.38869357e-01, -3.87700319e-01, 1.12864268e+00, -5.82494810e-02, 1.43608093e-01, -5.40578723e-01, 1.17179848e-01, 2.51674443e-01, -1.42769992e-01, -1.31010675e+00, -8.51148784e-01, -1.48061931e-01, 2.58323908e-01, 3.67341787e-02, -7.23920584e-01, -9.88820434e-01, -1.39375091e-01, -1.14198053e+00, -7.28593171e-02, -1.04956701e-01, -5.85499108e-01, -6.31171286e-01, -5.10103285e-01, 1.05367959e+00, -6.68842137e-01, 4.63386625e-02, -9.96850908e-01, -9.28651869e-01, 7.93903470e-01, -8.99808407e-01, 8.27691436e-01, 9.12066579e-01, -4.78461653e-01, 8.14078569e-01, 6.02525920e-02, 5.26673317e-01, -5.26469648e-01, -7.05779612e-01, -1.71829477e-01, 1.62325189e-01, 2.85767645e-01, 5.12952507e-01, -1.45051509e-01, 1.37109146e-01, 1.83014393e-01, -1.55559137e-01, 2.12739974e-01, -9.23290730e-01, -1.19877413e-01, 2.81804621e-01, 3.34185094e-01, 1.39511657e+00, -5.90442002e-01, 5.74788213e-01, 1.24385524e+00, -7.21555293e-01, 8.28844130e-01, -8.85802656e-02, -4.08442408e-01, 6.71276212e-01, 1.09820986e+00, -3.75631481e-01, -1.33836254e-01, 6.32796347e-01, -2.02802300e-01, 6.25178933e-01, 6.77876830e-01, -2.75646240e-01, -5.96459627e-01, -2.86792219e-01, -8.54366064e-01, 8.39510620e-01, -1.31479844e-01, 3.25115770e-01, -4.99351650e-01, 2.03135818e-01, -1.43900430e+00, -2.20209926e-01, -2.65229672e-01, 7.82352269e-01, -5.65962434e-01, -3.06415796e-01, 1.99779794e-01, -8.66775632e-01, 4.85115051e-01, 1.44741565e-01, -6.92898750e-01, -2.17116451e+00, -4.12736893e-01, 3.95528555e-01, -1.70124784e-01, 1.67738914e-01, 1.08319551e-01, -8.58196616e-01, -7.99020886e-01, -1.58257377e+00, 7.09277153e-01, -6.97348595e-01, -3.49428415e-01, -1.84181049e-01, -1.62712783e-01, 3.94277692e-01, 7.23135471e-01, 9.47946787e-01, 5.40045500e-01, -8.75189006e-01, -1.86740071e-01, -3.83477867e-01, -3.24022211e-02, 8.44550133e-01, 5.08218348e-01, 1.74616441e-01, 9.65049744e-01, 1.43482059e-01, -4.31216598e-01, -2.10186943e-01, -5.37824035e-01, -3.14835757e-01, -1.09177876e+00, 1.27525091e+00, -7.89696574e-01, -7.59191632e-01, 1.91085026e-01, -2.13713408e-01, 9.87634897e-01, 7.08811343e-01, 1.55087793e+00, 2.73356378e-01, 6.54023588e-01, -8.55911076e-01, 1.92686439e-01, -1.50089972e-02, 2.38779679e-01, 1.49614379e-01, 3.62314701e-01, 6.94537103e-01, -3.87004137e-01, 2.10883880e+00, -3.75697196e-01, -1.82452798e-01, -3.22899401e-01, -8.25561047e-01, 1.80501044e+00, 5.33488870e-01, 2.24471204e-02, 6.21750236e-01, 1.03810385e-01, -9.79628026e-01, 9.70385015e-01, -7.47687459e-01, -4.07829493e-01, 1.48922369e-01, -1.19734859e+00, -3.71993333e-01, 4.34708387e-01, -8.65958393e-01, -5.35230339e-01, 1.72286785e+00, 2.20375031e-01, 5.11880279e-01, -7.53360510e-01, 1.08028436e+00, -4.57028896e-01, -1.50861815e-02, 7.17765152e-01, 4.38092917e-01, 3.15289497e-01, 2.67259568e-01, 6.93954825e-02, 3.62798750e-01, 1.36038041e+00, 1.30169702e+00, -4.57468122e-01, -4.37783718e-01, -5.08757949e-01, 8.63207519e-01, -2.89590597e-01, 1.10191441e+00, 1.98435009e-01, 3.19641560e-01, -1.21980719e-01, 1.29272318e+00, 1.45268068e-01, 1.14542401e+00, -4.47698474e-01, 5.11548400e-01, -2.13712007e-01, 7.16760218e-01, 3.56799394e-01, -8.98992419e-01, 2.53364801e-01, 2.46685684e-01, 2.20981494e-01, 2.45370770e+00, -1.58328819e+00, -4.75152791e-01, -6.23002470e-01, 6.19043648e-01, 7.42533743e-01, -4.50964779e-01, 8.05252671e-01, 7.01121390e-02, 1.94267094e-01, 9.58551466e-01, -2.75623322e-01, -4.63303924e-01, -1.89976543e-01, 7.89426208e-01, 5.38144112e-01, 6.55530512e-01, -8.33069980e-01, -7.98664808e-01, 8.72453809e-01, 2.56688178e-01, -1.63096809e+00, -7.62300074e-01, -2.44294450e-01, -1.18391609e+00, -3.18642884e-01, 2.10066810e-01, 1.68145791e-01, -6.57323003e-03, 6.80729449e-01, 1.39025539e-01, 3.32543373e-01, -4.70169991e-01, 2.51329923e+00, -7.84055650e-01, 6.36785984e-01, -2.01801226e-01, -6.74835324e-01, 5.39556563e-01, 6.31205678e-01, 3.46641839e-01, -1.85673684e-02, -2.24657819e-01, 8.87112379e-01, -3.31156075e-01, -6.33936048e-01, -7.78989196e-01, -7.24589527e-01, -8.97557616e-01, -1.19332623e+00, 9.22472417e-01, -7.65920877e-01, 3.12098682e-01, -1.39098316e-02, -8.49792808e-02, 1.01152039e+00, 2.23431200e-01, -1.90913692e-01, 2.77387857e-01, -1.03543140e-02, -7.31578097e-03, 2.77540356e-01, 6.14465535e-01, 1.22704911e+00, -1.18605226e-01, 4.48604554e-01, 3.99403453e-01, 9.76211205e-02, -2.72304147e-01, -6.34450793e-01, -8.57364178e-01, -6.94554448e-01, -3.04330140e-01, 1.05320036e-01, 1.73476115e-01, 1.00599945e+00, 3.46087098e-01, 3.30770224e-01, -2.74857372e-01, -2.06077129e-01, 7.10511386e-01, 1.58540100e-01, -5.68631530e-01, -3.54029030e-01, -1.38866380e-01, -1.23456165e-01, 5.68514943e-01, 2.85906672e-01, -1.28487337e+00, -9.45348591e-02, 4.24727708e-01, 3.99977595e-01, 2.40924731e-01, -4.46219951e-01, 8.51806283e-01, 1.41895026e-01, -5.66927195e-01, -1.45217299e-01, 4.25449193e-01, -3.61947298e-01, 7.06071258e-01, -5.11380136e-01, -6.05433211e-02, -9.70409751e-01, -4.07448590e-01, -1.02107680e+00], "limit": 4, "with_payload": true }
-
输出
-
{ "result": [{ "id": 3, "version": 0, "score": 0.9361942, "payload": { "sentence": "老王是程序员" } }, { "id": 4, "version": 0, "score": 0.9035911, "payload": { "sentence": "老王是开发者" } }, { "id": 2, "version": 0, "score": 0.88393474, "payload": { "sentence": "老王是研发" } }, { "id": 1, "version": 0, "score": 0.8612121, "payload": { "sentence": "老王是领导" } }], "status": "ok", "time": 0.000412088 }
使用"老王爱汇报"查询
-
{ "result": [{ "id": 1, "version": 0, "score": 0.8335363, "payload": { "sentence": "老王是领导" } }, { "id": 2, "version": 0, "score": 0.81425905, "payload": { "sentence": "老王是研发" } }, { "id": 4, "version": 0, "score": 0.80951333, "payload": { "sentence": "老王是开发者" } }, { "id": 3, "version": 0, "score": 0.7966002, "payload": { "sentence": "老王是程序员" } } ], "status": "ok", "time": 0.000405555 }
-
使用上述两个示例, 帮助我们更好的感受文本相似度。