Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: support sparse vector for bge-m3 #2540

Merged
merged 15 commits into from
Nov 22, 2024
Merged

Conversation

pengjunfeng11
Copy link
Contributor

@pengjunfeng11 pengjunfeng11 commented Nov 11, 2024

支持bge-m3模型的稀疏向量生成功能,

调用方式为:model.create_embedding(text, return_sparse=True)

新增convert_ids_to_tokens方法

该方法可将token_id转换为人类可读文字,调用方式为

from xinference.client import Client

client = Client("http://ip:port")
model = client.get_model(model_name)
seq = model.convert_ids_to_tokens(key_list)

该方法返回类型为List[str],如传入List[str],将按顺序返回值

Fixes #2527 .

@XprobeBot XprobeBot added this to the v0.16 milestone Nov 11, 2024
@qinxuye qinxuye changed the title sparse vector support FEAT: support sparse vector for bge-m3 Nov 11, 2024
@qinxuye
Copy link
Contributor

qinxuye commented Nov 15, 2024

For convert_ids_to_tokens, can you add a test to verify it to

https://github.com/xorbitsai/inference/blob/main/xinference/model/embedding/tests/test_embedding_models.py

For bge-m3, it's too large for CI, we can test it manually.

@pengjunfeng11
Copy link
Contributor Author

For convert_ids_to_tokens, can you add a test to verify it to

main/xinference/model/embedding/tests/test_embedding_models.py

For bge-m3, it's too large for CI, we can test it manually.

OK

@qinxuye
Copy link
Contributor

qinxuye commented Nov 20, 2024

About reloading in get_embeddings, it's sort of breaking the current design, is it possible to load hybrid mode in advance to support sparse instead of reloading?

Copy link
Contributor

@qinxuye qinxuye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qinxuye qinxuye merged commit f2b22bb into xorbitsai:main Nov 22, 2024
13 checks passed
@lmolhw5252
Copy link

您好,
已更新v1.0.1 部署bge-m3
调用方式
curl http://localhost:9997/v1/embeddings \ -H "Content-Type: application/json" \ -d '{ "input": "测试ebmeddings", "model": "bge-m3" }'

输出结果
{"object":"list","model":"bge-m3-0","data":[{"index":0,"object":"embedding","embedding":[-0.04604385793209076,-0.029126456007361412,-0.00529841473326087,-0.006523269694298506,-0.013490816578269005,-0.03337893635034561,0.02439737692475319,-0.03034304454922676,0.008534069173038006,-0.005122436210513115,-0.05194900929927826,0.004064634907990694,0.015142815187573433,0.000042782881791936234,0.016455188393592834,-0.02856031246483326,-0.012678087688982487,-0.03227345272898674,-0.01931859739124775,-0.07516235113143921,-0.03358013182878494,-0.04792957752943039,0.038128290325403214,0.016266878694295883,-0.008757623843848705,0.03945262357592583,-0.08221528679132462,0.0005865582497790456,0.04983450844883919,-0.020075716078281403,-0.012835495173931122,0.019004439935088158,0.023942070081830025,-0.04249326139688492,-0.017036451026797295,-0.0012883071321994066,0.004572800826281309,-0.03743869066238403,-0.04191333428025246,-0.01806463859975338,-0.015125664882361889,-0.009685643948614597,0.018780698999762535,-0.04026232287287712,0.005524180363863707,-0.022370103746652603,0.020360523834824562,-0.028514310717582703,-0.013898404315114021,-0.03786025196313858,0.005325477570295334,0.03829166665673256,0.025551458820700645,-0.031435150653123856,0.018725259229540825,0.0518522635102272,0.01030291523784399,0.029779545962810516,-0.08157116174697876,-0.025148959830403328,-0.012578606605529785,0.030995143577456474,-0.02332298643887043,0.03421041741967201,0.018365751951932907,0.01931469514966011,-0.02328280359506607,-0.013310645706951618,-0.03858063369989395,-0.04224191978573799,-0.022491658106446266,0.010217142291367054,0.01217228826135397,0.02423980087041855,-0.051994215697050095,0.030370360240340233,0.01875845156610012,-0.027164550498127937,0.0014314608415588737,-0.022466616705060005,0.03541479632258415,-0.015831435099244118,-0.027753576636314392,0.011553257703781128,-0.015905283391475677,0.06175083667039871,-0.009260174818336964,-0.007976812310516834,-0.004825358744710684,0.018083134666085243,-0.026491263881325722,-0.016278525814414024,0.014005634002387524,-0.03400354087352753,-0.023670872673392296,0.009051971137523651,-0.02802387811243534,0.018369268625974655,0.06173993647098541,0.033902160823345184,-0.015278668142855167,0.009357872419059277,-0.0045003886334598064,0.03276104852557182,0.031332168728113174,0.014935112558305264,0.03131174296140671,0.03832254186272621,0.013456401415169239,0.0007462339708581567,0.011264362372457981,0.016822222620248795,-0.016039514914155006,0.057713866233825684,0.002838365500792861,0.007086284924298525,-0.07571546733379364,0.005020846147090197,-0.009382961317896843,-0.022304803133010864,0.06501180678606033,0.03402217477560043,0.01952623948454857,-0.051898494362831116,0.030497901141643524,-0.03904484957456589,-0.0022171561140567064,-0.0017648499924689531,-0.04739215597510338,-0.005764839239418507,0.005778302904218435,-0.028450099751353264,-0.014612702652812004,-0.04660738632082939,0.010910139419138432,-0.0006860136636532843,-0.0389135405421257,0.037176407873630524,-0.015402857214212418,-0.05434243381023407,-0.007945903576910496,0.012199519202113152,-0.019285520538687706,-0.03946128860116005,-0.012468056753277779,-0.09838396310806274,0.012906829826533794,-0.0036584646441042423,0.0018021087162196636,-0.006489022634923458,0.01415557973086834,0.013621034100651741,0.008746661245822906,0.014509853906929493,-0.002701870631426573,-0.00007115585322026163,-0.0358487032353878,0.005922779906541109,0.005875235423445702,0.05729271098971367,0.0012833992950618267,-0.010631521232426167,-0.023526238277554512,-0.027687720954418182,0.009967368096113205,-0.013723870739340782,0.015584702603518963,0.010030734352767467,0.016141533851623535,-0.021117698401212692,0.025901153683662415,-0.017921242862939835,0.014887855388224125,0.040496230125427246,0.020354581996798515,0.011811088770627975,0.07477299124002457,0.01816914603114128,0.016647344455122948,-0.0680510550737381,-0.0017860329244285822,0.04964568838477135,0.021505434066057205,0.014221846126019955,-0.020970169454813004,-0.002924892818555236,0.026437141001224518,-0.028089499101042747,-0.003220551647245884,0.04773680865764618,-0.004141880664974451,-0.06272779405117035,0.03556183725595474,0.02990475669503212,0.01580018177628517,0.022914500907063484,-0.0033618700690567493,0.0368686318397522,0.0011903494596481323,0.002999877091497183,-0.005847234278917313,0.011782829649746418,0.03483477607369423,-0.030359352007508278,0.009255832992494106,-0.024434976279735565,-0.03996998444199562,-0.07868264615535736,0.008336818777024746,0.017998546361923218,-0.0030764334369450808,0.011860193684697151,0.04397423565387726,0.012817742303013802,-0.003891746746376157,-0.03831308335065842,0.004204480908811092,0.04137352854013443,-0.00016630289610475302,-0.027048924937844276,-0.012973828241229057,0.0361005924642086,0.04848453402519226,-0.003646144876256585,-0.008353421464562416,-0.028122948482632637,-0.007711535319685936,0.04131132736802101,0.011024304665625095,-0.05019949749112129,0.0253014974296093,0.007825787179172039,-0.032299160957336426,0.0024993768893182278,-0.009310619905591011,0.000987725448794663,-0.041013412177562714,0.05598897859454155,0.06319805234670639,0.010576874949038029,0.010871327482163906,-0.017004305496811867,0.029243560507893562,-0.012422151863574982,-0.0063285501673817635,-0.0007880419725552201,0.01478077657520771,-0.04085547849535942,0.011431975290179253,-0.02970919758081436,-0.0011933190980926156,-0.033936746418476105,-0.06165551021695137,0.01941009797155857,-0.003129678312689066,0.014049652963876724,-0.009005500935018063,-0.02927190624177456,0.031161056831479073,-0.023434501141309738,0.045556068420410156,0.024086978286504745,0.04400530830025673,0.04741973802447319,-0.004239608533680439,-0.03251064568758011,-0.02112610824406147,0.01287594810128212,0.01622898504137993,-0.017921561375260353,-0.0009594571893103421,-0.026867903769016266,0.047609131783246994,-0.0243223849684,-0.026924068108201027,0.018885938450694084,0.00816210638731718,-0.039708126336336136,0.0362100787460804,0.005212056916207075,-0.025672273710370064,0.014608590863645077,-0.0325128510594368,-0.0346476212143898,0.018542805686593056,-0.03340098261833191,-0.028265714645385742,-0.035603996366262436,-0.0027264675591140985,-0.052643269300460815,-0.02094072848558426,0.004590706434100866,0.058612242341041565,0.012316590175032616,-0.08359653502702713,-0.012066734954714775,-0.002053597243502736,-0.16052329540252686,-0.016568439081311226,-0.003780834376811981,0.02555290423333645,-0.01732010953128338,0.008426462300121784,-0.0591094046831131,0.0009774032514542341,-0.0046181632205843925,0.045732416212558746,-0.008407115936279297,-0.06185086444020271,0.015231318771839142,-0.04624003544449806,-0.015449656173586845,0.011694827117025852,-0.0224919393658638,-0.030008982867002487,0.027687283232808113,-0.004137504380196333,-0.03915403410792351,0.013283437117934227,0.059227604418992996,0.03074299730360508,-0.011184651404619217,-0.050553109496831894,0.0466928593814373,0.025472043082118034,-0.02331041544675827,0.02416168339550495,-0.019448334351181984,0.057902991771698,-0.013549731113016605,0.025122957304120064,0.02627977728843689,0.0591752789914608,0.048513393849134445,0.00611028540879488,-0.04379820451140404,0.008610358461737633,0.006436006166040897,-0.011269486509263515,-0.0070890686474740505,0.01716400310397148,0.06279289722442627,-0.005807168781757355,-0.012115233577787876,0.005423721857368946,-0.037670087069272995,-0.0016552685992792249,-0.012908754870295525,-0.022784527391195297,0.0011664879275485873,-0.016102749854326248,-0.029122253879904747,-0.021906057372689247,0.011884286999702454,0.01895938441157341,-0.013493509963154793,-0.01782437413930893,-0.041447047144174576,-0.04139809310436249,0.007423060480505228,0.031414639204740524,-0.044134557247161865,-0.002796472515910864,0.003914720844477415,-0.03928155079483986,0.017782261595129967,0.0005297909956425428,0.02720917947590351,-0.028532644733786583,0.0464429035782814,0.021041523665189743,-0.01484812330454588,0.033840518444776535,-0.023397058248519897,-0.01964186690747738,-0.04201821610331535,-0.12350736558437347,-0.0339217334985733,0.04450136423110962,-0.015289900824427605,0.05350621044635773,-0.008130636066198349,-0.023633593693375587,0.013275651261210442,-0.002544102491810918,0.03732019290328026,0.19561462104320526,0.011808402836322784,0.03278623893857002,-0.03631392493844032,0.049332309514284134,-0.018385382369160652,-0.0054062060080468655,-0.01066483836621046,-0.012671100907027721,-0.026945270597934723,-0.000017326787201454863,-0.01377619244158268,-0.021898066624999046,0.01772058568894863,-0.021022547036409378,0.009515585377812386,0.0022900481708347797,0.008592041209340096,0.09405656903982162,0.016949065029621124,0.010311225429177284,0.0077826399356126785,0.017575440928339958,0.0029077669605612755,-0.012169594876468182,-0.04160062223672867,0.014662248082458973,0.04970336705446243,-0.033360544592142105,0.03484472632408142,-0.018379777669906616,0.013932452537119389,0.0578148253262043,0.012335647828876972,-0.004842869937419891,0.028109446167945862,-0.020643308758735657,0.009980875067412853,0.038842808455228806,0.033290795981884,-0.017760347574949265,-0.0012231654254719615,-0.026623560115695,0.020923281088471413,0.0021353985648602247,0.020320629701018333,0.0020343258511275053,-0.035546209663152695,-0.002817857777699828,0.04211704432964325,0.004074611235409975,0.011484736576676369,0.06985614448785782,0.006948523689061403,-0.02259114198386669,0.03744565695524216,-0.03825387358665466,-0.022464875131845474,-0.019385075196623802,0.016486959531903267,0.006925140507519245,0.04216954857110977,-0.0020144334994256496,0.03111676126718521,0.023798050358891487,0.02217385545372963,-0.06305284798145294,0.012965439818799496,0.026009880006313324,0.013332769274711609,0.07410158216953278,-0.011120125651359558,-0.03004535846412182,0.006123990751802921,-0.009285722859203815,0.017046701163053513,0.03326726704835892,-0.022147690877318382,0.01635468751192093,-0.015262141823768616,-0.024572305381298065,-0.013474049977958202,-0.06236923858523369,0.006716535426676273,-0.00016663491260260344,0.03201346471905708,-0.005641802214086056,-0.00906108133494854,-0.018280435353517532,-0.03602343052625656,-0.004929191432893276,0.0018246161052957177,-0.030001021921634674,-0.014891184866428375,-0.007463232148438692,0.04694244638085365,0.010439522564411163,-0.05217444524168968,-0.009681877680122852,-0.02105952426791191,-0.017682798206806183,0.0031598147470504045,0.005026880651712418,-0.00744391605257988,-0.032788027077913284,0.02492659166455269,0.031785283237695694,0.02574756182730198,0.04759121313691139,0.02692968025803566,-0.01690039038658142,0.050126925110816956,-0.009996912442147732,-0.043750643730163574,-0.017543179914355278,0.022402353584766388,-0.015502750873565674,0.04903284087777138,-0.023879647254943848,0.006892840843647718,0.011801090091466904,0.04173601046204567,-0.04741973057389259,0.0126557732000947,-0.030203888192772865,0.012514598667621613,-0.033059261739254,0.042197756469249725,-0.03851189836859703,0.030444730073213577,0.014338172972202301,-0.016278136521577835,-0.04007817059755325,0.02279566042125225,0.012138327583670616,0.009086298756301403,0.04360903799533844,0.058100853115320206,0.028666958212852478,0.04508518427610397,0.01883212849497795,-0.044096123427152634,0.00040349195478484035,0.005651986692100763,-0.04173274338245392,-0.004339367151260376,0.0469193272292614,0.021787844598293304,0.01674877665936947,0.014417871832847595,0.035600390285253525,0.006331161595880985,-0.007994706742465496,-0.028501635417342186,0.0010844592470675707,-0.05261500924825668,-0.010023480281233788,-0.03547043353319168,0.014194886200129986,-0.033331479877233505,0.016800589859485626,0.0002658177400007844,-0.011667415499687195,0.04116903990507126,0.03341029956936836,0.03466938063502312,-0.04091882333159447,0.007292162161320448,0.04865869879722595,-0.02494373731315136,0.0045357076451182365,0.002180996583774686,-0.033767394721508026,0.007345755118876696,0.0501905120909214,-0.03990822657942772,-0.013708100654184818,-0.04523048177361488,-0.020911239087581635,0.0393691211938858,-0.01130569726228714,-0.028412051498889923,-0.005110193509608507,0.06992224603891373,0.030883630737662315,-0.030654456466436386,-0.0019086631946265697,0.00275409291498363,0.05429418385028839,-0.031910017132759094,-0.02864273637533188,0.08717666566371918,-0.04313124716281891,-0.020672880113124847,0.008458174765110016,-0.003892963519319892,-0.002106033032760024,0.01969563588500023,0.0038034396711736917,-0.02306871861219406,0.017875518649816513,-0.01845056749880314,-0.0025636525824666023,0.010756687261164188,0.04332274943590164,-0.014504985883831978,-0.015679888427257538,0.015580490231513977,-0.027290157973766327,0.0094929663464427,-0.041346024721860886,0.0025165067054331303,-0.019951963797211647,0.0025285393930971622,-0.047026608139276505,0.004311210475862026,0.04997284337878227,0.010259203612804413,-0.012643170543015003,0.022547157481312752,-0.022337423637509346,0.024787528440356255,-0.025150949135422707,-0.010579710826277733,-0.03637236729264259,-0.03380469232797623,-0.005495845805853605,-0.00045892951311543584,0.0413888655602932,0.04824687913060188,0.00603882409632206,0.03449680283665657,-0.013943953439593315,-0.01607300527393818,0.01673620194196701,0.03473205119371414,-0.0002855684142559767,0.014127680100500584,0.00906394887715578,-0.013710808008909225,-0.02288750745356083,0.002169650746509433,-0.0020111408084630966,0.09199518710374832,-0.000553179532289505,0.01328995916992426,-0.03033692017197609,0.04578867927193642,0.014794963411986828,-0.04268645495176315,-0.0017998985713347793,-0.020375192165374756,0.026988977566361427,-0.03165459260344505,0.01488446444272995,0.02612108364701271,0.016911419108510017,-0.057283371686935425,-0.01899932697415352,0.036786120384931564,-0.040373362600803375,0.01340899895876646,-0.02724609337747097,-0.0011021201498806477,0.0008002074901014566,-0.04172009229660034,0.023657524958252907,-0.03416452929377556,-0.015277397818863392,-0.05682336911559105,-0.009860619902610779,0.018289459869265556,-0.02249855361878872,-0.07699508219957352,0.001565405516885221,0.01651591807603836,-0.005985572934150696,-0.005501575767993927,0.011962693184614182,0.051959048956632614,-0.011035415343940258,0.009687340818345547,0.013132056221365929,0.010291959159076214,-0.027081098407506943,-0.001350612728856504,0.00941834133118391,-0.004516478627920151,0.021483799442648888,-0.008705969899892807,-0.0007515018805861473,0.02248493954539299,-0.02231753244996071,0.002076168544590473,-0.044440820813179016,0.020651213824748993,-0.037132635712623596,-0.00600862642750144,-0.025595074519515038,0.036495331674814224,-0.035340648144483566,0.03552260622382164,-0.0012013893574476242,0.008788688108325005,-0.00292442599311471,-0.027023907750844955,-0.03140708804130554,-0.0008829005528241396,0.07042591273784637,-0.007476688362658024,0.0015311776660382748,-0.023815300315618515,-0.013232788071036339,-0.03647061064839363,-0.003501733997836709,-0.011930856853723526,0.017034661024808884,0.02120763622224331,0.02230231463909149,-0.003190415445715189,0.020222704857587814,-0.03325140103697777,-0.005488506518304348,-0.007437506690621376,0.009587598964571953,-0.02731906808912754,-0.01655813492834568,0.006652333308011293,-0.006553318817168474,-0.03890804201364517,-0.010733203962445259,0.0011803784873336554,-0.04560159519314766,-0.022346191108226776,-0.06118476018309593,0.04279783368110657,0.04278156906366348,-0.014531953260302544,0.0366358645260334,-0.024806136265397072,0.021838609129190445,-0.03309101238846779,0.043582648038864136,-0.07944957911968231,0.009205476380884647,0.004888721276074648,0.009224429726600647,-0.015718035399913788,0.021202487871050835,-0.03183073550462723,0.003102855058386922,0.012779036536812782,0.014497940428555012,-0.06086887791752815,0.019189909100532532,0.061778102070093155,-0.05189529433846474,0.07064127177000046,0.06045672297477722,0.02155938185751438,0.009147388860583305,0.016578102484345436,-0.006635654717683792,-0.0012382414424791932,-0.04239378869533539,0.021271033212542534,0.035416968166828156,0.014749023132026196,-0.0040213908068835735,-0.030098868533968925,-0.0407763309776783,0.030529633164405823,0.003338130656629801,0.010910257697105408,-0.028543656691908836,0.037008412182331085,0.04064006358385086,-0.0010923970257863402,0.059876587241888046,-0.020881375297904015,0.030734142288565636,-0.024373402819037437,-0.01579766534268856,-0.01905207894742489,-0.04046672582626343,0.009284565225243568,-0.05796760693192482,0.0008512765052728355,0.03174441307783127,0.09236731380224228,-0.013216892257332802,-0.0027480502612888813,-0.0018929323414340615,0.013677427545189857,-0.16371820867061615,0.029842043295502663,0.021076012402772903,-0.028310490772128105,0.004503306001424789,0.017410334199666977,-0.013595284894108772,-0.05746331810951233,-0.020931433886289597,-0.019154570996761322,-0.06555299460887909,0.03289443999528885,0.06970605999231339,-0.02703191339969635,-0.031618162989616394,0.023465950042009354,-0.019385868683457375,-0.01567101664841175,-0.00012225547106936574,0.052064958959817886,-0.010199291631579399,-0.012235772795975208,0.0459195077419281,0.004701683763414621,0.00021155689319130033,-0.05250600725412369,-0.0018985270289704204,-0.0276967640966177,-0.017418572679162025,0.023877086117863655,0.003107488388195634,0.002317320555448532,0.008355158381164074,0.07365857809782028,0.03711866959929466,0.005159372929483652,0.01364834699779749,-0.03076549619436264,-0.021173477172851562,0.008598518557846546,0.0663943812251091,0.03921487182378769,-0.013488835655152798,0.038670722395181656,0.05351698026061058,0.03319991007447243,-0.02032570354640484,-0.0027105961926281452,-0.058086324483156204,-0.02430521324276924,-0.04491931572556496,0.038100991398096085,-0.03560648858547211,-0.0007644529105164111,-0.016487544402480125,-0.03475784510374069,-0.02573326975107193,-0.0007733335951343179,-0.004745916463434696,-0.018239453434944153,-0.014882692135870457,0.044527970254421234,0.0060078841634094715,-0.04098253324627876,-0.069342240691185,0.02121998555958271,-0.04962529242038727,0.002730493899434805,-0.0013471930287778378,0.0426267609000206,-0.02966499514877796,0.045443154871463776,-0.023860052227973938,-0.057371433824300766,0.03063998743891716,0.015262532979249954,0.033430565148591995,-0.006125288084149361,-0.009242547675967216,-0.04065855219960213,-0.042608171701431274,0.016168972477316856,0.008357016369700432,-0.0438622422516346,-0.002296534599736333,-0.03203599154949188,-0.033829525113105774,0.01459485199302435,-0.027919532731175423,0.025277119129896164,-0.02801189199090004,-0.008321781642735004,0.012227334082126617,0.03878309950232506,-0.005124130751937628,-0.027452461421489716,-0.015155197121202946,0.0028554664459079504,-0.053693875670433044,-0.05147118866443634,-0.020483938977122307,-0.023401884362101555,-0.0027010429184883833,-0.004098834004253149,-0.019213363528251648,0.012874152511358261,0.005955146625638008,0.0016402980545535684,-0.003842683043330908,0.029756011441349983,0.0348031260073185,-0.024913327768445015,0.005987818818539381,-0.010589232668280602,-0.036961399018764496,0.059702981263399124,-0.02044805884361267,0.016022847965359688,-0.020030558109283447,-0.04619355872273445,0.0476769395172596,-0.0024862505961209536,-0.006521931383758783,-0.029554011300206184,0.02178449183702469,0.047027088701725006,0.029071131721138954,-0.02619827352464199,-0.029650475829839706,-0.01811663806438446,0.01422896608710289,-0.06308940798044205,0.007544003427028656,0.023337528109550476,0.013903715647757053,-0.025148918852210045,-0.0155536700040102,0.054638441652059555,-0.06206072121858597,-0.014242650009691715,-0.006616115570068359,-0.019843094050884247,-0.04123426228761673,0.0037933324929326773,-0.007908321917057037,0.02890142798423767,0.013971544802188873,-0.009434860199689865,-0.019558455795049667,-0.0015586072113364935,0.048938099294900894,-0.01657358929514885,0.004799368791282177,0.025440407916903496,0.020632382482290268,0.015574359335005283,-0.035839129239320755,-0.007499258033931255,0.0032220399007201195,0.019484831020236015,-0.007248235400766134,-0.014503364451229572,-0.03462712839245796,-0.03550190106034279,-0.0029532406479120255,-0.0047995601780712605,-0.03517697751522064,0.0350244864821434,-0.048274021595716476,0.012624640949070454,-0.008357720449566841,0.06783539056777954,-0.009262723848223686,0.009634525515139103,0.06550244987010956,0.015412172302603722,0.0010375302517786622,0.03146678954362869,0.026500927284359932,0.013810420408844948,-0.009135938249528408,0.05952722206711769,0.03565974161028862,0.04414576664566994,-0.0026436427142471075,0.005502105690538883,-0.01756707951426506,-0.01737314648926258,0.028895694762468338,0.026966003701090813,0.05291897803544998,-0.017726697027683258,-0.007894748821854591,-0.007940856739878654,0.035873208194971085,0.003494190750643611,0.041449714452028275,0.033498961478471756,-0.004823171999305487,0.02981145679950714,-0.06416894495487213,-0.011354446411132812,-0.034569233655929565,0.002354192081838846,0.0042194947600364685,0.005316335242241621,0.011099337600171566,-0.025803785771131516,-0.025034580379724503,-0.024638773873448372,-0.02261119894683361,-0.01296953298151493,-0.05233842879533768,0.041092172265052795,0.04818394035100937,0.012949320487678051,0.008981938473880291,0.015773333609104156,-0.01443012710660696,0.012044872157275677,0.01861540414392948,0.05573103949427605,-0.028982482850551605,-0.0017593421507626772,-0.01821901462972164,-0.0006061688181944191,-0.006085908971726894,0.00932837463915348,0.01618850603699684,0.008304047398269176,-0.017136961221694946,0.03195170313119888,-0.00999964214861393,0.015525651164352894,-0.008939458057284355,-0.03627492114901543,-0.026611676439642906,-0.008705168031156063,-0.01483701728284359,-0.013373185880482197,-0.006345970090478659,-0.01264334749430418,-0.04504808038473129,0.017728528007864952]}],"usage":{"prompt_tokens":8,"total_tokens":8}}

如何生成稀疏向量呢?是在部署时添加配置么?

@pengjunfeng11
Copy link
Contributor Author

pengjunfeng11 commented Dec 5, 2024

您好, 已更新v1.0.1 部署bge-m3 调用方式 curl http://localhost:9997/v1/embeddings \ -H "Content-Type: application/json" \ -d '{ "input": "测试ebmeddings", "model": "bge-m3" }'

输出结果 {"object":"list","model":"bge-m3-0","data":[{"index":0,"object":"embedding","embedding":[-0.04604385793209076,-0.029126456007361412,-0.00529841473326087,-0.006523269694298506,-0.013490816578269005,-0.03337893635034561,0.02439737692475319,-0.03034304454922676,0.008534069173038006,-0.005122436210513115,-0.05194900929927826,0.004064634907990694,0.015142815187573433,0.000042782881791936234,0.016455188393592834,-0.02856031246483326,-0.012678087688982487,-0.03227345272898674,-0.01931859739124775,-0.07516235113143921,-0.03358013182878494,-0.04792957752943039,0.038128290325403214,0.016266878694295883,-0.008757623843848705,0.03945262357592583,-0.08221528679132462,0.0005865582497790456,0.04983450844883919,-0.020075716078281403,-0.012835495173931122,0.019004439935088158,0.023942070081830025,-0.04249326139688492,-0.017036451026797295,-0.0012883071321994066,0.004572800826281309,-0.03743869066238403,-0.04191333428025246,-0.01806463859975338,-0.015125664882361889,-0.009685643948614597,0.018780698999762535,-0.04026232287287712,0.005524180363863707,-0.022370103746652603,0.020360523834824562,-0.028514310717582703,-0.013898404315114021,-0.03786025196313858,0.005325477570295334,0.03829166665673256,0.025551458820700645,-0.031435150653123856,0.018725259229540825,0.0518522635102272,0.01030291523784399,0.029779545962810516,-0.08157116174697876,-0.025148959830403328,-0.012578606605529785,0.030995143577456474,-0.02332298643887043,0.03421041741967201,0.018365751951932907,0.01931469514966011,-0.02328280359506607,-0.013310645706951618,-0.03858063369989395,-0.04224191978573799,-0.022491658106446266,0.010217142291367054,0.01217228826135397,0.02423980087041855,-0.051994215697050095,0.030370360240340233,0.01875845156610012,-0.027164550498127937,0.0014314608415588737,-0.022466616705060005,0.03541479632258415,-0.015831435099244118,-0.027753576636314392,0.011553257703781128,-0.015905283391475677,0.06175083667039871,-0.009260174818336964,-0.007976812310516834,-0.004825358744710684,0.018083134666085243,-0.026491263881325722,-0.016278525814414024,0.014005634002387524,-0.03400354087352753,-0.023670872673392296,0.009051971137523651,-0.02802387811243534,0.018369268625974655,0.06173993647098541,0.033902160823345184,-0.015278668142855167,0.009357872419059277,-0.0045003886334598064,0.03276104852557182,0.031332168728113174,0.014935112558305264,0.03131174296140671,0.03832254186272621,0.013456401415169239,0.0007462339708581567,0.011264362372457981,0.016822222620248795,-0.016039514914155006,0.057713866233825684,0.002838365500792861,0.007086284924298525,-0.07571546733379364,0.005020846147090197,-0.009382961317896843,-0.022304803133010864,0.06501180678606033,0.03402217477560043,0.01952623948454857,-0.051898494362831116,0.030497901141643524,-0.03904484957456589,-0.0022171561140567064,-0.0017648499924689531,-0.04739215597510338,-0.005764839239418507,0.005778302904218435,-0.028450099751353264,-0.014612702652812004,-0.04660738632082939,0.010910139419138432,-0.0006860136636532843,-0.0389135405421257,0.037176407873630524,-0.015402857214212418,-0.05434243381023407,-0.007945903576910496,0.012199519202113152,-0.019285520538687706,-0.03946128860116005,-0.012468056753277779,-0.09838396310806274,0.012906829826533794,-0.0036584646441042423,0.0018021087162196636,-0.006489022634923458,0.01415557973086834,0.013621034100651741,0.008746661245822906,0.014509853906929493,-0.002701870631426573,-0.00007115585322026163,-0.0358487032353878,0.005922779906541109,0.005875235423445702,0.05729271098971367,0.0012833992950618267,-0.010631521232426167,-0.023526238277554512,-0.027687720954418182,0.009967368096113205,-0.013723870739340782,0.015584702603518963,0.010030734352767467,0.016141533851623535,-0.021117698401212692,0.025901153683662415,-0.017921242862939835,0.014887855388224125,0.040496230125427246,0.020354581996798515,0.011811088770627975,0.07477299124002457,0.01816914603114128,0.016647344455122948,-0.0680510550737381,-0.0017860329244285822,0.04964568838477135,0.021505434066057205,0.014221846126019955,-0.020970169454813004,-0.002924892818555236,0.026437141001224518,-0.028089499101042747,-0.003220551647245884,0.04773680865764618,-0.004141880664974451,-0.06272779405117035,0.03556183725595474,0.02990475669503212,0.01580018177628517,0.022914500907063484,-0.0033618700690567493,0.0368686318397522,0.0011903494596481323,0.002999877091497183,-0.005847234278917313,0.011782829649746418,0.03483477607369423,-0.030359352007508278,0.009255832992494106,-0.024434976279735565,-0.03996998444199562,-0.07868264615535736,0.008336818777024746,0.017998546361923218,-0.0030764334369450808,0.011860193684697151,0.04397423565387726,0.012817742303013802,-0.003891746746376157,-0.03831308335065842,0.004204480908811092,0.04137352854013443,-0.00016630289610475302,-0.027048924937844276,-0.012973828241229057,0.0361005924642086,0.04848453402519226,-0.003646144876256585,-0.008353421464562416,-0.028122948482632637,-0.007711535319685936,0.04131132736802101,0.011024304665625095,-0.05019949749112129,0.0253014974296093,0.007825787179172039,-0.032299160957336426,0.0024993768893182278,-0.009310619905591011,0.000987725448794663,-0.041013412177562714,0.05598897859454155,0.06319805234670639,0.010576874949038029,0.010871327482163906,-0.017004305496811867,0.029243560507893562,-0.012422151863574982,-0.0063285501673817635,-0.0007880419725552201,0.01478077657520771,-0.04085547849535942,0.011431975290179253,-0.02970919758081436,-0.0011933190980926156,-0.033936746418476105,-0.06165551021695137,0.01941009797155857,-0.003129678312689066,0.014049652963876724,-0.009005500935018063,-0.02927190624177456,0.031161056831479073,-0.023434501141309738,0.045556068420410156,0.024086978286504745,0.04400530830025673,0.04741973802447319,-0.004239608533680439,-0.03251064568758011,-0.02112610824406147,0.01287594810128212,0.01622898504137993,-0.017921561375260353,-0.0009594571893103421,-0.026867903769016266,0.047609131783246994,-0.0243223849684,-0.026924068108201027,0.018885938450694084,0.00816210638731718,-0.039708126336336136,0.0362100787460804,0.005212056916207075,-0.025672273710370064,0.014608590863645077,-0.0325128510594368,-0.0346476212143898,0.018542805686593056,-0.03340098261833191,-0.028265714645385742,-0.035603996366262436,-0.0027264675591140985,-0.052643269300460815,-0.02094072848558426,0.004590706434100866,0.058612242341041565,0.012316590175032616,-0.08359653502702713,-0.012066734954714775,-0.002053597243502736,-0.16052329540252686,-0.016568439081311226,-0.003780834376811981,0.02555290423333645,-0.01732010953128338,0.008426462300121784,-0.0591094046831131,0.0009774032514542341,-0.0046181632205843925,0.045732416212558746,-0.008407115936279297,-0.06185086444020271,0.015231318771839142,-0.04624003544449806,-0.015449656173586845,0.011694827117025852,-0.0224919393658638,-0.030008982867002487,0.027687283232808113,-0.004137504380196333,-0.03915403410792351,0.013283437117934227,0.059227604418992996,0.03074299730360508,-0.011184651404619217,-0.050553109496831894,0.0466928593814373,0.025472043082118034,-0.02331041544675827,0.02416168339550495,-0.019448334351181984,0.057902991771698,-0.013549731113016605,0.025122957304120064,0.02627977728843689,0.0591752789914608,0.048513393849134445,0.00611028540879488,-0.04379820451140404,0.008610358461737633,0.006436006166040897,-0.011269486509263515,-0.0070890686474740505,0.01716400310397148,0.06279289722442627,-0.005807168781757355,-0.012115233577787876,0.005423721857368946,-0.037670087069272995,-0.0016552685992792249,-0.012908754870295525,-0.022784527391195297,0.0011664879275485873,-0.016102749854326248,-0.029122253879904747,-0.021906057372689247,0.011884286999702454,0.01895938441157341,-0.013493509963154793,-0.01782437413930893,-0.041447047144174576,-0.04139809310436249,0.007423060480505228,0.031414639204740524,-0.044134557247161865,-0.002796472515910864,0.003914720844477415,-0.03928155079483986,0.017782261595129967,0.0005297909956425428,0.02720917947590351,-0.028532644733786583,0.0464429035782814,0.021041523665189743,-0.01484812330454588,0.033840518444776535,-0.023397058248519897,-0.01964186690747738,-0.04201821610331535,-0.12350736558437347,-0.0339217334985733,0.04450136423110962,-0.015289900824427605,0.05350621044635773,-0.008130636066198349,-0.023633593693375587,0.013275651261210442,-0.002544102491810918,0.03732019290328026,0.19561462104320526,0.011808402836322784,0.03278623893857002,-0.03631392493844032,0.049332309514284134,-0.018385382369160652,-0.0054062060080468655,-0.01066483836621046,-0.012671100907027721,-0.026945270597934723,-0.000017326787201454863,-0.01377619244158268,-0.021898066624999046,0.01772058568894863,-0.021022547036409378,0.009515585377812386,0.0022900481708347797,0.008592041209340096,0.09405656903982162,0.016949065029621124,0.010311225429177284,0.0077826399356126785,0.017575440928339958,0.0029077669605612755,-0.012169594876468182,-0.04160062223672867,0.014662248082458973,0.04970336705446243,-0.033360544592142105,0.03484472632408142,-0.018379777669906616,0.013932452537119389,0.0578148253262043,0.012335647828876972,-0.004842869937419891,0.028109446167945862,-0.020643308758735657,0.009980875067412853,0.038842808455228806,0.033290795981884,-0.017760347574949265,-0.0012231654254719615,-0.026623560115695,0.020923281088471413,0.0021353985648602247,0.020320629701018333,0.0020343258511275053,-0.035546209663152695,-0.002817857777699828,0.04211704432964325,0.004074611235409975,0.011484736576676369,0.06985614448785782,0.006948523689061403,-0.02259114198386669,0.03744565695524216,-0.03825387358665466,-0.022464875131845474,-0.019385075196623802,0.016486959531903267,0.006925140507519245,0.04216954857110977,-0.0020144334994256496,0.03111676126718521,0.023798050358891487,0.02217385545372963,-0.06305284798145294,0.012965439818799496,0.026009880006313324,0.013332769274711609,0.07410158216953278,-0.011120125651359558,-0.03004535846412182,0.006123990751802921,-0.009285722859203815,0.017046701163053513,0.03326726704835892,-0.022147690877318382,0.01635468751192093,-0.015262141823768616,-0.024572305381298065,-0.013474049977958202,-0.06236923858523369,0.006716535426676273,-0.00016663491260260344,0.03201346471905708,-0.005641802214086056,-0.00906108133494854,-0.018280435353517532,-0.03602343052625656,-0.004929191432893276,0.0018246161052957177,-0.030001021921634674,-0.014891184866428375,-0.007463232148438692,0.04694244638085365,0.010439522564411163,-0.05217444524168968,-0.009681877680122852,-0.02105952426791191,-0.017682798206806183,0.0031598147470504045,0.005026880651712418,-0.00744391605257988,-0.032788027077913284,0.02492659166455269,0.031785283237695694,0.02574756182730198,0.04759121313691139,0.02692968025803566,-0.01690039038658142,0.050126925110816956,-0.009996912442147732,-0.043750643730163574,-0.017543179914355278,0.022402353584766388,-0.015502750873565674,0.04903284087777138,-0.023879647254943848,0.006892840843647718,0.011801090091466904,0.04173601046204567,-0.04741973057389259,0.0126557732000947,-0.030203888192772865,0.012514598667621613,-0.033059261739254,0.042197756469249725,-0.03851189836859703,0.030444730073213577,0.014338172972202301,-0.016278136521577835,-0.04007817059755325,0.02279566042125225,0.012138327583670616,0.009086298756301403,0.04360903799533844,0.058100853115320206,0.028666958212852478,0.04508518427610397,0.01883212849497795,-0.044096123427152634,0.00040349195478484035,0.005651986692100763,-0.04173274338245392,-0.004339367151260376,0.0469193272292614,0.021787844598293304,0.01674877665936947,0.014417871832847595,0.035600390285253525,0.006331161595880985,-0.007994706742465496,-0.028501635417342186,0.0010844592470675707,-0.05261500924825668,-0.010023480281233788,-0.03547043353319168,0.014194886200129986,-0.033331479877233505,0.016800589859485626,0.0002658177400007844,-0.011667415499687195,0.04116903990507126,0.03341029956936836,0.03466938063502312,-0.04091882333159447,0.007292162161320448,0.04865869879722595,-0.02494373731315136,0.0045357076451182365,0.002180996583774686,-0.033767394721508026,0.007345755118876696,0.0501905120909214,-0.03990822657942772,-0.013708100654184818,-0.04523048177361488,-0.020911239087581635,0.0393691211938858,-0.01130569726228714,-0.028412051498889923,-0.005110193509608507,0.06992224603891373,0.030883630737662315,-0.030654456466436386,-0.0019086631946265697,0.00275409291498363,0.05429418385028839,-0.031910017132759094,-0.02864273637533188,0.08717666566371918,-0.04313124716281891,-0.020672880113124847,0.008458174765110016,-0.003892963519319892,-0.002106033032760024,0.01969563588500023,0.0038034396711736917,-0.02306871861219406,0.017875518649816513,-0.01845056749880314,-0.0025636525824666023,0.010756687261164188,0.04332274943590164,-0.014504985883831978,-0.015679888427257538,0.015580490231513977,-0.027290157973766327,0.0094929663464427,-0.041346024721860886,0.0025165067054331303,-0.019951963797211647,0.0025285393930971622,-0.047026608139276505,0.004311210475862026,0.04997284337878227,0.010259203612804413,-0.012643170543015003,0.022547157481312752,-0.022337423637509346,0.024787528440356255,-0.025150949135422707,-0.010579710826277733,-0.03637236729264259,-0.03380469232797623,-0.005495845805853605,-0.00045892951311543584,0.0413888655602932,0.04824687913060188,0.00603882409632206,0.03449680283665657,-0.013943953439593315,-0.01607300527393818,0.01673620194196701,0.03473205119371414,-0.0002855684142559767,0.014127680100500584,0.00906394887715578,-0.013710808008909225,-0.02288750745356083,0.002169650746509433,-0.0020111408084630966,0.09199518710374832,-0.000553179532289505,0.01328995916992426,-0.03033692017197609,0.04578867927193642,0.014794963411986828,-0.04268645495176315,-0.0017998985713347793,-0.020375192165374756,0.026988977566361427,-0.03165459260344505,0.01488446444272995,0.02612108364701271,0.016911419108510017,-0.057283371686935425,-0.01899932697415352,0.036786120384931564,-0.040373362600803375,0.01340899895876646,-0.02724609337747097,-0.0011021201498806477,0.0008002074901014566,-0.04172009229660034,0.023657524958252907,-0.03416452929377556,-0.015277397818863392,-0.05682336911559105,-0.009860619902610779,0.018289459869265556,-0.02249855361878872,-0.07699508219957352,0.001565405516885221,0.01651591807603836,-0.005985572934150696,-0.005501575767993927,0.011962693184614182,0.051959048956632614,-0.011035415343940258,0.009687340818345547,0.013132056221365929,0.010291959159076214,-0.027081098407506943,-0.001350612728856504,0.00941834133118391,-0.004516478627920151,0.021483799442648888,-0.008705969899892807,-0.0007515018805861473,0.02248493954539299,-0.02231753244996071,0.002076168544590473,-0.044440820813179016,0.020651213824748993,-0.037132635712623596,-0.00600862642750144,-0.025595074519515038,0.036495331674814224,-0.035340648144483566,0.03552260622382164,-0.0012013893574476242,0.008788688108325005,-0.00292442599311471,-0.027023907750844955,-0.03140708804130554,-0.0008829005528241396,0.07042591273784637,-0.007476688362658024,0.0015311776660382748,-0.023815300315618515,-0.013232788071036339,-0.03647061064839363,-0.003501733997836709,-0.011930856853723526,0.017034661024808884,0.02120763622224331,0.02230231463909149,-0.003190415445715189,0.020222704857587814,-0.03325140103697777,-0.005488506518304348,-0.007437506690621376,0.009587598964571953,-0.02731906808912754,-0.01655813492834568,0.006652333308011293,-0.006553318817168474,-0.03890804201364517,-0.010733203962445259,0.0011803784873336554,-0.04560159519314766,-0.022346191108226776,-0.06118476018309593,0.04279783368110657,0.04278156906366348,-0.014531953260302544,0.0366358645260334,-0.024806136265397072,0.021838609129190445,-0.03309101238846779,0.043582648038864136,-0.07944957911968231,0.009205476380884647,0.004888721276074648,0.009224429726600647,-0.015718035399913788,0.021202487871050835,-0.03183073550462723,0.003102855058386922,0.012779036536812782,0.014497940428555012,-0.06086887791752815,0.019189909100532532,0.061778102070093155,-0.05189529433846474,0.07064127177000046,0.06045672297477722,0.02155938185751438,0.009147388860583305,0.016578102484345436,-0.006635654717683792,-0.0012382414424791932,-0.04239378869533539,0.021271033212542534,0.035416968166828156,0.014749023132026196,-0.0040213908068835735,-0.030098868533968925,-0.0407763309776783,0.030529633164405823,0.003338130656629801,0.010910257697105408,-0.028543656691908836,0.037008412182331085,0.04064006358385086,-0.0010923970257863402,0.059876587241888046,-0.020881375297904015,0.030734142288565636,-0.024373402819037437,-0.01579766534268856,-0.01905207894742489,-0.04046672582626343,0.009284565225243568,-0.05796760693192482,0.0008512765052728355,0.03174441307783127,0.09236731380224228,-0.013216892257332802,-0.0027480502612888813,-0.0018929323414340615,0.013677427545189857,-0.16371820867061615,0.029842043295502663,0.021076012402772903,-0.028310490772128105,0.004503306001424789,0.017410334199666977,-0.013595284894108772,-0.05746331810951233,-0.020931433886289597,-0.019154570996761322,-0.06555299460887909,0.03289443999528885,0.06970605999231339,-0.02703191339969635,-0.031618162989616394,0.023465950042009354,-0.019385868683457375,-0.01567101664841175,-0.00012225547106936574,0.052064958959817886,-0.010199291631579399,-0.012235772795975208,0.0459195077419281,0.004701683763414621,0.00021155689319130033,-0.05250600725412369,-0.0018985270289704204,-0.0276967640966177,-0.017418572679162025,0.023877086117863655,0.003107488388195634,0.002317320555448532,0.008355158381164074,0.07365857809782028,0.03711866959929466,0.005159372929483652,0.01364834699779749,-0.03076549619436264,-0.021173477172851562,0.008598518557846546,0.0663943812251091,0.03921487182378769,-0.013488835655152798,0.038670722395181656,0.05351698026061058,0.03319991007447243,-0.02032570354640484,-0.0027105961926281452,-0.058086324483156204,-0.02430521324276924,-0.04491931572556496,0.038100991398096085,-0.03560648858547211,-0.0007644529105164111,-0.016487544402480125,-0.03475784510374069,-0.02573326975107193,-0.0007733335951343179,-0.004745916463434696,-0.018239453434944153,-0.014882692135870457,0.044527970254421234,0.0060078841634094715,-0.04098253324627876,-0.069342240691185,0.02121998555958271,-0.04962529242038727,0.002730493899434805,-0.0013471930287778378,0.0426267609000206,-0.02966499514877796,0.045443154871463776,-0.023860052227973938,-0.057371433824300766,0.03063998743891716,0.015262532979249954,0.033430565148591995,-0.006125288084149361,-0.009242547675967216,-0.04065855219960213,-0.042608171701431274,0.016168972477316856,0.008357016369700432,-0.0438622422516346,-0.002296534599736333,-0.03203599154949188,-0.033829525113105774,0.01459485199302435,-0.027919532731175423,0.025277119129896164,-0.02801189199090004,-0.008321781642735004,0.012227334082126617,0.03878309950232506,-0.005124130751937628,-0.027452461421489716,-0.015155197121202946,0.0028554664459079504,-0.053693875670433044,-0.05147118866443634,-0.020483938977122307,-0.023401884362101555,-0.0027010429184883833,-0.004098834004253149,-0.019213363528251648,0.012874152511358261,0.005955146625638008,0.0016402980545535684,-0.003842683043330908,0.029756011441349983,0.0348031260073185,-0.024913327768445015,0.005987818818539381,-0.010589232668280602,-0.036961399018764496,0.059702981263399124,-0.02044805884361267,0.016022847965359688,-0.020030558109283447,-0.04619355872273445,0.0476769395172596,-0.0024862505961209536,-0.006521931383758783,-0.029554011300206184,0.02178449183702469,0.047027088701725006,0.029071131721138954,-0.02619827352464199,-0.029650475829839706,-0.01811663806438446,0.01422896608710289,-0.06308940798044205,0.007544003427028656,0.023337528109550476,0.013903715647757053,-0.025148918852210045,-0.0155536700040102,0.054638441652059555,-0.06206072121858597,-0.014242650009691715,-0.006616115570068359,-0.019843094050884247,-0.04123426228761673,0.0037933324929326773,-0.007908321917057037,0.02890142798423767,0.013971544802188873,-0.009434860199689865,-0.019558455795049667,-0.0015586072113364935,0.048938099294900894,-0.01657358929514885,0.004799368791282177,0.025440407916903496,0.020632382482290268,0.015574359335005283,-0.035839129239320755,-0.007499258033931255,0.0032220399007201195,0.019484831020236015,-0.007248235400766134,-0.014503364451229572,-0.03462712839245796,-0.03550190106034279,-0.0029532406479120255,-0.0047995601780712605,-0.03517697751522064,0.0350244864821434,-0.048274021595716476,0.012624640949070454,-0.008357720449566841,0.06783539056777954,-0.009262723848223686,0.009634525515139103,0.06550244987010956,0.015412172302603722,0.0010375302517786622,0.03146678954362869,0.026500927284359932,0.013810420408844948,-0.009135938249528408,0.05952722206711769,0.03565974161028862,0.04414576664566994,-0.0026436427142471075,0.005502105690538883,-0.01756707951426506,-0.01737314648926258,0.028895694762468338,0.026966003701090813,0.05291897803544998,-0.017726697027683258,-0.007894748821854591,-0.007940856739878654,0.035873208194971085,0.003494190750643611,0.041449714452028275,0.033498961478471756,-0.004823171999305487,0.02981145679950714,-0.06416894495487213,-0.011354446411132812,-0.034569233655929565,0.002354192081838846,0.0042194947600364685,0.005316335242241621,0.011099337600171566,-0.025803785771131516,-0.025034580379724503,-0.024638773873448372,-0.02261119894683361,-0.01296953298151493,-0.05233842879533768,0.041092172265052795,0.04818394035100937,0.012949320487678051,0.008981938473880291,0.015773333609104156,-0.01443012710660696,0.012044872157275677,0.01861540414392948,0.05573103949427605,-0.028982482850551605,-0.0017593421507626772,-0.01821901462972164,-0.0006061688181944191,-0.006085908971726894,0.00932837463915348,0.01618850603699684,0.008304047398269176,-0.017136961221694946,0.03195170313119888,-0.00999964214861393,0.015525651164352894,-0.008939458057284355,-0.03627492114901543,-0.026611676439642906,-0.008705168031156063,-0.01483701728284359,-0.013373185880482197,-0.006345970090478659,-0.01264334749430418,-0.04504808038473129,0.017728528007864952]}],"usage":{"prompt_tokens":8,"total_tokens":8}}

如何生成稀疏向量呢?是在部署时添加配置么?

参考bge-m3在huggingface中的官方示例,当需要返回稀疏向量时,需指定return_sparse=True。默认返回稠密向量

@lmolhw5252
Copy link

感谢回复,官方样例用的是FlagEmbedd

from FlagEmbedding import BGEM3FlagModel
model = BGEM3FlagModel('BAAI/bge-m3',  use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation
sentences_1 = ["What is BGE M3?", "Defination of BM25"]
sentences_2 = ["BGE M3 is an embedding model supporting dense retrieval, lexical matching and multi-vector interaction.", 
               "BM25 is a bag-of-words retrieval function that ranks a set of documents based on the query terms appearing in each document"]
output_1 = model.encode(sentences_1, return_dense=True, return_sparse=True, return_colbert_vecs=False)
output_2 = model.encode(sentences_2, return_dense=True, return_sparse=True, return_colbert_vecs=False)
# you can see the weight for each token:
print(model.convert_id_to_token(output_1['lexical_weights']))
# [{'What': 0.08356, 'is': 0.0814, 'B': 0.1296, 'GE': 0.252, 'M': 0.1702, '3': 0.2695, '?': 0.04092}, 
#  {'De': 0.05005, 'fin': 0.1368, 'ation': 0.04498, 'of': 0.0633, 'BM': 0.2515, '25': 0.3335}]
# compute the scores via lexical mathcing
lexical_scores = model.compute_lexical_matching_score(output_1['lexical_weights'][0], output_2['lexical_weights'][0])
print(lexical_scores)
# 0.19554901123046875
print(model.compute_lexical_matching_score(output_1['lexical_weights'][0], output_1['lexical_weights'][1]))
# 0.0

请问有没有请求的样例呢?

@qinxuye
Copy link
Contributor

qinxuye commented Dec 5, 2024

加载 bge-m3 选择 hybrid_mode=True,界面是额外选项,命令行是 --hybrid_mode True。

然后请求时加 return_sparse=True。

@lmolhw5252 试验下是不是可以,ok 的话我们加个文档。

@lmolhw5252
Copy link

image 这样不行

@lmolhw5252
Copy link

lmolhw5252 commented Dec 6, 2024 via email

@qinxuye
Copy link
Contributor

qinxuye commented Dec 6, 2024

是 1.0.1 吗?

@lmolhw5252
Copy link

image

@colinTmx
Copy link

通过restful请求,如何生成sparse向量?在body中封装了return_sparse:true 不生效

@qinxuye
Copy link
Contributor

qinxuye commented Dec 16, 2024

加载 bge-m3 的时候需要指定 hybrid_mode,值为 True。

@lmolhw5252
Copy link

lmolhw5252 commented Dec 16, 2024 via email

@qinxuye
Copy link
Contributor

qinxuye commented Dec 16, 2024

可以,additional 选项里设置。

@lmolhw5252
Copy link

lmolhw5252 commented Dec 16, 2024 via email

@qinxuye
Copy link
Contributor

qinxuye commented Dec 16, 2024

升级 1.1.0 了吗?有报错贴报错,

@lmolhw5252
Copy link

lmolhw5252 commented Dec 16, 2024 via email

@colinTmx
Copy link

colinTmx commented Dec 17, 2024

能在一个请求中同时返回 sparse和dense 吗?

@qinxuye
Copy link
Contributor

qinxuye commented Dec 17, 2024

能在一个请求中同时返回 sparse和dense 吗?

不行。目前只能分两个请求。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xf不支持生成稀疏向量
5 participants