Add missing pip package llama-index-embeddings-huggingface-api

#49

Fix the following import error occurring at step 6 (IngestionPipeline relying on HuggingFaceInferenceAPIEmbedding)

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[6], line 1
----> 1 from llama_index.embeddings.huggingface_api import HuggingFaceInferenceAPIEmbedding
      2 from llama_index.core.node_parser import SentenceSplitter
      3 from llama_index.core.ingestion import IngestionPipeline

ModuleNotFoundError: No module named 'llama_index.embeddings.huggingface_api'

With %pip install -q -U google-generativeai
%pip install python-dotenv ipywidgets
%pip install llama-index datasets llama-index-callbacks-arize-phoenix llama-index-vector-stores-chroma llama-index-llms-huggingface llama-index-llms-huggingface-api -U -q
%pip install llama-index-embeddings-huggingface
%pip install llama-index-embeddings-huggingface-api -U -q" i got the same: ModuleNotFoundError Traceback (most recent call last)
Cell In[6], line 1
----> 1 from llama_index.embeddings.huggingface_api import HuggingFaceInferenceAPIEmbedding
2 from llama_index.core.node_parser import SentenceSplitter
3 from llama_index.core.ingestion import IngestionPipeline

ModuleNotFoundError: No module named 'llama_index.embeddings.huggingface_api'

I found the solution on https://docs.llamaindex.ai/en/stable/examples/embeddings/huggingface/ in the chapter "
Base HuggingFace Embeddings" with this example working:
from llama_index.embeddings.huggingface import HuggingFaceEmbedding

loads BAAI/bge-small-en-v1.5

embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
test_emeds = embed_model.get_text_embedding("Hello World!"). So finally my cell was running: from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.core.node_parser import SentenceSplitter
from llama_index.core.ingestion import IngestionPipeline

embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")

create the pipeline with transformations

pipeline = IngestionPipeline(
transformations=[
SentenceSplitter(),
embed_model ,
]
)

run the pipeline sync or async

nodes = await pipeline.arun(documents=documents[:10])
nodes

Result: [TextNode(id_='453ec6ba-6380-4ad6-87fb-23225f79318d', embedding=[-0.041332945227622986, 0.009067350067198277, 0.045314010232686996, -0.0031704942230135202, 0.004984738305211067, -0.03442731127142906, -0.01120108924806118, 0.01703874208033085, -0.05228905752301216, -0.06552951782941818, 0.0006800332339480519, -0.032225772738456726, -0.0361214205622673, 0.018456168472766876, -0.017449432983994484, -0.004060361068695784, 0.004597707651555538, 0.0856025218963623, 0.004833478946238756, 0.009958012029528618, 0.015292982570827007, -0.08044665306806564, 0.07174284011125565, -0.026560306549072266, -0.03583443537354469, 0.03176948055624962, 0.023099087178707123, -0.004005969036370516, 0.006027331110090017, -0.13000787794589996, -0.047905828803777695, 0.025874163955450058, -0.012980309315025806, -0.004410617519170046, 0.050506990402936935, 0.01496216282248497, 0.0032134917564690113, 0.05617731809616089, -0.0005276186857372522, 0.03524484485387802, 0.02124783769249916, 0.01660194993019104, -0.027336159721016884, 0.06564830243587494, 0.0651300773024559, -0.016639456152915955, -0.005451463162899017, -0.010113381780683994, -0.0028987585101276636, 0.002254751045256853, 0.009164107963442802, 0.002555646700784564, -0.03337232396006584, -0.005290789529681206, -0.020617742091417313, 0.0998319461941719, 0.10240244120359421, 0.023584231734275818, -0.0064231716096401215, 0.037448700517416, 0.056790005415678024, 0.02170727401971817, -0.1824636161327362, 0.0557890459895134, 3.102635673712939e-05, 0.010028543882071972, -0.06600049883127213, 0.0010374941630288959, -0.012904113158583641, -0.02515915222465992, -0.04104403778910637, -0.0149741405621171, -0.055378831923007965, 0.006561242043972015, 0.02122783474624157, -0.07705418020486832, 0.04287811741232872, 0.010192624293267727, -0.061003800481557846, 0.01711132936179638, 0.020656876266002655, -0.026467110961675644, -0.02733886055648327, -0.026953404769301414, 0.010681685991585255, 0.03345639631152153, 0.006906216964125633, 0.017420047894120216, -0.02873927727341652, -0.01234118640422821, -0.03811921551823616, -0.08056064695119858, 0.061106499284505844, 0.009597742930054665, -0.02798374742269516, -0.03212577849626541, 0.03368997573852539, 0.042575545608997345, -0.003906717989593744, 0.43671154975891113, -0.014699641615152359, -0.0036592467222362757, -0.016954617574810982, -0.027758684009313583, 0.028411436825990677, 0.012017425149679184, -0.00595382833853364, 0.021893002092838287, -0.041500024497509, -0.010865265503525734, -0.010625810362398624, 0.0024872238282114267, -0.049321115016937256, -0.031319428235292435, 0.09134368598461151, -0.013665853068232536, 0.05121807008981705, 0.07082359492778778, 0.010402699001133442, -0.012450761161744595, 0.023473525419831276, -0.0073508392088115215, 0.04818829149007797, 0.008054759353399277, -0.01724025420844555, -0.04499072954058647, -0.018214428797364235, 0.03397584706544876, 0.010159439407289028, 0.02183775044977665, -0.03142543509602547, 0.05600310489535332, -0.051218900829553604, 0.01956700161099434, -0.0061310455203056335, 0.05852903425693512, 0.04191441461443901, -0.03534305468201637, 0.02374560572206974, -0.0018296991474926472, 0.028594624251127243, -0.00808726903051138, -0.027935201302170753, 0.018780093640089035, -0.08773281425237656, 0.048089101910591125, -0.006184491328895092, -0.018536051735281944, 0.01875540055334568, -0.013666655868291855, -0.016536979004740715, 0.01218313816934824, -0.092189721763134, 0.05457121506333351, 0.039883796125650406, 0.01626967079937458, 0.08247333765029907, 0.027705315500497818, -0.052753280848264694, 0.071024090051651, 0.023657575249671936, -0.09345517307519913, 0.03509223461151123, 0.029804827645421028, 0.02173614501953125, -0.07139313966035843, -0.011930203065276146, -0.002416499424725771, 0.03570212051272392, -0.009351634420454502, 0.05248980224132538, 0.04449588060379028, -0.045822691172361374, 0.05833965539932251, 0.04302315041422844, 0.01919221691787243, -0.03468142822384834, 0.005975401494652033, 0.005459193605929613, 0.03582235425710678, -0.03231566399335861, -0.032660700380802155, -0.0010448000393807888, 0.013913383707404137, -0.014218131080269814, 0.02718822844326496, 0.007714171893894672, 0.006632671691477299, 0.026822753250598907, 0.05908038839697838, 0.04718808829784393, 0.03527361899614334, -0.012378890067338943, -0.027112405747175217, -0.02526053972542286, -0.015536771155893803, 0.0008287122473120689, 0.03273368999361992, -0.023911893367767334, -0.04670843482017517, -0.05848315730690956, 0.007303070742636919, -0.059699323028326035, 0.03536807373166084, -0.023538745939731598, 0.002920907223597169, -0.006674579344689846, 0.0011525735026225448, 0.029340974986553192, -0.05584575608372688, -0.05681641772389412, -0.03222868591547012, -0.008526326157152653, -0.015204260125756264, 0.034091077744960785, -0.010699339210987091, 0.055003147572278976, -0.006634707562625408, 0.09175414592027664, 0.03550543263554573, -0.06536974757909775, -0.07017211616039276, -0.09150739759206772, -0.3013283908367157, -0.007358519360423088, -0.05957943946123123, 0.04896940663456917, -0.043855633586645126, -0.06216764822602272, -0.019591446965932846, 0.02290809340775013, -0.00832637120038271, 0.05801398307085037, -0.03149576857686043, -0.015043928287923336, -0.0022843540646135807, 0.024730753153562546, 0.027922552078962326, 0.016877388581633568, 0.06543832272291183, 0.017594879493117332, -0.056787751615047455, -0.022364988923072815, 0.018123265355825424, -0.02698904275894165, -3.3412092307116836e-05, -0.029443642124533653, 0.017701728269457817, 0.01788935996592045, 0.10022366046905518, 0.06030913442373276, -0.03015471063554287, -0.04575174301862717, -0.03384491428732872, -0.024680549278855324, -0.09968480467796326, -0.11307013034820557, -0.013790212571620941, -0.009269608184695244, 0.05158529430627823, 0.030902216210961342, -0.014115754514932632, 0.056835588067770004, -0.06414065510034561, -0.05935835465788841, -0.013087719678878784, 0.02457541786134243, -0.030009238049387932, 0.045894842594861984, 0.0426289364695549, -0.0019668424502015114, 0.027564197778701782, 0.010523189790546894, 0.03548938035964966, -0.015792423859238625, -0.02577577345073223, 0.025583280250430107, -0.07057563215494156, -0.022774754092097282, -0.03171762451529503, 0.05015665292739868, 0.007359371054917574, 0.032129354774951935, 0.020409338176250458, -0.05158661678433418, -0.00012129063543397933, 0.013112397864460945, 0.0323212631046772, 0.008380802348256111, -0.05581660196185112, -0.051760122179985046, 0.08602114766836166, -0.07511799037456512, 0.016434459015727043, 0.03202737867832184, -0.04380973428487778, -0.053527381271123886, 0.00896440539509058, 0.04358638823032379, 0.0419851653277874, -0.000537160667590797, 0.011261365376412868, -0.02045127935707569, 0.061019670218229294, -0.01384558342397213, 0.014711450785398483, -0.012757597491145134, -0.04425697401165962, 0.01658298447728157, 0.04798426479101181, -0.04453880712389946, 0.027242744341492653, 0.002302535343915224, 0.010367898270487785, -0.004604297690093517, -0.024582117795944214, -0.02553459256887436, 0.005828562658280134, 0.002397824078798294, -0.2558535635471344, 0.003184608882293105, 0.09798002988100052, 0.02915128320455551, 0.015612064860761166, 0.03929789736866951, 0.021403232589364052, -0.017933109775185585, 0.054454755038022995, 0.012800713069736958, 0.09868155419826508, -0.03273751959204674, 0.009620936587452888, -0.05798213183879852, -0.00027490651700645685, -0.023249894380569458, 0.016413483768701553, 0.060314394533634186, 4.7569588787155226e-05, 0.02575172670185566, -0.020711226388812065, -0.05676734074950218, 0.1573728322982788, -0.004716068506240845, -0.012953726574778557, -0.10545027256011963, -0.010198810137808323, -0.02924421615898609, 0.008826099336147308, 0.024642450734972954, -0.02855210192501545, -0.0030454916413873434, 0.04931654408574104, -0.06400243192911148, 0.012422721832990646, 0.020133929327130318, -0.024791931733489037, 0.07206056267023087, -0.0370284840464592, -0.04417375102639198, -0.062337733805179596, 0.010869198478758335, -0.050606437027454376, -0.05010642483830452, 0.04761314392089844, 0.028948353603482246, -0.009823376312851906, 0.050759561359882355, -0.023747436702251434, 0.05526141822338104, 0.027527518570423126, -0.04484310373663902, -0.06076750159263611, 0.0038701349403709173, 0.030123624950647354, 0.0673835277557373, 0.024884138256311417, 0.022848641499876976, -0.003263763850554824, 0.018232295289635658, 0.0007643077988177538, 0.012628400698304176, 0.007578621618449688, -0.020551810041069984, 0.050375666469335556], metadata={'file_path': '/home/martin/ExternePlatten/LinuxData/LanguageModels/Trainings/HuggingFace/LLamaIndex/data/persona_0.txt', 'file_name': 'persona_0.txt', 'file_type': 'text/plain', 'file_size': 132, 'creation_date': '2025-03-12', 'last_modified_date': '2025-03-12'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={<NodeRelationship.SOURCE: '1'>: RelatedNodeInfo(node_id='60db66b2-0d47-45a9-a2ef-7286c59d9e7c', node_type=<ObjectType.DOCUMENT: '4'>, metadata={'file_path': '/home/martin/ExternePlatten/LinuxData/LanguageModels/Trainings/HuggingFace/LLamaIndex/data/persona_0.txt', 'file_name': 'persona_0.txt', 'file_type': 'text/plain', 'file_size': 132, 'creation_date': '2025-03-12', 'last_modified_date': '2025-03-12'}, hash='58941961f90b934d82fa9d9b70fda325c381f42a776edd7a7dd312150a5e6268')}, metadata_template='{key}: {value}', metadata_separator='\n', text='A local art historian and museum professional interested in 19th-century American art and the local cultural heritage of Cincinnati.', mimetype='text/plain', start_char_idx=0, end_char_idx=132, metadata_seperator='\n', text_template='{metadata_str}\n\n{content}'),
TextNode(id_='71a0b2eb-1ecc-4157-b160-7a80d220914e', embedding=[0.018294867128133774, 0.08462988585233688, 0.037305593490600586, -0.04070982336997986, -0.017835011705756187, -0.06227517127990723, 0.07314393669366837, 0.02052365429699421, -0.015876999124884605, -0.035049330443143845, -0.01971106231212616, -0.09965484589338303, 0.02657662145793438, 0.013252542354166508, 0.013017113320529461, 0.03176000341773033, -0.0008040915708988905, 0.015870921313762665, 0.01783314347267151, 0.007858190685510635, 0.037690646946430206, -0.06152050942182541, -0.008311556652188301, -0.014004741795361042, -0.029202381148934364, 0.01456891093403101, 0.03514190763235092, -0.028521763160824776, -0.015729324892163277, -0.09152117371559143, -0.035128913819789886, 0.007489635143429041, -0.0031195003539323807, 0.014446535147726536, -0.01906348578631878, 0.00729037681594491, 0.028389587998390198, 0.02948128618299961, -0.0007086701807565987, 0.10824833065271378, 0.01851908303797245, -0.05295424163341522, 0.008626931346952915, 0.045585744082927704, 0.03794669359922409, -0.043701428920030594, -0.009404988959431648, -0.008188808336853981, -0.03544452786445618, -0.06561090797185898, -0.07629749923944473, -0.04547080025076866, -0.01804407872259617, -0.03358574956655502, -0.03243524953722954, -0.0062443166971206665, 0.11083853244781494, 0.029896533116698265, -0.0006672837189398706, 0.026027563959360123, 0.047981373965740204, 0.07183539867401123, -0.13923107087612152, 0.08114360272884369, -0.020897556096315384, 0.06642939895391464, -0.010458961129188538, -0.05230787396430969, -0.07753857225179672, -0.07005216926336288, -0.07750658690929413, 0.022437546402215958, 0.03730073943734169, 0.041348181664943695, 0.023618048056960106, -0.025523219257593155, 0.015187516808509827, -0.009056387469172478, -0.03950725868344307, 0.04796389862895012, 0.030695995315909386, -0.007719182875007391, -0.036978211253881454, -0.03550310805439949, 0.03597264364361763, 0.047846220433712006, 0.007400799077004194, 0.01528893131762743, -0.01098951231688261, 0.02477378025650978, -0.04599122703075409, 0.00539435027167201, 0.04548784717917442, 0.027481675148010254, -0.006464299280196428, -0.022477855905890465, -0.017414582893252373, 0.0604214146733284, -0.04029170796275139, 0.4113937020301819, -0.013843756169080734, -0.027778780087828636, 0.04684419184923172, 0.005191903095692396, 0.021395990625023842, -0.01965607888996601, 0.0296457652002573, 0.001028803177177906, 0.03492634743452072, -0.016069993376731873, -0.03407776355743408, 0.04262160509824753, -0.050679516047239304, 0.010479193180799484, 0.051490165293216705, -0.00039761955849826336, 0.048849087208509445, 0.04199696704745293, -0.028207536786794662, -0.02979966811835766, -0.001500279875472188, -0.05425899848341942, 0.0624317042529583, -0.007177273742854595, 0.012576342560350895, 0.02452419511973858, 0.00950634479522705, 0.05103634297847748, 0.025372004136443138, 0.052833203226327896, 0.041593119502067566, -0.0036843253765255213, -0.03290576487779617, 0.010461251251399517, 0.0031060355249792337, 0.02629726566374302, -0.013064282946288586, -0.02272781915962696, 0.018285583704710007, -0.0154929393902421, -0.03116079792380333, -0.0062871831469237804, 0.03848916292190552, 0.05559035763144493, -0.08873045444488525, 0.046375859528779984, -0.023938622325658798, 0.0441189669072628, -0.01578863523900509, 0.06482632458209991, -0.045684196054935455, 0.03178242966532707, -0.03674441576004028, -0.011224469169974327, -0.00023751970729790628, -0.024784451350569725, 0.08762974292039871, 0.018125373870134354, -0.05643008276820183, -0.01717844046652317, -0.0021031247451901436, -0.1091243252158165, -0.018921585753560066, 0.04722323641180992, 0.028535783290863037, -0.07899762690067291, -0.01084232423454523, 0.001905150362290442, 0.03854481130838394, -0.04153554141521454, 0.049250081181526184, -0.000900478451512754, -0.021152514964342117, 0.04128823056817055, 0.05832569673657417, 0.00736895902082324, 0.006218443624675274, 0.03993025794625282, -0.017538858577609062, 0.022733692079782486, 0.018129143863916397, 0.0034926512744277716, -0.013526099734008312, -0.009313979186117649, -0.019077826291322708, -0.01249456126242876, -0.058269668370485306, 0.012471160851418972, 0.051874998956918716, -0.018144840374588966, 0.03425122797489166, 0.06873521208763123, 0.0011189287761226296, -0.06572187691926956, 0.03616774454712868, -0.0028066663071513176, -0.006592564284801483, 0.012915942817926407, -0.04325176775455475, 0.014880280010402203, -0.04741201549768448, 0.09484266489744186, -0.007241315674036741, 0.012264562770724297, -0.025964146479964256, -0.05591516196727753, 0.005195487290620804, 0.025471435859799385, 0.02049267664551735, -0.01431381143629551, -0.025214489549398422, -0.01828659512102604, -0.09270244091749191, 0.03192823380231857, 0.017084330320358276, -0.023827670142054558, 0.05659175291657448, -0.0176393985748291, 0.06519415974617004, -0.004893360659480095, -0.02954922989010811, -0.09703253209590912, -0.06518584489822388, -0.31099608540534973, 0.059446562081575394, -0.0011221755994483829, 0.04440035670995712, -0.005810285918414593, -5.614329711534083e-05, 0.003315594745799899, 0.029463166370987892, 0.029061727225780487, 0.012739274650812149, 0.0032557938247919083, -0.03104557655751705, -0.0167549941688776, 0.10706298053264618, 0.004694777075201273, 0.00475181732326746, 0.019524389877915382, -0.01428203471004963, -0.05655268579721451, -0.009442870505154133, -0.005625920370221138, -0.006797869224101305, -0.01707841083407402, -0.08601801097393036, 0.015813708305358887, -0.017365489155054092, 0.09597738087177277, 0.07614833116531372, -0.023740723729133606, -0.09697014838457108, 0.014535542577505112, 0.045748911798000336, -0.031412847340106964, -0.15271559357643127, 0.02275431528687477, -0.02388934977352619, 0.07359122484922409, -0.05713527649641037, 0.006493949797004461, 0.017422610893845558, 0.024607641622424126, -0.04492426663637161, 0.006248578894883394, 0.04919060692191124, -0.06446091085672379, 0.03719787672162056, 0.013914034701883793, -0.014018449932336807, 0.0328356996178627, 0.008281181566417217, 0.0016630663303658366, 0.013942667283117771, -0.013900965452194214, -0.02464418113231659, -0.09347954392433167, 0.005151862744241953, -0.028284713625907898, -0.017731165513396263, -0.018853183835744858, 0.06426806002855301, 0.04492976889014244, 0.00625296076759696, 0.060341089963912964, -0.000591647403780371, 0.023292236030101776, -0.05754639580845833, -0.05000888928771019, 0.035543397068977356, 0.06767841428518295, -0.011980132199823856, 0.005534857977181673, 0.11905956268310547, -0.07038194686174393, -0.019937720149755478, 0.02163345366716385, -0.003208916401490569, 0.009764567017555237, -0.01570303365588188, 0.0036691329441964626, 0.02923484519124031, 0.09277708828449249, -0.06928201019763947, -0.04440062865614891, -0.008475150913000107, 0.018348557874560356, 0.02308298647403717, -0.005135706625878811, -0.040002308785915375, 0.03310944885015488, -0.02917572669684887, 0.001728285220451653, 0.020004551857709885, -0.026233281940221786, -0.00941296387463808, -0.01567384973168373, 0.005032102111726999, -0.2633620798587799, 0.062059395015239716, -0.02213640697300434, 0.022980641573667526, 0.09089589864015579, 0.000234582184930332, -0.0399191714823246, 0.0019833643455058336, 0.028677290305495262, -0.023309241980314255, 0.109468474984169, 0.010231385007500648, 0.031102653592824936, 0.03626209869980812, 0.012353715486824512, -0.007468645926564932, 0.054271623492240906, 0.002789817750453949, 0.030158275738358498, -0.03221786022186279, -0.044687312096357346, -0.06408765912055969, 0.12686146795749664, 0.01401266548782587, -0.037006210535764694, -0.07743930071592331, -0.0071536824107170105, -0.025468653067946434, 0.00585741363465786, -0.061836134642362595, 0.025067301467061043, 0.006354640703648329, 0.02724836766719818, -0.0021101883612573147, 0.007605257444083691, 0.022213110700249672, -0.008911038748919964, 0.0025592194870114326, -0.009217089042067528, -0.027291273698210716, -0.026325199753046036, -0.022281941026449203, 0.0421261228621006, 0.013847963884472847, 0.06108025088906288, -0.019904397428035736, -0.03928301855921745, -0.0462917797267437, 0.015866396948695183, 0.01261853240430355, 0.036630403250455856, -0.0449371375143528, -0.05874146148562431, 0.05129314586520195, 0.02162526175379753, -0.015680942684412003, -0.02451855130493641, -0.04392381012439728, 0.053310684859752655, -0.04052154719829559, -0.0036035955417901278, 0.011350327171385288, 0.015976903960108757, -0.044815316796302795, -0.021200336515903473], metadata={'file_path': '/home/martin/ExternePlatten/LinuxData/LanguageModels/Trainings/HuggingFace/LLamaIndex/data/persona_1.txt', 'file_name': 'persona_1.txt', 'file_type': 'text/plain', 'file_size': 266, 'creation_date': '2025-03-12', 'last_modified_date': '2025-03-12'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={<NodeRelationship.SOURCE: '1'>: RelatedNodeInfo(node_id='7528b649-6f05-4772-99a3-4462f1970db0', node_type=<ObjectType.DOCUMENT: '4'>, metadata={'file_path': '/home/martin/ExternePlatten/LinuxData/LanguageModels/Trainings/HuggingFace/LLamaIndex/data/persona_1.txt', 'file_name': 'persona_1.txt', 'file_type': 'text/plain', 'file_size': 266, 'creation_date': '2025-03-12', 'last_modified_date': '2025-03-12'}, hash='e6c87149a97bf9e5dbdf33922a4e5023c6b72550ca0b63472bd5d25103b28e99')}, metadata_template='{key}: {value}', metadata_separator='\n', text='An anthropologist or a cultural expert interested in the intricacies of Cypriot culture, history, and society, particularly someone who has spent considerable time researching and living in Cyprus to gain a deep understanding of its people, customs, and way of life.', mimetype='text/plain', start_char_idx=0, end_char_idx=266, metadata_seperator='\n', text_template='{metadata_str}\n\n{content}'),
...

Ready to merge
This branch is ready to get merged automatically.
Your need to confirm your account before you can post a new comment.

Sign up or log in to comment