Migrate from /api/embedding to /api/embed#115
Conversation
https://ollama.com/blog/embedding-models /embeddings is depreciated ollama/ollama#9742 Update embed_ollama.go Fixed endpoint change. It's now called embeddings. curl http://localhost:11434/api/embed -d '{ "model": "qwen3:0.6b", "input": "CLEVELAND CLINICFind a Doctor and Specialists<SEP>High-Risk Pregnancy Care<SEP>Cleveland Clinic High-Risk Pregnancy Care<SEP>Make an Appointment<SEP>Consult with a maternal-fetal medicine specialist<SEP>Labor Induction<SEP>Cesarean Delivery<SEP>High-Risk Pregnancy Care <https://my.clevelandclinic.org/services/high-risk-pregnancy-care><SEP>Cleveland Clinic: High-Risk Pregnancy Care <https://my.clevelandclinic.org/webappointment><SEP>It’s important to talk to your pregnancy care provider about your risks for these complications.<SEP>Diagnosis and Tests: How is high-risk pregnancy diagnosed and monitored?<SEP>Management and Treatment: What is the treatment for a high-risk pregnancy?<SEP>Care at Cleveland Clinic: High-Risk Pregnancy Care <https://my.clevelandclinic.org/webappointment><SEP>Outlook / Prognosis: What’s the prognosis (outlook) for people with high-risk pregnancy?<SEP>Can you still work with a high-risk pregnancy?" }' {"model":"qwen3:0.6b","embeddings":[[-0.0144871455,0.30038583,-0.010185229,0.05683866,0.009924336,-0.17014848,-0.022180464,-0.26728317,-0.054444324,0.14578612,-0.030278103,-0.0019496871,0.049777653,-0.009411709,-0.008272115,0.009253697,-0.13884658,-0.084018365,-0.13657713,-0.029163864,-0.010457194,-0.0041468707,0.017137801,0.22340368,0.004522382,0.005705169,0.00986887,-0.11207489,0.051995557,0.048660044,-0.06998437,0.0040654694,-0.10013804,-0.0010271197,-0.045406498,-0.011331499,0.025221575,-0.010726623,0.022650689,0.019138051,-0.03098051,0.01832366,0.08990769,-0.009123681,0.05223581,0.14929359,0.010787157,0.0053058355,-0.006884325,0.029378194,0.0040891934,-0.016375529,0.0023929763,0.0071745445,0.00472148,0.02747788,0.0010745788,0.011154617,0.01437341,-0.0006973319,-0.12504715,0.120475665,0.030319456,0.07465311,0.0038300704,-0.002753977,0.0025586328,0.005251124,-0.021991167,0.00041795897,-0.017457142,-0.008119913,0.016687479,-0.0045305723,-0.034415826,-0.013224352,-0.0020782826,0.027015802,0.02956296,-0.001227799,-0.008190772,-0.043376308,-0.048587427,0.008002308,-0.0039497935,0.0475471,0.023124166,-0.019919703,-0.02058464,-0.034265276,0.047037013,0.0069652316,0.023479113,-0.0250642,-0.019009853,0.01705365,0.001934765,-0.03092076,-0.0060409377,0.004574682,-0.021430941,0.0061136154,0.02140033,0.05749043,0.032083694,0.09750455,-0.03272667,-0.0069406875,-0.031725187,-0.02701726,-0.016023843,0.004469769,-0.021625243,0.05694495,-0.0139038125,0.025569722,-0.025402915,-0.0004818314,-0.003373715,0.007831872,0.016572585,0.03295737,0.012523558,0.019470263,-0.016881991,0.009797731,-0.0011225395,-0.019252002,-0.0047892723,-0.0025710815,-0.0060731294,-0.058931626,-0.008865957,-0.020393824,-0.040287938,-0.018075172,0.023317534,0.0000379403,-0.028706392,-0.0053563835,-0.00796419,-0.0044577788,-0.012420566,0.0015502871,-0.010777512,0.0065605915,-0.028824167,-0.01635131,0.02272146,0.0024842815,-0.0123336,0.009828588,0.033859897,0.0077868463,0.01803804,-0.009999139,-0.017517218,0.026667275,-0.045773245,0.022309262,-0.0032477332,-0.005729833,0.007270668,0.02805666,-0.042022426,0.0104916785,0.009332491,-0.006810187,-0.060776968,0.0046510166,0.007900435,-0.00006430151,0.015011252,0.002435016,0.018608823,-0.012753007,0.01273199,-0.0028703024,0.004015948,-0.011655024,-0.025661178,-0.0020915389,0.006030221,-0.014805517,0.010645711,-0.01810779,-0.038713146,0.00015572198,-0.021890499,0.015974578,-0.017881691,-0.027568003,-0.022444157,0.0404895,-0.040566575,-0.013648546,-0.027236795,0.024087558,-0.030310128,0.039147098,-0.0065576667,-0.04452381,0.034021746,0.0019196534,-0.010635028,-0.009259377,0.0048132758,-0.006131371,-0.0039011065,0.008855308,-0.018118871,-0.024535758,0.03174147,-0.040825065,0.019932585,-0.016556172,0.0015088473,0.039113656,-0.028158313,-0.02164777,-0.0028229195,0.023274653,0.029707318,-0.01731378,0.00072012,0.026459659,0.028158035,0.020654257,0.01696106,0.01742351,0.017791266,0.029370492,0.0006704487,-0.00729359,-0.033634793,0.00028339488,-0.021841764,0.018193187,0.017156405,0.00080565765,-0.020881599,0.022357374,0.02283968,0.030258507,-0.008626946,0.016865151,-0.011275038,0.028391011,-0.06585217,0.015321458,0.034185834,-0.1052789,0.0156023735,-0.0048370534,0.017612847,0.012755163,-0.012321323,0.023992369,-0.044814963,0.003961282,0.02972406,-0.020010114,0.013820171,-0.045103054,-0.008670036,0.021223083,-0.0076445406,0.010680353,-0.008760225,-0.0011470917,-0.012560391,-0.012252729,-0.01823415,-0.007914699,-0.009704411,-0.018529657,0.0013226989,-0.3339668,-0.03998295,-0.027770923,0.019662036,-0.012543729,-0.0053013144,-0.013176513,0.022551537,-0.013697018,-0.0012491187,-0.013635285,0.022215953,-0.026132999,0.008392897,-0.016429149,0.0011975088,0.0047817538,-0.020396907,-0.012638857,-0.0128794955,0.06395404,0.036275312,-0.002459235,-0.008235185,-0.032788936,0.025245415,-0.014726887,0.00036560217,0.0055275406,-0.00005528224,0.035473537,-0.021669054,-0.014862691,0.02646458,0.01738113,-0.0065499097,0.021001535,-0.005849921,-0.027450195,-0.00403034,-0.006225347,-0.028455429,0.00048651992,0.008246264,0.029539675,0.0034036324,0.037908938,0.007709175,-0.017241322,0.07168121,-0.021601545,0.010147912,-0.027882915,0.017129784,0.008073356,-0.0024203276,0.0018444579,0.009402577,0.038098305,0.02072856,-0.025342584,0.038448352,0.009925878,0.03675505,-0.005685499,-0.02621384,0.018184014,0.0015068483,-0.008356281,0.046824917,0.013714526,0.0025897007,0.0019755098,0.02585877,-0.005112211,-0.0067499573,-0.019990874,-0.0014271801,0.011860414,-0.003968871,0.004440471,0.019175142,-0.008234884,-0.02907329,-0.13928114,0.015773749,0.039386794,-0.009226031,-0.032213602,0.030199956,-0.044305004,-0.0013241905,0.00021095532,-0.14860493,-0.03443714,-0.0048154877,0.04551811,0.032449238,-0.0015365797,0.02203935,0.027326511,0.0074219825,0.0009767747,0.0042596096,0.009365565,0.022534698,0.01618729,0.0025943366,0.008092905,-0.0033844353,0.035585925,0.0069810636,0.019909045,-0.0039872644,0.019870145,0.005188641,0.009911585,0.020641167,0.0432816,-0.009185368,-0.005040939,-0.008340548,0.020244962,0.0064866752,-0.016727582,0.0046330728,-0.010944662,-0.009595038,-0.002678146,-0.01378086,-0.02762313,-0.002548494,0.047249123,-0.044252362,-0.013413334,-0.0203139,0.013947472,0.00724659,-0.021741277,0.02941991,-0.007117807,-0.03692759,0.004049232,0.022955878,-0.0005896289,-0.012524931,-0.039529163,0.0038905658,-0.015955735,-0.016239246,-0.13969605,0.03587698,-0.1341332,0.020538237,-0.008809331,-0.022968344,-0.0006469919,0.008079878,0.0215101,0.02297248,-0.0012971183,-0.02908328,0.018217217,-0.015409168,-0.027769446,0.02303293,-0.008396843,-0.01609582,-0.021360893,-0.022712465,0.026868861,0.019280832,0.017000344,-0.017522674,0.0013416815,-0.0030179573,0.015356714,-0.015680922,-0.0069987597,-0.020455679,0.005178813,0.026327822,-0.0045088814,-0.02060511,0.002160521,0.036467165,-0.014312247,0.035548538,-0.01827487,0.004069821,0.0153483935,0.020640729,0.0057419906,-0.0179088,-0.0009775409,0.0149310995,0.00087631436,-0.033664655,-0.006266345,-0.004253473,0.025155872,-0.025005372,0.033061083,0.01951303,-0.015542171,0.008936375,-0.025762811,0.004350102,-0.0029788348,0.0023572298,0.026271686,-0.0024203088,-0.011337358,0.018894512,0.0011255826,-0.020868093,0.0072924756,0.0042294604,-0.026706304,-0.011906892,0.020634778,-0.013189023,0.0155329695,-0.0002060287,0.024344618,-0.0007534026,-0.007875384,0.00481841,-0.005971445,-0.008006555,0.014474175,-0.025089119,0.021464368,0.023851056,-0.015858155,0.0040160907,-0.009602285,0.006656206,0.0038293006,0.0105911,0.008404895,0.0206097,-0.019025302,-0.009427067,0.03713963,-0.02011358,-0.011094207,-0.03907085,0.03870079,0.0044307713,-0.006279566,0.0040788758,0.0005717828,0.03950811,0.020648917,0.0052516605,-0.010334162,-0.020750966,-0.011542616,-0.0008671633,0.010677895,-0.0012802355,0.02908683,-0.030398037,0.003252379,0.022374602,-0.0038583004,-0.012633003,-0.01602231,0.030659614,0.008017331,-0.023044499,0.0011321227,0.028905742,0.009276907,0.016722457,-0.011377249,0.009978567,0.005135974,-0.0055522034,-0.018931422,0.020314803,-0.045153204,-0.016993789,0.009223568,-0.012867214,0.042849813,0.029956521,0.0005556946,0.03162553,-0.01992204,-0.007931653,0.012956471,-0.01470302,0.01802204,0.011470287,0.014496709,-0.011822486,0.012792762,-0.0036260989,0.004623317,0.027459309,0.009411917,-0.015674524,0.0029353607,0.022557518,0.008086629,-0.017864797,-0.014890999,0.016777752,0.0015783681,-0.025938874,-0.01870127,-0.00051374466,0.01738344,0.01356412,0.010084287,0.02142906,0.003054071,-0.025823342,0.025933292,-0.005024972,0.0016440955,0.014777843,0.019790161,0.0013433226,-0.0024547235,-0.021632992,-0.004399233,0.0039073913,0.026482942,0.025121437,0.033559725,0.001433932,0.0053570573,-0.0058062486,-0.011706344,-0.003178351,0.040018197,0.009814535,-0.04932615,-0.0017116772,-0.028249327,0.022280836,-0.01303701,0.0088751735,-0.0042468417,-0.01451773,-0.01316122,0.015086667,0.007954668,-0.0037557771,0.0021306947,-0.009504823,0.0303923,-0.005880629,-0.0058853053,-0.009270621,-0.005541978,-0.016497081,0.0062224106,-0.01159247,0.0070131957,-0.017362446,0.011869499,-0.021478252,-0.0016544842,0.011924579,-0.0016941857,-0.012394493,0.012811205,-0.005397572,-0.018027944,-0.009653467,0.0073203505,0.04022958,0.021850904,-0.013596549,-0.015797962,0.01810222,-0.01575565,-0.057195432,0.014611663,0.015781863,-0.0114740785,0.02348902,-0.010502499,-0.010407339,-0.022118302,-0.004236475,0.028977498,-0.015835796,0.021455726,0.051699027,-0.005834561,-0.0010828066,0.007469381,-0.00041619004,-0.010880422,0.011628481,-0.003927036,0.01743024,0.0018081724,-0.0030737917,-0.0047820853,0.014038665,-0.0025272942,0.01431216,0.008702344,0.0072608343,-0.018583199,0.0034049246,-0.005616061,0.000896669,-0.020724759,0.019691234,-0.0025158874,-0.02310367,-0.018323205,0.011083447,0.009298679,-0.010085907,-0.018268008,-0.011254972,-0.0016590703,-0.019281358,0.011321506,0.009361085,-0.015660398,-0.0029787505,-0.0011206582,-0.017869463,0.022455718,0.01186097,0.004774177,0.009660803,-0.01084918,-0.012166555,-0.0087769,0.007302575,0.039478403,-0.020752942,-0.016792318,-0.00041591833,0.017376691,0.01414235,0.009972838,0.013867293,-0.012975973,0.0046403822,0.015270666,0.0030951793,-0.012325154,0.0049528643,-0.05197814,-0.028156674,0.006572966,0.012049416,0.034923494,0.0051758317,-0.009165027,0.011994592,-0.007523156,0.0030148267,-0.006423347,0.014220971,0.0028781444,0.0071343384,-0.046932977,-0.021435048,0.0018763707,-0.021459706,0.013183437,-0.012152162,-0.008914386,0.0293565,-0.009917625,-0.015350597,-0.033514913,0.0095242215,-0.023737153,0.0039526136,-0.024840267,-0.00793909,0.00893494,0.0059509575,0.013832902,0.053088054,0.00808429,-0.0017386021,-0.0036472084,0.005003803,-0.01292927,-0.018151047,0.023477957,0.0015803637,0.00984953,0.025194554,0.007977384,-0.0013885807,0.023143692,0.0030309926,-0.027823022,-0.008917738,-0.024042448,-0.013537942,0.020903962,0.01665512,-0.006675665,0.0043961704,-0.009279509,-0.013714543,-0.021062031,-0.018763963,0.0063871657,-0.017939687,-0.018360078,-0.011353349,0.0034972893,0.0035415771,-0.006638962,-0.032948248,0.026791614,0.0058913864,-0.0026708867,0.009173678,-0.014895924,-0.004513439,-0.021531792,-0.009861462,0.0006727364,-0.02091075,-0.019367216,0.011038345,0.016262604,0.0038988574,0.024886966,-0.009510667,0.00777275,0.018160382,0.016934553,0.0019063207,-0.0046151564,-0.012023915,0.035953693,-0.017124912,0.028941162,-0.0077191573,-0.007904067,0.012798391,-0.018566858,-0.0075275786,-0.0119070755,0.009414205,0.01627204,0.0037221706,-0.004894518,-0.0021659462,-0.02039053,-0.038074013,0.010153117,-0.03274531,0.019314693,0.00029824284,-0.016872497,0.004878054,0.03526636,-0.010309705,0.04277547,-0.004250805,0.011912996,-0.011457092,-0.0010842533,0.0014594573,-0.0009080529,-0.0053208726,0.00522101,-0.014261352,0.0018400879,-0.014311005,0.020352649,-0.010190122,-0.031930316,0.008841659,0.005248607,0.012679108,-0.01780979,0.030379705,-0.0051396736,0.009493686,0.014948418,0.0057676663,0.0011975411,0.004676065,-0.012740947,-0.008975529,0.014892428,-0.0032944,0.021501996,0.01990987,0.00994183,0.0035257642,-0.045715652,0.0062454036,0.018343583,0.0041616675,0.02109384,-0.009404812,-0.0015086159,0.015030414,0.0034330129,0.011399021,-0.011368099,0.004549179,-0.022201223,0.041410998,0.012551247,-0.07647698,-0.031402323,-0.019825114,-0.008942945,-0.0000063310868,0.012193067,0.00030623315,-0.0047921315,0.007580696,0.018276127,0.010136157,-0.00037423533,0.009861515,0.0018333644,0.006395704,-0.017288346,-0.005649673,0.010598828,0.005308285,0.0031826014,0.01759755,-0.03741463,-0.017551975,0.0042132097,0.016602715,-0.0039381203,0.017492594,-0.01762212,0.022631917,-0.0039586276,-0.0025950568,-0.014900873,0.03264507,-0.012643562,0.015525822,0.023150392,0.004344632,-0.021591447,-0.018599622,-0.023712093,-0.02272904,0.019435288,-0.015393578,-0.0019481208,0.019688904,-0.008800893,-0.025844045,-0.004867172,-0.014459278,0.02314658,-0.0030161508,0.024041666,-0.0114225885,0.012443731,0.0023191248,0.003052547,0.010948241,0.013086531,-0.018284507,0.0077818674,0.01877495,0.0063256705,0.0030113754,0.017051673,0.001965473,-0.003584849,0.019543225,-0.007970849,0.008593772,-0.0072274553,0.0006910343,-0.033917148,0.028572135,-0.023598045,-0.030954784,-0.003356447,-0.0037015032,-0.0024273943,-0.0059600566,0.00038786142,-0.045397196,0.025766935,-0.008340146,-0.0018014378,0.0010650783,0.012247161,-0.009220517,0.02509936,0.007329123,-0.014159611,-0.010854696,-0.023898583,0.02955445,0.016693847,0.03276805,0.018021092,-0.0037296158,-0.005966207,0.0051975264,-0.018850662,0.01705377,0.0054075047,0.005259528,0.0033557091,0.003137213,-0.0051726033,0.007439294,0.021336775,0.018869946,-0.014196763,0.00260307,0.0160413,-0.023171255,-0.023080757,0.00003447399,0.017816318,0.010521688,0.048114676,0.012169853,-0.030179776,-0.0026471308,-0.01473185,0.009831718,-0.018418591,-0.00007527888,-0.01307311,-0.021872463,-0.0006124853,-0.0048849094,-0.00066035666]],"total_duration":16066504083,"load_duration":22878875,"prompt_eval_count":214}% Update embed_ollama.go Change from prompt to input {"model":"qwen3:0.6b","embeddings":[]} time=2025-07-18T15:47:35.939-04:00 level=INFO msg="Done call LLM" package=golightrag function=Insert entities=6 relationships=6 {"model":"qwen3:0.6b","embeddings":[]} time=2025-07-18T15:47:56.500-04:00 level=INFO msg="Done call LLM" package=golightrag function=Insert entities=2 relationships=2 {"model":"qwen3:0.6b","embeddings":[]} time=2025-07-18T15:48:26.555-04:00 level=INFO msg="Done call LLM" package=golightrag function=Insert entities=1 relationships=1 {"model":"qwen3:0.6b","embeddings":[]}
match ollama api https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings curl http://localhost:11434/api/embed -d '{ "model": "all-minilm", "input": "Why is the sky blue?" }' Response { "model": "all-minilm", "embeddings": [[ 0.010071029, -0.0017594862, 0.05007221, 0.04692972, 0.054916814, 0.008599704, 0.105441414, -0.025878139, 0.12958129, 0.031952348 ]], "total_duration": 14143917, "load_duration": 1019500, "prompt_eval_count": 8 } Request (Multiple input) curl http://localhost:11434/api/embed -d '{ "model": "all-minilm", "input": ["Why is the sky blue?", "Why is the grass green?"] }' Response { "model": "all-minilm", "embeddings": [[ 0.010071029, -0.0017594862, 0.05007221, 0.04692972, 0.054916814, 0.008599704, 0.105441414, -0.025878139, 0.12958129, 0.031952348 ],[ -0.0098027075, 0.06042469, 0.025257962, -0.006364387, 0.07272725, 0.017194884, 0.09032035, -0.051705178, 0.09951512, 0.09072481 ]] }
|
Alternate solution https://github.com/ollama/ollama/releases?q=%2Fapi%2Fembedding&expanded=true
|
|
Awesome! I had this on my TODO for a while, but never got around to implement it. But I think you need to adapt the test accordingly, as it's currently starting a server and mocking a response of the OpenAI-compatible endpoint. |
go test ./embed_ollama_test.go:55:4: unknown field Embedding in struct literal of type ollamaResponse
|
I fixed the ollama test, but I do not know about the opanai compatible test. |
|
philippgille
left a comment
There was a problem hiding this comment.
I fixed the ollama test
Perfect, thanks a lot!
I do not know about the opanai compatible test.
I just meant that the Ollama test set up a server that acted like Ollama's OpenAI-compatible endpoint. So your latest commit fixed that 👍
The embed_openai_test.go is unrelated and can stay as is.
Migrated from /api/embedding to /api/embed
ollama/ollama#5127
https://ollama.com/blog/embedding-models