嵌入向量生成与查询

news2024/11/18 5:47:42

嵌入向量生成与查询

文本嵌入模型

  • 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
    }
    
  • 使用上述两个示例, 帮助我们更好的感受文本相似度。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2184336.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

React 原理分析

优质博文:IT-BLOG-CN 一、简介 为什么我要用react?JQuery也挺好的呀? 1、因为浏览器和JavaScript一直在更新,新版前端框架可以更好对接新的API,更好的利用浏览器的能力, 提供更新潮强大的功能。 2、react…

C++中,如何使你设计的迭代器被标准算法库所支持。

iterator(读写迭代器) const_iterator(只读迭代器) reverse_iterator(反向读写迭代器) const_reverse_iterator(反向只读迭代器) 以经常介绍的_DList类为例,它的迭代…

番茄间的一分钟休息

很多人喜欢使用番茄工作法,在25分钟内集中工作。这种方法提高了25分钟内的工作效率,但是也增加了自己的疲劳程度。 我建议,在25分钟的工作时间内,要保持对自己身体的觉察。如果感觉呼吸短促,有一些紧张,用…

C0007.Clion中添加ui文件及运行的完整步骤

1.创建ui文件 选择Ui文件目录,右击,打开Qt Designer; 创建完成后,保存ui界面,并且命名为test.ui; 2.新建头文件test.h 在include目录中,新建头文件,文件名为test.h 3.新建test.…

ScrapeGraphAI 大模型增强的网络爬虫

在数据驱动的动态领域,从在线资源中提取有价值的见解至关重要。从市场分析到学术研究,对特定数据的需求推动了对强大的网络抓取工具的需求。 NSDT工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线…

C++语言学习(1): std::endl 在做什么?

std::endl 是一个函数(而不是变量): std::endl 会向控制台写入 \n 字符,并且刷新缓冲。 刷新缓冲肯定比不刷新缓冲慢。 这就是为什么有些 guide 里提到,少用 std::endl, 多用 \n.

Notepad++ 之 AndroidLogger插件

背景 最近一段时间在分析Android log 定位问题,Notepad 之前用的比较少,现在看log觉得确实好用,美中不足的是 看Android log的时候不像 logcat -v color 可以区分不同等级的颜色,于是调研了一下,发现大部分都是使用An…

DAY84服务攻防-端口协议桌面应用QQWPS 等 RCEhydra 口令猜解未授权检测

Day84:服务攻防-端口协议&桌面应用&QQ&WPS等RCE&hydra口令猜解&未授权检测_wps漏洞复现 rce-CSDN博客https://blog.csdn.net/qq_61553520/article/details/137119893?ops_request_misc%257B%2522request%255Fid%2522%253A%25220E34BCAF-166A-4…

Python 实现指定股票三日趋势分析脚本及原理详解

以下是一个基于Python的股票三日趋势分析脚本,它能够分析指定股票在三天内的趋势变化情况。脚本主要依赖pandas、numpy、matplotlib和yfinance等库。分析内容包括收盘价的涨跌趋势、成交量变化,并生成可视化图表来帮助用户更好地理解短期趋势。 脚本的分…

汇总binder相关一些常见面试题-安卓系统常见面试题

背景: 国庆前有几个学员朋友在群里讨论了几个binder相关的面试题,讨论较为激烈,这里马哥统一整理一下列出来了,并且也补充了几个,大家有兴趣的可以尝试做一下,后续方便每个学员进行查缺补漏。后续会进行整…

三维地图场景学习总结 20241002

1. 学习内容 1.1 cesium 学习 基础教程:提供了cesium的配置方式及简单案例 dvgis:该网址提供了关系cesium的使用案例 1.2 OpenStreetMap 学习 List_of_OSM-based_services:提供了openstreetmap所有相关工具及相关使用案例 1.3 三维场景渲…

生信初学者教程(十一):数据校正

文章目录 介绍加载R包导入数据准备数据ComBatremoveBatchEffectVoom SNM批次效应校正结果比较校正后的结果输出校正后的结果总结介绍 批次效应在生物学数据分析中是一个普遍存在的问题,它指的是由于实验过程中非生物学因素(如样本处理时间、实验条件、测序平台等)的差异,导…

如何使用ssm实现基于HTML的中国传统面食介绍网站的搭建+vue

TOC ssm758基于HTML的中国传统面食介绍网站的搭建vue 第1章 绪论 1.1选题动因 当前的网络技术,软件技术等都具备成熟的理论基础,市场上也出现各种技术开发的软件,这些软件都被用于各个领域,包括生活和工作的领域。随着电脑和笔…

前端框架对比和选择指南

前端框架对比和选择指南 随着 Web 开发技术的快速发展,前端框架已经成为了现代 Web 开发的核心工具之一。它们为开发人员提供了快速构建高效、交互性强的应用的基础。当前流行的前端框架主要包括 React.js、Vue.js 和 Angular.js。在这篇技术博客中,我们…

dubbo微服务

一.启动nacos和redis 1.虚拟机查看是否开启nacos和redis docker ps2.查看是否安装nacos和redis docker ps -a3.启动nacos和redis docker start nacos docker start redis-6379 docker ps二.创建三个idea的maven项目 1.第一个项目dubboapidemo 2.1.1向pom.xml里添加依赖 …

uniapp微信小程序使用ucharts遮挡自定义tabbar的最佳解决方案

如图所示: 使用的ucharts遮挡住了我自定义的tabbar(如果不是提需求的有病,我才不会去自定义tabbar) 查阅了不少文档,说是开启 ucharts 的 canvas2d 即可: 官网文档地址: uCharts官网 - 秋云…

忽有庞然大物,拔山倒树而来 – 盖RAD Studio 12.2是也

忽有庞然大物,拔山倒树而来 – 盖RAD Studio 12.2是也 不知为什么, 在看到RAD Studio 12.2推出的新功能之后, 脑中出现的第1个反应就是小时候唸的”忽有庞然大物,拔山倒树而来” 这句话, 因为12.2的新功能出乎我意料之外的巨大, 根本不象是一个0.2…

攻防世界---->SignIn

做题笔记。 下载 查壳。 64ida打开。 先运行一下程序: 那么,我们可以直接查找字符串看看,锁定位置。 ### 纠正一下:应该是 n 值 不是d值 n p*q 。。。### ### v6的值 应该就是 我们func(input,49) 进行加密后的值。 (猜测的&a…

《向量数据库指南》——非结构化数据挑战升级:如何高效导入向量数据库?

哈哈,说到 AI 应用中的非结构化数据处理,这可真是个让人又爱又恨的话题啊!今天呢,咱就聊聊这个话题,尤其是那个让人头疼的如何将各种数据源和格式的非结构化数据导入向量数据库的问题。 非结构化数据处理:挑战与复杂性 在 AI 应用领域,非结构化数据无处不在,从社交媒…

【递归】11. leetcode 129 求根节点到叶节点数字之和

1 题目描述 题目链接: 求根节点到叶节点数字之和 2 解答思路 第一步:挖掘出相同的子问题 (关系到具体函数头的设计) 第二步:只关心具体子问题做了什么 (关系到具体函数体怎么写,是一个宏观…