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

Upgrade text embedding from text-embedding-004 to text-embedding-preview-0815 #46

Closed
MrCsabaToth opened this issue Aug 30, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request RAG Retrieval Augmented Generation related

Comments

@MrCsabaToth
Copy link
Member

MrCsabaToth commented Aug 30, 2024

At the latest Gemini Unplugged show when I was the guest speaker (https://www.linkedin.com/events/7234841228205268993/comments/) CHANDRA drew my attention that there's a new embedding model in a preview state. He said 008 I think he meant the text-embedding-preview-0815. It seems that it's also has 768 dimensionality.

This change will require a data migration. The dimensionality is the same, so no schema change is needed.

@MrCsabaToth MrCsabaToth added the enhancement New feature or request label Aug 30, 2024
@MrCsabaToth
Copy link
Member Author

MrCsabaToth commented Aug 30, 2024

Calling the preview embedding:

curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    "https://us-central1-aiplatform.googleapis.com/v1/projects/duet-ai-roadshow-415022/locations/us-central1/publishers/google/models/text-embedding-preview-0815:predict"

payload (request.json):

{
  "instances": [
    {
      "task_type": "RETRIEVAL_DOCUMENT",
      "title": "document title",
      "content": "I would like embeddings for this text!"
    }
  ]
}

response:

{
  "predictions": [
    {
      "embeddings": {
        "statistics": {
          "truncated": false,
          "token_count": 13
        },
        "values": [
          -0.021774781867861748,
          0.0014458232326433063,
          0.010504881851375103,
          -0.056177422404289246,
          -0.0015289660077542067,
          0.048421718180179596,
          -0.017547592520713806,
          0.028642501682043076,
          -0.0076510906219482422,
          -0.0040214196778833866,
          -0.070240415632724762,
          -0.021022669970989227,
          0.015652207657694817,
          -0.059977326542139053,
          -0.026493890210986137,
          0.045211326330900192,
          0.060452785342931747,
          -0.050158478319644928,
          -0.0029212450608611107,
          0.0036183302290737629,
          0.022550243884325027,
          -0.053942855447530746,
          -0.079953983426094055,
          -0.031800564378499985,
          0.025167113170027733,
          -0.0405794121325016,
          -0.020507281646132469,
          -0.011410856619477272,
          -0.040921527892351151,
          -0.0078529044985771179,
          0.026464305818080902,
          -0.00047276075929403305,
          0.056704189628362656,
          -0.0084340637549757957,
          0.0436987429857254,
          0.011440955102443695,
          0.027891179546713829,
          0.023694425821304321,
          0.035877622663974762,
          0.031010551378130913,
          0.021696619689464569,
          -0.023172538727521896,
          -0.024321386590600014,
          -0.012801742181181908,
          0.0044998163357377052,
          0.048152033239603043,
          -0.03335140272974968,
          0.00060173083329573274,
          0.0050478321500122547,
          -0.013480179011821747,
          0.024382501840591431,
          0.034457370638847351,
          -0.024557949975132942,
          0.0038352007977664471,
          0.015968086197972298,
          0.096904784440994263,
          0.0021414451766759157,
          0.020832585170865059,
          -0.028813360258936882,
          0.013507497496902943,
          -0.033953018486499786,
          -0.020295590162277222,
          -0.010692441835999489,
          -0.0045930305495858192,
          -0.044162765145301819,
          0.03424140065908432,
          0.052728615701198578,
          0.025763953104615211,
          0.0033735588658601046,
          -0.0423593632876873,
          -0.01845349557697773,
          -0.040231723338365555,
          0.013052248395979404,
          0.0093116667121648788,
          0.0016950659919530153,
          -0.024643378332257271,
          0.022903634235262871,
          0.094094984233379364,
          0.0023023909889161587,
          -0.0017041621031239629,
          -0.023327797651290894,
          0.0071488087996840477,
          -0.047391291707754135,
          0.00060206517810001969,
          0.023821339011192322,
          -0.02004573680460453,
          -0.0010645722504705191,
          -0.03196856752038002,
          -0.045169375836849213,
          -0.0055922507308423519,
          -0.0025941827334463596,
          -0.003524725092574954,
          0.0022631476167589426,
          -0.01177661120891571,
          0.033781345933675766,
          0.059119857847690582,
          0.023578550666570663,
          0.068819113075733185,
          -0.030122406780719757,
          -0.022047044709324837,
          -0.018873734399676323,
          0.034059647470712662,
          -0.023706419393420219,
          -0.016503416001796722,
          0.012974395416676998,
          0.018209969624876976,
          -0.022946583107113838,
          -0.027582358568906784,
          0.0484137199819088,
          -0.030842343345284462,
          -0.042723279446363449,
          -0.034374985843896866,
          -0.010763033293187618,
          0.029578268527984619,
          0.018966155126690865,
          -0.021846579387784004,
          -0.037965349853038788,
          0.0059455134905874729,
          -0.11214451491832733,
          -0.03957749530673027,
          -0.031448684632778168,
          0.033144939690828323,
          0.10751207917928696,
          -0.0097673209384083748,
          -0.012084078043699265,
          0.027921387925744057,
          0.051365770399570465,
          -0.0060564056038856506,
          0.00895755086094141,
          -0.026227371767163277,
          -0.0012718980433419347,
          -0.090246088802814484,
          0.035615533590316772,
          0.059210047125816345,
          -0.019808189943432808,
          -0.019191795960068703,
          -0.016770901158452034,
          -0.017387380823493004,
          -0.00098383077420294285,
          0.026235153898596764,
          -0.035868126899003983,
          -0.031717110425233841,
          0.0038841641508042812,
          0.02880268357694149,
          -0.020595008507370949,
          -0.033308245241642,
          -0.044197779148817062,
          -0.0026309848763048649,
          0.0028090174309909344,
          -0.016289670020341873,
          -0.033587511628866196,
          0.053191002458333969,
          -0.034720759838819504,
          0.04800356924533844,
          0.028666626662015915,
          0.0064544170163571835,
          -0.023985330015420914,
          0.0092831365764141083,
          0.00938801933079958,
          -0.018621858209371567,
          0.0064995517022907734,
          -0.012571759521961212,
          -0.019051611423492432,
          0.061933930963277817,
          -0.044498670846223831,
          0.022613519802689552,
          0.081987529993057251,
          -0.003336792578920722,
          -0.00512844230979681,
          -0.011698208749294281,
          -0.0080760614946484566,
          -0.021180681884288788,
          -0.052994683384895325,
          -0.0022084699012339115,
          0.0041451854631304741,
          0.0032892595045268536,
          -0.0244243573397398,
          -0.0044173486530780792,
          -0.0027647928800433874,
          -0.061688687652349472,
          -0.080527834594249725,
          -0.0031160616781562567,
          0.019680369645357132,
          0.032771576195955276,
          -0.17991502583026886,
          0.0094533218070864677,
          -0.0548165962100029,
          -0.018050665035843849,
          -0.055058591067790985,
          -0.022633342072367668,
          -0.070556618273258209,
          -0.034296046942472458,
          -0.014964488334953785,
          0.03266867995262146,
          0.030758500099182129,
          0.084302976727485657,
          0.021498693153262138,
          -0.0887361541390419,
          -0.031074471771717072,
          0.013065120205283165,
          -0.037896811962127686,
          0.034950107336044312,
          0.068475924432277679,
          0.03585747629404068,
          -0.059266529977321625,
          -0.024149049073457718,
          0.030221534892916679,
          -0.033998753875494,
          0.0032910858280956745,
          -0.03506527841091156,
          0.033050339668989182,
          -0.0080013424158096313,
          -0.11101219058036804,
          -0.020019497722387314,
          -0.063304059207439423,
          -0.098688103258609772,
          0.0038267185445874929,
          -0.026861961930990219,
          0.054075304418802261,
          0.00547225633636117,
          0.051136303693056107,
          0.020693410187959671,
          -0.15868094563484192,
          0.0084580741822719574,
          0.011894317343831062,
          -0.03163238987326622,
          0.053585901856422424,
          0.0050710211507976055,
          0.038885295391082764,
          0.022358249872922897,
          0.019814610481262207,
          0.0319862887263298,
          -0.039032984524965286,
          -0.0081737479194998741,
          -0.0069760368205606937,
          0.012426475994288921,
          -0.019405964761972427,
          -0.005539468489587307,
          -0.080556541681289673,
          -0.0015226284740492702,
          -0.0041428813710808754,
          -0.013558456674218178,
          -0.059828657656908035,
          0.012627605348825455,
          -0.02253059484064579,
          -0.044461194425821304,
          -0.035708550363779068,
          0.050151124596595764,
          -0.063698515295982361,
          -0.042142678052186966,
          -0.02113422192633152,
          0.024042671546339989,
          0.022771863266825676,
          0.020093336701393127,
          0.12360061705112457,
          -0.091610118746757507,
          -0.033842567354440689,
          0.019157236441969872,
          0.012021053582429886,
          0.054898679256439209,
          0.011740684509277344,
          0.049889437854290009,
          -0.018074711784720421,
          -0.027907976880669594,
          0.048590492457151413,
          -0.02515273354947567,
          -0.07177387923002243,
          -0.029783423990011215,
          -0.0023505007848143578,
          0.034908458590507507,
          -0.026468662545084953,
          0.027850639075040817,
          0.026468921452760696,
          -0.0060486532747745514,
          0.024421969428658485,
          0.011915950104594231,
          -0.031494811177253723,
          -0.0062446999363601208,
          0.017849644646048546,
          0.012540507130324841,
          0.00078893324825912714,
          -0.0041668596677482128,
          -0.01547075342386961,
          0.11568048596382141,
          0.013663913123309612,
          0.021140802651643753,
          -0.019176619127392769,
          0.0014319871552288532,
          -0.0066644852049648762,
          -0.022607423365116119,
          -0.024285942316055298,
          0.050549428910017014,
          0.025777766481041908,
          -0.051354512572288513,
          0.017119927331805229,
          0.024681732058525085,
          0.016903702169656754,
          0.00042274314910173416,
          -0.031285088509321213,
          -0.014639210887253284,
          -0.035230536013841629,
          0.0098502049222588539,
          -9.5620358479209244e-05,
          0.0087270159274339676,
          0.057894013822078705,
          -0.072937220335006714,
          0.017782550305128098,
          -0.031170113012194633,
          -0.013484799303114414,
          0.064140580594539642,
          -0.012040629982948303,
          -0.054155278950929642,
          0.01517393346875906,
          0.027101511135697365,
          0.0088720591738820076,
          -0.033846300095319748,
          0.0275143813341856,
          -0.0215111393481493,
          0.031407300382852554,
          -0.036051370203495026,
          0.0483730211853981,
          -0.03726852685213089,
          0.044886320829391479,
          -0.029150279238820076,
          -0.022008186206221581,
          -0.018546497449278831,
          0.0018934317631646991,
          -0.015578201971948147,
          0.010925859212875366,
          -0.040439940989017487,
          0.037055451422929764,
          -0.019228927791118622,
          0.028502233326435089,
          -0.020464751869440079,
          -0.018667154014110565,
          -0.0041655991226434708,
          -0.011528071947395802,
          0.029946215450763702,
          -0.018005149438977242,
          -0.002108375309035182,
          0.024616455659270287,
          0.017844893038272858,
          -0.0043321368284523487,
          0.038232866674661636,
          -0.041765168309211731,
          -0.015017447993159294,
          -0.046843111515045166,
          -0.02491484209895134,
          0.0094039188697934151,
          0.016956280916929245,
          0.022230932489037514,
          0.062237169593572617,
          0.0439520925283432,
          -0.035331651568412781,
          0.022792087867856026,
          -0.0177854485809803,
          -0.035741176456213,
          0.018812444061040878,
          -0.0015067650238052011,
          -0.056927625089883804,
          -0.016059830784797668,
          0.030402090400457382,
          -0.010571143589913845,
          -0.026113193482160568,
          -0.0060997651889920235,
          0.0083835218101739883,
          -0.018285296857357025,
          -0.029934048652648926,
          0.020184030756354332,
          0.0034154073800891638,
          0.00237235683016479,
          0.010670823976397514,
          0.00012547780352178961,
          -0.060628276318311691,
          -0.0084161190316081047,
          -0.060863733291625977,
          -0.026325082406401634,
          0.017873430624604225,
          -0.029610361903905869,
          0.031875915825366974,
          0.032592881470918655,
          -0.023419534787535667,
          -0.035249080508947372,
          -0.0078541208058595657,
          -0.021709591150283813,
          0.0079167960211634636,
          0.014660331420600414,
          0.043110236525535583,
          -0.03487001359462738,
          -0.055759523063898087,
          0.002179933013394475,
          0.0848834216594696,
          0.031628761440515518,
          -0.0046144742518663406,
          0.043730400502681732,
          -0.025460192933678627,
          -0.026648577302694321,
          0.035486191511154175,
          -0.046214140951633453,
          0.007239712867885828,
          0.047322727739810944,
          0.0288052000105381,
          -0.028652723878622055,
          -0.0037461656611412764,
          -0.035873588174581528,
          -0.01836458221077919,
          -0.021551776677370071,
          0.010356859304010868,
          -0.037706732749938965,
          -0.0015300967497751117,
          -0.024040909484028816,
          -0.021991739049553871,
          0.05279931053519249,
          0.029689272865653038,
          -0.011161833070218563,
          -0.092574924230575562,
          0.05276835709810257,
          -0.014300218783318996,
          0.010284527204930782,
          -0.011415119282901287,
          -0.057631947100162506,
          0.061371389776468277,
          0.0096835307776927948,
          0.024255981668829918,
          0.00045667504309676588,
          -0.0099514946341514587,
          0.029966384172439575,
          0.018291058018803596,
          0.048728387802839279,
          0.032597146928310394,
          -0.049227144569158554,
          0.02859056368470192,
          -0.011064711026847363,
          -0.022336145862936974,
          0.010463166050612926,
          -0.056031439453363419,
          0.030088122934103012,
          -0.0068000038154423237,
          0.031818907707929611,
          0.018181581050157547,
          -0.026281209662556648,
          -0.027649767696857452,
          0.0063619641587138176,
          0.0014983814908191562,
          -0.027757028117775917,
          -0.0677800253033638,
          0.050914432853460312,
          0.011468294076621532,
          0.036111962050199509,
          0.030668970197439194,
          0.021078659221529961,
          0.046358183026313782,
          -0.0039190193638205528,
          0.012055959552526474,
          -0.018220817670226097,
          -0.0093942089006304741,
          0.031568825244903564,
          -0.027930382639169693,
          0.01756245456635952,
          -0.034884888678789139,
          0.035489458590745926,
          -0.057402454316616058,
          0.012431959621608257,
          0.049534190446138382,
          0.076713360846042633,
          -0.046164266765117645,
          -0.014683746732771397,
          -0.063365466892719269,
          0.0402139313519001,
          -0.029646303504705429,
          0.011863862164318562,
          -0.059141881763935089,
          -0.0096539147198200226,
          -0.00802008155733347,
          -0.021715229377150536,
          0.023114070296287537,
          -0.019527046009898186,
          -0.0444367378950119,
          0.0084402486681938171,
          -0.0043062940239906311,
          -0.032459143549203873,
          0.069625303149223328,
          0.0071613043546676636,
          -0.039952885359525681,
          0.016742879524827003,
          0.12426478415727615,
          -0.03690757229924202,
          -0.046673465520143509,
          0.022664748132228851,
          -0.0015964729245752096,
          -0.03295014426112175,
          -0.0065085799433290958,
          -0.0020393680315464735,
          -0.17158897221088409,
          -6.02473555773031e-05,
          0.016538256779313087,
          -0.051147650927305222,
          -3.1084717193152755e-05,
          -0.014451862312853336,
          -0.021461647003889084,
          -0.040933795273303986,
          0.031723391264677048,
          -0.075353547930717468,
          0.018864816054701805,
          -0.032818373292684555,
          0.0086905164644122124,
          -0.040777750313282013,
          0.054591860622167587,
          -0.014740613289177418,
          0.0015311044408008456,
          -0.0023663491010665894,
          0.020168516784906387,
          -0.040506951510906219,
          -0.031601753085851669,
          0.03977033868432045,
          -0.0039237723685801029,
          0.038682162761688232,
          -0.066593669354915619,
          -0.017195850610733032,
          0.027073463425040245,
          -0.016341743990778923,
          -0.020651334896683693,
          -0.017519522458314896,
          0.0086283786222338676,
          -0.055173460394144058,
          -0.014052296057343483,
          -0.010071054100990295,
          0.0234991405159235,
          0.035897217690944672,
          0.026073804125189781,
          0.009781157597899437,
          0.023003844544291496,
          -0.037815459072589874,
          -0.020861698314547539,
          -0.0001160782267106697,
          0.042673584073781967,
          -0.019456015899777412,
          -0.024175278842449188,
          0.00887260865420103,
          0.073118463158607483,
          0.0007028797990642488,
          -0.053898829966783524,
          -0.017049012705683708,
          -0.015866044908761978,
          0.041074711829423904,
          0.006722982507199049,
          0.010554057545959949,
          -0.024799229577183723,
          0.0014999278355389833,
          0.05796508863568306,
          -0.038971416652202606,
          0.024133875966072083,
          0.038408823311328888,
          0.017133297398686409,
          -0.013238903135061264,
          -0.017404269427061081,
          -0.010112117975950241,
          -0.042733136564493179,
          0.039005272090435028,
          -0.015757780522108078,
          0.015023832209408283,
          -0.039034295827150345,
          0.025784606114029884,
          -0.034814897924661636,
          0.010682228952646255,
          -0.022024558857083321,
          0.012652909383177757,
          0.06026160717010498,
          -0.0158837977796793,
          -0.0051385755650699139,
          -0.00509354192763567,
          -0.048735227435827255,
          0.0081318225711584091,
          0.059404216706752777,
          0.02323581650853157,
          -0.025588277727365494,
          -0.029172297567129135,
          0.045571859925985336,
          -0.027900652959942818,
          0.046487361192703247,
          -0.00060249428497627378,
          0.0052796183153986931,
          0.018766334280371666,
          -0.018207378685474396,
          -0.028080547228455544,
          0.006261750590056181,
          -0.014131380245089531,
          -0.023936944082379341,
          -0.0058982600457966328,
          -0.045024245977401733,
          0.00074653257615864277,
          -0.013740883208811283,
          0.009123614989221096,
          0.033719353377819061,
          -0.031148325651884079,
          0.0055756215006113052,
          -0.0443621389567852,
          8.0897792940959334e-05,
          0.071555666625499725,
          -0.0341670922935009,
          -0.021722590550780296,
          -0.0076287589035928249,
          -0.023003589361906052,
          -0.013624776154756546,
          -0.0052906842902302742,
          -0.00018225863459520042,
          -0.032098971307277679,
          -0.023788644000887871,
          0.012512697838246822,
          -0.038046084344387054,
          0.050530072301626205,
          0.015314036048948765,
          -0.0041715488769114017,
          0.022563951089978218,
          -0.0076685813255608082,
          0.029391083866357803,
          0.013386175036430359,
          -0.026719976216554642,
          -0.030390972271561623,
          0.041156403720378876,
          -0.037845931947231293,
          -0.0418287068605423,
          -0.02726445160806179,
          -0.043239906430244446,
          0.045565027743577957,
          -0.039215758442878723,
          -0.04005320742726326,
          -0.030921274796128273,
          -0.048105310648679733,
          -0.030200103297829628,
          -0.036578990519046783,
          0.054268926382064819,
          -0.070667892694473267,
          -0.015252616256475449,
          -0.0020989177282899618,
          0.014281987212598324,
          0.016198311001062393,
          0.039533548057079315,
          -0.0055923773907125,
          -0.037280794233083725,
          -0.053698014467954636,
          -0.074113108217716217,
          0.019100259989500046,
          -0.034026689827442169,
          -0.01589776948094368,
          -0.016470815986394882,
          0.004527305718511343,
          0.0049384594894945621,
          0.02424897626042366,
          -0.022919286042451859,
          -0.000932719383854419,
          -0.0398709774017334,
          -0.0088608758524060249,
          0.011772294528782368,
          0.013040509074926376,
          -0.032067049294710159,
          0.052671477198600769,
          0.025247801095247269,
          -0.035084132105112076,
          0.0022916251327842474,
          0.010862289927899837,
          -0.030127322301268578,
          -0.017595265060663223,
          0.020010216161608696,
          0.0097522614523768425,
          -0.027495620772242546,
          -0.021501971408724785,
          0.022594450041651726,
          -0.047076702117919922,
          -0.095144383609294891,
          -0.044689800590276718,
          -0.022939354181289673,
          -0.019717572256922722,
          -0.0030744229443371296,
          -0.027546141296625137,
          0.00024531024973839521,
          0.0018489062786102295,
          -0.038467716425657272,
          -0.012939534150063992,
          0.030025847256183624,
          0.00047190932673402131,
          -0.048362139612436295,
          0.034487910568714142,
          -0.005644570104777813,
          0.014611801132559776,
          -0.0010166236897930503,
          0.02893567830324173,
          0.00032747857039794326,
          0.002590113552287221,
          0.016698529943823814,
          -0.016067046672105789,
          0.033639095723629,
          -0.01272500678896904,
          -0.095197074115276337,
          0.022986825555562973,
          0.011578270234167576,
          -0.0085490681231021881,
          -0.02820982038974762,
          0.027242293581366539,
          0.015584683045744896,
          -0.018877191469073296,
          0.011676996015012264,
          0.025908367708325386,
          -0.011888467706739902,
          0.033566359430551529,
          0.0118098808452487,
          -0.031554318964481354,
          0.050506774336099625,
          -0.018691964447498322,
          -0.0087724896147847176,
          0.041709322482347488,
          -0.0074965008534491062,
          -0.025236101821064949,
          -0.056734494864940643,
          -0.024751385673880577,
          -0.0017706133658066392,
          -0.021796273067593575,
          -0.016532637178897858,
          0.0091147851198911667,
          -0.012102853506803513,
          0.1040823832154274,
          -0.026143310591578484,
          0.024864867329597473,
          0.0012257550843060017,
          0.026510421186685562,
          0.012120861560106277,
          -0.053318437188863754,
          0.013446405529975891,
          -0.0092000626027584076,
          0.047744601964950562,
          -0.01916712149977684,
          -0.0793130099773407,
          0.012573312036693096,
          -0.045523222535848618,
          0.010105717927217484,
          -0.042666662484407425,
          -0.14096125960350037,
          -0.006199283991008997,
          0.0056674065999686718,
          -0.023183494806289673,
          0.015512506477534771,
          0.0012833424843847752,
          0.041555318981409073,
          0.015058381482958794,
          0.0060295676812529564,
          -0.00931320246309042,
          -0.0088958172127604485,
          0.05530417338013649,
          -0.010741876438260078,
          0.029487820342183113,
          -0.016200318932533264,
          -0.022861532866954803,
          -0.010613166727125645,
          -0.025787154212594032,
          0.032756797969341278,
          0.08357682079076767,
          -0.0087577551603317261,
          -0.00076706340769305825,
          0.069976754486560822,
          -0.024074329063296318,
          0.031941983848810196,
          0.028854873031377792,
          -0.026110406965017319,
          0.022878957912325859,
          0.0077975653111934662,
          0.0085627157241106033,
          0.010242539457976818,
          0.00508549390360713
        ]
      }
    }
  ],
  "metadata": {
    "billableCharacterCount": 45
  }
}

@MrCsabaToth
Copy link
Member Author

For comparison, here is the call of the 004 embedding (with the same payload):

curl -X POST
     -H "Authorization: Bearer $(gcloud auth print-access-token)"
     -H "Content-Type: application/json; charset=utf-8"
     -d @request.json
     "https://us-central1-aiplatform.googleapis.com/v1/projects/duet-ai-roadshow-415022/locations/us-central1/publishers/google/models/text-embedding-004:predict"
{
  "predictions": [
    {
      "embeddings": {
        "statistics": {
          "token_count": 13,
          "truncated": false
        },
        "values": [
          -0.016722500324249268,
          0.032409753650426865,
          -0.053263206034898758,
          0.0075933993794023991,
          0.046885136514902115,
          0.014588227495551109,
          0.030420849099755287,
          0.031137362122535706,
          -0.015239215455949306,
          0.0066787987016141415,
          -0.013378811068832874,
          0.051181342452764511,
          0.10451716184616089,
          0.026061650365591049,
          -0.0045420387759804726,
          -0.040593724697828293,
          0.019489806145429611,
          0.024696018546819687,
          -0.073073893785476685,
          0.023589795455336571,
          0.022165276110172272,
          0.010520919226109982,
          0.028342509642243385,
          -0.029765661805868149,
          -0.011158361099660397,
          -0.021424815058708191,
          0.043313901871442795,
          -0.059918545186519623,
          0.031911730766296387,
          0.00052738614613190293,
          0.042713802307844162,
          0.077403664588928223,
          0.018459711223840714,
          -0.022964585572481155,
          0.013043171726167202,
          0.0039040092378854752,
          0.014727166853845119,
          -0.0037506595253944397,
          0.077670469880104065,
          -0.057848677039146423,
          -0.093526355922222137,
          0.0037229126319289207,
          -0.03657851368188858,
          0.069450743496418,
          -0.03182191401720047,
          -0.031100710853934288,
          0.0039494712837040424,
          0.0396987609565258,
          -0.023859472945332527,
          0.06520359218120575,
          0.043132167309522629,
          -0.0088603934273123741,
          -0.038068246096372604,
          -0.020608805119991302,
          -0.015901634469628334,
          -0.016034532338380814,
          -0.023815186694264412,
          -0.02960561029613018,
          0.04956735298037529,
          -0.025931335985660553,
          0.013992585241794586,
          -0.023106461390852928,
          -0.031746938824653625,
          -0.023092394694685936,
          0.0085400762036442757,
          -0.039396222680807114,
          -0.0012573269195854664,
          -0.025826824828982353,
          -0.094064027070999146,
          0.039299242198467255,
          0.0039649284444749355,
          -0.0027545152697712183,
          -0.034510578960180283,
          0.036019526422023773,
          0.023475509136915207,
          -0.0080276597291231155,
          0.031416777521371841,
          -0.03272261843085289,
          -0.027621718123555183,
          0.031457986682653427,
          -0.045476395636796951,
          0.047299399971961975,
          0.086032114923000336,
          0.072308063507080078,
          0.029276134446263313,
          0.030928527936339378,
          0.016835602000355721,
          -0.062085568904876709,
          -0.074041493237018585,
          -0.027044311165809631,
          0.076636753976345062,
          -0.023412719368934631,
          0.0044994130730628967,
          0.031774718314409256,
          0.098852880299091339,
          -0.049364455044269562,
          -0.092228084802627563,
          -0.079130947589874268,
          0.030251685529947281,
          0.082187801599502563,
          0.016215570271015167,
          0.019113378599286079,
          -0.02776644192636013,
          -0.027980290353298187,
          0.053634937852621078,
          0.066422648727893829,
          -0.036763157695531845,
          -0.02538563497364521,
          -0.060418464243412018,
          0.043990455567836761,
          -0.031455177813768387,
          -0.021560689434409142,
          0.033228438347578049,
          -0.036404471844434738,
          -0.020714761689305305,
          0.0023970943875610828,
          -0.025025671347975731,
          0.00269587361253798,
          -0.033014643937349319,
          -0.016931617632508278,
          -0.0077413297258317471,
          0.041830208152532578,
          -0.01577426865696907,
          0.08749052882194519,
          0.047235351055860519,
          0.001938781701028347,
          -0.004099368117749691,
          -0.0070778531953692436,
          -0.061830595135688782,
          -0.040238182991743088,
          0.058083027601242065,
          -0.062496788799762726,
          -0.0079630268737673759,
          0.043193522840738297,
          -0.0028657345101237297,
          -0.032217919826507568,
          0.063608378171920776,
          -0.0026765565853565931,
          0.029666466638445854,
          0.029717113822698593,
          0.0065227421000599861,
          -0.05392678827047348,
          -0.080859504640102386,
          0.013395684771239758,
          -0.0033660500776022673,
          -0.010723729617893696,
          0.0055348677560687065,
          0.073913276195526123,
          -0.026300009340047836,
          0.0353788398206234,
          -0.025888903066515923,
          -0.0067105228081345558,
          -0.012274575419723988,
          0.005269917193800211,
          -0.027422873303294182,
          -0.0094085214659571648,
          0.05583493784070015,
          -0.046655222773551941,
          0.05271945521235466,
          -0.017039164900779724,
          0.040403455495834351,
          -0.079773135483264923,
          0.01854822039604187,
          0.013410541228950024,
          -0.015381427481770515,
          -0.017672300338745117,
          0.028972549363970757,
          -0.068713173270225525,
          0.00032406815444119275,
          0.037328779697418213,
          -0.065457485616207123,
          -0.048142760992050171,
          -0.0013721764553338289,
          -0.048555098474025726,
          -0.012392120435833931,
          0.0087105482816696167,
          -0.018128974363207817,
          -0.021269578486680984,
          -0.04410407692193985,
          0.0042181815952062607,
          0.10986275970935822,
          0.041633524000644684,
          0.007483847439289093,
          -0.080939009785652161,
          -0.010923171415925026,
          -0.040077079087495804,
          -0.038010936230421066,
          0.0028125601820647717,
          0.039982303977012634,
          0.083343863487243652,
          -0.076751433312892914,
          0.0054352851584553719,
          0.0011601789155974984,
          0.021011756733059883,
          -0.020547270774841309,
          -0.0031872140243649483,
          0.024772858247160912,
          -0.041201595216989517,
          -0.024429628625512123,
          -0.025510242208838463,
          0.032654035836458206,
          -0.0025601547677069902,
          -0.01110873743891716,
          -0.049636758863925934,
          -0.0071271862834692,
          0.025743262842297554,
          -0.024788901209831238,
          -0.06054924800992012,
          0.028890121728181839,
          0.010279292240738869,
          -0.055088791996240616,
          -0.046719949692487717,
          0.027112996205687523,
          -0.036996278911828995,
          0.035534519702196121,
          0.0064693000167608261,
          0.042312577366828918,
          0.036214608699083328,
          0.066976100206375122,
          -0.0252698827534914,
          -0.0080494415014982224,
          -0.011216835118830204,
          -0.022826898843050003,
          -0.001349462429061532,
          0.021073747426271439,
          -0.0074141486547887325,
          -0.035716038197278976,
          -0.019166665151715279,
          0.020094197243452072,
          -0.011137012392282486,
          0.0071283117868006229,
          0.034872919321060181,
          0.011699020862579346,
          0.020481271669268608,
          -0.043710324913263321,
          0.043508268892765045,
          0.014829088933765888,
          -0.044294338673353195,
          -0.049173064529895782,
          -0.0011995631502941251,
          -0.0020096285734325647,
          0.029930012300610542,
          0.018299292773008347,
          0.011855324730277061,
          0.026068728417158127,
          -0.015177605673670769,
          0.041284237056970596,
          0.082379840314388275,
          -0.0174381285905838,
          -0.049503661692142487,
          -0.038034550845623016,
          -0.020140554755926132,
          -0.014016816392540932,
          -0.037409275770187378,
          -0.049937799572944641,
          -0.018149418756365776,
          0.065234750509262085,
          0.015874877572059631,
          -0.019663620740175247,
          -0.039437510073184967,
          0.03942590206861496,
          -0.023182965815067291,
          -0.01325707696378231,
          -0.052937019616365433,
          -0.048753410577774048,
          -0.0824175775051117,
          -0.035299360752105713,
          -0.0097839543595910072,
          0.073604613542556763,
          -0.042748022824525833,
          0.027734220027923584,
          -0.014643307775259018,
          0.0015147734666243196,
          -0.059865362942218781,
          -0.013124912045896053,
          0.0495704784989357,
          -0.011272280476987362,
          -0.0017365413950756192,
          -0.0059836115688085556,
          -0.058314122259616852,
          0.038130812346935272,
          0.010806785896420479,
          -0.033323217183351517,
          -0.00053167901933193207,
          -0.012327702715992928,
          -0.081273198127746582,
          -0.0127793550491333,
          -0.014244464226067066,
          -0.036958117038011551,
          0.010185387916862965,
          0.030475830659270287,
          0.020908145233988762,
          -0.0058989515528082848,
          -0.049127720296382904,
          0.039447519928216934,
          0.00028243847191333771,
          0.049685589969158173,
          0.020907344296574593,
          -0.055647026747465134,
          -0.0073981573805212975,
          0.045269925147295,
          0.061892576515674591,
          0.0045486683957278728,
          0.060802843421697617,
          0.0017253726255148649,
          0.0065088272094726562,
          -0.0082556726410985,
          -0.00916493684053421,
          -0.0047292574308812618,
          0.052355434745550156,
          -0.014909058809280396,
          0.03023739717900753,
          -0.019152432680130005,
          -0.075785651803016663,
          -0.054040715098381042,
          -0.052379604429006577,
          -0.16180272400379181,
          0.0020225991029292345,
          -0.021914290264248848,
          -0.0056397118605673313,
          0.0015444318996742368,
          0.030765281990170479,
          -0.034251481294631958,
          -0.032352868467569351,
          0.02692183293402195,
          -0.024158691987395287,
          -0.0041360822506248951,
          -0.0064119426533579826,
          0.022272191941738129,
          0.028427179902791977,
          0.0029375313315540552,
          0.0089548230171203613,
          -0.021705593913793564,
          -0.049962654709815979,
          -0.01829378679394722,
          0.025553716346621513,
          -0.011512328870594501,
          0.032310701906681061,
          0.0680682361125946,
          0.048368651419878006,
          0.041952021420001984,
          0.038969989866018295,
          0.035217948257923126,
          0.0058580534532666206,
          0.0067467200569808483,
          -0.037400692701339722,
          -0.016394069418311119,
          -0.02439538761973381,
          0.040449265390634537,
          0.024113187566399574,
          0.042666397988796234,
          0.055946856737136841,
          -0.016298824921250343,
          -0.014263945631682873,
          -0.018320651724934578,
          0.0048256455920636654,
          0.070511728525161743,
          -0.036395475268363953,
          0.025544220581650734,
          -0.0068054893054068089,
          0.010830053128302097,
          0.019119080156087875,
          -0.009021134115755558,
          0.0030538155697286129,
          -0.0090296929702162743,
          -0.055473890155553818,
          0.037933528423309326,
          0.03688514232635498,
          -0.055544950067996979,
          -0.017388323321938515,
          0.021337836980819702,
          0.025927452370524406,
          0.01236102357506752,
          -0.031116466969251633,
          0.026660257950425148,
          -0.03111264668405056,
          -0.037772644311189651,
          0.045715209096670151,
          0.016416944563388824,
          -0.026723785325884819,
          -0.0016200469108298421,
          -0.00043807021575048566,
          0.010516243986785412,
          -0.0010003607021644711,
          -0.01989438571035862,
          0.05826679989695549,
          -0.041043411940336227,
          0.038247127085924149,
          0.010992209427058697,
          0.0037623073440045118,
          -0.04000520333647728,
          0.018003948032855988,
          0.01711430586874485,
          0.047777988016605377,
          0.010968976654112339,
          0.0024632732383906841,
          -0.044490713626146317,
          0.024814814329147339,
          0.002660724800080061,
          0.0057569420896470547,
          -0.0019532004371285439,
          -0.049039188772439957,
          0.060297075659036636,
          -0.022560305893421173,
          -0.0022706331219524145,
          -0.0085129681974649429,
          0.072391942143440247,
          0.019415231421589851,
          0.0049497694708406925,
          -0.0018329138401895761,
          -0.0088093765079975128,
          -0.018327154219150543,
          -0.066685199737548828,
          0.042093321681022644,
          -0.033533122390508652,
          0.030089344829320908,
          0.019429475069046021,
          -0.035864043980836868,
          -0.018494267016649246,
          0.028211040422320366,
          -0.0080900788307189941,
          0.0343344546854496,
          -0.0020938331726938486,
          0.022308019921183586,
          0.0093867229297757149,
          -0.088539823889732361,
          -0.019267752766609192,
          0.01439562626183033,
          0.062832489609718323,
          -0.023542040959000587,
          0.039262760430574417,
          0.041609171777963638,
          0.001337496330961585,
          0.0646359845995903,
          0.039762962609529495,
          0.042012687772512436,
          0.00879718828946352,
          -0.037047389894723892,
          -0.038820460438728333,
          0.027516305446624756,
          0.0037339448463171721,
          -0.016776014119386673,
          0.048318896442651749,
          0.033557094633579254,
          -0.0016963870730251074,
          0.057931266725063324,
          0.016984399408102036,
          0.0025228559970855713,
          0.0051629436202347279,
          -0.0071125016547739506,
          0.02663414366543293,
          -0.020165996626019478,
          -0.054869037121534348,
          -0.039955340325832367,
          -0.078092522919178009,
          0.021087627857923508,
          0.047203890979290009,
          0.019378479570150375,
          -0.02930743619799614,
          -0.0053197713568806648,
          -0.020373774692416191,
          -0.025125166401267052,
          0.0650205984711647,
          0.026769937947392464,
          0.0032977159135043621,
          -0.036601271480321884,
          0.026618517935276031,
          0.05759044736623764,
          -0.042391002178192139,
          0.038427848368883133,
          0.042896918952465057,
          0.00088223535567522049,
          0.0235847607254982,
          0.04123934730887413,
          -0.073676906526088715,
          -0.0089143859222531319,
          0.032414611428976059,
          0.014512203633785248,
          0.013507270254194736,
          -0.02074156142771244,
          -0.007495170459151268,
          0.018472939729690552,
          -0.023671405389904976,
          0.038706153631210327,
          0.014390021562576294,
          -0.056902658194303513,
          -0.054087962955236435,
          0.00048969464842230082,
          0.0183763038367033,
          0.0060598100535571575,
          0.0063430164009332657,
          0.012780562043190002,
          -0.050684157758951187,
          0.0072912639006972313,
          -0.018304623663425446,
          -0.01298584695905447,
          0.0019017797894775867,
          -0.019163263961672783,
          -0.0076927137561142445,
          0.038826175034046173,
          0.046415206044912338,
          0.01954280212521553,
          -0.021528752520680428,
          -0.067588090896606445,
          -0.033248201012611389,
          0.023944174870848656,
          -0.0317067950963974,
          -0.029793109744787216,
          0.057651244103908539,
          0.00030442213756032288,
          0.057580012828111649,
          -0.0079544885084033012,
          0.028885111212730408,
          -0.0079712346196174622,
          -0.014006108976900578,
          0.039564236998558044,
          -0.025189951062202454,
          0.020815543830394745,
          -0.074204280972480774,
          0.031808141618967056,
          -0.0436573252081871,
          -0.022910945117473602,
          0.020082719624042511,
          -0.019528631120920181,
          -0.0076614003628492355,
          -0.055362481623888016,
          -0.014875208958983421,
          0.0067984787747263908,
          0.025364972651004791,
          -0.031649559736251831,
          -0.02526044100522995,
          0.090641379356384277,
          0.035829652100801468,
          0.027120761573314667,
          0.025860995054244995,
          0.051330059766769409,
          0.06741410493850708,
          0.011995734646916389,
          -0.0019326049368828535,
          0.013578549027442932,
          0.0036912667565047741,
          0.020486574620008469,
          0.0023475934285670519,
          0.011508979834616184,
          0.061154019087553024,
          0.025562793016433716,
          -0.011781212873756886,
          0.054564721882343292,
          -0.0062274457886815071,
          0.062936335802078247,
          -0.0456191785633564,
          -0.046667177230119705,
          0.0016587444115430117,
          0.01586030051112175,
          -0.0072436179034411907,
          -0.037756361067295074,
          0.0054557356052100658,
          -0.028410270810127258,
          -0.06384364515542984,
          -0.01080094650387764,
          0.020307904109358788,
          -0.032953593879938126,
          -0.0066134268417954445,
          -0.034536335617303848,
          -0.023437559604644775,
          -0.013058078475296497,
          -0.0042093852534890175,
          0.057160302996635437,
          -0.048498116433620453,
          -0.039237495511770248,
          0.015397642739117146,
          -0.021502619609236717,
          0.025364316999912262,
          -0.030177028849720955,
          0.016820617020130157,
          0.0044629410840570927,
          -0.026653232052922249,
          -0.01150424312800169,
          0.061398789286613464,
          -0.05052981898188591,
          0.025097418576478958,
          -0.0060188327915966511,
          0.0791311115026474,
          -0.016885537654161453,
          0.016079945489764214,
          -0.017330003902316093,
          0.016216712072491646,
          0.025029147043824196,
          -0.0077807307243347168,
          -0.008046773262321949,
          -0.040872160345315933,
          0.024990921840071678,
          0.0013206898001953959,
          -0.0332571305334568,
          -0.010158398188650608,
          -0.020395241677761078,
          -0.036654114723205566,
          0.0099316369742155075,
          0.024264531210064888,
          0.022689277306199074,
          0.0031313051003962755,
          -0.0024328436702489853,
          0.051225807517766953,
          0.014541300944983959,
          -0.017429938539862633,
          -0.043361242860555649,
          -0.029602032154798508,
          -0.027675770223140717,
          0.022758759558200836,
          0.0054391762241721153,
          0.0094474190846085548,
          0.044385485351085663,
          -0.0319492444396019,
          0.0099362470209598541,
          -0.07551167905330658,
          -0.0038146751467138529,
          -0.045572292059659958,
          -0.038885597139596939,
          -0.0032978404778987169,
          0.014146142639219761,
          -0.0048681986518204212,
          0.024991068989038467,
          0.012037001550197601,
          0.0042806887067854404,
          -0.030880218371748924,
          -0.00058462598826736212,
          -0.0065437708981335163,
          -0.00761528592556715,
          0.063845276832580566,
          -0.0080487178638577461,
          -0.027692148461937904,
          0.016787007451057434,
          0.081214413046836853,
          -0.029448211193084717,
          -0.022803071886301041,
          0.020602414384484291,
          0.008394196629524231,
          0.017003932967782021,
          -0.00092184776440262794,
          0.011008922010660172,
          0.012368042021989822,
          0.028012549504637718,
          0.054360687732696533,
          0.01189832016825676,
          -0.035269390791654587,
          0.069453127682209015,
          -0.023391829803586006,
          0.017020344734191895,
          0.040046058595180511,
          0.051810041069984436,
          0.0096082296222448349,
          -0.0071223839186131954,
          -0.0003307425940874964,
          0.016053387895226479,
          -0.021799355745315552,
          -0.00256650079973042,
          -0.017896177247166634,
          -0.014900152571499348,
          -0.014119005762040615,
          -0.0038263960741460323,
          -0.026816273108124733,
          0.00569531274959445,
          0.015737881883978844,
          0.028020666912198067,
          -0.020118040964007378,
          -0.0046447836793959141,
          -0.012223627418279648,
          0.0039264257065951824,
          -0.018204541876912117,
          -0.032855946570634842,
          0.0027764283586293459,
          -0.018948948010802269,
          -0.011843615211546421,
          0.048192501068115234,
          0.0044640302658081055,
          0.032081272453069687,
          0.028534719720482826,
          0.0031547835096716881,
          -0.036054633557796478,
          0.020710138604044914,
          0.0061266780830919743,
          -0.0027923958841711283,
          0.015844536945223808,
          -0.05948340892791748,
          0.018097462132573128,
          -0.021657753735780716,
          0.042552690953016281,
          -0.0458558164536953,
          -0.0053713885135948658,
          0.0397966168820858,
          0.0030462860595434904,
          -0.019357901066541672,
          -0.024021735414862633,
          0.044134333729743958,
          0.019138626754283905,
          0.040805518627166748,
          -0.037521582096815109,
          -0.00022854462440591305,
          -0.081912167370319366,
          -0.012425007298588753,
          -0.038766499608755112,
          0.014218413271009922,
          -0.06031503900885582,
          -0.057496026158332825,
          0.010833749547600746,
          -0.010470574721693993,
          0.048053763806819916,
          -0.0030220614280551672,
          -0.07963966578245163,
          -0.0016456586308777332,
          -0.023718979209661484,
          0.051403984427452087,
          -0.0042074332013726234,
          0.017381586134433746,
          -0.0064004883170127869,
          0.013992476277053356,
          0.014748291112482548,
          0.0042660865001380444,
          0.04349454864859581,
          0.0035186910536140203,
          -0.014583097770810127,
          -0.023969778791069984,
          0.057505261152982712,
          0.056631214916706085,
          -0.0026181472931057215,
          0.021767357364296913,
          -0.064992561936378479,
          0.016739437356591225,
          -0.021946385502815247,
          0.05469435453414917,
          0.035416010767221451,
          0.0040827034972608089,
          -0.014068931341171265,
          0.04915044829249382,
          -0.0012524226913228631,
          -0.040387913584709167,
          0.006815851666033268,
          0.024734072387218475,
          -0.0539962463080883,
          0.0025539519265294075,
          0.0072357989847660065,
          -0.022975575178861618,
          -0.090967796742916107,
          -0.029539778828620911,
          -0.0024344995617866516,
          -0.0021022427827119827,
          -0.035567700862884521,
          -0.0382637120783329,
          -0.031059341505169868,
          -0.0096123293042182922,
          -0.097755566239357,
          0.0048737511970102787,
          0.04275086522102356,
          -0.0012772650225088,
          0.045118939131498337,
          -0.016231458634138107,
          0.004538301844149828,
          -0.014355421997606754,
          0.0549403578042984,
          -0.0067816623486578465,
          -0.0062274457886815071,
          0.078395627439022064,
          -0.02036130428314209,
          0.0050725541077554226,
          -0.072064720094203949,
          -0.060127902776002884,
          0.034720364958047867,
          -0.015305683016777039
        ]
      }
    }
  ],
  "metadata": {
    "billableCharacterCount": 45
  }
}

@MrCsabaToth
Copy link
Member Author

Since embedding-004 the API supports outputDimensionality reduction, it's part of the parameter section of the payload:

{
  "instances": [
    { "content": "TEXT",
      "task_type": "TASK_TYPE",
      "title": "TITLE"
    },
  ],
  "parameters": {
    "autoTruncate": AUTO_TRUNCATE,
    "outputDimensionality": OUTPUT_DIMENSIONALITY
  }
}

According to doc the "reduction" is a simple truncation:

Used to specify output embedding size. If set, output embeddings will be truncated to the size specified.

Note that a code example suggests reduction to 256. Note also that autoTruncate is on by default.

@MrCsabaToth
Copy link
Member Author

Since the app is in alpha I will skip the data migration this time. Later when we'll need that the migration could mean a lot of embedding calls (with long chat history), which possibly even need to be throttled to not hit any quotas. We can use batch inference to cut down the number of requests, but that has a limit as well (max number of texts in the array). We cannot do that during app startup, this would rather be in the settings and once the user switches the embedding model an alert could verify the intent and then a progress bar view would accompany the process.

@MrCsabaToth
Copy link
Member Author

MrCsabaToth commented Aug 30, 2024

I'll decide if I take advantage of the dimensionality truncation. A reduction to 256 dimensions would cut the storage size in 1/3rd (768 / 3 = 256) and also the retrieval processing time as well. If we go with the truncation we'd definitely benefit from a reranking #39

@MrCsabaToth
Copy link
Member Author

Looks like the reduction works with any arbitrary number, I tried 64. I also realize that this is not available on the Gemini Dart API yet google-gemini/generative-ai-dart#208, however the workaround can be to perform the truncation ourselves until the support, since it's a simple truncation.

@MrCsabaToth
Copy link
Member Author

I ended up opening a separate ticket for dimensionality reduction: #47
My idea is that since we'd need to perform the reduction manually anyway, we should rather fold the dimensions instead of truncating. That will be a simple procedure only containing 512 floating point addition operations per embedding.

@MrCsabaToth MrCsabaToth added the RAG Retrieval Augmented Generation related label Aug 30, 2024
@MrCsabaToth MrCsabaToth self-assigned this Aug 31, 2024
@MrCsabaToth
Copy link
Member Author

I prefer multilingual model #48 over this upgrade

@MrCsabaToth MrCsabaToth closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request RAG Retrieval Augmented Generation related
Projects
None yet
Development

No branches or pull requests

1 participant