Dataset Preview
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
Couldn't reach 'Igortin/github-datasets-issues-embeddings' on the Hub (ReadTimeout)
Error code: UnexpectedError
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
html_url
string | title
string | comments
string | body
string | comments_length
int64 | text
string | embeddings
sequence |
---|---|---|---|---|---|---|
https://github.com/huggingface/datasets/issues/7456
|
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
|
I can fix this.
It's mainly because faiss-gpu requires python<=3.10 but the default python version in colab is 3.11. We just have to downgrade the CPython version down to 3.10 and it should work fine.
|
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
| 35 |
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
I can fix this.
It's mainly because faiss-gpu requires python<=3.10 but the default python version in colab is 3.11. We just have to downgrade the CPython version down to 3.10 and it should work fine.
|
[
-0.16117000579833984,
-0.11760753393173218,
-0.15066224336624146,
0.08203524351119995,
-0.1286037713289261,
-0.00994054228067398,
0.10475793480873108,
0.1413806676864624,
0.5156817436218262,
0.4201788902282715,
-0.23171284794807434,
0.3851391077041626,
0.09162198752164841,
-0.031732842326164246,
-0.22691023349761963,
0.2530635595321655,
0.31324052810668945,
0.3141487240791321,
0.286990761756897,
-0.225828155875206,
-0.21031071245670319,
0.24549394845962524,
-0.11663298308849335,
-0.14979669451713562,
-0.061843808740377426,
0.20163683593273163,
-0.04081256687641144,
-0.060086242854595184,
-0.17773616313934326,
-0.4343525171279907,
0.3564590811729431,
-0.2465187907218933,
0.06784113496541977,
0.45280614495277405,
-0.00012001708091702312,
0.16983987390995026,
0.46698254346847534,
0.038603462278842926,
-0.20051944255828857,
-0.2968881130218506,
-0.34063124656677246,
-0.1492750197649002,
0.3670836389064789,
-0.11481065303087234,
0.007955286651849747,
-0.11012418568134308,
-0.11281844973564148,
-0.21513177454471588,
0.13531622290611267,
0.4694521725177765,
0.14951427280902863,
0.06196172535419464,
0.1800299882888794,
-0.21636570990085602,
0.5414345264434814,
-0.30696386098861694,
-0.22465455532073975,
-0.016008924692869186,
0.036910559982061386,
0.24787604808807373,
0.4191136360168457,
0.1929059773683548,
-0.08678627014160156,
-0.01986824721097946,
-0.36704665422439575,
0.07248660922050476,
-0.07346541434526443,
-0.3942570388317108,
-0.011618684977293015,
-0.037493087351322174,
0.10735979676246643,
-0.16118240356445312,
-0.22358283400535583,
0.1561070680618286,
0.10509961098432541,
-0.25884976983070374,
0.22590795159339905,
0.02065884694457054,
0.014161558821797371,
0.19833941757678986,
0.3465823531150818,
-0.14075376093387604,
-0.19422593712806702,
0.05597778782248497,
-0.28478899598121643,
0.49147096276283264,
-0.04927155748009682,
-0.11800331622362137,
0.11341769993305206,
-0.10482732951641083,
0.22461381554603577,
0.06444834917783737,
0.16802719235420227,
-0.10034651309251785,
-0.17825940251350403,
0.04722083359956741,
0.1361667960882187,
-0.08213513344526291,
-0.12494523078203201,
-0.039579398930072784,
-0.35669249296188354,
0.007569471374154091,
0.09197752922773361,
0.3693396747112274,
-0.4950583577156067,
0.12524934113025665,
0.00571085512638092,
-0.0023592920042574406,
0.2595343589782715,
0.07186460494995117,
-0.13065402209758759,
-0.014068752527236938,
0.07384522259235382,
-0.2511730492115021,
-0.41447457671165466,
-0.1172662153840065,
0.137697234749794,
-0.3650587499141693,
-0.46173542737960815,
0.08694619685411453,
-0.37541764974594116,
-0.07669366896152496,
0.010866579599678516,
0.3808978796005249,
-0.033448271453380585,
-0.3733902871608734,
0.1065153032541275,
0.23127561807632446,
-0.11577831953763962,
0.27290013432502747,
-0.18207122385501862,
0.2185625433921814,
0.15644453465938568,
0.28199055790901184,
0.3098966181278229,
-0.6035938858985901,
0.430266410112381,
-0.01865580677986145,
0.11926405131816864,
0.12065625190734863,
0.11778198182582855,
-0.27658987045288086,
0.09237615019083023,
0.5115554928779602,
0.11889557540416718,
0.06079360097646713,
-0.01675218716263771,
-0.30686694383621216,
-0.12403038889169693,
0.02150382101535797,
-0.4513663053512573,
-0.1714765429496765,
-0.2683683931827545,
0.1931690275669098,
-0.26483702659606934,
-0.1902206540107727,
-0.00963158905506134,
0.06139732152223587,
0.022929102182388306,
-0.031789038330316544,
-0.10731133073568344,
-0.10580423474311829,
-0.11228859424591064,
-0.20336408913135529,
0.19544769823551178,
-0.010690644383430481,
-0.2846740484237671,
-0.18304625153541565,
-0.2959628105163574,
0.21858294308185577,
-0.002251371741294861,
0.3062683939933777,
-0.039837151765823364,
0.16121360659599304,
-0.2587433457374573,
0.18084590137004852,
0.47567662596702576,
-0.38209670782089233,
-0.33405327796936035,
-0.0464184507727623,
0.20323805510997772,
-0.11482933163642883,
0.33721107244491577,
-0.3041093647480011,
0.13790956139564514,
0.21408343315124512,
0.40372195839881897,
0.09647197276353836,
0.04032605141401291,
-0.21423329412937164,
-0.31953945755958557,
-0.3014972507953644,
0.04426121711730957,
0.1507096290588379,
0.28164923191070557,
-0.1397862732410431,
0.2283763289451599,
-0.558803915977478,
-0.2248099148273468,
-0.027080070227384567,
-0.17033375799655914,
0.17325320839881897,
0.7504816651344299,
0.11588825285434723,
0.250286728143692,
-0.09420672804117203,
0.03429264575242996,
0.23494622111320496,
-0.16884760558605194,
0.3206605911254883,
-0.5654057264328003,
-0.07951882481575012,
-0.2047884464263916,
0.01621283032000065,
-0.11963531374931335,
-0.08547830581665039,
0.09035539627075195,
0.02688578888773918,
0.07011270523071289,
0.3450736999511719,
-0.149666428565979,
0.23788809776306152,
0.029455920681357384,
0.08601481467485428,
-0.2821899652481079,
0.4557609260082245,
-0.355103999376297,
-0.21232423186302185,
-0.26934367418289185,
0.0550079345703125,
0.11870615184307098,
-0.16724710166454315,
-0.06345903128385544,
-0.1393352746963501,
0.022707529366016388,
0.001660957932472229,
0.35844680666923523,
-0.031841471791267395,
0.15138156712055206,
-0.3605331778526306,
0.0007368139922618866,
-0.014245271682739258,
0.19100113213062286,
0.10995949059724808,
0.13783526420593262,
0.22354117035865784,
0.34959572553634644,
0.31639477610588074,
0.048732027411460876,
-0.25815367698669434,
0.2894139289855957,
0.15064361691474915,
-0.00478145107626915,
-0.3528922200202942,
-0.01283501461148262,
0.2490568608045578,
0.1571197658777237,
-0.07574699074029922,
0.10761070251464844,
0.1634841412305832,
0.24935084581375122,
0.1806226223707199,
0.059507012367248535,
-0.01909622550010681,
-0.18093451857566833,
0.04272516071796417,
0.2133590131998062,
-0.3315229117870331,
0.5042451024055481,
0.1952822357416153,
-0.10752677917480469,
0.002021320164203644,
-0.23246237635612488,
-0.15534016489982605,
0.22551575303077698,
0.15586592257022858,
0.16927507519721985,
0.021715018898248672,
0.40005555748939514,
0.001977999694645405,
-0.1599210500717163,
-0.396759033203125,
-0.18060946464538574,
0.015682226046919823,
-0.22388997673988342,
0.23846985399723053,
-0.3335368037223816,
0.0387190580368042,
-0.26496416330337524,
-0.32123979926109314,
-0.05915385112166405,
-0.1550196409225464,
-0.06616184115409851,
0.1655339002609253,
-0.04197154939174652,
0.09799930453300476,
0.08658251166343689,
0.16132646799087524,
0.12170617282390594,
-0.5659324526786804,
-0.12707310914993286,
0.07293909043073654,
-0.13817229866981506,
0.03119627758860588,
0.0463983528316021,
0.1443513184785843,
0.2281331866979599,
-0.22272621095180511,
-0.04931464046239853,
-0.03734709322452545,
-0.5407865047454834,
0.13256728649139404,
-0.17953747510910034,
0.3834962248802185,
-0.02238471806049347,
-0.22363264858722687,
-0.2287382334470749,
-0.2209000587463379,
0.08535301685333252,
0.03302214294672012,
-0.07387572526931763,
-0.16914428770542145,
-0.2024255096912384,
0.16350404918193817,
-0.07980343699455261,
-0.4645572602748871,
-0.273506760597229,
-0.29208099842071533,
-0.1883683055639267,
0.23808394372463226,
0.07035378366708755,
-0.051195427775382996,
0.4012899398803711,
0.12842698395252228,
0.26016679406166077,
0.1833799034357071,
-0.08417943865060806,
0.1034243106842041,
0.40126869082450867,
-0.2088790237903595,
-0.19478511810302734,
0.3140634596347809,
-0.19571863114833832,
0.1738995611667633,
0.26666849851608276,
-0.20691372454166412,
-0.25385159254074097,
-0.1654600203037262,
0.2149738371372223,
0.15121686458587646,
0.3295900523662567,
0.208226278424263,
0.06291403621435165,
-0.0629701241850853,
-0.07440649718046188,
-0.340837299823761,
0.037091124802827835,
0.24042591452598572,
0.13391061127185822,
-0.08302077651023865,
0.3498714864253998,
-0.14694276452064514,
0.6421234011650085,
0.0022957678884267807,
-0.12015606462955475,
0.4455321133136749,
0.1388605386018753,
0.3459651470184326,
-0.22012680768966675,
-0.25990140438079834,
-0.06418562680482864,
0.2821204662322998,
-0.11512740701436996,
0.11511081457138062,
-0.05819567292928696,
-0.2546572983264923,
-0.2041834443807602,
-0.015062844380736351,
-0.22018662095069885,
-0.04428558051586151,
-0.00493219681084156,
0.5682275295257568,
0.18974393606185913,
-0.02852044627070427,
0.019131436944007874,
-0.08276355266571045,
0.0331137590110302,
-0.07715123891830444,
0.36668384075164795,
-0.19770854711532593,
0.01454408559948206,
0.5677427053451538,
-0.5961407423019409,
-0.3954414427280426,
0.47168171405792236,
0.12705183029174805,
0.1797829270362854,
0.12959589064121246,
-0.09018629789352417,
0.16894309222698212,
0.047159794718027115,
0.3042554259300232,
-0.10313451290130615,
-0.5570278763771057,
0.25937291979789734,
-0.021157583221793175,
-0.4514586329460144,
-0.27979105710983276,
-0.40093061327934265,
0.17905350029468536,
0.21344764530658722,
0.4027971625328064,
-0.1314033567905426,
-0.031220823526382446,
0.11118880659341812,
0.23547682166099548,
-0.012499582022428513,
-0.12767396867275238,
-0.4390488564968109,
-0.5053246021270752,
-0.14893405139446259,
0.1272612363100052,
0.012313922867178917,
0.22506967186927795,
-0.04457536339759827,
-0.08763767778873444,
-0.18596786260604858,
-0.280423104763031,
0.10364237427711487,
0.2624562978744507,
0.03796811401844025,
-0.02384076826274395,
0.13794831931591034,
-0.21762365102767944,
0.07267096638679504,
0.5520889163017273,
0.4959200918674469,
-0.22852712869644165,
-0.06572668254375458,
0.021160989999771118,
0.020821329206228256,
0.12997226417064667,
0.1585116982460022,
-0.11120104789733887,
0.19656914472579956,
-0.4038280248641968,
0.047139931470155716,
0.1977158933877945,
0.08394196629524231,
0.1980421394109726,
0.05862422287464142,
0.0065465387888252735,
-0.14845918118953705,
0.5298153162002563,
0.2245994508266449,
-0.15603825449943542,
-0.07618790864944458,
0.49599236249923706,
-0.31994861364364624,
0.7623822093009949,
-0.11319435387849808,
0.614052951335907,
0.2812572717666626,
-0.3093530237674713,
0.39586594700813293,
0.07837022840976715,
0.7126440405845642,
-0.0990818440914154,
0.2383415251970291,
-0.1748022437095642,
-0.12976080179214478,
0.13259708881378174,
-0.18334564566612244,
0.3717232644557953,
-0.3628873825073242,
-0.37863689661026,
0.34615135192871094,
0.05880056321620941,
-0.1165204644203186,
0.09917206317186356,
0.1682925522327423,
0.14760246872901917,
-0.1932554543018341,
-0.16427432000637054,
0.09358473122119904,
0.12308994680643082,
0.34345442056655884,
-0.007854117080569267,
-0.03099898248910904,
-0.4329080581665039,
-0.17739374935626984,
-0.12102271616458893,
0.11789954453706741,
-0.06187263876199722,
0.4830719828605652,
0.10279454290866852,
-0.15362471342086792,
0.3304445147514343,
-0.48574328422546387,
0.45066243410110474,
-0.0365280844271183,
-0.14461082220077515,
0.02786291018128395,
0.06460634618997574,
-0.17278245091438293,
0.015483134426176548,
-0.24725721776485443,
0.25953927636146545,
-0.11148464679718018,
-0.27438825368881226,
0.129989892244339,
0.08946399390697479,
-0.34428006410598755,
0.051644161343574524,
0.3508386015892029,
-0.23134745657444,
-0.09209757298231125,
-0.0880647599697113,
0.10985944420099258,
0.12464286386966705,
-0.08334432542324066,
0.10545122623443604,
0.09531547129154205,
-0.04372940585017204,
0.48864150047302246,
0.026420833542943,
-0.3472288250923157,
-0.22439946234226227,
0.2679886519908905,
0.33001959323883057,
-0.017567694187164307,
0.2617092728614807,
-0.21279560029506683,
-0.322132408618927,
-0.08400598168373108,
-0.5679416060447693,
-0.22690320014953613,
-0.01061045378446579,
-0.06528133898973465,
0.10800426453351974,
-0.22138020396232605,
0.0654950961470604,
0.01341899111866951,
0.1939387172460556,
0.04285073280334473,
-0.3218673765659332,
-0.1680380403995514,
0.09906768798828125,
0.1305999606847763,
-0.03251064196228981,
0.1478329300880432,
-0.0076471418142318726,
0.07050541043281555,
-0.06118663400411606,
-0.18794438242912292,
-0.2624443471431732,
0.21434856951236725,
-0.14817018806934357,
-0.009950689971446991,
-0.3508014976978302,
-0.027760423719882965,
0.261823832988739,
-0.011296333745121956,
0.06566181778907776,
0.1084924265742302,
-0.1978408545255661,
-0.1798180639743805,
-0.011459517292678356,
0.13145963847637177,
0.06411301344633102,
0.17080160975456238,
-0.3131437301635742,
0.02164752408862114,
0.1238110214471817,
-0.1320168673992157,
0.08651238679885864,
0.17828333377838135,
-0.06173950433731079,
0.026039309799671173,
0.11361517012119293,
-0.07234374433755875,
0.26507312059402466,
0.356405645608902,
0.10694436728954315,
0.31416165828704834,
0.08078551292419434,
0.3546185791492462,
-0.17993582785129547,
0.11872217059135437,
0.37123870849609375,
-0.01434672623872757,
-0.18913103640079498,
0.22855868935585022,
0.08697914332151413,
-0.20667152106761932,
-0.20523713529109955,
0.03913458064198494,
-0.1381497085094452,
0.5096691846847534,
-0.20340697467327118,
-0.1416870653629303,
0.17453983426094055,
0.1806524097919464,
-0.13577434420585632,
0.055578120052814484,
0.40988287329673767,
0.017553534358739853,
0.22751310467720032,
0.39886000752449036,
0.6414452791213989,
0.05760069191455841,
0.31095314025878906,
0.17182299494743347,
0.33142417669296265,
0.544065535068512,
0.07087385654449463,
-0.5886974334716797,
-0.02643878385424614,
0.17250145971775055,
0.12854091823101044,
0.07617340981960297,
0.42602914571762085,
0.18182283639907837,
-0.13735949993133545,
0.14575998485088348,
-0.0007226690649986267,
-0.18548233807086945,
0.25053155422210693,
-0.0787622481584549,
0.5536108613014221,
-0.08980047702789307,
0.172328382730484,
-0.18316370248794556,
0.21064120531082153,
0.1932205855846405,
-0.15876556932926178,
-0.0006246804259717464,
-0.22309254109859467,
0.06487267464399338,
-0.06243047118186951,
0.0015389332547783852,
0.4362599551677704,
0.04552013427019119,
-0.26329305768013,
-0.11454637348651886,
0.17220383882522583,
-0.19361762702465057,
-0.39592334628105164,
0.021501574665308,
-0.43723630905151367,
0.13394732773303986,
-0.11147507280111313,
0.3427950441837311,
0.11631297320127487,
0.06815871596336365,
0.1440614014863968,
-0.10813573002815247,
-0.22307831048965454,
-0.2716769874095917,
0.2758486866950989,
0.4407409727573395,
0.40185222029685974,
-0.16976776719093323,
0.053797803819179535,
0.07463385909795761,
-0.12524229288101196,
-0.06307075917720795,
-0.13670337200164795,
-0.30346179008483887,
-0.07035721838474274,
0.16045603156089783,
0.13645809888839722,
-0.2550845146179199,
-0.3640289306640625,
-0.000843975692987442,
0.4340205192565918,
-0.09535250067710876,
-0.19906878471374512,
-0.18211664259433746,
0.18161776661872864,
-0.03117753565311432,
-0.060212887823581696,
-0.6458978056907654,
0.10765334218740463,
0.17626094818115234,
-0.3111002445220947,
0.08649361878633499,
0.15622512996196747,
0.05998341739177704,
-0.10081678628921509,
0.2696950137615204,
0.331211656332016,
0.33928969502449036,
0.005997262895107269,
-0.054433271288871765,
-0.22064068913459778,
0.2568538188934326,
-0.23269301652908325,
0.2532843351364136,
-0.11365832388401031,
0.41433608531951904,
-0.14204296469688416,
0.08048990368843079,
0.04179240018129349,
0.12893220782279968,
0.25818392634391785,
-0.1492053121328354,
-0.276449978351593,
-0.1550917774438858,
-0.032408975064754486,
-0.3881831467151642,
-0.01348104327917099,
-0.08445538580417633,
0.002357345074415207,
-0.5446872711181641,
0.10900575667619705,
-0.2633470892906189,
-0.21406406164169312,
0.16988015174865723,
-0.3694571852684021,
0.9051520228385925,
0.24940890073776245,
0.32790374755859375,
-0.17533421516418457,
0.06997817754745483,
-0.0456269197165966,
-0.30698564648628235,
-0.08461236208677292,
0.21839258074760437,
0.11247725784778595,
0.05133263021707535,
-0.08871262520551682,
-0.44749531149864197,
-0.10945489257574081,
0.7328310608863831,
0.013871517032384872,
-0.36447757482528687,
0.14604488015174866,
0.03350736200809479,
-0.2910647392272949,
0.12016628682613373,
-0.28736117482185364,
-0.013258501887321472,
0.015426427125930786,
0.21695047616958618,
-0.11316098272800446,
-0.4931493103504181,
0.43367087841033936,
-0.2741332948207855,
-0.08480600267648697,
-0.3300609588623047,
0.3259088397026062,
0.5856763124465942,
0.16075104475021362,
-0.42206573486328125,
0.01683451235294342,
0.1702301949262619,
-0.04799061268568039,
-0.23958823084831238,
0.16900864243507385,
0.15467405319213867,
0.06412522494792938,
-0.18468646705150604,
-0.21630316972732544,
0.008873147889971733,
0.039037078619003296,
-0.22239933907985687,
-0.18871131539344788
] |
https://github.com/huggingface/datasets/issues/7456
|
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
|
I think I just had no chance to meet with faiss-cpu.
It could be import problem?
_has_faiss gets its value at the beginning of datasets/search.
I tried to call object before import faiss, so _has_faiss took False. And never updated later.
|
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
| 41 |
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
I think I just had no chance to meet with faiss-cpu.
It could be import problem?
_has_faiss gets its value at the beginning of datasets/search.
I tried to call object before import faiss, so _has_faiss took False. And never updated later.
|
[
-0.16117000579833984,
-0.11760753393173218,
-0.15066224336624146,
0.08203524351119995,
-0.1286037713289261,
-0.00994054228067398,
0.10475793480873108,
0.1413806676864624,
0.5156817436218262,
0.4201788902282715,
-0.23171284794807434,
0.3851391077041626,
0.09162198752164841,
-0.031732842326164246,
-0.22691023349761963,
0.2530635595321655,
0.31324052810668945,
0.3141487240791321,
0.286990761756897,
-0.225828155875206,
-0.21031071245670319,
0.24549394845962524,
-0.11663298308849335,
-0.14979669451713562,
-0.061843808740377426,
0.20163683593273163,
-0.04081256687641144,
-0.060086242854595184,
-0.17773616313934326,
-0.4343525171279907,
0.3564590811729431,
-0.2465187907218933,
0.06784113496541977,
0.45280614495277405,
-0.00012001708091702312,
0.16983987390995026,
0.46698254346847534,
0.038603462278842926,
-0.20051944255828857,
-0.2968881130218506,
-0.34063124656677246,
-0.1492750197649002,
0.3670836389064789,
-0.11481065303087234,
0.007955286651849747,
-0.11012418568134308,
-0.11281844973564148,
-0.21513177454471588,
0.13531622290611267,
0.4694521725177765,
0.14951427280902863,
0.06196172535419464,
0.1800299882888794,
-0.21636570990085602,
0.5414345264434814,
-0.30696386098861694,
-0.22465455532073975,
-0.016008924692869186,
0.036910559982061386,
0.24787604808807373,
0.4191136360168457,
0.1929059773683548,
-0.08678627014160156,
-0.01986824721097946,
-0.36704665422439575,
0.07248660922050476,
-0.07346541434526443,
-0.3942570388317108,
-0.011618684977293015,
-0.037493087351322174,
0.10735979676246643,
-0.16118240356445312,
-0.22358283400535583,
0.1561070680618286,
0.10509961098432541,
-0.25884976983070374,
0.22590795159339905,
0.02065884694457054,
0.014161558821797371,
0.19833941757678986,
0.3465823531150818,
-0.14075376093387604,
-0.19422593712806702,
0.05597778782248497,
-0.28478899598121643,
0.49147096276283264,
-0.04927155748009682,
-0.11800331622362137,
0.11341769993305206,
-0.10482732951641083,
0.22461381554603577,
0.06444834917783737,
0.16802719235420227,
-0.10034651309251785,
-0.17825940251350403,
0.04722083359956741,
0.1361667960882187,
-0.08213513344526291,
-0.12494523078203201,
-0.039579398930072784,
-0.35669249296188354,
0.007569471374154091,
0.09197752922773361,
0.3693396747112274,
-0.4950583577156067,
0.12524934113025665,
0.00571085512638092,
-0.0023592920042574406,
0.2595343589782715,
0.07186460494995117,
-0.13065402209758759,
-0.014068752527236938,
0.07384522259235382,
-0.2511730492115021,
-0.41447457671165466,
-0.1172662153840065,
0.137697234749794,
-0.3650587499141693,
-0.46173542737960815,
0.08694619685411453,
-0.37541764974594116,
-0.07669366896152496,
0.010866579599678516,
0.3808978796005249,
-0.033448271453380585,
-0.3733902871608734,
0.1065153032541275,
0.23127561807632446,
-0.11577831953763962,
0.27290013432502747,
-0.18207122385501862,
0.2185625433921814,
0.15644453465938568,
0.28199055790901184,
0.3098966181278229,
-0.6035938858985901,
0.430266410112381,
-0.01865580677986145,
0.11926405131816864,
0.12065625190734863,
0.11778198182582855,
-0.27658987045288086,
0.09237615019083023,
0.5115554928779602,
0.11889557540416718,
0.06079360097646713,
-0.01675218716263771,
-0.30686694383621216,
-0.12403038889169693,
0.02150382101535797,
-0.4513663053512573,
-0.1714765429496765,
-0.2683683931827545,
0.1931690275669098,
-0.26483702659606934,
-0.1902206540107727,
-0.00963158905506134,
0.06139732152223587,
0.022929102182388306,
-0.031789038330316544,
-0.10731133073568344,
-0.10580423474311829,
-0.11228859424591064,
-0.20336408913135529,
0.19544769823551178,
-0.010690644383430481,
-0.2846740484237671,
-0.18304625153541565,
-0.2959628105163574,
0.21858294308185577,
-0.002251371741294861,
0.3062683939933777,
-0.039837151765823364,
0.16121360659599304,
-0.2587433457374573,
0.18084590137004852,
0.47567662596702576,
-0.38209670782089233,
-0.33405327796936035,
-0.0464184507727623,
0.20323805510997772,
-0.11482933163642883,
0.33721107244491577,
-0.3041093647480011,
0.13790956139564514,
0.21408343315124512,
0.40372195839881897,
0.09647197276353836,
0.04032605141401291,
-0.21423329412937164,
-0.31953945755958557,
-0.3014972507953644,
0.04426121711730957,
0.1507096290588379,
0.28164923191070557,
-0.1397862732410431,
0.2283763289451599,
-0.558803915977478,
-0.2248099148273468,
-0.027080070227384567,
-0.17033375799655914,
0.17325320839881897,
0.7504816651344299,
0.11588825285434723,
0.250286728143692,
-0.09420672804117203,
0.03429264575242996,
0.23494622111320496,
-0.16884760558605194,
0.3206605911254883,
-0.5654057264328003,
-0.07951882481575012,
-0.2047884464263916,
0.01621283032000065,
-0.11963531374931335,
-0.08547830581665039,
0.09035539627075195,
0.02688578888773918,
0.07011270523071289,
0.3450736999511719,
-0.149666428565979,
0.23788809776306152,
0.029455920681357384,
0.08601481467485428,
-0.2821899652481079,
0.4557609260082245,
-0.355103999376297,
-0.21232423186302185,
-0.26934367418289185,
0.0550079345703125,
0.11870615184307098,
-0.16724710166454315,
-0.06345903128385544,
-0.1393352746963501,
0.022707529366016388,
0.001660957932472229,
0.35844680666923523,
-0.031841471791267395,
0.15138156712055206,
-0.3605331778526306,
0.0007368139922618866,
-0.014245271682739258,
0.19100113213062286,
0.10995949059724808,
0.13783526420593262,
0.22354117035865784,
0.34959572553634644,
0.31639477610588074,
0.048732027411460876,
-0.25815367698669434,
0.2894139289855957,
0.15064361691474915,
-0.00478145107626915,
-0.3528922200202942,
-0.01283501461148262,
0.2490568608045578,
0.1571197658777237,
-0.07574699074029922,
0.10761070251464844,
0.1634841412305832,
0.24935084581375122,
0.1806226223707199,
0.059507012367248535,
-0.01909622550010681,
-0.18093451857566833,
0.04272516071796417,
0.2133590131998062,
-0.3315229117870331,
0.5042451024055481,
0.1952822357416153,
-0.10752677917480469,
0.002021320164203644,
-0.23246237635612488,
-0.15534016489982605,
0.22551575303077698,
0.15586592257022858,
0.16927507519721985,
0.021715018898248672,
0.40005555748939514,
0.001977999694645405,
-0.1599210500717163,
-0.396759033203125,
-0.18060946464538574,
0.015682226046919823,
-0.22388997673988342,
0.23846985399723053,
-0.3335368037223816,
0.0387190580368042,
-0.26496416330337524,
-0.32123979926109314,
-0.05915385112166405,
-0.1550196409225464,
-0.06616184115409851,
0.1655339002609253,
-0.04197154939174652,
0.09799930453300476,
0.08658251166343689,
0.16132646799087524,
0.12170617282390594,
-0.5659324526786804,
-0.12707310914993286,
0.07293909043073654,
-0.13817229866981506,
0.03119627758860588,
0.0463983528316021,
0.1443513184785843,
0.2281331866979599,
-0.22272621095180511,
-0.04931464046239853,
-0.03734709322452545,
-0.5407865047454834,
0.13256728649139404,
-0.17953747510910034,
0.3834962248802185,
-0.02238471806049347,
-0.22363264858722687,
-0.2287382334470749,
-0.2209000587463379,
0.08535301685333252,
0.03302214294672012,
-0.07387572526931763,
-0.16914428770542145,
-0.2024255096912384,
0.16350404918193817,
-0.07980343699455261,
-0.4645572602748871,
-0.273506760597229,
-0.29208099842071533,
-0.1883683055639267,
0.23808394372463226,
0.07035378366708755,
-0.051195427775382996,
0.4012899398803711,
0.12842698395252228,
0.26016679406166077,
0.1833799034357071,
-0.08417943865060806,
0.1034243106842041,
0.40126869082450867,
-0.2088790237903595,
-0.19478511810302734,
0.3140634596347809,
-0.19571863114833832,
0.1738995611667633,
0.26666849851608276,
-0.20691372454166412,
-0.25385159254074097,
-0.1654600203037262,
0.2149738371372223,
0.15121686458587646,
0.3295900523662567,
0.208226278424263,
0.06291403621435165,
-0.0629701241850853,
-0.07440649718046188,
-0.340837299823761,
0.037091124802827835,
0.24042591452598572,
0.13391061127185822,
-0.08302077651023865,
0.3498714864253998,
-0.14694276452064514,
0.6421234011650085,
0.0022957678884267807,
-0.12015606462955475,
0.4455321133136749,
0.1388605386018753,
0.3459651470184326,
-0.22012680768966675,
-0.25990140438079834,
-0.06418562680482864,
0.2821204662322998,
-0.11512740701436996,
0.11511081457138062,
-0.05819567292928696,
-0.2546572983264923,
-0.2041834443807602,
-0.015062844380736351,
-0.22018662095069885,
-0.04428558051586151,
-0.00493219681084156,
0.5682275295257568,
0.18974393606185913,
-0.02852044627070427,
0.019131436944007874,
-0.08276355266571045,
0.0331137590110302,
-0.07715123891830444,
0.36668384075164795,
-0.19770854711532593,
0.01454408559948206,
0.5677427053451538,
-0.5961407423019409,
-0.3954414427280426,
0.47168171405792236,
0.12705183029174805,
0.1797829270362854,
0.12959589064121246,
-0.09018629789352417,
0.16894309222698212,
0.047159794718027115,
0.3042554259300232,
-0.10313451290130615,
-0.5570278763771057,
0.25937291979789734,
-0.021157583221793175,
-0.4514586329460144,
-0.27979105710983276,
-0.40093061327934265,
0.17905350029468536,
0.21344764530658722,
0.4027971625328064,
-0.1314033567905426,
-0.031220823526382446,
0.11118880659341812,
0.23547682166099548,
-0.012499582022428513,
-0.12767396867275238,
-0.4390488564968109,
-0.5053246021270752,
-0.14893405139446259,
0.1272612363100052,
0.012313922867178917,
0.22506967186927795,
-0.04457536339759827,
-0.08763767778873444,
-0.18596786260604858,
-0.280423104763031,
0.10364237427711487,
0.2624562978744507,
0.03796811401844025,
-0.02384076826274395,
0.13794831931591034,
-0.21762365102767944,
0.07267096638679504,
0.5520889163017273,
0.4959200918674469,
-0.22852712869644165,
-0.06572668254375458,
0.021160989999771118,
0.020821329206228256,
0.12997226417064667,
0.1585116982460022,
-0.11120104789733887,
0.19656914472579956,
-0.4038280248641968,
0.047139931470155716,
0.1977158933877945,
0.08394196629524231,
0.1980421394109726,
0.05862422287464142,
0.0065465387888252735,
-0.14845918118953705,
0.5298153162002563,
0.2245994508266449,
-0.15603825449943542,
-0.07618790864944458,
0.49599236249923706,
-0.31994861364364624,
0.7623822093009949,
-0.11319435387849808,
0.614052951335907,
0.2812572717666626,
-0.3093530237674713,
0.39586594700813293,
0.07837022840976715,
0.7126440405845642,
-0.0990818440914154,
0.2383415251970291,
-0.1748022437095642,
-0.12976080179214478,
0.13259708881378174,
-0.18334564566612244,
0.3717232644557953,
-0.3628873825073242,
-0.37863689661026,
0.34615135192871094,
0.05880056321620941,
-0.1165204644203186,
0.09917206317186356,
0.1682925522327423,
0.14760246872901917,
-0.1932554543018341,
-0.16427432000637054,
0.09358473122119904,
0.12308994680643082,
0.34345442056655884,
-0.007854117080569267,
-0.03099898248910904,
-0.4329080581665039,
-0.17739374935626984,
-0.12102271616458893,
0.11789954453706741,
-0.06187263876199722,
0.4830719828605652,
0.10279454290866852,
-0.15362471342086792,
0.3304445147514343,
-0.48574328422546387,
0.45066243410110474,
-0.0365280844271183,
-0.14461082220077515,
0.02786291018128395,
0.06460634618997574,
-0.17278245091438293,
0.015483134426176548,
-0.24725721776485443,
0.25953927636146545,
-0.11148464679718018,
-0.27438825368881226,
0.129989892244339,
0.08946399390697479,
-0.34428006410598755,
0.051644161343574524,
0.3508386015892029,
-0.23134745657444,
-0.09209757298231125,
-0.0880647599697113,
0.10985944420099258,
0.12464286386966705,
-0.08334432542324066,
0.10545122623443604,
0.09531547129154205,
-0.04372940585017204,
0.48864150047302246,
0.026420833542943,
-0.3472288250923157,
-0.22439946234226227,
0.2679886519908905,
0.33001959323883057,
-0.017567694187164307,
0.2617092728614807,
-0.21279560029506683,
-0.322132408618927,
-0.08400598168373108,
-0.5679416060447693,
-0.22690320014953613,
-0.01061045378446579,
-0.06528133898973465,
0.10800426453351974,
-0.22138020396232605,
0.0654950961470604,
0.01341899111866951,
0.1939387172460556,
0.04285073280334473,
-0.3218673765659332,
-0.1680380403995514,
0.09906768798828125,
0.1305999606847763,
-0.03251064196228981,
0.1478329300880432,
-0.0076471418142318726,
0.07050541043281555,
-0.06118663400411606,
-0.18794438242912292,
-0.2624443471431732,
0.21434856951236725,
-0.14817018806934357,
-0.009950689971446991,
-0.3508014976978302,
-0.027760423719882965,
0.261823832988739,
-0.011296333745121956,
0.06566181778907776,
0.1084924265742302,
-0.1978408545255661,
-0.1798180639743805,
-0.011459517292678356,
0.13145963847637177,
0.06411301344633102,
0.17080160975456238,
-0.3131437301635742,
0.02164752408862114,
0.1238110214471817,
-0.1320168673992157,
0.08651238679885864,
0.17828333377838135,
-0.06173950433731079,
0.026039309799671173,
0.11361517012119293,
-0.07234374433755875,
0.26507312059402466,
0.356405645608902,
0.10694436728954315,
0.31416165828704834,
0.08078551292419434,
0.3546185791492462,
-0.17993582785129547,
0.11872217059135437,
0.37123870849609375,
-0.01434672623872757,
-0.18913103640079498,
0.22855868935585022,
0.08697914332151413,
-0.20667152106761932,
-0.20523713529109955,
0.03913458064198494,
-0.1381497085094452,
0.5096691846847534,
-0.20340697467327118,
-0.1416870653629303,
0.17453983426094055,
0.1806524097919464,
-0.13577434420585632,
0.055578120052814484,
0.40988287329673767,
0.017553534358739853,
0.22751310467720032,
0.39886000752449036,
0.6414452791213989,
0.05760069191455841,
0.31095314025878906,
0.17182299494743347,
0.33142417669296265,
0.544065535068512,
0.07087385654449463,
-0.5886974334716797,
-0.02643878385424614,
0.17250145971775055,
0.12854091823101044,
0.07617340981960297,
0.42602914571762085,
0.18182283639907837,
-0.13735949993133545,
0.14575998485088348,
-0.0007226690649986267,
-0.18548233807086945,
0.25053155422210693,
-0.0787622481584549,
0.5536108613014221,
-0.08980047702789307,
0.172328382730484,
-0.18316370248794556,
0.21064120531082153,
0.1932205855846405,
-0.15876556932926178,
-0.0006246804259717464,
-0.22309254109859467,
0.06487267464399338,
-0.06243047118186951,
0.0015389332547783852,
0.4362599551677704,
0.04552013427019119,
-0.26329305768013,
-0.11454637348651886,
0.17220383882522583,
-0.19361762702465057,
-0.39592334628105164,
0.021501574665308,
-0.43723630905151367,
0.13394732773303986,
-0.11147507280111313,
0.3427950441837311,
0.11631297320127487,
0.06815871596336365,
0.1440614014863968,
-0.10813573002815247,
-0.22307831048965454,
-0.2716769874095917,
0.2758486866950989,
0.4407409727573395,
0.40185222029685974,
-0.16976776719093323,
0.053797803819179535,
0.07463385909795761,
-0.12524229288101196,
-0.06307075917720795,
-0.13670337200164795,
-0.30346179008483887,
-0.07035721838474274,
0.16045603156089783,
0.13645809888839722,
-0.2550845146179199,
-0.3640289306640625,
-0.000843975692987442,
0.4340205192565918,
-0.09535250067710876,
-0.19906878471374512,
-0.18211664259433746,
0.18161776661872864,
-0.03117753565311432,
-0.060212887823581696,
-0.6458978056907654,
0.10765334218740463,
0.17626094818115234,
-0.3111002445220947,
0.08649361878633499,
0.15622512996196747,
0.05998341739177704,
-0.10081678628921509,
0.2696950137615204,
0.331211656332016,
0.33928969502449036,
0.005997262895107269,
-0.054433271288871765,
-0.22064068913459778,
0.2568538188934326,
-0.23269301652908325,
0.2532843351364136,
-0.11365832388401031,
0.41433608531951904,
-0.14204296469688416,
0.08048990368843079,
0.04179240018129349,
0.12893220782279968,
0.25818392634391785,
-0.1492053121328354,
-0.276449978351593,
-0.1550917774438858,
-0.032408975064754486,
-0.3881831467151642,
-0.01348104327917099,
-0.08445538580417633,
0.002357345074415207,
-0.5446872711181641,
0.10900575667619705,
-0.2633470892906189,
-0.21406406164169312,
0.16988015174865723,
-0.3694571852684021,
0.9051520228385925,
0.24940890073776245,
0.32790374755859375,
-0.17533421516418457,
0.06997817754745483,
-0.0456269197165966,
-0.30698564648628235,
-0.08461236208677292,
0.21839258074760437,
0.11247725784778595,
0.05133263021707535,
-0.08871262520551682,
-0.44749531149864197,
-0.10945489257574081,
0.7328310608863831,
0.013871517032384872,
-0.36447757482528687,
0.14604488015174866,
0.03350736200809479,
-0.2910647392272949,
0.12016628682613373,
-0.28736117482185364,
-0.013258501887321472,
0.015426427125930786,
0.21695047616958618,
-0.11316098272800446,
-0.4931493103504181,
0.43367087841033936,
-0.2741332948207855,
-0.08480600267648697,
-0.3300609588623047,
0.3259088397026062,
0.5856763124465942,
0.16075104475021362,
-0.42206573486328125,
0.01683451235294342,
0.1702301949262619,
-0.04799061268568039,
-0.23958823084831238,
0.16900864243507385,
0.15467405319213867,
0.06412522494792938,
-0.18468646705150604,
-0.21630316972732544,
0.008873147889971733,
0.039037078619003296,
-0.22239933907985687,
-0.18871131539344788
] |
https://github.com/huggingface/datasets/issues/7456
|
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
|
Yes you can't meet the requirements because faiss-cpu runs only on
python3.10 and lower but the default version for colab is python3.11 which
results in pip not being able to find wheels for faiss-cpu with python3.11.
On Mon, 17 Mar, 2025, 3:56 pm MapleBloom, ***@***.***> wrote:
> I think I just had no chance to meet with faiss-cpu.
> It could be import problem?
> _has_faiss gets its value at the beginning of datasets/search.
> I tried to call object before import faiss, so _has_faiss took False. And
> never updated later.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2728975672>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AVUSZMBVD7LEDDUGALOTVN32U2PMBAVCNFSM6AAAAABZDBA426VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRYHE3TKNRXGI>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
> [image: MapleBloom]*MapleBloom* left a comment (huggingface/datasets#7456)
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2728975672>
>
> I think I just had no chance to meet with faiss-cpu.
> It could be import problem?
> _has_faiss gets its value at the beginning of datasets/search.
> I tried to call object before import faiss, so _has_faiss took False. And
> never updated later.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2728975672>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AVUSZMBVD7LEDDUGALOTVN32U2PMBAVCNFSM6AAAAABZDBA426VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRYHE3TKNRXGI>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
| 215 |
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
Yes you can't meet the requirements because faiss-cpu runs only on
python3.10 and lower but the default version for colab is python3.11 which
results in pip not being able to find wheels for faiss-cpu with python3.11.
On Mon, 17 Mar, 2025, 3:56 pm MapleBloom, ***@***.***> wrote:
> I think I just had no chance to meet with faiss-cpu.
> It could be import problem?
> _has_faiss gets its value at the beginning of datasets/search.
> I tried to call object before import faiss, so _has_faiss took False. And
> never updated later.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2728975672>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AVUSZMBVD7LEDDUGALOTVN32U2PMBAVCNFSM6AAAAABZDBA426VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRYHE3TKNRXGI>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
> [image: MapleBloom]*MapleBloom* left a comment (huggingface/datasets#7456)
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2728975672>
>
> I think I just had no chance to meet with faiss-cpu.
> It could be import problem?
> _has_faiss gets its value at the beginning of datasets/search.
> I tried to call object before import faiss, so _has_faiss took False. And
> never updated later.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2728975672>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AVUSZMBVD7LEDDUGALOTVN32U2PMBAVCNFSM6AAAAABZDBA426VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRYHE3TKNRXGI>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
[
-0.16117000579833984,
-0.11760753393173218,
-0.15066224336624146,
0.08203524351119995,
-0.1286037713289261,
-0.00994054228067398,
0.10475793480873108,
0.1413806676864624,
0.5156817436218262,
0.4201788902282715,
-0.23171284794807434,
0.3851391077041626,
0.09162198752164841,
-0.031732842326164246,
-0.22691023349761963,
0.2530635595321655,
0.31324052810668945,
0.3141487240791321,
0.286990761756897,
-0.225828155875206,
-0.21031071245670319,
0.24549394845962524,
-0.11663298308849335,
-0.14979669451713562,
-0.061843808740377426,
0.20163683593273163,
-0.04081256687641144,
-0.060086242854595184,
-0.17773616313934326,
-0.4343525171279907,
0.3564590811729431,
-0.2465187907218933,
0.06784113496541977,
0.45280614495277405,
-0.00012001708091702312,
0.16983987390995026,
0.46698254346847534,
0.038603462278842926,
-0.20051944255828857,
-0.2968881130218506,
-0.34063124656677246,
-0.1492750197649002,
0.3670836389064789,
-0.11481065303087234,
0.007955286651849747,
-0.11012418568134308,
-0.11281844973564148,
-0.21513177454471588,
0.13531622290611267,
0.4694521725177765,
0.14951427280902863,
0.06196172535419464,
0.1800299882888794,
-0.21636570990085602,
0.5414345264434814,
-0.30696386098861694,
-0.22465455532073975,
-0.016008924692869186,
0.036910559982061386,
0.24787604808807373,
0.4191136360168457,
0.1929059773683548,
-0.08678627014160156,
-0.01986824721097946,
-0.36704665422439575,
0.07248660922050476,
-0.07346541434526443,
-0.3942570388317108,
-0.011618684977293015,
-0.037493087351322174,
0.10735979676246643,
-0.16118240356445312,
-0.22358283400535583,
0.1561070680618286,
0.10509961098432541,
-0.25884976983070374,
0.22590795159339905,
0.02065884694457054,
0.014161558821797371,
0.19833941757678986,
0.3465823531150818,
-0.14075376093387604,
-0.19422593712806702,
0.05597778782248497,
-0.28478899598121643,
0.49147096276283264,
-0.04927155748009682,
-0.11800331622362137,
0.11341769993305206,
-0.10482732951641083,
0.22461381554603577,
0.06444834917783737,
0.16802719235420227,
-0.10034651309251785,
-0.17825940251350403,
0.04722083359956741,
0.1361667960882187,
-0.08213513344526291,
-0.12494523078203201,
-0.039579398930072784,
-0.35669249296188354,
0.007569471374154091,
0.09197752922773361,
0.3693396747112274,
-0.4950583577156067,
0.12524934113025665,
0.00571085512638092,
-0.0023592920042574406,
0.2595343589782715,
0.07186460494995117,
-0.13065402209758759,
-0.014068752527236938,
0.07384522259235382,
-0.2511730492115021,
-0.41447457671165466,
-0.1172662153840065,
0.137697234749794,
-0.3650587499141693,
-0.46173542737960815,
0.08694619685411453,
-0.37541764974594116,
-0.07669366896152496,
0.010866579599678516,
0.3808978796005249,
-0.033448271453380585,
-0.3733902871608734,
0.1065153032541275,
0.23127561807632446,
-0.11577831953763962,
0.27290013432502747,
-0.18207122385501862,
0.2185625433921814,
0.15644453465938568,
0.28199055790901184,
0.3098966181278229,
-0.6035938858985901,
0.430266410112381,
-0.01865580677986145,
0.11926405131816864,
0.12065625190734863,
0.11778198182582855,
-0.27658987045288086,
0.09237615019083023,
0.5115554928779602,
0.11889557540416718,
0.06079360097646713,
-0.01675218716263771,
-0.30686694383621216,
-0.12403038889169693,
0.02150382101535797,
-0.4513663053512573,
-0.1714765429496765,
-0.2683683931827545,
0.1931690275669098,
-0.26483702659606934,
-0.1902206540107727,
-0.00963158905506134,
0.06139732152223587,
0.022929102182388306,
-0.031789038330316544,
-0.10731133073568344,
-0.10580423474311829,
-0.11228859424591064,
-0.20336408913135529,
0.19544769823551178,
-0.010690644383430481,
-0.2846740484237671,
-0.18304625153541565,
-0.2959628105163574,
0.21858294308185577,
-0.002251371741294861,
0.3062683939933777,
-0.039837151765823364,
0.16121360659599304,
-0.2587433457374573,
0.18084590137004852,
0.47567662596702576,
-0.38209670782089233,
-0.33405327796936035,
-0.0464184507727623,
0.20323805510997772,
-0.11482933163642883,
0.33721107244491577,
-0.3041093647480011,
0.13790956139564514,
0.21408343315124512,
0.40372195839881897,
0.09647197276353836,
0.04032605141401291,
-0.21423329412937164,
-0.31953945755958557,
-0.3014972507953644,
0.04426121711730957,
0.1507096290588379,
0.28164923191070557,
-0.1397862732410431,
0.2283763289451599,
-0.558803915977478,
-0.2248099148273468,
-0.027080070227384567,
-0.17033375799655914,
0.17325320839881897,
0.7504816651344299,
0.11588825285434723,
0.250286728143692,
-0.09420672804117203,
0.03429264575242996,
0.23494622111320496,
-0.16884760558605194,
0.3206605911254883,
-0.5654057264328003,
-0.07951882481575012,
-0.2047884464263916,
0.01621283032000065,
-0.11963531374931335,
-0.08547830581665039,
0.09035539627075195,
0.02688578888773918,
0.07011270523071289,
0.3450736999511719,
-0.149666428565979,
0.23788809776306152,
0.029455920681357384,
0.08601481467485428,
-0.2821899652481079,
0.4557609260082245,
-0.355103999376297,
-0.21232423186302185,
-0.26934367418289185,
0.0550079345703125,
0.11870615184307098,
-0.16724710166454315,
-0.06345903128385544,
-0.1393352746963501,
0.022707529366016388,
0.001660957932472229,
0.35844680666923523,
-0.031841471791267395,
0.15138156712055206,
-0.3605331778526306,
0.0007368139922618866,
-0.014245271682739258,
0.19100113213062286,
0.10995949059724808,
0.13783526420593262,
0.22354117035865784,
0.34959572553634644,
0.31639477610588074,
0.048732027411460876,
-0.25815367698669434,
0.2894139289855957,
0.15064361691474915,
-0.00478145107626915,
-0.3528922200202942,
-0.01283501461148262,
0.2490568608045578,
0.1571197658777237,
-0.07574699074029922,
0.10761070251464844,
0.1634841412305832,
0.24935084581375122,
0.1806226223707199,
0.059507012367248535,
-0.01909622550010681,
-0.18093451857566833,
0.04272516071796417,
0.2133590131998062,
-0.3315229117870331,
0.5042451024055481,
0.1952822357416153,
-0.10752677917480469,
0.002021320164203644,
-0.23246237635612488,
-0.15534016489982605,
0.22551575303077698,
0.15586592257022858,
0.16927507519721985,
0.021715018898248672,
0.40005555748939514,
0.001977999694645405,
-0.1599210500717163,
-0.396759033203125,
-0.18060946464538574,
0.015682226046919823,
-0.22388997673988342,
0.23846985399723053,
-0.3335368037223816,
0.0387190580368042,
-0.26496416330337524,
-0.32123979926109314,
-0.05915385112166405,
-0.1550196409225464,
-0.06616184115409851,
0.1655339002609253,
-0.04197154939174652,
0.09799930453300476,
0.08658251166343689,
0.16132646799087524,
0.12170617282390594,
-0.5659324526786804,
-0.12707310914993286,
0.07293909043073654,
-0.13817229866981506,
0.03119627758860588,
0.0463983528316021,
0.1443513184785843,
0.2281331866979599,
-0.22272621095180511,
-0.04931464046239853,
-0.03734709322452545,
-0.5407865047454834,
0.13256728649139404,
-0.17953747510910034,
0.3834962248802185,
-0.02238471806049347,
-0.22363264858722687,
-0.2287382334470749,
-0.2209000587463379,
0.08535301685333252,
0.03302214294672012,
-0.07387572526931763,
-0.16914428770542145,
-0.2024255096912384,
0.16350404918193817,
-0.07980343699455261,
-0.4645572602748871,
-0.273506760597229,
-0.29208099842071533,
-0.1883683055639267,
0.23808394372463226,
0.07035378366708755,
-0.051195427775382996,
0.4012899398803711,
0.12842698395252228,
0.26016679406166077,
0.1833799034357071,
-0.08417943865060806,
0.1034243106842041,
0.40126869082450867,
-0.2088790237903595,
-0.19478511810302734,
0.3140634596347809,
-0.19571863114833832,
0.1738995611667633,
0.26666849851608276,
-0.20691372454166412,
-0.25385159254074097,
-0.1654600203037262,
0.2149738371372223,
0.15121686458587646,
0.3295900523662567,
0.208226278424263,
0.06291403621435165,
-0.0629701241850853,
-0.07440649718046188,
-0.340837299823761,
0.037091124802827835,
0.24042591452598572,
0.13391061127185822,
-0.08302077651023865,
0.3498714864253998,
-0.14694276452064514,
0.6421234011650085,
0.0022957678884267807,
-0.12015606462955475,
0.4455321133136749,
0.1388605386018753,
0.3459651470184326,
-0.22012680768966675,
-0.25990140438079834,
-0.06418562680482864,
0.2821204662322998,
-0.11512740701436996,
0.11511081457138062,
-0.05819567292928696,
-0.2546572983264923,
-0.2041834443807602,
-0.015062844380736351,
-0.22018662095069885,
-0.04428558051586151,
-0.00493219681084156,
0.5682275295257568,
0.18974393606185913,
-0.02852044627070427,
0.019131436944007874,
-0.08276355266571045,
0.0331137590110302,
-0.07715123891830444,
0.36668384075164795,
-0.19770854711532593,
0.01454408559948206,
0.5677427053451538,
-0.5961407423019409,
-0.3954414427280426,
0.47168171405792236,
0.12705183029174805,
0.1797829270362854,
0.12959589064121246,
-0.09018629789352417,
0.16894309222698212,
0.047159794718027115,
0.3042554259300232,
-0.10313451290130615,
-0.5570278763771057,
0.25937291979789734,
-0.021157583221793175,
-0.4514586329460144,
-0.27979105710983276,
-0.40093061327934265,
0.17905350029468536,
0.21344764530658722,
0.4027971625328064,
-0.1314033567905426,
-0.031220823526382446,
0.11118880659341812,
0.23547682166099548,
-0.012499582022428513,
-0.12767396867275238,
-0.4390488564968109,
-0.5053246021270752,
-0.14893405139446259,
0.1272612363100052,
0.012313922867178917,
0.22506967186927795,
-0.04457536339759827,
-0.08763767778873444,
-0.18596786260604858,
-0.280423104763031,
0.10364237427711487,
0.2624562978744507,
0.03796811401844025,
-0.02384076826274395,
0.13794831931591034,
-0.21762365102767944,
0.07267096638679504,
0.5520889163017273,
0.4959200918674469,
-0.22852712869644165,
-0.06572668254375458,
0.021160989999771118,
0.020821329206228256,
0.12997226417064667,
0.1585116982460022,
-0.11120104789733887,
0.19656914472579956,
-0.4038280248641968,
0.047139931470155716,
0.1977158933877945,
0.08394196629524231,
0.1980421394109726,
0.05862422287464142,
0.0065465387888252735,
-0.14845918118953705,
0.5298153162002563,
0.2245994508266449,
-0.15603825449943542,
-0.07618790864944458,
0.49599236249923706,
-0.31994861364364624,
0.7623822093009949,
-0.11319435387849808,
0.614052951335907,
0.2812572717666626,
-0.3093530237674713,
0.39586594700813293,
0.07837022840976715,
0.7126440405845642,
-0.0990818440914154,
0.2383415251970291,
-0.1748022437095642,
-0.12976080179214478,
0.13259708881378174,
-0.18334564566612244,
0.3717232644557953,
-0.3628873825073242,
-0.37863689661026,
0.34615135192871094,
0.05880056321620941,
-0.1165204644203186,
0.09917206317186356,
0.1682925522327423,
0.14760246872901917,
-0.1932554543018341,
-0.16427432000637054,
0.09358473122119904,
0.12308994680643082,
0.34345442056655884,
-0.007854117080569267,
-0.03099898248910904,
-0.4329080581665039,
-0.17739374935626984,
-0.12102271616458893,
0.11789954453706741,
-0.06187263876199722,
0.4830719828605652,
0.10279454290866852,
-0.15362471342086792,
0.3304445147514343,
-0.48574328422546387,
0.45066243410110474,
-0.0365280844271183,
-0.14461082220077515,
0.02786291018128395,
0.06460634618997574,
-0.17278245091438293,
0.015483134426176548,
-0.24725721776485443,
0.25953927636146545,
-0.11148464679718018,
-0.27438825368881226,
0.129989892244339,
0.08946399390697479,
-0.34428006410598755,
0.051644161343574524,
0.3508386015892029,
-0.23134745657444,
-0.09209757298231125,
-0.0880647599697113,
0.10985944420099258,
0.12464286386966705,
-0.08334432542324066,
0.10545122623443604,
0.09531547129154205,
-0.04372940585017204,
0.48864150047302246,
0.026420833542943,
-0.3472288250923157,
-0.22439946234226227,
0.2679886519908905,
0.33001959323883057,
-0.017567694187164307,
0.2617092728614807,
-0.21279560029506683,
-0.322132408618927,
-0.08400598168373108,
-0.5679416060447693,
-0.22690320014953613,
-0.01061045378446579,
-0.06528133898973465,
0.10800426453351974,
-0.22138020396232605,
0.0654950961470604,
0.01341899111866951,
0.1939387172460556,
0.04285073280334473,
-0.3218673765659332,
-0.1680380403995514,
0.09906768798828125,
0.1305999606847763,
-0.03251064196228981,
0.1478329300880432,
-0.0076471418142318726,
0.07050541043281555,
-0.06118663400411606,
-0.18794438242912292,
-0.2624443471431732,
0.21434856951236725,
-0.14817018806934357,
-0.009950689971446991,
-0.3508014976978302,
-0.027760423719882965,
0.261823832988739,
-0.011296333745121956,
0.06566181778907776,
0.1084924265742302,
-0.1978408545255661,
-0.1798180639743805,
-0.011459517292678356,
0.13145963847637177,
0.06411301344633102,
0.17080160975456238,
-0.3131437301635742,
0.02164752408862114,
0.1238110214471817,
-0.1320168673992157,
0.08651238679885864,
0.17828333377838135,
-0.06173950433731079,
0.026039309799671173,
0.11361517012119293,
-0.07234374433755875,
0.26507312059402466,
0.356405645608902,
0.10694436728954315,
0.31416165828704834,
0.08078551292419434,
0.3546185791492462,
-0.17993582785129547,
0.11872217059135437,
0.37123870849609375,
-0.01434672623872757,
-0.18913103640079498,
0.22855868935585022,
0.08697914332151413,
-0.20667152106761932,
-0.20523713529109955,
0.03913458064198494,
-0.1381497085094452,
0.5096691846847534,
-0.20340697467327118,
-0.1416870653629303,
0.17453983426094055,
0.1806524097919464,
-0.13577434420585632,
0.055578120052814484,
0.40988287329673767,
0.017553534358739853,
0.22751310467720032,
0.39886000752449036,
0.6414452791213989,
0.05760069191455841,
0.31095314025878906,
0.17182299494743347,
0.33142417669296265,
0.544065535068512,
0.07087385654449463,
-0.5886974334716797,
-0.02643878385424614,
0.17250145971775055,
0.12854091823101044,
0.07617340981960297,
0.42602914571762085,
0.18182283639907837,
-0.13735949993133545,
0.14575998485088348,
-0.0007226690649986267,
-0.18548233807086945,
0.25053155422210693,
-0.0787622481584549,
0.5536108613014221,
-0.08980047702789307,
0.172328382730484,
-0.18316370248794556,
0.21064120531082153,
0.1932205855846405,
-0.15876556932926178,
-0.0006246804259717464,
-0.22309254109859467,
0.06487267464399338,
-0.06243047118186951,
0.0015389332547783852,
0.4362599551677704,
0.04552013427019119,
-0.26329305768013,
-0.11454637348651886,
0.17220383882522583,
-0.19361762702465057,
-0.39592334628105164,
0.021501574665308,
-0.43723630905151367,
0.13394732773303986,
-0.11147507280111313,
0.3427950441837311,
0.11631297320127487,
0.06815871596336365,
0.1440614014863968,
-0.10813573002815247,
-0.22307831048965454,
-0.2716769874095917,
0.2758486866950989,
0.4407409727573395,
0.40185222029685974,
-0.16976776719093323,
0.053797803819179535,
0.07463385909795761,
-0.12524229288101196,
-0.06307075917720795,
-0.13670337200164795,
-0.30346179008483887,
-0.07035721838474274,
0.16045603156089783,
0.13645809888839722,
-0.2550845146179199,
-0.3640289306640625,
-0.000843975692987442,
0.4340205192565918,
-0.09535250067710876,
-0.19906878471374512,
-0.18211664259433746,
0.18161776661872864,
-0.03117753565311432,
-0.060212887823581696,
-0.6458978056907654,
0.10765334218740463,
0.17626094818115234,
-0.3111002445220947,
0.08649361878633499,
0.15622512996196747,
0.05998341739177704,
-0.10081678628921509,
0.2696950137615204,
0.331211656332016,
0.33928969502449036,
0.005997262895107269,
-0.054433271288871765,
-0.22064068913459778,
0.2568538188934326,
-0.23269301652908325,
0.2532843351364136,
-0.11365832388401031,
0.41433608531951904,
-0.14204296469688416,
0.08048990368843079,
0.04179240018129349,
0.12893220782279968,
0.25818392634391785,
-0.1492053121328354,
-0.276449978351593,
-0.1550917774438858,
-0.032408975064754486,
-0.3881831467151642,
-0.01348104327917099,
-0.08445538580417633,
0.002357345074415207,
-0.5446872711181641,
0.10900575667619705,
-0.2633470892906189,
-0.21406406164169312,
0.16988015174865723,
-0.3694571852684021,
0.9051520228385925,
0.24940890073776245,
0.32790374755859375,
-0.17533421516418457,
0.06997817754745483,
-0.0456269197165966,
-0.30698564648628235,
-0.08461236208677292,
0.21839258074760437,
0.11247725784778595,
0.05133263021707535,
-0.08871262520551682,
-0.44749531149864197,
-0.10945489257574081,
0.7328310608863831,
0.013871517032384872,
-0.36447757482528687,
0.14604488015174866,
0.03350736200809479,
-0.2910647392272949,
0.12016628682613373,
-0.28736117482185364,
-0.013258501887321472,
0.015426427125930786,
0.21695047616958618,
-0.11316098272800446,
-0.4931493103504181,
0.43367087841033936,
-0.2741332948207855,
-0.08480600267648697,
-0.3300609588623047,
0.3259088397026062,
0.5856763124465942,
0.16075104475021362,
-0.42206573486328125,
0.01683451235294342,
0.1702301949262619,
-0.04799061268568039,
-0.23958823084831238,
0.16900864243507385,
0.15467405319213867,
0.06412522494792938,
-0.18468646705150604,
-0.21630316972732544,
0.008873147889971733,
0.039037078619003296,
-0.22239933907985687,
-0.18871131539344788
] |
https://github.com/huggingface/datasets/issues/7456
|
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
|
> you can't meet the requirements
It is not the case (or I didn't reach this point) because the same code in notebook
```importlib.util.find_spec("faiss")```
finds faiss. I've mention it.
I think the problem is in the very moment when _has_faiss takes its value and never try again.
(or it couldn't find the path that was easily found when started from my code)
|
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
| 62 |
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
> you can't meet the requirements
It is not the case (or I didn't reach this point) because the same code in notebook
```importlib.util.find_spec("faiss")```
finds faiss. I've mention it.
I think the problem is in the very moment when _has_faiss takes its value and never try again.
(or it couldn't find the path that was easily found when started from my code)
|
[
-0.16117000579833984,
-0.11760753393173218,
-0.15066224336624146,
0.08203524351119995,
-0.1286037713289261,
-0.00994054228067398,
0.10475793480873108,
0.1413806676864624,
0.5156817436218262,
0.4201788902282715,
-0.23171284794807434,
0.3851391077041626,
0.09162198752164841,
-0.031732842326164246,
-0.22691023349761963,
0.2530635595321655,
0.31324052810668945,
0.3141487240791321,
0.286990761756897,
-0.225828155875206,
-0.21031071245670319,
0.24549394845962524,
-0.11663298308849335,
-0.14979669451713562,
-0.061843808740377426,
0.20163683593273163,
-0.04081256687641144,
-0.060086242854595184,
-0.17773616313934326,
-0.4343525171279907,
0.3564590811729431,
-0.2465187907218933,
0.06784113496541977,
0.45280614495277405,
-0.00012001708091702312,
0.16983987390995026,
0.46698254346847534,
0.038603462278842926,
-0.20051944255828857,
-0.2968881130218506,
-0.34063124656677246,
-0.1492750197649002,
0.3670836389064789,
-0.11481065303087234,
0.007955286651849747,
-0.11012418568134308,
-0.11281844973564148,
-0.21513177454471588,
0.13531622290611267,
0.4694521725177765,
0.14951427280902863,
0.06196172535419464,
0.1800299882888794,
-0.21636570990085602,
0.5414345264434814,
-0.30696386098861694,
-0.22465455532073975,
-0.016008924692869186,
0.036910559982061386,
0.24787604808807373,
0.4191136360168457,
0.1929059773683548,
-0.08678627014160156,
-0.01986824721097946,
-0.36704665422439575,
0.07248660922050476,
-0.07346541434526443,
-0.3942570388317108,
-0.011618684977293015,
-0.037493087351322174,
0.10735979676246643,
-0.16118240356445312,
-0.22358283400535583,
0.1561070680618286,
0.10509961098432541,
-0.25884976983070374,
0.22590795159339905,
0.02065884694457054,
0.014161558821797371,
0.19833941757678986,
0.3465823531150818,
-0.14075376093387604,
-0.19422593712806702,
0.05597778782248497,
-0.28478899598121643,
0.49147096276283264,
-0.04927155748009682,
-0.11800331622362137,
0.11341769993305206,
-0.10482732951641083,
0.22461381554603577,
0.06444834917783737,
0.16802719235420227,
-0.10034651309251785,
-0.17825940251350403,
0.04722083359956741,
0.1361667960882187,
-0.08213513344526291,
-0.12494523078203201,
-0.039579398930072784,
-0.35669249296188354,
0.007569471374154091,
0.09197752922773361,
0.3693396747112274,
-0.4950583577156067,
0.12524934113025665,
0.00571085512638092,
-0.0023592920042574406,
0.2595343589782715,
0.07186460494995117,
-0.13065402209758759,
-0.014068752527236938,
0.07384522259235382,
-0.2511730492115021,
-0.41447457671165466,
-0.1172662153840065,
0.137697234749794,
-0.3650587499141693,
-0.46173542737960815,
0.08694619685411453,
-0.37541764974594116,
-0.07669366896152496,
0.010866579599678516,
0.3808978796005249,
-0.033448271453380585,
-0.3733902871608734,
0.1065153032541275,
0.23127561807632446,
-0.11577831953763962,
0.27290013432502747,
-0.18207122385501862,
0.2185625433921814,
0.15644453465938568,
0.28199055790901184,
0.3098966181278229,
-0.6035938858985901,
0.430266410112381,
-0.01865580677986145,
0.11926405131816864,
0.12065625190734863,
0.11778198182582855,
-0.27658987045288086,
0.09237615019083023,
0.5115554928779602,
0.11889557540416718,
0.06079360097646713,
-0.01675218716263771,
-0.30686694383621216,
-0.12403038889169693,
0.02150382101535797,
-0.4513663053512573,
-0.1714765429496765,
-0.2683683931827545,
0.1931690275669098,
-0.26483702659606934,
-0.1902206540107727,
-0.00963158905506134,
0.06139732152223587,
0.022929102182388306,
-0.031789038330316544,
-0.10731133073568344,
-0.10580423474311829,
-0.11228859424591064,
-0.20336408913135529,
0.19544769823551178,
-0.010690644383430481,
-0.2846740484237671,
-0.18304625153541565,
-0.2959628105163574,
0.21858294308185577,
-0.002251371741294861,
0.3062683939933777,
-0.039837151765823364,
0.16121360659599304,
-0.2587433457374573,
0.18084590137004852,
0.47567662596702576,
-0.38209670782089233,
-0.33405327796936035,
-0.0464184507727623,
0.20323805510997772,
-0.11482933163642883,
0.33721107244491577,
-0.3041093647480011,
0.13790956139564514,
0.21408343315124512,
0.40372195839881897,
0.09647197276353836,
0.04032605141401291,
-0.21423329412937164,
-0.31953945755958557,
-0.3014972507953644,
0.04426121711730957,
0.1507096290588379,
0.28164923191070557,
-0.1397862732410431,
0.2283763289451599,
-0.558803915977478,
-0.2248099148273468,
-0.027080070227384567,
-0.17033375799655914,
0.17325320839881897,
0.7504816651344299,
0.11588825285434723,
0.250286728143692,
-0.09420672804117203,
0.03429264575242996,
0.23494622111320496,
-0.16884760558605194,
0.3206605911254883,
-0.5654057264328003,
-0.07951882481575012,
-0.2047884464263916,
0.01621283032000065,
-0.11963531374931335,
-0.08547830581665039,
0.09035539627075195,
0.02688578888773918,
0.07011270523071289,
0.3450736999511719,
-0.149666428565979,
0.23788809776306152,
0.029455920681357384,
0.08601481467485428,
-0.2821899652481079,
0.4557609260082245,
-0.355103999376297,
-0.21232423186302185,
-0.26934367418289185,
0.0550079345703125,
0.11870615184307098,
-0.16724710166454315,
-0.06345903128385544,
-0.1393352746963501,
0.022707529366016388,
0.001660957932472229,
0.35844680666923523,
-0.031841471791267395,
0.15138156712055206,
-0.3605331778526306,
0.0007368139922618866,
-0.014245271682739258,
0.19100113213062286,
0.10995949059724808,
0.13783526420593262,
0.22354117035865784,
0.34959572553634644,
0.31639477610588074,
0.048732027411460876,
-0.25815367698669434,
0.2894139289855957,
0.15064361691474915,
-0.00478145107626915,
-0.3528922200202942,
-0.01283501461148262,
0.2490568608045578,
0.1571197658777237,
-0.07574699074029922,
0.10761070251464844,
0.1634841412305832,
0.24935084581375122,
0.1806226223707199,
0.059507012367248535,
-0.01909622550010681,
-0.18093451857566833,
0.04272516071796417,
0.2133590131998062,
-0.3315229117870331,
0.5042451024055481,
0.1952822357416153,
-0.10752677917480469,
0.002021320164203644,
-0.23246237635612488,
-0.15534016489982605,
0.22551575303077698,
0.15586592257022858,
0.16927507519721985,
0.021715018898248672,
0.40005555748939514,
0.001977999694645405,
-0.1599210500717163,
-0.396759033203125,
-0.18060946464538574,
0.015682226046919823,
-0.22388997673988342,
0.23846985399723053,
-0.3335368037223816,
0.0387190580368042,
-0.26496416330337524,
-0.32123979926109314,
-0.05915385112166405,
-0.1550196409225464,
-0.06616184115409851,
0.1655339002609253,
-0.04197154939174652,
0.09799930453300476,
0.08658251166343689,
0.16132646799087524,
0.12170617282390594,
-0.5659324526786804,
-0.12707310914993286,
0.07293909043073654,
-0.13817229866981506,
0.03119627758860588,
0.0463983528316021,
0.1443513184785843,
0.2281331866979599,
-0.22272621095180511,
-0.04931464046239853,
-0.03734709322452545,
-0.5407865047454834,
0.13256728649139404,
-0.17953747510910034,
0.3834962248802185,
-0.02238471806049347,
-0.22363264858722687,
-0.2287382334470749,
-0.2209000587463379,
0.08535301685333252,
0.03302214294672012,
-0.07387572526931763,
-0.16914428770542145,
-0.2024255096912384,
0.16350404918193817,
-0.07980343699455261,
-0.4645572602748871,
-0.273506760597229,
-0.29208099842071533,
-0.1883683055639267,
0.23808394372463226,
0.07035378366708755,
-0.051195427775382996,
0.4012899398803711,
0.12842698395252228,
0.26016679406166077,
0.1833799034357071,
-0.08417943865060806,
0.1034243106842041,
0.40126869082450867,
-0.2088790237903595,
-0.19478511810302734,
0.3140634596347809,
-0.19571863114833832,
0.1738995611667633,
0.26666849851608276,
-0.20691372454166412,
-0.25385159254074097,
-0.1654600203037262,
0.2149738371372223,
0.15121686458587646,
0.3295900523662567,
0.208226278424263,
0.06291403621435165,
-0.0629701241850853,
-0.07440649718046188,
-0.340837299823761,
0.037091124802827835,
0.24042591452598572,
0.13391061127185822,
-0.08302077651023865,
0.3498714864253998,
-0.14694276452064514,
0.6421234011650085,
0.0022957678884267807,
-0.12015606462955475,
0.4455321133136749,
0.1388605386018753,
0.3459651470184326,
-0.22012680768966675,
-0.25990140438079834,
-0.06418562680482864,
0.2821204662322998,
-0.11512740701436996,
0.11511081457138062,
-0.05819567292928696,
-0.2546572983264923,
-0.2041834443807602,
-0.015062844380736351,
-0.22018662095069885,
-0.04428558051586151,
-0.00493219681084156,
0.5682275295257568,
0.18974393606185913,
-0.02852044627070427,
0.019131436944007874,
-0.08276355266571045,
0.0331137590110302,
-0.07715123891830444,
0.36668384075164795,
-0.19770854711532593,
0.01454408559948206,
0.5677427053451538,
-0.5961407423019409,
-0.3954414427280426,
0.47168171405792236,
0.12705183029174805,
0.1797829270362854,
0.12959589064121246,
-0.09018629789352417,
0.16894309222698212,
0.047159794718027115,
0.3042554259300232,
-0.10313451290130615,
-0.5570278763771057,
0.25937291979789734,
-0.021157583221793175,
-0.4514586329460144,
-0.27979105710983276,
-0.40093061327934265,
0.17905350029468536,
0.21344764530658722,
0.4027971625328064,
-0.1314033567905426,
-0.031220823526382446,
0.11118880659341812,
0.23547682166099548,
-0.012499582022428513,
-0.12767396867275238,
-0.4390488564968109,
-0.5053246021270752,
-0.14893405139446259,
0.1272612363100052,
0.012313922867178917,
0.22506967186927795,
-0.04457536339759827,
-0.08763767778873444,
-0.18596786260604858,
-0.280423104763031,
0.10364237427711487,
0.2624562978744507,
0.03796811401844025,
-0.02384076826274395,
0.13794831931591034,
-0.21762365102767944,
0.07267096638679504,
0.5520889163017273,
0.4959200918674469,
-0.22852712869644165,
-0.06572668254375458,
0.021160989999771118,
0.020821329206228256,
0.12997226417064667,
0.1585116982460022,
-0.11120104789733887,
0.19656914472579956,
-0.4038280248641968,
0.047139931470155716,
0.1977158933877945,
0.08394196629524231,
0.1980421394109726,
0.05862422287464142,
0.0065465387888252735,
-0.14845918118953705,
0.5298153162002563,
0.2245994508266449,
-0.15603825449943542,
-0.07618790864944458,
0.49599236249923706,
-0.31994861364364624,
0.7623822093009949,
-0.11319435387849808,
0.614052951335907,
0.2812572717666626,
-0.3093530237674713,
0.39586594700813293,
0.07837022840976715,
0.7126440405845642,
-0.0990818440914154,
0.2383415251970291,
-0.1748022437095642,
-0.12976080179214478,
0.13259708881378174,
-0.18334564566612244,
0.3717232644557953,
-0.3628873825073242,
-0.37863689661026,
0.34615135192871094,
0.05880056321620941,
-0.1165204644203186,
0.09917206317186356,
0.1682925522327423,
0.14760246872901917,
-0.1932554543018341,
-0.16427432000637054,
0.09358473122119904,
0.12308994680643082,
0.34345442056655884,
-0.007854117080569267,
-0.03099898248910904,
-0.4329080581665039,
-0.17739374935626984,
-0.12102271616458893,
0.11789954453706741,
-0.06187263876199722,
0.4830719828605652,
0.10279454290866852,
-0.15362471342086792,
0.3304445147514343,
-0.48574328422546387,
0.45066243410110474,
-0.0365280844271183,
-0.14461082220077515,
0.02786291018128395,
0.06460634618997574,
-0.17278245091438293,
0.015483134426176548,
-0.24725721776485443,
0.25953927636146545,
-0.11148464679718018,
-0.27438825368881226,
0.129989892244339,
0.08946399390697479,
-0.34428006410598755,
0.051644161343574524,
0.3508386015892029,
-0.23134745657444,
-0.09209757298231125,
-0.0880647599697113,
0.10985944420099258,
0.12464286386966705,
-0.08334432542324066,
0.10545122623443604,
0.09531547129154205,
-0.04372940585017204,
0.48864150047302246,
0.026420833542943,
-0.3472288250923157,
-0.22439946234226227,
0.2679886519908905,
0.33001959323883057,
-0.017567694187164307,
0.2617092728614807,
-0.21279560029506683,
-0.322132408618927,
-0.08400598168373108,
-0.5679416060447693,
-0.22690320014953613,
-0.01061045378446579,
-0.06528133898973465,
0.10800426453351974,
-0.22138020396232605,
0.0654950961470604,
0.01341899111866951,
0.1939387172460556,
0.04285073280334473,
-0.3218673765659332,
-0.1680380403995514,
0.09906768798828125,
0.1305999606847763,
-0.03251064196228981,
0.1478329300880432,
-0.0076471418142318726,
0.07050541043281555,
-0.06118663400411606,
-0.18794438242912292,
-0.2624443471431732,
0.21434856951236725,
-0.14817018806934357,
-0.009950689971446991,
-0.3508014976978302,
-0.027760423719882965,
0.261823832988739,
-0.011296333745121956,
0.06566181778907776,
0.1084924265742302,
-0.1978408545255661,
-0.1798180639743805,
-0.011459517292678356,
0.13145963847637177,
0.06411301344633102,
0.17080160975456238,
-0.3131437301635742,
0.02164752408862114,
0.1238110214471817,
-0.1320168673992157,
0.08651238679885864,
0.17828333377838135,
-0.06173950433731079,
0.026039309799671173,
0.11361517012119293,
-0.07234374433755875,
0.26507312059402466,
0.356405645608902,
0.10694436728954315,
0.31416165828704834,
0.08078551292419434,
0.3546185791492462,
-0.17993582785129547,
0.11872217059135437,
0.37123870849609375,
-0.01434672623872757,
-0.18913103640079498,
0.22855868935585022,
0.08697914332151413,
-0.20667152106761932,
-0.20523713529109955,
0.03913458064198494,
-0.1381497085094452,
0.5096691846847534,
-0.20340697467327118,
-0.1416870653629303,
0.17453983426094055,
0.1806524097919464,
-0.13577434420585632,
0.055578120052814484,
0.40988287329673767,
0.017553534358739853,
0.22751310467720032,
0.39886000752449036,
0.6414452791213989,
0.05760069191455841,
0.31095314025878906,
0.17182299494743347,
0.33142417669296265,
0.544065535068512,
0.07087385654449463,
-0.5886974334716797,
-0.02643878385424614,
0.17250145971775055,
0.12854091823101044,
0.07617340981960297,
0.42602914571762085,
0.18182283639907837,
-0.13735949993133545,
0.14575998485088348,
-0.0007226690649986267,
-0.18548233807086945,
0.25053155422210693,
-0.0787622481584549,
0.5536108613014221,
-0.08980047702789307,
0.172328382730484,
-0.18316370248794556,
0.21064120531082153,
0.1932205855846405,
-0.15876556932926178,
-0.0006246804259717464,
-0.22309254109859467,
0.06487267464399338,
-0.06243047118186951,
0.0015389332547783852,
0.4362599551677704,
0.04552013427019119,
-0.26329305768013,
-0.11454637348651886,
0.17220383882522583,
-0.19361762702465057,
-0.39592334628105164,
0.021501574665308,
-0.43723630905151367,
0.13394732773303986,
-0.11147507280111313,
0.3427950441837311,
0.11631297320127487,
0.06815871596336365,
0.1440614014863968,
-0.10813573002815247,
-0.22307831048965454,
-0.2716769874095917,
0.2758486866950989,
0.4407409727573395,
0.40185222029685974,
-0.16976776719093323,
0.053797803819179535,
0.07463385909795761,
-0.12524229288101196,
-0.06307075917720795,
-0.13670337200164795,
-0.30346179008483887,
-0.07035721838474274,
0.16045603156089783,
0.13645809888839722,
-0.2550845146179199,
-0.3640289306640625,
-0.000843975692987442,
0.4340205192565918,
-0.09535250067710876,
-0.19906878471374512,
-0.18211664259433746,
0.18161776661872864,
-0.03117753565311432,
-0.060212887823581696,
-0.6458978056907654,
0.10765334218740463,
0.17626094818115234,
-0.3111002445220947,
0.08649361878633499,
0.15622512996196747,
0.05998341739177704,
-0.10081678628921509,
0.2696950137615204,
0.331211656332016,
0.33928969502449036,
0.005997262895107269,
-0.054433271288871765,
-0.22064068913459778,
0.2568538188934326,
-0.23269301652908325,
0.2532843351364136,
-0.11365832388401031,
0.41433608531951904,
-0.14204296469688416,
0.08048990368843079,
0.04179240018129349,
0.12893220782279968,
0.25818392634391785,
-0.1492053121328354,
-0.276449978351593,
-0.1550917774438858,
-0.032408975064754486,
-0.3881831467151642,
-0.01348104327917099,
-0.08445538580417633,
0.002357345074415207,
-0.5446872711181641,
0.10900575667619705,
-0.2633470892906189,
-0.21406406164169312,
0.16988015174865723,
-0.3694571852684021,
0.9051520228385925,
0.24940890073776245,
0.32790374755859375,
-0.17533421516418457,
0.06997817754745483,
-0.0456269197165966,
-0.30698564648628235,
-0.08461236208677292,
0.21839258074760437,
0.11247725784778595,
0.05133263021707535,
-0.08871262520551682,
-0.44749531149864197,
-0.10945489257574081,
0.7328310608863831,
0.013871517032384872,
-0.36447757482528687,
0.14604488015174866,
0.03350736200809479,
-0.2910647392272949,
0.12016628682613373,
-0.28736117482185364,
-0.013258501887321472,
0.015426427125930786,
0.21695047616958618,
-0.11316098272800446,
-0.4931493103504181,
0.43367087841033936,
-0.2741332948207855,
-0.08480600267648697,
-0.3300609588623047,
0.3259088397026062,
0.5856763124465942,
0.16075104475021362,
-0.42206573486328125,
0.01683451235294342,
0.1702301949262619,
-0.04799061268568039,
-0.23958823084831238,
0.16900864243507385,
0.15467405319213867,
0.06412522494792938,
-0.18468646705150604,
-0.21630316972732544,
0.008873147889971733,
0.039037078619003296,
-0.22239933907985687,
-0.18871131539344788
] |
https://github.com/huggingface/datasets/issues/7456
|
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
|
When you run the first cell containing pip install faiss-cpu does it
install it?
On Mon, 17 Mar, 2025, 8:01 pm MapleBloom, ***@***.***> wrote:
> you can't meet the requirements
>
> It is not the case (or I didn't reach this point) because the same code in
> notebook
> importlib.util.find_spec("faiss")
> finds faiss. I've mention it.
> I think the problem is in the very moment when _has_faiss takes its value
> and never try again.
> (or it couldn't find the path that was easily found when started from my
> code)
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2729737414>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AVUSZMCCE6BPZCOVAWXKIY32U3MFVAVCNFSM6AAAAABZDBA426VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRZG4ZTONBRGQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
> [image: MapleBloom]*MapleBloom* left a comment (huggingface/datasets#7456)
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2729737414>
>
> you can't meet the requirements
>
> It is not the case (or I didn't reach this point) because the same code in
> notebook
> importlib.util.find_spec("faiss")
> finds faiss. I've mention it.
> I think the problem is in the very moment when _has_faiss takes its value
> and never try again.
> (or it couldn't find the path that was easily found when started from my
> code)
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2729737414>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AVUSZMCCE6BPZCOVAWXKIY32U3MFVAVCNFSM6AAAAABZDBA426VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRZG4ZTONBRGQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
| 243 |
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
When you run the first cell containing pip install faiss-cpu does it
install it?
On Mon, 17 Mar, 2025, 8:01 pm MapleBloom, ***@***.***> wrote:
> you can't meet the requirements
>
> It is not the case (or I didn't reach this point) because the same code in
> notebook
> importlib.util.find_spec("faiss")
> finds faiss. I've mention it.
> I think the problem is in the very moment when _has_faiss takes its value
> and never try again.
> (or it couldn't find the path that was easily found when started from my
> code)
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2729737414>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AVUSZMCCE6BPZCOVAWXKIY32U3MFVAVCNFSM6AAAAABZDBA426VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRZG4ZTONBRGQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
> [image: MapleBloom]*MapleBloom* left a comment (huggingface/datasets#7456)
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2729737414>
>
> you can't meet the requirements
>
> It is not the case (or I didn't reach this point) because the same code in
> notebook
> importlib.util.find_spec("faiss")
> finds faiss. I've mention it.
> I think the problem is in the very moment when _has_faiss takes its value
> and never try again.
> (or it couldn't find the path that was easily found when started from my
> code)
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/datasets/issues/7456#issuecomment-2729737414>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AVUSZMCCE6BPZCOVAWXKIY32U3MFVAVCNFSM6AAAAABZDBA426VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRZG4ZTONBRGQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
[
-0.16117000579833984,
-0.11760753393173218,
-0.15066224336624146,
0.08203524351119995,
-0.1286037713289261,
-0.00994054228067398,
0.10475793480873108,
0.1413806676864624,
0.5156817436218262,
0.4201788902282715,
-0.23171284794807434,
0.3851391077041626,
0.09162198752164841,
-0.031732842326164246,
-0.22691023349761963,
0.2530635595321655,
0.31324052810668945,
0.3141487240791321,
0.286990761756897,
-0.225828155875206,
-0.21031071245670319,
0.24549394845962524,
-0.11663298308849335,
-0.14979669451713562,
-0.061843808740377426,
0.20163683593273163,
-0.04081256687641144,
-0.060086242854595184,
-0.17773616313934326,
-0.4343525171279907,
0.3564590811729431,
-0.2465187907218933,
0.06784113496541977,
0.45280614495277405,
-0.00012001708091702312,
0.16983987390995026,
0.46698254346847534,
0.038603462278842926,
-0.20051944255828857,
-0.2968881130218506,
-0.34063124656677246,
-0.1492750197649002,
0.3670836389064789,
-0.11481065303087234,
0.007955286651849747,
-0.11012418568134308,
-0.11281844973564148,
-0.21513177454471588,
0.13531622290611267,
0.4694521725177765,
0.14951427280902863,
0.06196172535419464,
0.1800299882888794,
-0.21636570990085602,
0.5414345264434814,
-0.30696386098861694,
-0.22465455532073975,
-0.016008924692869186,
0.036910559982061386,
0.24787604808807373,
0.4191136360168457,
0.1929059773683548,
-0.08678627014160156,
-0.01986824721097946,
-0.36704665422439575,
0.07248660922050476,
-0.07346541434526443,
-0.3942570388317108,
-0.011618684977293015,
-0.037493087351322174,
0.10735979676246643,
-0.16118240356445312,
-0.22358283400535583,
0.1561070680618286,
0.10509961098432541,
-0.25884976983070374,
0.22590795159339905,
0.02065884694457054,
0.014161558821797371,
0.19833941757678986,
0.3465823531150818,
-0.14075376093387604,
-0.19422593712806702,
0.05597778782248497,
-0.28478899598121643,
0.49147096276283264,
-0.04927155748009682,
-0.11800331622362137,
0.11341769993305206,
-0.10482732951641083,
0.22461381554603577,
0.06444834917783737,
0.16802719235420227,
-0.10034651309251785,
-0.17825940251350403,
0.04722083359956741,
0.1361667960882187,
-0.08213513344526291,
-0.12494523078203201,
-0.039579398930072784,
-0.35669249296188354,
0.007569471374154091,
0.09197752922773361,
0.3693396747112274,
-0.4950583577156067,
0.12524934113025665,
0.00571085512638092,
-0.0023592920042574406,
0.2595343589782715,
0.07186460494995117,
-0.13065402209758759,
-0.014068752527236938,
0.07384522259235382,
-0.2511730492115021,
-0.41447457671165466,
-0.1172662153840065,
0.137697234749794,
-0.3650587499141693,
-0.46173542737960815,
0.08694619685411453,
-0.37541764974594116,
-0.07669366896152496,
0.010866579599678516,
0.3808978796005249,
-0.033448271453380585,
-0.3733902871608734,
0.1065153032541275,
0.23127561807632446,
-0.11577831953763962,
0.27290013432502747,
-0.18207122385501862,
0.2185625433921814,
0.15644453465938568,
0.28199055790901184,
0.3098966181278229,
-0.6035938858985901,
0.430266410112381,
-0.01865580677986145,
0.11926405131816864,
0.12065625190734863,
0.11778198182582855,
-0.27658987045288086,
0.09237615019083023,
0.5115554928779602,
0.11889557540416718,
0.06079360097646713,
-0.01675218716263771,
-0.30686694383621216,
-0.12403038889169693,
0.02150382101535797,
-0.4513663053512573,
-0.1714765429496765,
-0.2683683931827545,
0.1931690275669098,
-0.26483702659606934,
-0.1902206540107727,
-0.00963158905506134,
0.06139732152223587,
0.022929102182388306,
-0.031789038330316544,
-0.10731133073568344,
-0.10580423474311829,
-0.11228859424591064,
-0.20336408913135529,
0.19544769823551178,
-0.010690644383430481,
-0.2846740484237671,
-0.18304625153541565,
-0.2959628105163574,
0.21858294308185577,
-0.002251371741294861,
0.3062683939933777,
-0.039837151765823364,
0.16121360659599304,
-0.2587433457374573,
0.18084590137004852,
0.47567662596702576,
-0.38209670782089233,
-0.33405327796936035,
-0.0464184507727623,
0.20323805510997772,
-0.11482933163642883,
0.33721107244491577,
-0.3041093647480011,
0.13790956139564514,
0.21408343315124512,
0.40372195839881897,
0.09647197276353836,
0.04032605141401291,
-0.21423329412937164,
-0.31953945755958557,
-0.3014972507953644,
0.04426121711730957,
0.1507096290588379,
0.28164923191070557,
-0.1397862732410431,
0.2283763289451599,
-0.558803915977478,
-0.2248099148273468,
-0.027080070227384567,
-0.17033375799655914,
0.17325320839881897,
0.7504816651344299,
0.11588825285434723,
0.250286728143692,
-0.09420672804117203,
0.03429264575242996,
0.23494622111320496,
-0.16884760558605194,
0.3206605911254883,
-0.5654057264328003,
-0.07951882481575012,
-0.2047884464263916,
0.01621283032000065,
-0.11963531374931335,
-0.08547830581665039,
0.09035539627075195,
0.02688578888773918,
0.07011270523071289,
0.3450736999511719,
-0.149666428565979,
0.23788809776306152,
0.029455920681357384,
0.08601481467485428,
-0.2821899652481079,
0.4557609260082245,
-0.355103999376297,
-0.21232423186302185,
-0.26934367418289185,
0.0550079345703125,
0.11870615184307098,
-0.16724710166454315,
-0.06345903128385544,
-0.1393352746963501,
0.022707529366016388,
0.001660957932472229,
0.35844680666923523,
-0.031841471791267395,
0.15138156712055206,
-0.3605331778526306,
0.0007368139922618866,
-0.014245271682739258,
0.19100113213062286,
0.10995949059724808,
0.13783526420593262,
0.22354117035865784,
0.34959572553634644,
0.31639477610588074,
0.048732027411460876,
-0.25815367698669434,
0.2894139289855957,
0.15064361691474915,
-0.00478145107626915,
-0.3528922200202942,
-0.01283501461148262,
0.2490568608045578,
0.1571197658777237,
-0.07574699074029922,
0.10761070251464844,
0.1634841412305832,
0.24935084581375122,
0.1806226223707199,
0.059507012367248535,
-0.01909622550010681,
-0.18093451857566833,
0.04272516071796417,
0.2133590131998062,
-0.3315229117870331,
0.5042451024055481,
0.1952822357416153,
-0.10752677917480469,
0.002021320164203644,
-0.23246237635612488,
-0.15534016489982605,
0.22551575303077698,
0.15586592257022858,
0.16927507519721985,
0.021715018898248672,
0.40005555748939514,
0.001977999694645405,
-0.1599210500717163,
-0.396759033203125,
-0.18060946464538574,
0.015682226046919823,
-0.22388997673988342,
0.23846985399723053,
-0.3335368037223816,
0.0387190580368042,
-0.26496416330337524,
-0.32123979926109314,
-0.05915385112166405,
-0.1550196409225464,
-0.06616184115409851,
0.1655339002609253,
-0.04197154939174652,
0.09799930453300476,
0.08658251166343689,
0.16132646799087524,
0.12170617282390594,
-0.5659324526786804,
-0.12707310914993286,
0.07293909043073654,
-0.13817229866981506,
0.03119627758860588,
0.0463983528316021,
0.1443513184785843,
0.2281331866979599,
-0.22272621095180511,
-0.04931464046239853,
-0.03734709322452545,
-0.5407865047454834,
0.13256728649139404,
-0.17953747510910034,
0.3834962248802185,
-0.02238471806049347,
-0.22363264858722687,
-0.2287382334470749,
-0.2209000587463379,
0.08535301685333252,
0.03302214294672012,
-0.07387572526931763,
-0.16914428770542145,
-0.2024255096912384,
0.16350404918193817,
-0.07980343699455261,
-0.4645572602748871,
-0.273506760597229,
-0.29208099842071533,
-0.1883683055639267,
0.23808394372463226,
0.07035378366708755,
-0.051195427775382996,
0.4012899398803711,
0.12842698395252228,
0.26016679406166077,
0.1833799034357071,
-0.08417943865060806,
0.1034243106842041,
0.40126869082450867,
-0.2088790237903595,
-0.19478511810302734,
0.3140634596347809,
-0.19571863114833832,
0.1738995611667633,
0.26666849851608276,
-0.20691372454166412,
-0.25385159254074097,
-0.1654600203037262,
0.2149738371372223,
0.15121686458587646,
0.3295900523662567,
0.208226278424263,
0.06291403621435165,
-0.0629701241850853,
-0.07440649718046188,
-0.340837299823761,
0.037091124802827835,
0.24042591452598572,
0.13391061127185822,
-0.08302077651023865,
0.3498714864253998,
-0.14694276452064514,
0.6421234011650085,
0.0022957678884267807,
-0.12015606462955475,
0.4455321133136749,
0.1388605386018753,
0.3459651470184326,
-0.22012680768966675,
-0.25990140438079834,
-0.06418562680482864,
0.2821204662322998,
-0.11512740701436996,
0.11511081457138062,
-0.05819567292928696,
-0.2546572983264923,
-0.2041834443807602,
-0.015062844380736351,
-0.22018662095069885,
-0.04428558051586151,
-0.00493219681084156,
0.5682275295257568,
0.18974393606185913,
-0.02852044627070427,
0.019131436944007874,
-0.08276355266571045,
0.0331137590110302,
-0.07715123891830444,
0.36668384075164795,
-0.19770854711532593,
0.01454408559948206,
0.5677427053451538,
-0.5961407423019409,
-0.3954414427280426,
0.47168171405792236,
0.12705183029174805,
0.1797829270362854,
0.12959589064121246,
-0.09018629789352417,
0.16894309222698212,
0.047159794718027115,
0.3042554259300232,
-0.10313451290130615,
-0.5570278763771057,
0.25937291979789734,
-0.021157583221793175,
-0.4514586329460144,
-0.27979105710983276,
-0.40093061327934265,
0.17905350029468536,
0.21344764530658722,
0.4027971625328064,
-0.1314033567905426,
-0.031220823526382446,
0.11118880659341812,
0.23547682166099548,
-0.012499582022428513,
-0.12767396867275238,
-0.4390488564968109,
-0.5053246021270752,
-0.14893405139446259,
0.1272612363100052,
0.012313922867178917,
0.22506967186927795,
-0.04457536339759827,
-0.08763767778873444,
-0.18596786260604858,
-0.280423104763031,
0.10364237427711487,
0.2624562978744507,
0.03796811401844025,
-0.02384076826274395,
0.13794831931591034,
-0.21762365102767944,
0.07267096638679504,
0.5520889163017273,
0.4959200918674469,
-0.22852712869644165,
-0.06572668254375458,
0.021160989999771118,
0.020821329206228256,
0.12997226417064667,
0.1585116982460022,
-0.11120104789733887,
0.19656914472579956,
-0.4038280248641968,
0.047139931470155716,
0.1977158933877945,
0.08394196629524231,
0.1980421394109726,
0.05862422287464142,
0.0065465387888252735,
-0.14845918118953705,
0.5298153162002563,
0.2245994508266449,
-0.15603825449943542,
-0.07618790864944458,
0.49599236249923706,
-0.31994861364364624,
0.7623822093009949,
-0.11319435387849808,
0.614052951335907,
0.2812572717666626,
-0.3093530237674713,
0.39586594700813293,
0.07837022840976715,
0.7126440405845642,
-0.0990818440914154,
0.2383415251970291,
-0.1748022437095642,
-0.12976080179214478,
0.13259708881378174,
-0.18334564566612244,
0.3717232644557953,
-0.3628873825073242,
-0.37863689661026,
0.34615135192871094,
0.05880056321620941,
-0.1165204644203186,
0.09917206317186356,
0.1682925522327423,
0.14760246872901917,
-0.1932554543018341,
-0.16427432000637054,
0.09358473122119904,
0.12308994680643082,
0.34345442056655884,
-0.007854117080569267,
-0.03099898248910904,
-0.4329080581665039,
-0.17739374935626984,
-0.12102271616458893,
0.11789954453706741,
-0.06187263876199722,
0.4830719828605652,
0.10279454290866852,
-0.15362471342086792,
0.3304445147514343,
-0.48574328422546387,
0.45066243410110474,
-0.0365280844271183,
-0.14461082220077515,
0.02786291018128395,
0.06460634618997574,
-0.17278245091438293,
0.015483134426176548,
-0.24725721776485443,
0.25953927636146545,
-0.11148464679718018,
-0.27438825368881226,
0.129989892244339,
0.08946399390697479,
-0.34428006410598755,
0.051644161343574524,
0.3508386015892029,
-0.23134745657444,
-0.09209757298231125,
-0.0880647599697113,
0.10985944420099258,
0.12464286386966705,
-0.08334432542324066,
0.10545122623443604,
0.09531547129154205,
-0.04372940585017204,
0.48864150047302246,
0.026420833542943,
-0.3472288250923157,
-0.22439946234226227,
0.2679886519908905,
0.33001959323883057,
-0.017567694187164307,
0.2617092728614807,
-0.21279560029506683,
-0.322132408618927,
-0.08400598168373108,
-0.5679416060447693,
-0.22690320014953613,
-0.01061045378446579,
-0.06528133898973465,
0.10800426453351974,
-0.22138020396232605,
0.0654950961470604,
0.01341899111866951,
0.1939387172460556,
0.04285073280334473,
-0.3218673765659332,
-0.1680380403995514,
0.09906768798828125,
0.1305999606847763,
-0.03251064196228981,
0.1478329300880432,
-0.0076471418142318726,
0.07050541043281555,
-0.06118663400411606,
-0.18794438242912292,
-0.2624443471431732,
0.21434856951236725,
-0.14817018806934357,
-0.009950689971446991,
-0.3508014976978302,
-0.027760423719882965,
0.261823832988739,
-0.011296333745121956,
0.06566181778907776,
0.1084924265742302,
-0.1978408545255661,
-0.1798180639743805,
-0.011459517292678356,
0.13145963847637177,
0.06411301344633102,
0.17080160975456238,
-0.3131437301635742,
0.02164752408862114,
0.1238110214471817,
-0.1320168673992157,
0.08651238679885864,
0.17828333377838135,
-0.06173950433731079,
0.026039309799671173,
0.11361517012119293,
-0.07234374433755875,
0.26507312059402466,
0.356405645608902,
0.10694436728954315,
0.31416165828704834,
0.08078551292419434,
0.3546185791492462,
-0.17993582785129547,
0.11872217059135437,
0.37123870849609375,
-0.01434672623872757,
-0.18913103640079498,
0.22855868935585022,
0.08697914332151413,
-0.20667152106761932,
-0.20523713529109955,
0.03913458064198494,
-0.1381497085094452,
0.5096691846847534,
-0.20340697467327118,
-0.1416870653629303,
0.17453983426094055,
0.1806524097919464,
-0.13577434420585632,
0.055578120052814484,
0.40988287329673767,
0.017553534358739853,
0.22751310467720032,
0.39886000752449036,
0.6414452791213989,
0.05760069191455841,
0.31095314025878906,
0.17182299494743347,
0.33142417669296265,
0.544065535068512,
0.07087385654449463,
-0.5886974334716797,
-0.02643878385424614,
0.17250145971775055,
0.12854091823101044,
0.07617340981960297,
0.42602914571762085,
0.18182283639907837,
-0.13735949993133545,
0.14575998485088348,
-0.0007226690649986267,
-0.18548233807086945,
0.25053155422210693,
-0.0787622481584549,
0.5536108613014221,
-0.08980047702789307,
0.172328382730484,
-0.18316370248794556,
0.21064120531082153,
0.1932205855846405,
-0.15876556932926178,
-0.0006246804259717464,
-0.22309254109859467,
0.06487267464399338,
-0.06243047118186951,
0.0015389332547783852,
0.4362599551677704,
0.04552013427019119,
-0.26329305768013,
-0.11454637348651886,
0.17220383882522583,
-0.19361762702465057,
-0.39592334628105164,
0.021501574665308,
-0.43723630905151367,
0.13394732773303986,
-0.11147507280111313,
0.3427950441837311,
0.11631297320127487,
0.06815871596336365,
0.1440614014863968,
-0.10813573002815247,
-0.22307831048965454,
-0.2716769874095917,
0.2758486866950989,
0.4407409727573395,
0.40185222029685974,
-0.16976776719093323,
0.053797803819179535,
0.07463385909795761,
-0.12524229288101196,
-0.06307075917720795,
-0.13670337200164795,
-0.30346179008483887,
-0.07035721838474274,
0.16045603156089783,
0.13645809888839722,
-0.2550845146179199,
-0.3640289306640625,
-0.000843975692987442,
0.4340205192565918,
-0.09535250067710876,
-0.19906878471374512,
-0.18211664259433746,
0.18161776661872864,
-0.03117753565311432,
-0.060212887823581696,
-0.6458978056907654,
0.10765334218740463,
0.17626094818115234,
-0.3111002445220947,
0.08649361878633499,
0.15622512996196747,
0.05998341739177704,
-0.10081678628921509,
0.2696950137615204,
0.331211656332016,
0.33928969502449036,
0.005997262895107269,
-0.054433271288871765,
-0.22064068913459778,
0.2568538188934326,
-0.23269301652908325,
0.2532843351364136,
-0.11365832388401031,
0.41433608531951904,
-0.14204296469688416,
0.08048990368843079,
0.04179240018129349,
0.12893220782279968,
0.25818392634391785,
-0.1492053121328354,
-0.276449978351593,
-0.1550917774438858,
-0.032408975064754486,
-0.3881831467151642,
-0.01348104327917099,
-0.08445538580417633,
0.002357345074415207,
-0.5446872711181641,
0.10900575667619705,
-0.2633470892906189,
-0.21406406164169312,
0.16988015174865723,
-0.3694571852684021,
0.9051520228385925,
0.24940890073776245,
0.32790374755859375,
-0.17533421516418457,
0.06997817754745483,
-0.0456269197165966,
-0.30698564648628235,
-0.08461236208677292,
0.21839258074760437,
0.11247725784778595,
0.05133263021707535,
-0.08871262520551682,
-0.44749531149864197,
-0.10945489257574081,
0.7328310608863831,
0.013871517032384872,
-0.36447757482528687,
0.14604488015174866,
0.03350736200809479,
-0.2910647392272949,
0.12016628682613373,
-0.28736117482185364,
-0.013258501887321472,
0.015426427125930786,
0.21695047616958618,
-0.11316098272800446,
-0.4931493103504181,
0.43367087841033936,
-0.2741332948207855,
-0.08480600267648697,
-0.3300609588623047,
0.3259088397026062,
0.5856763124465942,
0.16075104475021362,
-0.42206573486328125,
0.01683451235294342,
0.1702301949262619,
-0.04799061268568039,
-0.23958823084831238,
0.16900864243507385,
0.15467405319213867,
0.06412522494792938,
-0.18468646705150604,
-0.21630316972732544,
0.008873147889971733,
0.039037078619003296,
-0.22239933907985687,
-0.18871131539344788
] |
https://github.com/huggingface/datasets/issues/7456
|
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
|
> When you run the first cell containing pip install faiss-cpu does it
> install it?
> […](#)
Yes. It was installed succesfully.
Methods of datasets library that depends on _has_faiss constant didn't start to work.
|
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
| 36 |
.add_faiss_index and .add_elasticsearch_index returns ImportError at Google Colab
### Describe the bug
At Google Colab
```!pip install faiss-cpu``` works
```import faiss``` no error
but
```embeddings_dataset.add_faiss_index(column='embeddings')```
returns
```
[/usr/local/lib/python3.11/dist-packages/datasets/search.py](https://localhost:8080/#) in init(self, device, string_factory, metric_type, custom_index)
247 self.faiss_index = custom_index
248 if not _has_faiss:
--> 249 raise ImportError(
250 "You must install Faiss to use FaissIndex. To do so you can run conda install -c pytorch faiss-cpu or conda install -c pytorch faiss-gpu. "
251 "A community supported package is also available on pypi: pip install faiss-cpu or pip install faiss-gpu. "
```
because
```_has_faiss = importlib.util.find_spec("faiss") is not None``` at the beginning of ```datasets/search.py``` returns ```False```
when
the same code at colab notebook returns
```ModuleSpec(name='faiss', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7b7851449f50>, origin='/usr/local/lib/python3.11/dist-packages/faiss/init.py', submodule_search_locations=['/usr/local/lib/python3.11/dist-packages/faiss'])```
But
```
import datasets
datasets.search._has_faiss
```
at ```colab notebook``` also returns ```False```
The same story with ```_has_elasticsearch```
### Steps to reproduce the bug
1. Follow https://huggingface.co/learn/nlp-course/chapter5/6?fw=pt at Google Colab
2. till ```embeddings_dataset.add_faiss_index(column='embeddings')```
3. ```embeddings_dataset.add_elasticsearch_index(column='embeddings')```
4. https://colab.research.google.com/drive/1h2cjuiClblqzbNQgrcoLYOC8zBqTLLcv#scrollTo=3ddzRp72auOF
### Expected behavior
I've only started Tutorial and don't know exactly. But something tells me that ```embeddings_dataset.add_faiss_index(column='embeddings')```
should work without ```Import Error```
### Environment info
Google Colab notebook with default config
> When you run the first cell containing pip install faiss-cpu does it
> install it?
> […](#)
Yes. It was installed succesfully.
Methods of datasets library that depends on _has_faiss constant didn't start to work.
|
[
-0.16117000579833984,
-0.11760753393173218,
-0.15066224336624146,
0.08203524351119995,
-0.1286037713289261,
-0.00994054228067398,
0.10475793480873108,
0.1413806676864624,
0.5156817436218262,
0.4201788902282715,
-0.23171284794807434,
0.3851391077041626,
0.09162198752164841,
-0.031732842326164246,
-0.22691023349761963,
0.2530635595321655,
0.31324052810668945,
0.3141487240791321,
0.286990761756897,
-0.225828155875206,
-0.21031071245670319,
0.24549394845962524,
-0.11663298308849335,
-0.14979669451713562,
-0.061843808740377426,
0.20163683593273163,
-0.04081256687641144,
-0.060086242854595184,
-0.17773616313934326,
-0.4343525171279907,
0.3564590811729431,
-0.2465187907218933,
0.06784113496541977,
0.45280614495277405,
-0.00012001708091702312,
0.16983987390995026,
0.46698254346847534,
0.038603462278842926,
-0.20051944255828857,
-0.2968881130218506,
-0.34063124656677246,
-0.1492750197649002,
0.3670836389064789,
-0.11481065303087234,
0.007955286651849747,
-0.11012418568134308,
-0.11281844973564148,
-0.21513177454471588,
0.13531622290611267,
0.4694521725177765,
0.14951427280902863,
0.06196172535419464,
0.1800299882888794,
-0.21636570990085602,
0.5414345264434814,
-0.30696386098861694,
-0.22465455532073975,
-0.016008924692869186,
0.036910559982061386,
0.24787604808807373,
0.4191136360168457,
0.1929059773683548,
-0.08678627014160156,
-0.01986824721097946,
-0.36704665422439575,
0.07248660922050476,
-0.07346541434526443,
-0.3942570388317108,
-0.011618684977293015,
-0.037493087351322174,
0.10735979676246643,
-0.16118240356445312,
-0.22358283400535583,
0.1561070680618286,
0.10509961098432541,
-0.25884976983070374,
0.22590795159339905,
0.02065884694457054,
0.014161558821797371,
0.19833941757678986,
0.3465823531150818,
-0.14075376093387604,
-0.19422593712806702,
0.05597778782248497,
-0.28478899598121643,
0.49147096276283264,
-0.04927155748009682,
-0.11800331622362137,
0.11341769993305206,
-0.10482732951641083,
0.22461381554603577,
0.06444834917783737,
0.16802719235420227,
-0.10034651309251785,
-0.17825940251350403,
0.04722083359956741,
0.1361667960882187,
-0.08213513344526291,
-0.12494523078203201,
-0.039579398930072784,
-0.35669249296188354,
0.007569471374154091,
0.09197752922773361,
0.3693396747112274,
-0.4950583577156067,
0.12524934113025665,
0.00571085512638092,
-0.0023592920042574406,
0.2595343589782715,
0.07186460494995117,
-0.13065402209758759,
-0.014068752527236938,
0.07384522259235382,
-0.2511730492115021,
-0.41447457671165466,
-0.1172662153840065,
0.137697234749794,
-0.3650587499141693,
-0.46173542737960815,
0.08694619685411453,
-0.37541764974594116,
-0.07669366896152496,
0.010866579599678516,
0.3808978796005249,
-0.033448271453380585,
-0.3733902871608734,
0.1065153032541275,
0.23127561807632446,
-0.11577831953763962,
0.27290013432502747,
-0.18207122385501862,
0.2185625433921814,
0.15644453465938568,
0.28199055790901184,
0.3098966181278229,
-0.6035938858985901,
0.430266410112381,
-0.01865580677986145,
0.11926405131816864,
0.12065625190734863,
0.11778198182582855,
-0.27658987045288086,
0.09237615019083023,
0.5115554928779602,
0.11889557540416718,
0.06079360097646713,
-0.01675218716263771,
-0.30686694383621216,
-0.12403038889169693,
0.02150382101535797,
-0.4513663053512573,
-0.1714765429496765,
-0.2683683931827545,
0.1931690275669098,
-0.26483702659606934,
-0.1902206540107727,
-0.00963158905506134,
0.06139732152223587,
0.022929102182388306,
-0.031789038330316544,
-0.10731133073568344,
-0.10580423474311829,
-0.11228859424591064,
-0.20336408913135529,
0.19544769823551178,
-0.010690644383430481,
-0.2846740484237671,
-0.18304625153541565,
-0.2959628105163574,
0.21858294308185577,
-0.002251371741294861,
0.3062683939933777,
-0.039837151765823364,
0.16121360659599304,
-0.2587433457374573,
0.18084590137004852,
0.47567662596702576,
-0.38209670782089233,
-0.33405327796936035,
-0.0464184507727623,
0.20323805510997772,
-0.11482933163642883,
0.33721107244491577,
-0.3041093647480011,
0.13790956139564514,
0.21408343315124512,
0.40372195839881897,
0.09647197276353836,
0.04032605141401291,
-0.21423329412937164,
-0.31953945755958557,
-0.3014972507953644,
0.04426121711730957,
0.1507096290588379,
0.28164923191070557,
-0.1397862732410431,
0.2283763289451599,
-0.558803915977478,
-0.2248099148273468,
-0.027080070227384567,
-0.17033375799655914,
0.17325320839881897,
0.7504816651344299,
0.11588825285434723,
0.250286728143692,
-0.09420672804117203,
0.03429264575242996,
0.23494622111320496,
-0.16884760558605194,
0.3206605911254883,
-0.5654057264328003,
-0.07951882481575012,
-0.2047884464263916,
0.01621283032000065,
-0.11963531374931335,
-0.08547830581665039,
0.09035539627075195,
0.02688578888773918,
0.07011270523071289,
0.3450736999511719,
-0.149666428565979,
0.23788809776306152,
0.029455920681357384,
0.08601481467485428,
-0.2821899652481079,
0.4557609260082245,
-0.355103999376297,
-0.21232423186302185,
-0.26934367418289185,
0.0550079345703125,
0.11870615184307098,
-0.16724710166454315,
-0.06345903128385544,
-0.1393352746963501,
0.022707529366016388,
0.001660957932472229,
0.35844680666923523,
-0.031841471791267395,
0.15138156712055206,
-0.3605331778526306,
0.0007368139922618866,
-0.014245271682739258,
0.19100113213062286,
0.10995949059724808,
0.13783526420593262,
0.22354117035865784,
0.34959572553634644,
0.31639477610588074,
0.048732027411460876,
-0.25815367698669434,
0.2894139289855957,
0.15064361691474915,
-0.00478145107626915,
-0.3528922200202942,
-0.01283501461148262,
0.2490568608045578,
0.1571197658777237,
-0.07574699074029922,
0.10761070251464844,
0.1634841412305832,
0.24935084581375122,
0.1806226223707199,
0.059507012367248535,
-0.01909622550010681,
-0.18093451857566833,
0.04272516071796417,
0.2133590131998062,
-0.3315229117870331,
0.5042451024055481,
0.1952822357416153,
-0.10752677917480469,
0.002021320164203644,
-0.23246237635612488,
-0.15534016489982605,
0.22551575303077698,
0.15586592257022858,
0.16927507519721985,
0.021715018898248672,
0.40005555748939514,
0.001977999694645405,
-0.1599210500717163,
-0.396759033203125,
-0.18060946464538574,
0.015682226046919823,
-0.22388997673988342,
0.23846985399723053,
-0.3335368037223816,
0.0387190580368042,
-0.26496416330337524,
-0.32123979926109314,
-0.05915385112166405,
-0.1550196409225464,
-0.06616184115409851,
0.1655339002609253,
-0.04197154939174652,
0.09799930453300476,
0.08658251166343689,
0.16132646799087524,
0.12170617282390594,
-0.5659324526786804,
-0.12707310914993286,
0.07293909043073654,
-0.13817229866981506,
0.03119627758860588,
0.0463983528316021,
0.1443513184785843,
0.2281331866979599,
-0.22272621095180511,
-0.04931464046239853,
-0.03734709322452545,
-0.5407865047454834,
0.13256728649139404,
-0.17953747510910034,
0.3834962248802185,
-0.02238471806049347,
-0.22363264858722687,
-0.2287382334470749,
-0.2209000587463379,
0.08535301685333252,
0.03302214294672012,
-0.07387572526931763,
-0.16914428770542145,
-0.2024255096912384,
0.16350404918193817,
-0.07980343699455261,
-0.4645572602748871,
-0.273506760597229,
-0.29208099842071533,
-0.1883683055639267,
0.23808394372463226,
0.07035378366708755,
-0.051195427775382996,
0.4012899398803711,
0.12842698395252228,
0.26016679406166077,
0.1833799034357071,
-0.08417943865060806,
0.1034243106842041,
0.40126869082450867,
-0.2088790237903595,
-0.19478511810302734,
0.3140634596347809,
-0.19571863114833832,
0.1738995611667633,
0.26666849851608276,
-0.20691372454166412,
-0.25385159254074097,
-0.1654600203037262,
0.2149738371372223,
0.15121686458587646,
0.3295900523662567,
0.208226278424263,
0.06291403621435165,
-0.0629701241850853,
-0.07440649718046188,
-0.340837299823761,
0.037091124802827835,
0.24042591452598572,
0.13391061127185822,
-0.08302077651023865,
0.3498714864253998,
-0.14694276452064514,
0.6421234011650085,
0.0022957678884267807,
-0.12015606462955475,
0.4455321133136749,
0.1388605386018753,
0.3459651470184326,
-0.22012680768966675,
-0.25990140438079834,
-0.06418562680482864,
0.2821204662322998,
-0.11512740701436996,
0.11511081457138062,
-0.05819567292928696,
-0.2546572983264923,
-0.2041834443807602,
-0.015062844380736351,
-0.22018662095069885,
-0.04428558051586151,
-0.00493219681084156,
0.5682275295257568,
0.18974393606185913,
-0.02852044627070427,
0.019131436944007874,
-0.08276355266571045,
0.0331137590110302,
-0.07715123891830444,
0.36668384075164795,
-0.19770854711532593,
0.01454408559948206,
0.5677427053451538,
-0.5961407423019409,
-0.3954414427280426,
0.47168171405792236,
0.12705183029174805,
0.1797829270362854,
0.12959589064121246,
-0.09018629789352417,
0.16894309222698212,
0.047159794718027115,
0.3042554259300232,
-0.10313451290130615,
-0.5570278763771057,
0.25937291979789734,
-0.021157583221793175,
-0.4514586329460144,
-0.27979105710983276,
-0.40093061327934265,
0.17905350029468536,
0.21344764530658722,
0.4027971625328064,
-0.1314033567905426,
-0.031220823526382446,
0.11118880659341812,
0.23547682166099548,
-0.012499582022428513,
-0.12767396867275238,
-0.4390488564968109,
-0.5053246021270752,
-0.14893405139446259,
0.1272612363100052,
0.012313922867178917,
0.22506967186927795,
-0.04457536339759827,
-0.08763767778873444,
-0.18596786260604858,
-0.280423104763031,
0.10364237427711487,
0.2624562978744507,
0.03796811401844025,
-0.02384076826274395,
0.13794831931591034,
-0.21762365102767944,
0.07267096638679504,
0.5520889163017273,
0.4959200918674469,
-0.22852712869644165,
-0.06572668254375458,
0.021160989999771118,
0.020821329206228256,
0.12997226417064667,
0.1585116982460022,
-0.11120104789733887,
0.19656914472579956,
-0.4038280248641968,
0.047139931470155716,
0.1977158933877945,
0.08394196629524231,
0.1980421394109726,
0.05862422287464142,
0.0065465387888252735,
-0.14845918118953705,
0.5298153162002563,
0.2245994508266449,
-0.15603825449943542,
-0.07618790864944458,
0.49599236249923706,
-0.31994861364364624,
0.7623822093009949,
-0.11319435387849808,
0.614052951335907,
0.2812572717666626,
-0.3093530237674713,
0.39586594700813293,
0.07837022840976715,
0.7126440405845642,
-0.0990818440914154,
0.2383415251970291,
-0.1748022437095642,
-0.12976080179214478,
0.13259708881378174,
-0.18334564566612244,
0.3717232644557953,
-0.3628873825073242,
-0.37863689661026,
0.34615135192871094,
0.05880056321620941,
-0.1165204644203186,
0.09917206317186356,
0.1682925522327423,
0.14760246872901917,
-0.1932554543018341,
-0.16427432000637054,
0.09358473122119904,
0.12308994680643082,
0.34345442056655884,
-0.007854117080569267,
-0.03099898248910904,
-0.4329080581665039,
-0.17739374935626984,
-0.12102271616458893,
0.11789954453706741,
-0.06187263876199722,
0.4830719828605652,
0.10279454290866852,
-0.15362471342086792,
0.3304445147514343,
-0.48574328422546387,
0.45066243410110474,
-0.0365280844271183,
-0.14461082220077515,
0.02786291018128395,
0.06460634618997574,
-0.17278245091438293,
0.015483134426176548,
-0.24725721776485443,
0.25953927636146545,
-0.11148464679718018,
-0.27438825368881226,
0.129989892244339,
0.08946399390697479,
-0.34428006410598755,
0.051644161343574524,
0.3508386015892029,
-0.23134745657444,
-0.09209757298231125,
-0.0880647599697113,
0.10985944420099258,
0.12464286386966705,
-0.08334432542324066,
0.10545122623443604,
0.09531547129154205,
-0.04372940585017204,
0.48864150047302246,
0.026420833542943,
-0.3472288250923157,
-0.22439946234226227,
0.2679886519908905,
0.33001959323883057,
-0.017567694187164307,
0.2617092728614807,
-0.21279560029506683,
-0.322132408618927,
-0.08400598168373108,
-0.5679416060447693,
-0.22690320014953613,
-0.01061045378446579,
-0.06528133898973465,
0.10800426453351974,
-0.22138020396232605,
0.0654950961470604,
0.01341899111866951,
0.1939387172460556,
0.04285073280334473,
-0.3218673765659332,
-0.1680380403995514,
0.09906768798828125,
0.1305999606847763,
-0.03251064196228981,
0.1478329300880432,
-0.0076471418142318726,
0.07050541043281555,
-0.06118663400411606,
-0.18794438242912292,
-0.2624443471431732,
0.21434856951236725,
-0.14817018806934357,
-0.009950689971446991,
-0.3508014976978302,
-0.027760423719882965,
0.261823832988739,
-0.011296333745121956,
0.06566181778907776,
0.1084924265742302,
-0.1978408545255661,
-0.1798180639743805,
-0.011459517292678356,
0.13145963847637177,
0.06411301344633102,
0.17080160975456238,
-0.3131437301635742,
0.02164752408862114,
0.1238110214471817,
-0.1320168673992157,
0.08651238679885864,
0.17828333377838135,
-0.06173950433731079,
0.026039309799671173,
0.11361517012119293,
-0.07234374433755875,
0.26507312059402466,
0.356405645608902,
0.10694436728954315,
0.31416165828704834,
0.08078551292419434,
0.3546185791492462,
-0.17993582785129547,
0.11872217059135437,
0.37123870849609375,
-0.01434672623872757,
-0.18913103640079498,
0.22855868935585022,
0.08697914332151413,
-0.20667152106761932,
-0.20523713529109955,
0.03913458064198494,
-0.1381497085094452,
0.5096691846847534,
-0.20340697467327118,
-0.1416870653629303,
0.17453983426094055,
0.1806524097919464,
-0.13577434420585632,
0.055578120052814484,
0.40988287329673767,
0.017553534358739853,
0.22751310467720032,
0.39886000752449036,
0.6414452791213989,
0.05760069191455841,
0.31095314025878906,
0.17182299494743347,
0.33142417669296265,
0.544065535068512,
0.07087385654449463,
-0.5886974334716797,
-0.02643878385424614,
0.17250145971775055,
0.12854091823101044,
0.07617340981960297,
0.42602914571762085,
0.18182283639907837,
-0.13735949993133545,
0.14575998485088348,
-0.0007226690649986267,
-0.18548233807086945,
0.25053155422210693,
-0.0787622481584549,
0.5536108613014221,
-0.08980047702789307,
0.172328382730484,
-0.18316370248794556,
0.21064120531082153,
0.1932205855846405,
-0.15876556932926178,
-0.0006246804259717464,
-0.22309254109859467,
0.06487267464399338,
-0.06243047118186951,
0.0015389332547783852,
0.4362599551677704,
0.04552013427019119,
-0.26329305768013,
-0.11454637348651886,
0.17220383882522583,
-0.19361762702465057,
-0.39592334628105164,
0.021501574665308,
-0.43723630905151367,
0.13394732773303986,
-0.11147507280111313,
0.3427950441837311,
0.11631297320127487,
0.06815871596336365,
0.1440614014863968,
-0.10813573002815247,
-0.22307831048965454,
-0.2716769874095917,
0.2758486866950989,
0.4407409727573395,
0.40185222029685974,
-0.16976776719093323,
0.053797803819179535,
0.07463385909795761,
-0.12524229288101196,
-0.06307075917720795,
-0.13670337200164795,
-0.30346179008483887,
-0.07035721838474274,
0.16045603156089783,
0.13645809888839722,
-0.2550845146179199,
-0.3640289306640625,
-0.000843975692987442,
0.4340205192565918,
-0.09535250067710876,
-0.19906878471374512,
-0.18211664259433746,
0.18161776661872864,
-0.03117753565311432,
-0.060212887823581696,
-0.6458978056907654,
0.10765334218740463,
0.17626094818115234,
-0.3111002445220947,
0.08649361878633499,
0.15622512996196747,
0.05998341739177704,
-0.10081678628921509,
0.2696950137615204,
0.331211656332016,
0.33928969502449036,
0.005997262895107269,
-0.054433271288871765,
-0.22064068913459778,
0.2568538188934326,
-0.23269301652908325,
0.2532843351364136,
-0.11365832388401031,
0.41433608531951904,
-0.14204296469688416,
0.08048990368843079,
0.04179240018129349,
0.12893220782279968,
0.25818392634391785,
-0.1492053121328354,
-0.276449978351593,
-0.1550917774438858,
-0.032408975064754486,
-0.3881831467151642,
-0.01348104327917099,
-0.08445538580417633,
0.002357345074415207,
-0.5446872711181641,
0.10900575667619705,
-0.2633470892906189,
-0.21406406164169312,
0.16988015174865723,
-0.3694571852684021,
0.9051520228385925,
0.24940890073776245,
0.32790374755859375,
-0.17533421516418457,
0.06997817754745483,
-0.0456269197165966,
-0.30698564648628235,
-0.08461236208677292,
0.21839258074760437,
0.11247725784778595,
0.05133263021707535,
-0.08871262520551682,
-0.44749531149864197,
-0.10945489257574081,
0.7328310608863831,
0.013871517032384872,
-0.36447757482528687,
0.14604488015174866,
0.03350736200809479,
-0.2910647392272949,
0.12016628682613373,
-0.28736117482185364,
-0.013258501887321472,
0.015426427125930786,
0.21695047616958618,
-0.11316098272800446,
-0.4931493103504181,
0.43367087841033936,
-0.2741332948207855,
-0.08480600267648697,
-0.3300609588623047,
0.3259088397026062,
0.5856763124465942,
0.16075104475021362,
-0.42206573486328125,
0.01683451235294342,
0.1702301949262619,
-0.04799061268568039,
-0.23958823084831238,
0.16900864243507385,
0.15467405319213867,
0.06412522494792938,
-0.18468646705150604,
-0.21630316972732544,
0.008873147889971733,
0.039037078619003296,
-0.22239933907985687,
-0.18871131539344788
] |
https://github.com/huggingface/datasets/issues/7455
|
Problems with local dataset after upgrade from 3.3.2 to 3.4.0
|
Hi ! I just released 3.4.1 with a fix, let me know if it's working now !
|
### Describe the bug
I was not able to open a local saved dataset anymore that was created using an older datasets version after the upgrade yesterday from datasets 3.3.2 to 3.4.0
The traceback is
```
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/datasets/packaged_modules/arrow/arrow.py", line 67, in _generate_tables
batches = pa.ipc.open_stream(f)
File "/usr/local/lib/python3.10/dist-packages/pyarrow/ipc.py", line 190, in open_stream
return RecordBatchStreamReader(source, options=options,
File "/usr/local/lib/python3.10/dist-packages/pyarrow/ipc.py", line 52, in __init__
self._open(source, options=options, memory_pool=memory_pool)
File "pyarrow/ipc.pxi", line 1006, in pyarrow.lib._RecordBatchStreamReader._open
File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Expected to read 538970747 metadata bytes, but only read 2126
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/datasets/builder.py", line 1855, in _prepare_split_single
for _, table in generator:
File "/usr/local/lib/python3.10/dist-packages/datasets/packaged_modules/arrow/arrow.py", line 69, in _generate_tables
reader = pa.ipc.open_file(f)
File "/usr/local/lib/python3.10/dist-packages/pyarrow/ipc.py", line 234, in open_file
return RecordBatchFileReader(
File "/usr/local/lib/python3.10/dist-packages/pyarrow/ipc.py", line 110, in __init__
self._open(source, footer_offset=footer_offset,
File "pyarrow/ipc.pxi", line 1090, in pyarrow.lib._RecordBatchFileReader._open
File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Not an Arrow file
```
### Steps to reproduce the bug
Load a dataset from a local folder with
```
dataset = load_dataset(
args.train_data_dir,
cache_dir=args.cache_dir,
)
```
as it is done for example in the training script for SD3 controlnet.
This is the minimal script to test it:
```
from datasets import load_dataset
def main():
dataset = load_dataset(
"local_dataset",
)
print(dataset)
print("Sample data:", dataset["train"][0])
if __name__ == "__main__":
main()
````
### Expected behavior
Work in 3.4.0 like in 3.3.2
### Environment info
- `datasets` version: 3.4.0
- Platform: Linux-5.15.0-75-generic-x86_64-with-glibc2.35
- Python version: 3.10.12
- `huggingface_hub` version: 0.29.3
- PyArrow version: 19.0.1
- Pandas version: 2.2.3
- `fsspec` version: 2024.12.0
| 17 |
Problems with local dataset after upgrade from 3.3.2 to 3.4.0
### Describe the bug
I was not able to open a local saved dataset anymore that was created using an older datasets version after the upgrade yesterday from datasets 3.3.2 to 3.4.0
The traceback is
```
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/datasets/packaged_modules/arrow/arrow.py", line 67, in _generate_tables
batches = pa.ipc.open_stream(f)
File "/usr/local/lib/python3.10/dist-packages/pyarrow/ipc.py", line 190, in open_stream
return RecordBatchStreamReader(source, options=options,
File "/usr/local/lib/python3.10/dist-packages/pyarrow/ipc.py", line 52, in __init__
self._open(source, options=options, memory_pool=memory_pool)
File "pyarrow/ipc.pxi", line 1006, in pyarrow.lib._RecordBatchStreamReader._open
File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Expected to read 538970747 metadata bytes, but only read 2126
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/datasets/builder.py", line 1855, in _prepare_split_single
for _, table in generator:
File "/usr/local/lib/python3.10/dist-packages/datasets/packaged_modules/arrow/arrow.py", line 69, in _generate_tables
reader = pa.ipc.open_file(f)
File "/usr/local/lib/python3.10/dist-packages/pyarrow/ipc.py", line 234, in open_file
return RecordBatchFileReader(
File "/usr/local/lib/python3.10/dist-packages/pyarrow/ipc.py", line 110, in __init__
self._open(source, footer_offset=footer_offset,
File "pyarrow/ipc.pxi", line 1090, in pyarrow.lib._RecordBatchFileReader._open
File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Not an Arrow file
```
### Steps to reproduce the bug
Load a dataset from a local folder with
```
dataset = load_dataset(
args.train_data_dir,
cache_dir=args.cache_dir,
)
```
as it is done for example in the training script for SD3 controlnet.
This is the minimal script to test it:
```
from datasets import load_dataset
def main():
dataset = load_dataset(
"local_dataset",
)
print(dataset)
print("Sample data:", dataset["train"][0])
if __name__ == "__main__":
main()
````
### Expected behavior
Work in 3.4.0 like in 3.3.2
### Environment info
- `datasets` version: 3.4.0
- Platform: Linux-5.15.0-75-generic-x86_64-with-glibc2.35
- Python version: 3.10.12
- `huggingface_hub` version: 0.29.3
- PyArrow version: 19.0.1
- Pandas version: 2.2.3
- `fsspec` version: 2024.12.0
Hi ! I just released 3.4.1 with a fix, let me know if it's working now !
|
[
-0.3902001678943634,
0.45110374689102173,
-0.0023769065737724304,
0.3377929925918579,
0.21976236999034882,
-0.050108522176742554,
0.2956712543964386,
0.4789068400859833,
-0.6353299617767334,
0.0035277530550956726,
-0.18981291353702545,
0.5654850602149963,
-0.35310983657836914,
0.05658460408449173,
-0.13877111673355103,
-0.23781266808509827,
-0.003729112446308136,
0.07737185806035995,
0.04204586148262024,
0.01486804336309433,
-0.4560109078884125,
0.004157742485404015,
-0.10504023730754852,
0.14519056677818298,
0.058252234011888504,
0.2390466034412384,
0.015615271404385567,
0.19009682536125183,
-0.03026735596358776,
-0.8564949631690979,
0.20821349322795868,
-0.08828485012054443,
0.07719771564006805,
0.23909670114517212,
-0.00012268342834431678,
0.07269436120986938,
0.44456082582473755,
0.15936709940433502,
-0.4579218924045563,
-0.23751206696033478,
-0.39347782731056213,
-0.305167019367218,
0.2420259714126587,
0.04464825242757797,
-0.041810132563114166,
-0.6611257195472717,
-0.183668315410614,
-0.39811503887176514,
0.007663235068321228,
0.4158324897289276,
0.19232235848903656,
0.11785636842250824,
0.1632116734981537,
0.04783456772565842,
0.35740742087364197,
0.11572087556123734,
-0.1297786831855774,
0.5023078322410583,
0.3870479166507721,
0.23162509500980377,
-0.19242870807647705,
0.24668176472187042,
0.04535211622714996,
0.1324843466281891,
0.14733737707138062,
-0.07878392189741135,
0.07346469908952713,
0.11440594494342804,
0.2880212664604187,
0.14708837866783142,
0.406401664018631,
-0.3862444758415222,
-0.6111987829208374,
-0.26050859689712524,
0.02811514213681221,
-0.31772381067276,
0.29919707775115967,
0.3238416612148285,
-0.01129001285880804,
0.11639226973056793,
-0.44397857785224915,
-0.1098477840423584,
-0.43729740381240845,
0.15707337856292725,
-0.32322579622268677,
0.15169769525527954,
-0.0555606484413147,
0.10697659850120544,
0.15699996054172516,
-0.15437819063663483,
0.6057347059249878,
0.2024810016155243,
-0.2558515965938568,
0.14186879992485046,
0.07804781943559647,
0.05139999836683273,
0.25101494789123535,
0.21073758602142334,
-0.053843237459659576,
0.2483634054660797,
-0.44169026613235474,
0.13260112702846527,
0.004544185474514961,
-0.2074912190437317,
0.2139730602502823,
-0.034780826419591904,
0.21044045686721802,
0.06976653635501862,
0.33821189403533936,
-0.03340616077184677,
-0.10579851269721985,
-0.2370636761188507,
-0.09212660044431686,
-0.20163936913013458,
0.12505672872066498,
0.13534456491470337,
0.46905428171157837,
-0.24883870780467987,
-0.025337740778923035,
0.17007401585578918,
-0.10261127352714539,
-0.14842763543128967,
-0.21819700300693512,
0.2950422167778015,
-0.13399383425712585,
0.22278299927711487,
0.1329399198293686,
0.2727815508842468,
-0.07340292632579803,
-0.16521243751049042,
-0.06795681267976761,
-0.281220018863678,
-0.13840605318546295,
-0.03377396613359451,
0.12607480585575104,
-0.23375415802001953,
0.033630482852458954,
-0.028456367552280426,
-0.34573566913604736,
0.3029702603816986,
0.01848146878182888,
-0.3482700288295746,
0.2327701449394226,
0.4133947491645813,
-0.12117151916027069,
0.040673986077308655,
-0.09787385165691376,
-0.07881765812635422,
0.047270022332668304,
0.3071170449256897,
0.18894872069358826,
-0.45461371541023254,
-0.5145947933197021,
0.101750947535038,
-0.048499561846256256,
0.09341248869895935,
-0.28628677129745483,
0.07607629895210266,
-0.006989628076553345,
-0.13235758244991302,
-0.21666106581687927,
-0.3218827247619629,
-0.06160053610801697,
-0.304220587015152,
0.16314154863357544,
0.46451860666275024,
-0.5637194514274597,
0.11666801571846008,
-0.38615790009498596,
0.0283566452562809,
0.07895350456237793,
0.15150666236877441,
-0.2665169835090637,
0.07827587425708771,
-0.20881237089633942,
0.02650514990091324,
0.03443377465009689,
-0.14829963445663452,
-0.3393424153327942,
0.23673409223556519,
0.0585414320230484,
-0.06998979300260544,
-0.061268456280231476,
-0.3598952293395996,
0.051441941410303116,
0.013530833646655083,
0.032941628247499466,
0.010561920702457428,
-0.11335395276546478,
0.12330801039934158,
-0.1913171410560608,
-0.3316631317138672,
0.11576389521360397,
0.019931863993406296,
0.3804643750190735,
-0.06429652124643326,
0.25520241260528564,
-0.2322346717119217,
0.1560950130224228,
-0.183232381939888,
0.322542279958725,
0.06757891178131104,
0.43378737568855286,
-0.01525973528623581,
0.05329624190926552,
-0.143937885761261,
-0.3624260425567627,
0.24535101652145386,
-0.010705338791012764,
-0.14147000014781952,
-0.37147587537765503,
0.01297914981842041,
-0.15344297885894775,
0.0968000665307045,
-0.17090235650539398,
0.18394361436367035,
0.04854266345500946,
0.16162651777267456,
-0.014928357675671577,
0.4147442579269409,
-0.14490801095962524,
-0.10516605526208878,
-0.15374280512332916,
0.06102496758103371,
0.09889687597751617,
0.3547683656215668,
-0.013474812731146812,
-0.22820860147476196,
-0.10413187742233276,
0.09366946667432785,
0.04195230454206467,
0.0021430025808513165,
-0.18234309554100037,
0.34179413318634033,
0.20743437111377716,
0.37718665599823,
-0.22603574395179749,
0.08442448824644089,
0.37545356154441833,
-0.27118438482284546,
0.2978386878967285,
-0.1435186266899109,
0.025207974016666412,
0.10700751096010208,
0.06857557594776154,
0.2336082011461258,
0.2615237832069397,
0.1718127727508545,
0.3369758725166321,
-0.04052237421274185,
-0.035806819796562195,
-0.16660526394844055,
0.1878364533185959,
0.023263342678546906,
-0.17088431119918823,
0.006883997470140457,
0.7806562185287476,
0.07776685059070587,
-0.4527662694454193,
0.1699845939874649,
0.35293471813201904,
0.065714031457901,
-0.14822113513946533,
-0.01981336623430252,
-0.5710603594779968,
0.07208240777254105,
0.35078155994415283,
0.5274003744125366,
0.460979700088501,
0.13612177968025208,
0.1775345802307129,
0.2655998170375824,
0.11749817430973053,
-0.15960393846035004,
0.1821403205394745,
0.033771246671676636,
0.2761353850364685,
0.3568146526813507,
0.3609164357185364,
0.02459360472857952,
-0.2123676836490631,
0.21422183513641357,
0.18230867385864258,
0.3667299449443817,
-0.42631295323371887,
0.03201829642057419,
-0.43373534083366394,
-0.10545707494020462,
-0.12311741709709167,
-0.4346427917480469,
-0.16420724987983704,
-0.34205707907676697,
-0.23051361739635468,
0.2889341413974762,
-0.18631936609745026,
0.04512834548950195,
0.20142920315265656,
-0.16726677119731903,
-0.009433507919311523,
0.21384814381599426,
-0.15993554890155792,
-0.07021118700504303,
-0.38051679730415344,
0.009948670864105225,
0.3951328694820404,
-0.24008655548095703,
0.3482134938240051,
-0.1073794960975647,
-0.03817524015903473,
-0.41793519258499146,
-0.09868139773607254,
0.01808563619852066,
0.08402805775403976,
0.29681673645973206,
0.07728557288646698,
0.08276279270648956,
-0.25813308358192444,
-0.2898525595664978,
0.319215327501297,
-0.015456631779670715,
-0.16249217092990875,
0.006144234910607338,
-0.24325516819953918,
0.1980648934841156,
-0.05414000153541565,
-0.5752550363540649,
-0.36063817143440247,
-0.29108545184135437,
0.5704492330551147,
-0.21378812193870544,
0.16246668994426727,
0.31613272428512573,
0.124433234333992,
0.2712109684944153,
-0.03560100123286247,
-0.14219854772090912,
-0.034883491694927216,
0.057030875235795975,
0.006579846143722534,
-0.18142908811569214,
-0.4332048296928406,
-0.0026389025151729584,
0.07704000920057297,
0.15287436544895172,
0.11056579649448395,
-0.22628146409988403,
0.3846374750137329,
-0.1452348381280899,
0.39006307721138,
-0.14609394967556,
-0.20084910094738007,
0.4039996564388275,
0.20206066966056824,
0.019597435370087624,
-0.03841785714030266,
-0.041942134499549866,
-0.038518257439136505,
0.19171568751335144,
0.03138046711683273,
0.037585269659757614,
0.05950595811009407,
0.028931837528944016,
0.6794759035110474,
-0.17946122586727142,
-0.22560034692287445,
0.2005189061164856,
-0.3711093068122864,
0.4061756134033203,
-0.00659460574388504,
-0.28233805298805237,
0.02147473394870758,
0.07119675725698471,
-0.02034049667418003,
-0.05088737607002258,
0.14434820413589478,
-0.2857717275619507,
-0.08852517604827881,
-0.13564838469028473,
-0.21492868661880493,
-0.12069240212440491,
-0.13906967639923096,
-0.23136752843856812,
0.2814766466617584,
0.10657420754432678,
0.1276431381702423,
-0.03572770953178406,
-0.06989826261997223,
-0.030042894184589386,
0.01046474277973175,
0.271863728761673,
-0.15731048583984375,
-0.01837114244699478,
-0.3739898204803467,
-0.4723965525627136,
0.23234343528747559,
0.31423306465148926,
0.22816255688667297,
0.07006725668907166,
-0.2812722623348236,
0.12020735442638397,
-0.05520942434668541,
0.3651667833328247,
-0.4869847297668457,
-0.027185440063476562,
0.43119195103645325,
0.034336157143116,
-0.7335076928138733,
-0.09950155019760132,
-0.025644315406680107,
-0.07685709744691849,
0.11398346722126007,
0.4440820515155792,
0.08810701221227646,
-0.25976303219795227,
0.15176618099212646,
0.2581147849559784,
0.036763351410627365,
0.026152227073907852,
-0.12073592841625214,
0.0012104213237762451,
0.03541561961174011,
0.04784895107150078,
-0.42721647024154663,
0.07318954169750214,
-0.18534354865550995,
-0.12733760476112366,
0.011640054173767567,
0.13997352123260498,
-0.17982889711856842,
0.22773702442646027,
0.3665412962436676,
-0.12121999263763428,
0.412807822227478,
0.22248370945453644,
0.22412550449371338,
0.903600811958313,
0.35356032848358154,
-0.006628293544054031,
-0.11929607391357422,
0.05576557666063309,
-0.07454119622707367,
0.21823865175247192,
0.2148033082485199,
-0.10220014303922653,
-0.04086550325155258,
-0.022326886653900146,
-0.04420456290245056,
-0.10439524054527283,
-0.057636555284261703,
0.2211594581604004,
-0.16415125131607056,
-0.088971808552742,
-0.18766775727272034,
0.2420865297317505,
-0.19599035382270813,
-0.19805364310741425,
0.3047473430633545,
0.09110084176063538,
-0.1476954221725464,
0.12678329646587372,
0.004206433892250061,
0.5915055274963379,
-0.17056123912334442,
-0.05293850228190422,
0.4632476568222046,
-0.405514657497406,
-0.07202107459306717,
0.24970035254955292,
-0.060926541686058044,
-0.5221691131591797,
0.1313924491405487,
0.03145821392536163,
-0.21013322472572327,
0.3612375855445862,
-0.029396727681159973,
-0.09469857066869736,
-0.30897003412246704,
-0.0762537494301796,
0.086044542491436,
-0.09486614167690277,
0.11234442889690399,
-0.11278314143419266,
0.08536113798618317,
-0.20740379393100739,
0.09226460009813309,
-0.16037455201148987,
-0.1621498316526413,
0.008477725088596344,
-0.0935189351439476,
-0.314446359872818,
0.04294530302286148,
-0.3316466212272644,
0.07333066314458847,
-0.39844563603401184,
0.019333109259605408,
0.149732768535614,
-0.34059494733810425,
0.11803533136844635,
0.12194870412349701,
0.03249000757932663,
-0.015482429414987564,
-0.2651796340942383,
0.037500105798244476,
0.18936246633529663,
0.2571951150894165,
0.31226834654808044,
-0.142714723944664,
0.14911150932312012,
-0.028147291392087936,
-0.33413559198379517,
0.10170745849609375,
-0.18555764853954315,
-0.15351898968219757,
0.29804059863090515,
0.1311856508255005,
0.14745348691940308,
-0.187658429145813,
0.10246352851390839,
-0.18001583218574524,
0.12272341549396515,
-0.057152923196554184,
0.08019260317087173,
-0.12551355361938477,
0.16570870578289032,
0.13243089616298676,
-0.21471630036830902,
-0.43259763717651367,
-0.05758975073695183,
0.6669650077819824,
0.2234208881855011,
0.36009854078292847,
0.3807826340198517,
0.1011599749326706,
0.007006891071796417,
-0.12861838936805725,
0.2694963812828064,
0.24339339137077332,
-0.4402189552783966,
0.011133422143757343,
-0.06194491311907768,
0.24637673795223236,
0.21565644443035126,
-0.04887771233916283,
0.08409146219491959,
0.04315798357129097,
-0.1507154405117035,
-0.1625780165195465,
-0.3997440040111542,
0.1116042286157608,
-0.08029733598232269,
-0.06897103786468506,
0.0585637167096138,
0.18944242596626282,
0.1398611217737198,
-0.2669481635093689,
-0.20254388451576233,
0.2525632679462433,
-0.008944781497120857,
0.11340009421110153,
-0.2669048309326172,
0.014603771269321442,
0.19809861481189728,
-0.48964908719062805,
0.07662943005561829,
-0.16777350008487701,
-0.21596132218837738,
-0.09236429631710052,
-0.1635524034500122,
0.10650131851434708,
0.11938093602657318,
-0.24944822490215302,
-0.1898658573627472,
-0.34177929162979126,
-0.087161123752594,
0.036807846277952194,
0.10072687268257141,
0.24941033124923706,
-0.30532485246658325,
0.21046285331249237,
0.5343554615974426,
-0.00875924527645111,
0.19863232970237732,
0.1192484125494957,
-0.1075558215379715,
0.08677749335765839,
-0.16244199872016907,
0.3326849937438965,
0.05333200469613075,
-0.02071310207247734,
0.0949084609746933,
-0.16034933924674988,
-0.3567391633987427,
-0.02134200558066368,
0.45814648270606995,
-0.21723632514476776,
-0.10729150474071503,
-0.026808487251400948,
0.40854576230049133,
0.2615792155265808,
-0.037974100559949875,
-0.13477620482444763,
0.07911897450685501,
0.13074570894241333,
-0.19755148887634277,
-0.24197503924369812,
-0.15646947920322418,
0.09984201937913895,
-0.05354384705424309,
-0.15768954157829285,
0.4438011050224304,
-0.2253383845090866,
-0.05383981764316559,
0.22893458604812622,
0.21833427250385284,
0.03926225006580353,
0.07251591980457306,
0.6183441877365112,
0.03243708238005638,
-0.08580844104290009,
0.21681730449199677,
0.11303183436393738,
0.1684017777442932,
0.30974531173706055,
-0.007773980498313904,
0.03382698819041252,
0.1698806881904602,
0.19445040822029114,
0.104987233877182,
-0.6110806465148926,
-0.07328552007675171,
0.03306055814027786,
-0.3748840391635895,
-0.26436662673950195,
0.20147714018821716,
0.25947314500808716,
0.16453960537910461,
-0.4561632573604584,
0.0925387591123581,
0.3615882992744446,
-0.21522992849349976,
0.022301245480775833,
-0.0726306140422821,
-0.17903104424476624,
0.09315267205238342,
0.10855405032634735,
-0.24904975295066833,
-0.17652836441993713,
0.6230610609054565,
0.1632377803325653,
0.06661679595708847,
-0.23623590171337128,
-0.11851554363965988,
0.12526476383209229,
0.012017957866191864,
-0.16087625920772552,
0.20906932651996613,
0.20675808191299438,
-0.03081291913986206,
-0.018059179186820984,
0.5118764042854309,
0.4142431616783142,
0.28573858737945557,
-0.1116277426481247,
0.24336007237434387,
0.07935882359743118,
-0.07500225305557251,
0.06160712242126465,
0.047685202211141586,
0.12050288915634155,
0.4914309084415436,
0.19219599664211273,
0.11002059280872345,
-0.011763730086386204,
0.14418448507785797,
-0.03929078206419945,
0.39840683341026306,
-0.22476115822792053,
0.23750248551368713,
-0.05715397745370865,
-0.380029559135437,
0.06947380304336548,
0.0010558515787124634,
-0.16493451595306396,
0.14438778162002563,
0.592400848865509,
0.06016954407095909,
0.21567949652671814,
-0.016194790601730347,
0.025804627686738968,
0.1592109501361847,
0.3646254241466522,
0.4609009325504303,
0.08761052042245865,
-0.21281810104846954,
-0.6880553364753723,
-0.36341381072998047,
0.13934235274791718,
-0.12666672468185425,
0.34668290615081787,
0.1021927148103714,
0.09358033537864685,
0.007619477808475494,
-0.10420860350131989,
0.12437696009874344,
0.3303079307079315,
-0.08349250257015228,
0.009117763489484787,
-0.46522217988967896,
-0.1388862431049347,
0.34766924381256104,
-0.17935501039028168,
-0.29266902804374695,
-0.26039326190948486,
0.42861348390579224,
0.019066233187913895,
-0.0515248104929924,
0.04878486692905426,
-0.005468398332595825,
0.22510787844657898,
0.4038303792476654,
0.3572603166103363,
0.08996380865573883,
0.3616727888584137,
0.07666920870542526,
0.005472959950566292,
-0.18999582529067993,
-0.21174444258213043,
-0.11024248600006104,
0.3012937903404236,
-0.2645401656627655,
0.46476447582244873,
-0.029478223994374275,
-0.24416135251522064,
-0.12976408004760742,
0.2711903750896454,
-0.09829925745725632,
0.5007465481758118,
-0.26585546135902405,
0.18534408509731293,
-0.12809596955776215,
-0.01280135102570057,
-0.06151432916522026,
-0.12293341010808945,
0.0041471682488918304,
0.1426205337047577,
-0.3976772427558899,
-0.27211353182792664,
0.3735698461532593,
-0.6805402636528015,
-0.0515691414475441,
-0.13535742461681366,
0.1675872504711151,
-0.00949949026107788,
-0.2095899134874344,
-0.3817554712295532,
-0.18775907158851624,
0.6107072830200195,
-0.041959770023822784,
-0.13565592467784882,
-0.004156751558184624,
-0.10779611766338348,
0.21104131639003754,
-0.09127184003591537,
0.43378379940986633,
-0.03351150453090668,
-0.2536086440086365,
-0.2223731428384781,
-0.02320583164691925
] |
https://github.com/huggingface/datasets/issues/7449
|
Cannot load data with different schemas from different parquet files
|
Hi ! `load_dataset` expects all the data_files to have the same schema.
Maybe you can try enforcing certain `features` using:
```python
features = Features({"conversations": {'content': Value('string'), 'role': Value('string',)}})
ds = load_dataset(..., features=features)
```
|
### Describe the bug
Cannot load samples with optional fields from different files. The schema cannot be correctly derived.
### Steps to reproduce the bug
When I place two samples with an optional field `some_extra_field` within a single parquet file, it can be loaded via `load_dataset`.
```python
import pandas as pd
from datasets import load_dataset
data = [
{'conversations': {'role': 'user', 'content': 'hello'}},
{'conversations': {'role': 'user', 'content': 'hi', 'some_extra_field': 'some_value'}}
]
df = pd.DataFrame(data)
df.to_parquet('data.parquet')
dataset = load_dataset('parquet', data_files='data.parquet', split='train')
print(dataset.features)
```
The schema can be derived. `some_extra_field` is set to None for the first row where it is absent.
```
{'conversations': {'content': Value(dtype='string', id=None), 'role': Value(dtype='string', id=None), 'some_extra_field': Value(dtype='string', id=None)}}
```
However, when I separate the samples into different files, it cannot be loaded.
```python
import pandas as pd
from datasets import load_dataset
data1 = [{'conversations': {'role': 'user', 'content': 'hello'}}]
pd.DataFrame(data1).to_parquet('data1.parquet')
data2 = [{'conversations': {'role': 'user', 'content': 'hi', 'some_extra_field': 'some_value'}}]
pd.DataFrame(data2).to_parquet('data2.parquet')
dataset = load_dataset('parquet', data_files=['data1.parquet', 'data2.parquet'], split='train')
print(dataset.features)
```
Traceback:
```
Traceback (most recent call last):
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/builder.py", line 1854, in _prepare_split_single
for _, table in generator:
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/packaged_modules/parquet/parquet.py", line 106, in _generate_tables
yield f"{file_idx}_{batch_idx}", self._cast_table(pa_table)
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/packaged_modules/parquet/parquet.py", line 73, in _cast_table
pa_table = table_cast(pa_table, self.info.features.arrow_schema)
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 2292, in table_cast
return cast_table_to_schema(table, schema)
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 2245, in cast_table_to_schema
arrays = [
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 2246, in <listcomp>
cast_array_to_feature(
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 1795, in wrapper
return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 1795, in <listcomp>
return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 2108, in cast_array_to_feature
raise TypeError(f"Couldn't cast array of type\n{_short_str(array.type)}\nto\n{_short_str(feature)}")
TypeError: Couldn't cast array of type
struct<content: string, role: string, some_extra_field: string>
to
{'content': Value(dtype='string', id=None), 'role': Value(dtype='string', id=None)}
```
### Expected behavior
Correctly load data with optional fields from different parquet files.
### Environment info
- `datasets` version: 3.3.2
- Platform: Linux-5.10.135.bsk.4-amd64-x86_64-with-glibc2.31
- Python version: 3.9.2
- `huggingface_hub` version: 0.28.1
- PyArrow version: 17.0.0
- Pandas version: 2.2.2
- `fsspec` version: 2024.3.1
| 33 |
Cannot load data with different schemas from different parquet files
### Describe the bug
Cannot load samples with optional fields from different files. The schema cannot be correctly derived.
### Steps to reproduce the bug
When I place two samples with an optional field `some_extra_field` within a single parquet file, it can be loaded via `load_dataset`.
```python
import pandas as pd
from datasets import load_dataset
data = [
{'conversations': {'role': 'user', 'content': 'hello'}},
{'conversations': {'role': 'user', 'content': 'hi', 'some_extra_field': 'some_value'}}
]
df = pd.DataFrame(data)
df.to_parquet('data.parquet')
dataset = load_dataset('parquet', data_files='data.parquet', split='train')
print(dataset.features)
```
The schema can be derived. `some_extra_field` is set to None for the first row where it is absent.
```
{'conversations': {'content': Value(dtype='string', id=None), 'role': Value(dtype='string', id=None), 'some_extra_field': Value(dtype='string', id=None)}}
```
However, when I separate the samples into different files, it cannot be loaded.
```python
import pandas as pd
from datasets import load_dataset
data1 = [{'conversations': {'role': 'user', 'content': 'hello'}}]
pd.DataFrame(data1).to_parquet('data1.parquet')
data2 = [{'conversations': {'role': 'user', 'content': 'hi', 'some_extra_field': 'some_value'}}]
pd.DataFrame(data2).to_parquet('data2.parquet')
dataset = load_dataset('parquet', data_files=['data1.parquet', 'data2.parquet'], split='train')
print(dataset.features)
```
Traceback:
```
Traceback (most recent call last):
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/builder.py", line 1854, in _prepare_split_single
for _, table in generator:
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/packaged_modules/parquet/parquet.py", line 106, in _generate_tables
yield f"{file_idx}_{batch_idx}", self._cast_table(pa_table)
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/packaged_modules/parquet/parquet.py", line 73, in _cast_table
pa_table = table_cast(pa_table, self.info.features.arrow_schema)
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 2292, in table_cast
return cast_table_to_schema(table, schema)
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 2245, in cast_table_to_schema
arrays = [
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 2246, in <listcomp>
cast_array_to_feature(
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 1795, in wrapper
return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 1795, in <listcomp>
return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
File "/home/tiger/.local/lib/python3.9/site-packages/datasets/table.py", line 2108, in cast_array_to_feature
raise TypeError(f"Couldn't cast array of type\n{_short_str(array.type)}\nto\n{_short_str(feature)}")
TypeError: Couldn't cast array of type
struct<content: string, role: string, some_extra_field: string>
to
{'content': Value(dtype='string', id=None), 'role': Value(dtype='string', id=None)}
```
### Expected behavior
Correctly load data with optional fields from different parquet files.
### Environment info
- `datasets` version: 3.3.2
- Platform: Linux-5.10.135.bsk.4-amd64-x86_64-with-glibc2.31
- Python version: 3.9.2
- `huggingface_hub` version: 0.28.1
- PyArrow version: 17.0.0
- Pandas version: 2.2.2
- `fsspec` version: 2024.3.1
Hi ! `load_dataset` expects all the data_files to have the same schema.
Maybe you can try enforcing certain `features` using:
```python
features = Features({"conversations": {'content': Value('string'), 'role': Value('string',)}})
ds = load_dataset(..., features=features)
```
|
[
0.10294389724731445,
-0.16719797253608704,
0.0950295627117157,
0.5130628943443298,
0.29918497800827026,
-0.007598564028739929,
0.08269620686769485,
0.20173236727714539,
0.24091634154319763,
0.2161167711019516,
0.08312766999006271,
0.38739094138145447,
0.0929841548204422,
0.13671307265758514,
-0.45730751752853394,
-0.14579403400421143,
-0.0019356384873390198,
-0.021239735186100006,
0.17470520734786987,
-0.028722841292619705,
-0.02473507821559906,
0.2609446048736572,
-0.005409061908721924,
-0.14793936908245087,
0.1389560103416443,
0.08992564678192139,
-0.2555031180381775,
0.17885863780975342,
-0.10800796002149582,
-0.15024378895759583,
0.32727521657943726,
0.09514468163251877,
0.038072675466537476,
0.27882811427116394,
-0.00012102453911211342,
0.10141609609127045,
0.3112042546272278,
-0.3116844892501831,
-0.08104124665260315,
-0.4183070659637451,
0.00997886061668396,
-0.03144073486328125,
0.013391898013651371,
-0.17722687125205994,
-0.32601094245910645,
-0.11712152510881424,
-0.3073975443840027,
-0.23984311521053314,
0.2545650601387024,
0.3337027430534363,
0.11190636456012726,
0.18816827237606049,
-0.21503427624702454,
-0.41914692521095276,
0.41892027854919434,
0.0711984857916832,
-0.05101584270596504,
-0.04735187813639641,
0.17534202337265015,
-0.05756404995918274,
0.10440512001514435,
0.051083728671073914,
-0.1129600778222084,
-0.11156231164932251,
-0.10747367888689041,
0.11111408472061157,
0.2563057243824005,
-0.11128273606300354,
0.2508610486984253,
0.44638216495513916,
0.31978046894073486,
0.13347890973091125,
-0.2686270475387573,
-0.3085802495479584,
0.027203716337680817,
0.056992307305336,
0.2960551977157593,
0.2176237851381302,
0.0007079597562551498,
0.0326962023973465,
0.3151393532752991,
-0.012636398896574974,
-0.08503851294517517,
0.12666895985603333,
-0.2779112458229065,
-0.010214895009994507,
0.1471090167760849,
0.025846168398857117,
-0.2704083323478699,
-0.14946435391902924,
0.014932695776224136,
-0.20997869968414307,
-0.23092582821846008,
0.1631944179534912,
-0.14304490387439728,
-0.04451672360301018,
0.11811326444149017,
-0.3128873109817505,
0.09002998471260071,
0.15832990407943726,
0.1499558389186859,
0.046189576387405396,
0.07800138741731644,
0.17707738280296326,
0.4903313219547272,
-0.3174596130847931,
-0.27681705355644226,
0.1965142786502838,
-0.17042267322540283,
0.33491453528404236,
-0.23211562633514404,
-0.23728278279304504,
0.0673467293381691,
-0.11518028378486633,
-0.35029923915863037,
-0.18630728125572205,
0.4934660792350769,
-0.2642700970172882,
-0.2533920407295227,
0.24219635128974915,
-0.1313111037015915,
0.040274474769830704,
0.15519025921821594,
0.2684490382671356,
0.046026576310396194,
0.42154064774513245,
-0.07218913733959198,
0.42724788188934326,
0.12279503792524338,
-0.40214088559150696,
-0.20360617339611053,
0.10980847477912903,
-0.1368475705385208,
0.06018752604722977,
0.036335717886686325,
0.20141147077083588,
0.2047678530216217,
0.7038344144821167,
0.0026558339595794678,
-0.2073953002691269,
0.01218978688120842,
-0.5094615817070007,
-0.049256108701229095,
-0.005196671932935715,
0.06214543804526329,
0.047815099358558655,
0.1734890341758728,
-0.07367853075265884,
-0.13823302090168,
-0.11946327239274979,
-0.3957281708717346,
-0.29342755675315857,
-0.12037904560565948,
0.1181703433394432,
-0.23237277567386627,
0.12083955854177475,
-0.6396504044532776,
0.38046446442604065,
-0.03239349275827408,
-0.15405802428722382,
-0.06872845441102982,
-0.08708474040031433,
-0.1280897855758667,
-0.17266182601451874,
0.1381787359714508,
0.3844510316848755,
-0.19600386917591095,
0.2130335569381714,
0.15242716670036316,
-0.06839005649089813,
0.1479739546775818,
0.24505220353603363,
-0.4016152322292328,
0.06956810504198074,
-0.29939717054367065,
0.272957444190979,
0.609351396560669,
-0.6514682173728943,
-0.08339180052280426,
0.44243544340133667,
0.14393995702266693,
0.3447805941104889,
0.46590155363082886,
-0.5838675498962402,
0.32308444380760193,
-0.027957193553447723,
-0.18606910109519958,
0.4969790577888489,
-0.08245949447154999,
-0.17960402369499207,
-0.3519984781742096,
-0.2903047502040863,
0.4263935685157776,
0.26637935638427734,
0.09881138801574707,
0.040871258825063705,
0.08487744629383087,
0.05159670114517212,
0.20816606283187866,
-0.21670001745224,
-0.17366446554660797,
0.3746437430381775,
0.2523699998855591,
0.5893824696540833,
0.01413140632212162,
-0.29115012288093567,
-0.32957276701927185,
0.1716570258140564,
-0.25054270029067993,
-0.11771419644355774,
0.09689577668905258,
-0.22422751784324646,
-0.10698942095041275,
-0.33028075098991394,
0.0029005855321884155,
-0.07424971461296082,
0.1427839994430542,
0.12422613054513931,
0.10514704883098602,
-0.2542426884174347,
-0.08968167006969452,
0.1721128672361374,
-0.23883117735385895,
0.04295039176940918,
-0.1387416273355484,
0.4653913080692291,
0.19767318665981293,
-0.22791257500648499,
0.06997563689947128,
0.2658627927303314,
0.3157265782356262,
-0.21092326939105988,
-0.06904340535402298,
0.1923021376132965,
0.44821733236312866,
0.08680576831102371,
-0.15834131836891174,
-0.33632540702819824,
-0.04875066876411438,
0.14557303488254547,
-0.2966171205043793,
0.15951664745807648,
-0.001718440093100071,
-0.025846119970083237,
-0.5416109561920166,
0.35250329971313477,
0.09738299250602722,
0.14941714704036713,
0.1625468134880066,
-0.1580301970243454,
0.5439473986625671,
-0.28756022453308105,
-0.07155550271272659,
-0.23772121965885162,
-0.01241057738661766,
0.24822989106178284,
0.12524788081645966,
0.16285380721092224,
-0.48720812797546387,
0.10428844392299652,
0.2251821756362915,
0.15684151649475098,
-0.10098779946565628,
-0.17592331767082214,
0.37466996908187866,
-0.2976715564727783,
-0.022787349298596382,
0.2849734425544739,
0.6121921539306641,
0.21568574011325836,
-0.04234536364674568,
-0.06625542789697647,
0.09452873468399048,
0.02728525549173355,
0.14625979959964752,
0.0978715717792511,
-0.06078813597559929,
0.39777302742004395,
0.26388877630233765,
0.13706840574741364,
-0.13897845149040222,
-0.03562002629041672,
0.3215385973453522,
0.12244854122400284,
-0.3997764587402344,
0.0922047346830368,
-0.39643946290016174,
0.23209670186042786,
-0.23659907281398773,
0.06183193251490593,
-0.15014109015464783,
-0.15967580676078796,
-0.043888695538043976,
0.4857655167579651,
-0.1360950767993927,
-0.10952509194612503,
-0.26931288838386536,
0.15184491872787476,
-0.22240641713142395,
-0.13894949853420258,
-0.15029391646385193,
-0.11714410036802292,
-0.1638704538345337,
-0.041923899203538895,
0.19952142238616943,
0.44578421115875244,
0.07373237609863281,
-0.07129847258329391,
-0.3593810200691223,
-0.24086788296699524,
-0.40314802527427673,
0.044488731771707535,
0.11097745597362518,
0.26458320021629333,
0.2255554050207138,
-0.04434426128864288,
0.36284762620925903,
-0.44931355118751526,
0.26861703395843506,
-0.06199561804533005,
-0.07722829282283783,
0.17970716953277588,
-0.15977555513381958,
-0.11767280101776123,
0.009850375354290009,
-0.41362830996513367,
-0.1536097377538681,
-0.21570926904678345,
-0.09138444066047668,
0.1299586147069931,
-0.028515420854091644,
-0.046226534992456436,
-0.09524092078208923,
-0.19129545986652374,
0.03118310123682022,
0.20117011666297913,
-0.2573031783103943,
-0.28354135155677795,
0.16045424342155457,
-0.3279156982898712,
-0.2701990306377411,
0.08939900994300842,
-0.08568310737609863,
0.28159207105636597,
0.20788316428661346,
-0.174172043800354,
-0.21914929151535034,
0.08380649983882904,
0.04186747595667839,
-0.38160160183906555,
-0.4460963010787964,
0.26747798919677734,
0.009195411577820778,
0.0674276351928711,
-0.1831529140472412,
0.009794499725103378,
0.1613752841949463,
0.19814130663871765,
0.10032607614994049,
-0.33434203267097473,
0.41438281536102295,
-0.015208825469017029,
0.465837299823761,
0.2735655903816223,
0.22613538801670074,
0.45618775486946106,
-0.13505768775939941,
0.3297729790210724,
-0.07764028757810593,
-0.207827627658844,
-0.17550411820411682,
0.05712214112281799,
0.09958404302597046,
0.5030729174613953,
-0.2147880494594574,
0.0312180295586586,
-0.14279372990131378,
-0.13935425877571106,
-0.16042682528495789,
-0.24407446384429932,
-0.020724130794405937,
-0.2187565267086029,
0.0869603231549263,
-0.0027024801820516586,
0.24034127593040466,
-0.17934566736221313,
0.08811932057142258,
0.08336125314235687,
0.26194411516189575,
-0.01634056121110916,
0.048102352768182755,
-0.2849145233631134,
0.38154804706573486,
0.3161107897758484,
0.029459185898303986,
-0.04616479575634003,
0.126409113407135,
0.1038200706243515,
0.02057882770895958,
0.17717204988002777,
-0.13126058876514435,
0.6252633929252625,
-0.25764256715774536,
0.19192418456077576,
0.14941416680812836,
-0.21363875269889832,
-0.43464088439941406,
-0.38135644793510437,
-0.17477837204933167,
0.06680386513471603,
0.33616289496421814,
0.7124685645103455,
-0.5195906162261963,
-0.38073378801345825,
0.16373714804649353,
0.05840180441737175,
-0.14784571528434753,
-0.2677086591720581,
-0.2687796652317047,
0.0872645154595375,
-0.13359880447387695,
-0.09757896512746811,
0.134134903550148,
0.5008934736251831,
-0.27784591913223267,
-0.07629545032978058,
-0.3331877589225769,
-0.004168545827269554,
0.1380087286233902,
0.22772979736328125,
0.3293808400630951,
-0.2990070879459381,
0.30764278769493103,
-0.1046428233385086,
0.12253618240356445,
0.4012717604637146,
0.6107589602470398,
-0.0616304837167263,
-0.730227530002594,
0.0924011692404747,
-0.17271780967712402,
0.006324000656604767,
0.19429785013198853,
-0.09333842992782593,
0.3171391785144806,
-0.4536239504814148,
-0.18060512840747833,
-0.1366979032754898,
-0.09144598990678787,
0.40302571654319763,
-0.40212979912757874,
0.10117745399475098,
-0.3541410267353058,
0.3702082931995392,
0.0061872657388448715,
-0.141251802444458,
-0.13002194464206696,
0.2137143313884735,
-0.3577594459056854,
0.7129172682762146,
-0.0678061917424202,
0.700099766254425,
0.11228939890861511,
-0.07379068434238434,
0.24559450149536133,
-0.3231523633003235,
0.3485555052757263,
-0.3163995146751404,
-0.10675351321697235,
-0.2020055204629898,
-0.23195424675941467,
0.03412178158760071,
-0.08256686478853226,
0.3356391191482544,
0.4648258090019226,
-0.0657229870557785,
0.36263513565063477,
-0.1786143183708191,
0.4932381510734558,
0.09087582677602768,
0.26392459869384766,
0.07514689117670059,
0.12532149255275726,
-0.48454922437667847,
-0.01655934751033783,
0.14589619636535645,
-0.11655490100383759,
0.0055992696434259415,
-0.32655978202819824,
-0.33556243777275085,
-0.033598192036151886,
-0.10278917104005814,
0.3898022770881653,
-0.0162997767329216,
0.1745924949645996,
0.25402480363845825,
-0.1430094987154007,
0.134330153465271,
0.3809874355792999,
0.17768815159797668,
0.06577657163143158,
-0.33589792251586914,
0.05377097427845001,
0.16920194029808044,
-0.18203774094581604,
-0.16894683241844177,
-0.0389389805495739,
0.14432185888290405,
0.011869862675666809,
-0.0916733518242836,
0.07420701533555984,
-0.1759844571352005,
-0.06425061821937561,
-0.1685119867324829,
0.04229532927274704,
0.3280337452888489,
-0.5279552340507507,
-0.5010862946510315,
-0.1714208722114563,
0.34552881121635437,
-0.24563924968242645,
0.032641150057315826,
0.004443787038326263,
-0.09725398570299149,
-0.08084476739168167,
-0.16531148552894592,
-0.13565370440483093,
-0.04678190127015114,
0.26409560441970825,
-0.06262021511793137,
0.17741771042346954,
0.32885506749153137,
-0.3130809962749481,
-0.08548182249069214,
-0.13125646114349365,
-0.22424888610839844,
0.09049452841281891,
-0.4073905050754547,
0.11451929807662964,
0.15389053523540497,
0.09417776763439178,
0.08274853974580765,
0.06574492156505585,
0.22285248339176178,
-0.08283696323633194,
0.2312217801809311,
-0.475574791431427,
0.10480944067239761,
-0.012224756181240082,
-0.10978822410106659,
-0.043996650725603104,
0.20800554752349854,
0.09178952872753143,
-0.2521716356277466,
0.24939292669296265,
-0.20520073175430298,
0.35705333948135376,
-0.07693459093570709,
0.14562775194644928,
0.3636834919452667,
-0.1595023274421692,
-0.24132104218006134,
0.017230873927474022,
0.1129116415977478,
-0.20118366181850433,
0.15988148748874664,
-0.09250693023204803,
-0.3109321594238281,
0.19494181871414185,
0.2753705382347107,
0.3685334324836731,
-0.1292990744113922,
-0.21414288878440857,
-0.07972444593906403,
-0.12475660443305969,
0.24720162153244019,
0.3593156039714813,
0.034764669835567474,
0.02015603706240654,
0.43915319442749023,
0.3055587708950043,
-0.8808912634849548,
0.2889006435871124,
-0.2532942295074463,
-0.1839042752981186,
-0.22505740821361542,
0.04014066606760025,
-0.23702900111675262,
-0.009366348385810852,
-0.16473530232906342,
0.03477192670106888,
0.18085408210754395,
0.08568720519542694,
0.3137178122997284,
-0.00667242705821991,
0.21226277947425842,
0.4641919732093811,
-0.07173214107751846,
0.4485442340373993,
-0.16717581450939178,
0.051939159631729126,
0.08038879185914993,
0.11553555727005005,
-0.25415265560150146,
-0.06938314437866211,
0.20405913889408112,
-0.08428674191236496,
-0.03684400022029877,
0.22776947915554047,
0.3903733491897583,
-0.17433547973632812,
0.0978737622499466,
0.029384799301624298,
0.29870176315307617,
0.2836666703224182,
0.501598596572876,
0.583599865436554,
-0.2000722736120224,
0.03571136295795441,
0.03391116484999657,
0.008809668943285942,
-0.025116868317127228,
0.29283833503723145,
0.1276140660047531,
0.3049458861351013,
-0.24054476618766785,
-0.33269280195236206,
0.09514352679252625,
-0.41950806975364685,
0.09749425947666168,
0.12755802273750305,
0.39383745193481445,
-0.002720944583415985,
-0.2345191240310669,
0.2092800736427307,
0.036583319306373596,
-0.14110949635505676,
-0.26528477668762207,
0.2574252486228943,
-0.09590832144021988,
-0.265283465385437,
0.047874175012111664,
-0.24726837873458862,
-0.3160061836242676,
0.14946295320987701,
0.02636186219751835,
0.13487043976783752,
-0.16979369521141052,
0.1660657525062561,
-0.048775508999824524,
0.01796659268438816,
-0.26342204213142395,
0.10145120322704315,
0.21071642637252808,
-0.31263038516044617,
0.3520486056804657,
-0.15851019322872162,
-0.12732505798339844,
0.5540922284126282,
-0.08536723256111145,
0.31376275420188904,
0.4101293385028839,
-0.06153974309563637,
-0.28364136815071106,
0.2764701545238495,
-0.05919748544692993,
0.09137232601642609,
0.21808688342571259,
-0.07730327546596527,
0.11788789927959442,
0.3479626476764679,
0.04958680272102356,
-0.16850419342517853,
-0.12836751341819763,
0.10334845632314682,
0.06642040610313416,
-0.6544514298439026,
0.5064190626144409,
0.20514632761478424,
0.17276060581207275,
0.0345916822552681,
0.062240537256002426,
-0.04802671819925308,
-0.4960338771343231,
-0.24405518174171448,
0.31346508860588074,
0.1551000475883484,
0.1062476858496666,
0.029577698558568954,
0.2948894798755646,
0.04254760965704918,
0.12573513388633728,
-0.2692371606826782,
-0.29973113536834717,
-0.0191681906580925,
-0.742929995059967,
0.34629812836647034,
-0.3069216012954712,
0.07836366444826126,
0.21576273441314697,
0.32026997208595276,
0.12761469185352325,
-0.09766918420791626,
-0.06446446478366852,
0.10650421679019928,
0.1268789917230606,
0.34554561972618103,
-0.2664644718170166,
-0.029653023928403854,
-0.09705886244773865,
-0.22721673548221588,
-0.0000977739691734314,
-0.3470492959022522,
0.12379802763462067,
0.29145389795303345,
0.03705818951129913,
-0.015624966472387314,
-0.11827566474676132,
0.20232506096363068,
-0.15336973965168,
0.06616662442684174,
-0.0034102294594049454,
0.46558839082717896,
-0.06383911520242691,
-0.2366759330034256,
-0.2531373202800751,
-0.0995182991027832,
-0.20913691818714142,
0.4898689389228821,
0.09297535568475723,
-0.03767750784754753,
-0.1104559451341629,
-0.1817290037870407,
-0.19013597071170807,
0.02550937794148922,
-0.17656491696834564,
-0.09743323177099228,
-0.4729551374912262,
0.13645057380199432,
-0.04666515439748764,
0.274753212928772,
0.16610054671764374,
-0.015077725052833557,
-0.17917001247406006,
0.2556360065937042,
-0.0562056303024292,
-0.28642183542251587,
0.32114332914352417,
-0.2456641048192978,
-0.24997471272945404,
-0.35382941365242004,
0.4993320107460022,
-0.11504285782575607,
0.02868022955954075,
-0.39924976229667664,
0.05706094950437546,
0.3902982175350189,
0.057297807186841965,
0.2944297790527344,
-0.07449693977832794,
0.35750606656074524,
-0.12871231138706207,
-0.10809604823589325,
-0.05793848633766174,
0.10563673824071884,
0.06229744851589203,
0.10110583901405334,
-0.12871399521827698
] |
https://github.com/huggingface/datasets/issues/7447
|
Epochs shortened after resuming mid-epoch with Iterable dataset+StatefulDataloader(persistent_workers=True)
|
Thanks for reporting ! Maybe we should store the epoch in the state_dict, and then when the dataset is iterated on again after setting a new epoch it should restart from scratch instead of resuming ? wdyt ?
|
### Describe the bug
When `torchdata.stateful_dataloader.StatefulDataloader(persistent_workers=True)` the epochs after resuming only iterate through the examples that were left in the epoch when the training was interrupted. For example, in the script below training is interrupted on step 124 (epoch 1) when 3 batches are left. Then after resuming, the rest of epochs (2 and 3) only iterate through these 3 batches.
### Steps to reproduce the bug
Run the following script with and with PERSISTENT_WORKERS=true.
```python
# !/usr/bin/env python3
# torch==2.5.1
# datasets==3.3.2
# torchdata>=0.9.0
import datasets
import pprint
from torchdata.stateful_dataloader import StatefulDataLoader
import os
PERSISTENT_WORKERS = (
os.environ.get("PERSISTENT_WORKERS", "False").lower() == "true"
)
# PERSISTENT_WORKERS = True # Incorrect resume
# ds = datasets.load_from_disk("dataset").to_iterable_dataset(num_shards=4)
def generator():
for i in range(128):
yield {"x": i}
ds = datasets.Dataset.from_generator(
generator, features=datasets.Features({"x": datasets.Value("int32")})
).to_iterable_dataset(num_shards=4)
dl = StatefulDataLoader(
ds, batch_size=2, num_workers=2, persistent_workers=PERSISTENT_WORKERS
)
global_step = 0
epoch = 0
ds_state_dict = None
state_dict = None
resumed = False
while True:
if epoch >= 3:
break
if state_dict is not None:
dl.load_state_dict(state_dict)
state_dict = None
ds_state_dict = None
resumed = True
print("resumed")
for i, batch in enumerate(dl):
print(f"epoch: {epoch}, global_step: {global_step}, batch: {batch}")
global_step += 1 # consume datapoint
# simulate error
if global_step == 124 and not resumed:
ds_state_dict = ds.state_dict()
state_dict = dl.state_dict()
print("checkpoint")
print("ds_state_dict")
pprint.pprint(ds_state_dict)
print("dl_state_dict")
pprint.pprint(state_dict)
break
if state_dict is None:
ds.set_epoch(epoch)
epoch += 1
```
The script checkpoints when there are three batches left in the second epoch. After resuming, only the last three batches are repeated in the rest of the epochs.
If it helps, following are the two state_dicts for the dataloader save at the same step with the two settings. The left one is for `PERSISTENT_WORKERS=False`

### Expected behavior
All the elements in the dataset should be iterated through in the epochs following the one where we resumed. The expected behavior can be seen by setting `PERSISTENT_WORKERS=False`.
### Environment info
torch==2.5.1
datasets==3.3.2
torchdata>=0.9.0
| 38 |
Epochs shortened after resuming mid-epoch with Iterable dataset+StatefulDataloader(persistent_workers=True)
### Describe the bug
When `torchdata.stateful_dataloader.StatefulDataloader(persistent_workers=True)` the epochs after resuming only iterate through the examples that were left in the epoch when the training was interrupted. For example, in the script below training is interrupted on step 124 (epoch 1) when 3 batches are left. Then after resuming, the rest of epochs (2 and 3) only iterate through these 3 batches.
### Steps to reproduce the bug
Run the following script with and with PERSISTENT_WORKERS=true.
```python
# !/usr/bin/env python3
# torch==2.5.1
# datasets==3.3.2
# torchdata>=0.9.0
import datasets
import pprint
from torchdata.stateful_dataloader import StatefulDataLoader
import os
PERSISTENT_WORKERS = (
os.environ.get("PERSISTENT_WORKERS", "False").lower() == "true"
)
# PERSISTENT_WORKERS = True # Incorrect resume
# ds = datasets.load_from_disk("dataset").to_iterable_dataset(num_shards=4)
def generator():
for i in range(128):
yield {"x": i}
ds = datasets.Dataset.from_generator(
generator, features=datasets.Features({"x": datasets.Value("int32")})
).to_iterable_dataset(num_shards=4)
dl = StatefulDataLoader(
ds, batch_size=2, num_workers=2, persistent_workers=PERSISTENT_WORKERS
)
global_step = 0
epoch = 0
ds_state_dict = None
state_dict = None
resumed = False
while True:
if epoch >= 3:
break
if state_dict is not None:
dl.load_state_dict(state_dict)
state_dict = None
ds_state_dict = None
resumed = True
print("resumed")
for i, batch in enumerate(dl):
print(f"epoch: {epoch}, global_step: {global_step}, batch: {batch}")
global_step += 1 # consume datapoint
# simulate error
if global_step == 124 and not resumed:
ds_state_dict = ds.state_dict()
state_dict = dl.state_dict()
print("checkpoint")
print("ds_state_dict")
pprint.pprint(ds_state_dict)
print("dl_state_dict")
pprint.pprint(state_dict)
break
if state_dict is None:
ds.set_epoch(epoch)
epoch += 1
```
The script checkpoints when there are three batches left in the second epoch. After resuming, only the last three batches are repeated in the rest of the epochs.
If it helps, following are the two state_dicts for the dataloader save at the same step with the two settings. The left one is for `PERSISTENT_WORKERS=False`

### Expected behavior
All the elements in the dataset should be iterated through in the epochs following the one where we resumed. The expected behavior can be seen by setting `PERSISTENT_WORKERS=False`.
### Environment info
torch==2.5.1
datasets==3.3.2
torchdata>=0.9.0
Thanks for reporting ! Maybe we should store the epoch in the state_dict, and then when the dataset is iterated on again after setting a new epoch it should restart from scratch instead of resuming ? wdyt ?
|
[
-0.4715934693813324,
-0.18919697403907776,
-0.08230707049369812,
0.24805276095867157,
0.4071238040924072,
-0.13080044090747833,
0.2909560799598694,
0.09845782816410065,
-0.5329226851463318,
0.14724260568618774,
0.19084587693214417,
0.38357385993003845,
-0.02379915863275528,
-0.4059109389781952,
-0.09942248463630676,
-0.13176043331623077,
0.14091847836971283,
0.18104493618011475,
-0.1014246791601181,
-0.1640455722808838,
-0.07342049479484558,
-0.10841691493988037,
-0.37968504428863525,
-0.19356964528560638,
-0.25114771723747253,
0.05090439319610596,
-0.09701021760702133,
0.22416463494300842,
0.39455872774124146,
-0.382730096578598,
0.3257579803466797,
-0.10971769690513611,
0.001676999032497406,
0.40622231364250183,
-0.00011391434236429632,
-0.043420545756816864,
0.15013036131858826,
-0.030875196680426598,
-0.4956001043319702,
0.1221790537238121,
0.2331254780292511,
-0.06969262659549713,
0.314560204744339,
-0.20234277844429016,
-0.1916581690311432,
-0.06592122465372086,
-0.05763322114944458,
-0.3471551537513733,
0.4287067651748657,
0.02522355690598488,
0.19970515370368958,
0.4217540919780731,
-0.5632212162017822,
-0.2948366403579712,
0.07477585226297379,
-0.060878634452819824,
0.06853431463241577,
0.1500927358865738,
0.28910690546035767,
0.014412658289074898,
-0.21240422129631042,
0.30794721841812134,
0.029572216793894768,
0.3233068883419037,
-0.08223693817853928,
-0.2117563635110855,
-0.24981364607810974,
-0.19879989326000214,
0.14257749915122986,
0.23679381608963013,
0.3939564526081085,
-0.09755659848451614,
-0.16406747698783875,
-0.2995263338088989,
0.16530169546604156,
-0.492837131023407,
0.03113163262605667,
0.055278480052948,
-0.058781545609235764,
0.07521235197782516,
0.0037577960174530745,
0.3117257356643677,
-0.06238876283168793,
0.03876510635018349,
0.05259320139884949,
0.24976639449596405,
0.021208330988883972,
0.1413431465625763,
-0.19183936715126038,
0.19905708730220795,
0.5159233212471008,
0.09886864572763443,
0.3125898241996765,
0.10525309294462204,
-0.2214651256799698,
-0.050002653151750565,
-0.19913020730018616,
-0.1087392047047615,
0.18226668238639832,
0.16085657477378845,
-0.12234058976173401,
0.1709977090358734,
0.12906739115715027,
-0.15545156598091125,
-0.05095406249165535,
0.04529173672199249,
0.032247405499219894,
0.12637820839881897,
0.31675809621810913,
-0.14694416522979736,
-0.04312970116734505,
-0.11098947376012802,
-0.08995047956705093,
-0.3558145761489868,
0.3760332465171814,
0.19785505533218384,
-0.2063291370868683,
-0.05657368525862694,
-0.5072538256645203,
0.09266021847724915,
-0.4848492741584778,
-0.06005389243364334,
0.009890200570225716,
0.24211478233337402,
-0.04262268543243408,
0.2059306502342224,
0.04294373840093613,
-0.07128456234931946,
-0.29920855164527893,
-0.059295523911714554,
-0.1990053951740265,
-0.26579809188842773,
-0.41777628660202026,
0.31548672914505005,
0.09450909495353699,
-0.44309312105178833,
0.4603179395198822,
0.06064610183238983,
-0.32156556844711304,
-0.011380817741155624,
0.037565723061561584,
-0.02232126146554947,
0.26183661818504333,
-0.053520482033491135,
-0.06350723654031754,
0.1942983716726303,
0.07400202751159668,
0.24137355387210846,
0.06128496676683426,
0.16205981373786926,
0.1724877953529358,
-0.19316726922988892,
-0.13286729156970978,
0.1776132881641388,
0.021817006170749664,
0.22875194251537323,
-0.003143593668937683,
-0.13408301770687103,
0.6165016293525696,
0.06457455456256866,
0.45093587040901184,
-0.3819279074668884,
-0.13610407710075378,
-0.08028946071863174,
0.32684221863746643,
0.31121334433555603,
-0.11579689383506775,
-0.1785534918308258,
0.2747497260570526,
-0.09053605794906616,
0.18536902964115143,
0.34491273760795593,
-0.04366787150502205,
0.2698492109775543,
-0.32188156247138977,
-0.24417024850845337,
-0.06309343129396439,
-0.04324446991086006,
-0.2868956923484802,
0.020763009786605835,
-0.07969651371240616,
0.26588329672813416,
-0.27229276299476624,
0.03445301577448845,
0.3378344178199768,
-0.0645371526479721,
0.12770907580852509,
0.27865874767303467,
-0.09320388734340668,
-0.06623706221580505,
-0.3897618353366852,
0.07564812153577805,
0.07665354758501053,
0.0825204998254776,
0.32015296816825867,
-0.1562616229057312,
-0.10504169017076492,
-0.1394348293542862,
0.5179376006126404,
0.06240885332226753,
0.270008385181427,
0.03629747033119202,
-0.29191967844963074,
0.06580974161624908,
0.14346234500408173,
-0.1376791000366211,
-0.2760066092014313,
0.20029401779174805,
0.30563193559646606,
-0.11153291165828705,
0.11250269412994385,
0.07735751569271088,
0.041094109416007996,
0.04015825688838959,
-0.3137452006340027,
-0.39407333731651306,
0.06253071129322052,
0.06964373588562012,
0.11965629458427429,
0.18658262491226196,
0.1448817402124405,
-0.11476696282625198,
-0.31475889682769775,
0.16829632222652435,
-0.3634442985057831,
0.2796543538570404,
0.24791693687438965,
-0.11902579665184021,
-0.2636123299598694,
0.30445924401283264,
0.24405547976493835,
-0.1122843325138092,
-0.27719128131866455,
0.27243465185165405,
-0.17915013432502747,
0.31726178526878357,
-0.19821760058403015,
-0.043749287724494934,
0.0769021138548851,
-0.0455075204372406,
0.14133085310459137,
0.3137395977973938,
0.03562217578291893,
-0.28152644634246826,
0.13002386689186096,
0.2324032485485077,
0.15913094580173492,
0.27865439653396606,
-0.1053657978773117,
0.07834573090076447,
0.3932532072067261,
-0.10534961521625519,
-0.2760598659515381,
-0.09325078129768372,
0.2670239806175232,
0.08122391998767853,
0.15744508802890778,
-0.13894641399383545,
-0.7241177558898926,
0.12286630272865295,
0.1754508912563324,
-0.20419923961162567,
-0.24471232295036316,
0.09550150483846664,
-0.5937849879264832,
-0.029615117236971855,
0.15786202251911163,
-0.03015803173184395,
0.40408194065093994,
0.12387324869632721,
0.2614823281764984,
-0.18082627654075623,
0.08337139338254929,
-0.3631349802017212,
0.23789280652999878,
0.27886468172073364,
0.2327931970357895,
0.377359539270401,
0.23887518048286438,
0.08917376399040222,
-0.18967345356941223,
-0.3023685812950134,
-0.18616384267807007,
0.08005917817354202,
-0.17056414484977722,
0.26674720644950867,
-0.481780469417572,
-0.18425238132476807,
-0.2943077087402344,
-0.3799613416194916,
0.13463328778743744,
-0.18389892578125,
-0.0024155043065547943,
0.3140679895877838,
-0.07462504506111145,
0.5493572354316711,
0.18867722153663635,
0.18702846765518188,
0.4504377841949463,
0.23975326120853424,
-0.05757993832230568,
-0.12135845422744751,
-0.1348852813243866,
0.03070928528904915,
0.1048499047756195,
-0.1847570240497589,
0.3534628450870514,
-0.16835713386535645,
-0.4439087510108948,
-0.3731881380081177,
-0.004187189042568207,
0.2511308789253235,
-0.03606710582971573,
0.14288374781608582,
-0.0025140345096588135,
-0.024622485041618347,
0.11679999530315399,
0.09955387562513351,
0.17606937885284424,
-0.23438747227191925,
-0.05025572329759598,
0.06089045852422714,
-0.26925739645957947,
-0.08047623932361603,
-0.10527199506759644,
-0.07523532956838608,
-0.23675431311130524,
-0.14995531737804413,
0.011464886367321014,
0.10910631716251373,
-0.09656016528606415,
0.1315658688545227,
0.05367760732769966,
-0.030118778347969055,
0.13423259556293488,
-0.213618203997612,
-0.3288883566856384,
-0.44452786445617676,
0.22401951253414154,
-0.39600715041160583,
-0.11529920995235443,
-0.06451922655105591,
-0.49886494874954224,
0.3486369252204895,
0.20982815325260162,
-0.46982574462890625,
-0.10250713676214218,
-0.12938930094242096,
0.04051079973578453,
-0.3917367160320282,
-0.13201531767845154,
0.28044721484184265,
-0.19785496592521667,
-0.06064356118440628,
-0.024061376228928566,
0.05948340520262718,
0.16262754797935486,
-0.14997297525405884,
0.18680673837661743,
-0.21489465236663818,
0.45409494638442993,
0.13949152827262878,
0.9098092913627625,
0.2482410967350006,
-0.1678447127342224,
-0.017430827021598816,
-0.17920613288879395,
-0.07645468413829803,
-0.2599654793739319,
-0.1279933750629425,
0.04960183426737785,
-0.24800899624824524,
-0.024926744401454926,
0.08704178035259247,
-0.0338868722319603,
0.01982574537396431,
0.36497095227241516,
-0.1649201363325119,
-0.060591623187065125,
-0.3105325400829315,
0.09943461418151855,
-0.39619290828704834,
0.333127498626709,
0.07174380123615265,
0.4351111352443695,
-0.20192021131515503,
-0.058394841849803925,
-0.07136432081460953,
-0.08092546463012695,
0.30643367767333984,
-0.15940828621387482,
-0.05160552263259888,
0.1817513257265091,
-0.46387940645217896,
0.015864111483097076,
0.1874615103006363,
0.24524490535259247,
0.3829859793186188,
-0.22688105702400208,
0.2746780514717102,
0.3267455995082855,
0.6222115755081177,
0.2805662155151367,
0.16366389393806458,
0.16734029352664948,
-0.23639856278896332,
-0.4895831346511841,
-0.33017802238464355,
0.10392943024635315,
0.07380115240812302,
0.25803449749946594,
0.38684090971946716,
0.04105357080698013,
-0.030103154480457306,
0.2336810827255249,
0.16225874423980713,
-0.22556331753730774,
-0.15571977198123932,
0.16345450282096863,
0.005458232015371323,
-0.23191168904304504,
0.3926125168800354,
-0.07726222276687622,
-0.11033951491117477,
-0.39610958099365234,
-0.27036815881729126,
-0.098721943795681,
0.014033108949661255,
-0.21662841737270355,
0.2524603605270386,
0.22922271490097046,
-0.38169193267822266,
0.490400493144989,
0.21161812543869019,
0.0007858313620090485,
0.6647288203239441,
0.3443624973297119,
-0.18054422736167908,
0.0057828351855278015,
0.24291855096817017,
-0.2130889743566513,
0.08893722295761108,
0.4070160686969757,
-0.21632125973701477,
0.27805811166763306,
-0.20612779259681702,
0.4042261242866516,
-0.26078909635543823,
0.0320127047598362,
0.06415913999080658,
0.22278617322444916,
-0.3675044775009155,
-0.49183493852615356,
0.05661899596452713,
-0.02728273719549179,
0.007712759077548981,
0.014887548983097076,
-0.5683982372283936,
-0.10988077521324158,
0.30117374658584595,
0.2639508843421936,
0.7186457514762878,
0.2791685461997986,
0.27956414222717285,
0.3560207486152649,
0.1605217009782791,
0.05780012160539627,
0.23216389119625092,
0.3113979697227478,
-0.25867295265197754,
-0.27791500091552734,
0.18265002965927124,
-0.07154873013496399,
-0.295617014169693,
-0.14924395084381104,
-0.07871652394533157,
0.2822123169898987,
0.18954460322856903,
0.011295173317193985,
-0.20241929590702057,
-0.032286424189805984,
-0.17456716299057007,
-0.3300095200538635,
0.07664868235588074,
0.11584204435348511,
0.24128887057304382,
0.2617426812648773,
-0.08204787969589233,
0.0380038246512413,
0.11250992119312286,
-0.07410581409931183,
0.05115959048271179,
0.17261749505996704,
-0.3560922145843506,
0.07790391147136688,
0.09108441323041916,
-0.7689229249954224,
0.06900855898857117,
0.047726862132549286,
0.23716606199741364,
-0.19418123364448547,
0.10669168084859848,
0.08018265664577484,
0.22986027598381042,
0.13961414992809296,
-0.15793192386627197,
-0.2511333227157593,
0.5759854912757874,
-0.0076606012880802155,
0.14439967274665833,
-0.28688326478004456,
0.08176150172948837,
-0.010745923966169357,
0.03926345705986023,
0.21065212786197662,
0.2261800616979599,
-0.23158657550811768,
0.02387933060526848,
0.0026182755827903748,
-0.08329281955957413,
-0.48796844482421875,
0.09911279380321503,
0.2028168886899948,
-0.05158865079283714,
0.302497923374176,
-0.23553024232387543,
-0.05439990758895874,
-0.2097320854663849,
0.4931778907775879,
0.08073697984218597,
0.13623668253421783,
0.5554955005645752,
0.3404099941253662,
-0.35904085636138916,
-0.1344698965549469,
-0.00016155093908309937,
0.26606565713882446,
-0.6055054068565369,
0.270520955324173,
-0.24988968670368195,
0.4521430730819702,
0.12284970283508301,
0.23470835387706757,
-0.20799793303012848,
0.07576426863670349,
-0.30666109919548035,
-0.05919838324189186,
-0.3183773159980774,
-0.15973736345767975,
-0.12197518348693848,
0.4138892590999603,
-0.19276243448257446,
0.6376399397850037,
0.03532491624355316,
0.06358652561903,
-0.2855731248855591,
0.15019968152046204,
-0.025619756430387497,
0.361733078956604,
-0.05772102624177933,
-0.29337283968925476,
-0.007641304284334183,
0.07112769782543182,
0.0232777651399374,
0.5000757575035095,
-0.08434075862169266,
-0.2273777425289154,
-0.2913225591182709,
0.10085315257310867,
0.0740751251578331,
-0.32783299684524536,
0.06703445315361023,
-0.02963881939649582,
0.21644151210784912,
-0.3281290829181671,
0.2487563192844391,
0.1918688714504242,
0.10721186548471451,
0.10273498296737671,
0.3140832185745239,
0.4030354619026184,
0.23633860051631927,
0.10198170691728592,
-0.20494136214256287,
-0.04850354790687561,
0.1502746343612671,
0.17248603701591492,
-0.1786046028137207,
0.004261374473571777,
-0.23234529793262482,
0.06802036613225937,
0.4231519103050232,
0.014050263911485672,
0.356452077627182,
-0.13085930049419403,
-0.32186052203178406,
0.12943917512893677,
0.25852540135383606,
0.15771286189556122,
-0.2466970980167389,
-0.10057935118675232,
0.3280476927757263,
0.22635678946971893,
-0.22204448282718658,
0.06790266931056976,
-0.14121635258197784,
-0.033095188438892365,
0.12126675248146057,
0.20387038588523865,
0.10647282004356384,
-0.42781347036361694,
-0.034165769815444946,
0.07880766689777374,
0.20016145706176758,
-0.39813870191574097,
-0.031374964863061905,
0.11322876811027527,
-0.009906947612762451,
-0.02829894796013832,
0.28193745017051697,
0.1371997743844986,
0.26720690727233887,
0.27518290281295776,
0.3220771849155426,
0.48946818709373474,
0.29935675859451294,
-0.08747455477714539,
-0.14121201634407043,
-0.5163379907608032,
-0.32623693346977234,
-0.007057413458824158,
-0.1723017692565918,
0.12095235288143158,
0.05223368480801582,
0.111244797706604,
-0.12012077122926712,
-0.17786602675914764,
-0.10512985289096832,
0.1739783138036728,
-0.18722766637802124,
-0.019395116716623306,
0.08756794780492783,
-0.13452191650867462,
0.25634491443634033,
-0.035657014697790146,
-0.09062428772449493,
-0.043758027255535126,
0.1726997345685959,
-0.03441770374774933,
-0.27070319652557373,
-0.05767317861318588,
-0.04210088402032852,
0.11136062443256378,
0.08471433073282242,
-0.14248491823673248,
-0.09933822602033615,
0.34689873456954956,
0.05985426902770996,
-0.3891729712486267,
0.19067634642124176,
0.30765628814697266,
0.027784833684563637,
-0.035195138305425644,
0.06258524954319,
0.17000949382781982,
0.08258400112390518,
-0.044907085597515106,
0.18308378756046295,
-0.11222130060195923,
-0.0654027909040451,
0.23882617056369781,
0.17884190380573273,
-0.18932336568832397,
0.39753660559654236,
0.30523645877838135,
0.15097330510616302,
-0.4681912660598755,
-0.12252645939588547,
0.16080009937286377,
-0.21227112412452698,
-0.30601075291633606,
-0.03970161825418472,
-0.15944308042526245,
0.05859057232737541,
0.0864163190126419,
-0.360242635011673,
0.23140066862106323,
-0.1843758374452591,
0.07144192606210709,
-0.38949406147003174,
0.17665641009807587,
0.2708691656589508,
0.20013487339019775,
-0.25327610969543457,
-0.32618650794029236,
-0.04797474294900894,
0.1436769962310791,
-0.15062667429447174,
0.3558759391307831,
0.09809552878141403,
0.19032998383045197,
0.01717231422662735,
-0.08894657343626022,
0.10585350543260574,
-0.2659863829612732,
-0.111052006483078,
0.4591527283191681,
-0.17007936537265778,
-0.20904843509197235,
-0.06811773777008057,
-0.17298144102096558,
0.22628849744796753,
-0.17950159311294556,
-0.09966681897640228,
-0.29120495915412903,
0.1149401143193245,
0.00015258602797985077,
-0.05168116092681885,
0.18623487651348114,
0.21992909908294678,
0.45792156457901,
0.23000064492225647,
-0.15236333012580872,
-0.09653942286968231,
-0.07252763211727142,
-0.2693262994289398,
-0.10523919016122818,
-0.23650966584682465,
0.055792465806007385,
0.124024897813797,
0.2962511479854584,
-0.120356485247612,
-0.08066059648990631,
-0.1741655021905899,
0.13156214356422424,
0.2722562551498413,
0.43042221665382385,
-0.34777966141700745,
0.3529949188232422,
-0.2836749851703644,
0.24288274347782135,
0.12622757256031036,
0.2665897607803345,
0.017004050314426422,
0.22512631118297577,
-0.22286461293697357,
-0.42569828033447266,
0.24083545804023743,
-0.4652804434299469,
-0.19277963042259216,
-0.3327294886112213,
0.02049340307712555,
0.09509529173374176,
0.14559485018253326,
-0.39545243978500366,
-0.15346166491508484,
0.3914812207221985,
-0.15145394206047058,
-0.14018034934997559,
0.22011667490005493,
0.17288319766521454,
0.13354483246803284,
-0.24020493030548096,
0.3001229465007782,
0.16067257523536682,
-0.3149953782558441,
0.176426500082016,
-0.5237690806388855
] |
https://github.com/huggingface/datasets/issues/7447
| "Epochs shortened after resuming mid-epoch with Iterable dataset+StatefulDataloader(persistent_worke(...TRUNCATED) | "But why does this only happen when `persistent_workers=True`? I would expect it to work correctly e(...TRUNCATED) | "### Describe the bug\n\nWhen `torchdata.stateful_dataloader.StatefulDataloader(persistent_workers=T(...TRUNCATED) | 28 | "Epochs shortened after resuming mid-epoch with Iterable dataset+StatefulDataloader(persistent_worke(...TRUNCATED) | [-0.4715934693813324,-0.18919697403907776,-0.08230707049369812,0.24805276095867157,0.407123804092407(...TRUNCATED) |
End of preview.
README.md exists but content is empty.
- Downloads last month
- 8