title
stringclasses
312 values
author
stringclasses
138 values
date
stringclasses
263 values
local
stringclasses
312 values
tags
stringclasses
196 values
URL
stringclasses
312 values
chunk
stringlengths
7
30.6k
embedding
sequencelengths
768
768
Deploy GPT-J 6B for inference using Hugging Face Transformers and Amazon SageMaker
philschmid
January 11, 2022
gptj-sagemaker
partnerships, aws, guide, nlp
https://huggingface.co/blog/gptj-sagemaker
# Deploy GPT-J 6B for inference using Hugging Face Transformers and Amazon SageMaker Almost 6 months ago to the day, EleutherAI released GPT-J 6B, an open-source alternative to OpenAIs GPT-3. GPT-J 6B is the 6 billion parameter successor to EleutherAIs GPT-NEO family, a family of transformer-based language models based on the GPT architecture for text generation. EleutherAI's primary goal is to train a model that is equivalent in size to GPT⁠-⁠3 and make it available to the public under an open license. Over the last 6 months, GPT-J gained a lot of interest from Researchers, Data Scientists, and even Software Developers, but it remained very challenging to deploy GPT-J into production for real-world use cases and products. There are some hosted solutions to use GPT-J for production workloads, like the Hugging Face Inference API, or for experimenting using EleutherAIs 6b playground, but fewer examples on how to easily deploy it into your own environment. In this blog post, you will learn how to easily deploy GPT-J using Amazon SageMaker and the Hugging Face Inference Toolkit with a few lines of code for scalable, reliable, and secure real-time inference using a regular size GPU instance with NVIDIA T4 (~500$/m). But before we get into it, I want to explain why deploying GPT-J into production is challenging. ---
[ -0.04360431805253029, 0.007483981549739838, 0.037577468901872635, -0.01192410197108984, 0.04053672030568123, 0.05476274713873863, 0.03999969735741615, 0.02731635421514511, -0.010209781117737293, -0.003663926385343075, -0.03714088350534439, 0.029947593808174133, -0.017646629363298416, 0.11264677345752716, 0.021544039249420166, -0.07935973256826401, -0.014127029106020927, -0.013529695570468903, -0.0016123588429763913, 0.00020285736536607146, 0.06320493668317795, -0.0187874473631382, -0.031237756833434105, -0.00525166979059577, -0.03151629865169525, -0.04170271009206772, 0.019018281251192093, 0.025399016216397285, 0.006292063742876053, 0.05256432294845581, -0.07974560558795929, 0.007953792810440063, -0.012535830028355122, -0.017034633085131645, 0.024595782160758972, 0.045475564897060394, -0.15617959201335907, 0.035670921206474304, 0.05114099755883217, 0.0570395402610302, 0.0178434606641531, -0.01595589518547058, -0.06595546007156372, 0.03210226446390152, -0.024065712466835976, -0.0060901944525539875, -0.11269886791706085, 0.07556324452161789, -0.029642155393958092, 0.005785136949270964, -0.05761522799730301, 0.03448915481567383, 0.007266103755682707, -0.02005878835916519, 0.04215787351131439, 0.02093297801911831, 0.007774942088872194, -0.09732081741094589, 0.02703789994120598, -0.008516939356923103, 0.03134973347187042, -0.044302765280008316, 0.009997958317399025, 0.04774203896522522, 0.052264995872974396, -0.020037611946463585, 0.005634127650409937, -0.02261609025299549, -0.02291029319167137, -0.005802150350064039, -0.029276283457875252, -0.019181925803422928, -0.029188863933086395, -0.10077828168869019, -0.030825305730104446, 0.005308159161359072, 0.022194847464561462, 0.013889246620237827, 0.05717123672366142, 0.04003410041332245, -0.03450983017683029, -0.02449163980782032, -0.01781279221177101, 0.017136473208665848, 0.026332726702094078, 0.06412629038095474, 0.04344389960169792, -0.03855821117758751, -0.0419527068734169, 0.00014148865011520684, -0.035010866820812225, -0.10669315606355667, -0.032719820737838745, 0.01592622697353363, 0.02411394566297531, 0.0188748762011528, -0.021157072857022285, -0.014060869812965393, 0.05243033915758133, -0.015459432266652584, 0.02090546116232872, -0.03581196069717407, -0.015859153121709824, -0.0753936916589737, -0.04707420617341995, 0.06674371659755707, 0.02076428197324276, -0.10972582548856735, 0.033461228013038635, 0.007838419638574123, 0.05192343890666962, -0.031109772622585297, -0.0006738370866514742, 0.0755566656589508, -0.12798753380775452, 0.05879313126206398, -0.004845699295401573, -0.02728799171745777, 0.0035168244503438473, 0.029565712437033653, 0.05839937552809715, 0.08156375586986542, 0.01379417348653078, 0.034863147884607315, -0.004996344447135925, 0.08900438994169235, 0.024460555985569954, -0.016039006412029266, -0.012299686670303345, -0.012848179787397385, 0.050830990076065063, -0.12102095782756805, 0.04277448356151581, 0.00019894237630069256, 0.013656997121870518, -0.08373118937015533, 0.05403073504567146, -0.05877586081624031, 0.010414105840027332, 0.017513107508420944, -0.0335424430668354, 0.07140495628118515, 0.07040759176015854, -0.009318510070443153, 0.0456317700445652, 0.07357263565063477, -0.04244730621576309, 0.031134556978940964, 0.017316749319434166, 0.03276972100138664, -0.10024411976337433, 0.05000241845846176, -0.03515841066837311, -0.04429282993078232, 0.07949765771627426, 0.03830945864319801, -0.02582881599664688, -0.02018069103360176, -0.0767933651804924, -0.0648074597120285, -0.05095997452735901, -0.06432097405195236, 0.02522372454404831, -0.037221331149339676, -0.031164871528744698, -0.012457465752959251, 0.06894636899232864, 0.02084234170615673, 0.05661876127123833, 0.009132147766649723, 0.017657525837421417, -0.02807624079287052, 0.048747699707746506, 0.032691966742277145, 0.06310033053159714, -0.007548792287707329, 0.035304371267557144, 0.06869372725486755, 0.04276289790868759, -0.006576899439096451, -0.10064095258712769, 0.0359116867184639, 0.07755884528160095, 0.024814922362565994, 0.034710049629211426, -0.0785972997546196, -0.004198371432721615, -0.008208200335502625, 0.0017060476820915937, -0.030625224113464355, -0.03534400090575218, -0.006076216697692871, 0.06725195795297623, 0.0008482550620101392, 0.026350582018494606, -0.021598180755972862, -0.012610641308128834, 0.14166513085365295, 0.05068662390112877, 0.040317051112651825, 0.022256353870034218, -0.018999166786670685, 0.007620448712259531, 0.003577150171622634, -0.03034035488963127, 0.03234954923391342, 0.03323468193411827, -0.009319895878434181, 0.028065472841262817, 0.05380890518426895, 0.015851730480790138, -0.09706637263298035, 0.007378645706921816, -0.0644608736038208, -0.008218121714890003, -0.04567992314696312, -0.013231120072305202, -0.024455228820443153, 0.02821372076869011, 0.0415099561214447, 0.13814681768417358, -0.025600867345929146, -0.018706755712628365, -0.052382513880729675, -0.0003612067084759474, 0.02669014036655426, 0.08938392996788025, 0.05135504528880119, 0.019781339913606644, -0.07230736315250397, 0.006028853822499514, -0.06747602671384811, -0.001671917038038373, -0.008408315479755402, 0.03311363235116005, 0.006815607193857431, 0.009856674820184708, -0.0815027579665184, 0.030201388522982597, -0.05450970306992531, 0.012631713412702084, 0.04925084859132767, 0.02104427106678486, -0.002051309449598193, 0.04849252477288246, -0.025226620957255363, 0.08167729526758194, 0.07934591919183731, 0.018885472789406776, -0.01806717738509178, -0.1261364221572876, 0.06113166734576225, 0.017831383273005486, 0.013921486213803291, 0.012021276168525219, -0.0046136886812746525, 0.0013137226924300194, 0.010502342134714127, -0.017235994338989258, 0.05534642934799194, -0.004437790252268314, -0.01013790164142847, -0.011462625116109848, -0.008412200026214123, -0.014101147651672363, 0.014791343361139297, -0.0467212088406086, 0.0036532909143716097, 0.007035619579255581, -0.01877385564148426, 0.032776907086372375, -0.02492932789027691, 0.003501343308016658, -0.009339535608887672, -0.005653270520269871, 0.030723005533218384, 0.055633239448070526, -0.007350325118750334, -0.03573814406991005, 0.015731165185570717, 0.05090535059571266, -0.04440556839108467, -0.012298790737986565, 0.022660929709672928, 0.002956351265311241, -0.0029896744526922703, 0.02717173472046852, -0.016304800286889076, -0.011213043704628944, 0.01646057702600956, -0.0011793043231591582, 0.057177916169166565, 0.02647094428539276, -0.02197515405714512, -0.020001310855150223, -0.0042663030326366425, 0.0004864211950916797, -0.023711081594228745, -0.01063460297882557, 0.037726689130067825, 0.0037726256996393204, 0.0009867585031315684, -0.010822121985256672, -0.00850228313356638, -0.01464774552732706, 0.03802542760968208, 0.03423810377717018, 0.028972474858164787, -0.08755112439393997, -0.018627934157848358, -0.061717431992292404, 0.020328886806964874, -0.0014236187562346458, -0.03533443063497543, 0.06586156785488129, -0.00880445446819067, 0.016514677554368973, 0.04082099720835686, 0.017616236582398415, 0.02539348229765892, 0.00589665537700057, 0.002750616054981947, -0.017009317874908447, -0.005020865239202976, -0.007676554378122091, 0.005404568277299404, 0.026499230414628983, 0.037465181201696396, -0.02391607128083706, 0.024842888116836548, 0.007278034929186106, -0.018949322402477264, 0.026983585208654404, -0.03455875813961029, 0.02786046639084816, -0.015183595940470695, 0.00847115833312273, -0.008685873821377754, 0.01522931456565857, -0.027736898511648178, -0.008516989648342133, 0.02720845304429531, -0.036195285618305206, 0.016609393060207367, 0.02691532112658024, 0.02250411920249462, 0.01091835368424654, 0.031091710552573204, 0.02016943320631981, -0.03251488134264946, -0.0227906983345747, -0.017347265034914017, 0.038103554397821426, 0.03365025296807289, 0.007214231416583061, 0.003468722105026245, 0.024245338514447212, -0.048498690128326416, -0.03375939279794693, 0.030213702470064163, 0.012540541589260101, -0.013561231084167957, 0.024105718359351158, 0.014538077637553215, 0.008709440007805824, 0.027262480929493904, -0.0007756731356494129, -0.0016529218992218375, -0.05534340813755989, 0.02839428186416626, -0.01060112752020359, -0.018624378368258476, -0.017366576939821243, 0.04874034970998764, 0.030243223533034325, -0.02720794640481472, -0.012831556610763073, 0.05289177596569061, -0.04582745209336281, 0.047831904143095016, -0.00032682172604836524, -0.0007432983256876469, 0.016800666227936745, -0.0028396842535585165, -0.032258350402116776, -0.009709409438073635, 0.029226485639810562, 0.058007996529340744, -0.004941160790622234, -0.019951067864894867, 0.010885065421462059, -0.014437195844948292, 0.047648731619119644, 0.0011080269468948245, 0.015035834163427353, -0.040412694215774536, 0.023414038121700287, 0.013921686448156834, -0.013084353879094124, -0.018893614411354065, 0.021691856905817986, 0.00016038428293541074, -0.015106639824807644, -0.034937530755996704, 0.023738885298371315, 0.026519864797592163, 0.03853519633412361, -0.005354142282158136, -0.031484365463256836, -0.05088495835661888, 0.03705539181828499, -0.02067403867840767, -0.04510919749736786, 0.02137519046664238, -0.015238606370985508, -0.007356832269579172, -0.01142056006938219, 0.020164668560028076, 0.036466024816036224, -0.011483781971037388, 0.003212288487702608, 0.028484318405389786, -0.002860363107174635, 0.026219071820378304, -0.021403605118393898, -0.0075302934274077415, 0.003297341288998723, 0.04111989587545395, 0.007016826421022415, 0.01689811795949936, -0.05036056786775589, -0.033725421875715256, -0.00433014053851366, 0.007234039716422558, 0.010374926961958408, 0.012341238558292389, -0.018372537568211555, 0.01185679342597723, -0.006947503425180912, -0.010065668262541294, 0.01986151561141014, 0.019340069964528084, 0.016447436064481735, 0.006994090508669615, -0.07083733379840851, -0.015250780619680882, 0.011104373261332512, 0.021169859915971756, 0.005179155617952347, 0.014555727131664753, -0.004972446709871292, -0.05022686719894409, 0.03280598297715187, -0.01491408422589302, -0.018291451036930084, -0.004433332476764917, -0.06562965363264084, 0.020826706662774086, 0.06138557940721512, -0.020430482923984528, -0.05442073196172714, 0.0381469763815403, 0.03538957238197327, 0.04930569604039192, -0.009558462537825108, -0.016182970255613327, 0.029871374368667603, 0.03864647448062897, 0.010613533668220043, 0.006174185313284397, -0.038177307695150375, -0.012118159793317318, 0.037148136645555496, 0.022394152358174324, 0.0012825640151277184, -0.07643084228038788, -0.03609790280461311, 0.047364041209220886, -0.019331203773617744, 0.0016460955375805497, 0.013162040151655674, -0.020912842825055122, -0.004704221151769161, 0.06103895232081413, 0.058617111295461655, 0.019169289618730545, -0.015150992199778557, 0.026684537529945374, -0.04133981838822365, -0.0480520986020565, -0.033979449421167374, -0.025797639042139053, -0.03223525732755661, 0.004973461851477623, 0.04719214886426926, 0.0649748370051384, 0.005675112828612328, -0.001239555305801332, 0.00105595076456666, -0.03318369761109352, 0.01601131074130535, -0.04842401295900345, 0.00548176746815443, -0.01762559451162815, -0.011163974180817604, 0.027091480791568756, 0.017576789483428, -0.0001637288078200072, 0.013236611150205135, 0.03578266128897667, -0.015311606228351593, 0.004062280990183353, 0.026687024161219597, -0.03331105038523674, -0.026146691292524338, -0.02755841799080372, 0.01321498118340969, 0.012907722033560276, 0.010891455225646496, 0.012349488213658333, -0.023349590599536896, -0.036895930767059326, 0.016406189650297165, -0.038975149393081665, -0.021696582436561584, 0.0632728859782219, 0.02887427620589733, 0.04024301841855049, -0.012827238067984581, -0.046592485159635544, -0.012011169455945492, -0.03273608908057213, 0.03542027249932289, -0.004864800255745649, -0.019282544031739235, 0.016990216448903084, -0.007400729693472385, 0.019392406567931175, 0.009922691620886326, 0.007513231132179499, -0.028410429134964943, 0.04092544689774513, 0.010456174612045288, -0.018420835956931114, -0.040069665759801865, 0.018024660646915436, 0.07853979617357254, 0.022267954424023628, 0.0006994337309151888, -0.018630698323249817, -0.021186646074056625, -0.038907263427972794, -0.07898496836423874, 0.029436159878969193, 0.02633124776184559, -0.025551212951540947, -0.03183281049132347, -0.04652807116508484, -0.026409998536109924, -0.0025868904776871204, 0.039643947035074234, 0.02104060910642147, 0.037435855716466904, 0.03277552127838135, 0.02777704782783985, 0.02947765775024891, -0.014003860764205456, 0.015859195962548256, 0.013296660967171192, -0.027962036430835724, 0.021810567006468773, 0.03287430852651596, -0.002619433682411909, -0.034022241830825806, 0.003339816117659211, -0.03438211977481842, 0.02517072670161724, 0.026566509157419205, 0.03580097109079361, 0.005690841935575008, -0.02418394573032856, -0.007332674227654934, -0.03379876911640167, -0.011882301419973373, 0.014374461024999619, 0.05647020414471626, -0.007129867095500231, -0.0039023251738399267, 0.0073448000475764275, 0.026035264134407043, 0.0342525988817215, 0.00026011449517682195, -0.010291875340044498, -0.019178664311766624, 0.07787581533193588, 0.0003554363502189517, 0.04195570945739746, 0.05083122476935387, -0.026156511157751083, -0.016857987269759178, -0.007604194805026054, -0.02140236832201481, -0.07010775804519653, 0.009370018728077412, 0.017879923805594444, -0.029640763998031616, 0.0016752769006416202, 0.0003961445763707161, 0.04606431722640991, 0.05516067147254944, 0.039013635367155075, 0.008432316593825817, 0.021429065614938736, 0.02644667774438858, 0.016648178920149803, -0.01932329684495926, 0.020859044045209885, 0.002798316301777959, -0.011294414289295673, 0.01010192558169365, 0.0016800911398604512, 0.03375512361526489, -0.03272296115756035, 0.04348662868142128, -0.037857796996831894, -0.001873547094874084, -0.0227994192391634, -0.002224511466920376, 0.0010085742687806487, -0.009788407944142818, -0.014345113188028336, -0.008246519602835178, -0.016359761357307434, 0.01742970384657383, 0.016348985955119133, 0.017845788970589638, -0.017409494146704674, -0.023374227806925774, 0.01086347084492445, 0.014236154966056347, 0.00935645867139101, -0.05319826677441597, 0.0003578465839382261, 0.019050300121307373, -0.009502037428319454, 0.011852899566292763, -0.045276105403900146, 0.007757332641631365, -0.028805360198020935, 0.009272010065615177, -0.02578379213809967, 0.014942698180675507, -0.028112312778830528, -0.043631263077259064, 0.028306884691119194, 0.011331172659993172, 0.007278554141521454, 0.05043249949812889, 0.014107326976954937, 0.004649692680686712, -0.044874925166368484, -0.00440225237980485, 0.01015277486294508, -0.05334693565964699, -0.019214360043406487, -0.0922468900680542, 0.0030621890909969807, -0.015241757966578007, 0.02495541051030159, 0.01489461399614811, 0.06506270170211792, 0.011273336596786976, -0.03541169315576553, 0.021444836631417274, 0.03781955689191818, -0.04622724652290344, 0.01344412099570036, 0.0016743282321840525, -0.020195234566926956, -0.02428775280714035, 0.020504670217633247, 0.00745238084346056, -0.00398695794865489, 0.008194755762815475, 0.015467912890017033, 0.006503755692392588, -0.04540087655186653, 0.0057791839353740215, 0.051720306277275085, -0.012652796693146229, 0.041088320314884186, 0.03204307332634926, -0.02980686165392399, 0.001968775875866413, -0.0033720177598297596, -0.0402030348777771, -0.07019877433776855, -0.007755662780255079, -0.038904156535863876, -0.056446176022291183, -0.011267640627920628, -0.007925004698336124, 0.0017402117373421788, 0.033913180232048035, -0.031905774027109146, -0.03426101431250572, -0.012684144079685211, 0.008488941006362438, -0.0449022613465786, 0.0163909699767828, 0.040506646037101746, 0.02956831455230713, 0.012633985839784145, -0.01569792442023754, -0.0307778287678957, 0.005670994985848665, 0.01253951620310545, 0.0021752428729087114, 0.03569278493523598, -0.03593223914504051, -0.01754050701856613, -0.05237084999680519, -0.014948357827961445, -0.013544023036956787, -0.03777410835027695, 0.05514072999358177, -0.009364819154143333, -0.007747048512101173, -0.041154902428388596, 0.033119071274995804, 0.025357495993375778, 0.010944148525595665, 0.019186902791261673, -0.0030905602034181356, 0.0464930459856987, -0.01190256793051958, -0.018027249723672867, -0.07139028608798981, -0.0030021939892321825, -0.04314679279923439, -0.010023456998169422, 0.019634511321783066, -0.001439461251720786, -0.00019812578102573752, -0.023780284449458122, -0.04077873006463051, -0.007333008106797934, -0.01626337319612503, -0.07017268985509872, -0.03553243353962898, 0.022550564259290695, 0.04334885627031326, -0.06986511498689651, -0.024633875116705894, -0.022913964465260506, -0.02183610573410988, -0.0182523000985384, -0.008568726480007172, -0.007184877991676331, 0.00880624819546938, -0.023188358172774315, 0.02243197150528431, 0.0115989213809371, 0.012341620400547981, 0.04596942290663719, -0.034956734627485275, -0.006333386059850454, -0.007071265019476414 ]
Deploy GPT-J 6B for inference using Hugging Face Transformers and Amazon SageMaker
philschmid
January 11, 2022
gptj-sagemaker
partnerships, aws, guide, nlp
https://huggingface.co/blog/gptj-sagemaker
Default request This is an example of a default request using greedy search. Inference-time after the first request: 3s python predictor.predict({ "inputs": "Can you please let us know more details about your " })
[ 0.016918202862143517, 0.04088033363223076, 0.05886993184685707, -0.002419769298285246, 0.04905693233013153, 0.03769933432340622, 0.053223930299282074, 0.04822546988725662, -0.03724001720547676, -0.021761257201433182, -0.06888985633850098, 0.04156741127371788, -0.011350725777447224, 0.043944794684648514, -0.020294632762670517, -0.05129358172416687, 0.05976537615060806, -0.04079608991742134, -0.07773352414369583, 0.01844225451350212, -0.0032615046948194504, -0.04194571450352669, 0.06357936561107635, -0.004104966297745705, 0.05078737065196037, -0.059277214109897614, -0.06782704591751099, -0.022330550476908684, -0.07011104375123978, 0.03642302379012108, -0.04554024338722229, -0.03270497918128967, 0.017342060804367065, -0.009918912313878536, 0.0321282222867012, 0.014726507477462292, -0.09647180885076523, 0.047137971967458725, -0.02131332829594612, -0.018589336425065994, -0.03351472690701485, -0.06640252470970154, -0.08753826469182968, -0.0064818477258086205, 0.01845567673444748, -0.021562159061431885, -0.1961265206336975, 0.05566149950027466, -0.019421909004449844, -0.03838193789124489, -0.0902271568775177, 0.05475374311208725, -0.019159143790602684, 0.03092287853360176, 0.027359912171959877, -0.03916604444384575, -0.021524464711546898, -0.07279512286186218, 0.003563058329746127, 0.0074570635333657265, 0.0051673599518835545, -0.01544585544615984, 0.03115573525428772, 0.08928948640823364, 0.0035582869313657284, 0.01121030654758215, -0.02172032743692398, 0.006192372180521488, 0.02222439832985401, -0.010269361548125744, 0.054579298943281174, -0.0022363008465617895, -0.02708533965051174, 0.044685639441013336, 0.0669761449098587, -0.01577715389430523, -0.007980596274137497, 0.0380624458193779, -0.05126968026161194, 0.08106028288602829, 0.00841942336410284, -0.012912887148559093, 0.06176963075995445, 0.004658212419599295, 0.042465776205062866, 0.05241028219461441, 0.02719549462199211, 0.015249272808432579, 0.0026522744446992874, 0.004614938981831074, -0.018655961379408836, -0.13999716937541962, 0.020081067457795143, -0.034228354692459106, -0.01514312345534563, -0.04860733449459076, 0.06110158562660217, 0.017973914742469788, -0.004339250735938549, -0.05125605687499046, -0.012853691354393959, -0.07505904138088226, -0.0483580119907856, -0.011671535670757294, -0.02915951982140541, 0.05872230604290962, -0.04386565834283829, -0.0585617832839489, -0.07896289974451065, -0.015166260302066803, -0.0074418275617063046, 0.036150719970464706, 0.00810452550649643, 0.11392927169799805, -0.041264984756708145, 0.008795677684247494, -0.005966052878648043, 0.00449017621576786, -0.050130102783441544, -0.04218048229813576, -0.005105666816234589, 0.04579562321305275, 0.07976970821619034, 0.04083004593849182, 0.032895173877477646, 0.050994470715522766, 0.044815655797719955, 0.04780600965023041, 0.0337756872177124, -0.03807913884520531, 0.04016236588358879, 0.001468289876356721, 0.021093975752592087, -0.02120468206703663, -0.020858220756053925, 0.00873495265841484, 0.027396850287914276, -0.044963933527469635, 0.03930580988526344, -0.004491070285439491, -0.04792590066790581, -0.003570473985746503, -0.02906193770468235, 0.04482191056013107, 0.13306796550750732, 0.030439911410212517, -0.014713859185576439, 0.02671215683221817, -0.0015504098264500499, 0.03439141437411308, -0.08961194008588791, 0.1173115149140358, 0.007586612366139889, -0.07371208071708679, 0.020016076043248177, 0.022646741941571236, -0.003469731193035841, -0.036577481776475906, 0.0012404542649164796, 0.007754182443022728, 0.03691120818257332, 0.04387449845671654, -0.007858548313379288, 0.010313008911907673, 0.05264861509203911, -0.02599908597767353, 0.021846044808626175, 0.019788600504398346, 0.03245155140757561, 0.013904470950365067, -0.011237733997404575, 0.03729921579360962, 0.06477735936641693, -0.0012841480784118176, 0.0007982533425092697, 0.0485941506922245, -0.02647341415286064, -0.03601304814219475, 0.03760900720953941, -0.006405047606676817, 0.0010536974295973778, 0.017806848511099815, -0.05003873631358147, 0.015802161768078804, 0.034939005970954895, -0.057335563004016876, 0.06738334149122238, 0.04248030483722687, 0.03839410841464996, -0.02647440880537033, -0.04650247469544411, -0.04851508140563965, 0.10982438921928406, -0.01577702909708023, 0.0016974702011793852, -0.05999571457505226, -0.05754058435559273, 0.013850008137524128, 0.02097642607986927, 0.02497544325888157, 0.04397166147828102, 0.017429955303668976, 0.10809163004159927, -0.03902652859687805, -0.013215586543083191, 0.052923087030649185, 0.03872321918606758, -0.09708463400602341, -0.008928862400352955, 0.031681567430496216, 0.006088046357035637, -0.02923525869846344, -0.023934604600071907, -0.10777481645345688, 0.009175097569823265, -0.02117581106722355, 0.054958801716566086, 0.044535696506500244, 0.04525589942932129, -0.045471496880054474, 0.17746379971504211, 0.010213118977844715, 0.055464278906583786, -0.0723549947142601, -0.051221318542957306, 0.01301833800971508, 0.10431256890296936, 0.05066287890076637, 0.03125089779496193, -0.04407379776239395, -0.010595990344882011, -0.019824709743261337, -0.03295057266950607, 0.05170416831970215, 0.004595328122377396, -0.036110058426856995, 0.018684474751353264, 0.0019476396264508367, -0.0325283482670784, -0.018957223743200302, 0.04577036574482918, 0.013682511635124683, -0.0253694336861372, 0.022611921653151512, -0.0548403337597847, -0.0130796292796731, 0.10251426696777344, 0.014032774604856968, -0.10073762387037277, 0.048996929079294205, -0.042073216289281845, -0.012395593337714672, 0.012340337969362736, -0.01375582441687584, 0.04167366027832031, 0.04328248277306557, -0.0657004565000534, -0.015213980339467525, 0.022655116394162178, 0.05091638118028641, -0.010108541697263718, 0.02379312366247177, 0.00415038550272584, 0.003886050544679165, -0.02359161712229252, -0.03038005158305168, -0.021785954013466835, 0.003686674404889345, 0.03253188729286194, 0.03584960848093033, 0.008018986321985722, -0.027285363525152206, -0.0025968183763325214, 0.018064364790916443, 0.02054448612034321, 0.04071443900465965, 0.0307585671544075, 0.0011111994972452521, -0.013058079406619072, 0.008549075573682785, -0.0017414821777492762, -0.019352346658706665, 0.04005572944879532, 0.016224777325987816, 0.017994636669754982, -0.031125346198678017, 0.008697425946593285, -0.025573642924427986, -0.035786453634500504, -0.029951592907309532, -0.007231722120195627, -0.0007100783404894173, 0.028073078021407127, 0.02038804441690445, 0.0075668152421712875, -0.008022698573768139, 0.00020472731557674706, -0.020077379420399666, 0.010272295214235783, -0.0010899575427174568, -0.0334874764084816, -0.028202427551150322, -0.02369355782866478, -0.009070857428014278, -0.015403101220726967, 0.0574164055287838, 0.029874155297875404, -0.007079548202455044, -0.10496699064970016, -0.025902288034558296, 0.009604166261851788, 0.0031901400070637465, 0.021451974287629128, -0.02602207474410534, 0.040530938655138016, -0.03134724125266075, 0.005829260218888521, -0.0017384350067004561, -0.0380745455622673, -0.021111680194735527, 0.016702909022569656, 0.01626555807888508, -0.001438404549844563, 0.016563037410378456, -0.04382786154747009, 0.031524963676929474, -0.00787860993295908, 0.003531069727614522, 0.007328142877668142, 0.03572288900613785, -0.00124553800560534, -0.01759781502187252, -0.025009822100400925, 0.026003828272223473, 0.02389075979590416, 0.02313525788486004, 0.035849906504154205, -0.06150665134191513, 0.002097497694194317, -0.0497862733900547, -0.050251204520463943, -0.00966479629278183, -0.043196480721235275, 0.0009601109195500612, -0.005832354072481394, -0.00023468217113986611, 0.013734441250562668, 0.02879919297993183, -0.0057589043863117695, -0.021500764414668083, -0.018273379653692245, 0.00353202479891479, -0.011972679756581783, 0.03131001442670822, 0.015657596290111542, 0.015047159045934677, 0.045114628970623016, -0.042794667184352875, -0.044572263956069946, -0.025112219154834747, -0.0020746877416968346, 0.017261721193790436, -0.0026570139452815056, 0.04018620029091835, 0.006935530807822943, 0.03604700416326523, 0.0259770005941391, 0.017580080777406693, -0.048365116119384766, 0.009382572956383228, -0.0005821814993396401, -0.019385334104299545, -0.029144350439310074, 0.009737767279148102, 0.007615834474563599, 0.04047985002398491, -0.019115038216114044, -0.012462658807635307, 0.00316010694950819, 0.007745346054434776, 0.015385682694613934, 0.011886444874107838, -0.0021326597779989243, -0.02865588106215, -0.0003571895940694958, -0.0580940768122673, 0.09420543909072876, 0.03628039360046387, -0.03467108681797981, 0.013127644546329975, -0.05612076818943024, -0.019995655864477158, 0.021639322862029076, -0.028226740658283234, 0.005145334638655186, -0.02696079947054386, 0.0020406574476510286, -0.008098057471215725, -0.017241690307855606, -0.00949547067284584, 0.019107354804873466, 0.004591718316078186, -0.05464571714401245, 0.019171757623553276, 0.041017912328243256, 0.04219163954257965, 0.028146009892225266, -0.022442905232310295, 0.012561970390379429, -0.05487268790602684, -0.03567875176668167, 0.012417183257639408, -0.02170800417661667, -0.02420535497367382, -0.013646760024130344, -0.020745934918522835, 0.009760596789419651, -0.004511944483965635, 0.004959478508681059, 0.014163533225655556, 0.008105164393782616, -0.037569742649793625, -0.005468443967401981, 0.07171524316072464, -0.019620852544903755, -0.00036309691495262086, -0.015408926643431187, 0.0007266401662491262, -0.00915121752768755, -0.016938554123044014, -0.018390340730547905, -0.0015173025894910097, -0.0013667027233168483, -0.030896862968802452, 0.013144711963832378, -0.007775151636451483, 0.03579173609614372, -0.0025987536646425724, -0.03618692234158516, 0.009251669049263, 0.007022214122116566, -0.01323032472282648, 0.008599312976002693, -0.0036029245238751173, 0.021526897326111794, 0.021023336797952652, 0.005590572487562895, -0.034890808165073395, -0.01731935143470764, 0.01942000351846218, 0.013681036420166492, -0.047337502241134644, -0.013716191053390503, 0.010784579440951347, -0.02722538448870182, -0.012167679145932198, -0.033274877816438675, 0.018732864409685135, 0.032263822853565216, 0.0015459301648661494, -0.04966398701071739, -0.009097017347812653, 0.031841520220041275, -0.04096601530909538, -0.003988713026046753, -0.009943227283656597, -0.040151964873075485, 0.05843568965792656, -0.012307630851864815, -0.026656320318579674, -0.029767774045467377, 0.03219456598162651, 0.01711646281182766, -0.010685640387237072, -0.06851658225059509, -0.017715157940983772, 0.01350337453186512, 0.004765587858855724, -0.013730782084167004, 0.00032167756580747664, 0.05430207401514053, -0.04614274948835373, 0.015110330656170845, 0.05294167622923851, 0.0165935717523098, -0.01603284291923046, -0.019219521433115005, 0.02836652658879757, -0.06150970980525017, -0.0200644638389349, 0.03253075107932091, -0.014096567407250404, 0.031196322292089462, 0.022333858534693718, 0.048932623118162155, 0.017146671190857887, 0.03585217148065567, 0.0662560760974884, -0.015008751302957535, -0.009671512059867382, 0.038115277886390686, -0.02523505501449108, 0.0055416482500731945, -0.03304019942879677, -0.021119317039847374, 0.0012771686306223273, -0.008091111667454243, -0.005439544562250376, 0.05513695999979973, 0.04111512750387192, -0.011966186575591564, -0.02013605274260044, 0.019195014610886574, 0.03362663835287094, 0.020067499950528145, -0.002356757875531912, -0.002867275383323431, -0.04017563909292221, 0.024748193100094795, -0.06162278726696968, 0.013144846074283123, 0.028529927134513855, 0.017854856327176094, -0.035122890025377274, -0.014016331173479557, 0.014723217114806175, 0.016101526096463203, 0.060634974390268326, -0.0007468546973541379, -0.0006414992385543883, -0.03541368246078491, 0.012184755876660347, 0.06494452059268951, -0.03259715437889099, -0.01161044929176569, 0.04930298402905464, 0.05795780569314957, 0.018284274265170097, 0.036811359226703644, -0.023958249017596245, 0.018728436902165413, 0.04776645824313164, -0.004739179741591215, 0.03220457583665848, -0.07550626248121262, 0.04351206123828888, 0.04108094424009323, -0.022158022969961166, -0.003964877221733332, -0.04593344405293465, -0.013497603125870228, -0.013960810378193855, -0.0007588141597807407, 0.043215252459049225, 0.0429612398147583, -0.004568106960505247, -0.012298221699893475, 0.008426055312156677, -0.004519385285675526, 0.026006337255239487, -0.008176133967936039, 0.01305403746664524, -0.03143179789185524, -0.002021046355366707, 0.0009987535886466503, -0.03078165091574192, -0.0008797668269835413, 0.0049675763584673405, 0.022602234035730362, -0.03937845304608345, 0.03515462949872017, 0.03408516198396683, -0.033944591879844666, 0.06150222197175026, 0.03108014538884163, -0.015220077708363533, -0.01798141561448574, -0.019250404089689255, 0.009714383631944656, -0.005019172094762325, 0.02395118586719036, -0.0066599007695913315, -0.009139325469732285, 0.027704894542694092, -0.025240585207939148, 0.07032106816768646, 0.0020490142051130533, 0.03706562519073486, 0.025750141590833664, 0.04045208916068077, -0.0011916124494746327, 0.02987639605998993, -0.015844330191612244, -0.01532244123518467, 0.03763594105839729, 0.020138217136263847, 0.019477419555187225, 0.002339681377634406, -0.02718222327530384, 0.04366527497768402, -0.01136013399809599, 0.0030568630900233984, -0.000497235800139606, 0.014099014922976494, 0.05003431811928749, -0.0016464038053527474, 0.0361616350710392, -0.07204045355319977, 0.029902221634984016, -0.012879716232419014, -0.005452735349535942, -0.013482489623129368, -0.02056758850812912, 0.06505543738603592, 0.022525791078805923, 0.03996071219444275, 0.025666942819952965, -0.02572990581393242, -0.02451459690928459, 0.032329268753528595, 0.03694545850157738, 0.011281480081379414, 0.01664876751601696, -0.0016202360857278109, -0.02944061905145645, -0.057839181274175644, -0.04176142439246178, 0.029659010469913483, 0.024492159485816956, 0.017251480370759964, -0.016154557466506958, 0.002897388767451048, -0.027616936713457108, -0.02203603833913803, -0.023893391713500023, 0.016338706016540527, 0.020299242809414864, -0.01154330000281334, 0.017327003180980682, 0.02008337900042534, 0.011565174907445908, -0.04890989884734154, -0.00287347543053329, 0.011614032089710236, 0.0030128657817840576, -0.01576939970254898, -0.06426408141851425, 0.011461146175861359, -0.01905929297208786, -0.0004519807989709079, -0.02024090476334095, 0.027150405570864677, -0.035522252321243286, -0.016229866072535515, 0.03623946011066437, 0.02117445319890976, -0.017346074804663658, 0.02505502663552761, 0.03133507817983627, 0.019276315346360207, -0.00301230326294899, 0.0064740488305687904, -0.04081243649125099, 0.0025951159186661243, 0.04452740028500557, -0.04546085000038147, -0.014906016178429127, -0.021405428647994995, 0.045717328786849976, 0.019565267488360405, 0.03241124004125595, -0.028351014479994774, 0.008575552143156528, 0.0072234864346683025, -0.030476070940494537, -0.022689325734972954, 0.020198537036776543, 0.01903345249593258, -0.023899495601654053, -0.012488185428082943, -0.00005308058098307811, -0.014367585070431232, -0.032788731157779694, -0.0031655244529247284, 0.030784329399466515, 0.004636846948415041, -0.028642835095524788, 0.0050173792988061905, 0.005071000661700964, -0.005705873016268015, 0.014029261656105518, 0.03766661137342453, -0.043111711740493774, 0.005478984210640192, -0.020959163084626198, -0.005676419474184513, 0.0017212101956829429, 0.03536388278007507, -0.0596923753619194, -0.024141162633895874, -0.034425463527441025, -0.029415670782327652, -0.003234481904655695, -0.002771628787741065, -0.0357220321893692, -0.0038618422113358974, -0.01701478101313114, 0.002337623853236437, -0.007584271486848593, -0.0072285751812160015, 0.03575553372502327, -0.006187587045133114, 0.08571117371320724, 0.01872587949037552, 0.026249244809150696, -0.019194558262825012, 0.012726807966828346, 0.0013403183547779918, 0.01707441546022892, -0.0017988054314628243, -0.01793360337615013, -0.01711132936179638, 0.01819855533540249, -0.037258829921483994, -0.06515409052371979, 0.03249697759747505, 0.014411198906600475, 0.021440057083964348, -0.06614408642053604, 0.018239974975585938, 0.02307354100048542, 0.010944998823106289, 0.04734846204519272, 0.03903767094016075, -0.011463250033557415, -0.03128841146826744, 0.05806864798069, -0.03523743152618408, -0.04086877405643463, 0.01957065425813198, -0.020877407863736153, -0.0005824780673719943, 0.01752803660929203, -0.006650993600487709, -0.01871182769536972, -0.0007108626887202263, -0.01634189486503601, -0.0247651357203722, -0.0650312677025795, -0.022258499637246132, -0.04741687700152397, 0.017247376963496208, -0.03907093405723572, 0.0053494474850595, 0.048492033034563065, -0.026525704190135002, -0.06829318404197693, -0.0024988120421767235, -0.00692707346752286, -0.0024719657376408577, 0.042212922126054764, 0.011882592923939228, -0.016884619370102882, 0.05102706700563431, 0.05258403718471527, -0.012340993620455265, -0.0016003464115783572, 0.0421883724629879 ]
Deploy GPT-J 6B for inference using Hugging Face Transformers and Amazon SageMaker
philschmid
January 11, 2022
gptj-sagemaker
partnerships, aws, guide, nlp
https://huggingface.co/blog/gptj-sagemaker
Background The weights of the 6 billion parameter model represent a ~24GB memory footprint. To load it in float32, one would need at least 2x model size CPU RAM: 1x for initial weights and another 1x to load the checkpoint. So for GPT-J it would require at least 48GB of CPU RAM to just load the model. To make the model more accessible, EleutherAI also provides float16 weights, and transformers has new options to reduce the memory footprint when loading large language models. Combining all this it should take roughly 12.1GB of CPU RAM to load the model. python from transformers import GPTJForCausalLM import torch model = GPTJForCausalLM.from_pretrained( "EleutherAI/gpt-j-6B", revision="float16", torch_dtype=torch.float16, low_cpu_mem_usage=True ) The caveat of this example is that it takes a very long time until the model is loaded into memory and ready for use. In my experiments, it took 3 minutes and 32 seconds to load the model with the code snippet above on a P3.2xlarge AWS EC2 instance (the model was not stored on disk). This duration can be reduced by storing the model already on disk, which reduces the load time to 1 minute and 23 seconds, which is still very long for production workloads where you need to consider scaling and reliability. For example, Amazon SageMaker has a 60s limit for requests to respond, meaning the model needs to be loaded and the predictions to run within 60s, which in my opinion makes a lot of sense to keep the model/endpoint scalable and reliable for your workload. If you have longer predictions, you could use batch-transform. In Transformers the models loaded with the from_pretrained method are following PyTorch's recommended practice, which takes around 1.97 seconds for BERT [REF]. PyTorch offers an additional alternative way of saving and loading models using torch.save(model, PATH) and torch.load(PATH). “Saving a model in this way will save the entire module using Python’s pickle module. The disadvantage of this approach is that the serialized data is bound to the specific classes and the exact directory structure used when the model is saved.” This means that when we save a model with transformers==4.13.2 it could be potentially incompatible when trying to load with transformers==4.15.0. However, loading models this way reduces the loading time by ~12x, down to 0.166s for BERT. Applying this to GPT-J means that we can reduce the loading time from 1 minute and 23 seconds down to 7.7 seconds, which is ~10.5x faster. Figure 1. Model load time of BERT and GPTJ
[ -0.040347758680582047, 0.04361865669488907, -0.04251265898346901, 0.008248877711594105, -0.031201865524053574, 0.051392167806625366, 0.06536508351564407, 0.044279757887125015, 0.0016966405091807246, 0.000038892176235094666, 0.012927859090268612, 0.040601637214422226, 0.001425074995495379, 0.06390958279371262, -0.007025174330919981, -0.08880051970481873, 0.058331895619630814, -0.017228523269295692, -0.019231483340263367, 0.007854192517697811, 0.03784741461277008, -0.027819352224469185, -0.022732848301529884, 0.009993832558393478, -0.031250081956386566, -0.07476206123828888, -0.04187513515353203, -0.0020430281292647123, 0.038666728883981705, 0.013496238738298416, -0.14066888391971588, -0.002233572071418166, -0.007298903539776802, -0.016057780012488365, -0.015318484976887703, 0.0018420990090817213, -0.0860496386885643, 0.07850532233715057, 0.05157533660531044, 0.010335206985473633, -0.006146202329546213, 0.04487214982509613, -0.041879456490278244, 0.038970425724983215, 0.010547999292612076, -0.0013775179395452142, -0.057116229087114334, 0.02414429746568203, -0.024342307820916176, -0.036346904933452606, -0.1185932531952858, 0.045167505741119385, 0.0010370296658948064, 0.04780064895749092, -0.0407227985560894, -0.005618464667350054, 0.011119035072624683, -0.026851583272218704, -0.0025639203377068043, -0.01979285106062889, 0.01754888892173767, 0.03824477642774582, -0.03482050076127052, 0.014101915992796421, 0.09287867695093155, -0.046231720596551895, 0.00285465270280838, 0.01259673573076725, -0.0352809801697731, -0.023166997358202934, 0.02352944016456604, -0.034467462450265884, -0.018037479370832443, -0.04179491475224495, -0.10259712487459183, -0.01986956223845482, 0.022943444550037384, 0.02008785679936409, 0.05790438875555992, 0.08863446116447449, -0.02034277282655239, 0.02727070450782776, -0.0020145890302956104, 0.006894371006637812, 0.04750654473900795, -0.030902624130249023, 0.06985816359519958, -0.04369160160422325, -0.04898768290877342, 0.007997390814125538, 0.007760557811707258, -0.06997944414615631, -0.007056123577058315, -0.01488084439188242, 0.049977388232946396, 0.03709457069635391, -0.028551973402500153, -0.0007575689232908189, 0.011389294639229774, 0.033883240073919296, 0.03417966142296791, -0.06329260021448135, -0.02070561796426773, -0.035777851939201355, -0.05328682065010071, 0.07560333609580994, -0.0416359044611454, -0.09819190949201584, 0.08068177849054337, -0.008601188659667969, -0.0038387144450098276, 0.05660508573055267, -0.11271863430738449, 0.0181350689381361, -0.08783064037561417, 0.026113692671060562, 0.049903176724910736, -0.06486826390028, 0.00013617648801300675, 0.04147881269454956, 0.003005452686920762, 0.07385329902172089, 0.03233623877167702, -0.04803691431879997, 0.01859254017472267, 0.09263566136360168, 0.05034104362130165, 0.030114388093352318, 0.009556164033710957, 0.015276831574738026, 0.12592555582523346, -0.09642988443374634, 0.06244969367980957, -0.03985578194260597, 0.01675514318048954, 0.01146375760436058, -0.01321442611515522, 0.01730315200984478, -0.004853908903896809, 0.012063880451023579, -0.05944884940981865, 0.047441888600587845, -0.007998676039278507, -0.008414993062615395, 0.08954211324453354, 0.025053437799215317, -0.058099135756492615, 0.060594379901885986, -0.011122041381895542, 0.04604820907115936, -0.1602618545293808, 0.06534292548894882, -0.0305415578186512, -0.016116980463266373, 0.055936165153980255, 0.03292812407016754, -0.022839514538645744, -0.010010434314608574, -0.09115716814994812, -0.06810151785612106, -0.013959855772554874, -0.020341074094176292, -0.024889273568987846, -0.03274056687951088, 0.011057094670832157, -0.03344719856977463, 0.04182206466794014, -0.03793405741453171, 0.06025155261158943, -0.008618367835879326, 0.023768197745084763, -0.009285910986363888, 0.07826195657253265, 0.02832043170928955, -0.01729898899793625, 0.014789428561925888, -0.004032195080071688, 0.0441710390150547, 0.018514206632971764, -0.05419507995247841, -0.03184444457292557, 0.006933772936463356, 0.03637443110346794, 0.11351745575666428, 0.0391063466668129, -0.09246005862951279, -0.006163035985082388, -0.07323028892278671, -0.06835123151540756, 0.05947517603635788, 0.023079799488186836, -0.007545122876763344, 0.07534022629261017, -0.005366436671465635, 0.04214993119239807, -0.02971966378390789, -0.009884401224553585, 0.07853701710700989, 0.06321710348129272, 0.03159305080771446, 0.003663761541247368, 0.016754936426877975, 0.02432035654783249, -0.0055977716110646725, -0.01737578958272934, -0.026874080300331116, -0.01959998905658722, -0.03523712977766991, 0.019901331514120102, 0.05188547447323799, 0.025795510038733482, -0.09608780592679977, 0.0034619576763361692, -0.12612488865852356, -0.034444794058799744, -0.06680940091609955, 0.005861538462340832, -0.01838068664073944, 0.024675242602825165, -0.011367938481271267, 0.13121265172958374, -0.0052511245012283325, -0.018621526658535004, -0.06778588891029358, -0.04331779107451439, 0.04301641881465912, 0.03271910175681114, 0.001224668463692069, 0.013691495172679424, -0.09095972031354904, -0.042738642543554306, -0.09948545694351196, -0.019730277359485626, 0.06105254217982292, -0.04259338974952698, 0.02233877219259739, -0.0320415273308754, -0.001659143017604947, 0.029763849452137947, -0.006359547842293978, -0.046353962272405624, 0.0062880669720470905, -0.007075258996337652, -0.02409815602004528, 0.032564934343099594, -0.0311199352145195, 0.015519353561103344, 0.004459291230887175, -0.016679128631949425, -0.040812183171510696, -0.04726146161556244, -0.004558380227535963, -0.014438790269196033, 0.015951264649629593, -0.022907113656401634, 0.008500956930220127, -0.000054988595366012305, -0.03385314345359802, 0.02416207641363144, 0.03504270687699318, 0.002074106130748987, 0.0341908261179924, -0.04578366130590439, 0.02519500069320202, 0.00048662489280104637, -0.014588777907192707, -0.01391300093382597, -0.028652314096689224, 0.03359265252947807, -0.048132941126823425, 0.03145632892847061, -0.020313017070293427, 0.0166714359074831, 0.03548808395862579, 0.0027238838374614716, 0.07667770981788635, -0.018136663362383842, -0.009362216107547283, -0.03898397088050842, 0.004534691106528044, 0.010690359398722649, -0.05413554236292839, 0.0011351604480296373, -0.0037463440094143152, -0.01813909225165844, 0.01389531884342432, 0.024512965232133865, -0.014576123096048832, 0.0027235629968345165, 0.02127019688487053, -0.0006413017981685698, 0.0033642377238720655, 0.005003843456506729, -0.021256472915410995, -0.02331675961613655, 0.0059971376322209835, -0.018781794235110283, -0.02648615837097168, -0.004852470010519028, 0.014711908996105194, -0.02163722924888134, 0.014971306547522545, 0.01689082756638527, -0.01586909592151642, -0.036436472088098526, -0.022280631586909294, 0.0048348912969231606, 0.021675892174243927, -0.07183060050010681, -0.010157671757042408, -0.013374537229537964, -0.002365496940910816, -0.008434713818132877, 0.020533857867121696, 0.0008224900811910629, 0.04307720065116882, 0.0010099011706188321, 0.03964635729789734, -0.013409712351858616, 0.023851877078413963, -0.005321509670466185, 0.04968563839793205, 0.01730513386428356, 0.015541419386863708, 0.013530591502785683, 0.00839020125567913, 0.023044632747769356, -0.003832535818219185, -0.004813771694898605, 0.025102820247411728, -0.029138097539544106, 0.03224052116274834, 0.006760440766811371, 0.005122236907482147, -0.0021201279014348984, 0.00899885967373848, -0.0027651723939925432, -0.023325379937887192, -0.03603427857160568, -0.06663704663515091, 0.010616516694426537, 0.020326340571045876, -0.027424853295087814, -0.026824533939361572, 0.0007180956890806556, 0.042635831981897354, 0.008377239108085632, 0.003982579801231623, 0.00011555597302503884, -0.05255761742591858, -0.004964813124388456, -0.024734534323215485, 0.04522683471441269, -0.010932826437056065, -0.010167891159653664, -0.02810104936361313, 0.002546737203374505, -0.0030935907270759344, -0.0313873365521431, -0.029687931761145592, -0.011298220604658127, 0.002836202969774604, 0.029482882469892502, 0.01747179962694645, 0.0009127492667175829, 0.04428500682115555, 0.00998939760029316, -0.026241088286042213, -0.024486955255270004, 0.011413615196943283, 0.017162472009658813, -0.0009897504933178425, -0.015463118441402912, 0.029388435184955597, 0.03233044594526291, -0.010591123253107071, -0.04202618449926376, 0.03741082176566124, -0.052097953855991364, 0.012868939898908138, 0.04309186711907387, 0.00306730717420578, -0.010521653108298779, -0.004281047265976667, -0.01194366067647934, -0.00655791349709034, 0.047313082963228226, 0.03501693531870842, -0.06042460352182388, -0.015329386107623577, -0.050558727234601974, -0.02578524500131607, -0.006738006137311459, 0.027861416339874268, -0.011695479974150658, -0.016818992793560028, 0.051302578300237656, 0.024929745122790337, 0.009332722052931786, 0.02085196040570736, -0.0004036786558572203, -0.005216458346694708, -0.017869839444756508, -0.07462593913078308, 0.03304106742143631, 0.0079695088788867, -0.009785681962966919, 0.0029465840198099613, -0.014367837458848953, -0.022167062386870384, 0.03532971814274788, 0.025098444893956184, 0.009922639466822147, 0.005715454462915659, -0.01652560941874981, 0.006940589286386967, 0.0031505816150456667, 0.0236983560025692, -0.011416803114116192, -0.002964708488434553, 0.021622173488140106, 0.007398105692118406, 0.021603045985102654, 0.0463409386575222, -0.01074543409049511, -0.015593091025948524, 0.018379289656877518, 0.06709891557693481, -0.036059532314538956, 0.006819161586463451, -0.03475186973810196, -0.014132736250758171, 0.0012421346036717296, 0.02615114487707615, 0.0005316940951161087, 0.011140010319650173, 0.003442649496719241, -0.0010177860967814922, -0.0443560928106308, 0.011474357917904854, 0.02468549646437168, 0.03689468652009964, -0.016539491713047028, 0.008033297955989838, -0.009656989946961403, -0.030607497319579124, 0.039238978177309036, -0.007123004179447889, -0.0029027259442955256, -0.030252451077103615, 0.018135998398065567, -0.03907792642712593, 0.004001695197075605, 0.02425973117351532, -0.0003222329542040825, 0.025719616562128067, -0.07970479875802994, 0.00977666862308979, 0.05356550216674805, 0.012663408182561398, -0.05400967597961426, 0.02379636839032173, 0.04105018824338913, 0.01499804388731718, -0.01691414974629879, -0.008235654793679714, 0.0035812221467494965, 0.05878593027591705, -0.011507797054946423, 0.025570757687091827, -0.021459322422742844, -0.01732414774596691, 0.02058546058833599, 0.028967445716261864, 0.007541260216385126, -0.03857722505927086, 0.0051353550516068935, 0.03303990513086319, 0.0006938295555301011, 0.03216039389371872, 0.023170895874500275, -0.018298182636499405, -0.00141900556627661, 0.0615411102771759, 0.012712614610791206, 0.020266208797693253, -0.03923032432794571, 0.06215221807360649, -0.020875127986073494, -0.045140355825424194, -0.04356236383318901, 0.002781560644507408, -0.018301596865057945, 0.01603146828711033, 0.030664218589663506, 0.09251020103693008, -0.004150083754211664, -0.006912935059517622, 0.004683847539126873, -0.024822747334837914, 0.015316396951675415, -0.018754761666059494, 0.01559937559068203, -0.011075039394199848, 0.024945516139268875, 0.043871838599443436, 0.008629059419035912, -0.006326703820377588, 0.03220723569393158, 0.048368945717811584, -0.034790486097335815, 0.013312733732163906, 0.012304509058594704, -0.023893458768725395, -0.011741694994270802, -0.052872367203235626, 0.06167091056704521, 0.0026155374944210052, -0.007042859680950642, 0.010402385145425797, -0.03025314211845398, 0.025855492800474167, 0.017658082768321037, -0.007123260293155909, -0.01262896228581667, 0.06756691634654999, 0.04910578206181526, 0.036204565316438675, 0.009897112846374512, -0.032157108187675476, -0.007646253798156977, -0.0326957032084465, 0.03982283174991608, -0.03892344608902931, 0.013172216713428497, 0.029897823929786682, -0.0014128568582236767, -0.01490059494972229, 0.008494183421134949, -0.009861298836767673, -0.036386728286743164, 0.07171175628900528, 0.009142694063484669, -0.05182487890124321, 0.016921918839216232, 0.014853330329060555, 0.05358981341123581, -0.004082086496055126, -0.015124806202948093, -0.016101203858852386, -0.04800577461719513, 0.01266785804182291, -0.06130342185497284, 0.03914845362305641, 0.02569139376282692, -0.019027244299650192, 0.0033600572496652603, -0.02851133607327938, 0.012311374768614769, 0.003260244382545352, 0.008769331499934196, 0.01761186122894287, -0.009933896362781525, -0.01343583408743143, -0.01607573963701725, -0.008452611975371838, 0.03450760617852211, 0.026961391791701317, 0.041953954845666885, -0.004254151601344347, -0.008454064838588238, 0.03901199996471405, -0.02952401153743267, -0.011925535276532173, -0.0076639908365905285, -0.03342090919613838, 0.02552899532020092, 0.013498719781637192, -0.0021338353399187326, 0.0001924446114571765, -0.06116567924618721, 0.023159800097346306, -0.02461608685553074, -0.0010727121261879802, 0.021579397842288017, 0.043690603226423264, -0.02827809751033783, 0.060200996696949005, 0.04736872389912605, 0.030057648196816444, 0.01390627771615982, -0.002547940704971552, -0.02031666412949562, -0.013530830852687359, 0.07182673364877701, 0.01078459806740284, -0.018574021756649017, 0.04196927696466446, -0.003721392946317792, 0.006477782502770424, -0.030008381232619286, -0.030442818999290466, -0.10064466297626495, 0.00850645825266838, 0.042674481868743896, -0.03189477697014809, 0.015263941138982773, -0.022624637931585312, 0.04358596354722977, 0.06660756468772888, 0.0633993074297905, 0.020053671672940254, 0.02395193837583065, -0.013887640088796616, 0.02937040850520134, 0.012010514736175537, 0.04881887882947922, 0.02102155238389969, 0.0013392949476838112, -0.005824929103255272, 0.018048761412501335, 0.036978673189878464, 0.04345923289656639, -0.02119026705622673, 0.012016460299491882, 0.009184896014630795, 0.006065210793167353, 0.0382121205329895, -0.00031143854721449316, 0.016889996826648712, -0.035338450223207474, -0.0011778130428865552, -0.03565191850066185, 0.020801927894353867, 0.006786143407225609, -0.01477818377315998, -0.038014840334653854, -0.013478845357894897, -0.009171639569103718, -0.03871055692434311, 0.004757193848490715, -0.028454614803195, 0.029539331793785095, 0.0050003607757389545, -0.008664831519126892, 0.0366085022687912, -0.020656757056713104, 0.013540584594011307, 0.006788989063352346, -0.004280595108866692, -0.03343946486711502, 0.04948553070425987, -0.007852100767195225, -0.003994441125541925, 0.03166094794869423, -0.004956989549100399, 0.006182137876749039, 0.06418223679065704, -0.002442834433168173, 0.0017589948838576674, 0.014344928786158562, 0.016435664147138596, 0.002539996523410082, -0.039262618869543076, 0.04617329686880112, 0.002184623619541526, -0.027691610157489777, 0.020627928897738457, 0.06426182389259338, 0.06664019823074341, 0.013826585374772549, -0.0002883353445213288, -0.04640289396047592, -0.013010891154408455, -0.009836014360189438, -0.03180575743317604, 0.04316796362400055, -0.014890574850142002, -0.008492987602949142, 0.020560963079333305, 0.01601676642894745, -0.007828167639672756, -0.029338693246245384, -0.04593975841999054, 0.02078273706138134, -0.012982881627976894, 0.030824527144432068, -0.042963653802871704, 0.0516839399933815, -0.012204318307340145, -0.006585157476365566, 0.04784085601568222, -0.024246763437986374, -0.0073128934018313885, 0.004461816046386957, -0.008649471215903759, -0.035781245678663254, 0.014451947994530201, -0.026295069605112076, 0.0016886693192645907, -0.028646104037761688, 0.014499284327030182, -0.011542475782334805, -0.0034588032867759466, -0.01953570544719696, -0.015516812913119793, -0.023661354556679726, 0.003176439553499222, -0.017852194607257843, 0.01345556415617466, 0.048732154071331024, 0.042687516659498215, 0.008746006526052952, 0.03805841505527496, -0.06450675427913666, -0.0021601717453449965, -0.00981779582798481, 0.020046310499310493, 0.033458638936281204, 0.02498820796608925, -0.024038923904299736, -0.028374040499329567, -0.007402075920253992, 0.031105946749448776, -0.03736592456698418, -0.010509278625249863, -0.004773174878209829, -0.014624247327446938, -0.05688263103365898, -0.0172437597066164, -0.0011560176499187946, 0.0168907567858696, 0.07446693629026413, -0.013170192018151283, 0.023174166679382324, 0.028469763696193695, 0.0008380294311791658, -0.09077704697847366, -0.0036818799562752247, -0.014993720687925816, -0.023065602406859398, 0.07972179353237152, 0.03016902506351471, 0.0361945666372776, 0.023267365992069244, -0.04857359826564789, -0.03275828808546066, 0.011851823888719082, -0.07473600655794144, -0.021131083369255066, 0.007444814778864384, 0.053794533014297485, -0.06430429965257645, -0.05401325225830078, -0.02003333903849125, -0.00010180372919421643, 0.003898429684340954, -0.010665569454431534, -0.005689252633601427, 0.006027990952134132, 0.0006780183175578713, 0.016186758875846863, 0.01520762499421835, 0.015123661607503891, 0.04858957231044769, -0.03515287861227989, 0.004010060336440802, -0.0041322289034724236 ]
Deploy GPT-J 6B for inference using Hugging Face Transformers and Amazon SageMaker
philschmid
January 11, 2022
gptj-sagemaker
partnerships, aws, guide, nlp
https://huggingface.co/blog/gptj-sagemaker
key: children tweet: Maybe we die so we can come back as children.
[ 0.08028026670217514, -0.010086535476148129, 0.06830530613660812, -0.024010518565773964, 0.07630749046802521, 0.039364755153656006, 0.020438924431800842, 0.019673435017466545, -0.031959060579538345, -0.057206910103559494, -0.031936030834913254, -0.04746784269809723, -0.03637239336967468, 0.023674296215176582, -0.041981808841228485, 0.01055817399173975, 0.008911109529435635, -0.0250544510781765, -0.035465892404317856, -0.03770008683204651, -0.08749701827764511, 0.002940175123512745, 0.0328739695250988, -0.00806371122598648, 0.03975358232855797, -0.024639705196022987, -0.008889886550605297, -0.02289283275604248, -0.04221365600824356, 0.06154770404100418, -0.0720565989613533, 0.046015385538339615, 0.0538177527487278, 0.03133773431181908, -0.0026686175260692835, 0.019317181780934334, -0.11806097626686096, -0.004288132302463055, 0.001454493380151689, -0.016589656472206116, 0.007896104827523232, -0.051412396132946014, 0.013165794312953949, 0.01777338609099388, -0.022157980129122734, -0.016281168907880783, -0.23550085723400116, 0.09831688553094864, -0.00025083182845264673, -0.04536737874150276, -0.018644681200385094, 0.005432283040136099, 0.07745242118835449, -0.02734852209687233, -0.022614717483520508, -0.01838492788374424, -0.04105525091290474, -0.05403737351298332, 0.04593438282608986, -0.0391988530755043, 0.060219548642635345, 0.028594953939318657, 0.027565784752368927, -0.02136431448161602, 0.0372922383248806, -0.01208016648888588, 0.01691504940390587, 0.07179516553878784, -0.10675738751888275, 0.022756867110729218, 0.0074142469093203545, -0.028654269874095917, -0.06891001760959625, -0.029581565409898758, 0.044096074998378754, -0.019468585029244423, -0.024508219212293625, 0.056032441556453705, 0.042968057096004486, 0.00033605642965994775, 0.0023686885833740234, -0.009552998468279839, 0.0852736085653305, 0.09192372113466263, -0.010849564336240292, -0.015287182293832302, 0.05806690454483032, 0.026498351246118546, -0.066689133644104, 0.014851878397166729, -0.03694973140954971, -0.10220490396022797, -0.013909492641687393, 0.045213792473077774, 0.04022758826613426, 0.011710519902408123, 0.01773814670741558, -0.06329159438610077, -0.03201183304190636, 0.020107446238398552, -0.010743659920990467, -0.02164824865758419, 0.006066654343158007, -0.08785830438137054, -0.07652965933084488, -0.08573474735021591, 0.012458935379981995, -0.03465333953499794, -0.0067127784714102745, -0.05058026686310768, -0.005348458886146545, 0.027429506182670593, 0.08409405499696732, -0.020330030471086502, 0.005310718435794115, 0.12720073759555817, 0.08668331056833267, -0.023929772898554802, -0.010490729473531246, 0.045125339180231094, -0.007702028378844261, 0.002805553376674652, 0.04849918931722641, 0.002046051202341914, 0.05620424076914787, -0.010578031651675701, -0.020480699837207794, 0.05077366530895233, -0.029951805248856544, -0.00774308992549777, 0.08354030549526215, 0.06260983645915985, 0.012399965897202492, -0.004199294839054346, -0.0294362660497427, -0.03125155717134476, -0.006334973033517599, -0.0010020247427746654, 0.0763712003827095, 0.02446616068482399, 0.01095874048769474, -0.012633086182177067, 0.005551278591156006, 0.1273983269929886, 0.04738926142454147, -0.04827095940709114, -0.051957812160253525, 0.03772330284118652, 0.012400776147842407, 0.008501698262989521, -0.02743411995470524, 0.022075442597270012, 0.022231312468647957, -0.06694644689559937, -0.0066864159889519215, 0.04274262115359306, 0.021033592522144318, -0.05735119432210922, 0.011079013347625732, 0.005437034647911787, 0.013085608370602131, -0.006627014372497797, 0.03022073209285736, -0.06042828783392906, 0.05211948603391647, -0.016786349937319756, -0.013142243027687073, 0.014348769560456276, -0.012506760656833649, -0.09248073399066925, -0.03591953590512276, -0.02876620925962925, 0.06116694211959839, -0.04354967176914215, -0.015562495216727257, 0.051132190972566605, 0.02937961183488369, -0.03154274821281433, 0.005761188454926014, -0.0029564418364316225, -0.02990269660949707, -0.03615790978074074, -0.0014577610418200493, 0.028285348787903786, -0.02509777620434761, -0.037074014544487, -0.0005040569230914116, -0.017181314527988434, 0.01717100292444229, 0.017099369317293167, -0.08509741723537445, -0.07051526755094528, 0.06457286328077316, 0.03396391496062279, -0.012629811652004719, -0.09358275681734085, -0.05611142888665199, 0.0845874771475792, 0.06872240453958511, 0.07373158633708954, 0.019175469875335693, -0.029910633340477943, 0.07008569687604904, -0.06547945737838745, -0.06185385212302208, 0.11655683815479279, -0.013130410574376583, 0.025768615305423737, 0.05953441560268402, -0.002278772182762623, -0.013676243834197521, -0.028067396953701973, 0.005901841912418604, -0.08692328631877899, 0.02461344376206398, -0.021612832322716713, -0.042618416249752045, -0.01718795858323574, -0.007981019094586372, -0.04160281643271446, 0.06758691370487213, -0.010842392221093178, 0.018145255744457245, 0.022121164947748184, 0.0333743616938591, 0.06541579216718674, 0.07720496505498886, -0.01991245709359646, 0.035352032631635666, -0.10780113190412521, -0.03387721627950668, 0.035190921276807785, -0.04008086398243904, 0.03285495936870575, 0.042339205741882324, 0.05515679717063904, 0.005778508726507425, -0.034415360540151596, 0.03600217401981354, -0.10340873897075653, -0.006695095915347338, -0.05433854088187218, 0.012591492384672165, 0.03867044299840927, -0.014328273013234138, -0.06717610359191895, 0.06127800792455673, -0.030682308599352837, -0.0719832256436348, -0.007993286475539207, -0.014644532464444637, 0.04962354525923729, 0.005929579492658377, -0.069808229804039, 0.06287699192762375, 0.03921065479516983, 0.0011852402240037918, -0.03302513062953949, -0.0000032792804631753825, 0.025423428043723106, -0.02903510443866253, -0.019193051382899284, 0.015330672264099121, -0.06972309947013855, -0.02815408445894718, -0.0021316951606422663, -0.014683568850159645, 0.004500574432313442, 0.0163477323949337, 0.026047654449939728, 0.008294614963233471, -0.05260938033461571, 0.035933129489421844, 0.014010222628712654, 0.0014568758197128773, 0.005965363699942827, 0.03192208707332611, -0.017791183665394783, -0.009924909099936485, -0.06526058167219162, -0.023770956322550774, -0.02178512141108513, 0.005118871107697487, 0.024010324850678444, 0.04144107177853584, -0.01629270799458027, 0.01041428092867136, 0.018895788118243217, 0.0050164093263447285, 0.014000121504068375, -0.01334382314234972, 0.004243484698235989, -0.005726673640310764, -0.0035770945250988007, 0.053378600627183914, -0.03176279366016388, 0.009529768489301205, 0.024791670963168144, -0.046201784163713455, 0.021986760199069977, 0.01712089404463768, 0.005612724926322699, 0.011731435544788837, 0.005208611488342285, -0.012896547093987465, 0.07158005237579346, 0.0032268925569951534, 0.03163965791463852, -0.12129583209753036, -0.0756591260433197, 0.038527701050043106, 0.028877999633550644, -0.019783852621912956, 0.011896167881786823, 0.05087611824274063, -0.04410697519779205, 0.005164371337741613, 0.018377084285020828, -0.02918502688407898, 0.010161176323890686, 0.024323174729943275, -0.012487273663282394, -0.005902120377868414, -0.07525844126939774, -0.022077884525060654, 0.018647203221917152, -0.015552712604403496, -0.004849399905651808, -0.06075451523065567, 0.06181848794221878, -0.021130157634615898, 0.01312796026468277, -0.006747701205313206, 0.01733766309916973, 0.03499840199947357, 0.032778553664684296, -0.0004080591897945851, -0.030726056545972824, -0.021128686144948006, 0.014261999167501926, -0.011980860494077206, 0.014635290950536728, -0.022203952074050903, 0.0243369173258543, 0.02627444826066494, -0.021355822682380676, 0.02106013521552086, 0.06207623705267906, -0.027867378666996956, -0.04101698845624924, -0.03813117370009422, 0.008859590627253056, -0.03866950422525406, -0.011823494918644428, 0.0005032864282839, -0.0059980531223118305, 0.009425097145140171, -0.049333006143569946, -0.041448723524808884, -0.01453748345375061, -0.009293928742408752, 0.04800661280751228, 0.019694138318300247, 0.0017607141053304076, 0.009636206552386284, 0.02735176868736744, 0.04433922842144966, -0.019001541659235954, -0.037843406200408936, 0.027858031913638115, 0.008534383960068226, -0.025522829964756966, -0.024438658729195595, 0.050743844360113144, -0.025564778596162796, 0.009101293981075287, -0.0016912512946873903, 0.02886076085269451, 0.019748538732528687, -0.025330545380711555, -0.03645620495080948, 0.01657569408416748, -0.005175869911909103, 0.006987480912357569, -0.009689915925264359, -0.029960867017507553, 0.06726057082414627, -0.003772422904148698, 0.011032900772988796, -0.02019653469324112, -0.017635885626077652, 0.017601821571588516, -0.0020973191130906343, -0.006508272141218185, 0.010636969469487667, 0.002357605379074812, 0.0024519267026335, 0.04538866505026817, -0.024346739053726196, -0.01544361561536789, -0.0018523003673180938, 0.013264961540699005, 0.01348796021193266, 0.06758739799261093, 0.042862191796302795, 0.008277414366602898, -0.004324115812778473, 0.03873162344098091, 0.046630989760160446, -0.019658571109175682, 0.015952570363879204, 0.00995541550219059, -0.018467681482434273, 0.062977135181427, -0.03734841197729111, 0.0018162309424951673, -0.03644164279103279, -0.016875991597771645, 0.0016966282855719328, 0.004851589445024729, 0.015364306047558784, -0.07861526310443878, -0.04519233480095863, -0.029250208288431168, -0.015052798204123974, 0.01115988940000534, 0.014015928842127323, -0.011636851355433464, -0.03525754064321518, 0.011656678281724453, 0.004579863045364618, 0.0036793865729123354, -0.030937014147639275, -0.032934822142124176, 0.027134813368320465, -0.01294848881661892, -0.024941623210906982, -0.010519157163798809, -0.003993630409240723, -0.06132590398192406, 0.052585095167160034, -0.010414158925414085, 0.006991566624492407, 0.010168773122131824, -0.008428801782429218, -0.0021406325977295637, 0.011115634813904762, -0.030716435983777046, -0.01667999103665352, 0.015158108435571194, 0.024902598932385445, -0.01872486062347889, 0.0007536930497735739, 0.008208711631596088, -0.031305763870477676, 0.014181593433022499, 0.02140577882528305, 0.04080185666680336, 0.06563938409090042, 0.044659391045570374, -0.024286556988954544, -0.01335595827549696, -0.01489570364356041, -0.002012559911236167, 0.01901458203792572, -0.008957159705460072, -0.02971268631517887, 0.07871834933757782, 0.018009807914495468, 0.009252287447452545, -0.025038857012987137, 0.016785671934485435, 0.00019107536354567856, -0.030093319714069366, 0.03678792342543602, -0.0392947793006897, 0.00968932919204235, 0.009502737782895565, -0.025201814249157906, -0.01656516268849373, 0.020581383258104324, 0.012460589408874512, 0.03104441799223423, 0.0006297887885011733, -0.013105189427733421, 0.05612920597195625, -0.00013304893218446523, 0.016167065128684044, 0.011610518209636211, 0.001450274372473359, -0.0024670588318258524, 0.015988877043128014, -0.017371516674757004, 0.024356061592698097, 0.03655899316072464, 0.0225425586104393, -0.021277565509080887, 0.04301748424768448, 0.0009533545817248523, 0.002286310074850917, -0.015700384974479675, -0.03839244693517685, 0.0275367870926857, 0.0031274750363081694, 0.03338894620537758, -0.016977546736598015, -0.004324545618146658, 0.019524987787008286, 0.019172852858901024, 0.033586569130420685, -0.005855164956301451, -0.023189617320895195, 0.03984788432717323, 0.01761959120631218, 0.004439883399754763, -0.0012222658842802048, 0.028142012655735016, -0.005905397702008486, 0.018450625240802765, -0.01729392819106579, -0.02286621183156967, -0.045756515115499496, -0.0072770859114825726, 0.002372459275647998, -0.03573736175894737, -0.015272500924766064, -0.007669789716601372, 0.020232759416103363, 0.010885817930102348, 0.003649792866781354, 0.033555448055267334, 0.06846074014902115, 0.03994745761156082, 0.024367522448301315, -0.010541577823460102, 0.04051316902041435, 0.03280933201313019, 0.029980966821312904, 0.03289595991373062, 0.0209015104919672, 0.05148206651210785, 0.023859703913331032, 0.0026310477405786514, 0.008087660185992718, -0.04052546247839928, 0.04676191508769989, 0.03356461971998215, 0.013907532207667828, -0.012474710121750832, -0.022002967074513435, -0.040527813136577606, -0.03448374941945076, -0.01636112481355667, -0.016150152310729027, 0.04034043475985527, 0.02917398326098919, 0.03095412813127041, 0.01714821346104145, 0.026767484843730927, 0.0012748766457661986, 0.003444746369495988, -0.005175050813704729, 0.007524494547396898, -0.02842860110104084, -0.0065466477535665035, -0.029241163283586502, 0.008365855552256107, -0.026395559310913086, -0.008147932589054108, -0.05213706195354462, 0.00889818836003542, 0.024981923401355743, 0.017211109399795532, 0.08424173295497894, 0.016990307718515396, 0.01619582436978817, 0.017928292974829674, 0.005742961540818214, 0.0069086672738194466, 0.02569015696644783, -0.014666281640529633, -0.003734721802175045, 0.012940983287990093, -0.02581498585641384, 0.03272419422864914, 0.03902778774499893, -0.02566027082502842, -0.006207162514328957, 0.042039960622787476, 0.03687771409749985, 0.01951025240123272, 0.010672670789062977, -0.023182351142168045, -0.0310535691678524, 0.06646381318569183, -0.004790960345417261, 0.06322122365236282, 0.023685183376073837, 0.017442554235458374, -0.03550615906715393, -0.011349325999617577, 0.017769863829016685, -0.013583768159151077, 0.023244058713316917, 0.009986096993088722, -0.04585987702012062, 0.04407116770744324, -0.030778804793953896, 0.037060052156448364, 0.013644403778016567, 0.027301600202918053, 0.005238181445747614, 0.005295932292938232, -0.012837466783821583, -0.02021954394876957, 0.05038178712129593, 0.04408623278141022, 0.0005193094839341938, -0.020582906901836395, 0.04785563051700592, -0.007117368746548891, -0.024857649579644203, 0.0313163585960865, 0.016581308096647263, -0.017030349001288414, 0.02052823081612587, -0.005621620919555426, -0.02657805010676384, 0.02851470746099949, -0.019709374755620956, 0.012001601979136467, -0.03924080729484558, -0.00238501257263124, -0.02912016399204731, 0.051765039563179016, 0.024087855592370033, -0.0026444068644195795, -0.01953013800084591, 0.024379732087254524, 0.013260032050311565, 0.02143314853310585, 0.02089742198586464, 0.014066537842154503, 0.009381063282489777, 0.04771457239985466, 0.05992980673909187, -0.030809227377176285, 0.045442018657922745, -0.02450975775718689, -0.018091341480612755, 0.006806589663028717, 0.003883852157741785, -0.0020198095589876175, -0.028096778318285942, 0.007838972844183445, 0.01567668467760086, 0.018461039289832115, -0.0035102413967251778, 0.01646583527326584, 0.012512297369539738, -0.03158958628773689, 0.013790884055197239, 0.023148927837610245, 0.05756460502743721, -0.014459432102739811, 0.006003012880682945, -0.005405695177614689, -0.002350978320464492, -0.0049322787672281265, 0.010462453588843346, -0.0023766416124999523, -0.024346960708498955, 0.0044412631541490555, 0.019699575379490852, -0.0434844084084034, 0.0006045258487574756, 0.02836005575954914, -0.003931508399546146, -0.047755979001522064, -0.04198508337140083, 0.011882488615810871, -0.015502114780247211, -0.05282159894704819, -0.0009381319978274405, -0.019466595724225044, -0.022028960287570953, 0.028083961457014084, 0.0013223197311162949, 0.007509457413107157, -0.027935177087783813, -0.003146482165902853, -0.005991744808852673, 0.02110486850142479, -0.01573975197970867, 0.018693961203098297, 0.009835553355515003, 0.0010674725053831935, 0.05532674863934517, -0.009328600950539112, -0.009423882700502872, -0.022120309993624687, -0.03770279884338379, -0.02285965532064438, -0.017543325200676918, -0.05265017971396446, -0.013359545730054379, 0.010768155567348003, -0.011949285864830017, -0.031391534954309464, 0.0184949841350317, 0.018684297800064087, -0.013994963839650154, 0.04674675315618515, -0.0050153424963355064, 0.05001358687877655, -0.05500400811433792, 0.020070506259799004, -0.013887919485569, 0.0010739299468696117, 0.026835765689611435, -0.008979772217571735, -0.03118964470922947, 0.052489329129457474, -0.053993191570043564, -0.0322275385260582, -0.002433354966342449, 0.012803585268557072, -0.053330834954977036, -0.0188840851187706, 0.0028129885904490948, -0.028184799477458, -0.0021315307822078466, 0.015142809599637985, 0.02652047947049141, -0.0213030893355608, 0.004375204909592867, 0.021389342844486237, -0.04079023748636246, 0.009539629332721233, 0.03014855831861496, 0.047851089388132095, 0.04271063208580017, 0.047426436096429825, -0.02121446654200554, 0.028824331238865852, -0.039004936814308167, 0.0025360840372741222, -0.013898623175919056, -0.008902380242943764, -0.037811823189258575, -0.01959773153066635, -0.007566948886960745, -0.03801777958869934, -0.05408317595720291, 0.036871977150440216, 0.03843804448843002, 0.014217502437531948, -0.013446380384266376, 0.011648958548903465, -0.008938262239098549, -0.015868108719587326, 0.0479983314871788, -0.006677032448351383, 0.022832298651337624, 0.01130682323127985, 0.0012581472983583808, 0.019775893539190292, 0.01915757916867733 ]
Boost Wav2Vec2 with n-gram LM in 🤗 Transformers
patrickvonplaten
January 12, 2022
wav2vec2-with-ngram
research, guide, audio
https://huggingface.co/blog/wav2vec2-with-ngram
1. Decoding audio data with Wav2Vec2 and a language model As shown in 🤗 Transformers exemple docs of Wav2Vec2, audio can be transcribed as follows. First, we install datasets and transformers. bash pip install datasets transformers Let's load a small excerpt of the Librispeech dataset to demonstrate Wav2Vec2's speech transcription capabilities. python from datasets import load_dataset dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation") dataset Output: bash Reusing dataset librispeech_asr (/root/.cache/huggingface/datasets/hf-internal-testing___librispeech_asr/clean/2.1.0/f2c70a4d03ab4410954901bde48c54b85ca1b7f9bf7d616e7e2a72b5ee6ddbfc) Dataset({ features: ['file', 'audio', 'text', 'speaker_id', 'chapter_id', 'id'], num_rows: 73 }) We can pick one of the 73 audio samples and listen to it. python audio_sample = dataset[2] audio_sample["text"].lower() Output: bash he tells us that at this festive season of the year with christmas and roast beef looming before us similes drawn from eating and its results occur most readily to the mind Having chosen a data sample, we now load the fine-tuned model and processor. python from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-100h") model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-100h") Next, we process the data python inputs = processor(audio_sample["audio"]["array"], sampling_rate=audio_sample["audio"]["sampling_rate"], return_tensors="pt") forward it to the model python import torch with torch.no_grad(): logits = model(**inputs).logits and decode it python predicted_ids = torch.argmax(logits, dim=-1) transcription = processor.batch_decode(predicted_ids) transcription[0].lower() Output: bash 'he tells us that at this festive season of the year with christmaus and rose beef looming before us simalyis drawn from eating and its results occur most readily to the mind' Comparing the transcription to the target transcription above, we can see that some words sound correct, but are not spelled correctly, e.g.: - christmaus vs. christmas - rose vs. roast - simalyis vs. similes Let's see whether combining Wav2Vec2 with an n-gram lnguage model can help here. First, we need to install pyctcdecode and kenlm. bash pip install https://github.com/kpu/kenlm/archive/master.zip pyctcdecode For demonstration purposes, we have prepared a new model repository patrickvonplaten/wav2vec2-base-100h-with-lm which contains the same Wav2Vec2 checkpoint but has an additional 4-gram language model for English. Instead of using Wav2Vec2Processor, this time we use Wav2Vec2ProcessorWithLM to load the 4-gram model in addition to the feature extractor and tokenizer. python from transformers import Wav2Vec2ProcessorWithLM processor = Wav2Vec2ProcessorWithLM.from_pretrained("patrickvonplaten/wav2vec2-base-100h-with-lm") In constrast to decoding the audio without language model, the processor now directly receives the model's output logits instead of the argmax(logits) (called predicted_ids) above. The reason is that when decoding with a language model, at each time step, the processor takes the probabilities of all possible output characters into account. Let's take a look at the dimension of the logits output. python logits.shape Output: bash torch.Size([1, 624, 32]) We can see that the logits correspond to a sequence of 624 vectors each having 32 entries. Each of the 32 entries thereby stands for the logit probability of one of the 32 possible output characters of the model: python " ".join(sorted(processor.tokenizer.get_vocab())) Output: bash "' </s> <pad> <s> <unk> A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |" Intuitively, one can understand the decoding process of Wav2Vec2ProcessorWithLM as applying beam search through a matrix of size 624 $\times$ 32 probabilities while leveraging the probabilities of the next letters as given by the n-gram language model. OK, let's run the decoding step again. pyctcdecode language model decoder does not automatically convert torch tensors to numpy so we'll have to convert them ourselves before. python transcription = processor.batch_decode(logits.numpy()).text transcription[0].lower() Output: bash 'he tells us that at this festive season of the year with christmas and rose beef looming before us similes drawn from eating and its results occur most readily to the mind' Cool! Recalling the words facebook/wav2vec2-base-100h without a language model transcribed incorrectly previously, e.g., > - christmaus vs. christmas > - rose vs. roast > - simalyis vs. similes we can take another look at the transcription of facebook/wav2vec2-base-100h with a 4-gram language model. 2 out of 3 errors are corrected; christmas and similes have been correctly transcribed. Interestingly, the incorrect transcription of rose persists. However, this should not surprise us very much. Decoding audio without a language model is much more prone to yield spelling mistakes, such as christmaus or similes (those words don't exist in the English language as far as I know). This is because the speech recognition system almost solely bases its prediction on the acoustic input it was given and not really on the language modeling context of previous and successive predicted letters \( {}^1 \). If on the other hand, we add a language model, we can be fairly sure that the speech recognition system will heavily reduce spelling errors since a well-trained n-gram model will surely not predict a word that has spelling errors. But the word rose is a valid English word and therefore the 4-gram will predict this word with a probability that is not insignificant. The language model on its own most likely does favor the correct word roast since the word sequence roast beef is much more common in English than rose beef. Because the final transcription is derived from a weighted combination of facebook/wav2vec2-base-100h output probabilities and those of the n-gram language model, it is quite common to see incorrectly transcribed words such as rose. For more information on how you can tweak different parameters when decoding with Wav2Vec2ProcessorWithLM, please take a look at the official documentation here. ------------------------------------------------------------------------ \({}^1 \) Some research shows that a model such as facebook/wav2vec2-base-100h - when sufficiently large and trained on enough data - can learn language modeling dependencies between intermediate audio representations similar to a language model. Great, now that you have seen the advantages adding an n-gram language model can bring, let's dive into how to create an n-gram and Wav2Vec2ProcessorWithLM from scratch.
[ 0.057313643395900726, -0.01970566436648369, 0.022221064195036888, -0.017001252621412277, -0.018345067277550697, 0.035126879811286926, 0.08782128989696503, 0.008991503156721592, -0.03609316051006317, -0.04095619171857834, -0.07390156388282776, 0.1044878363609314, 0.0328197255730629, 0.03360810875892639, -0.022980239242315292, -0.08273114264011383, 0.007584780920296907, 0.013077633455395699, 0.039517998695373535, 0.01624559797346592, -0.002163538709282875, -0.02222825586795807, 0.04568467289209366, 0.05899955704808235, 0.04404342174530029, -0.021353457123041153, 0.021611636504530907, 0.03319076821208, -0.093488909304142, 0.007761066313832998, -0.14603334665298462, 0.027795737609267235, -0.008919695392251015, -0.05579201504588127, -0.003465513698756695, 0.03812529519200325, -0.1535826474428177, 0.019576774910092354, 0.04012148082256317, -0.055402353405952454, 0.010245739482343197, -0.00039145976188592613, -0.038346290588378906, 0.039040468633174896, -0.010415545664727688, -0.03694917634129524, -0.13739953935146332, 0.06440602242946625, -0.020156338810920715, -0.046661559492349625, -0.0703015998005867, 0.09363258630037308, -0.007755438797175884, 0.0010169962188228965, 0.013644048944115639, -0.021611621603369713, -0.0138800498098135, -0.05001787468791008, -0.010659746825695038, 0.028313258662819862, 0.02904144488275051, -0.019529283046722412, -0.0235361959785223, 0.005122016184031963, 0.04786960408091545, -0.004035993479192257, -0.024309562519192696, 0.07416888326406479, -0.023458344861865044, 0.010858247056603432, -0.023919807747006416, -0.028943534940481186, -0.016668304800987244, -0.03276347368955612, 0.024318121373653412, -0.06200912967324257, 0.01758742704987526, 0.05449216440320015, 0.07812467962503433, 0.0738472267985344, 0.003625126788392663, 0.01963249035179615, 0.05634402111172676, 0.06177527830004692, 0.022144170477986336, -0.03644238039851189, 0.08034718781709671, -0.013225032016634941, -0.07146888226270676, 0.011217369697988033, -0.01262439601123333, -0.12807203829288483, -0.05002079904079437, 0.027009442448616028, 0.02265201322734356, -0.041099343448877335, 0.030637387186288834, 0.059337008744478226, -0.03520875424146652, 0.02430727891623974, -0.03603135421872139, -0.026692204177379608, 0.08055617660284042, -0.02827758714556694, -0.019041085615754128, 0.09613221138715744, -0.05200585722923279, -0.0267939455807209, -0.015076694078743458, -0.007399162743240595, 0.0785352811217308, -0.03689808025956154, 0.01572624407708645, 0.053400248289108276, -0.10183829069137573, -0.007505225017666817, 0.029436424374580383, -0.02979630045592785, -0.03199049085378647, 0.04529158025979996, -0.029681071639060974, 0.07162646949291229, 0.013272936455905437, 0.012104109860956669, 0.016026433557271957, 0.007123870309442282, 0.028911801055073738, 0.005557644180953503, 0.044696737080812454, -0.0072070094756782055, 0.02992158569395542, -0.04496072232723236, 0.11213954538106918, 0.044320862740278244, 0.02214021235704422, -0.040448661893606186, -0.021905144676566124, -0.01712423376739025, 0.04757248982787132, -0.006604200694710016, 0.024040814489126205, 0.0471053346991539, -0.0026888707652688026, 0.00815526396036148, 0.014771148562431335, 0.04253116622567177, -0.0893787145614624, 0.044491738080978394, -0.010805435478687286, 0.054631203413009644, -0.06736147403717041, 0.07304295152425766, -0.0005484072025865316, -0.07136887311935425, 0.0239856094121933, 0.020905325189232826, -0.02865411713719368, -0.0528876893222332, -0.07195363938808441, -0.013348836451768875, 0.018231885507702827, 0.04467260092496872, -0.01125358510762453, -0.003954682033509016, -0.013706354424357414, -0.05444950610399246, -0.06895442306995392, 0.0779462456703186, -0.012578033842146397, -0.0017700379248708487, -0.022068925201892853, -0.024515638127923012, 0.05645257234573364, 0.0017802142538130283, 0.00023317809973377734, 0.06702164560556412, -0.00793361570686102, 0.04611979052424431, -0.008051612414419651, -0.04490753263235092, -0.018414771184325218, 0.04043348506093025, 0.026908069849014282, 0.07084069401025772, 0.05785267427563667, -0.03627903759479523, -0.015787629410624504, -0.020395217463374138, 0.04450630024075508, 0.02072371169924736, -0.009328416548669338, -0.10377531498670578, 0.05155642330646515, -0.019645793363451958, 0.03136112913489342, -0.03732096031308174, -0.012889585457742214, 0.06475624442100525, 0.06505054980516434, 0.05468813329935074, 0.011278952471911907, 0.011990811675786972, 0.022536320611834526, 0.0021636930759996176, -0.0028988495469093323, -0.009294454008340836, 0.036750443279743195, -0.11231768876314163, 0.02769266627728939, 0.030332699418067932, 0.013715165667235851, -0.052074916660785675, 0.04925285652279854, -0.0936799943447113, -0.03422996401786804, -0.05409979447722435, -0.05816319212317467, 0.06331174075603485, -0.009700700640678406, -0.01670871116220951, 0.11794067174196243, -0.039202623069286346, 0.02778393216431141, -0.004865170456469059, -0.01704050414264202, 0.03566897660493851, 0.06084703654050827, 0.08459488302469254, 0.03255188837647438, -0.0414276048541069, -0.0495816133916378, -0.03179319575428963, -0.06704119592905045, -0.01927632838487625, -0.002252482110634446, -0.03879772126674652, 0.02226985991001129, 0.05977938696742058, -0.018208427354693413, 0.029396971687674522, 0.031992025673389435, -0.0635337233543396, -0.07079964131116867, 0.02583339996635914, -0.062240395694971085, -0.03359825536608696, 0.06009414792060852, -0.03360169380903244, -0.011493529193103313, 0.05011532083153725, -0.052511896938085556, 0.04198583960533142, -0.002622656524181366, 0.004901517182588577, -0.0029235484544187784, 0.07713785022497177, 0.03407872095704079, -0.018358193337917328, -0.03364022821187973, 0.021086469292640686, -0.04433844983577728, -0.02633780986070633, 0.0135393887758255, -0.040998462587594986, -0.028895219787955284, -0.06444204598665237, 0.005946186371147633, 0.04234451428055763, 0.006576405372470617, -0.001478234538808465, -0.018332161009311676, -0.005568327382206917, 0.05501743033528328, 0.004717569798231125, 0.04646608233451843, 0.02616904303431511, 0.024527031928300858, -0.016813574358820915, 0.008162989281117916, -0.0162893645465374, 0.02493600733578205, 0.011366407386958599, 0.028517168015241623, 0.0023557431995868683, 0.019549550488591194, -0.004394812975078821, 0.011034656316041946, 0.0073853665962815285, 0.026255838572978973, 0.04396848753094673, 0.009391351602971554, 0.025526104494929314, 0.03900060057640076, -0.023291435092687607, 0.017520397901535034, 0.023368103429675102, 0.008077393285930157, -0.03334028646349907, 0.0027983554173260927, 0.02688276395201683, -0.048493899405002594, -0.027013180777430534, -0.02667894773185253, 0.008282155729830265, -0.02647245302796364, -0.023679709061980247, -0.009613697417080402, -0.003762213746085763, -0.09298323839902878, 0.005218955222517252, -0.012095228768885136, -0.05742301791906357, 0.005615255329757929, 0.0029434910975396633, 0.032192498445510864, 0.007369585335254669, -0.021199557930231094, 0.015311075374484062, 0.006134078837931156, 0.022584086284041405, 0.051142968237400055, -0.0003015038091689348, 0.008603231981396675, -0.01443900540471077, -0.00011684388300636783, 0.01865088939666748, 0.0292060524225235, 0.005550204776227474, -0.009519812650978565, 0.017010074108839035, 0.005189159885048866, 0.016905777156352997, -0.01342348288744688, -0.010068695060908794, 0.058466989547014236, -0.0058097816072404385, -0.00024398330424446613, -0.027150088921189308, -0.0032349007669836283, -0.020881470292806625, 0.023360690101981163, 0.0004584972048178315, -0.037071797996759415, -0.02571464516222477, -0.025563739240169525, 0.0015032213414087892, 0.036412809044122696, 0.050489068031311035, 0.0035145056899636984, -0.027465999126434326, 0.015376544557511806, -0.01083011832088232, 0.006855254992842674, 0.025280509144067764, -0.04404592141509056, -0.01265700813382864, -0.04292503371834755, -0.004917143378406763, -0.039199817925691605, -0.032596051692962646, -0.008434844203293324, 0.06989000737667084, -0.00699634850025177, 0.012963096611201763, 0.02578761801123619, 0.05679181218147278, 0.05481663718819618, -0.010436219163239002, -0.04748283326625824, 0.006625394336879253, -0.0021671238355338573, -0.01832411251962185, -0.021512072533369064, 0.042565759271383286, 0.02647675946354866, 0.001279535936191678, -0.007908396422863007, 0.002243747701868415, 0.021868545562028885, 0.0011273573618382215, 0.017948472872376442, 0.006045865826308727, -0.00878908671438694, 0.01159898191690445, -0.03249227628111839, 0.02662227861583233, 0.06870854645967484, 0.053382813930511475, -0.04009953886270523, -0.02723972499370575, -0.01905483938753605, -0.026956165209412575, 0.008604808710515499, 0.011027076281607151, 0.01413708459585905, -0.02502083219587803, 0.0381835475564003, 0.003950546029955149, 0.00848112441599369, -0.015560336410999298, -0.008954218588769436, -0.014618119224905968, -0.02608378604054451, -0.019085368141531944, -0.0005404117982834578, 0.001374900690279901, -0.024203287437558174, 0.01986333541572094, 0.03067360259592533, -0.09026393294334412, 0.0006751167820766568, 0.019760742783546448, 0.025345638394355774, -0.021690405905246735, -0.04109702259302139, -0.05615173280239105, 0.006698281038552523, -0.0035251048393547535, 0.020730160176753998, -0.006950989831238985, 0.022589130327105522, -0.004400759004056454, 0.020917559042572975, -0.0006115715950727463, -0.010883847251534462, -0.06897655129432678, 0.0015520132146775723, 0.025802087038755417, -0.012496363371610641, -0.008277525193989277, -0.00873484741896391, -0.003438214072957635, 0.05605151131749153, 0.015043274499475956, 0.03490934520959854, 0.0025215374771505594, -0.04632223770022392, 0.0013714154483750463, 0.0056349532678723335, -0.011274420656263828, 0.009145958349108696, 0.012314417399466038, 0.017967719584703445, -0.003897551679983735, 0.017965029925107956, 0.0009242174564860761, 0.003024559933692217, -0.023191623389720917, -0.04452741891145706, -0.02897953800857067, 0.02642570436000824, 0.008582374081015587, -0.01097541581839323, 0.007861346006393433, -0.009702675975859165, -0.06966020166873932, 0.01375887356698513, -0.012190472334623337, 0.03129084035754204, 0.014662934467196465, 0.00397909851744771, 0.020373119041323662, 0.02934858202934265, -0.03400480002164841, -0.010547793470323086, 0.05021698772907257, 0.023984238505363464, 0.053347595036029816, -0.016304515302181244, -0.023039545863866806, -0.053128890693187714, 0.011492730118334293, -0.001891890773549676, 0.01173368003219366, -0.04328387603163719, -0.07827093452215195, 0.002635953715071082, 0.0139773553237319, -0.010706201195716858, 0.018915342167019844, 0.02559218928217888, -0.04293602705001831, -0.0008481224067509174, 0.05379481986165047, 0.015502135269343853, 0.015101735480129719, 0.013300853781402111, -0.0077574653550982475, 0.004115469753742218, -0.015821276232600212, -0.009842274710536003, 0.002284506568685174, -0.05824711173772812, 0.021102748811244965, 0.03841076046228409, 0.062367577105760574, 0.042757049202919006, -0.016175447031855583, 0.020250603556632996, -0.029516270384192467, -0.012130222283303738, -0.07592262327671051, -0.030270401388406754, -0.01967829093337059, 0.017972471192479134, -0.017779894173145294, -0.04936650022864342, -0.02753065526485443, 0.02309306152164936, 0.06308051943778992, 0.00742002297192812, -0.04121386259794235, 0.020850665867328644, -0.05223310738801956, -0.019503680989146233, -0.011201643384993076, -0.012292078696191311, -0.03246212378144264, -0.013802330940961838, -0.030388157814741135, -0.030938634648919106, -0.012027672491967678, 0.002723238430917263, -0.03402247652411461, -0.01696912944316864, 0.01106372382491827, 0.01047592330724001, 0.04450789466500282, -0.014794773422181606, -0.05674026161432266, -0.013476002961397171, 0.009794872254133224, 0.03229809179902077, -0.03166264668107033, 0.02831365540623665, 0.03120763972401619, 0.020433923229575157, -0.018554523587226868, 0.02324555814266205, -0.01709960214793682, 0.005629385821521282, 0.055671971291303635, -0.018777625635266304, -0.010234583169221878, -0.0665624588727951, 0.037001509219408035, 0.024725811555981636, -0.019291948527097702, 0.026052875444293022, 0.005690113641321659, -0.029101433232426643, 0.05951905995607376, -0.03648388385772705, 0.015295729041099548, 0.038797855377197266, 0.017979511991143227, 0.010332485660910606, 0.026661138981580734, 0.013925624080002308, 0.040055371820926666, -0.015788407996296883, -0.019194720312952995, -0.020025894045829773, 0.017398884519934654, 0.00476187514141202, 0.0009624644881114364, -0.0026316323783248663, 0.002071140334010124, 0.01864607073366642, -0.07900301367044449, 0.004035106860101223, 0.048720113933086395, -0.008098926395177841, -0.013094788417220116, 0.028243012726306915, -0.03561010956764221, 0.03730853274464607, 0.01993349939584732, 0.016140397638082504, 0.028722001239657402, -0.018190434202551842, 0.014146470464766026, 0.018150126561522484, -0.031386859714984894, -0.0009861921425908804, 0.07739858329296112, -0.009159795939922333, 0.0474136658012867, 0.03310306742787361, 0.015762224793434143, 0.03394671902060509, 0.0009258022182621062, -0.019468137994408607, 0.029871195554733276, 0.051325444132089615, 0.01292978785932064, 0.05488702654838562, 0.015545233152806759, -0.011806732974946499, -0.014926677569746971, -0.0020932003390043974, -0.0015047760680317879, -0.019523030146956444, 0.023354092612862587, 0.05980272963643074, -0.019812509417533875, 0.017272425815463066, -0.05017586424946785, 0.046227458864450455, 0.02463385835289955, 0.029302895069122314, -0.02131400816142559, 0.05236079916357994, 0.02135779708623886, 0.03052583895623684, -0.00020293729903642088, 0.025303367525339127, 0.021423906087875366, 0.020374255254864693, 0.06773543357849121, 0.02286478318274021, 0.024534190073609352, 0.005847165361046791, -0.02299979142844677, 0.022885603830218315, -0.008785532787442207, -0.017640314996242523, 0.020385608077049255, -0.010221857577562332, -0.03800138831138611, -0.028805091977119446, 0.012085432186722755, -0.010524321347475052, 0.0015823437133803964, -0.009155531413853168, -0.04097844660282135, 0.0017259381711483002, -0.019828516989946365, -0.01598419062793255, 0.07004120945930481, -0.0072577940300107, -0.04179030656814575, -0.041712939739227295, -0.005403608549386263, -0.015149504877626896, 0.02301548607647419, -0.031237754970788956, -0.03383904695510864, -0.0241241455078125, -0.05184878408908844, -0.023903680965304375, 0.03119852766394615, -0.0011523416033014655, -0.028064114972949028, -0.02799944207072258, 0.007316583301872015, 0.0040446193888783455, 0.026027821004390717, 0.015194625593721867, 0.02146444097161293, -0.01689193956553936, 0.006139041855931282, -0.012072188779711723, 0.025954851880669594, -0.0042731184512376785, -0.01993916928768158, 0.011427648365497589, 0.0032335075084120035, -0.006444029044359922, 0.024353478103876114, 0.039584603160619736, -0.0031408858485519886, -0.0758948102593422, -0.003940346650779247, 0.02809431590139866, -0.05509369447827339, 0.04361806809902191, 0.007273170165717602, -0.006210175808519125, -0.014705662615597248, -0.055652353912591934, -0.002184941666200757, 0.00907880812883377, -0.023621661588549614, 0.05561761185526848, -0.012662617489695549, -0.039436470717191696, -0.002964584156870842, 0.040436871349811554, 0.024830302223563194, 0.032509300857782364, -0.0037786909379065037, 0.009536679834127426, 0.010099874809384346, -0.00011712541891029105, 0.03231280669569969, -0.05657200515270233, -0.038194093853235245, -0.02832052856683731, -0.060360752046108246, -0.012045464478433132, 0.0038261874578893185, -0.03245237469673157, -0.004112916998565197, -0.0489274226129055, 0.0013262047432363033, -0.019464384764432907, -0.03437063470482826, -0.013558778911828995, 0.016303138807415962, 0.03195752575993538, 0.01619655266404152, 0.010950344614684582, 0.037145499140024185, -0.03200801834464073, -0.03245937451720238, -0.016545364633202553, 0.03749258071184158, 0.008358919061720371, 0.00723551120609045, -0.006802388466894627, -0.027585342526435852, 0.009664737619459629, -0.007772650104016066, -0.03458621725440025, -0.0030176076106727123, 0.00476031843572855, 0.0015539738815277815, -0.0256282240152359, 0.04450230672955513, -0.0007075226167216897, -0.00762007012963295, 0.05901552364230156, 0.030534332618117332, -0.025648891925811768, 0.021258167922496796, -0.023970963433384895, -0.04590866342186928, 0.01639978401362896, -0.017133032903075218, 0.023390701040625572, 0.030860062688589096, 0.03158300369977951, 0.03967221826314926, 0.005051197484135628, 0.013391575776040554, 0.010939985513687134, 0.03152329847216606, -0.010279850102961063, -0.05907146632671356, 0.002014710335060954, 0.023111307993531227, -0.05057821050286293, -0.024784404784440994, 0.08606129884719849, 0.012201926670968533, -0.022432008758187294, -0.0059354268014431, -0.009673581458628178, -0.02313869260251522, -0.02267482504248619, 0.01934182643890381, -0.02022366411983967, 0.05376874655485153, 0.003358013927936554, 0.029350174590945244, -0.01574680022895336, 0.034938473254442215 ]
Boost Wav2Vec2 with n-gram LM in 🤗 Transformers
patrickvonplaten
January 12, 2022
wav2vec2-with-ngram
research, guide, audio
https://huggingface.co/blog/wav2vec2-with-ngram
=== 4/5 Calculating and writing order-interpolated probabilities === Chain sizes: 1:4322496 2:87627856 3:363553620 4:728999592 5:1042486228 ----5---10---15---20---25---30---35---40---45---50---55---60---65---70---75---80---85---90---95--100
[ 0.017107149586081505, 0.03253769129514694, 0.06274954229593277, -0.00039442526758648455, 0.1466892957687378, 0.006192381959408522, 0.037383321672677994, -0.00839193258434534, -0.05258677154779434, -0.04041639342904091, -0.04270840436220169, -0.03302058205008507, -0.00080726551823318, -0.0068437992595136166, -0.018119890242815018, 0.07189446687698364, 0.0800018161535263, 0.04692515730857849, 0.03104298561811447, -0.062170810997486115, -0.06151089072227478, 0.011569369584321976, 0.030346281826496124, -0.01666107587516308, 0.0445052795112133, 0.0043982756324112415, -0.012849932536482811, 0.05741814896464348, -0.024244748055934906, 0.02241826057434082, -0.08667303621768951, 0.016766773536801338, 0.008846297860145569, -0.07880976796150208, 0.030205274000763893, -0.030948136001825333, -0.10511059314012527, 0.00328070973046124, 0.03627673164010048, 0.01752890646457672, 0.026461342349648476, -0.054534509778022766, -0.03653277829289436, 0.023447301238775253, -0.03455653786659241, -0.020393220707774162, -0.11319687217473984, 0.07377143949270248, -0.035825345665216446, 0.003418495412915945, -0.08205033838748932, 0.005659756250679493, -0.013603619299829006, 0.016854779794812202, 0.016138721257448196, -0.05208826810121536, 0.03256804868578911, -0.04800396412611008, 0.04428733512759209, 0.020384786650538445, 0.0941556915640831, -0.010570208542048931, 0.028729867190122604, 0.059945959597826004, 0.027996007353067398, 0.03282129392027855, 0.005097642540931702, 0.08714625984430313, 0.00318626849912107, -0.012989095412194729, 0.017909105867147446, 0.026026122272014618, 0.031877562403678894, 0.012113641947507858, 0.04919065907597542, -0.016316596418619156, -0.04601488262414932, 0.08853327482938766, -0.006042758468538523, 0.009106672368943691, 0.0018872254295274615, -0.03472943231463432, 0.009424690157175064, 0.062022753059864044, 0.032749369740486145, -0.0247957743704319, 0.07166418433189392, -0.023712435737252235, 0.027323583140969276, 0.08670160919427872, -0.044715527445077896, -0.05622875690460205, -0.061093706637620926, 0.01144325453788042, -0.029266733676195145, -0.03853829577565193, 0.01348006073385477, 0.038717180490493774, -0.011402414180338383, -0.0032122451812028885, -0.0019768134225159883, -0.006378348916769028, 0.057790834456682205, -0.009639878757297993, -0.02548987790942192, 0.05905919522047043, -0.007820441387593746, -0.08818740397691727, -0.062427110970020294, -0.05590420588850975, -0.05294044688344002, 0.011819367296993732, 0.02607003226876259, 0.05723511427640915, -0.029434096068143845, 0.0391550213098526, 0.03366219997406006, 0.027209876105189323, -0.015055670402944088, -0.002802025992423296, 0.006640453357249498, 0.06931126862764359, 0.08938354253768921, -0.00811642687767744, 0.025621386244893074, 0.04154607653617859, 0.06814293563365936, 0.02277650684118271, -0.025470014661550522, -0.022636987268924713, 0.0029161630664020777, 0.050916220992803574, -0.04622117802500725, -0.043726563453674316, 0.024550138041377068, -0.07290100306272507, -0.056999094784259796, 0.041007496416568756, -0.01107676513493061, -0.06179256737232208, -0.036056529730558395, 0.025720665231347084, -0.024567781016230583, 0.1099231019616127, 0.03551647439599037, 0.0032451823353767395, -0.054074209183454514, -0.012387498281896114, -0.03833785653114319, 0.11623304337263107, 0.029620805755257607, 0.016248885542154312, -0.006410427391529083, -0.03826180472970009, -0.01279274933040142, 0.008375450037419796, 0.0035108081065118313, -0.03415558859705925, -0.161584734916687, -0.06467181444168091, 0.029933705925941467, 0.037714701145887375, -0.00982442032545805, -0.05227030813694, 0.06494049727916718, -0.00046477324212901294, 0.04462986811995506, 0.040950071066617966, -0.025017352774739265, -0.010640186257660389, 0.018200820311903954, -0.05910642817616463, 0.037263646721839905, -0.021201981231570244, -0.03939075767993927, 0.10970349609851837, 0.016447583213448524, 0.05888476222753525, 0.029843075200915337, -0.06314519047737122, -0.03433263301849365, -0.009908243082463741, 0.005795533303171396, -0.006269179750233889, -0.03457620367407799, -0.050173159688711166, -0.0016252690693363547, -0.031150106340646744, 0.005021288525313139, 0.06098494306206703, -0.05845075100660324, -0.027318745851516724, 0.06682327389717102, 0.055144619196653366, -0.018436847254633904, -0.08366743475198746, -0.05314670503139496, 0.07490997016429901, 0.05244697257876396, 0.03177566081285477, -0.020548714324831963, 0.03315301239490509, 0.0555029958486557, -0.019717108458280563, 0.009697585366666317, -0.04629466310143471, 0.03436030074954033, -0.06732570379972458, 0.06388914585113525, -0.033361755311489105, 0.010492536239326, -0.03165145590901375, 0.0010228720493614674, -0.07415328919887543, -0.02128800004720688, 0.008747544139623642, 0.06633679568767548, 0.023576531559228897, 0.08593463897705078, 0.008512570522725582, 0.11826258897781372, 0.051897283643484116, 0.01639932207763195, -0.05425744131207466, -0.02034367062151432, 0.0605035126209259, 0.055723607540130615, 0.04636651650071144, -0.0017514587379992008, -0.036714162677526474, -0.0025802527088671923, 0.04272148385643959, 0.038900189101696014, 0.08895067870616913, 0.05313033238053322, 0.014468222856521606, -0.031744398176670074, 0.006874124053865671, 0.002298892242833972, -0.06051455810666084, 0.027698269113898277, 0.01676618494093418, -0.04911021888256073, 0.05091656744480133, -0.027247365564107895, 0.023681797087192535, 0.0865134745836258, -0.015454207547008991, -0.06626344472169876, 0.012907126918435097, -0.04089629650115967, -0.001196378143504262, -0.019137326627969742, -0.0490136556327343, 0.006963782478123903, 0.08291418850421906, -0.014898779802024364, -0.013958912342786789, 0.0035308594815433025, -0.016007082536816597, -0.014172084629535675, -0.03290385380387306, 0.007419330533593893, 0.005601869430392981, 0.013648930937051773, 0.010315830819308758, 0.010719986632466316, -0.025929810479283333, -0.026082461699843407, 0.06871408224105835, 0.04186813905835152, -0.009278988465666771, 0.03601158410310745, -0.00041382372728548944, 0.018591465428471565, -0.041345153003931046, 0.04063707962632179, -0.016641538590192795, -0.023024018853902817, -0.00227855471894145, -0.022241612896323204, -0.024593735113739967, 0.026367787271738052, 0.019760750234127045, 0.013976079411804676, 0.012338020838797092, 0.002827518153935671, 0.017202405259013176, 0.020980780944228172, 0.01997118443250656, 0.003919920884072781, 0.025491470471024513, 0.03614448383450508, 0.02424832247197628, 0.03630359470844269, -0.0223670843988657, -0.032314494252204895, -0.014874417334794998, 0.012143350206315517, -0.04737946763634682, 0.03467043861746788, -0.01926618255674839, -0.013181520625948906, -0.00890273880213499, -0.061007339507341385, 0.010948064737021923, -0.034256961196660995, 0.09166602790355682, -0.10639981925487518, 0.006777316331863403, 0.0348048061132431, 0.013995194807648659, 0.0012936200946569443, -0.001374848303385079, 0.06863714009523392, -0.049600303173065186, 0.0023568400647491217, 0.035843316465616226, 0.029600366950035095, -0.011987763457000256, -0.008293075487017632, -0.028242791071534157, 0.05038038641214371, -0.03765377774834633, 0.00031998188933357596, -0.013843105174601078, 0.027964605018496513, 0.008341176435351372, 0.008596165105700493, 0.04780127480626106, -0.029822057113051414, -0.029438145458698273, -0.03051421232521534, 0.03264596313238144, 0.012244102545082569, 0.015742886811494827, 0.019058020785450935, -0.058332230895757675, -0.022050894796848297, 0.012770306318998337, -0.04653264209628105, -0.007284108549356461, -0.07203532755374908, 0.005775884725153446, 0.007933170534670353, -0.013038300909101963, -0.035110488533973694, 0.038589026778936386, -0.002181445946916938, -0.013676880858838558, 0.03408248350024223, -0.004210236947983503, 0.0005877406802028418, -0.008580552414059639, 0.006166884675621986, -0.025365006178617477, 0.03403883054852486, -0.020545989274978638, 0.01634114794433117, -0.02919469028711319, -0.0011405834229663014, -0.012129882350564003, -0.014787347055971622, 0.0038153808563947678, -0.0076112509705126286, -0.00909128412604332, 0.04749690368771553, -0.00767890177667141, -0.0411539264023304, -0.014718587510287762, -0.010879339650273323, -0.06472554802894592, -0.009247101843357086, 0.02452877350151539, 0.03348790109157562, 0.07013288885354996, -0.023607533425092697, 0.021649478003382683, 0.02791406773030758, 0.007265167310833931, -0.0008726465166546404, 0.012922054156661034, -0.035234466195106506, -0.018716176971793175, -0.04414844512939453, 0.0016752576921135187, 0.030887272208929062, 0.01076923031359911, 0.006177824921905994, 0.008757060393691063, -0.0666622593998909, 0.00673455186188221, -0.014943262562155724, -0.005165969021618366, -0.013708737678825855, 0.05220228061079979, -0.017443832010030746, -0.03188886493444443, 0.03774316981434822, 0.00939847156405449, 0.029257677495479584, 0.019427092745900154, -0.04174741730093956, 0.01877528801560402, 0.030290303751826286, -0.04010429233312607, 0.02018217369914055, 0.06373703479766846, 0.05263979360461235, -0.02352948859333992, 0.026964977383613586, -0.030495140701532364, -0.054863013327121735, 0.011122292838990688, -0.033683426678180695, -0.047147758305072784, -0.03495708853006363, -0.005015220958739519, 0.02984110824763775, -0.057854872196912766, 0.04588557407259941, -0.03629499673843384, 0.04956384375691414, -0.0003129244432784617, -0.015971237793564796, -0.03566747158765793, -0.02125418186187744, -0.0005836518830619752, -0.022953659296035767, -0.013537995517253876, 0.02226940356194973, -0.01460062526166439, -0.021039284765720367, -0.019055340439081192, -0.023844966664910316, 0.016698047518730164, 0.013994099572300911, -0.003361141076311469, -0.012506626546382904, -0.0097281439229846, 0.024968024343252182, -0.01965452916920185, 0.01633896864950657, -0.0071668000891804695, -0.027148133143782616, 0.026641402393579483, -0.040638674050569534, -0.06207243725657463, -0.008579310029745102, -0.03246201574802399, 0.03347986936569214, -0.01476242858916521, 0.01868591085076332, -0.03249732404947281, -0.013456247746944427, -0.016605889424681664, 0.02029242366552353, 0.018668334931135178, 0.034112557768821716, -0.02410505712032318, -0.03753995522856712, 0.018110118806362152, 0.008326646871864796, -0.00897590909153223, 0.016501357778906822, -0.0343373604118824, -0.025946173816919327, 0.021315203979611397, -0.001538155134767294, -0.0382186658680439, -0.04720538854598999, 0.008555816486477852, -0.05749877169728279, -0.008899606764316559, 0.00716804014518857, -0.02440711483359337, -0.02452888712286949, -0.003927023150026798, 0.003950193058699369, -0.007724590599536896, -0.008059327490627766, -0.01715073734521866, 0.04430216923356056, 0.035362739115953445, -0.005289601627737284, -0.014246894977986813, 0.014352882280945778, -0.006589497439563274, -0.019923117011785507, -0.026164241135120392, 0.041559506207704544, -0.017101090401411057, -0.03953386843204498, 0.028280124068260193, 0.03419579192996025, 0.04057915881276131, 0.052580658346414566, 0.05554623901844025, -0.0006605652743019164, 0.01717967353761196, 0.05845127999782562, -0.024182675406336784, 0.0007997880456969142, -0.028214633464813232, 0.04515876993536949, 0.009341057389974594, 0.029839152470231056, 0.004300025757402182, 0.07023659348487854, 0.04335050284862518, 0.013786330819129944, -0.04211379587650299, 0.02252396009862423, -0.006031353026628494, 0.01692929118871689, -0.0037535936571657658, 0.04218892753124237, -0.02629934251308441, 0.018937313929200172, -0.012600399553775787, -0.07380662858486176, -0.018901953473687172, 0.027251796796917915, -0.0028572878800332546, -0.04625316336750984, -0.032502368092536926, -0.0024558566510677338, 0.048698797821998596, 0.009148309007287025, -0.014689712785184383, -0.037480998784303665, 0.021681657060980797, 0.06136820837855339, 0.004335278179496527, 0.009203837253153324, 0.010784367099404335, 0.05365722253918648, 0.012456250376999378, 0.03841044753789902, -0.03259147331118584, 0.028919661417603493, -0.004716150462627411, 0.029402481392025948, 0.006697249598801136, -0.046049583703279495, 0.02654130943119526, -0.009124650619924068, 0.003546983702108264, -0.029825452715158463, -0.006781965959817171, -0.029864046722650528, 0.003163999645039439, -0.00045501647400669754, -0.029047474265098572, 0.06637533009052277, -0.0005250118556432426, 0.02627475932240486, 0.012317280285060406, 0.009892703965306282, -0.039310481399297714, 0.03646402060985565, -0.0007704261806793511, -0.014539645053446293, 0.020721925422549248, -0.003539465134963393, -0.03215070813894272, 0.0006287215510383248, 0.02161807008087635, 0.03155364841222763, -0.029454533010721207, 0.03648928552865982, -0.0073875910602509975, -0.034759677946567535, 0.044856078922748566, -0.029865605756640434, -0.014394843950867653, 0.005001051817089319, 0.016820132732391357, 0.01969520002603531, 0.04125036299228668, 0.030449410900473595, 0.022875512018799782, -0.025060517713427544, -0.016672838479280472, 0.03636246547102928, 0.03219948709011078, -0.05119018629193306, 0.01701602339744568, 0.006859605200588703, 0.015270723961293697, -0.010464604943990707, 0.02723062038421631, -0.03373730927705765, 0.041728951036930084, 0.025250600650906563, -0.0292225182056427, 0.01862875372171402, 0.03640872985124588, -0.01888319104909897, 0.006796758156269789, -0.04839766025543213, -0.06153222918510437, -0.06242568418383598, -0.010960228741168976, -0.022990530356764793, 0.03166591003537178, 0.023741960525512695, -0.04488547891378403, 0.040052395313978195, -0.0015568681992590427, 0.02615845762193203, -0.015750238671898842, -0.010606235824525356, -0.018587591126561165, -0.022387979552149773, -0.05499992147088051, 0.038957949727773666, 0.00408928981050849, -0.014592267572879791, 0.03743985295295715, -0.032248105853796005, -0.0026696487329900265, 0.04331868886947632, -0.019824694842100143, -0.008153257891535759, -0.05749304220080376, -0.03976159170269966, 0.0035094814375042915, 0.003441693726927042, -0.03998314589262009, 0.006650015711784363, 0.018557747825980186, -0.02489105425775051, -0.012628212571144104, 0.015982771292328835, 0.0028495045844465494, -0.008622659370303154, 0.01564633846282959, -0.004451307933777571, 0.047117821872234344, 0.010218659415841103, -0.003671571146696806, -0.03071349859237671, 0.0385531410574913, -0.0020041593816131353, -0.005517964251339436, -0.030636996030807495, -0.00497227068990469, -0.031392935663461685, 0.006530302576720715, -0.009852088056504726, -0.002269046613946557, -0.007381012663245201, -0.020259050652384758, 0.02740158699452877, 0.027313649654388428, -0.01993516832590103, 0.02576000988483429, 0.037912845611572266, 0.04035622626543045, -0.009431609883904457, 0.01007044780999422, -0.012534501031041145, -0.01665486767888069, 0.03463566303253174, 0.022292008623480797, -0.030989274382591248, -0.03800220787525177, 0.02944638393819332, -0.033982209861278534, -0.025745941326022148, -0.031101185828447342, -0.03659207001328468, -0.04159647971391678, -0.04640874266624451, 0.04736006632447243, -0.05031217634677887, 0.032618485391139984, -0.002523497212678194, -0.005473282188177109, -0.00641834270209074, -0.005302809178829193, -0.05057080090045929, -0.006883120164275169, 0.0027787997387349606, 0.015262564644217491, -0.030397946015000343, 0.0027889644261449575, -0.027392258867621422, 0.0240130964666605, 0.00037883842014707625, 0.05174187198281288, 0.021641310304403305, 0.04048759490251541, 0.013874959200620651, -0.013101456686854362, -0.06520172953605652, 0.061293456703424454, -0.025599269196391106, -0.03955215588212013, -0.048248540610075, -0.010820888914167881, -0.021713213995099068, 0.003939327318221331, -0.008408566936850548, -0.0201787818223238, -0.008409564383327961, -0.017460517585277557, -0.02170802652835846, -0.004063755739480257, -0.001725542708300054, 0.0007200338877737522, 0.01731007732450962, 0.012117872014641762, 0.01737256720662117, 0.008833900094032288, -0.015192844904959202, 0.05620061978697777, 0.004303813446313143, -0.01415689755231142, -0.007618113420903683, 0.029742399230599403, 0.031753141433000565, -0.06994657218456268, -0.04648750647902489, -0.023244116455316544, -0.014193619601428509, -0.04861924424767494, -0.0001903413940453902, -0.025906847789883614, 0.030585436150431633, 0.05519722402095795, 0.022649085149168968, 0.039424218237400055, 0.05777622014284134, -0.023586483672261238, 0.013571922667324543, -0.019660087302327156, 0.014840472489595413, 0.026356864720582962, 0.008186151273548603, 0.02329224906861782, 0.02547132782638073, 0.00938545074313879, 0.02199002355337143, -0.022796308621764183, 0.029986664652824402, 0.03803163021802902, -0.028957899659872055, -0.015796760097146034, 0.012756823562085629, 0.04483798146247864, -0.006421507801860571, -0.057818278670310974, 0.018321802839636803, 0.013339598663151264, -0.02995520457625389, -0.04584379866719246, 0.041524048894643784, 0.030745407566428185, -0.0026623569428920746, -0.013771219179034233, 0.0019466388039290905, 0.0376952700316906, -0.01970776356756687, 0.017888803035020828, -0.00015811831690371037, 0.007207053247839212 ]
Boost Wav2Vec2 with n-gram LM in 🤗 Transformers
patrickvonplaten
January 12, 2022
wav2vec2-with-ngram
research, guide, audio
https://huggingface.co/blog/wav2vec2-with-ngram
4. Combine an n-gram with Wav2Vec2 In a final step, we want to wrap the 5-gram into a Wav2Vec2ProcessorWithLM object to make the 5-gram boosted decoding as seamless as shown in Section 1. We start by downloading the currently "LM-less" processor of xls-r-300m-sv. python from transformers import AutoProcessor processor = AutoProcessor.from_pretrained("hf-test/xls-r-300m-sv") Next, we extract the vocabulary of its tokenizer as it represents the "labels" of pyctcdecode's BeamSearchDecoder class. python vocab_dict = processor.tokenizer.get_vocab() sorted_vocab_dict = {k.lower(): v for k, v in sorted(vocab_dict.items(), key=lambda item: item[1])} The "labels" and the previously built 5gram_correct.arpa file is all that's needed to build the decoder. python from pyctcdecode import build_ctcdecoder decoder = build_ctcdecoder( labels=list(sorted_vocab_dict.keys()), kenlm_model_path="5gram_correct.arpa", ) Output: bash Found entries of length > 1 in alphabet. This is unusual unless style is BPE, but the alphabet was not recognized as BPE type. Is this correct? Unigrams and labels don't seem to agree. We can safely ignore the warning and all that is left to do now is to wrap the just created decoder, together with the processor's tokenizer and feature_extractor into a Wav2Vec2ProcessorWithLM class. python from transformers import Wav2Vec2ProcessorWithLM processor_with_lm = Wav2Vec2ProcessorWithLM( feature_extractor=processor.feature_extractor, tokenizer=processor.tokenizer, decoder=decoder ) We want to directly upload the LM-boosted processor into the model folder of xls-r-300m-sv to have all relevant files in one place. Let's clone the repo, add the new decoder files and upload them afterward. First, we need to install git-lfs. bash sudo apt-get install git-lfs tree Cloning and uploading of modeling files can be done conveniently with the huggingface_hub's Repository class. More information on how to use the huggingface_hub to upload any files, please take a look at the official docs. python from huggingface_hub import Repository repo = Repository(local_dir="xls-r-300m-sv", clone_from="hf-test/xls-r-300m-sv") Output: bash Cloning https://huggingface.co/hf-test/xls-r-300m-sv into local empty directory. Having cloned xls-r-300m-sv, let's save the new processor with LM into it. python processor_with_lm.save_pretrained("xls-r-300m-sv") Let's inspect the local repository. The tree command conveniently can also show the size of the different files. bash tree -h xls-r-300m-sv/ Output: bash xls-r-300m-sv/ ├── [ 23] added_tokens.json ├── [ 401] all_results.json ├── [ 253] alphabet.json ├── [2.0K] config.json ├── [ 304] emissions.csv ├── [ 226] eval_results.json ├── [4.0K] language_model │   ├── [4.1G] 5gram_correct.arpa │   ├── [ 78] attrs.json │   └── [4.9M] unigrams.txt ├── [ 240] preprocessor_config.json ├── [1.2G] pytorch_model.bin ├── [3.5K] README.md ├── [4.0K] runs │   └── [4.0K] Jan09_22-00-50_brutasse │   ├── [4.0K] 1641765760.8871996 │   │   └── [4.6K] events.out.tfevents.1641765760.brutasse.31164.1 │   ├── [ 42K] events.out.tfevents.1641765760.brutasse.31164.0 │   └── [ 364] events.out.tfevents.1641794162.brutasse.31164.2 ├── [1.2K] run.sh ├── [ 30K] run_speech_recognition_ctc.py ├── [ 502] special_tokens_map.json ├── [ 279] tokenizer_config.json ├── [ 29K] trainer_state.json ├── [2.9K] training_args.bin ├── [ 196] train_results.json ├── [ 319] vocab.json └── [4.0K] wandb ├── [ 52] debug-internal.log -> run-20220109_220240-1g372i3v/logs/debug-internal.log ├── [ 43] debug.log -> run-20220109_220240-1g372i3v/logs/debug.log ├── [ 28] latest-run -> run-20220109_220240-1g372i3v └── [4.0K] run-20220109_220240-1g372i3v ├── [4.0K] files │   ├── [8.8K] conda-environment.yaml │   ├── [140K] config.yaml │   ├── [4.7M] output.log │   ├── [5.4K] requirements.txt │   ├── [2.1K] wandb-metadata.json │   └── [653K] wandb-summary.json ├── [4.0K] logs │   ├── [3.4M] debug-internal.log │   └── [8.2K] debug.log └── [113M] run-1g372i3v.wandb 9 directories, 34 files As can be seen the 5-gram LM is quite large - it amounts to more than 4 GB. To reduce the size of the n-gram and make loading faster, kenLM allows converting .arpa files to binary ones using the build_binary executable. Let's make use of it here. bash kenlm/build/bin/build_binary xls-r-300m-sv/language_model/5gram_correct.arpa xls-r-300m-sv/language_model/5gram.bin Output: bash Reading xls-r-300m-sv/language_model/5gram_correct.arpa ----5---10---15---20---25---30---35---40---45---50---55---60---65---70---75---80---85---90---95--100 **************************************************************************************************** SUCCESS Great, it worked! Let's remove the .arpa file and check the size of the binary 5-gram LM. bash rm xls-r-300m-sv/language_model/5gram_correct.arpa && tree -h xls-r-300m-sv/ Output: bash xls-r-300m-sv/ ├── [ 23] added_tokens.json ├── [ 401] all_results.json ├── [ 253] alphabet.json ├── [2.0K] config.json ├── [ 304] emissions.csv ├── [ 226] eval_results.json ├── [4.0K] language_model │   ├── [1.8G] 5gram.bin │   ├── [ 78] attrs.json │   └── [4.9M] unigrams.txt ├── [ 240] preprocessor_config.json ├── [1.2G] pytorch_model.bin ├── [3.5K] README.md ├── [4.0K] runs │   └── [4.0K] Jan09_22-00-50_brutasse │   ├── [4.0K] 1641765760.8871996 │   │   └── [4.6K] events.out.tfevents.1641765760.brutasse.31164.1 │   ├── [ 42K] events.out.tfevents.1641765760.brutasse.31164.0 │   └── [ 364] events.out.tfevents.1641794162.brutasse.31164.2 ├── [1.2K] run.sh ├── [ 30K] run_speech_recognition_ctc.py ├── [ 502] special_tokens_map.json ├── [ 279] tokenizer_config.json ├── [ 29K] trainer_state.json ├── [2.9K] training_args.bin ├── [ 196] train_results.json ├── [ 319] vocab.json └── [4.0K] wandb ├── [ 52] debug-internal.log -> run-20220109_220240-1g372i3v/logs/debug-internal.log ├── [ 43] debug.log -> run-20220109_220240-1g372i3v/logs/debug.log ├── [ 28] latest-run -> run-20220109_220240-1g372i3v └── [4.0K] run-20220109_220240-1g372i3v ├── [4.0K] files │   ├── [8.8K] conda-environment.yaml │   ├── [140K] config.yaml │   ├── [4.7M] output.log │   ├── [5.4K] requirements.txt │   ├── [2.1K] wandb-metadata.json │   └── [653K] wandb-summary.json ├── [4.0K] logs │   ├── [3.4M] debug-internal.log │   └── [8.2K] debug.log └── [113M] run-1g372i3v.wandb 9 directories, 34 files Nice, we reduced the n-gram by more than half to less than 2GB now. In the final step, let's upload all files. python repo.push_to_hub(commit_message="Upload lm-boosted decoder") Output: bash Git LFS: (1 of 1 files) 1.85 GB / 1.85 GB Counting objects: 9, done. Delta compression using up to 2 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 1.23 MiB | 1.92 MiB/s, done. Total 9 (delta 3), reused 0 (delta 0) To https://huggingface.co/hf-test/xls-r-300m-sv 27d0c57..5a191e2 main -> main That's it. Now you should be able to use the 5gram for LM-boosted decoding as shown in Section 1. As can be seen on xls-r-300m-sv's model card our 5gram LM-boosted decoder yields a WER of 18.85% on Common Voice's 7 test set which is a relative performance of ca. 30% 🔥.
[ 0.027681395411491394, -0.017303958535194397, -0.024825414642691612, -0.029918920248746872, 0.013730478473007679, 0.043943583965301514, 0.0495443120598793, -0.013242870569229126, -0.033910464495420456, 0.0019356966949999332, -0.04832069203257561, 0.03425665199756622, -0.008760983124375343, 0.06877094507217407, 0.03228526934981346, -0.02767973579466343, 0.0411381870508194, 0.013390254229307175, 0.020840901881456375, 0.04409121721982956, 0.0006832120125181973, -0.029389798641204834, 0.07798805087804794, 0.07788429409265518, 0.08017189800739288, 0.02120276167988777, 0.0014910221798345447, 0.014250034466385841, -0.052203502506017685, -0.020357543602585793, -0.057444289326667786, 0.023582277819514275, 0.01034136489033699, -0.029837073758244514, 0.037428051233291626, 0.057363398373126984, -0.07991292327642441, 0.07450368255376816, 0.025419192388653755, -0.07298331707715988, 0.031132061034440994, -0.010701900348067284, -0.08570076525211334, 0.06680900603532791, -0.009267969988286495, -0.040004078298807144, -0.0811513215303421, 0.04521217942237854, -0.04777582734823227, -0.01144619844853878, -0.02748454362154007, 0.0035138316452503204, 0.014587941579520702, 0.029075954109430313, 0.04746390879154205, 0.011047913692891598, -0.040891751646995544, -0.069501593708992, 0.03274260833859444, 0.02421746589243412, -0.028759317472577095, -0.0422435998916626, -0.029593005776405334, 0.005844991188496351, 0.014635270461440086, 0.012889615260064602, -0.03172249346971512, 0.07864436507225037, -0.05338563397526741, -0.003116871928796172, -0.027598440647125244, -0.03255968913435936, -0.05709762126207352, -0.0002333832235308364, 0.03975556418299675, -0.109254390001297, -0.014571446925401688, 0.0018248135456815362, 0.02852378599345684, 0.07384612411260605, 0.02277451567351818, 0.035052113234996796, -0.009644021280109882, 0.027457423508167267, 0.030579326674342155, 0.028652358800172806, 0.055832866579294205, -0.023087602108716965, -0.03564983233809471, 0.02997014671564102, -0.037375956773757935, -0.1476840078830719, -0.02862771973013878, 0.013542861677706242, 0.03617272153496742, -0.019591331481933594, -0.06563612073659897, 0.04029656574130058, -0.036700643599033356, 0.014178412035107613, -0.02241821587085724, -0.06474868953227997, -0.010186891071498394, 0.05028086155653, -0.03198818862438202, 0.08006708323955536, -0.06211749091744423, -0.03130228817462921, -0.04053410887718201, -0.02328360639512539, 0.032725680619478226, 0.013233961537480354, -0.010283872485160828, 0.04406575858592987, -0.018461721017956734, 0.0020288676023483276, 0.050498608499765396, 0.040504999458789825, -0.024236224591732025, 0.039115019142627716, -0.021751243621110916, 0.14281408488750458, 0.038921672850847244, -0.013208817690610886, 0.029288651421666145, 0.024956392124295235, 0.010076943784952164, -0.0034857108257710934, -0.0056144618429243565, 0.03779147192835808, 0.020398607477545738, 0.04230865091085434, 0.09252078086137772, 0.039280910044908524, -0.018660781905055046, -0.061334725469350815, -0.0365065261721611, 0.02344541996717453, -0.03543974831700325, -0.002132802503183484, -0.0010911569697782397, 0.074781134724617, -0.03527982532978058, -0.03424574434757233, -0.005764364264905453, 0.03815946727991104, -0.026300135999917984, 0.1254064440727234, -0.03534752503037453, 0.0021530999802052975, -0.023608267307281494, 0.025572706013917923, -0.0602642297744751, -0.06741597503423691, 0.05288763716816902, 0.05808577314019203, -0.02786337025463581, 0.011019714176654816, -0.0679640993475914, 0.05177513137459755, 0.01307921763509512, 0.02262263000011444, -0.024386046454310417, 0.021611901000142097, -0.01799195632338524, -0.0765390619635582, -0.012392359785735607, 0.05107032507658005, 0.014085579663515091, 0.012355185113847256, 0.013095428235828876, 0.002777320332825184, 0.04453755542635918, 0.038810212165117264, -0.026943843811750412, 0.021079666912555695, 0.08750000596046448, 0.03876492753624916, -0.039966385811567307, -0.040411654859781265, -0.011584197171032429, 0.03971049189567566, -0.025546392425894737, -0.0003362209827173501, 0.0032301389146596193, -0.02333398163318634, 0.06888454407453537, -0.04844248294830322, -0.02123062126338482, 0.02652016468346119, 0.026186728850007057, -0.07746775448322296, 0.038271285593509674, 0.00032164945150725543, -0.0343705490231514, -0.023318013176321983, -0.012687484733760357, 0.13186003267765045, -0.0010960099752992392, 0.0084663275629282, 0.05271819978952408, 0.03979850187897682, 0.019305890426039696, -0.008858609944581985, 0.014041044749319553, 0.011619830504059792, -0.027024701237678528, -0.12400726228952408, 0.0004131394380237907, 0.035464994609355927, 0.021499397233128548, 0.013746635988354683, 0.04813867062330246, -0.12910783290863037, -0.018677834421396255, 0.008668322116136551, -0.04720066487789154, 0.004118969663977623, 0.011150306090712547, -0.033807095140218735, 0.08157560974359512, -0.06167114898562431, -0.02521350234746933, 0.0443100705742836, -0.0628066211938858, 0.052629824727773666, 0.10764684528112411, -0.007669420447200537, -0.004940997809171677, -0.09020563215017319, -0.051290471106767654, -0.1086876168847084, -0.0416494682431221, 0.03003719076514244, -0.05581089109182358, 0.00901681650429964, 0.006377466022968292, 0.029653942212462425, -0.0090559720993042, -0.028062984347343445, 0.05648249387741089, -0.04107049107551575, -0.07557303458452225, -0.02001195400953293, -0.011604984290897846, -0.011959142982959747, 0.08083554357290268, 0.012060925364494324, 0.029131034389138222, -0.009290078654885292, 0.02093157172203064, 0.09313564747571945, 0.034319885075092316, -0.06223618611693382, -0.021644599735736847, 0.038219477981328964, -0.014294697903096676, -0.09618524461984634, -0.046774692833423615, -0.00172501674387604, -0.026423349976539612, -0.0010190970497205853, -0.019884184002876282, -0.05672319233417511, 0.0014086662558838725, -0.00955172535032034, 0.019516829401254654, 0.02645024284720421, 0.025818074122071266, 0.005294678267091513, 0.012720189057290554, 0.003866356099024415, 0.016301298514008522, 0.015308823436498642, 0.05297462269663811, 0.004639556631445885, 0.021818062290549278, 0.007855185307562351, -0.030379246920347214, -0.03223950415849686, 0.009150597266852856, -0.0006920474115759134, 0.06683588773012161, -0.017180345952510834, -0.0170430988073349, -0.0030559031292796135, 0.026847871020436287, -0.026560606434941292, 0.020014220848679543, 0.07638905197381973, -0.03995264321565628, 0.05948788672685623, -0.013165530748665333, -0.026132630184292793, 0.004167742561548948, 0.011759323067963123, -0.023379217833280563, -0.04516991972923279, 0.007862242870032787, 0.02757585048675537, -0.035645805299282074, 0.029649926349520683, 0.01693352311849594, 0.026622096076607704, -0.06387932598590851, 0.01338260155171156, -0.014539219439029694, -0.028112320229411125, -0.08553645014762878, -0.015997078269720078, 0.004163733217865229, -0.01201346144080162, 0.007372948806732893, 0.023262111470103264, 0.032920196652412415, -0.026293979957699776, -0.03559853509068489, 0.014780296012759209, 0.025331763550639153, 0.001025418983772397, 0.038633160293102264, -0.007794058416038752, 0.033121343702077866, 0.019076276570558548, -0.02116197906434536, -0.035224683582782745, 0.02444959431886673, 0.038335781544446945, 0.02330300211906433, 0.014891318045556545, 0.05309765040874481, 0.0259748175740242, -0.007005039602518082, -0.02742771804332733, 0.031197989359498024, 0.024330848827958107, -0.04164528101682663, -0.0010014798026531935, -0.041291285306215286, -0.032198384404182434, 0.010331074707210064, -0.03797885775566101, -0.03493763133883476, -0.02228708565235138, 0.007588360458612442, -0.011012577451765537, 0.007512103766202927, 0.0033794776536524296, 0.032955292612314224, -0.04918360337615013, 0.006962627172470093, -0.0065856133587658405, -0.006603316869586706, 0.027999872341752052, 0.006524401716887951, -0.03947296366095543, 0.01827598176896572, -0.016911430284380913, -0.049877531826496124, 0.0028375117108225822, -0.005145691800862551, 0.045381881296634674, -0.015696341171860695, 0.0052977860905230045, 0.005442025139927864, 0.055306341499090195, 0.050680361688137054, 0.008046108298003674, -0.0017299576429650187, -0.0446586087346077, -0.016960779204964638, -0.003310752334073186, 0.01858242228627205, 0.038543909788131714, 0.027976462617516518, -0.029281923547387123, -0.029903119429945946, 0.04320268705487251, 0.003127087140455842, -0.003985049203038216, 0.007962440140545368, -0.004407508298754692, -0.007322411984205246, 0.012531259097158909, -0.015185843221843243, 0.005505868699401617, 0.03587616980075836, 0.01200670376420021, -0.037827715277671814, -0.0563511848449707, -0.05693408474326134, -0.04938846826553345, -0.005446891766041517, 0.025842517614364624, -0.0024530908558517694, -0.014935176819562912, 0.05029570683836937, 0.007070612162351608, -0.0014012422179803252, -0.03118816204369068, 0.01567358523607254, 0.011508452706038952, -0.010506315156817436, -0.029687391594052315, 0.015580784529447556, -0.021528828889131546, 0.01140549685806036, -0.023264283314347267, -0.005537183489650488, -0.032914116978645325, 0.005284980405122042, 0.0005833000177517533, -0.0037503796629607677, -0.021955665200948715, -0.033996835350990295, -0.03566044569015503, 0.01702781207859516, -0.01777404546737671, 0.0064932117238640785, -0.01381517294794321, 0.0020504449494183064, 0.004854387138038874, 0.021196886897087097, 0.0012054661056026816, -0.009325612336397171, -0.07519187778234482, -0.00975975301116705, 0.028595352545380592, -0.02250765822827816, -0.0007656369707547128, 0.0037897585425525904, -0.050773538649082184, 0.041029371321201324, -0.017841998487710953, 0.021201392635703087, -0.03452777862548828, -0.0493520051240921, -0.04198699817061424, -0.014328259974718094, -0.027088193222880363, 0.049506980925798416, -0.029148558154702187, 0.012983953580260277, 0.016846798360347748, -0.011563132517039776, 0.018759451806545258, 0.031558528542518616, -0.03888867422938347, -0.059616610407829285, -0.027484025806188583, 0.015623065643012524, -0.029814759269356728, -0.017586469650268555, -0.012965614907443523, 0.03796861693263054, -0.0386715792119503, -0.019946275278925896, -0.01748472824692726, 0.044350773096084595, 0.016839945688843727, -0.03388524428009987, -0.00048439856618642807, 0.027121491730213165, -0.003840179182589054, 0.022684374824166298, 0.058646511286497116, 0.049002230167388916, 0.022774800658226013, -0.014279519207775593, -0.0313325896859169, -0.032105207443237305, 0.02374870888888836, 0.009711227379739285, -0.006930527277290821, -0.01615750603377819, -0.05394698679447174, -0.0034806460607796907, 0.048987362533807755, -0.0024627111852169037, -0.028439203277230263, -0.010942297987639904, -0.029553541913628578, -0.00813121348619461, 0.01330648921430111, 0.0038975407369434834, -0.003206732450053096, -0.002884316025301814, 0.01956249214708805, -0.014325045049190521, -0.005292954389005899, -0.008029145188629627, 0.013652656227350235, -0.07233520597219467, 0.009565477259457111, -0.021237794309854507, -0.014644310809671879, 0.005516327917575836, 0.02490939013659954, -0.01595398224890232, -0.0432981513440609, 0.004654533229768276, -0.016238095238804817, 0.007637921255081892, -0.05458556488156319, -0.02538767084479332, -0.02347424253821373, -0.02860102243721485, -0.002640945604071021, 0.013664542697370052, 0.013540812768042088, 0.07194787263870239, -0.02023433893918991, 0.007604712620377541, -0.03761561959981918, 0.01318230852484703, -0.03658130019903183, -0.006489460822194815, -0.007467589806765318, 0.02545228786766529, 0.03878467157483101, -0.0075320289470255375, 0.06274879723787308, 0.020694242790341377, -0.05398030951619148, -0.06284038722515106, 0.07779110223054886, 0.012537944130599499, 0.01144860778003931, -0.005575526971369982, -0.034392546862363815, 0.012000104412436485, 0.017476772889494896, -0.00615334277972579, -0.0021308683790266514, 0.0024293807800859213, 0.0531601756811142, 0.028033630922436714, -0.006351898889988661, 0.041146934032440186, -0.058832377195358276, -0.02040650136768818, 0.05612664669752121, -0.022900186479091644, -0.013523311354219913, -0.013574336655437946, 0.039666928350925446, 0.0656406506896019, -0.03300603851675987, 0.038878750056028366, 0.001990200951695442, -0.012240627780556679, 0.03479442000389099, -0.006531889550387859, 0.05749937519431114, 0.002036432968452573, -0.021511293947696686, 0.014894893392920494, 0.005417506210505962, 0.06329307705163956, 0.0690850019454956, -0.019430747255682945, -0.03449856862425804, 0.031415197998285294, 0.02287740260362625, 0.05249602347612381, -0.021071529015898705, 0.016212616115808487, -0.04070824757218361, 0.014582457020878792, -0.05586439371109009, -0.018325207754969597, 0.02246808633208275, -0.04867236316204071, -0.0292957853525877, 0.02647181786596775, -0.031234800815582275, -0.006180783733725548, 0.02507612481713295, 0.028688563033938408, 0.03739708289504051, -0.029124200344085693, 0.056469183415174484, 0.061202455312013626, 0.009841158986091614, 0.013255604542791843, 0.04159865528345108, -0.010694397613406181, 0.007066282909363508, -0.00701685668900609, 0.01056043803691864, 0.05276001617312431, 0.0071141342632472515, -0.0011638171272352338, 0.03679677098989487, 0.00327958632260561, 0.018376681953668594, 0.017213601619005203, 0.017200984060764313, 0.008640906773507595, 0.012041651643812656, -0.0036323522217571735, -0.006306233815848827, -0.023154335096478462, 0.034598853439092636, 0.024383123964071274, -0.01029994897544384, -0.009950990788638592, -0.016481108963489532, 0.08168210089206696, 0.04113972187042236, 0.058851879090070724, -0.04517711326479912, 0.008711717091500759, 0.031422801315784454, 0.002660161117091775, 0.0602421835064888, -0.004498648922890425, -0.03611582890152931, -0.005994921084493399, 0.05235986039042473, -0.005894441623240709, 0.04296598210930824, 0.041625749319791794, 0.0016625776188448071, 0.039723288267850876, -0.007799713406711817, 0.007882053963840008, 0.00025654988712631166, 0.011753471568226814, -0.02307947725057602, 0.0030298205092549324, 0.016880163922905922, -0.06564842164516449, 0.012565991841256618, -0.04866579920053482, -0.0306102205067873, -0.02400766685605049, 0.0116497240960598, 0.007234117016196251, 0.04753683879971504, -0.010246890597045422, -0.03721997141838074, -0.013720966875553131, 0.0313451923429966, 0.03447163105010986, 0.07575836777687073, -0.009734515100717545, -0.015797754749655724, -0.05560582876205444, -0.046017106622457504, 0.016372263431549072, 0.005938685964792967, -0.0008844232652336359, -0.04713821783661842, -0.04293577000498772, -0.006510916166007519, -0.019539019092917442, 0.040973953902721405, -0.023014197126030922, 0.016029110178351402, -0.005589689128100872, -0.018155524507164955, -0.016015954315662384, -0.0011372736189514399, 0.03464839607477188, -0.011769362725317478, 0.01844068430364132, 0.014008556492626667, -0.01576412096619606, 0.0352630540728569, 0.05406923219561577, 0.018037835136055946, -0.045305944979190826, -0.043602198362350464, 0.01862110197544098, -0.035325683653354645, 0.011634288355708122, 0.026692038401961327, 0.036593496799468994, 0.009835774078965187, -0.027472499758005142, -0.02818761020898819, -0.012224025093019009, 0.011919311247766018, 0.03583314269781113, 0.013284318149089813, 0.006088781636208296, -0.01772206835448742, 0.016567960381507874, 0.015013808384537697, -0.031354792416095734, 0.04177674278616905, -0.052848320454359055, 0.00389730092138052, 0.036616019904613495, 0.0004999219090677798, -0.021860020235180855, -0.047709546983242035, -0.02707873284816742, -0.06732723116874695, -0.028230944648385048, -0.00045324082020670176, -0.005357163958251476, 0.01891726441681385, -0.02871253527700901, 0.007044854573905468, -0.012907380238175392, -0.05015947297215462, -0.017187774181365967, 0.002116863150149584, -0.018743066117167473, -0.0068916818127036095, -0.015474436804652214, 0.05245456099510193, -0.00380698312073946, 0.03268025070428848, 0.030542828142642975, 0.026378635317087173, 0.040013961493968964, 0.01801997981965542, -0.02022865228354931, -0.029185155406594276, 0.02257024496793747, 0.026020990684628487, -0.04558475315570831, -0.020947471261024475, -0.01907898113131523, -0.010145037434995174, 0.002280039945617318, 0.03584969416260719, 0.03452135622501373, -0.002217021072283387, 0.03727619722485542, 0.00639405706897378, -0.026650812476873398, 0.05968441069126129, -0.025894369930028915, -0.08124938607215881, -0.010013865306973457, 0.02759450301527977, 0.013853542506694794, -0.018978577107191086, 0.016831951215863228, 0.019119475036859512, 0.02569531835615635, -0.022215526551008224, 0.010332172736525536, 0.008274261839687824, -0.0009328816668130457, -0.019803369417786598, -0.004486956633627415, 0.023161644116044044, -0.03138120099902153, 0.005997445434331894, 0.07602277398109436, 0.06380970776081085, -0.00757094519212842, -0.013797486200928688, -0.028769930824637413, 0.020706363022327423, 0.013039599172770977, 0.0022116778418421745, 0.04560336098074913, 0.05637205019593239, -0.0006556645384989679, 0.008282799273729324, -0.021524380892515182, 0.01478614192456007 ]
Boost Wav2Vec2 with n-gram LM in 🤗 Transformers
patrickvonplaten
January 12, 2022
wav2vec2-with-ngram
research, guide, audio
https://huggingface.co/blog/wav2vec2-with-ngram
2. Getting data for your language model A language model that is useful for a speech recognition system should support the acoustic model, e.g. Wav2Vec2, in predicting the next word (or token, letter) and therefore model the following distribution: \( \mathbf{P}(w_n | \mathbf{w}_0^{t-1}) \) with \( w_n \) being the next word and \( \mathbf{w}_0^{t-1} \) being the sequence of all previous words since the beginning of the utterance. Simply said, the language model should be good at predicting the next word given all previously transcribed words regardless of the audio input given to the speech recognition system. As always a language model is only as good as the data it is trained on. In the case of speech recognition, we should therefore ask ourselves for what kind of data, the speech recognition will be used for: conversations, audiobooks, movies, speeches, , etc, ...? The language model should be good at modeling language that corresponds to the target transcriptions of the speech recognition system. For demonstration purposes, we assume here that we have fine-tuned a pre-trained facebook/wav2vec2-xls-r-300m on Common Voice 7 in Swedish. The fine-tuned checkpoint can be found here. Common Voice 7 is a relatively crowd-sourced read-out audio dataset and we will evaluate the model on its test data. Let's now look for suitable text data on the Hugging Face Hub. We search all datasets for those that contain Swedish data. Browsing a bit through the datasets, we are looking for a dataset that is similar to Common Voice's read-out audio data. The obvious choices of oscar and mc4 might not be the most suitable here because they: - are generated from crawling the web, which might not be very clean and correspond well to spoken language - require a lot of pre-processing - are very large which is not ideal for demonstration purposes here 😉 A dataset that seems sensible here and which is relatively clean and easy to pre-process is europarl_bilingual as it's a dataset that is based on discussions and talks of the European parliament. It should therefore be relatively clean and correspond well to read-out audio data. The dataset is originally designed for machine translation and can therefore only be accessed in translation pairs. We will only extract the text of the target language, Swedish (sv), from the English-to-Swedish translations. python target_lang="sv" # change to your target lang Let's download the data. python from datasets import load_dataset dataset = load_dataset("europarl_bilingual", lang1="en", lang2=target_lang, split="train") We see that the data is quite large - it has over a million translations. Since it's only text data, it should be relatively easy to process though. Next, let's look at how the data was preprocessed when training the fine-tuned XLS-R checkpoint in Swedish. Looking at the run.sh file, we can see that the following characters were removed from the official transcriptions: python chars_to_ignore_regex = '[,?.!\-\;\:"“%‘”�—’…–]' # change to the ignored characters of your fine-tuned model Let's do the same here so that the alphabet of our language model matches the one of the fine-tuned acoustic checkpoints. We can write a single map function to extract the Swedish text and process it right away. python import re def extract_text(batch): text = batch["translation"][target_lang] batch["text"] = re.sub(chars_to_ignore_regex, "", text.lower()) return batch Let's apply the .map() function. This should take roughly 5 minutes. python dataset = dataset.map(extract_text, remove_columns=dataset.column_names) Great. Let's upload it to the Hub so that we can inspect and reuse it better. You can log in by executing the following cell. python from huggingface_hub import notebook_login notebook_login() Output: bash Login successful Your token has been saved to /root/.huggingface/token Authenticated through git-credential store but this isn't the helper defined on your machine. You might have to re-authenticate when pushing to the Hugging Face Hub. Run the following command in your terminal in case you want to set this credential helper as the default git config --global credential.helper store Next, we call 🤗 Hugging Face's push_to_hub method to upload the dataset to the repo "sv_corpora_parliament_processed". python dataset.push_to_hub(f"{target_lang}_corpora_parliament_processed", split="train") That was easy! The dataset viewer is automatically enabled when uploading a new dataset, which is very convenient. You can now directly inspect the dataset online. Feel free to look through our preprocessed dataset directly on hf-test/sv_corpora_parliament_processed. Even if we are not a native speaker in Swedish, we can see that the data is well processed and seems clean. Next, let's use the data to build a language model.
[ 0.01696046069264412, -0.017262116074562073, 0.0226823091506958, -0.0334261879324913, 0.04967251420021057, 0.05049500986933708, 0.046776898205280304, 0.051532793790102005, -0.069008968770504, -0.02799990028142929, -0.04886181652545929, 0.08632957190275192, 0.035021986812353134, -0.025102825835347176, 0.0024034229572862387, -0.09123077988624573, 0.04520215839147568, 0.0443633534014225, 0.04904774948954582, 0.013912849128246307, -0.03271234780550003, -0.009974285960197449, 0.0798647478222847, 0.020990198478102684, 0.025797991082072258, -0.016712909564375877, 0.02437841147184372, 0.02575349062681198, -0.022714314982295036, -0.05595472455024719, -0.16466782987117767, 0.04217569902539253, -0.04190360754728317, -0.037350792437791824, -0.01002004649490118, 0.0477178692817688, -0.10444697737693787, 0.06987311691045761, 0.02661523036658764, -0.04664952680468559, 0.007520644925534725, -0.00011243222252232954, -0.012670619413256645, 0.0405433252453804, -0.010828142054378986, -0.03996656462550163, -0.12193568795919418, 0.08546064794063568, -0.0246854480355978, -0.02859070897102356, -0.06976310908794403, 0.05847698822617531, -0.05491025373339653, 0.08385296911001205, 0.004726008512079716, -0.05283459648489952, -0.009502341039478779, -0.09758023172616959, -0.03867099806666374, 0.03927982226014137, 0.01953008957207203, -0.0056061651557683945, 0.004498863127082586, -0.004254290834069252, 0.04460306465625763, -0.012318046763539314, -0.025857215747237206, -0.0039282022044062614, -0.07476828247308731, -0.025770697742700577, 3.565101849289931e-7, -0.025212062522768974, 0.0039053980726748705, -0.015675654634833336, 0.02813076041638851, -0.06652650237083435, -0.04388923943042755, 0.036506976932287216, 0.01979159191250801, -0.015071387402713299, 0.0033472857903689146, 0.020539825782179832, 0.03677104413509369, 0.038576796650886536, 0.00016048001998569816, 0.03625128045678139, 0.06567943096160889, -0.000008899710337573197, -0.0841590091586113, 0.0011114334920421243, -0.04946165159344673, -0.09974626451730728, -0.03699902072548866, 0.000933299248572439, 0.057124778628349304, -0.043723609298467636, 0.021062767133116722, 0.04594896361231804, -0.07277923077344894, 0.03255977854132652, -0.04901498928666115, -0.06260358542203903, 0.06080484390258789, -0.0753631517291069, -0.04552692919969559, 0.07093045860528946, -0.054149117320775986, -0.009437207132577896, -0.027052802965044975, 0.02565530315041542, 0.0739613026380539, -0.0661974549293518, 0.004877401515841484, 0.030149945989251137, -0.05821283534169197, 0.008402044884860516, 0.018983708694577217, 0.01567564345896244, 0.00420782808214426, 0.04668084904551506, -0.019793417304754257, 0.06462354958057404, 0.011207235977053642, -0.0027420874685049057, 0.006420176941901445, 0.030833180993795395, 0.05306067317724228, 0.03265285864472389, -0.020385248586535454, -0.05103059113025665, 0.054245270788669586, -0.07505327463150024, 0.09557943791151047, 0.04618358612060547, 0.014597437344491482, -0.01478617638349533, -0.001240635639987886, -0.013894143514335155, 0.04310600087046623, -0.027911726385354996, 0.012569633312523365, 0.06315112113952637, -0.01822403073310852, 0.0019073574803769588, 0.0632237121462822, -0.018807733431458473, -0.07590267807245255, 0.035563189536333084, -0.027338024228811264, 0.029690435156226158, -0.033748216927051544, 0.06450599431991577, 0.029427919536828995, -0.07998280972242355, 0.027555353939533234, 0.05248509719967842, 0.0005223426269367337, -0.04209788888692856, -0.06263509392738342, -0.008888953365385532, -0.06291420757770538, 0.07675996422767639, -0.03719903901219368, -0.0012090738164260983, 0.04632803797721863, -0.03242199867963791, -0.01789868250489235, 0.04908525198698044, 0.01210845448076725, 0.05650528520345688, 0.039987873286008835, 0.006888797041028738, 0.06937863677740097, -0.013425503857433796, -0.011780476197600365, 0.05374786630272865, 0.011363493278622627, 0.0200838353484869, 0.00225661089643836, -0.020512470975518227, 0.011215880513191223, 0.02396453730762005, 0.055817291140556335, 0.02714165300130844, 0.05638384446501732, -0.040636979043483734, -0.0004649094771593809, -0.01458493061363697, -0.03378918394446373, 0.043932780623435974, -0.021191179752349854, -0.0529509074985981, 0.08822634816169739, -0.06247231736779213, 0.010461900383234024, -0.04998743534088135, 0.014901273883879185, 0.08980116993188858, 0.04928971827030182, 0.061937082558870316, 0.07205703854560852, -0.016794828698039055, 0.037736907601356506, 0.033060017973184586, 0.019726695492863655, -0.01910329796373844, 0.023280778899788857, -0.07582388073205948, 0.0091793118044734, 0.029099715873599052, 0.013860130682587624, -0.060714639723300934, 0.024418430402874947, -0.07791926711797714, -0.056379351764917374, -0.045938510447740555, -0.01919638365507126, 0.022492459043860435, -0.020739518105983734, -0.028799990192055702, 0.1191072091460228, -0.0804278776049614, 0.03281477093696594, 0.04319198802113533, -0.027937842532992363, 0.0497022345662117, 0.07228806614875793, 0.09979415684938431, 0.06791283190250397, -0.06351885944604874, -0.06898241490125656, -0.06167006120085716, 0.05269902944564819, -0.013482470996677876, 0.004057886078953743, -0.06353586167097092, 0.005897939670830965, 0.035320933908224106, -0.017126457765698433, 0.02980070561170578, 0.03535625711083412, -0.06382608413696289, -0.0441153310239315, 0.05800330638885498, -0.01911381632089615, -0.021843502297997475, 0.07718196511268616, -0.032703906297683716, -0.0805489718914032, 0.013204026967287064, -0.039243124425411224, 0.059765640646219254, -0.03189774975180626, -0.02942599542438984, -0.023418279364705086, 0.05459992215037346, 0.04606729373335838, 0.0191044844686985, -0.037365950644016266, 0.019838573411107063, 0.006405800115317106, -0.03555142506957054, 0.011258857324719429, -0.046828046441078186, 0.02888091281056404, -0.06341584026813507, -0.011251944117248058, 0.003978481516242027, 0.01422157883644104, 0.029497891664505005, 0.028867103159427643, 0.00276574632152915, 0.023073697462677956, 0.002134351758286357, 0.030284211039543152, 0.04242304340004921, 0.043404676020145416, -0.050338536500930786, -0.04928360506892204, -0.004497797228395939, -0.0042012641206383705, -0.01177236158400774, 0.01930483989417553, 0.010076159611344337, -0.003324456512928009, -0.02536177821457386, 0.02331673540174961, -0.008474175818264484, -0.00446877209469676, 0.032132718712091446, 0.023609504103660583, 0.02286900207400322, -0.037630967795848846, -0.0078112902119755745, 0.01734398677945137, 0.004314552526921034, 0.006126209162175655, -0.009634739719331264, -0.029279310256242752, 0.004579733591526747, -0.05746495723724365, -0.0058469828218221664, -0.015656474977731705, -0.012577001936733723, -0.01151186227798462, 0.0054619163274765015, -0.024778781458735466, 0.027779802680015564, -0.09488540887832642, 0.01528968196362257, 0.03405464068055153, -0.026809075847268105, 0.006497977301478386, -0.013183129020035267, 0.037530574947595596, 0.01470081228762865, -0.025334583595395088, 0.02000347524881363, 0.01082347147166729, 0.03174864128232002, 0.028981821611523628, 0.009957050904631615, 0.006418992765247822, -0.013770777732133865, -0.017161402851343155, -0.0031743915751576424, 0.0349818617105484, 0.03692663088440895, -0.005079485476016998, -0.00993419997394085, 0.010503045283257961, 0.012438674457371235, -0.0359809473156929, -0.016511937603354454, 0.07297613471746445, 0.007951201871037483, 0.007323700934648514, -0.04134383425116539, 0.0010857128072530031, 0.001313644228503108, 0.02989690937101841, -0.020078549161553383, -0.05362794175744057, -0.019907066598534584, 0.0022683856077492237, 0.0736997202038765, 0.016007499769330025, 0.04115668684244156, -0.006528381258249283, -0.01686771772801876, 0.015534152276813984, 0.01724117435514927, -0.01705348677933216, 0.03906234726309776, -0.011080236174166203, -0.01928126811981201, -0.0012164236977696419, -0.01716255582869053, -0.012309842742979527, -0.01302206702530384, -0.02762429416179657, 0.057788677513599396, 0.029987234622240067, 0.03388686850667, 0.05754934623837471, 0.05055968463420868, -0.0031036899890750647, -0.013806845992803574, -0.03493097051978111, 0.02308349497616291, -0.027265043929219246, -0.043762169778347015, -0.049545466899871826, 0.017631780356168747, 0.01983308047056198, -0.011784176342189312, -0.027080783620476723, 0.006429560016840696, 0.04501603916287422, 0.019192909821867943, 0.03406510874629021, 0.003962543793022633, 0.013513224199414253, 0.009606762789189816, -0.015607021749019623, -0.01680601015686989, 0.0489179827272892, 0.04101776331663132, -0.03599188104271889, 0.019577983766794205, -0.026892807334661484, -0.021045509725809097, 0.009541930630803108, -0.02382768504321575, 0.03676935285329819, -0.04054199531674385, 0.03761018440127373, 0.02878331020474434, 0.008072594180703163, -0.022071586921811104, -0.006041092332452536, -0.010361616499722004, 0.0058822305873036385, -0.003553615650162101, 0.02122793160378933, -0.007921075448393822, 0.014288610778748989, -0.027711251750588417, 0.03642578795552254, -0.04376523196697235, 0.01665094867348671, -0.011076267808675766, 0.018163343891501427, 0.04663296788930893, -0.053585559129714966, -0.04107378050684929, -0.001395480940118432, 0.00713715422898531, -0.015950514003634453, 0.022749602794647217, 0.019262297078967094, 0.020123759284615517, 0.029158731922507286, -0.018535874783992767, -0.05483388528227806, -0.012615079060196877, -0.015168340876698494, -0.0038963088300079107, -0.0015652341535314918, -0.005612056702375412, -0.0023552807979285717, -0.0071347481571137905, 0.07964585721492767, -0.015446329489350319, 0.012284093536436558, -0.009421923197805882, -0.058420486748218536, -0.011906920932233334, -0.012130290269851685, -0.021411404013633728, 0.03607639670372009, 0.012700933031737804, 0.020213257521390915, -0.007871217094361782, -0.004509094636887312, 0.01226470060646534, -0.011607908643782139, -0.06652867048978806, -0.012324397452175617, -0.008889520540833473, 0.02490094117820263, 0.005806544795632362, 0.022531593218445778, 0.0019844493363052607, 0.012767435051500797, -0.04585164412856102, 0.01830967515707016, 0.001543511520139873, 0.04089802876114845, 0.008765266276896, -0.003545809304341674, 0.017004651948809624, 0.010131116025149822, -0.04951029270887375, -0.0342148132622242, 0.0461544394493103, 0.025164907798171043, 0.02019197680056095, 0.02558763697743416, 0.007910612970590591, -0.027258900925517082, 0.0662030279636383, 0.0099237821996212, -0.023771751672029495, -0.051022179424762726, -0.04205802455544472, -0.0209188349545002, 0.0156380757689476, 0.021010536700487137, 0.013135124929249287, -0.008231176994740963, -0.028315195813775063, -0.026808731257915497, 0.026674801483750343, 0.012612966820597649, 0.016883930191397667, -0.00032342574559152126, -0.011276386678218842, -0.009572386741638184, -0.03327355161309242, -0.008240170776844025, 0.04547969624400139, 0.010533176362514496, 0.03480944037437439, 0.04099716618657112, 0.044965751469135284, 0.015123986639082432, -0.027314890176057816, 0.011060087010264397, 0.01454784907400608, 0.006760327145457268, -0.06337091326713562, -0.03418739512562752, 0.012453427538275719, -0.012393172830343246, -0.004402827005833387, -0.007242302410304546, -0.007591215427964926, 0.016214141622185707, 0.0346224345266819, -0.0036511521320790052, 0.004472966771572828, 0.0011759363114833832, -0.030240334570407867, -0.017802327871322632, -0.029240237548947334, -0.0013779735891148448, -0.034878917038440704, -0.02512381225824356, -0.00897538848221302, -0.01985834538936615, -0.0008735624724067748, -0.0017600260907784104, -0.07024826854467392, -0.035821378231048584, 0.046049825847148895, 0.0015171378618106246, 0.04482904076576233, 0.02028440684080124, -0.0583312064409256, -0.05025000870227814, 0.012151369825005531, 0.023529574275016785, -0.027836956083774567, -0.03067662939429283, -0.009603966027498245, 0.02537175826728344, 0.008545555174350739, 0.0024602562189102173, -0.05626397952437401, 0.013235117308795452, 0.056742507964372635, -0.00027686322573572397, -0.0332883857190609, -0.049567434936761856, 0.0467955656349659, 0.008326658979058266, 0.0257999449968338, -0.0052173244766891, 0.015277283266186714, -0.03249451890587807, 0.013186504133045673, -0.02243734896183014, 0.014692983590066433, 0.0589866004884243, 0.005685383453965187, 0.021589165553450584, 0.0425499863922596, -0.001406434690579772, 0.04004957526922226, 0.003960418049246073, 0.025512130931019783, -0.006677280645817518, 0.013769607990980148, -0.0024865115992724895, -0.005795608274638653, -0.00018571912369225174, 0.010005097836256027, -0.0113359484821558, -0.08114354312419891, 0.031113963574171066, 0.017471564933657646, -0.020021352916955948, 0.016293510794639587, 0.02714499458670616, -0.045896850526332855, -0.0045782518573105335, 0.03668376803398132, 0.046999529004096985, -0.010253116488456726, -0.032973259687423706, -0.011804355308413506, -0.010887199081480503, -0.020911825820803642, -0.025997363030910492, 0.06472853571176529, -0.0014877158682793379, 0.04006216302514076, -0.01765361614525318, 0.000377864547772333, 0.02566179819405079, -0.01699119806289673, 0.0016306303441524506, 0.06971980631351471, 0.01971702091395855, 0.03691251948475838, 0.056464388966560364, 0.009340984746813774, 0.004432518966495991, -0.0150681771337986, -0.04266861081123352, -0.025634080171585083, -0.00848944578319788, 0.03708404675126076, 0.0013824899215251207, -0.022995242848992348, -0.0011048821033909917, -0.03284091874957085, 0.0457172729074955, 0.04332413524389267, -0.0029787151142954826, 0.012330496683716774, 0.01880631037056446, 0.004639677237719297, 0.03740229085087776, 0.02752395160496235, 0.029467402026057243, -0.019948141649365425, 0.002048657275736332, 0.029491757974028587, 0.03835860267281532, 0.03449152782559395, 0.03494197875261307, -0.013611945323646069, 0.024411868304014206, -0.009648159146308899, -0.026657233014702797, 0.01836426369845867, 0.0007670896011404693, -0.028639350086450577, -0.020252319052815437, 0.013731851242482662, -0.020123973488807678, -0.009807029739022255, -0.009027871303260326, -0.006023575086146593, -0.028717609122395515, -0.0214735958725214, 0.017478985711932182, 0.09161452949047089, -0.007026351056993008, -0.04896778240799904, -0.045981112867593765, -0.011270401068031788, -0.009665732271969318, -0.00467009749263525, -0.03362194076180458, -0.0425867922604084, -0.03473507985472679, 0.0030607786029577255, 0.009237096644937992, 0.007176713086664677, 0.021924082189798355, -0.030797086656093597, -0.038202330470085144, 0.011887473985552788, -0.024325553327798843, 0.01611175760626793, 0.016258303076028824, -0.001300531323067844, -0.0022489214316010475, 0.01566029153764248, -0.032495059072971344, 0.025864852592349052, 0.017504803836345673, -0.05432428792119026, 0.00398904038593173, -0.013209156692028046, 0.0065178885124623775, 0.03452109545469284, 0.10028144717216492, 0.019003530964255333, -0.05309825390577316, -0.008411378599703312, -0.00839702133089304, -0.03299345448613167, 0.05124993622303009, 0.009807090274989605, -0.024781484156847, -0.0087523702532053, -0.050254981964826584, 0.004281205590814352, -0.028160184621810913, -0.006512909661978483, 0.052296195179224014, 0.004939290229231119, -0.01585373282432556, -0.06256567686796188, 0.018189869821071625, 0.056758981198072433, 0.023499326780438423, 0.03341250121593475, 0.012762931175529957, 0.024050218984484673, 0.0018390340264886618, 0.07954739779233932, -0.02750261314213276, -0.03110312856733799, -0.041968412697315216, -0.04977109655737877, -0.0014470962341874838, -0.007011672016233206, -0.01217848900705576, -0.0017553266370669007, -0.017871059477329254, -0.02547742798924446, -0.03746839985251427, -0.02253289707005024, -0.008923335000872612, 0.00867434497922659, 0.011991633102297783, 0.003211816307157278, -0.0014881558017805219, 0.02212916873395443, -0.0172395221889019, 0.02691689319908619, -0.005963000003248453, 0.009403305128216743, 0.02901032194495201, -0.027942538261413574, 0.007920731790363789, 0.012617389671504498, 0.01283354964107275, -0.0003696626517921686, -0.03217489272356033, 0.0067638796754181385, 0.00958750769495964, 0.02801615186035633, -0.021171391010284424, 0.03154750168323517, 0.04030070826411247, 0.018474362790584564, 0.017042001709342003, 0.0046738977544009686, -0.016949696466326714, 0.01480388268828392, 0.0002594370162114501, -0.058590929955244064, -0.00012902021990157664, 0.004308125004172325, 0.0018018265254795551, 0.0723959356546402, 0.004422774538397789, 0.032516155391931534, 0.02133995294570923, 0.001574260531924665, 0.032267067581415176, -0.00885106436908245, 0.00809264462441206, -0.07864788174629211, 0.03500994294881821, 0.024271713569760323, -0.03197489678859711, -0.019162384793162346, 0.044835399836301804, 0.0170003492385149, -0.04465967416763306, -0.044298555701971054, -0.02688228152692318, -0.0066850450821220875, -0.013954155147075653, 0.01783752627670765, -0.010381928645074368, 0.06513310223817825, -0.023741254583001137, 0.01654529944062233, -0.04587102681398392, 0.0009248099522665143 ]
Boost Wav2Vec2 with n-gram LM in 🤗 Transformers
patrickvonplaten
January 12, 2022
wav2vec2-with-ngram
research, guide, audio
https://huggingface.co/blog/wav2vec2-with-ngram
3. Build an n-gram with KenLM* While large language models based on the Transformer architecture have become the standard in NLP, it is still very common to use an n-gram LM to boost speech recognition systems - as shown in Section 1. Looking again at Table 9 of Appendix C of the official Wav2Vec2 paper, it can be noticed that using a Transformer-based LM for decoding clearly yields better results than using an n-gram model, but the difference between n-gram and Transformer-based LM is much less significant than the difference between n-gram and no LM. E.g., for the large Wav2Vec2 checkpoint that was fine-tuned on 10min only, an n-gram reduces the word error rate (WER) compared to no LM by ca. 80% while a Transformer-based LM only reduces the WER by another 23% compared to the n-gram. This relative WER reduction becomes less, the more data the acoustic model has been trained on. E.g., for the large checkpoint a Transformer-based LM reduces the WER by merely 8% compared to an n-gram LM whereas the n-gram still yields a 21% WER reduction compared to no language model. The reason why an n-gram is preferred over a Transformer-based LM is that n-grams come at a significantly smaller computational cost. For an n-gram, retrieving the probability of a word given previous words is almost only as computationally expensive as querying a look-up table or tree-like data storage - i.e. it's very fast compared to modern Transformer-based language models that would require a full forward pass to retrieve the next word probabilities. For more information on how n-grams function and why they are (still) so useful for speech recognition, the reader is advised to take a look at this excellent summary from Stanford. Great, let's see step-by-step how to build an n-gram. We will use the popular KenLM library to do so. Let's start by installing the Ubuntu library prerequisites: bash sudo apt install build-essential cmake libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-test-dev libeigen3-dev zlib1g-dev libbz2-dev liblzma-dev before downloading and unpacking the KenLM repo. bash wget -O - https://kheafield.com/code/kenlm.tar.gz | tar xz KenLM is written in C++, so we'll make use of cmake to build the binaries. bash mkdir kenlm/build && cd kenlm/build && cmake .. && make -j2 ls kenlm/build/bin Great, as we can see, the executable functions have successfully been built under kenlm/build/bin/. KenLM by default computes an n-gram with Kneser-Ney smooting. All text data used to create the n-gram is expected to be stored in a text file. We download our dataset and save it as a .txt file. python from datasets import load_dataset username = "hf-test" # change to your username dataset = load_dataset(f"{username}/{target_lang}_corpora_parliament_processed", split="train") with open("text.txt", "w") as file: file.write(" ".join(dataset["text"])) Now, we just have to run KenLM's lmplz command to build our n-gram, called "5gram.arpa". As it's relatively common in speech recognition, we build a 5-gram by passing the -o 5 parameter. For more information on the different n-gram* LM that can be built with KenLM, one can take a look at the official website of KenLM. Executing the command below might take a minute or so. bash kenlm/build/bin/lmplz -o 5 <"text.txt" > "5gram.arpa" Output: bash === 1/5 Counting and sorting n-grams === Reading /content/swedish_text.txt ----5---10---15---20---25---30---35---40---45---50---55---60---65---70---75---80---85---90---95--100 tcmalloc: large alloc 1918697472 bytes == 0x55d40d0f0000 @ 0x7fdccb1a91e7 0x55d40b2f17a2 0x55d40b28c51e 0x55d40b26b2eb 0x55d40b257066 0x7fdcc9342bf7 0x55d40b258baa tcmalloc: large alloc 8953896960 bytes == 0x55d47f6c0000 @ 0x7fdccb1a91e7 0x55d40b2f17a2 0x55d40b2e07ca 0x55d40b2e1208 0x55d40b26b308 0x55d40b257066 0x7fdcc9342bf7 0x55d40b258baa **************************************************************************************************** Unigram tokens 42153890 types 360209 === 2/5 Calculating and sorting adjusted counts === Chain sizes: 1:4322508 2:1062772928 3:1992699264 4:3188318720 5:4649631744 tcmalloc: large alloc 4649631744 bytes == 0x55d40d0f0000 @ 0x7fdccb1a91e7 0x55d40b2f17a2 0x55d40b2e07ca 0x55d40b2e1208 0x55d40b26b8d7 0x55d40b257066 0x7fdcc9342bf7 0x55d40b258baa tcmalloc: large alloc 1992704000 bytes == 0x55d561ce0000 @ 0x7fdccb1a91e7 0x55d40b2f17a2 0x55d40b2e07ca 0x55d40b2e1208 0x55d40b26bcdd 0x55d40b257066 0x7fdcc9342bf7 0x55d40b258baa tcmalloc: large alloc 3188326400 bytes == 0x55d695a86000 @ 0x7fdccb1a91e7 0x55d40b2f17a2 0x55d40b2e07ca 0x55d40b2e1208 0x55d40b26bcdd 0x55d40b257066 0x7fdcc9342bf7 0x55d40b258baa Statistics: 1 360208 D1=0.686222 D2=1.01595 D3+=1.33685 2 5476741 D1=0.761523 D2=1.06735 D3+=1.32559 3 18177681 D1=0.839918 D2=1.12061 D3+=1.33794 4 30374983 D1=0.909146 D2=1.20496 D3+=1.37235 5 37231651 D1=0.944104 D2=1.25164 D3+=1.344 Memory estimate for binary LM: type MB probing 1884 assuming -p 1.5 probing 2195 assuming -r models -p 1.5 trie 922 without quantization trie 518 assuming -q 8 -b 8 quantization trie 806 assuming -a 22 array pointer compression trie 401 assuming -a 22 -q 8 -b 8 array pointer compression and quantization === 3/5 Calculating and sorting initial probabilities === Chain sizes: 1:4322496 2:87627856 3:363553620 4:728999592 5:1042486228 ----5---10---15---20---25---30---35---40---45---50---55---60---65---70---75---80---85---90---95--100
[ 0.00515364296734333, 0.0006423466838896275, 0.01900595799088478, -0.05143509432673454, 0.03687989339232445, 0.021631581708788872, 0.07064973562955856, 0.015417322516441345, -0.009932875633239746, 0.01881486177444458, -0.0046971938572824, 0.07812227308750153, 0.00799523200839758, 0.06297799199819565, -0.007872412912547588, -0.04168487340211868, 0.012858518399298191, -0.004687937442213297, 0.029272576794028282, 0.0008520177216269076, -0.03253544494509697, -0.03202339634299278, 0.10312968492507935, 0.013459564186632633, 0.08541610836982727, 0.024964939802885056, 0.048703595995903015, -0.01022713165730238, -0.0833129733800888, 0.002044758992269635, -0.09977520257234573, 0.037576284259557724, -0.024115124717354774, 0.0018421210115775466, 0.04580998048186302, 0.031038399785757065, -0.07247652858495712, 0.057603903114795685, 0.07846581190824509, -0.05692547187209129, 0.01862211525440216, -0.03379295766353607, -0.06099655106663704, 0.027707651257514954, -0.03488069400191307, -0.038499895483255386, -0.07573474198579788, 0.028367510065436363, -0.09933270514011383, -0.0034440108574926853, -0.08356790989637375, 0.011801398359239101, -0.04028388485312462, 0.006675950717180967, 0.047773342579603195, -0.022979412227869034, 0.043270424008369446, -0.04655736684799194, 0.007470102049410343, -0.031225040555000305, -0.025322550907731056, 0.009975830093026161, -0.021292943507432938, 0.005095059983432293, 0.00964591559022665, -0.003812883049249649, -0.025296073406934738, 0.039306022226810455, -0.07340914011001587, 0.0044579533860087395, 0.0131520451977849, -0.02194826491177082, -0.055110469460487366, 0.0007575913914479315, 0.002457784255966544, -0.05650582164525986, 0.04152094945311546, 0.03503753989934921, 0.04871702566742897, 0.0017309578834101558, 0.0065686353482306, 0.02857847511768341, 0.04528770595788956, 0.009696551598608494, 0.029908563941717148, 0.0894349068403244, 0.06485094875097275, -0.06334822624921799, -0.06731478124856949, 0.008656022138893604, -0.04416714981198311, -0.14504219591617584, -0.06040661409497261, -0.008789166808128357, 0.013985170051455498, -0.032396100461483, -0.006987570319324732, 0.05595835670828819, -0.03163165971636772, -0.012537267059087753, 0.013947662897408009, -0.06937383115291595, 0.04408054053783417, -0.021340109407901764, -0.06438103318214417, 0.07653073966503143, -0.05494770407676697, -0.06819655746221542, -0.026180291548371315, 0.020029233768582344, -0.022246219217777252, 0.03661618381738663, 0.04632895812392235, 0.007501557935029268, -0.048642996698617935, 0.03145506978034973, 0.05799725651741028, 0.04653039947152138, 0.011508023366332054, 0.02017347514629364, -0.018837742507457733, 0.1158122792840004, 0.05519593134522438, 0.010725440457463264, -0.013631054200232029, -0.01297911535948515, 0.030765384435653687, 0.025467926636338234, -0.04038960859179497, 0.04047621786594391, 0.08994333446025848, -0.05913649871945381, 0.04520588740706444, 0.04017253592610359, 0.004335582721978426, -0.004671855363994837, 0.0038154814392328262, 0.021672219038009644, -0.05563215911388397, -0.044465962797403336, -0.004077267367392778, 0.03666965290904045, -0.03651772812008858, -0.039937034249305725, 0.051608286798000336, -0.05110756307840347, -0.0366126112639904, 0.04958279803395271, 0.0016138773644343019, -0.0074937231838703156, -0.051228977739810944, 0.06423990428447723, -0.021254507824778557, -0.09333530813455582, 0.014791090041399002, 0.08606673032045364, -0.013359153643250465, 0.01808573491871357, -0.08158057928085327, 0.006675318814814091, -0.05081729590892792, -0.01716064102947712, -0.05706845596432686, 0.021206920966506004, 0.03971752151846886, -0.07173213362693787, -0.01224359031766653, 0.051556747406721115, -0.029104318469762802, 0.07109551131725311, 0.032299600541591644, -0.006384163163602352, 0.055507637560367584, -0.0431986004114151, -0.051428865641355515, -0.00473204767331481, -0.003350629238411784, 0.036951564252376556, -0.016151202842593193, -0.034352075308561325, -0.02604411542415619, 0.020929723978042603, 0.003800877369940281, -0.0007150665624067187, -0.027926849201321602, -0.07958149909973145, 0.024809012189507484, -0.09156463295221329, -0.0662527084350586, -0.0046430607326328754, 0.02438555844128132, -0.07876546680927277, 0.04265913367271423, 0.012527220882475376, -0.04269198700785637, -0.01867634244263172, 0.04841865226626396, 0.11108340322971344, 0.06731356680393219, 0.056483570486307144, 0.083673857152462, 0.033583056181669235, 0.034215640276670456, -0.05658695846796036, -0.016150113195180893, 0.04472599923610687, -0.01964429020881653, -0.10134050995111465, 0.007235127035528421, 0.03007383644580841, 0.010290141217410564, -0.04961059242486954, 0.03925086557865143, -0.1239413246512413, -0.0427885428071022, -0.05705007165670395, -0.04741571843624115, -0.011890736408531666, 0.040012259036302567, -0.017103297635912895, 0.07014671713113785, -0.05660887435078621, -0.06829538196325302, 0.04197600111365318, -0.035170260816812515, 0.07252564281225204, 0.09573400020599365, 0.02262984588742256, 0.03972911462187767, -0.036345239728689194, -0.058865662664175034, -0.16951552033424377, 0.03578046336770058, 0.022890213876962662, -0.012551329098641872, -0.033762797713279724, -0.015398198738694191, 0.037595443427562714, 0.008422460407018661, 0.007596357725560665, 0.04235268011689186, -0.007682809140533209, -0.030917273834347725, 0.03661644831299782, -0.006684472318738699, 0.005271085072308779, 0.019742930307984352, -0.040768835693597794, 0.033462803810834885, -0.011604605242609978, -0.06633518636226654, 0.05717021971940994, 0.08193723112344742, -0.04265861585736275, -0.007596208713948727, 0.041540008038282394, -0.015201191417872906, -0.03757479414343834, -0.05771316587924957, -0.01374109461903572, -0.019651297479867935, 0.015451439656317234, -0.02551012672483921, -0.08002613484859467, 0.018500711768865585, -0.026387043297290802, -0.01379048079252243, 0.008184622973203659, 0.029495282098650932, 0.03036600351333618, -0.0009808236500248313, -0.006033954210579395, 0.012267404235899448, 0.026374882087111473, 0.011282854713499546, 0.005844538565725088, 0.04608333855867386, -0.012491928413510323, -0.03286781162023544, -0.04781744256615639, 0.0020727277733385563, -0.03228245675563812, 0.04964917153120041, 0.02587815932929516, -0.0009410323691554368, 0.01997070200741291, 0.029255542904138565, -0.03128829598426819, 0.0010360957821831107, 0.04891732335090637, -0.010029543191194534, 0.04714414104819298, -0.029825935140252113, -0.03049844689667225, -0.010276836343109608, -0.01422529760748148, 0.004582580178976059, -0.01743769459426403, -0.020974500104784966, 0.018909547477960587, -0.0223198514431715, 0.011950882151722908, 0.033033210784196854, 0.012969453819096088, -0.017063146457076073, 0.01782047562301159, -0.016580522060394287, 0.04581400007009506, -0.08776593208312988, 0.0003683233808260411, -0.02660532109439373, -0.002608254086226225, 0.019465619698166847, -0.01733546517789364, 0.04057259112596512, -0.02484150230884552, -0.028562450781464577, 0.005785552319139242, -0.03137452155351639, 0.03348582237958908, 0.029602834954857826, -0.01976661942899227, 0.010079464875161648, -0.009151807054877281, -0.03505374491214752, -0.033017728477716446, 0.038761358708143234, 0.023450592532753944, 0.05217665806412697, -0.005801461171358824, 0.01723284274339676, 0.03893470764160156, -0.025797631591558456, -0.01604960672557354, -0.015450376085937023, 0.004124745726585388, 0.024504655972123146, -0.03870358318090439, 0.005620271898806095, -0.004309114068746567, 0.008499601855874062, -0.0009326066356152296, -0.05137532949447632, 0.006238813512027264, 0.020198417827486992, 0.023541709408164024, 0.042360447347164154, 0.04650750011205673, 0.01365637220442295, -0.030748428776860237, -0.008753483183681965, -0.005494622979313135, -0.006902117747813463, 0.03242655098438263, 0.0028028262313455343, -0.02349167875945568, 0.022416643798351288, -0.03389379754662514, -0.036974065005779266, -0.006784470286220312, -0.035074371844530106, 0.053553808480501175, -0.0006623368244618177, -0.00314262299798429, 0.023218698799610138, 0.022867098450660706, 0.02488275058567524, 0.019934946671128273, -0.017174743115901947, 0.0036687019746750593, -0.013810946606099606, 0.002914641285315156, -0.04320961982011795, 0.011693776585161686, 0.05037891864776611, 0.04453403502702713, -0.010578243061900139, 0.03668170049786568, -0.013809879310429096, 0.014888017438352108, 0.02063119411468506, 0.003405539086088538, -0.030982771888375282, 0.029567522928118706, -0.02129374071955681, -0.012636125087738037, 0.05538717284798622, 0.037063825875520706, -0.04410142824053764, -0.05830327793955803, -0.04079415276646614, -0.05461263656616211, 0.0015072646783664823, -0.008562375791370869, 0.011348315514624119, -0.01741710864007473, 0.052061229944229126, 0.007370509672909975, -0.026819074526429176, -0.01936192996799946, -0.013693545013666153, -0.004521604627370834, -0.010615917854011059, 0.01979592815041542, 0.0488731786608696, -0.004580645821988583, 0.009302276186645031, -0.02969207987189293, 0.015973109751939774, -0.008933580480515957, 0.015390876680612564, 0.00761288171634078, -0.035428743809461594, 0.03967153653502464, -0.04734034463763237, -0.008135405369102955, 0.026511505246162415, -0.004966918844729662, -0.004499033093452454, 0.026846610009670258, 0.0005924204597249627, 0.027866531163454056, -0.0034342778380960226, 0.015395854599773884, -0.013563201762735844, -0.02315603755414486, -0.0035090253222733736, 0.006061926018446684, 0.003927952144294977, 0.0323185995221138, 0.011127571575343609, -0.00517919659614563, 0.06791127473115921, 0.001765284570865333, 0.03807629644870758, -0.0006107994122430682, -0.0508524514734745, -0.03444305434823036, -0.010949554853141308, 0.011773329228162766, 0.06617234647274017, -0.016843948513269424, -0.030162250623106956, 0.00516184326261282, 0.009946970269083977, 0.024062760174274445, -0.006587225012481213, -0.04294552654027939, -0.04350078105926514, -0.014105889946222305, 0.030394526198506355, -0.05112927407026291, 0.0014732576673850417, -0.03166699409484863, -0.007273346185684204, -0.02634984813630581, -0.00819256342947483, 0.03552407771348953, 0.07183852791786194, -0.02065136656165123, 0.029341338202357292, 0.006785545498132706, 0.014297215268015862, -0.0036775129847228527, -0.018300769850611687, 0.0299111008644104, 0.05437995493412018, 0.012949989177286625, -0.004379097372293472, -0.022587204352021217, -0.04097692668437958, 0.045827873051166534, 0.027990857139229774, 0.02435089834034443, -0.01727653667330742, -0.025643229484558105, 0.013966094702482224, -0.011430404148995876, -0.0012955935671925545, -0.011493468657135963, -0.016311164945364, 0.004732056055217981, -0.016326749697327614, 0.0304800383746624, -0.04317321628332138, -0.014813439920544624, 0.0258658267557621, -0.006621221546083689, -0.02339794486761093, -0.028791556134819984, 0.00746588921174407, 0.04314878582954407, 0.004510541912168264, 0.021840227767825127, -0.0029976849909871817, 0.017964012920856476, -0.017548980191349983, 0.029229024425148964, 0.03381171077489853, -0.018943075090646744, 0.04792148992419243, -0.019480867311358452, 0.026405684649944305, -0.012361228466033936, -0.01762065477669239, 0.03757985308766365, -0.011967468075454235, 0.024815784767270088, 0.04182660952210426, -0.008720296435058117, 0.04098932072520256, 0.003439508844166994, -0.007421442307531834, -0.019832564517855644, -0.018387220799922943, -0.007753589190542698, -0.011226554401218891, 0.02811616286635399, -0.0033284202218055725, 0.011633554473519325, 0.008376328274607658, 0.005715383682399988, -0.028664499521255493, -0.03661780059337616, -0.025995900854468346, 0.04937221109867096, 0.033938392996788025, 0.03589929640293121, -0.00984737928956747, -0.04389992356300354, -0.01589919812977314, 0.02649002894759178, 0.013936556875705719, -0.024366231635212898, 0.002320528496056795, 0.01786160282790661, 0.020940925925970078, 0.005028074141591787, 0.009011466056108475, -0.036670081317424774, -0.0036598294973373413, 0.020448870956897736, -0.0001879510236904025, -0.01862160488963127, -0.0081510990858078, 0.04566976800560951, 0.03611455112695694, -0.011580842547118664, -0.013784545473754406, 0.025471730157732964, -0.041260525584220886, 0.03263217210769653, -0.05823560804128647, 0.021989837288856506, 0.02939518354833126, -0.03620404005050659, -0.03821860998868942, 0.024991244077682495, 0.008412891067564487, 0.043298233300447464, 0.0031633831094950438, 0.057586632668972015, 0.03493335470557213, 0.04355032369494438, 0.028318490833044052, 0.014956285245716572, 0.02369985356926918, -0.006418963894248009, 0.03302907198667526, -0.03351975977420807, 0.014161140657961369, 0.080154187977314, -0.05168958753347397, 0.011636145412921906, 0.01322233397513628, -0.028830580413341522, 0.0008681847830303013, 0.024762149900197983, 0.002946503460407257, 0.004961071070283651, -0.012981751933693886, 0.047144241631031036, 0.01214664988219738, -0.020629599690437317, -0.018617412075400352, 0.03628889098763466, -0.008463430218398571, 0.026083670556545258, 0.0142188286408782, -0.009823321364820004, 0.05096742510795593, -0.02922956831753254, -0.013150044716894627, 0.060661230236291885, 0.0120139354839921, 0.003773381467908621, 0.02981894463300705, -0.017208756878972054, -0.019370542839169502, 0.005836233031004667, 0.00262667634524405, -0.009613912552595139, -0.04008354991674423, 0.02130100317299366, 0.02645464614033699, 0.014550427906215191, 0.015804486349225044, -0.03133988752961159, 0.0744607225060463, 0.03750792518258095, 0.047405991703271866, -0.014166337437927723, -0.018719889223575592, -0.0147347217425704, 0.02942737005650997, 0.005080326460301876, 0.004765819292515516, -0.05832549184560776, 0.01335589587688446, 0.03414047881960869, 0.014801579527556896, 0.045326411724090576, 0.0012656812323257327, -0.03133174777030945, 0.02251049317419529, -0.021979134529829025, 0.02196701616048813, 0.000186068398761563, -0.006427458021789789, -0.02115156315267086, 0.019378092139959335, 0.028844045475125313, -0.0473768413066864, 0.02016150951385498, -0.002339150058105588, -0.014127383008599281, -0.022700771689414978, -0.01568576879799366, -0.008379085920751095, 0.059434544295072556, -0.0065732779912650585, -0.03902392089366913, -0.04015837237238884, -0.005815557204186916, 0.03259393200278282, 0.050790924578905106, -0.028906403109431267, -0.01918470300734043, -0.03266884386539459, -0.05679527670145035, 0.035747937858104706, -0.00303054042160511, 0.025637077167630196, -0.04492560774087906, 0.0022940614726394415, -0.002554567065089941, -0.013876481913030148, 0.04230771213769913, -0.04790988937020302, 0.010725214146077633, -0.014267145656049252, 0.02125059813261032, -0.009410794824361801, -0.005394580774009228, 0.022932695224881172, -0.04305972903966904, 0.010504025034606457, 0.01104056742042303, 0.025295883417129517, 0.020688019692897797, 0.07014206051826477, -0.014915259554982185, -0.0326494462788105, -0.0072229295037686825, 0.03949631750583649, -0.017659161239862442, 0.018365778028964996, 0.02859870158135891, 0.013747586868703365, -0.035255491733551025, -0.04496388882398605, 0.024560028687119484, -0.011306634172797203, 0.027620285749435425, 0.020539922639727592, 0.03854542598128319, -0.04814114049077034, -0.06860069185495377, 0.02354440651834011, 0.0349474772810936, -0.005031493026763201, 0.028900841251015663, -0.029772775247693062, 0.00433559063822031, 0.0033744596876204014, 0.012808768078684807, -0.03126700595021248, -0.04306628927588463, 0.014731037430465221, -0.07863001525402069, -0.022700874134898186, 0.021309198811650276, 0.007195748388767242, 0.04801737144589424, -0.02778221108019352, -0.025405723601579666, -0.026016129180788994, -0.027754735201597214, -0.03334565833210945, 0.03869689628481865, 0.02059214934706688, 0.023653946816921234, 0.04441459849476814, 0.016629675403237343, -0.03215865418314934, 0.01223139837384224, 0.037897877395153046, 0.042693931609392166, 0.031655605882406235, 0.023900078609585762, -0.01612791232764721, -0.001988467527553439, -0.02800985984504223, -0.0022188934963196516, -0.03136412054300308, -0.0037191894371062517, -0.013822153210639954, 0.01866745948791504, -0.013170653022825718, 0.0794093981385231, 0.007645684760063887, -0.02158396691083908, 0.058840226382017136, 0.012253547087311745, -0.001508147455751896, 0.04777644947171211, -0.01688879169523716, -0.07094687223434448, -0.0210659671574831, 0.05258772149682045, -0.0211685448884964, 0.013265984132885933, 0.010324100963771343, 0.028354760259389877, 0.02360023744404316, 0.008431656286120415, -0.009598926641047001, 0.04518857225775719, -0.03365437686443329, -0.0014555843081325293, 0.047849010676145554, 0.0033148357179015875, -0.053509823977947235, -0.01369817927479744, 0.031152823939919472, 0.003541088430210948, 0.003551200730726123, -0.05406813696026802, -0.026786046102643013, -0.020842930302023888, 0.038364067673683167, 0.017650295048952103, -0.020783929154276848, 0.021012388169765472, 0.0057764737866818905, 0.011181886307895184, -0.020759180188179016, -0.01583816483616829 ]
Boost Wav2Vec2 with n-gram LM in 🤗 Transformers
patrickvonplaten
January 12, 2022
wav2vec2-with-ngram
research, guide, audio
https://huggingface.co/blog/wav2vec2-with-ngram
# Boosting Wav2Vec2 with n-grams in 🤗 Transformers Wav2Vec2 is a popular pre-trained model for speech recognition. Released in September 2020 by Meta AI Research, the novel architecture catalyzed progress in self-supervised pretraining for speech recognition, e.g. G. Ng et al., 2021, Chen et al, 2021, Hsu et al., 2021 and Babu et al., 2021. On the Hugging Face Hub, Wav2Vec2's most popular pre-trained checkpoint currently amounts to over 250,000 monthly downloads. Using Connectionist Temporal Classification (CTC), pre-trained Wav2Vec2-like checkpoints are extremely easy to fine-tune on downstream speech recognition tasks. In a nutshell, fine-tuning pre-trained Wav2Vec2 checkpoints works as follows: A single randomly initialized linear layer is stacked on top of the pre-trained checkpoint and trained to classify raw audio input to a sequence of letters. It does so by: 1. extracting audio representations from the raw audio (using CNN layers), 2. processing the sequence of audio representations with a stack of transformer layers, and, 3. classifying the processed audio representations into a sequence of output letters. Previously audio classification models required an additional language model (LM) and a dictionary to transform the sequence of classified audio frames to a coherent transcription. Wav2Vec2's architecture is based on transformer layers, thus giving each processed audio representation context from all other audio representations. In addition, Wav2Vec2 leverages the CTC algorithm for fine-tuning, which solves the problem of alignment between a varying "input audio length"-to-"output text length" ratio. Having contextualized audio classifications and no alignment problems, Wav2Vec2 does not require an external language model or dictionary to yield acceptable audio transcriptions. As can be seen in Appendix C of the official paper, Wav2Vec2 gives impressive downstream performances on LibriSpeech without using a language model at all. However, from the appendix, it also becomes clear that using Wav2Vec2 in combination with a language model can yield a significant improvement, especially when the model was trained on only 10 minutes of transcribed audio. Until recently, the 🤗 Transformers library did not offer a simple user interface to decode audio files with a fine-tuned Wav2Vec2 and a language model. This has thankfully changed. 🤗 Transformers now offers an easy-to-use integration with Kensho Technologies' pyctcdecode library. This blog post is a step-by-step technical guide to explain how one can create an n-gram language model and combine it with an existing fine-tuned Wav2Vec2 checkpoint using 🤗 Datasets and 🤗 Transformers. We start by: 1. How does decoding audio with an LM differ from decoding audio without an LM? 2. How to get suitable data for a language model? 3. How to build an n-gram with KenLM? 4. How to combine the n-gram with a fine-tuned Wav2Vec2 checkpoint? For a deep dive into how Wav2Vec2 functions - which is not necessary for this blog post - the reader is advised to consult the following material: - wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations - Fine-Tune Wav2Vec2 for English ASR with 🤗 Transformers - An Illustrated Tour of Wav2vec 2.0
[ 0.04230552911758423, -0.04309922829270363, 0.03709723800420761, -0.04199545830488205, -0.03661362826824188, 0.02611258067190647, 0.02328464202582836, 0.06073084846138954, -0.052136000245809555, -0.0307552982121706, -0.02559119462966919, 0.07456959038972855, -0.02165430784225464, 0.0736265555024147, -0.019293153658509254, -0.06813491880893707, 0.030024977400898933, 0.019932270050048828, -0.016430214047431946, -0.000020675704945460893, -0.03599139675498009, -0.05982173979282379, 0.09016278386116028, 0.019941076636314392, 0.016783252358436584, 0.0462702177464962, 0.04734475538134575, 0.008588590659201145, -0.029020873829722404, 0.012652166187763214, -0.122545026242733, -0.009644964709877968, 0.039852388203144073, -0.05143626779317856, 0.04450737312436104, 0.06402582675218582, -0.10294332355260849, 0.01210391242057085, 0.01042864564806223, -0.01236542034894228, -0.031151534989476204, 0.0035569274332374334, -0.06166490167379379, 0.05758129805326462, -0.008051270619034767, -0.03196287900209427, -0.04696299135684967, 0.05670738220214844, -0.04559770226478577, -0.0668497309088707, -0.022501861676573753, 0.0323951356112957, -0.001766746398061514, -0.002185109071433544, 0.013645149767398834, -0.029706086963415146, -0.01573648862540722, -0.045587506145238876, 0.006284923758357763, 0.0006174173904582858, -0.010968903079628944, 0.003142606234177947, -0.058345675468444824, -0.01437072642147541, 0.0048438385128974915, -0.0075959255918860435, -0.035692259669303894, 0.07396009564399719, -0.024710454046726227, 0.002974641975015402, 0.01849486120045185, 0.02745673432946205, 0.0020687715150415897, -0.05179506912827492, 0.0034628517460078, -0.007603917270898819, -0.027100274339318275, 0.01608916185796261, 0.02290767803788185, 0.00053266785107553, -0.006861139088869095, 0.03507949784398079, 0.04280952736735344, -0.014066247269511223, 0.007822008803486824, 0.006768013350665569, 0.06863042712211609, -0.053026020526885986, -0.057981859892606735, 0.023273605853319168, -0.01561280433088541, -0.14521978795528412, -0.02469027228653431, -0.040613576769828796, 0.02210935950279236, 0.0034050624817609787, 0.00959587562829256, 0.04287135601043701, -0.01766417734324932, -0.052752021700143814, 0.03381861001253128, -0.03403129801154137, 0.04179944097995758, -0.021905431523919106, -0.10161164402961731, 0.11110193282365799, -0.08155369758605957, -0.038573965430259705, -0.08011326193809509, -0.010750754736363888, 0.08847158402204514, -0.02264290302991867, 0.019713636487722397, 0.05551021546125412, -0.09396892040967941, 0.03136482462286949, 0.03523118048906326, -0.019479136914014816, 0.025808218866586685, 0.052316199988126755, -0.0015331337926909328, 0.10380551218986511, 0.04359804466366768, -0.020469894632697105, 0.042146239429712296, -0.014812974259257317, 0.03231635317206383, 0.01321929506957531, 0.027849091216921806, 0.03053293749690056, 0.04097384586930275, -0.038468968123197556, 0.04746406152844429, 0.018431250005960464, -0.022047238424420357, -0.04697782173752785, 0.053723257035017014, -0.026994602754712105, -0.018943512812256813, 0.005651943385601044, -0.006393820513039827, 0.08072051405906677, -0.05680008977651596, -0.06444017589092255, 0.08645089715719223, -0.022342903539538383, -0.08777090162038803, 0.090202197432518, 0.017399251461029053, 0.04547615721821785, -0.0918869897723198, 0.04409385472536087, -0.06435983628034592, -0.08199484646320343, 0.015588213689625263, 0.04188363254070282, -0.0007759323343634605, 0.009135625325143337, -0.049354437738657, -0.031168941408395767, -0.03508821502327919, -0.0025564078241586685, -0.03428303822875023, 0.013895943760871887, 0.0212693028151989, -0.07174845039844513, -0.007298358250409365, 0.07192819565534592, -0.018240610137581825, 0.022371817380189896, 0.033265259116888046, -0.038990288972854614, 0.058552335947752, -0.001930456841364503, -0.08833245933055878, 0.0612722672522068, -0.03394400328397751, 0.07401157170534134, 0.0057221041060984135, -0.04121268540620804, -0.005933895707130432, 0.0653076097369194, 0.03466208279132843, 0.030456816777586937, 0.030783703550696373, -0.03089059516787529, 0.028710711747407913, -0.014559282921254635, -0.041624151170253754, 0.019214535132050514, 0.021556107327342033, -0.0037994789890944958, 0.02016361989080906, -0.023684682324528694, -0.03297673538327217, -0.03752392902970314, 0.005553099326789379, 0.11751268804073334, 0.05603358522057533, 0.012314231134951115, 0.062831811606884, 0.02195816859602928, 0.021911317482590675, 0.010717612691223621, -0.004707076121121645, -0.009039107710123062, -0.0029493593610823154, -0.10529543459415436, -0.015180813148617744, 0.016962554305791855, 0.026151143014431, -0.03637640178203583, -0.006838500499725342, -0.10149504244327545, -0.026638805866241455, -0.030176276341080666, -0.050137169659137726, 0.04054400697350502, -0.02809695340692997, -0.0450957715511322, 0.107880137860775, -0.04390677437186241, -0.011039749719202518, 0.036752477288246155, -0.0533578097820282, 0.057583287358284, 0.04144151508808136, 0.04911155253648758, 0.060208581387996674, -0.0715397298336029, -0.0314544253051281, -0.08574230968952179, -0.10649217665195465, -0.02594577893614769, 0.009406285360455513, -0.024711115285754204, 0.08721443265676498, -0.02081403136253357, 0.045298077166080475, -0.012497007846832275, -0.010234909132122993, -0.03665568679571152, -0.01595112308859825, 0.023591235280036926, -0.01940756104886532, -0.03153291344642639, -0.008736355230212212, -0.024085605517029762, 0.012015953660011292, 0.011270196177065372, -0.04303920641541481, 0.07124387472867966, 0.09864700585603714, 0.00417568814009428, -0.024011872708797455, 0.07291702926158905, 0.017247507348656654, -0.04339583218097687, -0.011963682249188423, 0.047771889716386795, -0.0005942002171650529, -0.0024546626955270767, 0.018068354576826096, -0.029315996915102005, -0.019482582807540894, -0.07915934175252914, 0.00451373215764761, 0.03372015431523323, 0.05139460414648056, -0.013558934442698956, 0.012059167958796024, -0.01253356784582138, -0.00019689113833010197, 0.02069162391126156, 0.04996975138783455, 0.017154628410935402, 0.019293956458568573, -0.03298439085483551, -0.009171261452138424, -0.04155127704143524, -0.0073205227963626385, -0.015267330221831799, 0.04904782399535179, -0.012111588381230831, 0.010303803719580173, 0.011778817512094975, 0.018357859924435616, -0.0005008465377613902, 0.041948944330215454, 0.03195882961153984, -0.02411695010960102, 0.023780986666679382, -0.02423463575541973, -0.019693894311785698, -0.006539462599903345, 0.007642981130629778, 0.004475461784750223, -0.016547836363315582, 0.01994774490594864, 0.05221270024776459, -0.0395871102809906, -0.021825026720762253, -0.0029791975393891335, 0.04049841687083244, -0.0025034891441464424, -0.015557683072984219, -0.015244614332914352, 0.013427029363811016, -0.07448966801166534, -0.03280423581600189, 0.0141009371727705, -0.030826814472675323, -0.026482567191123962, 0.015134169720113277, 0.0195013377815485, -0.01687384583055973, -0.04754443094134331, 0.029901323840022087, 0.021833162754774094, 0.021921630948781967, 0.05641168728470802, -0.00890292413532734, -0.03261423483490944, 0.001423264155164361, -0.02734970673918724, -0.015187036246061325, 0.04286693036556244, 0.03348170965909958, -0.014055854640901089, 0.025449752807617188, 0.0019927520770579576, 0.0034838488791137934, -0.0033208616077899933, -0.0021511295344680548, -0.022213168442249298, -0.03051088936626911, -0.0058782692067325115, -0.04091021046042442, -0.011619861237704754, -0.02847348526120186, -0.006993846036493778, -0.006584783550351858, -0.002205501776188612, -0.027280554175376892, 0.0012723797699436545, 0.006336587015539408, 0.04970838874578476, -0.012059720233082771, 0.02564116194844246, -0.009350834414362907, 0.016254810616374016, -0.00013969540304969996, 0.03374962508678436, 0.01804051361978054, 0.01400051824748516, -0.03642195090651512, -0.007539009675383568, -0.010439866222441196, -0.030376574024558067, -0.0049095191061496735, -0.028117284178733826, 0.07924728095531464, 0.01594332978129387, 0.02980799973011017, 0.012146180495619774, 0.035800155252218246, 0.015889564529061317, -0.040785789489746094, -0.008336576633155346, 0.013857764191925526, -0.022168083116412163, -0.012315602973103523, -0.025040779262781143, 0.03869089484214783, 0.013156699948012829, -0.005000897217541933, -0.0021344434935599566, 0.04370192065834999, 0.030013198032975197, 0.05317171663045883, 0.0008429616573266685, -0.001566262450069189, -0.03872836381196976, 0.004252187442034483, -0.023742632940411568, 0.0492669939994812, 0.050109442323446274, 0.03963135927915573, -0.05894339829683304, -0.06746108084917068, 0.005183357745409012, 0.004079281818121672, -0.030105436220765114, 0.011386987753212452, 0.03540011867880821, -0.023035239428281784, 0.060614213347435, 0.01986236684024334, 0.016078708693385124, 0.048126451671123505, -0.03043868951499462, -0.024229640141129494, -0.012058595195412636, -0.013016761280596256, 0.0021752186585217714, 0.04779824987053871, -0.010072215460240841, -0.027357561513781548, 0.0018328081350773573, -0.05264710262417793, -0.00879151001572609, -0.020042743533849716, 0.005037965252995491, -0.010954577475786209, -0.01752961240708828, -0.03724613040685654, 0.015315667726099491, 0.010761844925582409, 0.012017534114420414, 0.0231885127723217, 0.005506455432623625, 0.020437881350517273, 0.03821958601474762, -0.03944114223122597, 0.00688009150326252, -0.031404901295900345, 0.006097784731537104, -0.0016509711276739836, 0.020592182874679565, 0.036060184240341187, 0.011152124032378197, 0.013356903567910194, 0.09493392705917358, -0.01649056375026703, 0.04355430603027344, 0.006668090354651213, -0.039710599929094315, -0.027120061218738556, -0.01021429430693388, -0.03658998757600784, 0.04077843949198723, -0.0059028854593634605, -0.001375327236019075, 0.006130056921392679, -0.04137143865227699, 0.0008001805981621146, 0.01210856530815363, -0.03100082278251648, -0.03483698517084122, -0.01681484468281269, 0.03367767855525017, -0.010122537612915039, 0.00914624985307455, -0.024284495040774345, 0.024576688185334206, -0.03247610479593277, -0.019514363259077072, -0.002045324305072427, 0.05031004920601845, -0.012787099927663803, 0.024699926376342773, -0.0012075798586010933, 0.045084111392498016, -0.0022653033956885338, -0.03338799998164177, 0.06777118146419525, 0.06357768177986145, 0.07485322654247284, 0.0007970193400979042, -0.006036377511918545, -0.05454384163022041, 0.03855016827583313, 0.02056039310991764, 0.006640087813138962, -0.041803028434515, -0.011836507357656956, -0.027493508532643318, -0.0043329838663339615, 0.008633493445813656, -0.013967121951282024, 0.000027193784262635745, 0.006409832276403904, -0.013837672770023346, 0.029710965231060982, -0.01386314257979393, -0.02894003875553608, 0.0018378685927018523, 0.029207302257418633, -0.01172820758074522, -0.02360764518380165, 0.004572427831590176, 0.05415896698832512, -0.0169067345559597, -0.0040476955473423, 0.02115350216627121, 0.05840463191270828, 0.019174885004758835, 0.0253688246011734, 0.03384951129555702, -0.047823984175920486, 0.03473704308271408, -0.032635513693094254, 0.012222676537930965, -0.0689014196395874, 0.012133670970797539, 0.050011079758405685, -0.03653128817677498, -0.025201646611094475, 0.023139650002121925, 0.046356331557035446, 0.007477044127881527, -0.0023174819070845842, 0.00997250434011221, -0.01963794231414795, -0.05214959383010864, -0.05129483342170715, -0.027224060148000717, -0.01636623963713646, 0.006303576286882162, 0.001475792727433145, 0.044461689889431, -0.04174817353487015, -0.013804667629301548, -0.048622824251651764, -0.019848039373755455, 0.06290240585803986, 0.043429259210824966, 0.020086467266082764, -0.028146453201770782, -0.03427054360508919, 0.0144323306158185, -0.013406469486653805, -0.0170451607555151, -0.021494796499609947, 0.015950817614793777, -0.00017668807413429022, -0.018304094672203064, -0.015596103854477406, -0.02167290821671486, -0.03715755045413971, 0.028068793937563896, 0.031194673851132393, -0.02704053558409214, -0.04959024116396904, -0.0457589253783226, 0.025175441056489944, 0.03852662444114685, -0.008660401217639446, 0.016034621745347977, 0.014114893041551113, -0.05332958325743675, 0.029668256640434265, -0.03233909606933594, 0.05078503116965294, -0.004184909630566835, -0.025906173512339592, 0.004350021947175264, 0.005643052514642477, 0.0284273624420166, 0.04939371719956398, -0.007223616819828749, -0.00652046175673604, 0.009635129943490028, -0.0020309374667704105, -0.015372633934020996, 0.010036181658506393, 0.04878063499927521, -0.02567698433995247, 0.00045958461123518646, -0.0473531074821949, 0.00039529797504656017, 0.035158369690179825, -0.06411237269639969, -0.006592828314751387, 0.011507094837725163, -0.03573046997189522, 0.02041786164045334, 0.06931465119123459, 0.009081043303012848, -0.03796326369047165, -0.01654699631035328, 0.027317818254232407, -0.0014967266470193863, -0.01446384098380804, 0.002902842126786709, 0.04844685643911362, -0.007475808262825012, -0.0023430960718542337, 0.033863916993141174, 0.013484513387084007, 0.01831224001944065, 0.005413529463112354, -0.011874556541442871, 0.0335000641644001, 0.04635497182607651, 0.003345176111906767, 0.04856892675161362, -0.016561653465032578, 0.010587898083031178, 0.006523579824715853, 0.03313387185335159, -0.04811285436153412, -0.00026139061083085835, 0.007488876581192017, 0.027928277850151062, 0.022034060209989548, 0.04431965947151184, -0.029636630788445473, 0.07952404767274857, 0.01637331023812294, 0.0608668327331543, -0.03400773927569389, 0.019196923822164536, 0.02165672369301319, 0.009827164001762867, 0.03430299088358879, -0.00479018734768033, -0.04099145159125328, -0.012421585619449615, 0.033044006675481796, 0.02637745440006256, 0.051337577402591705, -0.017238948494195938, -0.0379549115896225, 0.03500170260667801, -0.029559265822172165, 0.013845815323293209, 0.011837263591587543, -0.02751792222261429, 0.013045900501310825, -0.021767420694231987, 0.02040283940732479, -0.013510456308722496, -0.012003982439637184, -0.005552566144615412, -0.016973810270428658, 0.002991511719301343, -0.010688462294638157, 0.020805655047297478, 0.050531744956970215, 0.011604647152125835, -0.03706745430827141, -0.03391990438103676, -0.04097305238246918, 0.02555101178586483, 0.07188976556062698, -0.020230522379279137, -0.029402023181319237, -0.01798667013645172, -0.035573847591876984, 0.0513455793261528, 0.04105893522500992, 0.010737686417996883, -0.012151209637522697, -0.016044583171606064, 0.04820374771952629, -0.034539226442575455, -0.0005091505008749664, 0.03224640339612961, -0.008342635817825794, -0.004562695045024157, -0.012270203791558743, -0.017898958176374435, 0.01940874196588993, -0.020662477239966393, -0.05304380878806114, 0.017734330147504807, 0.013243189081549644, -0.008383113890886307, 0.04598406329751015, 0.06631922721862793, -0.02347305230796337, -0.05279025435447693, 0.0015495795523747802, -0.011326250620186329, -0.007260945625603199, 0.06832713633775711, 0.03069211170077324, -0.02318546362221241, -0.03516014292836189, -0.0615379624068737, 0.000446161167928949, -0.020365813747048378, 0.0005486752488650382, 0.01782640814781189, 0.0070373667404055595, -0.03293570131063461, -0.010786204598844051, 0.027259916067123413, 0.025743957608938217, 0.016872981563210487, 0.006441172678023577, -0.015286793932318687, 0.0050913263112306595, 0.0009401040733791888, -0.007772806100547314, -0.049992360174655914, -0.04411318525671959, -0.01924961805343628, -0.03344205766916275, -0.03193892911076546, 0.024157939478754997, 0.02868754416704178, 0.0065765297040343285, -0.02450747601687908, 0.0006382105639204383, -0.04081376641988754, -0.04756456986069679, -0.027092251926660538, 0.029857194051146507, 0.015087801963090897, 0.04417724162340164, 0.014852027408778667, 0.03395582363009453, -0.02571709267795086, -0.008997432887554169, -0.01751687563955784, 0.008068779483437538, 0.026450615376234055, -0.02744862250983715, 0.003149260301142931, -0.014312687329947948, -0.004984850063920021, 0.00999712198972702, -0.03434882313013077, -0.019767362624406815, -0.0077758231200277805, 0.0030649849213659763, -0.013197281397879124, 0.05827621743083, -0.013050774112343788, -0.0021857842803001404, 0.046034712344408035, 0.0018162725027650595, -0.0443313792347908, 0.01361876167356968, -0.036935076117515564, -0.06888430565595627, 0.022610511630773544, 0.031666215509176254, 0.03688357397913933, 0.044809937477111816, -0.00007584270497318357, 0.017772726714611053, 0.032118137925863266, 0.008217360824346542, 0.05173322185873985, 0.013147988356649876, -0.03414103388786316, -0.04283744841814041, 0.018555667251348495, 0.026382260024547577, -0.004374247509986162, 0.005258418619632721, 0.04972614720463753, 0.026753602549433708, -0.02697627805173397, 0.024483181536197662, -0.03894307464361191, 0.007410577032715082, -0.0070953075774014, 0.029555849730968475, 0.029701625928282738, 0.042647045105695724, -0.0007434485596604645, 0.044331107288599014, -0.03413962572813034, 0.0355159193277359 ]
Boost Wav2Vec2 with n-gram LM in 🤗 Transformers
patrickvonplaten
January 12, 2022
wav2vec2-with-ngram
research, guide, audio
https://huggingface.co/blog/wav2vec2-with-ngram
=== 5/5 Writing ARPA model === ----5---10---15---20---25---30---35---40---45---50---55---60---65---70---75---80---85---90---95--100 **************************************************************************************************** Name:lmplz VmPeak:14181536 kB VmRSS:2199260 kB RSSMax:4160328 kB user:120.598 sys:26.6659 CPU:147.264 real:136.344 Great, we have built a 5-gram LM! Let's inspect the first couple of lines. bash head -20 5gram.arpa Output: bash \data\ ngram 1=360208 ngram 2=5476741 ngram 3=18177681 ngram 4=30374983 ngram 5=37231651 \1-grams: -6.770219 <unk> 0 0 <s> -0.11831701 -4.6095004 återupptagande -1.2174699 -2.2361007 av -0.79668784 -4.8163533 sessionen -0.37327805 -2.2251768 jag -1.4205662 -4.181505 förklarar -0.56261665 -3.5790775 europaparlamentets -0.63611007 -4.771945 session -0.3647111 -5.8043895 återupptagen -0.3058712 -2.8580177 efter -0.7557702 -5.199537 avbrottet -0.43322718 There is a small problem that 🤗 Transformers will not be happy about later on. The 5-gram correctly includes a "Unknown" or <unk>, as well as a begin-of-sentence, <s> token, but no end-of-sentence, </s> token. This sadly has to be corrected currently after the build. We can simply add the end-of-sentence token by adding the line 0 </s> -0.11831701 below the begin-of-sentence token and increasing the ngram 1 count by 1. Because the file has roughly 100 million lines, this command will take ca. 2 minutes. python with open("5gram.arpa", "r") as read_file, open("5gram_correct.arpa", "w") as write_file: has_added_eos = False for line in read_file: if not has_added_eos and "ngram 1=" in line: count=line.strip().split("=")[-1] write_file.write(line.replace(f"{count}", f"{int(count)+1}")) elif not has_added_eos and "<s>" in line: write_file.write(line) write_file.write(line.replace("<s>", "</s>")) has_added_eos = True else: write_file.write(line) Let's now inspect the corrected 5-gram. bash head -20 5gram_correct.arpa Output: bash \data\ ngram 1=360209 ngram 2=5476741 ngram 3=18177681 ngram 4=30374983 ngram 5=37231651 \1-grams: -6.770219 <unk> 0 0 <s> -0.11831701 0 </s> -0.11831701 -4.6095004 återupptagande -1.2174699 -2.2361007 av -0.79668784 -4.8163533 sessionen -0.37327805 -2.2251768 jag -1.4205662 -4.181505 förklarar -0.56261665 -3.5790775 europaparlamentets -0.63611007 -4.771945 session -0.3647111 -5.8043895 återupptagen -0.3058712 -2.8580177 efter -0.7557702 Great, this looks better! We're done at this point and all that is left to do is to correctly integrate the "ngram" with pyctcdecode and 🤗 Transformers.
[ 0.016145801171660423, 0.036427393555641174, 0.07267792522907257, -0.025401204824447632, 0.13112308084964752, -0.027055172249674797, 0.11792910844087601, -0.018657701089978218, -0.03978962078690529, -0.02379918284714222, 0.006947248242795467, 0.056522369384765625, -0.046105023473501205, 0.031287092715501785, -0.005216281861066818, 0.055425014346838, 0.003139741253107786, -0.019275804981589317, 0.03075660765171051, 0.02469145692884922, -0.0031738493125885725, -0.03946639969944954, 0.07865126430988312, 0.05147166922688484, 0.08950384706258774, -0.00025567380362190306, 0.01394718699157238, -0.002058306010439992, -0.09094007313251495, 0.02632693201303482, -0.012343884445726871, 0.04353295639157295, 0.013882135972380638, 0.025876374915242195, 0.03772753104567528, 0.03414406254887581, -0.0855005532503128, 0.1181536316871643, -0.01967870071530342, -0.04338178411126137, 0.0021968898363411427, -0.07404077798128128, -0.043289296329021454, 0.022374477237462997, -0.017230872064828873, -0.04988831654191017, -0.05995859205722809, 0.10781916230916977, 0.024865515530109406, -0.003985951654613018, -0.07065483182668686, 0.07056059688329697, -0.03882358595728874, -0.005573359318077564, -0.01124630682170391, 0.03430419787764549, 0.04005623981356621, 0.03695976361632347, 0.06272295117378235, -0.00358846434392035, 0.04114062711596489, -0.07164793461561203, -0.009046787396073341, -0.036345720291137695, 0.018257061019539833, 0.031096791848540306, -0.011075928807258606, -0.021259598433971405, -0.025517750531435013, 0.00847270991653204, -0.06191065162420273, 0.015200989320874214, -0.015632400289177895, 0.024909403175115585, -0.021328216418623924, -0.03907698020339012, 0.008643798530101776, 0.048575930297374725, 0.04059324041008949, 0.06631319969892502, 0.008387841284275055, 0.015785032883286476, -0.03353474661707878, 0.05233880504965782, 0.022001221776008606, -0.05612511932849884, 0.025588707998394966, -0.04034437611699104, -0.005831950344145298, 0.03542112559080124, -0.01974177174270153, -0.059047333896160126, 0.011157295666635036, 0.03390434756875038, 0.0023612214718014, -0.03842763975262642, -0.013802907429635525, 0.0443524532020092, -0.008358464576303959, 0.022241294384002686, 0.04013372212648392, -0.02062750607728958, 0.037888895720243454, -0.03661669045686722, -0.02520584873855114, 0.043174151331186295, 0.022390998899936676, -0.074103944003582, -0.0719674751162529, -0.03125183284282684, -0.01668967492878437, 0.12111565470695496, 0.03665865585207939, 0.000028160146030131727, -0.07219643145799637, 0.014948645606637001, -0.03902873396873474, 0.023821426555514336, 0.016489645466208458, 0.050313837826251984, 0.03252807632088661, 0.16082629561424255, 0.07988179475069046, 0.0019980764482170343, 0.03165863826870918, 0.023818695917725563, 0.050528910011053085, -0.012950262054800987, -0.033365629613399506, 0.06865358352661133, 0.0035906045231968164, 0.009628640487790108, 0.013795954175293446, 0.07168920338153839, 0.028091492131352425, 0.010319923050701618, -0.023562463000416756, 0.04035530239343643, 0.04662804678082466, -0.005876661278307438, -0.03414379060268402, -0.01665748655796051, -0.03484998270869255, 0.046220164746046066, -0.019169069826602936, -0.0016697635874152184, -0.02650333195924759, 0.014135899022221565, -0.03104165568947792, 0.00045266756205819547, -0.0137775344774127, 0.015855278819799423, -0.03432265669107437, -0.02915991097688675, 0.0016574752517044544, 0.0066221775487065315, -0.015380718745291233, 0.00889609195291996, -0.1123967170715332, -0.03607923537492752, 0.04298445209860802, -0.030253354460000992, -0.025208180770277977, -0.015927685424685478, 0.003624376142397523, 0.003664671443402767, -0.011559952050447464, 0.02098344825208187, -0.017218204215168953, 0.02408394031226635, 0.0032952118199318647, -0.01812870241701603, 0.0857052206993103, -0.019886242225766182, 0.003175566205754876, 0.052577339112758636, 0.04734139144420624, 0.01604292169213295, 0.0008057656814344227, -0.029819877818226814, 0.02425132505595684, 0.05876145139336586, -0.05213949456810951, 0.063010573387146, -0.05768506973981857, -0.11170946806669235, -0.005200998857617378, -0.02987116016447544, -0.009922504425048828, 0.015449698083102703, -0.06249203160405159, -0.0468052476644516, 0.11091222614049911, -0.009273545816540718, -0.022963497787714005, -0.04839857667684555, -0.07154746353626251, 0.054467812180519104, 0.08254627138376236, 0.10962584614753723, -0.041815273463726044, 0.04784809798002243, 0.06427981704473495, -0.07283079624176025, -0.022816529497504234, -0.004931510891765356, 0.0006576981395483017, -0.074424147605896, 0.07862060517072678, 0.05542684718966484, 0.009749405086040497, -0.10726740956306458, 0.02927795797586441, -0.06666037440299988, -0.043819814920425415, -0.0024824305437505245, -0.005991353187710047, -0.010089571587741375, 0.030519340187311172, 0.004899388179183006, 0.03125971928238869, -0.020707789808511734, -0.012325157411396503, 0.027076173573732376, 0.0008561405120417476, 0.05173097550868988, 0.08683089166879654, 0.04562641307711601, 0.057672299444675446, -0.032788243144750595, -0.011449902318418026, -0.044855497777462006, 0.038651954382658005, 0.10834089666604996, 0.027110762894153595, 0.06571178138256073, -0.036504827439785004, 0.02045409381389618, -0.004295035731047392, -0.06982287019491196, -0.006892045494168997, 0.0443275161087513, -0.0534638985991478, 0.0867137685418129, -0.038603346794843674, -0.08241596817970276, 0.09912765771150589, 0.01958450861275196, -0.06151600182056427, -0.01747186668217182, -0.04326130077242851, 0.050447192043066025, -0.06600993871688843, -0.05409011244773865, 0.017665859311819077, -0.008364290930330753, -0.00801816675812006, -0.006101167760789394, -0.04744258150458336, -0.03669668734073639, -0.011075281538069248, -0.02292466163635254, 0.013065164908766747, -0.05919507518410683, 0.017065610736608505, 0.0023226903285831213, 0.022002127021551132, -0.040280863642692566, -0.03045705519616604, 0.00978306494653225, 0.0009011002257466316, -0.021555714309215546, 0.05670548975467682, 0.006408947054296732, 0.011980189010500908, -0.04199804738163948, -0.022837189957499504, -0.012411409988999367, 0.024237098172307014, -0.041912104934453964, -0.041637737303972244, -0.03407112881541252, 0.04626840353012085, 0.05129503458738327, 0.006883841007947922, -0.010139553807675838, 0.022532617673277855, -0.008010570891201496, -0.042575761675834656, 0.05487905070185661, -0.0316479466855526, 0.016819234937429428, -0.003590889973565936, -0.007893024012446404, 0.025283798575401306, -0.006720026955008507, 0.016642702743411064, -0.018771935254335403, 0.007029976230114698, -0.015145127661526203, 0.027601787820458412, 0.013096746988594532, -0.006738289259374142, 0.0015894189709797502, -0.043006159365177155, 0.042640358209609985, 0.0027235436718910933, 0.03256969153881073, -0.1029667928814888, 0.04950147867202759, 0.03225291520357132, 0.01436498761177063, 0.031849127262830734, 0.02317011170089245, 0.051011960953474045, -0.012088893912732601, 0.021485615521669388, -0.00729430140927434, 0.012312812730669975, -0.008104831911623478, 0.01654011756181717, -0.010572642087936401, 0.0009231558651663363, -0.03783543407917023, 0.009381084702908993, 0.03367187827825546, 0.034478433430194855, -0.03042113408446312, 0.012038416229188442, -0.0001306521735386923, -0.012520510703325272, -0.020171672105789185, -0.020937947556376457, 0.04887741804122925, -0.018885033205151558, -0.007170000113546848, 0.003203387139365077, -0.0022068596445024014, -0.047308821231126785, -0.028384212404489517, 0.0035377948079258204, 0.004342472646385431, -0.02941969409584999, -0.024495720863342285, -0.04367738217115402, -0.001638468587771058, 0.0041549429297447205, 0.0697556808590889, 0.02408425137400627, 0.00017079654207918793, 0.022253181785345078, -0.009364842437207699, -0.04030665382742882, -0.0051040430553257465, 0.04025448486208916, -0.004303145222365856, 0.04232250899076462, 0.0041602300480008125, -0.019701024517416954, -0.009578073397278786, 0.00827806442975998, 0.0062752412632107735, -0.022122392430901527, 0.021792927756905556, -0.030181940644979477, 0.008983835577964783, 0.04802913963794708, -0.019888395443558693, -0.01583278551697731, 0.016043834388256073, -0.02788752317428589, -0.02414782904088497, 0.008146549575030804, 0.086665078997612, 0.04610954225063324, -0.009717663750052452, -0.006493519060313702, 0.036538589745759964, -0.014849371276795864, 0.03709013760089874, 0.0009097825968638062, 0.00023434650211129338, 0.0011625268962234259, -0.03972374275326729, -0.006789516657590866, -0.02747518941760063, 0.013518731109797955, 0.00521067762747407, -0.007431498728692532, -0.008455942384898663, -0.04027324169874191, -0.0034202171955257654, 0.05496496334671974, 0.003064011689275503, -0.049078281968832016, 0.05394593998789787, -0.010066960006952286, 0.028410155326128006, 0.02526799403131008, -0.02667682059109211, 0.044607337564229965, 0.034089166671037674, -0.013649139553308487, -0.012943529523909092, 0.033955302089452744, -0.023851821199059486, 0.012922876514494419, 0.028348218649625778, -0.004222291987389326, 0.006599768530577421, 0.01957191899418831, -0.030993226915597916, -0.04066599905490875, -0.01946607232093811, -0.023443002253770828, -0.017633561044931412, 0.0017644414911046624, -0.02170017547905445, -0.011378216557204723, -0.01948399469256401, 0.0432860404253006, -0.026526855304837227, 0.010338468477129936, 0.025763053447008133, -0.024307413026690483, -0.03187785670161247, -0.02661818265914917, 0.014483594335615635, -0.0620579794049263, 0.01968332938849926, -0.00822510477155447, -0.019047193229198456, 0.01668408513069153, -0.026854844763875008, -0.03319816291332245, 0.02305198460817337, -0.03415107727050781, -0.0018989231903105974, -0.013532379642128944, -0.031463373452425, 0.057115573436021805, -0.02673942968249321, 0.040385954082012177, 0.006750347092747688, -0.015400697477161884, 0.026188557967543602, 0.03290814906358719, -0.04787175729870796, -0.010551595129072666, 0.024025874212384224, 0.03407304733991623, -0.027330590412020683, -0.003922195173799992, -0.014795724302530289, 0.020280472934246063, -0.016064532101154327, 0.05668272450566292, 0.009067948907613754, 0.046924054622650146, -0.02563607133924961, -0.0713646188378334, -0.015283830463886261, 0.023752963170409203, 0.007150487974286079, 0.017631791532039642, 0.001062752678990364, -0.0006781028932891786, 0.02514808066189289, 0.00846166256815195, -0.0558554008603096, -0.05248938500881195, 0.013001415878534317, -0.022343875840306282, -0.027978969737887383, -0.0034930130932480097, -0.009950688108801842, -0.005022835452109575, 0.01394282840192318, -0.062185660004615784, 0.0010551530867815018, 0.033873774111270905, -0.03697371855378151, 0.03241444751620293, 0.036925531923770905, -0.03249232470989227, -0.008719218894839287, 0.06916849315166473, 0.0301387757062912, -0.025464482605457306, 0.022948596626520157, 0.0019652305636554956, 0.02961082197725773, -0.03515844792127609, 0.0027449228800833225, 0.0023555580992251635, 0.014442622661590576, 0.05104861408472061, -0.003641490824520588, -0.02107088454067707, 0.0015879846177995205, 0.044761430472135544, -0.027785826474428177, 0.044631872326135635, -0.0018744246335700154, -0.045392271131277084, 0.020587338134646416, -0.025557737797498703, -0.027662698179483414, 0.04691317304968834, 0.0536271296441555, -0.022145159542560577, -0.028088536113500595, 0.017438525334000587, 0.01524199265986681, -0.00040006081690080464, 0.012562815099954605, -0.013104586862027645, 0.008967827074229717, 0.008194321766495705, -0.012890595011413097, -0.047446358948946, 0.021542387083172798, 0.05288892239332199, -0.013370927423238754, -0.06453597545623779, 0.025561973452568054, 0.01333723682910204, 0.021492058411240578, 0.008091844618320465, -0.0030735572800040245, 0.004182191099971533, 0.020522207021713257, 0.04610588774085045, -0.00915455725044012, 0.03326054662466049, -0.011736302636563778, -0.006470703985542059, -0.002031453885138035, 0.03211524337530136, -0.0065305656753480434, 0.0031530987471342087, 0.02352227084338665, 0.015567821450531483, 0.005956553854048252, -0.01930704154074192, 0.028144197538495064, 0.012183469720184803, 0.005457242950797081, -0.02287796325981617, -0.04036870226264, -0.07024632394313812, 0.02753468044102192, -0.007097678259015083, -0.014462212100625038, 0.03076746314764023, 0.02337823621928692, 0.002588501665741205, -0.005557030905038118, 0.04719860479235649, -0.015238333493471146, -0.011222632601857185, 0.054049815982580185, 0.05726414918899536, 0.03231535851955414, -0.023599406704306602, -0.04154975339770317, 0.019306868314743042, -0.018976908177137375, 0.02242034487426281, -0.008768823929131031, -0.01285482943058014, 0.04256497323513031, -0.03783980756998062, 0.014859657734632492, -0.010972156189382076, -0.06298784166574478, 0.05814475193619728, 0.022982660681009293, -0.023501070216298103, -0.03787447139620781, 0.008732893504202366, 0.018095053732395172, -0.01995854079723358, 0.018239736557006836, 0.04374024271965027, 0.04854792356491089, 0.014258797280490398, -0.018701838329434395, -0.01915852539241314, -0.0048484415747225285, 0.021189318969845772, 0.004169394262135029, -0.08243799209594727, 0.009333713911473751, 0.05514143407344818, -0.03530674800276756, 0.008710253983736038, -0.003527674823999405, -0.04660768061876297, 0.0042765201069414616, -0.015126045793294907, -0.010425093583762646, -0.06250935792922974, 0.014135169796645641, -0.012921079061925411, -0.01737997494637966, 0.004042592830955982, -0.06470164656639099, 0.03889649361371994, 0.02641887031495571, 0.016316767781972885, 0.0001518393837613985, -0.03388286009430885, -0.0599370114505291, 0.027369098737835884, -0.027356399223208427, 0.06246189773082733, -0.015277172438800335, -0.018506865948438644, 0.044631633907556534, -0.0431106835603714, 0.033811554312705994, 0.020561302080750465, -0.014670577831566334, 0.0354430191218853, -0.01915355958044529, -0.0004492311563808471, -0.023352256044745445, 0.02581789717078209, -0.009082178585231304, -0.010949013754725456, 0.02901320531964302, -0.032762911170721054, -0.05431074649095535, -0.006574838887900114, -0.02453847974538803, 0.0003312976914457977, -0.014532554894685745, 0.019636914134025574, 0.013659398071467876, 0.0031689268071204424, -0.006360322702676058, -0.05930771306157112, 0.01949876919388771, 0.025838371366262436, -0.015531542710959911, -0.015654128044843674, -0.003072179388254881, -0.017543518915772438, -0.012328905053436756, -0.019685162231326103, -0.002050241222605109, 0.024870915338397026, -0.0528428740799427, 0.0513777956366539, 0.026951080188155174, -0.03417059779167175, -0.003323957324028015, -0.004206021782010794, 0.026458069682121277, -0.03168591484427452, 0.0384083166718483, 0.0006479280418716371, 0.008487867191433907, 0.0099034383893013, 0.014079312793910503, 0.005346319172531366, 0.00030099315335974097, 0.034640055149793625, -0.04066677764058113, -0.012357682920992374, 0.008257223293185234, -0.038599178194999695, -0.07946076989173889, 0.01214684545993805, -0.04742860049009323, -0.004429526627063751, -0.013809422962367535, 0.032842691987752914, 0.02341812290251255, 0.014652183279395103, -0.023524416610598564, -0.02458886057138443, -0.005116306245326996, 0.028519868850708008, -0.021846482530236244, -0.007699369918555021, -0.021391987800598145, 0.003958567511290312, 0.004306664690375328, -0.0025295321829617023, 0.045971982181072235, 0.008882774040102959, 0.06188524514436722, 0.012166648171842098, -0.00847425777465105, -0.02025839500129223, 0.05279941111803055, -0.005052423570305109, -0.02404676005244255, -0.020101265981793404, -0.018118754029273987, -0.043639782816171646, 0.040474191308021545, -0.04057934135198593, -0.011648068204522133, -0.008634245954453945, -0.039506036788225174, -0.02833344042301178, 0.012213054113090038, 0.003457040525972843, 0.03669358044862747, -0.00909156072884798, 0.02649141289293766, -0.04353629797697067, 0.011900576762855053, -0.03583219647407532, 0.06273701041936874, 0.0153929078951478, 0.01426095049828291, 0.0043279798701405525, -0.017932888120412827, -0.015723884105682373, -0.017542917281389236, -0.056421779096126556, -0.05476467311382294, 0.025912689045071602, -0.01587432436645031, 0.0066338349133729935, 0.019944248721003532, -0.013711702078580856, -0.043251048773527145, 0.01497244369238615, -0.009235503152012825, 0.013910552486777306, 0.0026934873312711716, -0.018687205389142036, -0.06109313294291496, 0.012420149520039558, 0.025634558871388435, -0.03618704527616501, 0.04840826988220215, 0.03600383922457695, -0.01198146864771843, -0.007591567002236843, -0.008049837313592434, -0.012191565707325935, 0.010945948772132397, -0.01344645582139492, -0.023941781371831894, 0.04054151102900505, -0.01864611729979515, 0.01011468656361103, -0.062392160296440125, 0.025021778419613838, 0.015049627050757408, 0.010430637747049332, -0.00823916681110859, -0.026755021885037422, -0.028809593990445137, 0.028369925916194916, -0.023554246872663498, -0.03396432101726532, 0.015124800615012646, 0.04694946110248566, -0.017884422093629837, 0.0023835913743823767, -0.012118234299123287 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Introduction Transfer learning has changed Machine Learning by reaching new levels of accuracy from Natural Language Processing (NLP) to Audio and Computer Vision tasks. At Hugging Face, we work hard to make these new complex models and large checkpoints as easily accessible and usable as possible. But while researchers and data scientists have converted to the new world of Transformers, few companies have been able to deploy these large, complex models in production at scale. The main bottleneck is the latency of predictions which can make large deployments expensive to run and real-time use cases impractical. Solving this is a difficult engineering challenge for any Machine Learning Engineering team and requires the use of advanced techniques to optimize models all the way down to the hardware. With Hugging Face Infinity, we offer a containerized solution that makes it easy to deploy low-latency, high-throughput, hardware-accelerated inference pipelines for the most popular Transformer models. Companies can get both the accuracy of Transformers and the efficiency necessary for large volume deployments, all in a simple to use package. In this blog post, we want to share detailed performance results for Infinity running on the latest generation of Intel Xeon CPU, to achieve optimal cost, efficiency, and latency for your Transformer deployments.
[ -0.05246860533952713, -0.03964732214808464, -0.025983165949583054, 0.01727033220231533, 0.016363149508833885, 0.04295262694358826, 0.0354294516146183, 0.10830323398113251, -0.0057236491702497005, 0.0031557753682136536, -0.03539856895804405, 0.0428885892033577, -0.026476483792066574, 0.05169902741909027, 0.021846862509846687, -0.029280850663781166, 0.061698634177446365, 0.004703387152403593, -0.026815146207809448, 0.06735668331384659, 0.06247071921825409, -0.0839422196149826, 0.0647813007235527, 0.01674206554889679, -0.08219633996486664, -0.07032912969589233, -0.01141456700861454, -0.005718308035284281, 0.03396287560462952, 0.061507698148489, -0.06526688486337662, -0.03534410893917084, 0.01980036124587059, -0.053641196340322495, -0.0074693588539958, -0.04149719327688217, -0.10258404910564423, 0.02442595362663269, -0.014617879875004292, -0.02152686007320881, 0.035607222467660904, 0.03936709836125374, -0.0353960357606411, 0.023479105904698372, -0.0016950765857473016, -0.009729674085974693, -0.0456991009414196, 0.0069969696924090385, -0.016531238332390785, 0.006527892779558897, -0.08294115960597992, 0.07019567489624023, -0.02998155541718006, 0.006621344015002251, 0.05290185660123825, 0.06624272465705872, -0.010545407421886921, -0.07401400804519653, -0.045517805963754654, 0.023218723013997078, -0.003556146752089262, 0.00684699509292841, -0.02721848525106907, -0.05400656908750534, -0.04148432984948158, -0.024187924340367317, 0.013827032409608364, -0.029102807864546776, -0.034718405455350876, -0.060673486441373825, -0.00048687259550206363, 0.009593605063855648, 0.02657613717019558, -0.06576782464981079, -0.012427622452378273, 0.003412778489291668, -0.0064001185819506645, 0.00590037927031517, 0.07212939113378525, 0.05097578093409538, -0.0053020743653178215, 0.0243228767067194, 0.026445632800459862, 0.04451679810881615, 0.054758958518505096, 0.016002634540200233, 0.027594145387411118, 0.011530021205544472, -0.10573922842741013, 0.021911943331360817, 0.06027498468756676, -0.07667265087366104, 0.008284990675747395, 0.014320283196866512, 0.032681334763765335, 0.054170165210962296, 0.03306842967867851, 0.06461823731660843, 0.0015609689289703965, 0.0036474247463047504, 0.025670954957604408, -0.010720163583755493, -0.02369428239762783, -0.04510832577943802, -0.01927175000309944, -0.01895565167069435, -0.01069805771112442, -0.0839666798710823, -0.03632830083370209, 0.027772070840001106, -0.043525371700525284, -0.014228717423975468, -0.015036474913358688, 0.03260558471083641, -0.14338520169258118, -0.004698991775512695, -0.022106196731328964, 0.01927942782640457, 0.03722196817398071, -0.01371636614203453, 0.04033815488219261, 0.09612546861171722, 0.009083261713385582, -0.06441381573677063, -0.00016593087639193982, 0.0387299507856369, -0.04660472646355629, 0.012759147211909294, 0.009970935061573982, -0.004883352667093277, 0.017317267134785652, -0.07222142070531845, 0.05976332724094391, 0.016438623890280724, -0.012829064391553402, -0.08179325610399246, 0.02334011159837246, -0.05131162703037262, -0.019517257809638977, 0.040313392877578735, -0.01558229885995388, 0.02645844593644142, 0.062398944050073624, -0.08007873594760895, 0.11385034024715424, -0.042454544454813004, -0.10177895426750183, 0.042601704597473145, 0.032562512904405594, 0.002028699265792966, -0.11073299497365952, 0.017660124227404594, -0.07028692960739136, -0.03644081950187683, 0.035083360970020294, 0.0507095567882061, -0.01160322967916727, -0.02442345768213272, -0.08560991287231445, -0.08741798996925354, -0.06656824797391891, -0.03953656181693077, -0.05647467076778412, -0.02734510228037834, 0.010876992717385292, 0.01041482761502266, 0.03315909579396248, 0.02079312689602375, -0.02536688558757305, -0.010517435148358345, 0.03447888791561127, -0.0023583401925861835, 0.04614639654755592, -0.007666421588510275, 0.011342689394950867, -0.0214423518627882, 0.010569321922957897, 0.09288747608661652, 0.01974012330174446, -0.01350940391421318, -0.025713324546813965, 0.11380311101675034, 0.03331867977976799, 0.09540219604969025, 0.014132975600659847, -0.060403402894735336, -0.006821214687079191, 0.0007246159948408604, -0.009178675711154938, -0.029017167165875435, -0.04272086173295975, 0.017170047387480736, 0.07962089031934738, -0.005961584392935038, -0.013104983605444431, -0.0054075391963124275, -0.020727358758449554, 0.0823984369635582, 0.04633450135588646, 0.05955825001001358, 0.05033788084983826, -0.021319320425391197, 0.11007316410541534, -0.040981072932481766, -0.06346994638442993, -0.04072824493050575, -0.0670420452952385, -0.04573732987046242, -0.010007895529270172, 0.036992624402046204, -0.016902267932891846, -0.13668940961360931, -0.028517641127109528, -0.018337536603212357, -0.02703186869621277, -0.050277724862098694, -0.03182659298181534, 0.0025177455972880125, -0.0035515453200787306, -0.03837810829281807, 0.12772609293460846, -0.04442062973976135, -0.005248802248388529, -0.06441638618707657, 0.027951844036579132, -0.03060709498822689, 0.0648365244269371, -0.0033535531256347895, 0.03786225616931915, -0.011537514626979828, -0.060385581105947495, -0.10599784553050995, -0.09342225641012192, -0.02369517646729946, 0.058091700077056885, -0.014954694546759129, 0.0027444991283118725, 0.0013251756317913532, -0.002512414939701557, 0.028631795197725296, -0.03392646089196205, 0.019210143014788628, -0.03564253821969032, 0.026048528030514717, 0.04459403455257416, -0.008305917493999004, 0.04821407049894333, -0.014793655835092068, 0.033989738672971725, -0.031183600425720215, -0.04693406820297241, 0.00216978183016181, 0.004206942860037088, -0.03010600619018078, 0.03594670817255974, -0.023954123258590698, 0.010178370401263237, 0.002032269723713398, -0.04366772249341011, 0.04435949772596359, 0.016992075368762016, -0.0201495923101902, 0.003340254072099924, -0.017245158553123474, 0.008734207600355148, -0.03963955491781235, -0.011425483971834183, -0.00827953964471817, 0.016465479508042336, -0.04287479445338249, -0.01490755658596754, -0.03219549357891083, 0.03006802871823311, -0.01612597517669201, -0.011642485857009888, 0.02157185785472393, 0.01843995600938797, 0.012179775163531303, -0.025185726583003998, -0.02898862026631832, 0.041951894760131836, -0.044099584221839905, -0.010994361713528633, 0.006821154151111841, 0.02044813148677349, -0.017724575474858284, -0.01408024225383997, -0.04354143515229225, -0.02749587781727314, -0.01684580370783806, 0.05158533528447151, -0.011411097832024097, -0.008449940010905266, -0.01700487546622753, -0.013727830722928047, 0.01787775196135044, 0.01809595711529255, -0.04992431774735451, -0.010052490048110485, 0.011969395913183689, -0.03606824576854706, -0.007712880149483681, 0.0009034761460497975, 0.06139124557375908, 0.011043180711567402, 0.015556213445961475, 0.020566578954458237, 0.0015866897301748395, -0.06734146177768707, -0.002042345004156232, -0.049739591777324677, 0.022206950932741165, -0.016118744388222694, -0.0655948668718338, 0.023810530081391335, 0.008668246679008007, 0.023668158799409866, 0.020602665841579437, 0.024833135306835175, 0.040127772837877274, 0.015829715877771378, -0.025733068585395813, 0.01040850579738617, -0.0052930391393601894, 0.03222492337226868, -0.035163383930921555, 0.016373859718441963, 0.007081344723701477, -0.01399416197091341, -0.037711694836616516, 0.035330671817064285, -0.02117709256708622, 0.01758289523422718, 0.05827755481004715, 0.03535115346312523, -0.026703031733632088, 0.023580828681588173, -0.00892000924795866, -0.034573547542095184, -0.007020498160272837, -0.03733323886990547, 0.01761803589761257, -0.006265013013035059, 0.01759490557014942, -0.024059994146227837, 0.025472942739725113, 0.043706297874450684, 0.018577685579657555, 0.0028584846295416355, -0.012243324890732765, 0.040885522961616516, -0.03263120353221893, 0.06445900350809097, -0.003818715689703822, 0.022672515362501144, -0.05242088809609413, 0.014604814350605011, -0.026158099994063377, -0.04787878319621086, 0.04335832595825195, 0.019090725108981133, 0.02972307614982128, 0.020903967320919037, 0.020511090755462646, -0.003229732159525156, -0.024714317172765732, 0.030128056183457375, 0.006053455173969269, -0.04493726044893265, 0.030647534877061844, -0.031580012291669846, -0.009557590819895267, -0.021611705422401428, 0.052952222526073456, 0.0036733117885887623, -0.037221938371658325, 0.018750278279185295, 0.00214987900108099, 0.0021163199562579393, 0.07554714381694794, -0.018052246421575546, 0.005431318189948797, -0.024635164067149162, 0.005905719939619303, 0.010540650226175785, -0.030499828979372978, 0.0236615352332592, 0.047658730298280716, -0.06076416000723839, -0.03006937727332115, -0.01106475479900837, 0.009926468133926392, -0.00494961766526103, 0.025292111560702324, 0.013354551047086716, -0.03601120039820671, -0.007878451608121395, 0.02997937984764576, 0.0053323847241699696, -0.018847543746232986, -0.0013973951572552323, -0.07408315688371658, -0.006860019639134407, -0.05664992704987526, 0.016879120841622353, 0.022302793338894844, -0.008722016587853432, -0.030697064474225044, -0.0289864894002676, -0.011627835221588612, 0.012255850248038769, 0.0006268115248531103, -0.054325543344020844, 0.028402071446180344, 0.024833152070641518, -0.001803682534955442, 0.02084960788488388, 0.015638194978237152, 0.0356568917632103, -0.026250764727592468, 0.009157374501228333, -0.009199518710374832, 0.06362342834472656, -0.006007219199091196, 0.01561048999428749, 0.02219601906836033, 0.00013451285485643893, 0.009343243204057217, -0.0035719419829547405, 0.021658549085259438, -0.004717404022812843, -0.026086589321494102, 0.0280301570892334, 0.026591436937451363, 0.005184528883546591, 0.026623006910085678, -0.0006171292043291032, -0.02319089137017727, -0.02626737952232361, 0.03229844197630882, 0.06741807609796524, 0.03078405186533928, 0.01642945036292076, -0.030767709016799927, -0.005241731647402048, -0.01991080865263939, -0.03987684100866318, 0.016356462612748146, 0.0018255820032209158, 0.023461880162358284, 0.023644769564270973, -0.039883505553007126, 0.012233397923409939, 0.03816274553537369, 0.013798692263662815, -0.009870409034192562, -0.0032358572352677584, 0.01162886805832386, -0.008670611307024956, 0.00330917164683342, -0.016374699771404266, 0.0438648946583271, 0.08178307116031647, 0.03555624932050705, -0.02684875950217247, -0.008364262990653515, 0.010303136892616749, 0.026335177943110466, -0.009827965870499611, 0.03480853885412216, -0.03809642046689987, -0.038584623485803604, 0.019213484600186348, 0.014415367506444454, -0.019072983413934708, 0.015549708157777786, -0.03039274550974369, 0.02140735276043415, -0.025287313386797905, 0.014988243579864502, 0.02720336802303791, 0.0034219282679259777, 0.005672058556228876, 0.06023023650050163, 0.020634492859244347, -0.03098524734377861, 0.01354866661131382, 0.05702895671129227, 0.005284416954964399, -0.04745063930749893, 0.05455294996500015, -0.017748819664120674, 0.01683857850730419, -0.011841530911624432, 0.07600562274456024, 0.06513024121522903, -0.04133216664195061, 0.007844829931855202, -0.01694486290216446, -0.019635658711194992, 0.004092345479875803, -0.02703932859003544, -0.013965158723294735, -0.04641373082995415, 0.022172849625349045, 0.04962512478232384, 0.009928126819431782, -0.016028011217713356, 0.009473745711147785, 0.027790900319814682, 0.0008508909377269447, 0.0005513138603419065, 0.042691659182310104, 0.024558378383517265, 0.0018778941594064236, -0.013275745324790478, 0.029795682057738304, 0.016858557239174843, 0.002584329806268215, 0.027286654338240623, -0.0322902537882328, 0.01669461466372013, -0.0025747509207576513, -0.003207704983651638, -0.021896451711654663, 0.0637030377984047, 0.061794109642505646, 0.04082540422677994, -0.0483890175819397, -0.025634516030550003, 0.005961213726550341, -0.03626067191362381, -0.009191266261041164, -0.04068245738744736, 0.04433273524045944, -0.004958304576575756, -0.034817811101675034, -0.006788033992052078, -0.005462098401039839, 0.004809163976460695, -0.008047156035900116, 0.025890955701470375, 0.05262492597103119, 0.007075291592627764, 0.025298908352851868, 0.012640859931707382, 0.03631513565778732, -0.027490051463246346, -0.007281364873051643, -0.024838386103510857, 0.013548546470701694, 0.025760434567928314, -0.07911405712366104, 0.05205151066184044, 0.04954245686531067, -0.0012931742239743471, -0.03372696414589882, -0.0008860543603077531, -0.010580982081592083, -0.027042098343372345, 0.012154385447502136, -0.01164334174245596, -0.01673821359872818, -0.018822696059942245, 0.02283087931573391, 0.012781740166246891, 0.026999520137906075, 0.03571620211005211, 0.00039076790562830865, -0.06792014092206955, 0.0171190295368433, 0.026423564180731773, 0.0157016571611166, 0.048019539564847946, -0.035959720611572266, -0.018742863088846207, 0.06541736423969269, 0.065133236348629, 0.011927054263651371, 0.02826732210814953, 0.020960645750164986, 0.007978834211826324, -0.04900515824556351, 0.00040704660932533443, 0.027735788375139236, 0.048192098736763, 0.02272125333547592, 0.0126423304900527, 0.01693122088909149, 0.02084396965801716, 0.04037981480360031, -0.013179318979382515, 0.029063675552606583, -0.018100665882229805, 0.06395616382360458, -0.034265290945768356, 0.03366757556796074, 0.05440850183367729, -0.022157710045576096, -0.006949889473617077, 0.0038719461299479008, -0.01860290765762329, 0.014942914247512817, 0.010421809740364552, 0.03432560712099075, -0.03384136036038399, 0.008443938568234444, -0.044321753084659576, 0.0389205664396286, 0.043863847851753235, 0.0063830893486738205, -0.014610727317631245, 0.011585724540054798, 0.03073401004076004, 0.014087395742535591, 0.0030741356313228607, -0.017749447375535965, -0.0005449143354780972, -0.01193381566554308, 0.06883008778095245, -0.007149980403482914, 0.05859377235174179, -0.018446700647473335, 0.02508547157049179, -0.017823588103055954, -0.03132283315062523, -0.003224025247618556, 0.06374992430210114, -0.015393844805657864, -0.011357888579368591, 0.0022621226962655783, 0.014659593813121319, -0.0040300823748111725, 0.05472876876592636, -0.020567620173096657, -0.010247358120977879, -0.01999868080019951, 0.008562939241528511, 0.0011414174223318696, 0.02404641918838024, 0.011645975522696972, -0.025465451180934906, 0.005162722896784544, -0.03796862065792084, 0.010468735359609127, 0.02243729680776596, -0.010299409739673138, -0.003460885025560856, 0.01661360077559948, 0.007256150711327791, 0.023500017821788788, 0.0446762889623642, 0.013052880764007568, 0.014416901394724846, 0.03557170182466507, 0.04024394974112511, 0.03413372114300728, 0.003843097249045968, 0.01533570233732462, 0.02189773879945278, -0.02211787924170494, -0.0012130929389968514, 0.018060553818941116, -0.06251249462366104, 0.00943173747509718, -0.03760157898068428, 0.00988000351935625, -0.004204069264233112, 0.03147611394524574, 0.00536402128636837, 0.049830589443445206, -0.03546586632728577, -0.008710925467312336, 0.0076986211352050304, 0.016475874930620193, -0.014707762748003006, 0.0474039651453495, -0.037288643419742584, -0.0301420446485281, 0.011671655811369419, 0.024938492104411125, 0.03740080073475838, 0.005289414897561073, 0.01368728931993246, 0.025016481056809425, -0.038940344005823135, -0.036336783319711685, -0.014636359177529812, 0.0017431213054805994, 0.030864190310239792, 0.03858232498168945, 0.042236581444740295, 0.037324756383895874, 0.03782723844051361, -0.021338634192943573, 0.002013299148529768, -0.03389700874686241, 0.0003074465203098953, -0.02733610011637211, -0.007652081083506346, 0.007220021914690733, -0.0060479589737951756, -0.000684281752910465, 0.015841277316212654, -0.041613634675741196, -0.012662330642342567, -0.048526208847761154, -0.037811096757650375, 0.036859918385744095, -0.008192252367734909, 0.05487515404820442, 0.03600510582327843, 0.0011149018537253141, 0.02263437956571579, -0.03720273822546005, -0.0338565856218338, -0.035315003246068954, 0.012506821192800999, 0.08540870249271393, 0.008413291536271572, -0.0044844732619822025, -0.04964599385857582, -0.043553903698921204, 0.024379059672355652, -0.03140081837773323, -0.006393829360604286, -0.0010769432410597801, -0.007025947794318199, -0.008853726089000702, 0.02799277752637863, 0.004254298750311136, -0.055408772081136703, 0.03955782204866409, -0.05489744991064072, 0.009669890627264977, -0.029777757823467255, -0.002202461240813136, -0.07249803841114044, -0.0034920587204396725, -0.008536000736057758, 0.010648874565958977, 0.04502483084797859, 0.011720649898052216, 0.00030471061472781, -0.009077050723135471, -0.022548820823431015, 0.056079767644405365, -0.03863740712404251, -0.02126380242407322, -0.02503153868019581, -0.003471581730991602, 0.036314457654953, -0.0196552574634552, -0.04315055161714554, 0.009875371120870113, -0.0016024633077904582, 0.03744473680853844, -0.019447896629571915, -0.03877091035246849, -0.013945252634584904, 0.0063541908748447895, -0.011001546867191792, 0.0016924010124057531, 0.014110504649579525, 0.04668262228369713, -0.01742277853190899, -0.04590998589992523, -0.0510316900908947 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Methodologies When it comes to benchmarking BERT-like models, two metrics are most adopted: * Latency: Time it takes for a single prediction of the model (pre-process, prediction, post-process) * Throughput: Number of executions performed in a fixed amount of time for one benchmark configuration, respecting Physical CPU cores, Sequence Length, and Batch Size These two metrics will be used to benchmark Hugging Face Infinity across different setups to understand the benefits and tradeoffs in this blog post. ---
[ -0.0020248694345355034, -0.0066933403722941875, -0.008609861135482788, -0.051557909697294235, 0.012076068669557571, 0.06685847789049149, 0.03791297227144241, 0.07335936278104782, -0.04810705408453941, -0.03715160861611366, -0.03887910395860672, 0.06453457474708557, 0.02511812373995781, 0.06948501616716385, -0.011765469796955585, 0.00812511332333088, 0.037734419107437134, 0.0006937478319741786, 0.01674652472138405, -0.014644908718764782, -0.01759869046509266, -0.04804797098040581, 0.04745842143893242, 0.002250303979963064, -0.0021757048089057207, -0.05811592563986778, 0.001340364571660757, -0.021161941811442375, -0.0325680747628212, -0.00033147691283375025, -0.08527731895446777, -0.020275281742215157, 0.02062532864511013, -0.024005210027098656, -0.004550501704216003, -0.03594592586159706, -0.10490446537733078, 0.10949860513210297, 0.002044357592239976, -0.04278471693396568, -0.01263023354113102, -0.013819248415529728, -0.01746104098856449, 0.0037174015305936337, -0.02072812430560589, 0.006077700760215521, -0.08291634172201157, 0.049186594784259796, 0.021520406007766724, 0.0047742584720253944, -0.07722815126180649, 0.13011585175991058, -0.005533948540687561, 0.05199806019663811, 0.012746497057378292, 0.017105771228671074, 0.00935988500714302, -0.059954166412353516, -0.022825881838798523, 0.034944966435432434, 0.0537022203207016, -0.03351818025112152, 0.009455956518650055, 0.0024702695664018393, 0.002437681658193469, 0.03786829486489296, -0.010871676728129387, 0.03547748178243637, -0.04941544681787491, 0.0009280332014895976, -0.02217957191169262, 0.006741287186741829, 0.011936689727008343, 0.012501776218414307, 0.02133488468825817, 0.0076927137561142445, 0.038332246243953705, 0.016169168055057526, 0.04964021220803261, 0.09730476140975952, -0.02377207577228546, -0.007456784602254629, -0.01875697262585163, 0.03237606957554817, 0.016178032383322716, 0.05554511770606041, 0.08616087585687637, -0.03650788962841034, -0.09159940481185913, 0.06805524230003357, 0.010464504361152649, -0.1305575668811798, 0.028913967311382294, -0.0039049701299518347, 0.05315103381872177, -0.03370082750916481, 0.015734704211354256, 0.0366184301674366, -0.0676141306757927, 0.024967743083834648, 0.00655437633395195, -0.07725449651479721, 0.019646460190415382, 0.00015893160889390856, -0.07071241736412048, 0.013680931180715561, -0.01656709611415863, -0.11760693043470383, -0.03813355788588524, 0.02654961124062538, -0.019902199506759644, -0.014666156843304634, 0.025729523971676826, 0.09969445317983627, -0.10541270673274994, 0.038255348801612854, -0.07094033807516098, 0.016302499920129776, 0.017948592081665993, 0.02039317600429058, 0.016894564032554626, 0.018803026527166367, 0.040455885231494904, -0.08803841471672058, -0.0029505121055990458, 0.07142315804958344, 0.0457821860909462, 0.013362564146518707, 0.030227426439523697, -0.0015889094211161137, 0.0468204990029335, -0.07230675220489502, 0.05890098214149475, 0.013696778565645218, -0.010356923565268517, -0.04655110090970993, -0.00548936240375042, -0.0591917522251606, 0.017664026468992233, 0.0033083041198551655, -0.02756141498684883, 0.01398446038365364, 0.015159429982304573, -0.005068913102149963, 0.06809680163860321, -0.06874193996191025, -0.055614620447158813, 0.03903071582317352, -0.020047949627041817, -0.016536589711904526, -0.14300155639648438, 0.02708345279097557, -0.06326594948768616, -0.02401694469153881, 0.028105825185775757, 0.07034539431333542, -0.021825557574629784, -0.05001450330018997, -0.0553424246609211, -0.033450085669755936, -0.029879549518227577, 0.00043184016249142587, -0.048855189234018326, -0.036372363567352295, 0.06515901535749435, -0.04620977118611336, 0.03156285360455513, 0.000986287952400744, -0.042741771787405014, 0.01000176277011633, 0.01265773642808199, 0.05075463280081749, 0.09184423834085464, -0.056261397898197174, -0.019176915287971497, 0.019938426092267036, 0.04647495597600937, 0.07584375143051147, -0.020851632580161095, 0.014123713597655296, -0.0026099015958607197, 0.0570250041782856, 0.05761030316352844, 0.06501993536949158, 0.0671406164765358, -0.083406962454319, -0.010224509984254837, -0.010029738768935204, -0.01402476616203785, 0.02097127214074135, -0.03385161980986595, -0.02738199755549431, 0.0823860689997673, -0.07188814878463745, -0.014552080072462559, -0.04304482787847519, -0.0032841155771166086, 0.09399155527353287, 0.025420740246772766, 0.00661812536418438, 0.05163843557238579, 0.013902952894568443, 0.04862307384610176, -0.04497022181749344, -0.04100562632083893, 0.005240580998361111, -0.0013055338058620691, -0.03404819592833519, -0.008538180030882359, -0.02783307060599327, 0.03388213366270065, -0.0961022898554802, -0.03943276405334473, -0.0333012193441391, -0.02303777076303959, -0.045774172991514206, 0.02430129051208496, -0.00005594938193098642, 0.004014084115624428, -0.02907118760049343, 0.18291258811950684, -0.06740842014551163, 0.026213424280285835, -0.007977887988090515, -0.00934626441448927, 0.0003796038217842579, 0.02135283686220646, 0.0650409534573555, 0.10015369206666946, -0.02608029730618, -0.011079085059463978, -0.09715094417333603, 0.01659422367811203, 0.08265335112810135, -0.02812282368540764, -0.03871928155422211, -0.020009076222777367, -0.005793667398393154, 0.027914246544241905, -0.050891924649477005, -0.06824375689029694, -0.03524482622742653, 0.08045681565999985, 0.09501978009939194, 0.0024297961499542, -0.023316675797104836, 0.0012301469687372446, -0.01662244275212288, -0.051511235535144806, 0.030645888298749924, -0.05036971718072891, -0.014389055781066418, 0.03017386421561241, -0.06194606423377991, 0.05074924975633621, 0.030488930642604828, -0.024396318942308426, -0.0012119699968025088, -0.03798140957951546, 0.05165977403521538, 0.025700882077217102, -0.025231609120965004, -0.001979217864573002, -0.016837619245052338, 0.016526231542229652, -0.04648162052035332, -0.010028949938714504, -0.019730834290385246, -0.01831905171275139, 0.006557843182235956, 0.038970522582530975, 0.023605920374393463, 0.028822066262364388, 0.0002938057004939765, -0.014407780021429062, 0.010394267737865448, 0.03282935544848442, -0.021404128521680832, -0.018762974068522453, -0.00016363135364372283, -0.021914690732955933, -0.054166603833436966, 0.030862441286444664, -0.0022946903482079506, 0.013485439121723175, -0.021136945113539696, 0.010346464812755585, -0.0528939925134182, -0.06328333914279938, -0.005915566813200712, 0.019260359928011894, 0.01586906425654888, -0.040182482451200485, -0.01723572239279747, 0.004088487941771746, 0.018078813329339027, 0.03412391617894173, -0.04926437884569168, 0.006384539417922497, -0.0006404489977285266, -0.037203676998615265, 0.02323976159095764, -0.03537731245160103, -0.009667576290667057, -0.026285316795110703, 0.014718107879161835, 0.023857008665800095, 0.03239201754331589, -0.09406930953264236, -0.030153756961226463, 0.016246020793914795, 0.0463462769985199, -0.056144725531339645, -0.05751735344529152, 0.060560572892427444, -0.011631322093307972, 0.005221684463322163, 0.039147019386291504, 0.02470029890537262, -0.019544977694749832, 0.018623406067490578, 0.014215094037353992, -0.01875961944460869, -0.017180968075990677, -0.01942451484501362, -0.0017585977911949158, -0.015983082354068756, 0.030942896381020546, 0.005418973974883556, -0.01585719920694828, 0.015520544722676277, -0.016431620344519615, -0.006376269273459911, 0.036401696503162384, 0.0005997614935040474, -0.0019324746681377292, 0.04501180350780487, -0.0094274478033185, -0.01253824308514595, -0.01978287845849991, -0.058580368757247925, -0.007763031404465437, -0.01603519730269909, -0.024037279188632965, 0.0008811604930087924, 0.04485907405614853, 0.056689612567424774, 0.042712174355983734, 0.012719984166324139, -0.01049206405878067, 0.009616849943995476, 0.0058096772991120815, 0.01607331819832325, 0.0028507644310593605, 0.019224068149924278, -0.021418794989585876, 0.008566588163375854, -0.03644990921020508, -0.04453343525528908, 0.004068839363753796, -0.026542093604803085, 0.04065506160259247, 0.03308882564306259, -0.0067611620761454105, -0.03889557719230652, 0.021322987973690033, 0.004265259951353073, -0.01630086451768875, -0.03809763863682747, 0.025600090622901917, -0.002672281814739108, -0.04221987724304199, -0.03895596042275429, 0.013934439048171043, -0.0056150187738239765, -0.007682419382035732, -0.006879119668155909, 0.01513943076133728, 0.017674559727311134, 0.025718586519360542, -0.022363891825079918, 0.012110627256333828, -0.03335815295577049, 0.0013494755839928985, -0.024020258337259293, -0.03921779617667198, 0.05133574828505516, 0.015162675641477108, -0.04555349424481392, -0.01087174005806446, -0.016386600211262703, -0.0191105417907238, 0.01875276304781437, 0.0031629735603928566, 0.03067985363304615, -0.010315093211829662, 0.009584752842783928, 0.053841833025217056, 0.025826770812273026, -0.025320295244455338, -0.005214244592934847, -0.017628246918320656, -0.011014788411557674, -0.06860393285751343, 0.041675981134176254, -0.009711786173284054, -0.01835310086607933, 0.04306446388363838, 0.009228010661900043, -0.03891126066446304, 0.018360959365963936, 0.01461411640048027, 0.04032700136303902, 0.0631864070892334, -0.014498078264296055, -0.02111153118312359, 0.034342531114816666, 0.002943238476291299, 0.01380737591534853, 0.007363943848758936, 0.0015820786356925964, -0.0047990563325583935, 0.06031370162963867, 0.010643882676959038, -0.010744180530309677, -0.005852232687175274, -0.004467510152608156, 0.04814564064145088, -0.004899193532764912, 0.04380270838737488, -0.012275735847651958, 0.029018836095929146, 0.06515104323625565, -0.007442194502800703, 0.010172138921916485, 0.024985194206237793, 0.010634495876729488, -0.050420258194208145, -0.037391964346170425, 0.005383167415857315, 0.04221304878592491, 0.03303895145654678, -0.0092684431001544, 0.01966032199561596, -0.02665906585752964, -0.018992431461811066, -0.00711356895044446, -0.04357492923736572, 0.023921160027384758, 0.02838195487856865, 0.013436521403491497, -0.01773146353662014, 0.01380727905780077, 0.03728046268224716, -0.03608814626932144, -0.020444132387638092, -0.01631206087768078, 0.03453076630830765, 0.037710946053266525, -0.003604591591283679, -0.04991837963461876, -0.0013744481839239597, 0.031124049797654152, -0.018671080470085144, -0.006384097971022129, 0.012967989780008793, 0.016501115635037422, 0.029267122969031334, -0.001961590489372611, -0.028203634545207024, -0.021039580926299095, -0.015480881556868553, -0.0009906376944854856, -0.014644665643572807, -0.016528461128473282, -0.002952500944957137, 0.03844838589429855, -0.01242296863347292, 0.0006292732432484627, 0.0017478622030466795, 0.007322320248931646, -0.028224658221006393, 0.028691226616501808, 0.05309081822633743, 0.009725715965032578, -0.013524208217859268, 0.005335075315088034, 0.03471885249018669, -0.02930987812578678, -0.02379847690463066, 0.031293176114559174, -0.003939895890653133, 0.0262079369276762, 0.023416440933942795, 0.06035362929105759, 0.05784284695982933, -0.006103342864662409, 0.0495879128575325, 0.050257958471775055, 0.01592562533915043, 0.00475906440988183, -0.04760143533349037, -0.016783704981207848, 0.004211429040879011, 0.010125909931957722, -0.01121773011982441, -0.013395511545240879, 0.00783549528568983, 0.011378545314073563, 0.023392172530293465, -0.022491276264190674, 0.015220972709357738, 0.052509672939777374, -0.023134641349315643, -0.015047064982354641, -0.05823168158531189, 0.032823335379362106, -0.00907215103507042, -0.020862028002738953, 0.014538614079356194, -0.04839150235056877, 0.04668160155415535, 0.005768091883510351, -0.033545371145009995, -0.011247205547988415, 0.032278575003147125, 0.02136719785630703, 0.03934285789728165, -0.00391137320548296, -0.011030211113393307, -0.05975189805030823, -0.03101315163075924, -0.03047417849302292, -0.021051257848739624, -0.009858752600848675, -0.04734833538532257, -0.013203761540353298, 0.021896131336688995, 0.003935493528842926, -0.019229955971240997, -0.016801968216896057, 0.028156805783510208, 0.009313796646893024, 0.007791165262460709, 0.015339464880526066, 0.04572311043739319, 0.051997970789670944, -0.04138384386897087, -0.018665852025151253, 0.029772179201245308, -0.023232722654938698, 0.013657210394740105, -0.04393122345209122, -0.005982486065477133, 0.08261042088270187, -0.011514687910676003, -0.002718317089602351, 0.032135382294654846, -0.004517947323620319, 0.009775691665709019, -0.003485922934487462, 0.007786791771650314, -0.0010974095202982426, 0.011858762241899967, 0.017000077292323112, 0.024781091138720512, -0.010297179222106934, 0.045794468373060226, 0.04622327908873558, -0.0543956495821476, 0.006641215644776821, 0.02464352548122406, -0.05060447007417679, 0.05319308862090111, -0.017361734062433243, -0.04086735099554062, 0.027255350723862648, 0.05423637852072716, -0.002977333264425397, 0.022327667102217674, 0.03197894245386124, 0.009492354467511177, -0.0037362624425441027, -0.01991739682853222, 0.023184847086668015, 0.05591047927737236, 0.0016919748159125447, 0.037362419068813324, 0.026158472523093224, 0.057137418538331985, 0.05682289972901344, 0.019814444705843925, -0.00904056429862976, 0.019267788156867027, 0.07801161706447601, -0.008330331183969975, 0.039977263659238815, 0.041842248290777206, -0.030499687418341637, 0.00043658495997078717, 0.004397690761834383, -0.045118097215890884, -0.034443449229002, -0.0076102628372609615, -0.002340331207960844, -0.03037797287106514, -0.00047635193914175034, -0.012204591184854507, 0.017153432592749596, -0.004615748301148415, 0.009417707100510597, -0.025308897718787193, 0.011487406678497791, 0.022674763575196266, 0.015440593473613262, -0.029790258035063744, 0.014080229215323925, 0.01636459119617939, -0.02228921465575695, 0.07560641318559647, 0.023151710629463196, 0.026580553501844406, -0.009133793413639069, -0.021761197596788406, 0.008879797533154488, -0.009366486221551895, -0.01733856461942196, -0.0069135562516748905, 0.025974148884415627, 0.008259222842752934, 0.007718045264482498, 0.013609948568046093, -0.016428735107183456, 0.021611083298921585, -0.02210695669054985, -0.0031555709429085255, -0.009053390473127365, 0.0012390665942803025, 0.013093016110360622, 0.0632975697517395, -0.0037674717605113983, -0.030121657997369766, 0.019428526982665062, -0.006423126440495253, -0.005560299381613731, 0.047948285937309265, -0.061147041618824005, -0.024326171725988388, 0.009702790528535843, 0.014529725536704063, -0.015304479748010635, 0.009433563798666, -0.003654031315818429, 0.029323287308216095, 0.023575376719236374, 0.011992712505161762, 0.0050453199073672295, 0.015246594324707985, 0.012414987199008465, 0.012878418900072575, -0.03170529752969742, 0.005838748533278704, -0.0000644045285298489, -0.04852301999926567, 0.05226462334394455, -0.011485697701573372, 0.0009123669005930424, -0.005182357504963875, 0.054450418800115585, 0.006258381064981222, 0.031065309420228004, -0.019615434110164642, 0.04115297272801399, -0.04524817317724228, -0.013001774437725544, -0.03907249867916107, 0.033844660967588425, 0.014623752795159817, -0.028787950053811073, 0.04495643451809883, -0.030247924849390984, 0.00120821304153651, -0.04074472934007645, 0.026454748585820198, 0.030329955741763115, -0.019657906144857407, -0.029458390548825264, -0.04177752137184143, 0.011032543145120144, 0.01978113129734993, 0.006552692037075758, 0.07671403139829636, 0.00025030062533915043, 0.03893691673874855, -0.041455864906311035, 0.060480594635009766, -0.028779566287994385, 0.003099096706137061, -0.04318710416555405, 0.017138106748461723, -0.04706788808107376, 0.011269209906458855, 0.0058500696904957294, 0.013494693674147129, -0.04063884913921356, 0.0019298342522233725, -0.021383102983236313, -0.020800191909074783, 0.007880385965108871, 0.0032414207234978676, 0.06444214284420013, 0.034502334892749786, 0.03491532802581787, 0.02279703877866268, -0.03721322864294052, 0.005797979887574911, -0.045552439987659454, 0.021061770617961884, 0.04554916173219681, 0.018734769895672798, -0.002540102694183588, -0.0302847009152174, -0.028463318943977356, 0.0026943236589431763, -0.02729317732155323, 0.02061045914888382, 0.030678831040859222, -0.03861983120441437, 0.02685612253844738, -0.013310249894857407, 0.002094641327857971, -0.010351256467401981, 0.07006789743900299, 0.006426781881600618, -0.023874420672655106, -0.02701578475534916, -0.0043022907339036465, -0.03908033296465874, -0.03415169194340706, 0.02495943382382393, -0.025145480409264565, 0.05405293405056, -0.007618839852511883, 0.025897471234202385, -0.014849300496280193, -0.0020478705409914255, 0.016481848433613777, -0.011044816114008427, -0.05252057686448097, -0.058904778212308884, 0.008433600887656212, -0.0052536241710186005, -0.03824086859822273, -0.04190622642636299, 0.0164851825684309, -0.006952026858925819, 0.007055818103253841, -0.007567008025944233, -0.02099534682929516, -0.02759477123618126, -0.0312536396086216, 0.016305793076753616, -0.014982516877353191, 0.014900785870850086, 0.00000213670136872679, 0.02224525809288025, 0.016833746805787086, -0.0018169680843129754 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Latency Below, you can find the latency results for an experiment running Hugging Face Infinity on 2 Physical Cores with Batch Size 1. It is remarkable to see how robust and constant Infinity is, with minimal deviation for p95, p99, or p100 (max latency). This result is confirmed for other experiments as well in the benchmark. Figure 4. Latency (Batch=1, Physical Cores=2) ---
[ 0.016200929880142212, -0.05635388568043709, 0.011464126408100128, -0.06178310886025429, -0.01884119026362896, 0.0019428847590461373, 0.01410437561571598, 0.06143883243203163, -0.06408940255641937, -0.08302398025989532, -0.012395772151648998, 0.017824478447437286, 0.014922385104000568, -0.0010268543846905231, -0.0353948138654232, 0.005993720144033432, 0.005113877821713686, -0.0020599099807441235, -0.007649561855942011, 0.012230527587234974, 0.022710619494318962, 0.004574311897158623, 0.05708402767777443, 0.040965087711811066, -0.06304876506328583, -0.03648810461163521, 0.012777408584952354, 0.011153050698339939, -0.018667146563529968, -0.02735278755426407, -0.12466663122177124, -0.06273793429136276, 0.06319966167211533, 0.02613515965640545, 0.052639298141002655, -0.029614027589559555, -0.13393956422805786, 0.11363700777292252, 0.011667062528431416, -0.0008667811052873731, 0.00837999302893877, 0.02395702712237835, -0.04758479818701744, -0.030370477586984634, -0.01766463927924633, 0.04238515347242355, -0.044959694147109985, 0.07461640238761902, -0.016999542713165283, -0.029850345104932785, -0.06696582585573196, 0.060919854789972305, 0.022149251773953438, 0.042743466794490814, 0.03291000798344612, 0.007369986269623041, -0.04215994104743004, 0.019601168110966682, 0.024110304191708565, -0.01176388282328844, 0.051861464977264404, -0.06112933158874512, 0.004693755879998207, -0.033759307116270065, -0.06957938522100449, 0.0896887257695198, -0.009144906885921955, -0.0006243529496714473, -0.07482574135065079, -0.05023562163114548, 0.028631029650568962, 0.014099766500294209, 0.01972860097885132, -0.05360377952456474, -0.038103289902210236, 0.02860143594443798, -0.01171947829425335, 0.022737696766853333, 0.019124500453472137, 0.09126899391412735, -0.02821638621389866, -0.06469090282917023, 0.0312630832195282, 0.060763921588659286, -0.0013156115310266614, 0.06617752462625504, -0.016700947657227516, -0.018522800877690315, -0.07277077436447144, 0.05691634863615036, 0.042272839695215225, -0.07110948860645294, 0.06352142244577408, -0.008899936452507973, -0.00865424145013094, -0.04016854986548424, -0.018259195610880852, -0.0031101000495254993, -0.040507618337869644, 0.04829048365354538, -0.00545437540858984, -0.05651235952973366, -0.01464279554784298, -0.013665981590747833, -0.024014176800847054, 0.014907159842550755, -0.0318022295832634, -0.0854092463850975, -0.04628879204392433, 0.019441254436969757, -0.07641194015741348, 0.006292296573519707, 0.03524498641490936, 0.06596322357654572, -0.16976629197597504, 0.053683169186115265, -0.07373150438070297, 0.010696867480874062, 0.012953553348779678, -0.04418162256479263, -0.00467223534360528, 0.05480584874749184, 0.014145094901323318, -0.07783877104520798, -0.01302696205675602, 0.06770536303520203, 0.01587725058197975, -0.01015750877559185, 0.01737113483250141, 0.03461317718029022, 0.0050647365860641, -0.02151847817003727, 0.07640013843774796, -0.00242730975151062, 0.0009619402117095888, -0.06778401881456375, 0.034055545926094055, -0.011359627358615398, -0.005720224697142839, 0.004347662441432476, -0.004404806531965733, 0.0022407781798392534, 0.06089544668793678, -0.005533132702112198, 0.05916548892855644, -0.03893657401204109, -0.07482627779245377, 0.020217975601553917, -0.03662709891796112, -0.04897681996226311, -0.08395153284072876, 0.06746811419725418, -0.0263568963855505, -0.054285794496536255, -0.005033306777477264, 0.020347723737359047, 0.029731180518865585, -0.024895159527659416, -0.06289482861757278, -0.04368719458580017, -0.03868652880191803, -0.030150650069117546, -0.07381080090999603, -0.019067011773586273, 0.08166692405939102, 0.06690461933612823, 0.049366336315870285, 0.013106316328048706, -0.06815047562122345, -0.0018937850836664438, 0.025390032678842545, 0.02270827814936638, 0.07996279746294022, -0.03777763620018959, -0.04734721779823303, -0.013281124643981457, 0.009946665726602077, 0.10677389800548553, 0.019803745672106743, 0.002414037473499775, -0.008680138736963272, 0.007395917549729347, 0.03787008672952652, 0.034827038645744324, 0.00394244072958827, -0.07984080165624619, 0.018486855551600456, 0.018883131444454193, -0.04023400694131851, 0.03700415790081024, -0.020339764654636383, 0.00686152558773756, 0.06508475542068481, -0.06742670387029648, 0.0326986238360405, -0.034152060747146606, -0.01860903389751911, 0.05830882117152214, 0.022373078390955925, 0.03360231593251228, -0.00344257359392941, 0.033406734466552734, 0.08910007774829865, -0.007093240041285753, -0.04439195990562439, 0.02564169466495514, 0.0018157949671149254, -0.007209083531051874, -0.036585818976163864, -0.014755863696336746, 0.016871033236384392, -0.09497399628162384, -0.07362257689237595, 0.004624801687896252, -0.015043316408991814, -0.005092144012451172, 0.019303958863019943, 0.013438040390610695, 0.03626929223537445, -0.021229179576039314, 0.1523357331752777, -0.008936178870499134, 0.06527800858020782, -0.048548050224781036, -0.03567173331975937, 0.026432249695062637, 0.0300742294639349, 0.03202993795275688, -0.026751650497317314, -0.04718319699168205, -0.018746869638562202, -0.04462982341647148, -0.033994730561971664, 0.08123544603586197, 0.035781484097242355, -0.04885852709412575, -0.04507741704583168, 0.01534444373100996, 0.022008150815963745, -0.04510479047894478, -0.06450100988149643, -0.013383657671511173, 0.03600392863154411, 0.07274221628904343, -0.0204421728849411, -0.026551654562354088, 0.007465321104973555, -0.02158268727362156, -0.06842757761478424, -0.005148860160261393, -0.06037177890539169, -0.039603520184755325, -0.0003605983220040798, -0.036203041672706604, 0.053592246025800705, -0.024358654394745827, -0.023122498765587807, 0.010161487385630608, -0.05662207305431366, 0.021518012508749962, 0.05235433205962181, -0.009968346916139126, 0.02176332287490368, 0.00722585991024971, 0.005626414902508259, 0.002013762015849352, 0.012071855366230011, 0.001931558595970273, -0.012764512561261654, 0.004276985302567482, 0.0678555816411972, 0.034655164927244186, -0.005156693514436483, -0.028196923434734344, -0.0015318823279812932, 0.003547888481989503, 0.026940368115901947, -0.004689708352088928, -0.016629574820399284, 0.0055790976621210575, 0.037289950996637344, -0.03145924210548401, 0.03025348298251629, -0.0008891857578419149, 0.0021450535859912634, -0.012876116670668125, 0.003372735809534788, -0.031020214781165123, -0.07990554720163345, -0.011035501025617123, 0.030373038724064827, 0.011123222298920155, -0.014853197149932384, -0.03279154375195503, 0.055296242237091064, 0.008865409530699253, 0.019601723179221153, -0.03710321709513664, -0.03713282570242882, 0.00514594791457057, -0.02672526426613331, 0.009312430396676064, -0.040069133043289185, 0.018891112878918648, -0.018406547605991364, -0.014353162609040737, 0.035929057747125626, 0.0744943767786026, -0.08564189821481705, -0.020649828016757965, -0.013894003815948963, 0.03781057149171829, -0.0520976185798645, -0.024288460612297058, 0.01351361908018589, -0.004857244901359081, 0.013267717324197292, 0.014365613460540771, 0.002472044201567769, -0.023720528930425644, -0.014235866256058216, 0.011110016144812107, 0.018670611083507538, 0.004284024704247713, 0.027834231033921242, 0.01979374885559082, -0.0014167440822347999, -0.0011902377009391785, 0.019618401303887367, -0.0020781615749001503, 0.03287810459733009, -0.018068809062242508, -0.023679902777075768, 0.04851985350251198, -0.009181643836200237, -0.007333884947001934, 0.06284767389297485, -0.03285841643810272, -0.013191302306950092, -0.006889134179800749, -0.014677182771265507, 0.014836951158940792, -0.000016643045455566607, -0.04265304654836655, 0.0004441046330612153, -0.01622139662504196, 0.03648762032389641, 0.019686764106154442, 0.01447016466408968, 0.004010010045021772, 0.043938472867012024, -0.04449308663606644, 0.006265643984079361, 0.025157716125249863, -0.014980192296206951, -0.03024088405072689, 0.0623520165681839, -0.05349034443497658, -0.0302505474537611, 0.04630497470498085, -0.0012970063835382462, 0.06760011613368988, -0.010343525558710098, 0.0476420596241951, -0.04655129089951515, 0.015250607393682003, 0.028630901128053665, -0.03899150341749191, -0.04410339891910553, -0.01604311168193817, -0.028373409062623978, 0.002220984548330307, -0.019435929134488106, 0.03344808518886566, -0.027279559522867203, -0.02534198760986328, 0.010232812725007534, -0.02690567821264267, 0.016247007995843887, 0.003638225607573986, 0.0006160557386465371, 0.010988602414727211, -0.02102656103670597, 0.02530800551176071, -0.030507585033774376, -0.04633239284157753, 0.03205615654587746, 0.022052470594644547, -0.018627841025590897, 0.025775810703635216, 0.004320680163800716, 0.011853117495775223, -0.0015988834202289581, 0.024015625938773155, 0.04538271576166153, -0.0156510379165411, 0.0015174925792962313, 0.042748115956783295, 0.011081196367740631, -0.0068090311251580715, 0.0038389437831938267, -0.04975906386971474, -0.026722455397248268, -0.043564021587371826, 0.023166414350271225, -0.001321145100519061, 0.016077788546681404, 0.024843521416187286, -0.016902927309274673, 0.007068335078656673, -0.016757460311055183, -0.039110276848077774, 0.020644331350922585, 0.05390212684869766, -0.014201999641954899, 0.008240306749939919, 0.002641149330884218, 0.0022101113572716713, 0.01697906106710434, -0.030950767919421196, 0.0340152382850647, -0.02023475617170334, 0.05878598988056183, 0.004195870831608772, -0.0007388368248939514, -0.015287145040929317, -0.01411354634910822, 0.021048584952950478, -0.02407807670533657, 0.01130143366754055, 0.004552253056317568, 0.004682986531406641, 0.04320687800645828, 0.0025422093458473682, 0.011563681997358799, 0.012399228289723396, 0.001029553241096437, -0.011421695351600647, -0.025182796642184258, 0.012958222068846226, 0.011802399531006813, 0.019877858459949493, 0.026337390765547752, -0.028040019795298576, -0.021056899800896645, 0.009015996009111404, -0.015401887707412243, -0.05833929777145386, 0.015158549882471561, 0.0015721763484179974, 0.03465236723423004, -0.0072108241729438305, 0.006936497054994106, 0.06352721899747849, -0.007840568199753761, 0.023621276021003723, 0.0018021941650658846, 0.02455957606434822, 0.06338880956172943, -0.04293462634086609, -0.04292648285627365, 0.0005172546952962875, 0.031765103340148926, -0.026833001524209976, -0.027910791337490082, 0.013255571946501732, 0.012628014199435711, 0.06762364506721497, -0.01010389719158411, -0.01527743972837925, -0.015966814011335373, -0.003280042437836528, -0.0013744061579927802, -0.01964283175766468, -0.04166246950626373, -0.00039291969733312726, 0.0003584286605473608, 0.007773337885737419, -0.0036595293786376715, -0.04522274062037468, -0.002503077732399106, 0.00705068139359355, 0.02929845079779625, 0.06340666860342026, 0.006853591650724411, -0.05786759406328201, 0.030498849228024483, 0.049670085310935974, -0.011392028070986271, -0.0077206711284816265, 0.07754095643758774, -0.03748606517910957, 0.012349491007626057, 0.017740746960043907, 0.07377616316080093, 0.08070003986358643, -0.003853016998618841, 0.014832230284810066, 0.06292638927698135, -0.024599257856607437, 0.0380648709833622, -0.04129776358604431, 0.013307682238519192, -0.007711939513683319, 0.012744653038680553, 0.01002239715307951, -0.0077980938367545605, -0.015225301496684551, 0.019093548879027367, 0.029263582080602646, -0.0063895597122609615, 0.001060127280652523, 0.055301278829574585, 0.023450030013918877, 0.019224246963858604, 0.005938313435763121, 0.031717754900455475, -0.030552394688129425, -0.022373396903276443, 0.018158406019210815, -0.06738416105508804, -0.005053704138845205, 0.0346638560295105, -0.013445216231048107, -0.04015759378671646, 0.057264748960733414, 0.03994280844926834, 0.049644213169813156, -0.00965038314461708, 0.010658122599124908, -0.03454422578215599, -0.046792905777692795, -0.010335410945117474, 0.0045149545185267925, 0.014596954919397831, -0.029467811807990074, -0.0007332977256737649, 0.009875524789094925, 0.01304567325860262, -0.00624080142006278, -0.0263602826744318, -0.04214593768119812, 0.03167205676436424, 0.026492290198802948, 0.02740650437772274, 0.0506676509976387, 0.06117163226008415, -0.033806007355451584, -0.020209478214383125, -0.008409582078456879, 0.0321856327354908, -0.012175924144685268, -0.04441181942820549, 0.0066887433640658855, 0.09232442826032639, 0.02571067400276661, -0.023176584392786026, 0.005791897419840097, 0.0019965963438153267, 0.006984296254813671, -0.05007799714803696, 0.015387126244604588, -0.002115539275109768, 0.04313095286488533, 0.015932291746139526, -0.01320735365152359, 0.023085927590727806, 0.03098224103450775, 0.021038129925727844, -0.054662879556417465, 0.052664682269096375, -0.0029261475428938866, 0.001295365858823061, 0.03634854406118393, -0.01932113617658615, -0.018216021358966827, 0.018511103466153145, 0.036001767963171005, 0.03944087401032448, 0.000103258658782579, 0.004572286270558834, 0.026100721210241318, -0.037208572030067444, 0.024900110438466072, 0.009620538912713528, 0.0645245686173439, 0.007946672849357128, -0.0021059676073491573, 0.044709187000989914, 0.021827924996614456, 0.07464592903852463, 0.040987174957990646, -0.026045408099889755, -0.019773036241531372, 0.028625598177313805, -0.018278170377016068, 0.024515576660633087, 0.051681794226169586, -0.02599439211189747, 0.022205986082553864, -0.027276549488306046, -0.06772049516439438, 0.009251677431166172, -0.002657421864569187, -0.007938467897474766, -0.014647905714809895, -0.02058495581150055, -0.04327606409788132, 0.018203722313046455, 0.0027400848921388388, 0.02482137642800808, -0.010641876608133316, 0.019016535952687263, -0.0023419647477567196, 0.003536900505423546, -0.030828841030597687, 0.019830506294965744, -0.003307787701487541, 0.0018020328134298325, 0.016537118703126907, 0.009650972671806812, 0.013728173449635506, -0.0413828119635582, 0.007237269543111324, -0.0033098591957241297, -0.029292546212673187, -0.03556661680340767, -0.0020139801781624556, 0.00928142387419939, 0.03262465447187424, 0.0344250425696373, -0.010411659255623817, -0.004252907820045948, 0.03239652141928673, -0.050436101853847504, -0.01330731250345707, 0.031028132885694504, 0.017113229259848595, 0.01707947999238968, 0.026027575135231018, 0.007481730077415705, 0.0061114937998354435, 0.06795381754636765, -0.01399447675794363, 0.014698537066578865, 0.05820280313491821, -0.06445270776748657, 0.015580917708575726, 0.025500737130641937, 0.05249479413032532, 0.04561749845743179, 0.03768289089202881, -0.014995424076914787, 0.014748805202543736, 0.03279329836368561, 0.02852393314242363, 0.02546490915119648, 0.00250871479511261, 0.0242459736764431, 0.011483900249004364, -0.07330729067325592, 0.045537568628787994, 0.01529872789978981, -0.011139491572976112, 0.06161011382937431, -0.0019041341729462147, -0.004303340800106525, -0.017196180298924446, 0.07257740944623947, 0.02010367438197136, 0.022597072646021843, 0.019075389951467514, 0.007518526166677475, -0.029707180336117744, -0.06337078660726547, -0.026533719152212143, 0.007303877733647823, -0.0233670212328434, -0.07099740952253342, 0.028202015906572342, 0.02418762631714344, 0.004575558006763458, -0.03115285001695156, 0.021533366292715073, 0.005746258422732353, 0.010919525288045406, 0.0021180782932788134, -0.026785386726260185, -0.008853413164615631, 0.02483866922557354, 0.025831161066889763, 0.04583464562892914, 0.0005792874726466835, 0.05046090483665466, -0.042473528534173965, 0.021767225116491318, -0.038862187415361404, 0.004013788420706987, -0.013152956031262875, 0.023040521889925003, -0.01979600451886654, -0.02547542192041874, -0.03500940650701523, -0.01584339514374733, -0.01909184455871582, 0.006891987752169371, 0.008491364307701588, -0.0429813526570797, 0.02866661362349987, 0.003483298234641552, 0.026867114007472992, 0.06040874868631363, 0.018744822591543198, 0.041510794311761856, -0.038077402859926224, 0.0073644062504172325, -0.03820714354515076, 0.01579010672867298, 0.04587861895561218, -0.014238161034882069, -0.029847750440239906, -0.04352470859885216, 0.005453118588775396, 0.012471233494579792, -0.04805396869778633, 0.014504536986351013, -0.009260193444788456, -0.012489594519138336, -0.0008169374195858836, -0.01103740930557251, -0.013870755210518837, 0.01623394526541233, 0.07491710036993027, -0.0010344234760850668, -0.017363611608743668, -0.04671276733279228, -0.003978500608354807, -0.038758277893066406, -0.014906712807714939, 0.04760749638080597, 0.029421737417578697, 0.04577276483178139, 0.015543993562459946, 0.0163901187479496, -0.04457596316933632, -0.02023332007229328, 0.014364786446094513, -0.05822791904211044, -0.07963692396879196, -0.015914371237158775, -0.02201993577182293, -0.010686277411878109, -0.02460118941962719, -0.016137346625328064, 0.019882723689079285, 0.02857976406812668, 0.006677852477878332, 0.009211897850036621, -0.032002370804548264, 0.002811610698699951, -0.0010431834962219, -0.013355211354792118, 0.008185949176549911, -0.00464342487975955, 0.0016024396754801273, 0.004883945919573307, 0.009335452690720558, 0.002285317750647664 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Conclusion In this post, we showed how Hugging Face Infinity performs on the new Intel Ice Lake Xeon CPU. We created a detailed benchmark with over 190 different configurations sharing the results you can expect when using Hugging Face Infinity on CPU, what would be the best configuration to optimize your Infinity Container for latency, and what would be the best configuration to maximize throughput. Hugging Face Infinity can deliver up to 800% higher throughput compared to vanilla transformers, and down to 1-4ms latency for sequence lengths up to 64 tokens. The flexibility to optimize transformer models for throughput, latency, or both enables businesses to either reduce the amount of infrastructure cost for the same workload or to enable real-time use cases that were not possible before. If you are interested in trying out Hugging Face Infinity sign up for your trial at hf.co/infinity-trial
[ -0.005118690896779299, -0.03713429719209671, -0.011512166820466518, -0.025804415345191956, -0.02662324160337448, 0.012353993020951748, 0.03577197343111038, 0.09653522074222565, -0.04551471024751663, -0.02147790789604187, -0.00989985279738903, 0.03856191039085388, -0.0054197488352656364, 0.03157513216137886, -0.014096939004957676, -0.012586663477122784, 0.04128213971853256, 0.06316975504159927, 0.015591692179441452, 0.035348158329725266, 0.07007716596126556, -0.043717216700315475, 0.0844913125038147, 0.03491944447159767, -0.053478341549634933, -0.03170230984687805, -0.04127969965338707, -0.02980038896203041, 0.03289034962654114, 0.013183286413550377, -0.10754910111427307, -0.05001620203256607, 0.03202389180660248, -0.0535462461411953, 0.04787931218743324, -0.032563019543886185, -0.14094124734401703, 0.056581560522317886, -0.004890406504273415, 0.03101542964577675, 0.025258703157305717, 0.023714246228337288, -0.05667337030172348, 0.021374700590968132, -0.049384355545043945, 0.026893792673945427, -0.11042172461748123, 0.037170857191085815, -0.021605011075735092, 0.00827174074947834, -0.07058711349964142, 0.0658140629529953, 0.013337813317775726, 0.026757223531603813, 0.05865267664194107, 0.026639090850949287, -0.04328310862183571, -0.018144365400075912, -0.0035322767216712236, 0.03207942843437195, 0.03904231637716293, -0.04112045094370842, -0.020471889525651932, -0.049936361610889435, -0.05253169313073158, 0.006333625875413418, -0.07940277457237244, -0.008978920057415962, -0.0381745807826519, -0.03896407410502434, 0.006053232587873936, 0.030601773411035538, 0.03731229528784752, 0.012463806197047234, 0.002980432938784361, 0.006015871185809374, -0.025509726256132126, 0.028228580951690674, 0.06235023960471153, 0.08474776893854141, 0.0017431604210287333, 0.021193232387304306, 0.026874983683228493, 0.0490591898560524, 0.05282321199774742, 0.02086894027888775, 0.004460545256733894, 0.028970330953598022, -0.125027135014534, 0.06575561314821243, 0.05542777106165886, -0.09295423328876495, 0.05489654466509819, -0.006537204142659903, 0.010103274136781693, 0.0025465551298111677, 0.015008565969765186, 0.07216628640890121, -0.0046374378725886345, 0.038389287889003754, 0.008272157050669193, -0.0624108761548996, -0.0024592617992311716, -0.029771720990538597, -0.03129003196954727, -0.011034298688173294, -0.03888911008834839, -0.11062931269407272, 0.003548780921846628, -0.014525486156344414, -0.04822342097759247, -0.012702369131147861, -0.00013219901302363724, 0.0695769190788269, -0.16537787020206451, 0.04125264286994934, -0.049133364111185074, -0.010020635090768337, 0.022757841274142265, 0.0016359351575374603, 0.050333648920059204, 0.09670606255531311, 0.01773359440267086, -0.036810874938964844, 0.009206458926200867, 0.04414135962724686, -0.008020520210266113, -0.016747979447245598, 0.029565179720520973, -0.03888769820332527, 0.016049951314926147, -0.07002808898687363, 0.07888588309288025, 0.026292776688933372, -0.030633894726634026, -0.06392766535282135, -0.018980219960212708, -0.06779485195875168, 0.004519188776612282, 0.017698166891932487, -0.010160446166992188, -0.002180631272494793, 0.05960291624069214, -0.04056641459465027, 0.09574749320745468, -0.03852105885744095, -0.0711469054222107, 0.05111544579267502, 0.013368487358093262, 0.0036629836540669203, -0.0866318941116333, 0.051245540380477905, -0.09009046852588654, -0.03243231028318405, 0.051298197358846664, 0.035755425691604614, -0.016039986163377762, -0.07257207483053207, -0.0703168660402298, -0.06271225214004517, -0.05849127471446991, -0.006755602080374956, -0.0961800217628479, -0.023801328614354134, 0.03356632962822914, 0.01358271948993206, 0.03192107751965523, 0.004402047023177147, -0.01354612223803997, -0.00509589072316885, 0.04731438681483269, 0.026140762493014336, 0.04745003208518028, -0.024714253842830658, 0.0011717984452843666, -0.012671160511672497, 0.028354665264487267, 0.10451959073543549, 0.02182912826538086, -0.033422667533159256, -0.028723284602165222, 0.04890960454940796, 0.024615801870822906, 0.10107096284627914, 0.02319604530930519, -0.07220648229122162, -0.026876216754317284, 0.02584172412753105, 0.023498577997088432, -0.003679117886349559, 0.009772539138793945, 0.01666427217423916, 0.07132817059755325, -0.036217864602804184, -0.0018734808545559645, -0.021825583651661873, -0.017679015174508095, 0.05001618340611458, 0.05191349610686302, 0.08339470624923706, 0.05155083164572716, 0.007639776915311813, 0.06598269939422607, -0.01842910423874855, -0.10132573544979095, -0.020577270537614822, -0.034409429877996445, -0.04673027619719505, -0.056148212403059006, 0.023611407727003098, 0.016085216775536537, -0.13348400592803955, -0.019935254007577896, 0.002296673832461238, -0.008735350333154202, -0.03869801014661789, -0.009446116164326668, 0.010875075124204159, -0.014143213629722595, -0.02098582312464714, 0.11593692749738693, -0.02395510859787464, 0.022066663950681686, -0.03332774341106415, 0.007596665993332863, -0.011443867348134518, 0.0650649219751358, 0.02275496907532215, 0.02146001346409321, 0.0061011118814349174, -0.0325838066637516, -0.08913671225309372, -0.06608196347951889, 0.01921018399298191, 0.05189965292811394, -0.019080735743045807, 0.04393477365374565, 0.045151881873607635, 0.06261608749628067, 0.02419275976717472, -0.06243610382080078, -0.03735261410474777, -0.01208100188523531, 0.04771708324551582, 0.035848747938871384, 0.013162389397621155, 0.0064681461080908775, -0.04839687794446945, 0.020167985931038857, -0.023087868466973305, -0.047054558992385864, -0.016640961170196533, 0.007005395367741585, -0.039499957114458084, 0.044894538819789886, 0.0004315695259720087, 0.009862499311566353, 0.005233615171164274, -0.023926137015223503, 0.026878012344241142, 0.0374116487801075, -0.013615555129945278, -0.023271391168236732, -0.017729051411151886, 0.01486677024513483, -0.025141850113868713, -0.025571919977664948, -0.02380276285111904, 0.01463240571320057, -0.012423007749021053, 0.00005132049773237668, 0.011067016050219536, 0.010048897005617619, -0.018642602488398552, -0.026883317157626152, 0.00998761411756277, 0.015001703053712845, 0.0010175055358558893, -0.02977806329727173, -0.015577726066112518, 0.040502600371837616, -0.0074707805179059505, 0.004343475680798292, 0.028941988945007324, 0.004466760437935591, -0.01002494990825653, 0.005072048865258694, -0.06753662973642349, -0.09038816392421722, -0.014145390130579472, 0.04565141722559929, 0.0007600089884363115, -0.02666042000055313, -0.020279042422771454, -0.010902686975896358, 0.0200367234647274, 0.024903034791350365, -0.03056083433330059, -0.025227874517440796, 0.022220194339752197, -0.04605025798082352, -0.004201643634587526, -0.00915274303406477, 0.025961831212043762, -0.00048006369615904987, 0.010555010288953781, 0.024170219898223877, 0.01843942701816559, -0.07858874648809433, -0.02490365318953991, -0.04726973548531532, 0.05172668397426605, -0.04406256601214409, -0.042240459471940994, 0.02717876434326172, 0.016933778300881386, 0.03464648872613907, 0.034467607736587524, -0.0001646441378397867, -0.0007759230211377144, 0.01990356855094433, -0.00016077604959718883, -0.014031636528670788, -0.006214559078216553, 0.04819459840655327, -0.011315671727061272, 0.022183453664183617, 0.0005488577880896628, -0.010838297195732594, -0.006835276260972023, 0.01701710745692253, -0.003036257578060031, 0.017876455560326576, -0.008126643486320972, 0.03789538890123367, -0.019863681867718697, 0.029730787500739098, -0.004671843256801367, -0.018051134422421455, 0.01022682897746563, -0.008634679019451141, 0.008673220872879028, -0.020934144034981728, -0.007816802710294724, -0.00945472251623869, -0.0005083685973659158, 0.06021629646420479, 0.03309664875268936, 0.013324453495442867, -0.02309763804078102, 0.060464635491371155, -0.0404551662504673, 0.0460616871714592, -0.00862001534551382, 0.00485164625570178, -0.05326531454920769, 0.029049504548311234, -0.037065207958221436, -0.05212085694074631, 0.024343671277165413, 0.026299579069018364, 0.053417570888996124, -0.0165985357016325, 0.01758636347949505, -0.040215156972408295, 0.010407463647425175, 0.02255222573876381, 0.006156527437269688, -0.05432723090052605, -0.00331098772585392, -0.03690236434340477, 0.017804455012083054, -0.05606018379330635, 0.03728146478533745, -0.0063755810260772705, -0.01640094630420208, 0.0289407167583704, -0.004534958396106958, 0.003972181119024754, 0.03225892409682274, -0.010229433886706829, 0.008195454254746437, -0.00356511608697474, -0.01535376999527216, -0.015025358647108078, 0.01257091760635376, 0.0528276190161705, 0.045954786241054535, -0.05117413401603699, -0.009555410593748093, -0.016621999442577362, -0.007294504437595606, 0.007848958484828472, 0.007371808867901564, -0.005894659552723169, -0.03337989002466202, -0.004337431862950325, 0.028142159804701805, -0.004189444240182638, -0.023008625954389572, 0.006379047874361277, -0.04503323510289192, -0.02322758175432682, -0.03459074720740318, 0.02577226050198078, -0.0038170847110450268, -0.005689340177923441, 0.009332939982414246, 0.010633398778736591, -0.0036523621529340744, 0.03071923367679119, -0.012708311900496483, 0.014229373075067997, 0.025782952085137367, 0.009390353225171566, -0.020028918981552124, 0.00839194469153881, 0.02367079257965088, 0.03957796469330788, -0.03864338621497154, 0.011113557033240795, -0.000600058410782367, 0.06801310181617737, -0.00038113989285193384, 0.014328892342746258, -0.012961843982338905, 0.016568340361118317, 0.01572316698729992, 0.003199398284777999, 0.023363277316093445, -0.02530936896800995, -0.012126210145652294, 0.024279342964291573, 0.0030805019196122885, 0.0109250508248806, 0.03597073629498482, 0.004182703327387571, 0.004198412410914898, -0.03277643397450447, 0.008731476031243801, 0.043208103626966476, 0.04879609867930412, -0.010860725305974483, -0.022629888728260994, -0.019768090918660164, -0.023699965327978134, -0.020764732733368874, -0.05009494349360466, 0.013907878659665585, 0.01623208448290825, 0.048756785690784454, -0.012900058180093765, -0.009329305030405521, 0.06241646036505699, 0.006290190853178501, -0.015479558147490025, 0.014455565251410007, 0.018349220976233482, -0.0010026756208389997, -0.027421392500400543, -0.021963784471154213, 0.03460725396871567, 0.06194118782877922, -0.0016083598602563143, -0.026713939383625984, -0.0033866767771542072, 0.015605168417096138, 0.03056660294532776, 0.0006798866670578718, 0.01674138382077217, -0.021415764465928078, -0.03254874050617218, 0.019965115934610367, -0.007039020303636789, -0.021566571667790413, -0.0005758667830377817, -0.028482746332883835, 0.0021129713859409094, -0.014014200307428837, 0.01753372885286808, 0.002019264502450824, -0.005780404899269342, 0.022047679871320724, 0.0455978624522686, 0.035096507519483566, -0.034022122621536255, 0.02491661161184311, 0.03649601340293884, -0.0004439795739017427, -0.02877962402999401, 0.0202799029648304, -0.008636284619569778, 0.0168294757604599, -0.012774967588484287, 0.07844535261392593, 0.07824520021677017, 0.005118158645927906, -0.007925711572170258, 0.04183153063058853, -0.030957216396927834, -0.003277558833360672, -0.047426920384168625, 0.009305582381784916, -0.03979874774813652, 0.007604701444506645, 0.0285735372453928, -0.0009559851023368537, 0.001827955711632967, 0.0171533040702343, -0.000020331295672804117, -0.004505880642682314, -0.00558322062715888, 0.0026855773758143187, 0.010235299356281757, 0.00006804573786212131, -0.027409177273511887, 0.02775055542588234, -0.024515843018889427, 0.00922388769686222, 0.021527918055653572, -0.027060776948928833, 0.009662951342761517, 0.020077018067240715, -0.02108856476843357, -0.056014787405729294, 0.02306034229695797, 0.046377889811992645, 0.028641795739531517, -0.01888931915163994, -0.0225947517901659, 0.006811102386564016, -0.06188419833779335, -0.03993681073188782, -0.00440198415890336, 0.02879190258681774, -0.022727036848664284, -0.03339824080467224, 0.019907720386981964, 0.04776347801089287, -0.030858676880598068, 0.0006262797978706658, 0.0073257205076515675, 0.0483953133225441, 0.003274179296568036, 0.041272301226854324, 0.016453400254249573, 0.031084975227713585, -0.027546590194106102, -0.008489986881613731, 0.004532348830252886, 0.0044112480245530605, -0.016225455328822136, -0.07546861469745636, 0.03224452957510948, 0.08010972291231155, 0.017762446776032448, -0.04880126193165779, 0.00014992873184382915, -0.005761384032666683, -0.026972968131303787, -0.017822440713644028, -0.00944418553262949, -0.015716347843408585, -0.040574848651885986, -0.009558665566146374, 0.0015371313784271479, 0.03755643591284752, 0.01568537764251232, -0.004911752417683601, -0.05461829528212547, 0.03170856088399887, 0.044104062020778656, -0.004008009098470211, 0.052289415150880814, -0.015204197727143764, -0.025479700416326523, 0.051849886775016785, 0.07079976797103882, 0.003111204132437706, 0.015618426725268364, 0.024862509220838547, -0.01584804244339466, -0.03538399934768677, 0.0017501311376690865, -0.0035363472998142242, 0.09271387755870819, 0.01429075002670288, 0.031051017343997955, 0.021937143057584763, 0.03895346447825432, 0.0412944033741951, 0.010336584411561489, -0.023107726126909256, 0.005098388995975256, 0.021711409091949463, -0.029200227931141853, 0.056658077985048294, 0.023157315328717232, -0.04463985562324524, -0.02028583735227585, -0.002042287727817893, -0.05874650552868843, 0.0013726095203310251, -0.00909155048429966, 0.013572103343904018, -0.005334127228707075, 0.0025859596207737923, -0.04586371034383774, 0.036420851945877075, 0.04441902041435242, -0.015335864387452602, -0.03125607967376709, 0.00616898387670517, 0.02072865329682827, 0.015823425725102425, -0.004671063274145126, -0.00215148669667542, -0.008372241631150246, 0.0057244496420025826, 0.08333753794431686, 0.007474224548786879, 0.05992460995912552, -0.0012347882147878408, 0.02834830805659294, -0.02924208715558052, -0.02343323454260826, -0.010509218089282513, 0.02501530386507511, -0.01017894595861435, -0.013534401543438435, 0.0046227253042161465, 0.032456282526254654, -0.0136363934725523, 0.03799223527312279, -0.044124625623226166, -0.0007957074558362365, -0.028882509097456932, 0.026996467262506485, 0.007674884516745806, 0.025839868932962418, -0.041300829499959946, -0.036106374114751816, 0.026751255616545677, -0.008679309859871864, -0.017909619957208633, -0.003060824703425169, -0.08296996355056763, -0.013744841329753399, 0.020118558779358864, 0.023113219067454338, 0.0075876000337302685, 0.040141910314559937, -0.005685691721737385, 0.008437242358922958, 0.02285727672278881, 0.04777124896645546, 0.017191514372825623, 0.014966868795454502, 0.015033675357699394, 0.02547602169215679, -0.05441480502486229, -0.019978107884526253, 0.004343753680586815, 0.00340275838971138, 0.027994193136692047, -0.02853839471936226, 0.02494223415851593, -0.010183664970099926, 0.043258633464574814, -0.015285901725292206, 0.03980221226811409, -0.012840556912124157, 0.010325897485017776, -0.029689522460103035, -0.05162076652050018, -0.03109140880405903, 0.035748861730098724, -0.023709867149591446, -0.052519384771585464, 0.006188471335917711, 0.020041652023792267, 0.009329604916274548, -0.021594028919935226, 0.014441446401178837, 0.04181364178657532, -0.038489390164613724, -0.03881149739027023, -0.020715031772851944, 0.016402877867221832, 0.030552709475159645, 0.021611981093883514, 0.05008605867624283, 0.009077566675841808, 0.04051344841718674, -0.010575255379080772, 0.054316893219947815, -0.02649950422346592, 0.0019723158329725266, -0.037273209542036057, 0.034316107630729675, -0.018304158002138138, -0.029098771512508392, 0.03107922524213791, 0.026649709790945053, -0.04732099175453186, 0.00563052436336875, -0.03204020857810974, -0.025137772783637047, 0.01733069121837616, -0.010918905027210712, 0.046834398061037064, 0.05905621498823166, 0.036818187683820724, 0.017017008736729622, -0.03915281221270561, -0.029281869530677795, -0.028960619121789932, 0.018054217100143433, 0.0674719586968422, 0.014507891610264778, -0.021345915272831917, -0.053027812391519547, -0.03703279420733452, 0.014851156622171402, -0.042547982186079025, 0.015522703528404236, -0.012104968540370464, -0.014125107787549496, 0.013636737130582333, 0.0063394405879080296, 0.005194910801947117, -0.021665023639798164, 0.08605299890041351, -0.021111339330673218, 0.011540720239281654, -0.017417771741747856, 0.03664770349860191, -0.031508203595876694, -0.03884420543909073, -0.01672283746302128, 0.01810339279472828, 0.03989826515316963, 0.008422313258051872, 0.0008454308845102787, -0.017155727371573448, -0.004883980378508568, 0.06125907972455025, -0.031058045104146004, -0.027275992557406425, -0.021579017862677574, -0.010684722103178501, 0.03765103965997696, -0.0031405771151185036, -0.05245295539498329, 0.018201475962996483, -0.012273216620087624, 0.02756544016301632, -0.008833717554807663, -0.026660706847906113, -0.0027997714933007956, -0.012433094903826714, 0.014917697757482529, 0.005577338859438896, 0.007459320593625307, 0.050186607986688614, -0.009183160029351711, -0.03605077415704727, -0.025478532537817955 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs December 2022 Update: Infinity is no longer offered by Hugging Face as a commercial inference solution. To deploy and accelerate your models, we recommend the following new solutions: * Inference Endpoints to easily deploy models on dedicated infrastructure managed by Hugging Face. * Our open-source optimization libraries, 🤗 Optimum Intel and 🤗 Optimum ONNX Runtime, to get the highest efficiency out of training and running models for inference. * Hugging Face Expert Acceleration Program, a commercial service for Hugging Face experts to work directly with your team to accelerate your Machine Learning roadmap and models.
[ -0.007362101227045059, -0.03675757348537445, 0.03393358364701271, -0.01608291082084179, -0.015232629142701626, 0.03713884949684143, -0.0019130571745336056, 0.07835136353969574, -0.04512627795338631, -0.029459604993462563, -0.05489344894886017, 0.0073600998148322105, -0.02884877286851406, 0.06141160428524017, 0.03491021320223808, -0.07662290334701538, 0.017852267250418663, 0.013600165024399757, -0.06930963695049286, 0.04713895916938782, 0.026593303307890892, -0.05478154495358467, 0.019578751176595688, -0.012220775708556175, -0.10134025663137436, -0.03347086161375046, -0.006820496637374163, -0.023401066660881042, 0.012081483379006386, 0.050224419683218, -0.07671356946229935, -0.02552257850766182, -0.016806693747639656, -0.014893843792378902, 0.05433828756213188, 0.010726917535066605, -0.10659441351890564, 0.07822389900684357, -0.0016268808394670486, 0.027175093069672585, 0.005852933507412672, 0.00010598164953989908, -0.10229310393333435, 0.01879059709608555, -0.006740964017808437, 0.004509510472416878, -0.07163458317518234, 0.021901505067944527, -0.01030710805207491, -0.033711694180965424, -0.06166893243789673, 0.07370659708976746, -0.02450673282146454, -0.0027219245675951242, 0.05779275298118591, 0.02440362237393856, 0.010259291157126427, -0.09957339614629745, -0.0071787708438932896, 0.0016156616620719433, 0.022937742993235588, -0.051412712782621384, 0.017020342871546745, -0.023800097405910492, -0.0064692143350839615, -0.0009914854308590293, -0.07175340503454208, -0.05785519257187843, -0.035240620374679565, -0.04537969455122948, 0.014833733439445496, 0.030644088983535767, -0.010333915241062641, 0.00473779859021306, 0.01749258115887642, -0.033594414591789246, -0.009360458701848984, 0.04186383634805679, 0.05628572031855583, 0.06589991599321365, -0.012793853878974915, -0.03333412483334541, 0.025270041078329086, -0.01645461656153202, 0.001435906975530088, 0.027516210451722145, 0.006429153494536877, -0.01100796740502119, -0.09937557578086853, 0.011268756352365017, 0.07411283254623413, -0.07157868146896362, 0.03816232830286026, 0.03396542742848396, -0.004170758184045553, 0.04418322443962097, 0.03337487950921059, 0.026810256764292717, 0.02284867689013481, -0.05856338143348694, -0.023903919383883476, -0.06090597063302994, -0.08077866584062576, -0.02436605468392372, -0.007952425628900528, 0.037042297422885895, -0.008246821351349354, -0.05014033988118172, -0.07457336038351059, 0.02000180259346962, -0.06185868754982948, -0.03616716340184212, 0.01717844046652317, 0.034406013786792755, -0.1401011198759079, 0.025976210832595825, -0.020788032561540604, 0.014428413473069668, 0.03568239137530327, -0.013509939424693584, 0.06086232140660286, 0.0786646381020546, -0.0014717441517859697, -0.048123933374881744, 0.04197936877608299, 0.08700185269117355, 0.015815820544958115, -0.014391381293535233, 0.026641706004738808, -0.05407381057739258, 0.04869581386446953, -0.03099396638572216, -0.006225110497325659, -0.0304352268576622, 0.039775777608156204, -0.05412280932068825, 0.006991173606365919, -0.1007080078125, 0.02909577451646328, 0.013673953711986542, -0.04413972795009613, 0.028850164264440536, 0.10554015636444092, -0.023291338235139847, 0.10509463399648666, -0.06446903198957443, -0.07210082560777664, 0.033113714307546616, 0.007323123514652252, -0.013772159814834595, -0.06393073499202728, 0.035941652953624725, -0.036235321313142776, -0.018368864431977272, 0.05981691926717758, 0.046101685613393784, 0.001742554479278624, -0.013012348674237728, -0.02552030049264431, -0.0636637732386589, -0.05136122554540634, -0.03541494160890579, -0.06222951039671898, -0.02802404761314392, 0.03711409494280815, 0.02102348767220974, 0.011425022967159748, 0.03914809599518776, -0.019785545766353607, -0.0580531544983387, 0.012475996278226376, -0.027960168197751045, 0.04538148641586304, -0.04749327898025513, 0.05794293060898781, 0.01797785423696041, 0.01567767560482025, 0.09189755469560623, -0.03245188295841217, -0.006196952424943447, -0.04373219609260559, 0.07036411762237549, 0.052881184965372086, 0.051429763436317444, 0.06307034939527512, -0.058469850569963455, 0.014469862915575504, -0.030243927612900734, 0.012921289540827274, -0.04876984283328056, -0.023184431716799736, 0.04413807764649391, 0.07893767207860947, -0.03666236251592636, 0.0173490010201931, 0.01970820687711239, -0.03996347635984421, 0.1014922633767128, 0.031321968883275986, 0.03710699826478958, 0.05377800390124321, 0.006118167657405138, 0.09805930405855179, -0.013235530816018581, -0.04846859350800514, 0.02519739791750908, -0.002220848808065057, -0.10256947576999664, -0.0345345214009285, 0.04554719850420952, 0.04339813441038132, -0.15887880325317383, 0.0025004169438034296, -0.028635971248149872, -0.0005839992663823068, -0.041084080934524536, -0.04015810787677765, 0.009219378232955933, 0.004853209014981985, -0.04708514362573624, 0.1289188265800476, -0.07281104475259781, 0.034658435732126236, -0.08915408700704575, -0.04927476495504379, -0.017687151208519936, 0.12536029517650604, 0.0035929051227867603, 0.06448058784008026, 0.01853921078145504, -0.01937686651945114, -0.07585355639457703, -0.0661827102303505, 0.02437867596745491, 0.07050790637731552, 0.003978361841291189, 0.005740018095821142, -0.03539714962244034, 0.02495608478784561, -0.002423191675916314, -0.005419789347797632, 0.00889651570469141, 0.0122076366096735, 0.03514593094587326, 0.06351860612630844, -0.026093490421772003, 0.0478237085044384, 0.00013333543029148132, -0.02313452586531639, -0.034059181809425354, 0.013748401775956154, 0.031787533313035965, 0.012230632826685905, -0.02917511574923992, 0.020140094682574272, 0.017185043543577194, -0.03648246452212334, 0.01733586937189102, -0.05005044862627983, 0.06970284134149551, 0.05836412310600281, -0.024125419557094574, 0.041781675070524216, -0.0018022095318883657, 0.010150621645152569, -0.034129299223423004, -0.017676083371043205, -0.020540213212370872, -0.015837576240301132, -0.00042307941475883126, 0.04496850073337555, -0.03717927262187004, -0.013364234007894993, 0.012029385194182396, 0.030143890529870987, 0.03492128103971481, 0.02316645160317421, -0.00503882160410285, -0.05434456095099449, -0.03188149631023407, 0.022466052323579788, -0.01682916097342968, 0.0014406164409592748, 0.021651316434144974, -0.003372995648533106, -0.011845175176858902, 0.0018658431945368648, -0.03990839049220085, -0.07067659497261047, 0.03466201201081276, 0.023330358788371086, 0.012767150066792965, -0.012168759480118752, 0.004564719740301371, -0.015498395077884197, 0.020759236067533493, 0.024715859442949295, -0.023114055395126343, -0.02225799672305584, 0.01937578059732914, -0.03865037485957146, -0.035837702453136444, -0.018634211272001266, -0.007782289292663336, 0.001080036978237331, 0.05544859915971756, 0.03471161052584648, 0.0007192345801740885, -0.07628558576107025, -0.011830676347017288, -0.06536439806222916, 0.026075195521116257, -0.03192674368619919, -0.03516238555312157, 0.0416438989341259, 0.008344266563653946, -0.005337064620107412, 0.03376922383904457, 0.012324616312980652, 0.024116240441799164, 0.024327663704752922, -0.028428256511688232, -0.038825247436761856, -0.005589692387729883, 0.017766118049621582, -0.023254698142409325, -0.017999006435275078, -0.007265782915055752, 0.007028792053461075, 0.019951868802309036, 0.024970553815364838, -0.030868539586663246, 0.025669515132904053, 0.015480025671422482, 0.04842138662934303, 0.01303833443671465, 0.007786042522639036, -0.03031114675104618, 0.0006049635703675449, -0.030183635652065277, -0.004079070407897234, -0.008237247355282307, 0.0003251599846407771, 0.02282627671957016, -0.01112018246203661, -0.002133080270141363, 0.04626293480396271, 0.0007394963758997619, 0.008683156222105026, -0.03731682896614075, -0.006385723128914833, -0.04765328764915466, 0.0021987578365951777, 0.006388187408447266, 0.00722684757784009, -0.03263590484857559, 0.04497646912932396, -0.013356099836528301, -0.01841229945421219, 0.03121674433350563, 0.005707984324544668, 0.03218328580260277, 0.0014272105181589723, 0.02634339965879917, -0.030978510156273842, -0.009303179569542408, 0.03138627111911774, 0.01587439700961113, -0.05955285206437111, 0.022238612174987793, -0.019117461517453194, -0.014981146901845932, -0.02248457260429859, 0.04001707583665848, 0.025746643543243408, -0.06994522362947464, 0.014446033164858818, -0.011208218522369862, -0.006515025161206722, 0.06147032976150513, -0.003355657681822777, 0.007462257985025644, -0.009925929829478264, -0.01489938609302044, -0.018885057419538498, -0.030052492395043373, 0.03955988585948944, 0.04432322457432747, -0.02419455535709858, -0.025288516655564308, 0.022443950176239014, -0.009306860156357288, -0.006849531549960375, 0.014058166183531284, 0.0068768891505897045, -0.013445896096527576, 0.006073617842048407, 0.03359733894467354, -0.028001954779028893, -0.033981189131736755, 0.03357858210802078, -0.026412544772028923, 0.00793012697249651, -0.002438133582472801, 0.029255850240588188, 0.04320117458701134, 0.011308283545076847, -0.014833837747573853, -0.04080887883901596, -0.04426869750022888, -0.0033481502905488014, -0.006386108230799437, -0.047098781913518906, 0.046384669840335846, 0.0034214446786791086, -0.01025781687349081, 0.0209560114890337, 0.017400361597537994, 0.004722359590232372, -0.007078134920448065, -0.035580262541770935, -0.04998665675520897, 0.04492294788360596, -0.01931912824511528, -0.015971297398209572, 0.030770938843488693, -0.030963242053985596, 0.011551465839147568, -0.009225036017596722, 0.009386752732098103, -0.011965005658566952, -0.040529582649469376, 0.06586044281721115, 0.018713556230068207, -0.02116057462990284, 0.018888991326093674, 0.023085441440343857, 0.015383939258754253, -0.016698159277439117, -0.007265807595103979, 0.08205500990152359, 0.05081852152943611, 0.04017191752791405, -0.019527213647961617, -0.013185790739953518, 0.008199101313948631, -0.021294372156262398, 0.005850279238075018, 0.01600591093301773, 0.03248335048556328, 0.024831898510456085, -0.023435350507497787, -0.011960572563111782, 0.042875781655311584, -0.011211386881768703, 0.013342293910682201, -0.02049785479903221, 0.011908481828868389, -0.00947618018835783, -0.0259232260286808, -0.015048591420054436, 0.04216524213552475, 0.057094473391771317, 0.01081072073429823, -0.030134130269289017, -0.01570010744035244, 0.012653686106204987, 0.02073509991168976, -0.01194320060312748, 0.03474414348602295, -0.03232591226696968, -0.019795453175902367, -0.0017796249594539404, -0.028601601719856262, 0.027133991941809654, -0.030306847766041756, -0.052822187542915344, 0.0090881222859025, -0.04395211115479469, 0.02033573016524315, -0.012860594317317009, -0.005968486424535513, -0.012230757623910904, 0.06968770921230316, 0.09042656421661377, -0.00973900780081749, -0.027307912707328796, 0.05376680940389633, 0.00032676468254067004, -0.03988416865468025, 0.05116409435868263, -0.0012909085489809513, 0.033414535224437714, 0.004436761140823364, 0.06270702928304672, 0.07601239532232285, -0.007402450777590275, 0.010059294290840626, 0.043797027319669724, -0.019550157710909843, 0.002152723493054509, -0.021095700562000275, 0.007273985538631678, -0.014134070836007595, 0.04245118424296379, 0.02069646678864956, 0.020837651565670967, 0.0009624457452446222, -0.0054311603307724, 0.0331210158765316, -0.012181229889392853, -0.03181218355894089, 0.026094915345311165, 0.004959280602633953, 0.03267475217580795, -0.02801513485610485, 0.04341084137558937, -0.01629745215177536, -0.032771505415439606, 0.009484284557402134, -0.011786499060690403, 0.009799501858651638, 0.0109022231772542, -0.01088467426598072, -0.021223098039627075, 0.053666647523641586, 0.013323715887963772, 0.02387329190969467, -0.018769273534417152, -0.0029005815740674734, 0.0013647056184709072, -0.046291783452034, -0.045927055180072784, -0.01206580363214016, 0.0172977726906538, -0.03743433579802513, -0.0076294862665236, 0.029606802389025688, 0.014166277833282948, -0.0031930257100611925, 0.008446412160992622, -0.0014340840280056, 0.022112833335995674, 0.007143239490687847, 0.005352277308702469, 0.043786030262708664, 0.053968071937561035, -0.019664762541651726, -0.03255348652601242, -0.03790324181318283, 0.0005483630811795592, -0.03961833566427231, -0.06513161957263947, 0.02155357599258423, 0.06071979179978371, -0.003382259514182806, -0.031145021319389343, 0.008516195230185986, 0.00927781779319048, 0.014804805628955364, -0.012987854890525341, -0.028881249949336052, 0.009565764106810093, -0.015175706706941128, 0.020505649968981743, -0.011747325770556927, -0.015882117673754692, 0.017048204317688942, 0.031711872667074203, -0.0337306372821331, 0.020953135564923286, 0.027658341452479362, -0.016648149117827415, 0.02947242371737957, -0.014797238633036613, -0.014098037034273148, 0.05030212178826332, 0.022530242800712585, 0.008694731630384922, -0.004228843841701746, 0.05250849574804306, -0.024131810292601585, 0.005261200945824385, 0.020939772948622704, 0.03346148133277893, 0.05283147469162941, 0.019742026925086975, -0.01395354326814413, 0.022328952327370644, 0.04019691050052643, 0.05468415841460228, -0.010673059150576591, 0.007157948333770037, -0.02615067921578884, 0.07686445116996765, -0.008992325514554977, 0.025845546275377274, 0.060824453830718994, -0.056880541145801544, -0.014543905854225159, 0.010044845752418041, -0.0075664515607059, -0.009701435454189777, -0.012019150890409946, 0.04345618560910225, 0.00979524478316307, 0.02022523805499077, -0.031241534277796745, 0.0489109568297863, -0.002067902125418186, 0.038557250052690506, -0.015997156500816345, -0.014982206746935844, 0.012585960328578949, 0.021564114838838577, 0.028927912935614586, 0.011227519251406193, -0.01872321218252182, -0.009272875264286995, 0.061509869992733, 0.015359101817011833, 0.06525284051895142, 0.020605096593499184, 0.03592083603143692, -0.021248405799269676, -0.03235255181789398, -0.008414900861680508, 0.016547100618481636, 0.017916850745677948, 0.011023011058568954, -0.002578684128820896, -0.0027690029237419367, -0.03601690009236336, 0.022190267220139503, -0.030433950945734978, 0.02515873871743679, -0.014863455668091774, 0.036635253578424454, -0.010594950057566166, 0.04618431627750397, 0.02886032499372959, 0.009266873821616173, 0.01567719504237175, -0.02053535357117653, -0.0037453228142112494, -0.007982888258993626, -0.04547487571835518, -0.03665886074304581, 0.014405664056539536, -0.01838584989309311, -0.01053788885474205, 0.02774418331682682, -0.018266141414642334, 0.028341220691800117, 0.03376779705286026, 0.060460176318883896, 0.062472667545080185, -0.020301273092627525, 0.03967169672250748, 0.03254067152738571, -0.045939091593027115, -0.004237040411680937, 0.0024961831513792276, -0.02837662398815155, 0.0033501216676086187, -0.04539350047707558, 0.026757502928376198, -0.022807475179433823, 0.03976554423570633, 0.02954455278813839, 0.03590824827551842, -0.02551734261214733, -0.0369730107486248, 0.012124672532081604, -0.03578651323914528, -0.01078119408339262, 0.04672626033425331, -0.022232331335544586, 0.006973201874643564, 0.009237491525709629, 0.03837846964597702, 0.019149940460920334, -0.021581338718533516, 0.0016745743341743946, 0.017590554431080818, 0.008858243003487587, -0.04108419269323349, 0.00039282202487811446, 0.006237835623323917, 0.0036394617054611444, 0.04827936738729477, 0.022894853726029396, 0.014424492605030537, 0.012110002338886261, -0.0182291641831398, 0.02546066790819168, -0.03968998044729233, 0.02703195810317993, -0.05146093666553497, -0.0013723482843488455, -0.021568167954683304, -0.01570393331348896, -0.017757393419742584, 0.008388825692236423, -0.0008543846197426319, -0.02617424912750721, -0.03308340162038803, 0.0023924291599541903, 0.024036269634962082, 0.016598375514149666, 0.033885467797517776, 0.052652209997177124, 0.0032842655200511217, 0.013158370740711689, -0.02340736612677574, -0.017927261069417, -0.0029279282316565514, 0.029062122106552124, 0.04927165061235428, -0.021684186533093452, -0.02421816624701023, -0.030127575621008873, -0.006459822878241539, 0.033357806503772736, -0.03965933248400688, 0.007238669786602259, -0.037774160504341125, -0.007333112880587578, -0.015841033309698105, 0.03318057209253311, 0.02087668515741825, -0.04599684476852417, 0.01654435135424137, -0.036482930183410645, -0.02262730337679386, 0.0017710260581225157, 0.021791156381368637, -0.04320436716079712, -0.0037526129744946957, -0.038642339408397675, 0.007359982933849096, 0.038836363703012466, -0.016422249376773834, -0.014989168383181095, 0.004652006085962057, -0.01797524280846119, 0.04025442898273468, -0.04470953345298767, -0.05826577916741371, 0.008449102751910686, 0.010340513661503792, 0.03696921095252037, -0.009159783832728863, -0.01828305423259735, 0.018438808619976044, -0.0015438301488757133, 0.00964578427374363, -0.010213824920356274, -0.048446230590343475, -0.003313810098916292, 0.008359706029295921, 0.0053308154456317425, 0.0035445219837129116, 0.027673229575157166, 0.06850845366716385, -0.019388092681765556, -0.04727887734770775, -0.03661550581455231 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Benchmark Inference performance benchmarks often only measure the execution of the model. In this blog post, and when discussing the performance of Infinity, we always measure the end-to-end pipeline including pre-processing, prediction, post-processing. Please keep this in mind when comparing these results with other latency measurements. Figure 2. Infinity End-to-End Pipeline
[ 0.02666277438402176, -0.03701474517583847, 0.04086685553193092, -0.03179974481463432, 0.022714463993906975, 0.0037822327576577663, 0.024049140512943268, 0.08096325397491455, -0.05182943865656853, -0.0402638278901577, 0.020973021164536476, 0.008532063104212284, 0.008347734808921814, 0.04157126322388649, 0.02329769916832447, 0.015020927414298058, 0.028653116896748543, 0.024454092606902122, 0.0075673628598451614, 0.00582470465451479, 0.026636775583028793, -0.02956622838973999, 0.035062506794929504, -0.026726270094513893, -0.06185372173786163, -0.030376559123396873, -0.021840611472725868, -0.04389098286628723, -0.06459865719079971, 0.01055587362498045, -0.109869584441185, -0.02458137832581997, 0.02913116104900837, -0.014090897515416145, -0.01014923769980669, -0.05740394443273544, -0.10526230931282043, 0.06115109845995903, -0.0022619774099439383, -0.05942314863204956, -0.006766072008758783, -0.0015408714534714818, -0.007135676220059395, 0.0051363189704716206, -0.017173217609524727, 0.013974970206618309, -0.14737673103809357, 0.04620734229683876, 0.016348008066415787, 0.015534547157585621, -0.05831074342131615, 0.10666478425264359, -0.03150250017642975, 0.03768453747034073, 0.0090147340670228, 0.027476463466882706, 0.01656491681933403, -0.042802877724170685, 0.010251629166305065, -0.0011979535920545459, 0.07354478538036346, -0.015631400048732758, 0.022099647670984268, -0.02023819088935852, -0.005021729040890932, 0.008183440193533897, 0.016163039952516556, 0.041961804032325745, -0.06099870428442955, 0.012658439576625824, -0.03408056125044823, 0.00399291655048728, 0.047370925545692444, 0.018329640850424767, 0.01516132615506649, 0.003615979105234146, -0.007910394109785557, 0.03471796587109566, 0.03776033595204353, 0.05623626708984375, -0.013008960522711277, -0.010924848727881908, 0.04003513231873512, 0.0306071974337101, 0.0160506758838892, 0.025957828387618065, 0.09746484458446503, -0.015447961166501045, -0.039324503391981125, 0.06756586581468582, 0.062055185437202454, -0.12349330633878708, 0.00790812261402607, 0.003625518176704645, -0.02508457936346531, -0.015489797107875347, 0.05118328705430031, 0.09669294953346252, -0.03467174246907234, 0.01226961798965931, -0.012182729318737984, -0.05798880010843277, -0.02633143961429596, -0.02814078889787197, 0.019629554823040962, 0.041362009942531586, -0.015477373264729977, -0.12440290302038193, -0.08559081703424454, 0.025391625240445137, -0.0724591612815857, 0.02440229058265686, 0.030494749546051025, 0.046550948172807693, -0.13783210515975952, 0.039303626865148544, -0.07723501324653625, 0.017994802445173264, 0.006501632276922464, 0.016501255333423615, 0.030817897990345955, 0.04688270017504692, 0.06324862688779831, -0.04968877136707306, -0.023741278797388077, 0.028150994330644608, 0.05245143547654152, 0.0444403700530529, -0.016123028472065926, -0.005895701237022877, 0.03667488321661949, -0.04153653606772423, 0.04988114908337593, 0.025973476469516754, -0.04738246649503708, -0.10804758220911026, -0.008401591330766678, -0.10507587343454361, 0.04274056851863861, -0.018107028678059578, -0.05398553982377052, -0.02219417504966259, 0.043626490980386734, -0.0026802688371390104, 0.09311717003583908, -0.037194397300481796, -0.024351710453629494, 0.0015583180356770754, -0.0013474461156874895, 0.020698590204119682, -0.08491835743188858, 0.09996277093887329, -0.07738588005304337, -0.06548222154378891, 0.044271647930145264, 0.02635795995593071, 0.02753939852118492, -0.02729920856654644, -0.0687742605805397, -0.005341865587979555, -0.019110390916466713, -0.028064221143722534, 0.020226268097758293, -0.026201386004686356, 0.039804231375455856, -0.0028457881417125463, 0.03688681498169899, -0.018735045567154884, -0.0240946002304554, -0.005194488912820816, -0.015379226766526699, -0.026355819776654243, 0.09691329300403595, -0.05730114132165909, 0.029746543616056442, -0.0008942362619563937, 0.009866178035736084, 0.07451853156089783, 0.03533743694424629, 0.028490817174315453, 0.011943916790187359, 0.052184928208589554, -0.03902377933263779, 0.039986178278923035, 0.036460813134908676, -0.10357806831598282, 0.03495122119784355, -0.05835020914673805, 0.011019221507012844, -0.0001388540695188567, -0.0802663266658783, -0.05731803551316261, 0.08620595186948776, -0.08833501487970352, 0.03369148075580597, -0.08281180262565613, -0.0025132354348897934, 0.07157675176858902, 0.019174685701727867, 0.04448990896344185, 0.021486029028892517, 0.037441570311784744, 0.06853901594877243, -0.03816038370132446, -0.03272289037704468, 0.04545869678258896, 0.04243261739611626, -0.0025188394356518984, -0.017192384228110313, -0.03922422602772713, -0.00772780179977417, -0.11958340555429459, -0.0308668352663517, -0.024531658738851547, -0.04198530688881874, -0.012922356836497784, 0.02761119231581688, 0.005993088241666555, 0.02464170753955841, -0.07494144886732101, 0.15809904038906097, -0.06411545723676682, 0.03765517473220825, -0.034679509699344635, -0.07503079622983932, 0.0075705754570662975, 0.030925890430808067, 0.022395312786102295, 0.030167343094944954, 0.041497331112623215, -0.015574191696941853, -0.0578862763941288, -0.01808219775557518, 0.08690778911113739, 0.03204617276787758, 0.0031653428450226784, -0.035764213651418686, 0.004649592563509941, 0.0388307087123394, -0.0257119070738554, 0.015801841393113136, -0.0006089612143114209, -0.0033707793336361647, 0.1316080540418625, -0.011082914657890797, -0.04422902688384056, 0.04358244687318802, -0.024392256513237953, -0.06705518811941147, 0.000694676476996392, -0.00015761585382279009, -0.021518714725971222, 0.004918769933283329, -0.06261536478996277, 0.0892244502902031, -0.014846249483525753, -0.011870671063661575, -0.010610905475914478, -0.03820124641060829, 0.046742137521505356, 0.033342063426971436, -0.012152235023677349, 0.0006357623497024179, -0.022490184754133224, 0.010348325595259666, -0.019778670743107796, -0.010483216494321823, -0.007407935801893473, -0.02416086755692959, 0.015290748327970505, 0.028408251702785492, -0.03151193633675575, -0.006742837838828564, 0.002708569634705782, -0.0006464498583227396, 0.024163875728845596, 0.042002446949481964, -0.013199212960898876, 0.006681828759610653, -0.010090804658830166, -0.00455374363809824, -0.023192858323454857, 0.014681553468108177, 0.02873912826180458, 0.009876334108412266, -0.030929630622267723, 0.013306495733559132, -0.010824302211403847, -0.06843698769807816, 0.015100722201168537, 0.01633908413350582, -0.005970017984509468, -0.0019102178048342466, -0.02591695636510849, 0.0002829415607266128, 0.011601670645177364, 0.007118262350559235, -0.060687411576509476, 0.0004102657549083233, -0.0078023383393883705, -0.06081746146082878, 0.029590437188744545, -0.04316575452685356, -0.016285084187984467, -0.021874241530895233, 0.05689400061964989, 0.0024623493663966656, 0.04125883802771568, -0.11348024755716324, -0.02018629014492035, 0.018096204847097397, 0.030097821727395058, -0.025466356426477432, -0.05569777265191078, 0.03547102212905884, -0.01470879279077053, 0.012699547223746777, 0.018795903772115707, 0.00917009450495243, -0.021912794560194016, 0.023693732917308807, 0.020096657797694206, -0.003858780488371849, -0.00849245022982359, 0.01073137391358614, -0.005805788561701775, -0.02293180674314499, 0.02233443595468998, 0.010273260064423084, 0.03061479516327381, 0.009107505902647972, -0.02909242920577526, -0.005644694902002811, 0.063553087413311, 0.011865047737956047, 0.01820957101881504, 0.045094821602106094, 0.004996977746486664, -0.03740406408905983, -0.023094918578863144, -0.04657312482595444, 0.004383724182844162, -0.014046531170606613, -0.019109521061182022, -0.032646916806697845, 0.005954583641141653, 0.027489179745316505, 0.018473107367753983, 0.02998332679271698, -0.01789344660937786, 0.03990573063492775, -0.02679998241364956, 0.015794623643159866, -0.006978875491768122, 0.03823255002498627, 0.005923382006585598, 0.04684407636523247, -0.04808935150504112, -0.03590397164225578, 0.013936333358287811, 0.003665101481601596, 0.05598599463701248, -0.0012989143142476678, -0.030951298773288727, -0.0462736040353775, 0.003961894195526838, 0.03967953473329544, -0.018391206860542297, -0.045669566839933395, -0.0038548291195183992, 0.03829142078757286, -0.009184739552438259, -0.06815125793218613, 0.02690386399626732, 0.007903791964054108, 0.004530144855380058, -0.00676689250394702, 0.011282132938504219, -0.00020196956756990403, 0.045635104179382324, -0.0005945271113887429, 0.01850193366408348, -0.024806125089526176, 0.010702808387577534, 0.005249406676739454, -0.03568103536963463, 0.07580816000699997, 0.05151905491948128, -0.055784787982702255, -0.009725028648972511, -0.002734108129516244, -0.009507485665380955, 0.007248267065733671, 0.038424137979745865, 0.036802295595407486, -0.002224472351372242, -0.010554468259215355, 0.03916438668966293, 0.011153556406497955, 0.0009659194038249552, 0.010829477570950985, -0.01511316280812025, -0.0007295841933228076, 0.01621297560632229, 0.02403540164232254, 0.0017108905594795942, 0.0031368788331747055, 0.0034671444445848465, 0.016033947467803955, -0.032507363706827164, 0.004580482374876738, 0.0040588085539639, -0.0045927222818136215, 0.0493420846760273, -0.014457453973591328, -0.0030302521772682667, 0.019176574423909187, -0.013270033523440361, 0.03361319378018379, -0.02082323655486107, 0.019331591203808784, -0.02253095805644989, 0.03395552560687065, 0.025800280272960663, -0.008902708068490028, 0.0016960991779342294, -0.0019425422651693225, 0.0358969047665596, -0.033032286912202835, 0.01030320767313242, -0.010398034937679768, -0.011825362220406532, 0.034670405089855194, 0.002007530303671956, 0.013961255550384521, 0.00870482437312603, 0.0031616080086678267, -0.03297039866447449, -0.004511642269790173, 0.027553416788578033, 0.055081963539123535, 0.03509100526571274, 0.019482383504509926, -0.009520363062620163, -0.03024216555058956, 0.019178427755832672, -0.0031168300192803144, -0.034991487860679626, 0.0368213877081871, 0.026394521817564964, 0.010896093212068081, -0.016457200050354004, 0.0011478725355118513, 0.023942984640598297, -0.05630306154489517, -0.006784542463719845, -0.014806329272687435, 0.027669690549373627, 0.04652081057429314, -0.02540169097483158, -0.04510064050555229, -0.032666102051734924, 0.04220813512802124, -0.009386592544615269, -0.02498112991452217, -0.006676073186099529, -0.016255484893918037, 0.037855114787817, -0.008805269375443459, -0.004629587754607201, -0.034065354615449905, 0.016240999102592468, -0.01502010878175497, -0.007647803984582424, -0.037325434386730194, 0.008131136186420918, -0.010829377919435501, 0.020654598250985146, -0.024690931662917137, -0.008144792169332504, 0.022935057058930397, -0.024755803868174553, 0.04388176649808884, 0.033146925270557404, 0.01868823729455471, -0.014786542393267155, 0.0069738333113491535, 0.005256658419966698, -0.0016537308692932129, -0.05732174217700958, 0.04428163170814514, -0.022967392578721046, 0.022836416959762573, -0.023134632036089897, 0.05836661905050278, 0.046679891645908356, -0.007727369666099548, 0.050537656992673874, 0.05888788774609566, 0.011391479521989822, 0.00464087026193738, -0.048790767788887024, 0.00034491982660256326, -0.009295094758272171, 0.05701744183897972, -0.013128646649420261, -0.009769265539944172, -0.0015948832733556628, 0.006820782087743282, 0.05209070071578026, 0.015809182077646255, -0.005616920068860054, 0.021559787914156914, 0.04502043500542641, 0.010563530027866364, -0.02861594967544079, 0.056590232998132706, -0.00034878324368037283, -0.0036278278566896915, -0.003863179124891758, -0.057798244059085846, 0.03864161670207977, 0.017579946666955948, -0.03449001908302307, -0.021427081897854805, 0.038580406457185745, 0.02833622135221958, 0.05336805433034897, -0.0023735114373266697, -0.0027907860931009054, -0.038127392530441284, -0.008665055967867374, -0.0005560404970310628, -0.010312958620488644, -0.011360709555447102, -0.04370217025279999, -0.01447155699133873, 0.03345998749136925, -0.014842511154711246, -0.010018796660006046, -0.01623068004846573, 0.005079792812466621, 0.03105117194354534, 0.040265537798404694, 0.007254238706082106, 0.05254848301410675, 0.03689217194914818, -0.024655204266309738, -0.05800242722034454, -0.03421931713819504, -0.0010842564515769482, -0.03715788573026657, -0.07006122916936874, 0.006642241962254047, 0.06806857138872147, -0.027529772371053696, -0.03254469856619835, 0.04500949755311012, 0.0019411847461014986, -0.006313657853752375, 0.01717236265540123, 0.010868793353438377, 0.004783681593835354, 0.007237974554300308, -0.0031131363939493895, -0.029634756967425346, -0.01894918456673622, 0.04471644014120102, 0.023560410365462303, -0.01966939866542816, 0.026598341763019562, 0.020918620750308037, -0.024986138567328453, 0.04551912844181061, 0.005981268361210823, -0.020112209022045135, 0.041004814207553864, 0.045799486339092255, 0.006340373307466507, 0.003761679632589221, 0.026258712634444237, -0.006510323379188776, -0.01108588557690382, -0.0075387293472886086, -0.0010860373731702566, 0.07811442017555237, -0.008656981401145458, 0.03408195078372955, 0.03465886041522026, 0.04839355871081352, 0.04797839745879173, 0.002320586470887065, -0.019275281578302383, -0.011188789270818233, 0.03947904706001282, -0.0011485208524391055, 0.03183653950691223, 0.010466130450367928, 0.003097029635682702, -0.005511159542948008, 0.006752478424459696, -0.044142164289951324, -0.03712567687034607, 0.003962110262364149, 0.016671448945999146, 0.010340488515794277, 0.0032900425139814615, -0.04703705757856369, 0.0048699877224862576, -0.015287903137505054, 0.009861941449344158, 0.0015750780003145337, -0.009040254168212414, 0.04228721559047699, 0.017898114398121834, -0.010784896090626717, 0.022361479699611664, -0.01550073828548193, -0.00909949280321598, 0.08424272388219833, -0.008431117050349712, 0.02445516176521778, -0.009691677987575531, -0.010088099166750908, 0.009409723803400993, 0.009313046932220459, -0.026220614090561867, 0.02036786824464798, 0.03772752732038498, 0.0016448169481009245, 0.018032236024737358, 0.028542576357722282, -0.02105199731886387, -0.014255656860768795, -0.005705154500901699, -0.005852589383721352, 0.0030543103348463774, -0.02242978848516941, 0.018137069419026375, 0.03442265838384628, 0.00775066576898098, -0.04897857457399368, -0.02725822664797306, -0.022944912314414978, -0.018321674317121506, 0.02627073973417282, -0.042332783341407776, -0.011039906181395054, 0.02749646082520485, 0.03696056455373764, 0.011779623106122017, 0.020445534959435463, -0.036342643201351166, 0.028820525854825974, 0.04467443376779556, 0.0019181884126737714, -0.00036405149148777127, -0.0033028183970600367, 0.033454447984695435, -0.005960000213235617, -0.013383043929934502, -0.0001808178349165246, -0.01928664930164814, -0.028402788564562798, 0.02848002314567566, 0.028091464191675186, 0.0011125090532004833, -0.013139540329575539, 0.021039554849267006, 0.03343644365668297, 0.01267192792147398, -0.019222689792513847, 0.014582785777747631, -0.03437953442335129, -0.04579536244273186, -0.014211035333573818, -0.008902168832719326, -0.009138832800090313, -0.026081187650561333, 0.016140228137373924, 0.0024618126917630434, 0.02186567150056362, -0.021285010501742363, 0.016927199438214302, 0.030206754803657532, -0.01398195419460535, -0.04000614583492279, -0.043107740581035614, -0.0008862947579473257, 0.013381769880652428, 0.04146425798535347, 0.05431128665804863, 0.012660015374422073, 0.018676195293664932, -0.0330595038831234, 0.04147312790155411, -0.03507077693939209, 0.02275265008211136, -0.033123310655355453, 0.004147032741457224, -0.04993891716003418, 0.012417876161634922, -0.017183491960167885, -0.006243427284061909, -0.02071372978389263, -0.01154277753084898, -0.02856016717851162, -0.035953763872385025, -0.00042218275484628975, 0.0012041367590427399, 0.0866326242685318, 0.05779634043574333, 0.025612009689211845, 0.01776633970439434, -0.03630500286817551, -0.010151972062885761, -0.019992705434560776, 0.02399001643061638, 0.020557977259159088, 0.0092642055824399, 0.007233146112412214, -0.011046364903450012, 0.0320340134203434, -0.04383346438407898, -0.011907339096069336, 0.03967171534895897, 0.01878470741212368, -0.028677279129624367, -0.007762267254292965, 0.0063604917377233505, -0.007096417248249054, -0.0037595462054014206, 0.06527940183877945, 0.026726018637418747, -0.010424851439893246, -0.03418019413948059, -0.0157766193151474, -0.0417296439409256, -0.020715821534395218, 0.008864358067512512, 0.0004954434698447585, 0.034583210945129395, 0.04133833572268486, 0.033250097185373306, -0.013676677830517292, -0.024170633405447006, 0.02538168616592884, -0.03368045762181282, -0.06450577080249786, -0.029691506177186966, -0.011178234592080116, -0.01986735500395298, -0.04007010906934738, -0.05213585123419762, 0.020743118599057198, -0.01872057281434536, -0.005325077101588249, 0.005093301646411419, 0.005251956172287464, 0.010211250744760036, -0.012250654399394989, 0.008831975050270557, -0.011425741016864777, 0.028524456545710564, 0.08470653742551804, 0.004254478961229324, 0.016119247302412987, -0.012885354459285736 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Environment As a benchmark environment, we are going to use the Amazon EC2 C6i instances, which are compute-optimized instances powered by the 3rd generation of Intel Xeon Scalable processors. These new Intel-based instances are using the ice-lake Process Technology and support Intel AVX-512, Intel Turbo Boost, and Intel Deep Learning Boost. In addition to superior performance for machine learning workloads, the Intel Ice Lake C6i instances offer great cost-performance and are our recommendation to deploy Infinity on Amazon Web Services. To learn more, visit the EC2 C6i instance page.
[ 0.011240709573030472, -0.01656358875334263, -0.007180084008723497, 0.0540345199406147, -0.0049029383808374405, 0.04198707267642021, -0.0030149787198752165, 0.06754588335752487, -0.08683717995882034, -0.0776473879814148, -0.0011194429825991392, 0.008771596476435661, -0.04228134825825691, 0.046413738280534744, 0.08832857757806778, 0.004720771685242653, 0.032895371317863464, 0.08801143616437912, -0.03338739648461342, 0.048270076513290405, 0.06451219320297241, -0.017702631652355194, 0.01982256956398487, 0.0694115161895752, -0.03260548412799835, 0.05182232707738876, -0.01068982295691967, -0.01869047060608864, -0.018094230443239212, -0.061009909957647324, -0.024658557027578354, -0.0018438491970300674, -0.02340746484696865, -0.013696854002773762, 0.0047821723856031895, 0.012537365779280663, -0.1061423048377037, 0.06015598401427269, -0.08310049027204514, -0.03192436695098877, -0.004134558606892824, 0.004074576310813427, -0.04743271693587303, 0.04756331443786621, -0.06433326005935669, 0.06453633308410645, -0.03713718056678772, -0.03829651325941086, 0.019327448680996895, 0.031026342883706093, -0.11436397582292557, 0.049700990319252014, -0.00831716787070036, 0.011268869042396545, 0.06909578293561935, 0.033852774649858475, 0.04706304147839546, -0.018417252227663994, 0.054220352321863174, 0.04182935506105423, 0.058033287525177, -0.022842345759272575, -0.017397060990333557, -0.04745661839842796, 0.017711982131004333, -0.06524234265089035, -0.028607798740267754, -0.041385218501091, -0.013773349113762379, -0.015347822569310665, -0.0032387326937168837, 0.012858637608587742, 0.05593353882431984, 0.012823431752622128, -0.007144576404243708, -0.015971846878528595, -0.01947415992617607, 0.04580696299672127, 0.03243895247578621, 0.0900718942284584, -0.004131793510168791, 0.06147221475839615, 0.0006008388008922338, -0.02025667391717434, 0.006678265985101461, -0.029212579131126404, 0.025347517803311348, 0.005500762723386288, -0.10120628774166107, 0.022196926176548004, 0.10899939388036728, -0.01856119930744171, 0.09797430038452148, 0.07836920022964478, -0.005251269321888685, -0.02056080661714077, 0.03468063846230507, -0.04785151034593582, 0.0734449177980423, 0.07077094912528992, -0.00795021466910839, 0.012440290302038193, -0.050601452589035034, -0.0330413356423378, -0.11069837212562561, 0.07006732374429703, -0.027576513588428497, -0.12712281942367554, -0.022416485473513603, 0.014913693070411682, -0.019957132637500763, 0.016032524406909943, -0.005574401468038559, 0.04314929619431496, -0.10328874737024307, 0.0123046999797225, -0.04048345610499382, -0.015089946798980236, 0.01686508022248745, -0.020801298320293427, 0.061836667358875275, 0.046953991055488586, 0.008334296755492687, -0.009725069627165794, -0.03222081437706947, 0.03402332589030266, -0.012187101878225803, 0.02434835210442543, -0.017997443675994873, -0.052906472235918045, 0.04287360608577728, -0.02934125065803528, 0.08419988304376602, 0.0013017572928220034, 0.0071276272647082806, -0.024751143530011177, -0.017250629141926765, -0.06763333827257156, -0.04381321743130684, 0.05018796771764755, 0.03102707490324974, 0.006291399709880352, 0.10700292140245438, -0.05225254222750664, 0.10156989842653275, 0.013984867371618748, 0.02767576463520527, 0.0173503328114748, 0.05010901764035225, 0.03301174193620682, -0.053722795099020004, 0.019933030009269714, -0.14362218976020813, -0.01597384177148342, 0.07456862926483154, 0.057404808700084686, -0.014115194790065289, -0.059854745864868164, -0.03255288302898407, -0.061824943870306015, -0.008364793844521046, -0.023367946967482567, -0.0879392921924591, -0.0089981434866786, 0.03986215591430664, -0.007742851506918669, 0.010724854655563831, 0.0033485449384897947, 0.005976605229079723, -0.050017137080430984, -0.029288800433278084, 0.02594730444252491, 0.08762197196483612, 0.07315962016582489, 0.05372530594468117, 0.021062681451439857, 0.031237270683050156, 0.06109293922781944, 0.041980892419815063, -0.04186462610960007, -0.07153039425611496, 0.0380040779709816, -0.00716490438207984, 0.05395639315247536, -0.01952391490340233, 0.0065945289097726345, 0.020062049850821495, -0.009328731335699558, 0.061069875955581665, -0.019203320145606995, -0.014331808313727379, -0.00043446882045827806, 0.01632082089781761, 0.033695120364427567, -0.0008972532814368606, 0.013209916651248932, 0.007372571155428886, 0.05427885055541992, 0.03325539082288742, 0.0603141114115715, 0.04278934746980667, -0.041549813002347946, 0.060256343334913254, 0.025539834052324295, -0.09779506176710129, 0.036096472293138504, -0.01652466133236885, 0.004442411009222269, 0.0013900769408792257, 0.03619496151804924, -0.025423889979720116, -0.07802165299654007, -0.03166624531149864, -0.02969515323638916, -0.07642385363578796, 0.008744672872126102, -0.10967954993247986, 0.043465424329042435, 0.030590597540140152, 0.041270770132541656, 0.10851498693227768, -0.04987476021051407, 0.06207767874002457, -0.018875474110245705, 0.030895482748746872, 0.023161405697464943, 0.06464459747076035, -0.016165869310498238, 0.058171339333057404, 0.027113690972328186, -0.028992481529712677, -0.08336809277534485, -0.028447307646274567, 0.00239031040109694, 0.06349658221006393, 0.04348275065422058, 0.061390820890665054, 0.013977882452309132, 0.050587911158800125, 0.026285015046596527, -0.025187164545059204, -0.00910993292927742, -0.0821215957403183, 0.04471352696418762, 0.06318587809801102, -0.05022226274013519, 0.05808880925178528, -0.07730334252119064, -0.054713331162929535, -0.06133370101451874, 0.005002452526241541, -0.014123746193945408, 0.012716490775346756, -0.022709066048264503, 0.021023105829954147, -0.02248142659664154, 0.01434064470231533, -0.0053566074930131435, -0.006078890524804592, 0.061655834317207336, 0.010435967706143856, -0.0009258270147256553, -0.012374612502753735, 0.0016945728566497564, 0.06975850462913513, -0.029075901955366135, 0.013036508113145828, -0.07169138640165329, 0.033400535583496094, -0.013861052691936493, -0.01766371726989746, -0.010862181894481182, 0.00018534132686909288, -0.03613044321537018, -0.03126883506774902, -0.015480765141546726, -0.026351552456617355, 0.03116120584309101, 0.0037815214600414038, -0.04287104681134224, 0.012512322515249252, -0.045968517661094666, 0.02666480652987957, 0.016978468745946884, 0.0051154522225260735, -0.033120229840278625, -0.00552111491560936, -0.03475995361804962, -0.04530130699276924, 0.0028252191841602325, 0.005953528918325901, 0.013092201203107834, -0.023059457540512085, 0.05091382935643196, -0.011678230948746204, 0.04371723160147667, -0.029164422303438187, -0.019305380061268806, -0.05927562341094017, -0.009133283980190754, -0.02776257134974003, -0.01142923068255186, -0.0383462980389595, 0.03819430246949196, -0.0072441501542925835, 0.011992902494966984, -0.01481120940297842, -0.012326107360422611, -0.06971615552902222, 0.0019650498870760202, -0.005862879101186991, 0.040271155536174774, 0.009087290614843369, -0.04258454591035843, 0.04677890986204147, 0.054528914391994476, -0.01262352243065834, 0.06613155454397202, -0.0008978606783784926, 0.002531524747610092, 0.036457985639572144, -0.004370892886072397, -0.03109622932970524, 0.011798562481999397, -0.008082798682153225, -0.04415486007928848, -0.013879929669201374, -0.03285593539476395, 0.005214369855821133, -0.010877550579607487, 0.007416910491883755, -0.03455038368701935, -0.0344562828540802, 0.02396487630903721, 0.025166470557451248, 0.012134610675275326, 0.00801423005759716, 0.009962903335690498, -0.02642017789185047, -0.009020709432661533, -0.01879112236201763, -0.008895410224795341, -0.043899055570364, -0.0021243072114884853, -0.023184381425380707, 0.04314432665705681, 0.044884975999593735, -0.008502722717821598, -0.01236138679087162, -0.03011522814631462, 0.06026093661785126, -0.03853900730609894, 0.0390852615237236, -0.007311107125133276, 0.02764386311173439, -0.02644895575940609, 0.012075696140527725, 0.014268611557781696, -0.09017331153154373, -0.008189765736460686, 0.02748844027519226, 0.03279288485646248, 0.001271950313821435, -0.01741263084113598, -0.01013133954256773, 0.02775522880256176, 0.011495369486510754, -0.016267577186226845, 0.009396304376423359, 0.021332217380404472, 0.0240800678730011, 0.04729091376066208, -0.002425159327685833, -0.02752119116485119, 0.0030553818214684725, -0.02828991785645485, -0.03376220911741257, -0.0039701759815216064, 0.03063930943608284, 0.04507206380367279, -0.02064753696322441, 0.0019860800821334124, 0.007887749932706356, 0.002148857107385993, 0.029943782836198807, -0.02765270508825779, -0.006064008921384811, 0.056531015783548355, -0.025393150746822357, -0.010726547800004482, 0.004125524312257767, -0.025787122547626495, 0.02904101461172104, 0.010087120346724987, -0.034543849527835846, -0.0005088532925583422, 0.035706326365470886, 0.03939688205718994, 0.0002123224694514647, -0.050679776817560196, 0.022406598553061485, -0.004748205654323101, -0.03235030174255371, -0.07429416477680206, 0.003462517634034157, 0.002183578908443451, -0.00916311051696539, 0.014030096121132374, -0.018744997680187225, -0.007638696581125259, 0.029711566865444183, 0.031139757484197617, -0.015633849427103996, -0.025835683569312096, 0.02410122938454151, -0.0068586221896111965, -0.004731631837785244, 0.011797980405390263, 0.02612489089369774, -0.04133535549044609, 0.009642860852181911, -0.008938748389482498, 0.03298040106892586, 0.011414713226258755, 0.019849618896842003, 0.017007477581501007, 0.051188599318265915, 0.01789507269859314, -0.0013035620795562863, 0.022862831130623817, 0.005895367357879877, -0.001911977888084948, -0.014918182976543903, -0.03339202702045441, 0.0007981833186931908, -0.01393119990825653, -0.008760947734117508, -0.045108724385499954, -0.024978918954730034, -0.018368206918239594, 0.04131103307008743, 0.03386158496141434, -0.0018891706131398678, -0.04536057263612747, 0.010299928486347198, 0.013332360424101353, 0.016901666298508644, -0.023981543257832527, 0.01991122029721737, 0.04875977337360382, 0.0014089096803218126, -0.022776443511247635, 0.006667578127235174, 0.036559078842401505, 0.015607491135597229, -0.03190866857767105, 0.024128707125782967, -0.0142097482457757, 0.020713595673441887, 0.024759262800216675, -0.004983512684702873, 0.01456162054091692, 0.05126034468412399, 0.0027987707871943712, -0.019545506685972214, -0.020839491859078407, -0.015389676205813885, 0.0001572738983668387, 0.004028950817883015, 0.02584702894091606, -0.04273161664605141, -0.038832150399684906, 0.030575139448046684, -0.00829691905528307, 0.013745317235589027, 0.0035171236377209425, -0.043956685811281204, 0.05462547764182091, -0.010586059652268887, 0.02801879681646824, -0.05157678946852684, -0.015010613016784191, -0.010803557001054287, 0.029703417792916298, 0.044365160167217255, 0.02626199834048748, 0.010803349316120148, 0.04790089279413223, -0.036146823316812515, -0.05405879765748978, -0.02727426588535309, -0.0028679128736257553, 0.02942577190697193, -0.013486018404364586, 0.02965390309691429, 0.018424339592456818, 0.006490806117653847, 0.01408746000379324, 0.0263271015137434, -0.008745632134377956, 0.02303115464746952, 0.006685455795377493, 0.01014986913651228, 0.015491057187318802, 0.017681820318102837, 0.01948557049036026, 0.0007700976566411555, -0.03552098199725151, 0.011945378966629505, -0.012197449803352356, -0.012911036610603333, -0.001901016803458333, -0.003121183952316642, 0.010426576249301434, -0.02798241190612316, 0.01118598971515894, 0.004661013372242451, 0.011061172932386398, -0.012241736054420471, 0.017710739746689796, -0.024150129407644272, -0.00721484562382102, -0.014258320443332195, 0.0026735616847872734, -0.012343388050794601, 0.0439872071146965, -0.02063010260462761, -0.004744190257042646, -0.013738328590989113, -0.02781311236321926, 0.04243561998009682, -0.042446259409189224, -0.05770077183842659, 0.02382727526128292, -0.0009110872051678598, -0.013245373964309692, -0.03144501522183418, -0.02788556180894375, 0.05931077152490616, -0.0024942257441580296, -0.02831314504146576, 0.0052648368291556835, 0.04561923071742058, -0.03791527822613716, 0.04977453500032425, 0.028431812301278114, 0.04104122892022133, -0.07563941180706024, -0.06939052045345306, -0.0472714938223362, 0.021835483610630035, -0.05171022564172745, -0.0608302466571331, 0.006287363823503256, 0.03292148560285568, 0.007818243466317654, -0.039661429822444916, -0.0019234688952565193, -0.027937373146414757, -0.012419072911143303, 0.008200296200811863, -0.04135769605636597, 0.004045200068503618, -0.02217554673552513, 0.02212493121623993, -0.007300463505089283, 0.01804816722869873, -0.009991413913667202, -0.05005769059062004, -0.005426374729722738, 0.02771848998963833, 0.06099623814225197, -0.025113936513662338, -0.0015055350959300995, -0.018714332953095436, -0.018228890374302864, 0.030869239941239357, 0.04128630459308624, 0.016570469364523888, 0.014852297492325306, 0.02141822688281536, -0.05475054308772087, -0.012173890136182308, 0.0516984723508358, -0.01223406195640564, 0.07491706311702728, -0.00885043665766716, -0.002634597709402442, 0.005316884256899357, 0.05224013701081276, 0.04388289153575897, -0.02711270935833454, -0.021321136504411697, -0.004247183911502361, 0.02829550765454769, -0.01193002238869667, 0.05130598694086075, 0.044353555887937546, -0.007433768827468157, 0.01604810357093811, -0.004286167211830616, -0.018991777673363686, -0.006399199832230806, -0.004996828269213438, 0.009020381607115269, -0.035108260810375214, -0.01428370364010334, -0.05986206606030464, 0.05058909207582474, 0.0462067574262619, 0.0012784362770617008, -0.00012960199092049152, -0.04879419878125191, 0.004501184914261103, -0.012362289242446423, 0.010736454278230667, 0.014439240097999573, -0.023453805595636368, 0.038905348628759384, 0.04201073199510574, -0.004786810837686062, 0.046133119612932205, -0.01923341676592827, 0.01035377848893404, 0.021891290321946144, -0.016380755230784416, 0.020583869889378548, 0.02106834016740322, 0.02149246446788311, -0.03355805203318596, -0.00603880500420928, -0.005212497431784868, -0.005651000887155533, -0.004971256945282221, -0.03542674332857132, 0.0019109181594103575, -0.009361876174807549, 0.027460120618343353, -0.04209616035223007, 0.01995678059756756, -0.023435009643435478, -0.020273486152291298, -0.025911834090948105, 0.006173929199576378, -0.023624232038855553, 0.002701658522710204, -0.061257269233465195, 0.005381822120398283, 0.011972745880484581, 0.0243375264108181, 0.015208180993795395, 0.017174379900097847, -0.019699087366461754, 0.011720926500856876, -0.00014659152657259256, 0.039527274668216705, -0.011606409214437008, 0.010190187022089958, 0.006366046145558357, 0.026799678802490234, 0.01609935611486435, -0.011547544971108437, -0.04441846162080765, -0.04273630306124687, 0.0214956384152174, -0.030737299472093582, 0.04841247946023941, -0.04144727811217308, 0.02330014295876026, 0.005231231451034546, 0.03763190656900406, 0.009437273256480694, -0.006570296362042427, -0.015165789052844048, -0.010277912952005863, -0.022120939567685127, 0.06653211265802383, -0.010621283203363419, -0.038837533444166183, -0.0028553353622555733, 0.015417168848216534, -0.012720271944999695, -0.024121155962347984, 0.015609725378453732, -0.00030563672771677375, -0.032939210534095764, -0.05972891300916672, -0.018139783293008804, 0.038346901535987854, -0.02240905538201332, 0.06253714859485626, 0.006070245988667011, 0.021230079233646393, -0.006097112782299519, -0.00857551209628582, -0.009264589287340641, -0.0245263259857893, 0.013812463730573654, -0.0438203401863575, -0.004395586904138327, -0.005907420534640551, -0.0049506379291415215, 0.002896763850003481, 0.02384275570511818, -0.0545516274869442, 0.01770913600921631, -0.03781049698591232, -0.004512547515332699, -0.02974911965429783, 0.021125786006450653, 0.02924651838839054, 0.040329497307538986, -0.018595634028315544, 0.0006944875349290669, -0.03827499970793724, -0.0038810893893241882, 0.004837242886424065, 0.00465972488746047, 0.03199924901127815, 0.0036871491465717554, 0.014822069555521011, -0.028615936636924744, 0.017656363546848297, 0.01353901345282793, -0.00097692443523556, 0.04518364369869232, -0.05275862291455269, -0.017739012837409973, -0.044619783759117126, 0.0076395682990550995, -0.004215977620333433, -0.0038660061545670033, 0.026938559487462044, -0.012372415512800217, -0.012486442923545837, 0.004141612909734249, -0.027445483952760696, -0.047654133290052414, -0.03814822435379028, -0.017206093296408653, -0.023007886484265327, 0.06534749269485474, 0.028429849073290825, -0.0015020174905657768, -0.05866038054227829, -0.015066945925354958, 0.07089139521121979, -0.023283734917640686, -0.045321930199861526, 0.003170873736962676, 0.010222106240689754, 0.02540799230337143, -0.007177416235208511, -0.04379308968782425, 0.0066801514476537704, -0.061695341020822525, 0.023288113996386528, 0.018452173098921776, -0.019590066745877266, -0.011412734165787697, -0.025801777839660645, 0.028432825580239296, -0.001189651433378458, -0.007021110970526934, 0.06018080562353134, 0.01058324333280325, 0.028893401846289635, -0.022479131817817688 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Throughput Below you can find the throughput comparison for running infinity on 2 physical cores with batch size 1, compared with vanilla transformers. Figure 3. Throughput: Infinity vs Transformers | Sequence Length | Infinity | Transformers | improvement | |-----------------|-------------|--------------|-------------| | 8 | 248 req/sec | 49 req/sec | +506% | | 16 | 212 req/sec | 50 req/sec | +424% | | 32 | 150 req/sec | 40 req/sec | +375% | | 64 | 97 req/sec | 28 req/sec | +346% | | 128 | 55 req/sec | 18 req/sec | +305% | | 256 | 27 req/sec | 9 req/sec | +300% | | 384 | 17 req/sec | 5 req/sec | +340% | | 512 | 12 req/sec | 4 req/sec | +300% |
[ 0.07290230691432953, 0.01036651898175478, 0.0313984677195549, -0.01717418245971203, 0.04854213818907738, 0.01574605330824852, 0.02976963296532631, 0.0432782806456089, -0.039973415434360504, -0.04227810725569725, 0.005556323099881411, 0.04478835687041283, -0.006306648254394531, 0.04721524566411972, -0.03402978554368019, 0.05699100345373154, 0.04346974939107895, 0.01125242467969656, -0.0019463265780359507, 0.005532229319214821, -0.01963132619857788, 0.008078223094344139, 0.0993279293179512, 0.032041605561971664, 0.00813236739486456, -0.015134252607822418, 0.0008100754930637777, -0.058788131922483444, -0.06258338689804077, 0.028276272118091583, -0.12198149412870407, -0.044570550322532654, 0.033552851527929306, -0.03876081109046936, 0.035029344260692596, -0.05055474862456322, -0.09189543128013611, 0.07021066546440125, 0.035432517528533936, -0.026529623195528984, -0.026258496567606926, 0.0199307668954134, -0.051382847130298615, -0.01744508370757103, -0.045473452657461166, 0.07576054334640503, -0.14100272953510284, 0.03862317278981209, -0.037300482392311096, 0.0072975242510437965, -0.04014073684811592, 0.04567715898156166, -0.04149001091718674, 0.009504030458629131, 0.024930942803621292, 0.04656641557812691, -0.02809186466038227, 0.038691285997629166, -0.023990333080291748, -0.0007141505484469235, 0.05930982157588005, -0.02067081816494465, -0.010525981895625591, 0.014363479800522327, -0.06753402948379517, 0.008944510482251644, -0.029855389147996902, 0.05471677705645561, -0.06379091739654541, -0.026293674483895302, 0.014753671362996101, 0.022577086463570595, 0.03721023350954056, 0.009058077819645405, -0.05025911703705788, -0.009948291815817356, -0.02792927995324135, 0.04575919359922409, 0.05430768430233002, 0.11433500796556473, -0.013526174239814281, 0.04743795469403267, 0.02621162310242653, 0.023048587143421173, 0.03464243933558464, 0.017665129154920578, 0.06501594930887222, 0.027375157922506332, -0.0389668345451355, 0.11297228187322617, 0.03165801241993904, -0.09956899285316467, 0.012919721193611622, -0.026058360934257507, 0.01945427805185318, -0.002713016699999571, 0.029727710410952568, 0.022415930405259132, -0.05674155056476593, 0.0859851986169815, 0.0061586531810462475, 0.043229542672634125, 0.005313070956617594, 0.01107499748468399, -0.04900594428181648, -0.024833722040057182, -0.05733707174658775, -0.11574776470661163, -0.03775808587670326, -0.0026978047098964453, -0.053989071398973465, -0.019951166585087776, 0.016794562339782715, 0.05296573415398598, -0.11288191378116608, -0.00422299187630415, -0.05332356318831444, 0.03558342531323433, -0.008187402039766312, 0.0029999481048434973, 0.046071913093328476, 0.12792858481407166, 0.056380126625299454, -0.017676014453172684, 0.008159489370882511, 0.0386226512491703, 0.04925007000565529, -0.022979455068707466, 0.0012860981514677405, 0.008291823789477348, 0.042775705456733704, -0.036764033138751984, 0.06618399173021317, -0.0059679714031517506, -0.05096149444580078, -0.1078396737575531, -0.01847890205681324, -0.008607745170593262, -0.03724171593785286, 0.01786087080836296, -0.05623830109834671, 0.014717315323650837, 0.03236553072929382, 0.023443786427378654, 0.0610223263502121, -0.054481133818626404, -0.08188574761152267, 0.021607503294944763, 0.015429800376296043, -0.04227650538086891, -0.08193457871675491, 0.08870489150285721, -0.0335962288081646, -0.09586744010448456, 0.04866303503513336, 0.04301472008228302, 0.02371213212609291, -0.02381194569170475, -0.08701039105653763, -0.05766821652650833, -0.0297545175999403, 0.0026361101772636175, -0.0183409396559, -0.0005484208813868463, 0.03809252381324768, 0.0031027698423713446, 0.05642169341444969, -0.01720753125846386, -0.017762236297130585, -0.018975043669342995, 0.011609258130192757, 0.04484853148460388, 0.02511034905910492, -0.021191813051700592, -0.04247088357806206, -0.008507843129336834, 0.022144703194499016, 0.1176355630159378, 0.02021271176636219, -0.024203838780522346, 0.04201295226812363, 0.04686763510107994, 0.009999925270676613, 0.03748738393187523, 0.011186075396835804, -0.07717254757881165, -0.023936519399285316, 0.0282679945230484, 0.008129307068884373, 0.02429807186126709, -0.05281626805663109, -0.007268826477229595, 0.10849574208259583, -0.01610844023525715, -0.005269449204206467, 0.019046086817979813, -0.009167023934423923, 0.029180806130170822, 0.03043636493384838, 0.05427836254239082, 0.03998997062444687, 0.020702479407191277, 0.06918158382177353, -0.036435939371585846, 0.004566258285194635, 0.04845895990729332, -0.01648016646504402, -0.040954217314720154, 0.03332953527569771, -0.056045256555080414, 0.017498228698968887, -0.05850452557206154, -0.054683536291122437, -0.0485747866332531, 0.0029394133016467094, -0.013057957403361797, 0.004878097679466009, 0.0025186093989759684, 0.06309937685728073, -0.06557408720254898, 0.13932473957538605, -0.016394848003983498, 0.007513988763093948, -0.04305160418152809, 0.010435479693114758, -0.012754696421325207, 0.055584684014320374, -0.016393018886446953, -0.038565464317798615, -0.057282645255327225, -0.008256486617028713, -0.021079426631331444, -0.0457666739821434, 0.08020129799842834, 0.03536827117204666, 0.024916604161262512, -0.047969065606594086, -0.031878482550382614, 0.050540413707494736, -0.016598299145698547, -0.0631709098815918, 0.03707078844308853, -0.01897915080189705, 0.10107225179672241, -0.0032390097621828318, -0.003908486105501652, 0.03864622488617897, -0.011371252126991749, -0.008891365490853786, -0.05132357031106949, -0.03941508010029793, -0.0026221273001283407, 0.07156059890985489, -0.08144870400428772, 0.09399896115064621, 0.015254489146173, -0.02744925022125244, -0.04279790818691254, -0.006785565987229347, 0.005495587829500437, 0.021669991314411163, 0.007071445696055889, -0.00786448922008276, -0.023067792877554893, -0.012119115330278873, -0.018200373277068138, -0.0271891001611948, -0.011372184380888939, -0.009826915338635445, -0.011628427542746067, 0.016457103192806244, -0.02441328577697277, 0.011589958332479, -0.004416205454617739, -0.0038232929073274136, -0.03666800633072853, 0.014611676335334778, -0.02431492507457733, 0.004614732693880796, -0.014987141825258732, 0.025998953729867935, -0.024872219190001488, 0.035996682941913605, -0.008699391968548298, 0.008897896856069565, -0.015006788074970245, 0.015237956307828426, -0.06615272164344788, -0.05327601358294487, -0.02836555615067482, 0.005366715136915445, -0.016499120742082596, -0.010782529599964619, -0.01884908229112625, 0.013325398787856102, 0.019675657153129578, -0.027368441224098206, -0.032181888818740845, -0.03422543406486511, 0.020646313205361366, -0.030822640284895897, 0.02833297848701477, 0.0055987220257520676, 0.028035499155521393, -0.04998384788632393, -0.014281246811151505, 0.028090717270970345, 0.06561194360256195, -0.10602040588855743, -0.030641766265034676, -0.026990309357643127, 0.06561412662267685, -0.018039092421531677, -0.026583576574921608, 0.029244735836982727, -0.020969627425074577, 0.012185790576040745, -0.009548593312501907, 0.010132251307368279, -0.0024248084519058466, 0.0015640186611562967, 0.0020473722834140062, -0.01591850258409977, -0.008373387157917023, 0.014142998494207859, 0.01362431887537241, 0.014919677749276161, 0.00524230906739831, 0.012831208296120167, -0.008103970438241959, 0.015227646566927433, -0.01931886188685894, -0.020793544128537178, 0.04133661463856697, -0.009683676064014435, 0.03802676126360893, 0.049805957823991776, -0.049359239637851715, -0.05685802921652794, 0.02503175102174282, -0.022298596799373627, 0.02528311312198639, -0.0019475853769108653, -0.01748913899064064, -0.022718356922268867, -0.0016887490637600422, -0.006149748340249062, 0.06422346830368042, 0.008443606086075306, -0.007769245188683271, 0.023611756041646004, -0.017399806529283524, 0.003219852689653635, -0.01748231053352356, 0.005777661222964525, -0.047058723866939545, 0.04873340204358101, -0.047176044434309006, -0.07269556820392609, 0.01813361421227455, 0.001101674628444016, 0.03982750326395035, -0.03201504051685333, 0.0070783114060759544, -0.04101280868053436, 0.028170060366392136, 0.04771733656525612, -0.003569865832105279, -0.038701221346855164, 0.019394731149077415, -0.006528152152895927, 0.02732274681329727, -0.04442505165934563, 0.057146959006786346, -0.008121466264128685, -0.0074758511036634445, 0.016858598217368126, 0.004060608334839344, -0.015114124864339828, 0.01261107437312603, 0.008957203477621078, 0.019746268168091774, -0.025642942637205124, 0.02276328206062317, -0.027394477277994156, 0.017009733244776726, 0.04651276394724846, 0.02475515380501747, -0.01650765724480152, -0.00819997489452362, -0.01816052384674549, -0.021101072430610657, -0.032805584371089935, 0.018935421481728554, 0.03130731359124184, -0.011163534596562386, -0.011813156306743622, 0.00003686488344101235, 0.010939395986497402, -0.03783142566680908, 0.015758663415908813, -0.03974076360464096, -0.012587293051183224, -0.016008853912353516, 0.050887156277894974, -0.01583339087665081, -0.023446477949619293, 0.023147767409682274, 0.032082416117191315, -0.038963209837675095, 0.012042730115354061, -0.01281929761171341, 0.027162885293364525, 0.031588826328516006, -0.010205200873315334, -0.028826221823692322, -0.018458381295204163, -0.0064348019659519196, 0.024940140545368195, -0.04501562938094139, -0.004076053388416767, -0.004752351902425289, 0.019955618306994438, 0.026075255125761032, 0.008636393584311008, -0.03321421146392822, 0.017507459968328476, 0.031659722328186035, -0.022080205380916595, -0.007220082450658083, -0.0016626102151349187, -0.009085147641599178, 0.020597191527485847, -0.018739236518740654, 0.05523615702986717, 0.050877783447504044, 0.008291982114315033, -0.0050796507857739925, -0.003932785242795944, -0.021665077656507492, 0.010832837782800198, 0.037006959319114685, -0.023090586066246033, 0.005514529533684254, -0.011431814171373844, 0.007268458139151335, -0.034100260585546494, -0.059937477111816406, 0.01316115166991949, 0.02492303028702736, 0.020210517570376396, -0.009976707398891449, -0.0075372979044914246, 0.028336286544799805, -0.0034050229005515575, -0.006592842750251293, 0.03262950852513313, -0.015697985887527466, 0.06113011762499809, -0.034851375967264175, -0.05335410311818123, 0.004782132338732481, -0.02297806181013584, -0.013369246385991573, -0.01611950993537903, -0.005896579474210739, -0.008819317445158958, 0.011375061236321926, -0.036052003502845764, -0.007608445361256599, -0.031687844544649124, -0.009651238098740578, 0.02425422891974449, 0.013765805400907993, -0.021932728588581085, -0.020437166094779968, -0.008105647750198841, 0.0130707873031497, -0.002851492026820779, -0.013900557532906532, -0.0014942048583179712, -0.02560834027826786, 0.014274969696998596, 0.058709029108285904, -0.005053634289652109, -0.018685566261410713, 0.04042786732316017, -0.02375810407102108, 0.021117400377988815, -0.05999457463622093, 0.05509359389543533, -0.01702316664159298, 0.018343999981880188, 0.003469826653599739, 0.06254459917545319, 0.06996753066778183, -0.016112571582198143, 0.018613802269101143, 0.03828221186995506, -0.035208046436309814, 0.030084652826189995, -0.05944344028830528, -0.016530508175492287, -0.04950684309005737, 0.03472962975502014, 0.04728139191865921, 0.011655631475150585, -0.006028894800692797, 0.0407889224588871, 0.042460840195417404, 0.001354808802716434, -0.005260911770164967, 0.01765299029648304, 0.0455227792263031, -0.014403142966330051, -0.016314415261149406, 0.021834375336766243, -0.023478390648961067, 0.014001867733895779, -0.02030925452709198, -0.05016844719648361, 0.0013722637668251991, -0.01546519249677658, -0.02323729917407036, -0.059877220541238785, 0.05564993619918823, 0.009708570316433907, 0.040948837995529175, -0.008839486166834831, 0.02779996208846569, 0.014361174777150154, 0.004725632257759571, -0.00977829284965992, -0.02578260377049446, 0.038339994847774506, 0.008156451396644115, -0.001527504762634635, -0.007644742261618376, 0.021429412066936493, -0.06425999850034714, -0.030119290575385094, -0.0014707765076309443, 0.04417681694030762, 0.022196413949131966, 0.0011290705297142267, 0.06456786394119263, 0.0307245422154665, -0.015337352640926838, -0.027412012219429016, -0.04353884980082512, 0.027003426104784012, 0.01051520649343729, -0.05004517734050751, 0.02719217911362648, 0.051979854702949524, -0.005561049561947584, -0.015482253395020962, 0.03213822469115257, 0.040271468460559845, -0.025350863113999367, -0.020447200164198875, 0.012373984791338444, 0.004889788571745157, 0.008642853237688541, -0.03824716806411743, -0.022132785990834236, 0.026299187913537025, 0.031123114749789238, 0.04034316912293434, -0.0174968671053648, 0.042904868721961975, 0.013973156921565533, -0.004095056559890509, 0.045859672129154205, -0.01309366337954998, -0.006450798828154802, 0.02424178086221218, 0.04209975525736809, -0.004057498648762703, 0.022682400420308113, 0.004490957595407963, 0.023760152980685234, -0.008160672150552273, 0.037768539041280746, 0.010393569245934486, 0.07983803004026413, 0.0007309905486181378, 0.06634146720170975, 0.020250266417860985, 0.04859701916575432, 0.017155073583126068, 0.03586644306778908, -0.02014041692018509, 0.027139633893966675, 0.054663341492414474, -0.04565604031085968, 0.006935620214790106, 0.049470219761133194, -0.02253134734928608, -0.023651208728551865, -0.015814075246453285, -0.028330452740192413, -0.020400801673531532, -0.021373257040977478, -0.006341468542814255, -0.012753468938171864, 0.023277614265680313, -0.02007804624736309, 0.0036987524945288897, -0.031456854194402695, -0.025165697559714317, -0.010055115446448326, -0.01091127097606659, -0.0009092902764678001, 0.04507390037178993, -0.011564606800675392, 0.016554443165659904, -0.01767321303486824, 0.003242445643991232, 0.0679263100028038, -0.021682722494006157, 0.039182066917419434, -0.009104490280151367, -0.026303019374608994, -0.014285962097346783, -0.03167594596743584, -0.011764513328671455, 0.024144276976585388, 0.035392649471759796, -0.005416389089077711, 0.047146111726760864, 0.015832150354981422, -0.006920213345438242, 0.026060380041599274, -0.01928788051009178, -0.009251466020941734, -0.025311453267931938, -0.037582702934741974, 0.016042858362197876, 0.030406564474105835, -0.019066648557782173, -0.019068725407123566, 0.007564338389784098, -0.007815474644303322, 0.005949248559772968, 0.06142544746398926, -0.0604240745306015, 0.019617648795247078, -0.0016040222253650427, 0.03315962851047516, 0.00780522171407938, 0.049154721200466156, -0.02966129779815674, 0.030860112980008125, 0.038843173533678055, 0.030885662883520126, -0.0013279172126203775, 0.02581389993429184, 0.03341908007860184, -0.008133023045957088, -0.07896098494529724, 0.03491892293095589, -0.02517988346517086, -0.029368050396442413, 0.039527516812086105, -0.017478125169873238, 0.02254500240087509, 0.007373014930635691, 0.034680940210819244, 0.008577536791563034, 0.028558658435940742, -0.007403479889035225, 0.03877175226807594, -0.04066461697220802, -0.05115292966365814, -0.015461022965610027, 0.005124680697917938, 0.0026417209301143885, -0.04632885381579399, 0.020003747195005417, -0.0075606354512274265, -0.002750682644546032, -0.028540298342704773, -0.002733254572376609, 0.014950587414205074, 0.012270992621779442, -0.002732394030317664, -0.031458232551813126, -0.012230558320879936, 0.057887859642505646, 0.008424336090683937, 0.05910024419426918, 0.03459693863987923, 0.028171580284833908, -0.026804013177752495, -0.012910028919577599, -0.03555256873369217, 0.0138095049187541, -0.019984325394034386, 0.0022256788797676563, -0.03095872513949871, -0.01358871441334486, -0.0032607251778244972, 0.013762800954282284, -0.04720699414610863, -0.0012780349934473634, -0.00673680379986763, -0.049730777740478516, 0.0066067371517419815, 0.00508149154484272, 0.06220566853880882, 0.052211564034223557, 0.07375233620405197, -0.015075010247528553, -0.056544844061136246, -0.01261849608272314, -0.06933782994747162, 0.0027200677432119846, 0.0325787253677845, 0.007187459617853165, -0.00005085317025077529, -0.06349777430295944, -0.011935516260564327, -0.028304962441325188, -0.017485352233052254, -0.02226809225976467, -0.0008023695554584265, -0.024807386100292206, 0.026476094499230385, 0.02258162386715412, -0.013877649791538715, 0.02823995240032673, 0.07612934708595276, -0.01819651387631893, -0.012905662879347801, -0.020885171368718147, -0.027770061045885086, -0.02774687483906746, -0.005249079782515764, 0.01498109195381403, 0.0055997720919549465, 0.019357450306415558, 0.01454243529587984, -0.008577913045883179, -0.011152039282023907, -0.022733978927135468, 0.0325932539999485, -0.053615767508745193, -0.005581207107752562, -0.04731952026486397, -0.004099060781300068, 0.01999366283416748, -0.0184288639575243, -0.04681428149342537, 0.03378685936331749, 0.0075158835388720036, 0.021729519590735435, 0.025290613994002342, -0.012027369812130928, -0.0292766522616148, -0.021302061155438423, 0.05257242172956467, 0.003755823941901326, 0.000508192228153348, 0.007191182114183903, 0.016556542366743088, -0.008574035950005054, -0.0005312972352840006 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Results To run the benchmark, we created an infinity container for the EC2 C6i instance (Ice-lake) and optimized a DistilBERT model for sequence classification using Infinity Multiverse. This ice-lake optimized Infinity Container can achieve up to 34% better latency & throughput compared to existing cascade-lake-based instances, and up to 800% better latency & throughput compared to vanilla transformers running on ice-lake. The Benchmark we created consists of 192 different experiments and configurations. We ran experiments for: * Physical CPU cores: 1, 2, 4, 8 * Sequence length: 8, 16, 32, 64, 128, 256, 384, 512 * Batch_size: 1, 2, 4, 8, 16, 32 In each experiment, we collect numbers for: * Throughput (requests per second) * Latency (min, max, avg, p90, p95, p99) You can find the full data of the benchmark in this google spreadsheet: 🤗 Infinity: CPU Ice-Lake Benchmark. In this blog post, we will highlight a few results of the benchmark including the best latency and throughput configurations. In addition to this, we deployed the DistilBERT model we used for the benchmark as an API endpoint on 2 physical cores. You can test it and get a feeling for the performance of Infinity. Below you will find a curl command on how to send a request to the hosted endpoint. The API returns a x-compute-time HTTP Header, which contains the duration of the end-to-end pipeline. bash curl --request POST `-i` \ --url https://infinity.huggingface.co/cpu/distilbert-base-uncased-emotion \ --header 'Content-Type: application/json' \ --data '{"inputs":"I like you. I love you"}'
[ -0.04257281497120857, -0.013339631259441376, -0.007474767975509167, -0.007757627405226231, -0.0009405643213540316, -0.005764350760728121, 0.06928514689207077, 0.08184200525283813, -0.07771986722946167, -0.06472481042146683, -0.018153153359889984, -0.014033829793334007, -0.016148988157510757, 0.053331125527620316, 0.017807234078645706, 0.016271114349365234, 0.013619628734886646, 0.059751447290182114, -0.024342406541109085, 0.032271042466163635, 0.0015640591736882925, -0.0034948624670505524, 0.007969475351274014, 0.028993314132094383, -0.07650087773799896, -0.0063252635300159454, 0.016232643276453018, 0.018220627680420876, -0.04066605120897293, 0.0029727485962212086, -0.07583848387002945, -0.028492789715528488, 0.030583182349801064, -0.011265304870903492, 0.028035910800099373, -0.032635774463415146, -0.11650678515434265, 0.06799004226922989, 0.011658137664198875, -0.022531194612383842, -0.005943302996456623, 0.011754175648093224, -0.08848866075277328, -0.0419619157910347, -0.031573981046676636, 0.09210728108882904, -0.07644251734018326, 0.021065939217805862, -0.019272921606898308, 0.019383404403924942, -0.07752077281475067, 0.025689102709293365, 0.01505581196397543, 0.02688688412308693, 0.08330123871564865, -0.02321700192987919, 0.014592067338526249, -0.031522832810878754, -0.028335416689515114, 0.031907666474580765, 0.043355174362659454, -0.020183663815259933, -0.039846327155828476, -0.04342499002814293, -0.05894111469388008, 0.033152591437101364, -0.07240249961614609, 0.04744952917098999, -0.037380401045084, -0.07961181551218033, 0.0269496887922287, 0.028140481561422348, 0.039409227669239044, 0.012709075585007668, 0.0085305692628026, 0.020402804017066956, -0.07694298028945923, 0.05142321065068245, 0.06562262773513794, 0.09975169599056244, -0.04500195011496544, 0.00744402501732111, -0.00042793157626874745, 0.025234080851078033, 0.035228196531534195, 0.01859956979751587, 0.02399434894323349, 0.0009442130103707314, -0.1634291112422943, -0.0005658456357195973, 0.04146566241979599, -0.06645209342241287, 0.08120644837617874, 0.04335454851388931, 0.0052372426725924015, -0.01432314608246088, 0.004236636217683554, 0.012090074829757214, -0.04890929162502289, 0.04660303145647049, 0.012633427046239376, -0.017167257145047188, -0.048408497124910355, -0.03517833352088928, -0.055254533886909485, 0.047691844403743744, -0.04717070236802101, -0.11647067964076996, -0.033810805529356, -0.014245828613638878, -0.005465437192469835, -0.0012591960839927197, -0.010028166696429253, 0.03275271877646446, -0.12795519828796387, 0.030225947499275208, -0.04002479091286659, 0.01666494831442833, -0.032683733850717545, -0.009621779434382915, 0.018512310460209846, 0.021638724952936172, 0.009379683062434196, -0.10503852367401123, -0.04180838540196419, 0.05090095102787018, 0.011790473014116287, -0.044155608862638474, 0.0089021110907197, 0.0457334965467453, 0.06095169857144356, -0.0295999925583601, 0.1332034468650818, 0.017472507432103157, -0.03230633959174156, -0.08208634704351425, 0.0013503158697858453, -0.069416344165802, 0.02804628573358059, 0.02464566007256508, 0.04520031437277794, 0.024977032095193863, 0.02517084591090679, -0.09212884306907654, 0.07790148258209229, 0.01236681267619133, -0.05901375040411949, 0.001818289514631033, 0.026703007519245148, -0.011838855221867561, -0.11478406935930252, 0.03663437068462372, -0.09488312155008316, -0.04879893735051155, 0.02984130196273327, 0.09974746406078339, -0.007236372213810682, -0.006310860626399517, -0.03225163742899895, -0.035538144409656525, -0.02960166148841381, 0.001888109603896737, -0.0872218906879425, -0.07951758056879044, 0.012557918205857277, -0.008705939166247845, 0.0329771414399147, -0.016996970400214195, -0.07030660659074783, -0.023642299696803093, -0.0042106993496418, 0.030558940023183823, 0.02643636241555214, -0.004833341110497713, -0.009925607591867447, 0.009298708289861679, 0.019806137308478355, 0.034682389348745346, 0.022425735369324684, -0.049156587570905685, -0.016532529145479202, 0.04766680672764778, 0.036922886967659, 0.08731596916913986, 0.039575375616550446, -0.055120278149843216, -0.011778293177485466, 0.007183495443314314, -0.029487403109669685, 0.011977197602391243, -0.015051893889904022, -0.018939446657896042, 0.10258713364601135, 0.003984029870480299, -0.01687437668442726, -0.01052925270050764, -0.02256992645561695, 0.027949098497629166, 0.04112778604030609, 0.046905070543289185, 0.02295004017651081, 0.024659600108861923, 0.08394332230091095, -0.04486388340592384, -0.04151900112628937, -0.030985191464424133, -0.05140528082847595, -0.029807111248373985, -0.026592520996928215, 0.0008047417504712939, 0.026931798085570335, -0.08163143694400787, -0.05497835576534271, -0.04120343178510666, -0.046804431825876236, -0.020667538046836853, 0.003596740309149027, -0.0025545423850417137, 0.044205401092767715, -0.004341104533523321, 0.12468774616718292, -0.015343612059950829, 0.04597652330994606, 0.007691587787121534, 0.01351668406277895, -0.005272216163575649, 0.05461108684539795, 0.01361151598393917, 0.05546052008867264, 0.0019424821948632598, -0.026374241337180138, -0.055088527500629425, -0.059409815818071365, 0.02072490192949772, 0.012017657980322838, -0.03112093359231949, 0.085581474006176, 0.00414650421589613, 0.012147151865065098, 0.059525277465581894, -0.030522949993610382, -0.022013289853930473, -0.005344569683074951, 0.055858854204416275, -0.004921254701912403, -0.0307278111577034, -0.005126819480210543, -0.018902936950325966, -0.030762195587158203, -0.03600660338997841, -0.019995596259832382, 0.04788188263773918, -0.0373234897851944, -0.0453060120344162, 0.09060896933078766, -0.011463205330073833, 0.005787839647382498, 0.038814932107925415, -0.042926885187625885, 0.05407493934035301, 0.005655013956129551, 0.025715146213769913, -0.009663240984082222, -0.01036593783646822, 0.03641068562865257, -0.02123299054801464, -0.017826471477746964, -0.03066941723227501, 0.011170891113579273, 0.0021092602983117104, -0.007375036366283894, 0.03727375343441963, 0.02073094993829727, -0.0005918003735132515, -0.02766687609255314, -0.008527803234755993, -0.00941191241145134, 0.0007897511241026223, 0.0028789383359253407, -0.006595252081751823, 0.013102239929139614, -0.051235638558864594, 0.044491104781627655, 0.025005081668496132, 0.013322090730071068, -0.005947667174041271, 0.013962525874376297, -0.05119694024324417, -0.07033008337020874, 0.030863113701343536, 0.04785315692424774, 0.005508151371032, 0.000969771237578243, 0.0016755531542003155, 0.0053397673182189465, 0.023765182122588158, 0.00003306196958874352, -0.06087000295519829, -0.01849529705941677, 0.04530986398458481, -0.041614361107349396, 0.0021053862292319536, -0.0493985079228878, 0.048343706876039505, 0.0068079885095357895, 0.017735030502080917, 0.015125604346394539, 0.010714483447372913, -0.06698407977819443, -0.03216998279094696, -0.021213289350271225, 0.039616908878088, -0.037267640233039856, -0.03919009864330292, 0.057268623262643814, -0.02150481380522251, -0.00286464998498559, 0.04513271898031235, 0.011744108982384205, -0.002345087006688118, -0.021380892023444176, -0.008823245763778687, 0.001610237406566739, -0.024917349219322205, 0.007185294292867184, -0.015123522840440273, -0.008751105517148972, 0.004978090059012175, 0.009955036453902721, -0.013804673217236996, 0.029969077557325363, -0.020957015454769135, -0.009807759895920753, 0.009912117384374142, 0.016582466661930084, -0.01265384815633297, 0.07125089317560196, -0.06938549876213074, -0.024616122245788574, 0.006411398760974407, -0.020123982802033424, 0.027416512370109558, -0.05681129917502403, -0.031693968921899796, 0.0005801438237540424, 0.025854049250483513, 0.038122981786727905, 0.04106645658612251, 0.012074721977114677, -0.0193036999553442, 0.032389599829912186, -0.0033936696127057076, 0.06833221763372421, -0.016747931018471718, 0.03841739520430565, -0.03219005465507507, 0.009652641601860523, 0.002301522297784686, -0.05254291370511055, 0.037393469363451004, -0.007199656683951616, 0.07228468358516693, 0.0031863271724432707, -0.0023555979132652283, -0.029615722596645355, 0.023793354630470276, 0.002128709340468049, -0.0230967216193676, -0.00978817604482174, 0.02550899051129818, -0.007648448459804058, 0.0044065676629543304, -0.010206708684563637, 0.044858016073703766, -0.03407047316431999, -0.012353315949440002, -0.024243874475359917, 0.014089157804846764, -0.0023435261100530624, 0.021715613082051277, -0.016017988324165344, 0.0020379959605634212, -0.020525967702269554, -0.02925931289792061, -0.02035832405090332, -0.019144032150506973, 0.01034172996878624, 0.06371094286441803, -0.05025036633014679, -0.022419659420847893, -0.02103838138282299, -0.0007653056527487934, 0.01791710965335369, 0.013019312173128128, 0.009437844157218933, -0.04885352402925491, 0.01791689172387123, -0.009700325317680836, 0.014044761657714844, 0.001281560049392283, -0.0003247088461648673, -0.03845115751028061, -0.03245855122804642, -0.05368442088365555, 0.03870353847742081, 0.009264953434467316, -0.015410993248224258, 0.019734468311071396, 0.018922969698905945, 0.029964065179228783, 0.012086006812751293, 0.026109520345926285, 0.02112659253180027, -0.015222012996673584, -0.02792372554540634, -0.04072646424174309, 0.00273047829978168, 0.01488824374973774, 0.009646122343838215, -0.025766296312212944, 0.000981976743787527, 0.00047576139331795275, 0.017853068187832832, 0.023229490965604782, 0.0431809164583683, 0.0021378006786108017, 0.002378933597356081, 0.03037117049098015, -0.01117024477571249, 0.0030168385710567236, -0.015719270333647728, 0.018426746129989624, 0.03846297413110733, 0.018252817913889885, 0.01563052088022232, 0.023772265762090683, 0.026948848739266396, -0.0157021414488554, -0.01632259227335453, -0.03882783651351929, 0.03133957087993622, 0.023869631811976433, -0.0031466030050069094, -0.014374131336808205, -0.006599907763302326, -0.021832887083292007, -0.0036761558149009943, -0.026797033846378326, 0.027812570333480835, -0.018961919471621513, -0.012324230745434761, -0.001488388399593532, -0.010054183192551136, 0.04988711699843407, 0.038153767585754395, -0.008481969125568867, 0.0022927632089704275, 0.006889187730848789, -0.01437913253903389, -0.018387766554951668, -0.008941279724240303, 0.016077667474746704, 0.019238147884607315, 0.02078855410218239, -0.04223897308111191, 0.02474212273955345, -0.005195466801524162, 0.025634262710809708, 0.008134739473462105, 0.03194165602326393, -0.022814815863966942, -0.03119366616010666, 0.018346324563026428, 0.05222071707248688, -0.026103626936674118, -0.027232700958848, 0.006934512406587601, -0.005310931243002415, -0.0321701243519783, -0.01066669076681137, -0.013977309688925743, -0.0034092881251126528, 0.019975047558546066, 0.07765475660562515, 0.017993763089179993, -0.008098208345472813, 0.040902674198150635, 0.054464612156152725, -0.03839569166302681, -0.03352862969040871, 0.021326418966054916, -0.029043294489383698, 0.02211756631731987, -0.02486020140349865, 0.07877656072378159, 0.05812453478574753, 0.006847141310572624, 0.047490835189819336, 0.017837150022387505, 0.000637414341326803, 0.02697581984102726, -0.0420350506901741, 0.015813695266842842, -0.035018231719732285, 0.021045969799160957, 0.04919413849711418, 0.011510752141475677, 0.006347728427499533, 0.05838247016072273, 0.045051347464323044, -0.025742003694176674, 0.008737500756978989, 0.04561273753643036, 0.04035817086696625, -0.00941766519099474, -0.016957411542534828, 0.009769567288458347, -0.050908930599689484, 0.005921431817114353, 0.013852548785507679, -0.05468900501728058, -0.0020595123060047626, 0.008154279552400112, 0.022122396156191826, -0.020962152630090714, 0.061466284096241, 0.023791320621967316, 0.02617272362112999, -0.01384811196476221, 0.00756295258179307, 0.021222833544015884, -0.026204479858279228, -0.0610981360077858, -0.02471904456615448, 0.030906999483704567, -0.0288641806691885, -0.03656863793730736, 0.00311678065918386, 0.04631989449262619, -0.03892456367611885, -0.01946997083723545, 0.004460956435650587, 0.0256805382668972, -0.004118050914257765, 0.04362185671925545, 0.03420879319310188, 0.03722862899303436, -0.037793852388858795, -0.01506501343101263, -0.03577953949570656, 0.009644250385463238, -0.016782516613602638, -0.04460977390408516, 0.04754549637436867, 0.06682860106229782, -0.010540765710175037, -0.0262791495770216, 0.016124118119478226, 0.032926857471466064, -0.03467677906155586, -0.037372294813394547, -0.0063894218765199184, 0.0009478291030973196, -0.009754659608006477, -0.004499205853790045, -0.002959455829113722, 0.04841860756278038, 0.04527296870946884, -0.015205444768071175, -0.004577815532684326, 0.03811865672469139, 0.03906043618917465, -0.013471580110490322, 0.012053885497152805, -0.0023245729971677065, -0.03906673938035965, 0.04229767993092537, 0.013835172168910503, -0.01962754875421524, -0.007868357002735138, 0.02084924466907978, -0.03698132932186127, -0.000585292000323534, 0.022308360785245895, 0.020116696134209633, 0.07000508159399033, 0.0018011535285040736, 0.021301427856087685, 0.04750897362828255, 0.0518561489880085, 0.02993781678378582, 0.03255075961351395, 0.01748480647802353, 0.002761511132121086, -0.004111252725124359, -0.002178581664338708, 0.040664538741111755, 0.03485385701060295, -0.01700015924870968, 0.011347769759595394, -0.007831737399101257, -0.0439702570438385, 0.012417267076671124, -0.025219935923814774, -0.0031466358341276646, -0.005047712940722704, -0.012772494927048683, -0.04152225703001022, 0.03207571431994438, 0.025823518633842468, 0.0028199206572026014, 0.005207565147429705, -0.012713083066046238, 0.012017901986837387, 0.0007632903289049864, -0.018703728914260864, 0.02316470630466938, -0.03259975463151932, -0.03744778037071228, 0.04647878184914589, -0.01134525891393423, 0.01557848323136568, 0.006182575598359108, 0.0027569434605538845, -0.0261622853577137, -0.01736036129295826, 0.00873221643269062, 0.021467790007591248, 0.005934520158916712, 0.01226358488202095, 0.014180018566548824, 0.00943063572049141, 0.015936853364109993, 0.04254142940044403, 0.004066846799105406, -0.01158609613776207, 0.0002534749801270664, 0.023960769176483154, 0.0045852079056203365, 0.014739485457539558, -0.018220702186226845, -0.0029776778537780046, 0.012650812044739723, -0.006312713027000427, 0.02883164770901203, 0.028844758868217468, -0.0790310800075531, -0.01806028001010418, -0.005004694685339928, 0.005808482877910137, 0.006397792603820562, 0.056901965290308, -0.05540831759572029, 0.008629837073385715, 0.016682179644703865, 0.03100617416203022, 0.049071572721004486, -0.0047516305930912495, 0.018545661121606827, 0.0403173565864563, 0.006742628291249275, 0.0003646182012744248, -0.022510021924972534, -0.02938457764685154, 0.06164873018860817, -0.031238147988915443, 0.007176178973168135, 0.009664016775786877, 0.0352240651845932, -0.013681369833648205, 0.04602794349193573, -0.001104979426600039, 0.013152815401554108, -0.030954601243138313, -0.006823103874921799, -0.02570459246635437, 0.027550039812922478, -0.03099150024354458, -0.06321448087692261, -0.010613146238029003, -0.02951161004602909, 0.030437659472227097, -0.029067708179354668, -0.017559941858053207, 0.011011735536158085, -0.02665892243385315, -0.048293307423591614, -0.0035275809932500124, -0.038135163486003876, 0.02115866355597973, 0.03670120611786842, 0.05580788105726242, 0.029576314613223076, 0.048058245331048965, 0.0011664708144962788, 0.06590249389410019, -0.04255632683634758, 0.003265372011810541, -0.02813633903861046, 0.0629035085439682, -0.013081063516438007, -0.019910722970962524, 0.017088331282138824, -0.0018815165385603905, -0.057977233082056046, -0.01220622006803751, -0.03049708530306816, -0.0555325448513031, 0.011205355636775494, -0.0038422371726483107, 0.044402413070201874, 0.05948586016893387, 0.03538062795996666, 0.034404560923576355, -0.07239504158496857, -0.006911744363605976, -0.05381311476230621, -0.008070756681263447, 0.041012875735759735, 0.009961353614926338, 0.006861340720206499, -0.03901728615164757, -0.030719086527824402, 0.03172022104263306, -0.020661739632487297, -0.0070670368149876595, -0.033923693001270294, -0.017982380464673042, -0.02889009192585945, 0.032405175268650055, 0.012943265959620476, 0.02597234584391117, 0.05402759462594986, 0.0029694954864680767, -0.02077818475663662, 0.01909010484814644, -0.01892838627099991, -0.026739193126559258, -0.010440835729241371, -0.005310169421136379, -0.005171499215066433, 0.0674547478556633, 0.020356053486466408, 0.03179534524679184, -0.037424344569444656, 0.03213489055633545, 0.046521928161382675, -0.07100755721330643, -0.02707979828119278, -0.01821710914373398, 0.018046831712126732, -0.026030510663986206, -0.023230671882629395, -0.005200428422540426, 0.0650918185710907, -0.0038308212533593178, 0.009501196444034576, -0.011874232441186905, -0.056134164333343506, 0.0019248109310865402, -0.028078114613890648, 0.01324190478771925, -0.012700906954705715, 0.0043990472331643105, 0.09890166670084, 0.011623993515968323, -0.017533792182803154, 0.008070929907262325 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
What is Hugging Face Infinity Hugging Face Infinity is a containerized solution for customers to deploy end-to-end optimized inference pipelines for State-of-the-Art Transformer models, on any infrastructure. Hugging Face Infinity consists of 2 main services: * The Infinity Container is a hardware-optimized inference solution delivered as a Docker container. * Infinity Multiverse is a Model Optimization Service through which a Hugging Face Transformer model is optimized for the Target Hardware. Infinity Multiverse is compatible with Infinity Container. The Infinity Container is built specifically to run on a Target Hardware architecture and exposes an HTTP /predict endpoint to run inference. Figure 1. Infinity Overview An Infinity Container is designed to serve 1 Model and 1 Task. A Task corresponds to machine learning tasks as defined in the Transformers Pipelines documentation. As of the writing of this blog post, supported tasks include feature extraction/document embedding, ranking, sequence classification, and token classification. You can find more information about Hugging Face Infinity at hf.co/infinity, and if you are interested in testing it for yourself, you can sign up for a free trial at hf.co/infinity-trial. ---
[ 0.009747276082634926, -0.04652533307671547, 0.039029333740472794, -0.05283885821700096, 0.030507953837513924, 0.04697253927588463, 0.015878766775131226, 0.1256200075149536, -0.0677124410867691, 0.02460315078496933, -0.08037544786930084, 0.031099244952201843, -0.03584162890911102, 0.0857602134346962, -0.01798371970653534, -0.02187288925051689, 0.09057176113128662, 0.04242706671357155, -0.06600506603717804, 0.0576368011534214, -0.021102948114275932, -0.01920444145798683, 0.0446288026869297, -0.03826747462153435, -0.06036696583032608, -0.049672190099954605, 0.02047588676214218, -0.014579682610929012, 0.04631732404232025, 0.054125674068927765, -0.10475979745388031, -0.02747861109673977, -0.02225004881620407, -0.044831663370132446, 0.0566486194729805, -0.0371236726641655, -0.15111571550369263, 0.04767809063196182, 0.002482071751728654, -0.01748758740723133, -0.002627516398206353, 0.00475215632468462, -0.07871952652931213, -0.04360561817884445, 0.018008986487984657, -0.0074537768959999084, -0.14440342783927917, 0.0877700224518776, -0.009902133606374264, -0.009515179321169853, -0.05128740146756172, 0.09722711145877838, -0.017225593328475952, 0.006627841852605343, 0.06304209679365158, 0.02216547355055809, -0.037798862904310226, -0.04927774891257286, 0.011168841272592545, -0.00020134254009462893, 0.035993609577417374, -0.003070515114814043, 0.037710342556238174, 0.008038981817662716, -0.051658038049936295, -0.018983354791998863, -0.032902464270591736, -0.010359862819314003, -0.033330000936985016, -0.048974983394145966, -0.03768583759665489, 0.03055609203875065, -0.020857008174061775, 0.022036973387002945, -0.0026890162844210863, -0.047583263367414474, -0.04867769405245781, 0.01986420527100563, 0.043962184339761734, 0.028095223009586334, -0.02615942433476448, 0.030570322647690773, 0.0207920353859663, 0.03798319026827812, 0.01972307078540325, 0.025843238458037376, -0.01547409500926733, -0.0008247539517469704, -0.12048892676830292, 0.1288331151008606, 0.08648533374071121, -0.12998193502426147, -0.02071581594645977, -0.008127326145768166, 0.02879607304930687, 0.018245281651616096, 0.01594066247344017, 0.026750510558485985, -0.006323983892798424, 0.02681967057287693, 0.0031327581964433193, -0.02446279302239418, -0.05214279890060425, -0.026721790432929993, -0.01137582678347826, 0.044352639466524124, 0.014180311933159828, -0.079164057970047, -0.05443805083632469, -0.003971261437982321, -0.0313667431473732, -0.06848117709159851, 0.01999351941049099, 0.06917894631624222, -0.10400494188070297, 0.06743865460157394, -0.01303898636251688, 0.028836479410529137, 0.017792586237192154, 0.0036098649725317955, 0.014719418250024319, 0.0689741000533104, 0.006717291194945574, -0.04077599570155144, 0.018258437514305115, 0.030787883326411247, -0.005349223036319017, -0.04774588346481323, -0.009339531883597374, -0.023180412128567696, 0.005781121086329222, -0.04043670371174812, 0.03919186443090439, 0.017192227765917778, -0.040395405143499374, -0.06362738460302353, 0.021599598228931427, -0.054927073419094086, 0.06823380291461945, -0.015498701483011246, -0.011627093888819218, -0.0023677677381783724, 0.058425772935152054, -0.01870725490152836, 0.07527530193328857, -0.05703939497470856, -0.028321770951151848, 0.07479852437973022, 0.004475973546504974, -0.013788079842925072, -0.07748378813266754, 0.0648985281586647, -0.0306719858199358, -0.07422637194395065, 0.0453268364071846, 0.04719782620668411, 0.020553531125187874, -0.015477117151021957, -0.01602049171924591, -0.044293392449617386, -0.056836966425180435, -0.04601095989346504, -0.06380721181631088, 0.013573797419667244, 0.006705779582262039, 0.0343642495572567, 0.0020759033504873514, 0.05127865821123123, -0.007978720590472221, -0.010654198005795479, 0.0110034653916955, -0.03298715129494667, 0.055627621710300446, -0.03376399353146553, 0.02451041340827942, 0.010110057890415192, 0.07597663253545761, 0.046452078968286514, -0.008693588897585869, 0.012772482819855213, -0.024146033450961113, 0.10874811559915543, 0.03691813722252846, 0.05355833098292351, 0.050582144409418106, -0.07304558902978897, -0.02632543444633484, 0.03566669672727585, 0.03157088905572891, -0.00131983554456383, -0.055264610797166824, -0.011275318451225758, 0.04550330340862274, -0.021183079108595848, 0.042811717838048935, -0.03594626486301422, -0.0594981350004673, 0.06259264051914215, 0.002911516698077321, 0.07134708762168884, 0.049756504595279694, 0.02033061534166336, 0.06331270188093185, -0.04196275770664215, -0.032818105071783066, 0.037835653871297836, 0.027398137375712395, -0.03873848170042038, 0.0035851020365953445, 0.012486839666962624, 0.07153121381998062, -0.14819499850273132, -0.005381049122661352, -0.008523478172719479, 0.04621235653758049, -0.030400680378079414, -0.04359041526913643, -0.0016717236721888185, -0.010015892796218395, -0.03760244697332382, 0.16377350687980652, -0.06404522061347961, 0.0006036824779585004, -0.0515151210129261, -0.023503132164478302, -0.015373333357274532, 0.08655146509408951, 0.008640527725219727, 0.05707315728068352, -0.031430914998054504, -0.03493596613407135, -0.027757972478866577, -0.054480571299791336, 0.017152156680822372, 0.06833551824092865, 0.0050277127884328365, 0.06393847614526749, 0.002366730710491538, 0.036155786365270615, 0.028048181906342506, -0.020659346133470535, -0.007398320361971855, 0.000892849056981504, 0.05075298249721527, 0.04414800554513931, -0.02597792074084282, 0.031211869791150093, -0.005399344954639673, -0.03107346035540104, -0.03332199156284332, 0.015905259177088737, 0.00005129456258146092, 0.00713249621912837, -0.017918672412633896, 0.07490580528974533, 0.00816008448600769, 0.017515193670988083, -0.02067330852150917, -0.02521643042564392, 0.051140766590833664, -0.014729280956089497, -0.020299337804317474, 0.01597268134355545, -0.052086248993873596, -0.02444322779774666, -0.014971193857491016, -0.0025615147314965725, 0.005127487704157829, -0.02127748169004917, 0.028321005403995514, 0.036926139146089554, -0.03143088147044182, 0.004570751450955868, -0.017443446442484856, 0.008806443773210049, 0.00856988038867712, 0.03358740732073784, 0.010775201953947544, -0.028853055089712143, -0.03210660070180893, -0.003822621423751116, -0.018825583159923553, 0.013834563083946705, 0.032536640763282776, 0.0324026383459568, -0.03529516980051994, 0.005904071033000946, -0.041270241141319275, -0.05288556590676308, 0.02363678067922592, 0.013451598584651947, 0.017953142523765564, -0.023958509787917137, -0.000019935203454224393, -0.022490795701742172, 0.010719121433794498, 0.03363047167658806, -0.03917230665683746, -0.04291214421391487, 0.026842376217246056, -0.017166944220662117, -0.010685469023883343, -0.005736167076975107, 0.012719981372356415, -0.004701557569205761, 0.0686841532588005, 0.03696030005812645, 0.012107501737773418, -0.09756942838430405, -0.03474864363670349, -0.01346617005765438, 0.028555918484926224, -0.03792000189423561, -0.012618659995496273, 0.05331152677536011, -0.002878614468500018, 0.021836867555975914, 0.005182249005883932, 0.027807071805000305, 0.021072503179311752, 0.04128892347216606, -0.030923934653401375, -0.025207189843058586, -0.005225960165262222, 0.023299193009734154, -0.018966570496559143, 0.017369020730257034, 0.03097902424633503, -0.045775193721055984, -0.001785729080438614, 0.021378057077527046, -0.010565483942627907, 0.012036745436489582, -0.021425515413284302, 0.03931041061878204, -0.004755748901516199, 0.011166048236191273, -0.015753310173749924, -0.017163336277008057, 0.0017239819280803204, -0.06562614440917969, -0.008092713542282581, -0.02229924127459526, 0.019430698826909065, 0.0019304853631183505, 0.002323833527043462, 0.025826100260019302, 0.009375736117362976, 0.003458058927208185, -0.01938251405954361, -0.007176836486905813, -0.007270549889653921, 0.0428580567240715, -0.02411540411412716, -0.020490633323788643, -0.0396391898393631, 0.02900010161101818, -0.015037866309285164, -0.04269092157483101, -0.0034962939098477364, 0.008951526135206223, 0.036891937255859375, 0.0016114362515509129, 0.004499762784689665, -0.011566520668566227, 0.006568466313183308, 0.02423769049346447, 0.004809476900845766, -0.06203305721282959, 0.004143523517996073, -0.038993239402770996, -0.025697188451886177, -0.04087269678711891, 0.013119283132255077, 0.007269490510225296, -0.03908681869506836, 0.035282306373119354, 0.014038176275789738, 0.005107077769935131, 0.05485549941658974, -0.020198950543999672, 0.014502724632620811, -0.02747485227882862, 0.0003946551005356014, -0.004789224360138178, -0.039322227239608765, 0.06020385026931763, 0.0042378404177725315, -0.03220164030790329, -0.01745670475065708, -0.005136674270033836, 0.01083745900541544, 0.017549661919474602, -0.008052391931414604, 0.03780869394540787, -0.029157452285289764, 0.01232732180505991, 0.05507547780871391, -0.01736138015985489, -0.025050275027751923, 0.04930467903614044, -0.002629477297887206, -0.010943148285150528, 0.015232243575155735, -0.013118510134518147, 0.020137930288910866, -0.00899207778275013, -0.029320014640688896, 0.006633139681071043, -0.03688906505703926, -0.0028561365325003862, -0.01200125738978386, -0.023874545469880104, 0.021805085241794586, 0.0034608414862304926, -0.034205950796604156, 0.018067948520183563, 0.002129465574398637, 0.046724289655685425, -0.006821960210800171, -0.02461932972073555, -0.01997399516403675, 0.048030659556388855, 0.02013816498219967, 0.009363594464957714, -0.018980341032147408, -0.010674698278307915, 0.01263381913304329, -0.003101321402937174, 0.008520104922354221, 0.000006982613285799744, -0.034833088517189026, 0.02536064200103283, 0.024861911311745644, 0.04184558242559433, -0.0025239386595785618, -0.00867663137614727, -0.013655683025717735, -0.007041632197797298, 0.0009657396585680544, 0.06565916538238525, 0.010783643461763859, 0.015060428529977798, -0.02293439581990242, -0.020445700734853745, -0.0024672825820744038, 0.0010845846263691783, -0.01649131067097187, 0.012907830998301506, -0.0031774139497429132, 0.03566842898726463, -0.00977740902453661, -0.015696140006184578, 0.05135384574532509, -0.06313265860080719, 0.02206149324774742, -0.024362808093428612, 0.013056235387921333, 0.013661817647516727, -0.020286748185753822, -0.048948984593153, 0.030946942046284676, 0.05296196788549423, -0.010163758881390095, -0.048977483063936234, 0.005005070939660072, -0.006163282785564661, 0.030538026243448257, 0.021741440519690514, 0.0029417790938168764, -0.02724422700703144, 0.002948032459244132, 0.027747798711061478, -0.012432392686605453, 0.0075492095202207565, -0.0301663801074028, -0.03642064332962036, 0.036863211542367935, -0.057576049119234085, -0.003298513824120164, 0.03343440592288971, -0.028121687471866608, -0.020400812849402428, 0.08273076266050339, 0.02337488904595375, -0.02455027401447296, -0.008664628490805626, 0.029438968747854233, 0.0006049974472261965, -0.0200128685683012, 0.026182591915130615, -0.01332709938287735, 0.02849503420293331, -0.0017503687413409352, 0.08126024901866913, 0.05590454488992691, -0.014412508346140385, 0.030509065836668015, 0.02545635960996151, -0.014437488280236721, 0.007321574725210667, -0.035180117934942245, -0.003638124791905284, -0.015227509662508965, 0.014712817966938019, 0.03435890004038811, 0.02977701649069786, -0.005531208124011755, -0.0035605940502136946, 0.03237675875425339, -0.0335361585021019, 0.0031273372005671263, 0.029381809756159782, 0.004666854161769152, 0.008399962447583675, -0.02264363132417202, 0.07160493731498718, 0.008910167962312698, -0.00956999883055687, -0.0075932894833385944, -0.02401905134320259, -0.007143552415072918, -0.019457653164863586, -0.01848806068301201, -0.022308962419629097, 0.008355692028999329, 0.02976761944591999, 0.011635174043476582, -0.009353418834507465, 0.002763978438451886, 0.027592839673161507, -0.042315565049648285, -0.017138410359621048, -0.04117859899997711, 0.038439057767391205, -0.03534320741891861, -0.0038940750528126955, -0.007586502004414797, 0.040889859199523926, -0.0197403933852911, 0.000027511812731972896, -0.030801214277744293, 0.035068579018116, 0.019911721348762512, -0.006371539086103439, 0.05333510786294937, 0.0327284075319767, -0.014976601116359234, -0.01873365417122841, -0.028168439865112305, 0.01000487245619297, -0.023187926039099693, -0.04491472616791725, 0.00973476842045784, 0.06995628029108047, 0.010076693259179592, -0.012027460150420666, 0.02108524553477764, 0.039757415652275085, 0.006464545615017414, -0.00576823391020298, -0.014351333491504192, 0.011010951362550259, 0.014970476739108562, -0.00014484222629107535, -0.0050831446424126625, 0.006855851970613003, 0.019253531470894814, 0.016369560733437538, -0.05695059895515442, 0.03161768242716789, 0.011317160911858082, -0.021801797673106194, 0.025692254304885864, 0.012659020721912384, -0.015032981522381306, 0.03949391841888428, 0.05636652931571007, 0.002839989261701703, 0.041524533182382584, 0.04233554005622864, 0.026392469182610512, -0.022782769054174423, 0.01116237509995699, 0.02522045373916626, 0.07568348944187164, 0.005496848840266466, 0.03751460835337639, 0.0519990548491478, 0.040807198733091354, 0.05827030539512634, -0.009750696830451488, 0.016577618196606636, -0.0026495398487895727, 0.08788970857858658, -0.015220102854073048, 0.03840877488255501, -0.0011235648998990655, -0.026224445551633835, -0.030452970415353775, 0.023909559473395348, -0.02418585680425167, -0.019369525834918022, -0.006611652672290802, 0.03323061391711235, 0.01279498916119337, 0.048487190157175064, -0.020934371277689934, 0.036241885274648666, 0.011273680254817009, 0.020582159981131554, -0.03554133325815201, 0.010365513153374195, 0.023357829079031944, 0.012255333364009857, 0.03660997003316879, 0.027955366298556328, -0.003646191442385316, 0.006136718671768904, 0.06597607582807541, -0.013590378686785698, 0.06381092965602875, 0.006761275697499514, 0.040116533637046814, -0.01327250525355339, -0.025640971958637238, -0.03556221351027489, 0.021541379392147064, -0.01802966184914112, -0.019270973280072212, 0.02818104438483715, 0.009477243758738041, -0.023333048447966576, 0.022584108635783195, -0.016114292666316032, 0.019188975915312767, -0.004999522119760513, -0.01069000456482172, 0.016406752169132233, 0.028333008289337158, 0.005099534522742033, -0.040998298674821854, 0.015500437468290329, -0.056956253945827484, 0.02163560874760151, -0.02401808835566044, -0.04776882007718086, -0.01981896162033081, -0.0003493218100629747, -0.013322481885552406, -0.004445425700396299, 0.026909150183200836, 0.010320152156054974, 0.024308182299137115, 0.007405594456940889, 0.05239729955792427, 0.021900523453950882, 0.02757822908461094, 0.04267630726099014, -0.012001783587038517, -0.03421550989151001, -0.021472182124853134, -0.016709506511688232, 0.003545345738530159, -0.006931070704013109, -0.02211523987352848, 0.013468286022543907, -0.029508432373404503, 0.025397393852472305, 0.01009682472795248, 0.049714453518390656, -0.025944678112864494, 0.003239257261157036, 0.005162233952432871, -0.06611385196447372, -0.013766658492386341, 0.03362979739904404, -0.03345537558197975, -0.029202066361904144, 0.024372760206460953, 0.004099708050489426, -0.0053025539964437485, -0.013958809897303581, 0.010093612596392632, 0.042698975652456284, 0.006291162222623825, -0.03138214349746704, -0.008359436877071857, 0.0038824467919766903, 0.043538857251405716, 0.04655787721276283, 0.02693612314760685, 0.017617395147681236, 0.011592677794396877, -0.007987234741449356, 0.033054549247026443, -0.03896263986825943, 0.010595041327178478, -0.03806000575423241, -0.005001773126423359, -0.017338525503873825, -0.025465095415711403, 0.012515715323388577, 0.007126708049327135, -0.03602335974574089, -0.0022713083308190107, -0.01621634140610695, -0.0390593595802784, 0.020514367148280144, 0.018038466572761536, 0.031313348561525345, 0.04170287027955055, 0.014897651970386505, 0.013387295417487621, -0.0019069326808676124, -0.01687724143266678, -0.026502739638090134, 0.007024748250842094, 0.07951417565345764, -0.03436245769262314, 0.02969500608742237, -0.07016726583242416, -0.00886621605604887, 0.015819814056158066, -0.044224388897418976, 0.0038546419236809015, -0.0033839528914541006, -0.02941710874438286, 0.004840424750000238, 0.02368241362273693, -0.009781544096767902, -0.022697847336530685, 0.02783900313079357, -0.0809558779001236, -0.024842187762260437, -0.024696173146367073, -0.013330291956663132, -0.04548073187470436, -0.010095704346895218, -0.014442774467170238, -0.0086752288043499, 0.02063680626451969, 0.0011637172428891063, 0.0021364428102970123, -0.020966552197933197, -0.017039330676198006, 0.031918853521347046, -0.06218811869621277, -0.05462902784347534, -0.049821339547634125, 0.0036089688073843718, 0.0176926888525486, -0.0087079256772995, -0.03904906287789345, 0.008302873000502586, 0.023292629048228264, 0.00010472893336554989, 0.01052889134734869, -0.02324814163148403, -0.010802801698446274, -0.024653360247612, 0.009469069540500641, 0.007955559529364109, 0.045591793954372406, 0.05209827050566673, -0.014884068630635738, -0.03144092857837677, -0.04545202478766441 ]
Case Study: Millisecond Latency using Hugging Face Infinity and modern CPUs
philschmid
January 13, 2022
infinity-cpu-performance
analysis
https://huggingface.co/blog/infinity-cpu-performance
Resources * Hugging Face Infinity * Hugging Face Infinity Trial * Amazon EC2 C6i instances * DistilBERT * DistilBERT paper * DistilBERT model * 🤗 Infinity: CPU Ice-Lake Benchmark
[ 0.012782528065145016, -0.013590910471975803, 0.03318462893366814, -0.012578997761011124, 0.047049909830093384, 0.0475558377802372, 0.03357011824846268, 0.06849028915166855, -0.091040700674057, -0.06968749314546585, -0.04512043297290802, 0.06050686165690422, -0.0024354662746191025, 0.04315003752708435, 0.03992176800966263, -0.005050284788012505, 0.030369717627763748, 0.05054980143904686, -0.0089253606274724, 0.015925386920571327, 0.0015887027839198709, -0.046540677547454834, 0.05051742121577263, 0.020449941977858543, -0.011224918998777866, -0.04438268765807152, 0.030240917578339577, -0.0058393399231135845, -0.03601066768169403, 0.008629963733255863, -0.1248353123664856, -0.015482882969081402, 0.014499555341899395, -0.02198019064962864, 0.04530123621225357, -0.0009998688474297523, -0.12667152285575867, 0.07610039412975311, 0.004562025424093008, -0.033818598836660385, 0.019852744415402412, -0.04966450855135918, -0.06361396610736847, 0.03541230782866478, -0.03688254579901695, 0.040383342653512955, -0.14875443279743195, 0.0801396369934082, 0.005127644166350365, 0.011938300915062428, -0.11123030632734299, 0.07061563432216644, 0.009292567148804665, -0.02443033829331398, 0.03081428073346615, 0.004345644265413284, 0.05335843190550804, -0.02007799781858921, 0.03325217589735985, -0.012123103253543377, 0.1127108484506607, -0.021258875727653503, -0.009214409627020359, 0.017900731414556503, -0.007583166006952524, -0.026687664911150932, -0.04919833689928055, -0.018255142495036125, -0.061690133064985275, -0.010878081433475018, 0.019026264548301697, -0.019783316180109978, -0.005738128442317247, 0.0081237917765975, 0.055503394454717636, -0.03533215820789337, -0.05183418095111847, 0.03365056589245796, 0.05681540071964264, 0.09287918359041214, 0.010204090736806393, -0.020430365577340126, 0.04750163480639458, 0.027936585247516632, 0.03009427897632122, 0.020537909120321274, 0.012678500264883041, -0.0432702898979187, -0.12317527085542679, 0.052472688257694244, 0.020303603261709213, -0.0558948740363121, 0.042358312755823135, 0.016063453629612923, 0.04599582776427269, -0.08658802509307861, 0.02710658870637417, 0.006818867288529873, -0.0017145263263955712, 0.027498457580804825, -0.02580389380455017, -0.018589593470096588, 0.011942485347390175, -0.04087008535861969, -0.04484735056757927, 0.03571903333067894, -0.034678563475608826, -0.09405571967363358, -0.04199628531932831, 0.01639624498784542, -0.027862491086125374, -0.010711093433201313, 0.006222879979759455, 0.033845603466033936, -0.12559783458709717, 0.07345004379749298, -0.009127920493483543, 0.006016697268933058, 0.011640931479632854, 0.03711668774485588, 0.027872281149029732, 0.05192195624113083, 0.022505322471261024, -0.05938291177153587, 0.04239582642912865, 0.07823928445577621, 0.03588392212986946, -0.03558976948261261, -0.032172296196222305, -0.043866273015737534, 0.008401444181799889, -0.05218752846121788, 0.084688201546669, -0.03178960457444191, 0.002267806325107813, -0.06834059953689575, 0.007081598974764347, -0.03331964462995529, 0.03639420121908188, 0.032043058425188065, -0.017833132296800613, 0.03697498142719269, 0.03865490108728409, 0.003496671561151743, 0.0826745554804802, -0.0545833557844162, -0.063229039311409, 0.035629142075777054, -0.008718418888747692, -0.009544184431433678, -0.06956180185079575, 0.05041094869375229, -0.08323667198419571, -0.026641126722097397, 0.027071921154856682, 0.06620801240205765, -0.03495079278945923, -0.05619525536894798, -0.03726859390735626, -0.05544154345989227, -0.03570437803864479, -0.0005369913997128606, -0.05454563722014427, -0.04382423684000969, 0.06175888702273369, -0.017502039670944214, 0.0022682298440486193, 0.03378262370824814, -0.05282193794846535, -0.05826779454946518, -0.010686187073588371, -0.0389135517179966, 0.052480004727840424, 0.012675258331000805, -0.012447251938283443, 0.05326917767524719, 0.04770372435450554, 0.06455247849225998, -0.0039450060576200485, -0.003217392135411501, -0.02795857936143875, 0.004489973187446594, 0.012380659580230713, 0.0639321357011795, 0.04052497074007988, -0.05695236846804619, 0.03385536000132561, -0.000022343247110256925, 0.041532017290592194, 0.002337471814826131, -0.07025448232889175, -0.024187929928302765, 0.11219895631074905, 0.02084711194038391, 0.03368427976965904, -0.04873565584421158, -0.03685080632567406, 0.05893442779779434, 0.01897769793868065, 0.0666026622056961, 0.006843114271759987, 0.0489068403840065, 0.08305876702070236, -0.012996688485145569, -0.10992708802223206, -0.001374024897813797, -0.013374012894928455, -0.020206840708851814, -0.007099381182342768, 0.005337968934327364, 0.04163070768117905, -0.1471908837556839, -0.005091093480587006, -0.049849733710289, -0.026784710586071014, -0.03742519021034241, -0.03507372364401817, -0.007470949087291956, 0.027476098388433456, -0.02895909547805786, 0.1694498360157013, -0.03353317081928253, 0.010449021123349667, 0.0003800410486292094, -0.018219897523522377, 0.03770546242594719, 0.12118462473154068, 0.026730874553322792, 0.08376529067754745, -0.0538981594145298, -0.02147764526307583, -0.029075056314468384, -0.018449852243065834, 0.06917883455753326, 0.021295389160513878, 0.00868863146752119, 0.06873628497123718, -0.01749071106314659, 0.057142600417137146, 0.007350024301558733, -0.030002443119883537, -0.060624875128269196, -0.0002899846585933119, 0.055336736142635345, 0.029363520443439484, -0.03149888291954994, 0.008571604266762733, 0.013279346749186516, -0.08203061670064926, -0.012875521555542946, -0.030630245804786682, 0.06019871309399605, -0.020917052403092384, -0.01528528705239296, 0.0858849585056305, -0.003113307524472475, -0.003821867285296321, 0.006779379211366177, -0.019611475989222527, 0.07403738796710968, 0.025307370349764824, -0.00044848164543509483, -0.02613143064081669, -0.025233194231987, 0.019749315455555916, -0.024876367300748825, -0.007369691040366888, -0.04193609207868576, -0.004202603362500668, 0.027097413316369057, 0.012270358391106129, -0.02840563654899597, 0.03318707272410393, 0.0035634248051792383, -0.020329413935542107, -0.007305507082492113, 0.016436398029327393, -0.002569638192653656, -0.004800078459084034, -0.015994427725672722, 0.00021635690063703805, -0.024995524436235428, 0.051829490810632706, 0.030764395371079445, 0.00207276432774961, -0.006538034416735172, 0.009784605354070663, -0.049016255885362625, -0.03277359902858734, 0.012228219769895077, 0.036600660532712936, 0.010280977003276348, -0.02614590898156166, -0.0018289436120539904, -0.012173621915280819, 0.004134295973926783, 0.014951787889003754, -0.018654484301805496, -0.04628245159983635, 0.021509766578674316, -0.021290455013513565, 0.010633079335093498, -0.04862545430660248, 0.027729004621505737, -0.02345593273639679, 0.034170880913734436, 0.007599946577101946, -0.00436497014015913, -0.11903203278779984, -0.017019910737872124, 0.011274798773229122, 0.056882988661527634, -0.027062585577368736, -0.039600204676389694, 0.04171571880578995, 0.007207721937447786, -0.000765476084779948, 0.006893099285662174, 0.01762734353542328, -0.005038583185523748, 0.0370655432343483, -0.0060543338768184185, -0.0228061955422163, -0.005346478894352913, 0.017290551215410233, -0.0017407075501978397, 0.0013394092675298452, 0.005043139681220055, -0.007071467116475105, 0.06872449815273285, 0.010930769145488739, -0.009436055086553097, -0.009684545919299126, 0.030195090919733047, 0.03405889496207237, 0.01020205020904541, 0.04905875399708748, -0.027471819892525673, -0.018942655995488167, 0.02259036898612976, -0.03693905472755432, 0.0194410253316164, -0.03901993855834007, -0.0036718626506626606, -0.057587627321481705, 0.02372720278799534, 0.04296828433871269, 0.048115529119968414, 0.01436474360525608, -0.019338056445121765, 0.04771454259753227, -0.007263593375682831, -0.0038630631752312183, 0.0019464495126158, 0.00009928572399076074, 0.012117116712033749, 0.03700950741767883, -0.01229478232562542, -0.03651072084903717, 0.006622717250138521, 0.011629964224994183, 0.06552779674530029, 0.013010713271796703, 0.008147303946316242, -0.014482946135103703, 0.04036431759595871, 0.01917514018714428, -0.03701593726873398, -0.029223525896668434, 0.03819692134857178, -0.009829660877585411, 0.0036373583134263754, -0.028639312833547592, 0.008828307501971722, -0.0338779017329216, -0.013833870179951191, -0.03568223863840103, 0.023015251383185387, 0.011977878399193287, 0.020037412643432617, -0.026071663945913315, 0.016721250489354134, -0.02877916768193245, 0.007868535816669464, -0.024093791842460632, -0.01856125146150589, 0.05923234298825264, 0.043511997908353806, -0.05483200028538704, -0.038060512393713, -0.01849411427974701, -0.046687472611665726, 0.009658519178628922, -0.020300084725022316, -0.02002410590648651, 0.007270532660186291, 0.009998171590268612, 0.04662083834409714, -0.01542939804494381, -0.019302239641547203, 0.026570498943328857, -0.013217378407716751, -0.0010392850963398814, -0.02092219702899456, 0.05204501375555992, -0.020038099959492683, -0.018266871571540833, 0.013067053630948067, 0.009082816541194916, -0.02150120586156845, 0.0047736261039972305, 0.011553533375263214, -0.006723170168697834, 0.04038247466087341, -0.04061727970838547, -0.0337279848754406, -0.00336051220074296, 0.005831016693264246, 0.006924684625118971, -0.01783229224383831, -0.01222959067672491, -0.01715659163892269, 0.01075761765241623, 0.015622694045305252, -0.030109934508800507, -0.00980224646627903, 0.0068508777767419815, 0.031746815890073776, -0.02106708474457264, 0.01607486419379711, -0.013911629095673561, -0.01743415929377079, 0.024948332458734512, 0.0028518466278910637, 0.01741182431578636, 0.012087851762771606, -0.0027615749277174473, 0.010688718408346176, -0.028756210580468178, -0.03710229694843292, 0.04929916188120842, 0.03600160777568817, -0.0047532739117741585, -0.008422257378697395, -0.03079395927488804, 0.02260679006576538, -0.011056317016482353, -0.052644871175289154, 0.011838335543870926, 0.03809354081749916, 0.02234278991818428, -0.017899487167596817, 0.028676558285951614, 0.031573764979839325, -0.02884906716644764, 0.001420757733285427, -0.01585034467279911, 0.03501059114933014, 0.015592716634273529, -0.017404647544026375, -0.0467325896024704, 0.06257804483175278, 0.041907086968421936, -0.00522697065025568, -0.03157133236527443, 0.010521995835006237, -0.020552610978484154, 0.04310480132699013, 0.018167447298765182, 0.010031113401055336, -0.03370941802859306, 0.006567457225173712, -0.004339977633208036, -0.006071239709854126, 0.017851179465651512, -0.039016880095005035, -0.0033620845060795546, -0.002502155490219593, -0.023249775171279907, 0.008834591135382652, -0.00353268813341856, -0.006459385622292757, 0.0177321694791317, 0.056173767894506454, 0.053104743361473083, 0.010342068038880825, 0.012122760526835918, 0.05006356164813042, -0.04556244984269142, -0.017482317984104156, 0.015099061653017998, -0.018227580934762955, 0.029773274436593056, 0.012462090700864792, 0.0759442076086998, 0.04809604212641716, 0.028380414471030235, 0.040490057319402695, 0.010495727881789207, -0.00787391234189272, 0.02974538691341877, -0.028994223102927208, 0.0032541672699153423, -0.006002909038215876, 0.013726620934903622, 0.008099793456494808, 0.023189136758446693, -0.02953944355249405, 0.03009173832833767, 0.04598921909928322, -0.03506601229310036, 0.001951380749233067, 0.02034476213157177, 0.022483637556433678, 0.0036625557113438845, -0.03985182195901871, 0.026871319860219955, -0.0553884357213974, -0.03096715360879898, 0.00502538587898016, -0.040091175585985184, -0.030787313356995583, 0.0009734073537401855, 0.0005406678537838161, -0.03184506669640541, 0.008300097659230232, 0.02275114133954048, 0.02497253194451332, -0.012961645610630512, 0.009913476184010506, 0.005258805118501186, -0.015776416286826134, -0.024917051196098328, -0.003332460531964898, -0.004627115558832884, -0.008217214606702328, -0.02627318911254406, 0.028494074940681458, 0.039998605847358704, -0.002872755751013756, 0.009367532096803188, 0.0028606527484953403, 0.0446566566824913, -0.003201498882845044, -0.021202106028795242, 0.045500289648771286, 0.026581784710288048, 0.0021045678295195103, -0.01085053663700819, -0.0037180567160248756, -0.0038123372942209244, -0.030224455520510674, -0.05061915144324303, 0.0021911878138780594, 0.09783855825662613, 0.012287224642932415, -0.004696746822446585, 0.0025922125205397606, 0.020784756168723106, -0.021748697385191917, -0.012388390488922596, -0.019729172810912132, 0.012152893468737602, 0.007740905042737722, -0.008233522064983845, -0.00834841001778841, 0.011011164635419846, 0.0012218845076858997, 0.012369630858302116, -0.01991591788828373, 0.04639967158436775, 0.027230238541960716, -0.04077312350273132, 0.015350542031228542, -0.04330236464738846, -0.039301931858062744, 0.04062332212924957, 0.04436233639717102, -0.004565092269331217, 0.02274618111550808, 0.043588846921920776, -0.02050456404685974, -0.013692806474864483, 0.009707915596663952, 0.02158603072166443, 0.08434616774320602, 0.006447481922805309, 0.014005908742547035, 0.01537693478167057, 0.04579094052314758, 0.0505107119679451, 0.008313785307109356, -0.024490607902407646, 0.004541871603578329, 0.032228920608758926, -0.0035521159879863262, 0.04613958299160004, 0.03739165514707565, 0.010057548061013222, -0.016748780384659767, -0.0230810958892107, -0.03656694293022156, -0.03159863129258156, -0.007972613908350468, 0.00768823130056262, -0.0063013844192028046, 0.008572129532694817, -0.0715859979391098, 0.048992402851581573, 0.030019445344805717, 0.01827537640929222, -0.0014492407208308578, 0.016235066577792168, 0.021357525140047073, -0.0006665359833277762, -0.00047243168228305876, 0.0039099822752177715, -0.02800058200955391, 0.014488590881228447, 0.07519817352294922, 0.0013108319835737348, 0.028529196977615356, 0.004692336544394493, -0.011674301698803902, -0.008377188816666603, -0.043857913464307785, 0.0008958395337685943, -0.011044736951589584, 0.04163985699415207, -0.016946841031312943, -0.0007591791800223291, 0.0140134422108531, -0.013632185757160187, -0.005170125514268875, -0.019672665745019913, 0.022975172847509384, 0.03109932132065296, 0.0022227875888347626, 0.021085117012262344, 0.02076934091746807, -0.008107314817607403, -0.008764046244323254, 0.02518189325928688, 0.01637406274676323, 0.018783489242196083, 0.007699760142713785, -0.0696595087647438, -0.0053812237456440926, 0.008782753720879555, -0.012122388929128647, -0.013745274394750595, 0.026262452825903893, -0.021516142413020134, 0.01917409338057041, 0.005405639763921499, 0.024327905848622322, 0.00829135812819004, 0.019453855231404305, 0.015292812138795853, 0.019048893824219704, -0.024035217240452766, 0.03638743609189987, -0.012603789567947388, -0.012073056772351265, 0.013993735425174236, -0.042406465858221054, 0.01664591021835804, -0.030833322554826736, 0.014472110196948051, 0.019314317032694817, 0.009638096205890179, -0.029545750468969345, -0.005762296263128519, -0.014136185869574547, -0.014401639811694622, -0.020988911390304565, 0.04580553621053696, -0.005331540014594793, -0.035281699150800705, -0.030530866235494614, 0.00047600522520951927, 0.0169368926435709, -0.03661851957440376, -0.017545951530337334, 0.01634466089308262, -0.014352996833622456, -0.05018409714102745, -0.007161600515246391, 0.011383267119526863, 0.020389115437865257, 0.0413372702896595, 0.03324628993868828, 0.038561515510082245, 0.028837498277425766, -0.03072947822511196, 0.03768917918205261, 0.014099754393100739, 0.010863498784601688, -0.04704055190086365, 0.013267667964100838, -0.02079472690820694, -0.05097449943423271, 0.017073290422558784, -0.020530281588435173, -0.06105738505721092, -0.016694501042366028, -0.050831690430641174, -0.045982372015714645, -0.009718975983560085, -0.006292274687439203, 0.0319913811981678, 0.02637721225619316, 0.03886294364929199, 0.022087475284934044, -0.03079577162861824, -0.0004312707169447094, -0.013797285966575146, -0.007009393535554409, 0.030608471482992172, 0.003574698232114315, 0.008980371057987213, -0.047677118331193924, -0.00895027443766594, -0.0037129370030015707, -0.06881296634674072, 0.01073702983558178, -0.01375394407659769, -0.008473656140267849, -0.029504740610718727, -0.02029835246503353, -0.0038494199980050325, 0.035778339952230453, 0.057634804397821426, 0.0017610444920137525, -0.0244358591735363, 0.0014199339784681797, -0.004711615387350321, -0.05791519209742546, 0.0010752086527645588, -0.018194423988461494, -0.007541148457676172, 0.06721030175685883, 0.01824590191245079, 0.004887552931904793, 0.002711297944188118, -0.007896712981164455, 0.032615210860967636, -0.000860191008541733, -0.07068910449743271, -0.01053855661302805, 0.026037557050585747, 0.0012103961780667305, 0.0006600866909138858, -0.06438613682985306, 0.0391814149916172, 0.008678693324327469, -0.014511918649077415, 0.0021850289776921272, -0.041121456772089005, 0.00794866681098938, -0.04125497490167618, 0.03291705995798111, -0.0038607309106737375, 0.03223414719104767, 0.0720689594745636, 0.0014931841287761927, -0.007465100847184658, 0.016504615545272827 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
filename = name of the model zip file from the repository including the extension .zip checkpoint = load_from_hub( repo_id="sb3/demo-hf-CartPole-v1", filename="ppo-CartPole-v1.zip", ) model = PPO.load(checkpoint) # Evaluate the agent and watch it eval_env = gym.make("CartPole-v1") mean_reward, std_reward = evaluate_policy( model, eval_env, render=True, n_eval_episodes=5, deterministic=True, warn=False ) print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")
[ 0.06369892507791519, -0.0375448614358902, -0.0838039293885231, 0.0043264515697956085, 0.07948687672615051, 0.05282578989863396, 0.03030999004840851, 0.03130089491605759, -0.01176392287015915, -0.005236712750047445, -0.08583737164735794, -0.00393566582351923, -0.05540110170841217, 0.02420007437467575, -0.011145710945129395, -0.03298157826066017, -0.010289001278579235, 0.008949500508606434, -0.010020128451287746, 0.09559909254312515, -0.03749346733093262, -0.010682939551770687, -0.015819059684872627, 0.04869598150253296, -0.05773917958140373, -0.005789534654468298, 0.05147048458456993, 0.03659685701131821, -0.035781219601631165, 0.047162845730781555, -0.035665396600961685, -0.061778660863637924, -0.009070953354239464, -0.021456550806760788, 0.021897928789258003, 0.04538640379905701, -0.09179890900850296, 0.04095601662993431, 0.08283615857362747, -0.07258955389261246, 0.04105711355805397, 0.014399252831935883, -0.06084234267473221, -0.021006371825933456, 0.046809498220682144, -0.03552709519863129, -0.08755264431238174, 0.004408789798617363, -0.0034592559095472097, -0.009557867422699928, -0.004854087717831135, 0.06559304147958755, 0.003969630692154169, -0.03358953073620796, 0.0024546498898416758, -0.04833321273326874, -0.05143013224005699, -0.061327528208494186, 0.05756540223956108, 0.0076604015193879604, 0.026311511173844337, 0.04305931553244591, -0.017365314066410065, 0.001940616755746305, 0.005250274669378996, 0.056405264884233475, 0.005548851098865271, -0.00455527612939477, 0.026362251490354538, -0.09644202888011932, -0.037610363215208054, 0.039898522198200226, -0.03624281287193298, -0.01256026141345501, 0.07193505764007568, -0.08423136174678802, 0.013275571167469025, 0.009648707695305347, 0.04308202490210533, 0.05994003266096115, -0.032419536262750626, 0.03372868523001671, -0.008045915514230728, 0.011269726790487766, 0.027371004223823547, -0.01170390099287033, -0.007380847353488207, -0.08788356184959412, -0.03848940506577492, 0.04527611657977104, -0.017556391656398773, -0.04490957409143448, -0.04449049010872841, -0.03135812282562256, 0.01620650850236416, -0.08794201910495758, 0.010644079186022282, -0.026880666613578796, 0.006127694621682167, -0.05089309439063072, 0.007457491476088762, -0.04863401874899864, -0.0029394912999123335, -0.08070464432239532, -0.00225605396553874, 0.06115274503827095, -0.054089318960905075, -0.0732957050204277, -0.08520656079053879, 0.04894433170557022, 0.0475909523665905, -0.019942551851272583, -0.010665121488273144, 0.07893349230289459, -0.019989946857094765, -0.014159251935780048, -0.03732459619641304, 0.010254479013383389, -0.006731300614774227, 0.06401735544204712, -0.041551027446985245, 0.08733139932155609, 0.07106712460517883, 0.013573147356510162, 0.08347464352846146, 0.03102814219892025, -0.029723625630140305, 0.03318913280963898, 0.0015099082374945283, -0.041808076202869415, 0.06047791242599487, 0.04250244051218033, 0.03714268282055855, 0.013272082433104515, 0.005853591486811638, 0.006289673503488302, -0.06763383001089096, -0.036283090710639954, 0.01305339578539133, 0.04021918401122093, -0.030291417613625526, 0.0791570320725441, -0.02754727564752102, 0.06340355426073074, -0.0012932722456753254, -0.014422906562685966, 0.05442472919821739, -0.0050848727114498615, 0.03332924842834473, 0.014464020729064941, 0.0031967428512871265, 0.07210853695869446, 0.055936846882104874, -0.034071050584316254, 0.012506000697612762, 0.04990603029727936, -0.010089912451803684, 0.003548681503161788, -0.03036794625222683, 0.00033282142248936, 0.08644186705350876, 0.015229553915560246, -0.10018569976091385, 0.02060261368751526, -0.018945911899209023, 0.026893585920333862, 0.017060695216059685, -0.022700289264321327, 0.04082350805401802, -0.06935005635023117, 0.014753073453903198, -0.0732734426856041, 0.06719308346509933, 0.04014274850487709, 0.04928773269057274, 0.05342181399464607, 0.05649501830339432, 0.0022036749869585037, 0.04109477251768112, -0.01837412267923355, -0.0024360562674701214, 0.070404551923275, -0.04715563729405403, -0.023349551483988762, 0.005833372473716736, -0.041445501148700714, 0.08998630195856094, 0.00885153841227293, 0.012031667865812778, 0.05849190056324005, -0.06402435153722763, -0.06063947081565857, 0.13393822312355042, -0.06686288863420486, 0.002887939102947712, -0.022844452410936356, 0.0757448673248291, 0.06708241999149323, 0.04951661080121994, -0.025869926437735558, -0.032286182045936584, -0.0004526730044744909, 0.07321608066558838, -0.0676054134964943, -0.026838775724172592, 0.020124074071645737, -0.014200044795870781, -0.026652593165636063, 0.09618386626243591, 0.019261687994003296, 0.0027733822353184223, -0.05312042310833931, 0.10231555998325348, -0.09919451922178268, -0.0010296311229467392, -0.017809733748435974, -0.022881923243403435, -0.01793014444410801, -0.004455765709280968, 0.018606485798954964, 0.0814131572842598, -0.04870685935020447, 0.002607142785564065, -0.04712049290537834, -0.03174600005149841, -0.009950702078640461, -0.004924760665744543, 0.082542285323143, -0.011395676992833614, -0.03404506295919418, -0.020118553191423416, -0.08889934420585632, -0.024290036410093307, 0.06950510293245316, 0.005060234572738409, -0.012353791855275631, 0.03966139629483223, 0.030589979141950607, 0.012117183767259121, -0.029695870354771614, -0.0024571740068495274, 0.011296623386442661, -0.03858444094657898, 0.0928068682551384, 0.052967097610235214, -0.03690597414970398, 0.04021459445357323, 0.012411779724061489, -0.09315166622400284, -0.012852206826210022, -0.05947529524564743, 0.034117840230464935, 0.02464761584997177, 0.010864445939660072, -0.006280568428337574, 0.004636213183403015, 0.00985395722091198, 0.018240828067064285, -0.015829145908355713, 0.03400344029068947, 0.003961382433772087, 0.010420329868793488, -0.06548048555850983, -0.01882822997868061, -0.0060814726166427135, 0.004387633875012398, 0.0005311072454787791, -0.008722529746592045, -0.029471086338162422, -0.02739417925477028, 0.041421182453632355, 0.004520665388554335, -0.0021880660206079483, 0.001224247389473021, 0.01900422014296055, 0.047166455537080765, 0.01691928319633007, 0.03553667664527893, 0.0004479717172216624, -0.007461085915565491, 0.018751496449112892, -0.022226721048355103, -0.011233595199882984, 0.0012452375376597047, 0.05119193717837334, 0.0008555920794606209, 0.018527593463659286, -0.0007088929414749146, -0.04546383023262024, 0.053212299942970276, -0.017297526821494102, 0.05572984740138054, -0.022166699171066284, -0.00975156482309103, 0.010857452638447285, 0.015157959423959255, 0.021318569779396057, -0.017872542142868042, 0.0004428274987731129, -0.015125992707908154, 0.017767105251550674, -0.022243278101086617, 0.027484074234962463, 0.0003732968762051314, 0.018291523680090904, 0.02371319942176342, 0.032308172434568405, -0.029633061960339546, -0.07768473774194717, 0.035038914531469345, 0.019634464755654335, -0.034873221069574356, 0.02909960225224495, -0.019749604165554047, 0.016879767179489136, 0.0063163042068481445, -0.019168948754668236, 0.02327926643192768, 0.01457561831921339, 0.00011278088641120121, 0.0393737256526947, -0.01798521913588047, 0.01837574504315853, -0.0021569812670350075, -0.015037355944514275, 0.03072538785636425, 0.0021207579411566257, 0.031216338276863098, -0.02036507986485958, -0.012945438735187054, 0.020710304379463196, -0.037286676466464996, 0.03189189359545708, 0.0023365335073322058, 0.04401799663901329, -0.01873042806982994, 0.008051498793065548, -0.09422887861728668, 0.03386812284588814, -0.031075481325387955, -0.009676254354417324, 0.00832290481775999, -0.017388103529810905, -0.04813086986541748, -0.03936249762773514, -0.02261880226433277, -0.004723627120256424, 0.020898297429084778, -0.042744118720293045, 0.030041616410017014, 0.029314003884792328, -0.007555676624178886, 0.02015346847474575, 0.007082460448145866, 0.005656703375279903, -0.019263634458184242, -0.0604851171374321, -0.008108149282634258, -0.023708978667855263, -0.01746942847967148, 0.018977170810103416, 0.0687154233455658, -0.010201992467045784, -0.008699302561581135, 0.01758296601474285, -0.0053903693333268166, 0.045572731643915176, -0.043383050709962845, -0.044133808463811874, -0.01577862724661827, 0.01928621158003807, -0.05760221555829048, -0.010905977338552475, 0.03143485262989998, -0.009467449970543385, -0.00499302800744772, -0.056054312735795975, -0.010195854119956493, -0.034045759588479996, 0.019539114087820053, -0.025198860093951225, 0.005164643749594688, -0.03089597262442112, -0.021275924518704414, 0.023388808593153954, -0.02610023133456707, 0.048093460500240326, -0.0069358693435788155, 0.004858600907027721, -0.00985513161867857, -0.03804896026849747, 0.015114963985979557, 0.016397973522543907, 0.03092336468398571, 0.016456536948680878, -0.037181492894887924, 0.00055200100177899, 0.046029794961214066, -0.008904023095965385, 0.0043635256588459015, -0.002200124552473426, 0.02083694562315941, -0.03188341110944748, -0.02888854593038559, -0.00017159534036181867, 0.021592209115624428, -0.04424089565873146, 0.0050822775810956955, -0.03754809498786926, -0.03420373424887657, -0.00025456849834881723, 0.012240283191204071, 0.003607118269428611, 0.00043351558269932866, -0.030496157705783844, -0.00017824089445639402, -0.0038413293659687042, -0.07045970112085342, -0.017804458737373352, -0.029581570997834206, 0.006094953045248985, -0.053749509155750275, 0.027222197502851486, 0.09186997264623642, 0.006023594178259373, -0.020246597006917, -0.03126358613371849, 0.05951841548085213, -0.06299739331007004, -0.02165852300822735, 0.026720641180872917, -0.06453686207532883, -0.030560171231627464, 0.014103474095463753, 0.010206785053014755, 0.021512558683753014, 0.004693862050771713, -0.0005391397862695158, -0.03709331527352333, 0.0032278632279485464, -0.0007870400440879166, -0.02979566901922226, 0.01666852831840515, 0.01746298000216484, 0.01913158781826496, 0.02539008855819702, -0.0059365518391132355, -0.03992846980690956, -0.014079606160521507, 0.0155986612662673, 0.050775110721588135, -0.006429389119148254, 0.0008630540687590837, -0.013475335203111172, 0.030126625671982765, -0.0041966987773776054, -0.0018736575730144978, -0.008155294694006443, 0.03872067853808403, 0.03805350512266159, -0.012672582641243935, -0.032260023057460785, 0.0627533495426178, 0.049925364553928375, 0.011354673653841019, 0.004433522000908852, 0.03235649690032005, 0.0628519058227539, -0.019189490005373955, 0.012414757162332535, -0.022198032587766647, 0.0408443883061409, 0.0038849213160574436, 0.07549548149108887, -0.02005728706717491, -0.09878599643707275, -0.03620115667581558, -0.025024399161338806, -0.054850466549396515, 0.01708197593688965, -0.007768845185637474, -0.02081572823226452, 0.036605264991521835, 0.014500794932246208, -0.0327434279024601, 0.031058738008141518, -0.024978894740343094, 0.02534782513976097, -0.0506577268242836, -0.010298490524291992, 0.04950792342424393, -0.04194679483771324, -0.003114736173301935, 0.030869677662849426, -0.015048673376441002, 0.014427131041884422, 0.029764432460069656, 0.007330488879233599, 0.007578972261399031, -0.0015220335917547345, 0.018488338217139244, -0.011478312313556671, -0.015952683985233307, 0.005610140506178141, -0.023664727807044983, -0.03713901340961456, -0.03940831869840622, -0.032409124076366425, 0.029100744053721428, 0.044496968388557434, 0.008160103112459183, -0.01339686382561922, -0.0009166997042484581, -0.01942368596792221, 0.0051283324137330055, 0.0450667105615139, 0.018087238073349, -0.009057140909135342, -0.02179408073425293, -0.037184055894613266, -0.03059222921729088, 0.018898161128163338, 0.012304387986660004, -0.036543816328048706, -0.022235941141843796, 0.041805583983659744, 0.0007478574407286942, -0.024677755311131477, -0.0437464639544487, -0.017266221344470978, -0.00003156601087539457, -0.0008123717270791531, -0.0027865637093782425, -0.062015846371650696, 0.017063476145267487, -0.011111721396446228, 0.010178850963711739, 0.04980108514428139, 0.010349291376769543, -0.019458364695310593, 0.04374350607395172, -0.012633671052753925, 0.029076622799038887, -0.028674811124801636, -0.04074257239699364, 0.05288732424378395, 0.038623396307229996, -0.01151352096349001, -0.023985987529158592, -0.01818106882274151, -0.038845404982566833, 0.04503575339913368, -0.01992947980761528, 0.03416774794459343, 0.032356373965740204, -0.0010336856357753277, 0.031207075342535973, 0.01603366807103157, 0.012005558237433434, 0.014464047737419605, -0.03882715851068497, 0.043746016919612885, 0.010224604047834873, 0.038847774267196655, 0.01461909431964159, 0.021521998569369316, 0.025083374232053757, 0.025284048169851303, 0.013206535018980503, 0.005887233652174473, -0.026365764439105988, 0.04169704020023346, 0.02530527673661709, 0.005728686228394508, -0.04233396053314209, -0.05292702466249466, -0.006133100017905235, -0.0014913681661710143, 0.027948101982474327, 0.023350294679403305, 0.013604017905890942, 0.02610967680811882, 0.04649553820490837, -0.017300069332122803, -0.007580944336950779, 0.012802798300981522, -0.043139394372701645, -0.01780874654650688, -0.01699472963809967, 0.007177291437983513, 0.009405549615621567, 0.05259397253394127, -0.01649227924644947, 0.008737083524465561, 0.051246527582407, 0.019720453768968582, 0.06012357026338577, 0.02258799783885479, -0.025873275473713875, -0.0019485462689772248, -0.017245285212993622, -0.0024481057189404964, 0.002009111689403653, 0.02507375180721283, 0.034621711820364, -0.009759131819009781, 0.020298931747674942, -0.051409874111413956, 0.010681257583200932, 0.003304355312138796, 0.007222346030175686, 0.025609556585550308, 0.0041877091862261295, 0.039832115173339844, 0.007890121079981327, 0.02501830831170082, -0.004163895733654499, -0.018984513357281685, 0.010718723759055138, 0.01925967074930668, -0.007026174571365118, -0.040451716631650925, 0.016628475859761238, 0.02642115391790867, 0.004898661747574806, -0.03261769190430641, -0.022761886939406395, 0.028047608211636543, 0.02726982906460762, -0.04462563991546631, -0.04894746094942093, -0.03012710064649582, -0.027852727100253105, -0.02839645743370056, -0.00919897761195898, -0.0044475216418504715, 0.016879117116332054, -0.012218035757541656, -0.0023031968157738447, 0.01322844810783863, -0.02841520495712757, -0.06756890565156937, -0.02044348046183586, 0.025179287418723106, 0.05378437414765358, 0.018034394830465317, 0.0033870271872729063, -0.023100534453988075, -0.012276074849069118, -0.0020972450729459524, -0.012303914874792099, 0.03228031471371651, 0.02157779410481453, -0.01441288460046053, 0.031386274844408035, 0.02368621900677681, 0.021804794669151306, 0.020390648394823074, -0.001074947533197701, 0.042068254202604294, 0.023597393184900284, 0.031166991218924522, 0.013893007300794125, -0.025027303025126457, 0.023135211318731308, -0.011635114438831806, 0.02575540915131569, 0.0006923205801285803, 0.03795702010393143, 0.02405310980975628, 0.002986443927511573, 0.023501204326748848, -0.035969462245702744, -0.006951023358851671, -0.024389276280999184, -0.04424378275871277, 0.08673885464668274, -0.010589385405182838, 0.017222892493009567, -0.011462396010756493, -0.00642028171569109, 0.04121744632720947, -0.005862782243639231, 0.0001728504430502653, 0.005659634713083506, 0.010168288834393024, 0.0224106777459383, 0.012459023855626583, 0.0204287301748991, 0.045372895896434784, 0.06236260384321213, 0.0058323778212070465, 0.04051277041435242, 0.014408866874873638, 0.0057832468301057816, 0.018218232318758965, -0.031231198459863663, -0.026772931218147278, -0.00903569720685482, -0.05112224817276001, -0.01936010643839836, 0.023708900436758995, -0.028705855831503868, 0.026799270883202553, -0.08994834125041962, -0.018412386998534203, 0.02565681003034115, -0.02336372621357441, -0.010307185351848602, -0.04170607030391693, 0.012111485004425049, 0.02892656810581684, 0.03651454672217369, -0.00024010655761230737, -0.07555095106363297, 0.05845130980014801, -0.03542986884713173, 0.016892466694116592, 0.054289404302835464, 0.03418991342186928, -0.019534466788172722, -0.032271843403577805, 0.01918250508606434, 0.006768299266695976, -0.059272486716508865, -0.0052435873076319695, 0.02976864017546177, -0.038998182862997055, -0.04754353687167168, 0.040721260011196136, 0.041512321680784225, 0.018761727958917618, -0.023790298029780388, -0.0027796828653663397, -0.013052282854914665, -0.06361207365989685, 0.003426391165703535, -0.10646157711744308, 0.005120947491377592, -0.03427698090672493, -0.02310842089354992, -0.002870360156521201, -0.008609425276517868, -0.013931130059063435, 0.01700863428413868, -0.04137773811817169, -0.007841454818844795, -0.009430517442524433, 0.004051199648529291, -0.008207619190216064, 0.0049626571126282215, 0.029593149200081825, -0.038820065557956696, 0.018589163199067116, 0.011449679732322693, 0.0012613104190677404, -0.052187997847795486, -0.014427327550947666, -0.018213223665952682, 0.06703835725784302, 0.026219787076115608, 0.007077604066580534, -0.054723769426345825, 0.02355140447616577, -0.007032306399196386, -0.044332105666399, -0.0247967466711998, 0.04355158284306526 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
filename: the name of the file == "name" inside model.save("ppo-CartPole-v1") push_to_hub( repo_id="ThomasSimonini/demo-hf-CartPole-v1", filename="ppo-CartPole-v1.zip", commit_message="Added Cartpole-v1 model trained with PPO", ) `````` Try it out and share your models with the community!
[ -0.029847564175724983, -0.01497497409582138, -0.02010725624859333, 0.025791501626372337, 0.0915374904870987, 0.0651312917470932, -0.005937700625509024, 0.019129678606987, 0.006123829632997513, -0.026085756719112396, -0.07090315222740173, -0.014756684191524982, -0.02566189132630825, 0.045422714203596115, -0.044845711439847946, -0.034382112324237823, 0.02350635454058647, 0.025199228897690773, -0.0395176038146019, 0.02270476706326008, -0.05537613108754158, -0.03299088031053543, 0.025820333510637283, -0.03395577147603035, -0.00864723976701498, 0.017783427610993385, 0.06697067618370056, 0.038040801882743835, -0.054632507264614105, -0.007258018013089895, -0.031550608575344086, 0.012920699082314968, 0.018836749717593193, -0.016256749629974365, 0.032707661390304565, 0.09865513443946838, -0.05796797201037407, 0.026965243741869926, 0.0598793551325798, -0.0984964668750763, -0.05132932588458061, 0.008366185240447521, -0.09716302901506424, 0.00417574867606163, 0.07060165703296661, 0.0009031635709106922, -0.12570048868656158, 0.036926861852407455, 0.008799142204225063, 0.013853851705789566, -0.044297926127910614, 0.033251624554395676, -0.005483073182404041, 0.011201254092156887, -0.02448287419974804, -0.01044080127030611, -0.07121028006076813, -0.07502548396587372, 0.03944026306271553, 0.02423340454697609, 0.07233930379152298, 0.04187900573015213, 0.01653778739273548, 0.05461358651518822, 0.03531107306480408, 0.04244512319564819, -0.0010973792523145676, -0.005703951697796583, -0.0022716589737683535, -0.03041771613061428, -0.02117614634335041, 0.0020791569259017706, 0.020147472620010376, -0.007314058020710945, 0.04416907951235771, -0.04537956789135933, 0.03480122983455658, 0.018750548362731934, 0.051533494144678116, 0.070041723549366, -0.02437865547835827, -0.024657387286424637, -0.009280076250433922, 0.004027905408293009, 0.04437045380473137, 0.018490301445126534, 0.00837191566824913, -0.025721173733472824, -0.006444999948143959, 0.05824283882975578, -0.007703910581767559, -0.09244684875011444, -0.04254377633333206, 0.030753454193472862, 0.03178279846906662, -0.05046302452683449, 0.012868465855717659, -0.005738109350204468, -0.009537450969219208, 0.0461471863090992, -0.02009006030857563, -0.05193589627742767, 0.02741377428174019, -0.04667153209447861, -0.01308505516499281, 0.019738486036658287, -0.017759600654244423, -0.09928238391876221, -0.07498276978731155, -0.0280930083245039, 0.0021010790951550007, -0.034916914999485016, -0.04410687834024429, 0.01924160122871399, 0.004930373281240463, 0.002845961367711425, -0.04329869523644447, -0.052396226674318314, -0.018327994272112846, 0.06061125546693802, -0.007626823149621487, 0.06462717801332474, 0.06440826505422592, 0.03945637866854668, 0.05613335594534874, 0.04814080521464348, -0.03942466527223587, -0.010143326595425606, -0.009642977267503738, -0.0736030861735344, 0.022371266037225723, 0.06733300536870956, 0.05457571521401405, -0.06187901273369789, 0.04430660232901573, -0.024309076368808746, -0.050804659724235535, -0.05149761959910393, 0.029681533575057983, 0.0073584215715527534, 0.013868153095245361, 0.07844790816307068, -0.034963008016347885, 0.030069520696997643, 0.06874855607748032, 0.03928351774811745, 0.007317695301026106, 0.038215965032577515, 0.010678784921765327, -0.03537547588348389, -0.008258857764303684, 0.062124818563461304, 0.007715663406997919, -0.08417186141014099, -0.031028535217046738, 0.0743635892868042, 0.007621906232088804, 0.01848803460597992, -0.017129523679614067, -0.0023340273182839155, 0.05288039892911911, 0.04113393649458885, -0.08462488651275635, 0.02831382304430008, -0.008494388312101364, -0.04275260120630264, 0.04581126570701599, -0.05547880008816719, 0.08262913674116135, -0.1319061666727066, -0.0004057832411490381, -0.0498417429625988, 0.056494344025850296, 0.030261432752013206, 0.01986530050635338, 0.07319406419992447, 0.06461582332849503, -0.00404489366337657, 0.011654173955321312, -0.003807999426499009, 0.003655865788459778, 0.09680741280317307, -0.05777668580412865, -0.0615730918943882, 0.05162340775132179, -0.07247187197208405, 0.016806339845061302, 0.034281425178050995, -0.0030841724947094917, 0.01391607616096735, -0.03650896996259689, -0.04209578037261963, 0.12232489138841629, -0.03352097421884537, 0.04063580557703972, -0.02898927591741085, 0.01324869878590107, 0.05806232616305351, 0.019012082368135452, 0.01626073196530342, -0.08192911744117737, -0.008282162249088287, -0.014561029151082039, -0.04719033092260361, 0.0011171168880537152, 0.03582470491528511, -0.022486329078674316, -0.04898601770401001, 0.07908886671066284, -0.026638684794306755, 0.039412546902894974, 0.03478197008371353, 0.11111435294151306, -0.1068616583943367, 0.0342782586812973, -0.06802310794591904, -0.03651538863778114, -0.021208174526691437, -0.047775547951459885, 0.009931199252605438, 0.15816913545131683, 0.0013558883219957352, -0.016189079731702805, 0.02252141945064068, 0.029548849910497665, 0.01763620786368847, 0.05081884562969208, 0.06447742879390717, 0.056745246052742004, -0.09731698781251907, -0.05059031397104263, -0.010405497625470161, -0.016216378659009933, 0.039820346981287, 0.028483791276812553, -0.02061290293931961, 0.03863148391246796, 0.05243126302957535, -0.0506603866815567, 0.0017559893894940615, -0.02179114520549774, -0.01528804562985897, -0.028284696862101555, 0.045386526733636856, -0.0009354911744594574, -0.006370812654495239, 0.08984256535768509, -0.004587000235915184, -0.047218337655067444, 0.010174598544836044, -0.08907891064882278, -0.006853107362985611, -0.014326340518891811, 0.06021910160779953, 0.04460788518190384, -0.005342886783182621, -0.007085250690579414, 0.00397050566971302, -0.006643928587436676, 0.05064133554697037, -0.02480991743505001, -0.011069603264331818, -0.05443253368139267, -0.029748067259788513, 0.002994187641888857, 0.00335861649364233, 0.002966817934066057, -0.0015696383779868484, -0.014485547319054604, -0.03758852183818817, -0.00279505574144423, -0.007022445555776358, 0.008516224101185799, -0.005360839422792196, -0.015855133533477783, 0.0182418841868639, 0.002026892965659499, 0.021340321749448776, 0.005247556604444981, -0.0030536819249391556, -0.00927674025297165, -0.021689509972929955, 0.027318214997649193, 0.014771254733204842, 0.07554639875888824, 0.00838468037545681, 0.03169925510883331, -0.02232116088271141, -0.046364471316337585, 0.012492416426539421, -0.0329383946955204, 0.004216053057461977, -0.001529870554804802, 0.014708631671965122, -0.004908690229058266, 0.006539137568324804, -0.004945880733430386, -0.021240778267383575, 0.014816993847489357, -0.016295557841658592, 0.023797092959284782, 0.005598755553364754, 0.018293118104338646, -0.02986118197441101, -0.012347441166639328, 0.04853653907775879, 0.008974523283541203, -0.021938301622867584, -0.09481805562973022, -0.011243664659559727, -0.003262777579948306, -0.0005165665643289685, 0.023968255147337914, -0.0012686640257015824, 0.02149294503033161, 0.018266815692186356, -0.009751657024025917, 0.03714948520064354, -0.008421329781413078, -0.023595210164785385, -0.004582100082188845, -0.035297881811857224, -0.026932692155241966, -0.0008055928046815097, 0.001628695521503687, 0.05285191908478737, 0.0191503893584013, 0.014515714719891548, -0.08570893853902817, 0.016338026151061058, 0.02177215740084648, -0.016743941232562065, -0.0006235014880076051, -0.019706055521965027, 0.029350776225328445, 0.03719692304730415, 0.004976199474185705, -0.0675451010465622, 0.02470402792096138, -0.026795141398906708, -0.0509595088660717, -0.03064310923218727, -0.06377126276493073, -0.01576935313642025, -0.022612128406763077, 0.011163796298205853, 0.0029045594856142998, 0.016554318368434906, -0.049464527517557144, 0.009230297058820724, 0.03309227153658867, 0.015279949642717838, 0.001532012247480452, -0.027401354163885117, -0.0060542612336575985, 0.014710857532918453, -0.02281772345304489, -0.002352834679186344, -0.024103263393044472, -0.044567402452230453, 0.03583800792694092, 0.025159049779176712, 0.015532844699919224, -0.0035510475281625986, -0.016737904399633408, 0.01981506124138832, 0.019976867362856865, -0.033018145710229874, -0.03781135007739067, 0.00380444573238492, -0.03694550320506096, -0.06230079382658005, -0.01905566267669201, 0.01683301106095314, -0.01649848371744156, 0.04203883558511734, -0.020054560154676437, 0.045180730521678925, -0.0037220236845314503, 0.015119301155209541, 0.022289253771305084, 0.012109731324017048, -0.037929460406303406, -0.027897454798221588, 0.0022493614815175533, -0.04575219377875328, 0.06266622990369797, 0.010955408215522766, 0.03777218982577324, 0.0019747428596019745, -0.009578736498951912, -0.007285232190042734, -0.0026933529879897833, 0.029442429542541504, 0.036801282316446304, -0.014837555587291718, 0.021499397233128548, 0.02267475426197052, -0.004064770415425301, 0.00018721434753388166, -0.00047032252768985927, -0.0037741258274763823, -0.030622562393546104, -0.03244742378592491, 0.028482681140303612, 0.02452944777905941, -0.03650553151965141, 0.014708615839481354, -0.0008157607517205179, -0.005760352127254009, -0.012399477884173393, 0.024951213970780373, 0.04315372183918953, 0.006771469954401255, -0.032565947622060776, -0.014740917831659317, 0.003074039937928319, 0.0092012295499444, -0.015263318084180355, -0.022097427397966385, 0.002231237245723605, -0.027355212718248367, 0.00871858187019825, 0.060353852808475494, -0.020630359649658203, -0.01888193190097809, -0.01548596192151308, 0.048282332718372345, -0.06741252541542053, -0.01548316515982151, -0.00814851000905037, -0.03920384496450424, 0.000030115375921013765, 0.04765065014362335, 0.05570376291871071, -0.009567505680024624, 0.006593140307813883, 0.030920088291168213, -0.07365012168884277, -0.0055327583104372025, 0.0026058366056531668, -0.02186725288629532, 0.0051036737859249115, 0.04171424359083176, -0.006146080791950226, 0.029332594946026802, 0.028590278699994087, -0.03273249417543411, -0.03980793431401253, 0.037986669689416885, 0.06336168944835663, -0.04544265940785408, 0.0011741520138457417, -0.02176557667553425, -0.031947266310453415, 0.0346732959151268, 0.022409802302718163, -0.010757692158222198, 0.022538119927048683, 0.030235348269343376, -0.006457253359258175, -0.005717223044484854, 0.052740778774023056, 0.024843290448188782, -0.013497553765773773, -0.011835683137178421, -0.00459748599678278, 0.060292284935712814, -0.03218696638941765, -0.008683739230036736, 0.004835468716919422, 0.041031282395124435, -0.00853840634226799, 0.06463462114334106, 0.020197056233882904, -0.0948791429400444, 0.001270040636882186, 0.013653555884957314, -0.001571370754390955, -0.006316256243735552, 0.011407365091145039, -0.030773084610700607, 0.015643924474716187, 0.018649941310286522, 0.0033836429938673973, 0.047835223376750946, -0.02586749941110611, 0.0028091217391192913, -0.027090253308415413, 0.02290290594100952, 0.04041080176830292, -0.015259546227753162, 0.008697397075593472, -0.006031395401805639, 0.03431536257266998, 0.03400353714823723, 0.018789680674672127, -0.026412131264805794, -0.009811939671635628, 0.01479323860257864, 0.02116142213344574, -0.007364936172962189, -0.02161017246544361, -0.030533136799931526, 0.01296765636652708, -0.05103620886802673, -0.01022778544574976, -0.00040257134241983294, 0.029763629660010338, 0.06980199366807938, -0.010749459266662598, -0.014350863173604012, 0.018311845138669014, -0.010371681302785873, 0.017148122191429138, 0.033920418471097946, 0.017084237188100815, -0.0002798468922264874, 0.007618884555995464, -0.024020710960030556, 0.002078559948131442, 0.03011079877614975, 0.0019261373672634363, -0.021907808259129524, -0.028259849175810814, 0.039034534245729446, -0.0022210218012332916, 0.023784760385751724, -0.05288795754313469, -0.009265798144042492, 0.015223625116050243, -0.0006084381602704525, 0.01725194603204727, -0.04770588129758835, 0.01606685481965542, 0.045924678444862366, 0.033940594643354416, 0.04074208810925484, 0.0335918664932251, -0.04811925068497658, 0.010797685943543911, -0.004836703184992075, 0.004612915683537722, 0.00024005140585359186, -0.02373032458126545, 0.04854188114404678, 0.03946429118514061, -0.026738345623016357, -0.013260032050311565, -0.03324532136321068, -0.09761935472488403, 0.056503478437662125, -0.018005119636654854, 0.008600267581641674, 0.03668918460607529, 0.01606585457921028, -0.021428298205137253, 0.0368070974946022, 0.01410194206982851, -0.012299015186727047, -0.017552146688103676, 0.005569244734942913, -0.008390211500227451, 0.05681281536817551, 0.01877686381340027, -0.028790421783924103, -0.022725654765963554, -0.0054354979656636715, 0.03347707912325859, 0.007740799803286791, -0.009074642322957516, 0.03942326828837395, 0.037015337496995926, 0.027237791568040848, -0.024171410128474236, -0.0502728708088398, -0.01579638384282589, 0.020985320210456848, 0.0327741838991642, 0.03528302162885666, 0.012951173819601536, -0.024323945865035057, -0.010410024784505367, 0.03511558100581169, -0.022051965817809105, 0.01900235377252102, -0.07964494824409485, 0.03360249102115631, 0.01347159594297409, 0.02676614746451378, 0.01764690689742565, 0.04009818658232689, 0.008942179381847382, 0.015052061527967453, 0.05461747944355011, 0.02423834428191185, 0.03974100202322006, 0.03165234997868538, 0.003041399409994483, 0.010567310266196728, -0.016654929146170616, 0.0025299005210399628, 0.013680833391845226, 0.021120285615324974, 0.008973938412964344, -0.004283077083528042, 0.00044673262163996696, -0.05383137986063957, 0.01308051310479641, -0.0031851844396442175, 0.016306951642036438, -0.007384031545370817, 0.03252728655934334, 0.03836485743522644, -0.03574347496032715, 0.012238455936312675, 0.027135388925671577, 0.019840726628899574, -0.011286906898021698, 0.025697903707623482, 0.0077278935350477695, -0.018199093639850616, 0.024226313456892967, -0.016233354806900024, 0.01871911808848381, -0.010363595560193062, -0.05399025231599808, 0.005516073666512966, 0.008671438321471214, 0.005047373939305544, -0.06226145476102829, 0.005388856399804354, -0.01272228267043829, -0.011580011807382107, -0.010201238095760345, 0.012189196422696114, -0.028263388201594353, -0.035206831991672516, 0.016178937628865242, 0.0160204004496336, -0.02544451877474785, -0.028028205037117004, -0.04792293906211853, 0.023742055520415306, 0.050176214426755905, 0.04436188191175461, 0.00011861078382935375, -0.04480227455496788, -0.050544433295726776, -0.021543821319937706, -0.026560921221971512, 0.0014823753153905272, 0.013672051019966602, -0.014511934481561184, 0.027818745002150536, 0.05149739980697632, 0.007589726708829403, 0.06460928171873093, 0.008797110058367252, 0.061572954058647156, 0.05139957368373871, -0.012982280924916267, -0.043588537722826004, -0.018102208152413368, 0.03760335221886635, 0.00004671578062698245, 0.018227819353342056, 0.03732569143176079, 0.022175021469593048, 0.03659474104642868, -0.004971769172698259, 0.012282214127480984, -0.0170451533049345, 0.005820747930556536, -0.009172871708869934, -0.009280652739107609, 0.03842997923493385, 0.010666466318070889, -0.023872606456279755, 0.01234352495521307, -0.028273647651076317, 0.012017153203487396, -0.020397303625941277, 0.014611577615141869, 0.04227918013930321, 0.015519252978265285, 0.03238628804683685, 0.02609853446483612, 0.0462595634162426, 0.03381888568401337, 0.004595165140926838, 0.017893636599183083, 0.016882963478565216, 0.00685893464833498, 0.0015864232555031776, 0.008078126236796379, -0.0074966903775930405, -0.04055697098374367, 0.008210238069295883, -0.06249379366636276, -0.01591060869395733, 0.030025657266378403, -0.040518101304769516, 0.002787957200780511, -0.11461551487445831, -0.03369976952672005, 0.010267124511301517, 0.00791161134839058, -0.023452606052160263, -0.014369538053870201, 0.024496957659721375, 0.04178602248430252, 0.052262887358665466, -0.001000619842670858, -0.03310682997107506, 0.03233419731259346, -0.02960822917521, 0.03970925137400627, 0.015214248560369015, 0.0358874537050724, -0.011455417610704899, -0.009229958988726139, 0.032430484890937805, -0.05159112066030502, -0.06611565500497818, 0.020150236785411835, 0.04261816665530205, -0.027805501595139503, -0.06850194931030273, -0.011107565835118294, 0.012608221732079983, 0.0059173861518502235, 0.011096754111349583, -0.017588630318641663, -0.033355697989463806, -0.06418288499116898, -0.010808722116053104, -0.03834185376763344, 0.012205148115754128, -0.04271334037184715, -0.014655757695436478, 0.02000593952834606, 0.008014152757823467, -0.02412879467010498, 0.0015524204354733229, -0.05205560103058815, 0.026363708078861237, -0.052105169743299484, -0.02049916610121727, -0.05228474363684654, -0.006702401675283909, 0.007725208532065153, -0.034797437489032745, 0.015925494953989983, -0.012144139036536217, 0.015431985259056091, -0.06155380606651306, 0.001012472785077989, 0.028327137231826782, 0.039193328469991684, -0.004262175410985947, -0.03186666592955589, -0.045985713601112366, 0.02851490117609501, -0.026783734560012817, -0.026277512311935425, -0.016351692378520966, 0.022223982959985733 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
Finding Models We’re currently uploading saved models of agents playing Space Invaders, Breakout, LunarLander and more. On top of this, you can find all stable-baselines-3 models from the community here When you found the model you need, you just have to copy the repository id:
[ 0.011057342402637005, -0.01868220791220665, 0.05832130089402199, 0.05956290289759636, 0.09449704736471176, 0.03187008574604988, 0.03181171417236328, 0.027771977707743645, -0.05480304732918739, -0.10905301570892334, -0.02676009014248848, 0.014063945971429348, 0.027596434578299522, -0.01071199495345354, 0.05260858312249184, -0.0065091815777122974, -0.027394896373152733, -0.0030556379351764917, -0.014429920352995396, 0.023500435054302216, 0.0020101394038647413, -0.06123946234583855, 0.03171404078602791, -0.077897809445858, -0.040590010583400726, -0.03653033450245857, 0.039307042956352234, -0.008348432369530201, -0.037127040326595306, 0.021118860691785812, -0.06329630315303802, -0.055807165801525116, 0.04482150822877884, -0.09197255969047546, -0.014358642511069775, -0.002253997605293989, -0.09890484809875488, 0.053601477295160294, -0.022498156875371933, -0.08841124922037125, 0.012308682315051556, -0.028322026133537292, -0.013491744175553322, 0.11679578572511673, 0.011070686392486095, -0.03498823195695877, -0.17101110517978668, 0.06197533383965492, -0.024579038843512535, -0.024477114900946617, -0.036162879317998886, 0.022795017808675766, -0.03703463077545166, -0.028635548427700996, 0.02265222743153572, 0.00414047809317708, 0.020813526585698128, -0.054617103189229965, 0.04812842234969139, 0.023699527606368065, 0.07306478172540665, 0.05419110506772995, 0.06375711411237717, -0.034099332988262177, 0.0006430302746593952, 0.04417995736002922, 0.05762893334031105, -0.048407625406980515, -0.013580151833593845, 0.018164167180657387, 0.013134829699993134, 0.007417278829962015, 0.03724132478237152, -0.03403753414750099, -0.018095269799232483, -0.06332740932703018, -0.033263448625802994, 0.11781464517116547, 0.0354362353682518, 0.017216434702277184, 0.06545253843069077, 0.002583504654467106, 0.0923360213637352, 0.05526108294725418, -0.015651553869247437, 0.019741561263799667, 0.02785496413707733, -0.027778327465057373, -0.005188025068491697, 0.0666276291012764, -0.02471042610704899, -0.09232893586158752, 0.014952491968870163, -0.022013770416378975, 0.035218700766563416, -0.004399155266582966, 0.015842173248529434, 0.0008618144784122705, 0.014199760742485523, -0.03829999640583992, -0.018611878156661987, -0.0067231301218271255, -0.03080045059323311, -0.08579284697771072, -0.00257088546641171, -0.015237393788993359, 0.006702651735395193, -0.04970001429319382, -0.05793344974517822, -0.04625488072633743, -0.03266032785177231, -0.02716199681162834, 0.06843458116054535, -0.013291683048009872, -0.015311247669160366, 0.06465334445238113, -0.002248375443741679, 0.007733890786767006, 0.00916954968124628, 0.07488809525966644, -0.004664309788495302, 0.06529169529676437, 0.03129097819328308, -0.0038383041974157095, 0.051978159695863724, 0.097536101937294, 0.025403089821338654, -0.03670673817396164, -0.07840738445520401, -0.0745716243982315, 0.016395222395658493, -0.018311889842152596, -0.034352704882621765, -0.010521017014980316, 0.07013680040836334, -0.11475823074579239, -0.0014147969195619226, 0.016185801476240158, 0.015391466207802296, 0.034420765936374664, -0.0804520770907402, 0.001972588710486889, -0.004410538822412491, 0.083236463367939, 0.08184772729873657, -0.07005772739648819, -0.06031879410147667, 0.01978462003171444, -0.04234032705426216, 0.03740113973617554, -0.018450792878866196, -0.024682465940713882, 0.006260355934500694, -0.04143022745847702, -0.040655747056007385, 0.0006423210143111646, -0.008860045112669468, -0.006093513686209917, -0.016544384881854057, -0.017314432188868523, -0.013645419850945473, -0.0384184867143631, 0.0014896583743393421, 0.02829262800514698, 0.08814200013875961, 0.003758900798857212, 0.0210654828697443, 0.012187723070383072, -0.012218565680086613, -0.048061802983284, 0.009706584736704826, 0.02199048362672329, 0.14707306027412415, 0.038681358098983765, 0.003872799687087536, 0.02204306237399578, 0.10742973536252975, 0.040097109973430634, 0.04261190444231033, -0.03609519824385643, -0.037501413375139236, -0.04425821080803871, -0.0018770454917103052, 0.020842717960476875, 0.03560976684093475, -0.08299755305051804, 0.008878841996192932, -0.018776781857013702, 0.02050241455435753, 0.03391329571604729, -0.01566622033715248, 0.0074149491265416145, 0.08006944507360458, 0.029085014015436172, 0.01058734580874443, -0.06256011128425598, -0.03474138304591179, 0.009835122153162956, 0.08267594128847122, 0.06280505657196045, 0.011609042063355446, 0.052785009145736694, -0.01841062679886818, -0.0016026401426643133, -0.0771745890378952, 0.020907564088702202, 0.039718955755233765, -0.05044921487569809, 0.0793684795498848, 0.007522102445363998, -0.0292240958660841, -0.07624898850917816, 0.025048157200217247, -0.0831058993935585, 0.06370566040277481, 0.005186620634049177, -0.06846984475851059, -0.015454157255589962, 0.019718514755368233, -0.055680934339761734, 0.18370522558689117, 0.0010358544532209635, -0.01230003871023655, 0.021119384095072746, -0.07575303316116333, 0.078621044754982, 0.06884575635194778, 0.004253603518009186, 0.06923086941242218, -0.05281839147210121, -0.0001960872032213956, 0.017017485573887825, -0.012173853814601898, 0.01501145027577877, -0.023944443091750145, 0.010472201742231846, 0.024725377559661865, -0.02538403496146202, 0.0003531480033416301, 0.005374709609895945, -0.00975684355944395, -0.061414603143930435, 0.029550494626164436, 0.043026428669691086, -0.038443613797426224, 0.00857686996459961, 0.04621322080492973, 0.03859913721680641, -0.06029331684112549, -0.00546474801376462, -0.043632201850414276, 0.04092762619256973, -0.01123543456196785, -0.05188484862446785, 0.04090990126132965, 0.018189840018749237, -0.011436199769377708, -0.007306715939193964, -0.014760746620595455, 0.022444866597652435, 0.01537136547267437, -0.020974213257431984, 0.011544720269739628, -0.0536627434194088, 0.00982595793902874, -0.046592358499765396, -0.008922930806875229, -0.012989535927772522, -0.012219417840242386, -0.024015728384256363, 0.037434957921504974, -0.023599345237016678, 0.004345493856817484, -0.0008145071333274245, 0.019618559628725052, 0.00929921492934227, -0.010491851717233658, -0.03713319078087807, -0.026124564930796623, -0.02427138015627861, 0.008463309146463871, -0.04465470835566521, 0.04631820321083069, 0.05092783272266388, 0.03419587388634682, -0.004035414196550846, 0.019631505012512207, -0.025013484060764313, 0.020520493388175964, 0.02330859750509262, 0.01119548175483942, 0.010807632468640804, 0.014353200793266296, 0.01830315962433815, 0.00042982937884517014, -0.03219746798276901, 0.002387408399954438, 0.025163188576698303, -0.010553036816418171, 0.007282931357622147, -0.016686514019966125, 0.026003507897257805, -0.0044144135899841785, 0.003894296009093523, -0.004387931898236275, 0.01373977493494749, -0.020446300506591797, 0.007816513068974018, -0.11402229219675064, -0.036478038877248764, 0.012382490560412407, 0.06203772500157356, 0.02175094000995159, -0.044758379459381104, 0.0006282656104303896, 0.0011974027147516608, -0.0014882116811349988, -0.0026351569686084986, 0.01596883311867714, 0.005065605975687504, 0.009570448659360409, -0.0033737418707460165, -0.06271546334028244, 0.038621652871370316, 0.018580541014671326, 0.01934332214295864, 0.01899837702512741, -0.0020495967473834753, -0.046552907675504684, 0.07785244286060333, -0.010655594989657402, 0.0044569713063538074, -0.012371957302093506, 0.02358098141849041, 0.054315194487571716, -0.005694394465535879, -0.03162865340709686, -0.022542335093021393, -0.025141365826129913, 0.028240201994776726, -0.02876407839357853, 0.009260051883757114, -0.05440045893192291, -0.006502732168883085, -0.03533061221241951, -0.0020841096993535757, 0.006260875146836042, 0.0004105767293367535, -0.002130460925400257, -0.00910595990717411, 0.005913750734180212, 0.0051136016845703125, 0.01748328097164631, -0.007892155088484287, 0.020634116604924202, 0.023855436593294144, 0.03624377399682999, -0.04283016175031662, 0.007965562865138054, 0.0028797388076782227, 0.009416908025741577, 0.022971784695982933, 0.02911815047264099, 0.008969473652541637, -0.010388108901679516, 0.04161406680941582, 0.030462441965937614, 0.0007456580642610788, -0.06223578378558159, 0.0232847910374403, 0.009710649959743023, 0.04424407333135605, -0.02117927558720112, 0.011418269015848637, 0.034666988998651505, -0.01812354475259781, -0.025123491883277893, 0.005742623005062342, 0.011543712578713894, 0.03649330884218216, -0.026072915643453598, 0.014062123373150826, -0.012157226912677288, 0.01054954994469881, -0.02409685030579567, -0.07160545885562897, 0.05040481314063072, 0.013615445233881474, -0.020529551431536674, -0.06097283586859703, -0.026522256433963776, -0.0038360401522368193, -0.01998191885650158, -0.0203716941177845, 0.024607010185718536, 0.005401258356869221, -0.01500873826444149, 0.0129333371296525, 0.004401339218020439, -0.025474954396486282, 0.055826637893915176, -0.02224002219736576, 0.05340634286403656, 0.023239491507411003, 0.013081647455692291, -0.005400868598371744, 0.03459526225924492, 0.046053577214479446, 0.011892911978065968, -0.04397208243608475, 0.017551444470882416, 0.020007845014333725, -0.0200714822858572, 0.018348921090364456, 0.013620597310364246, -0.03421662002801895, 0.015544543042778969, -0.021638095378875732, 0.012805536389350891, -0.019284268841147423, -0.027226611971855164, -0.010442310012876987, 0.006957509089261293, -0.004103128332644701, -0.02333413064479828, 0.001823600148782134, -0.03362559899687767, 0.007584074977785349, -0.049593500792980194, -0.008995605632662773, -0.009594732895493507, 0.010225345380604267, 0.0070266155526041985, 0.015956493094563484, -0.0047960770316421986, -0.02642672508955002, -0.011686883866786957, 0.008978568948805332, 0.007246590685099363, -0.030088720843195915, 0.03000914491713047, 0.05587892234325409, 0.01620354689657688, 0.014993163757026196, -0.0219948198646307, 0.02688021957874298, -0.01170368678867817, -0.04893358424305916, -0.009087027981877327, -0.01668933406472206, 0.053624700754880905, -0.007962618954479694, 0.012273484840989113, -0.02438417449593544, -0.02480655163526535, 0.0024508389178663492, 0.03423137217760086, 0.055542271584272385, 0.05698930844664574, -0.003911510109901428, 0.01514269970357418, -0.02573605254292488, 0.036931298673152924, -0.02190706692636013, -0.036542367190122604, 0.011443236842751503, -0.0331742987036705, 0.020347032696008682, 0.020298218354582787, 0.00023098435485735536, -0.005393903702497482, 0.07907544076442719, 0.03695351257920265, 0.004499835893511772, 0.001077030086889863, -0.06962474435567856, -0.013715733774006367, 0.023938840255141258, -0.023731766268610954, -0.021682189777493477, 0.01621507667005062, -0.008768819272518158, 0.0276790801435709, 0.030672963708639145, 0.04119552671909332, 0.01917516626417637, 0.024582525715231895, 0.023308034986257553, -0.059730492532253265, 0.017577458173036575, 0.06985929608345032, -0.013569854199886322, -0.004598586820065975, 0.01744478940963745, 0.06463304162025452, 0.04836563393473625, 0.02141009084880352, 0.00568769033998251, -0.011468058452010155, 0.03693823143839836, -0.017763203009963036, -0.002775097033008933, -0.01221123244613409, -0.005383500829339027, 0.025143614038825035, 0.018139051273465157, 0.01698075793683529, -0.011990220285952091, 0.01820540241897106, 0.05151465907692909, -0.047812700271606445, 0.00732326740399003, 0.02822679653763771, 0.027175214141607285, 0.023052630946040154, -0.01410567108541727, 0.04143821448087692, -0.0410291850566864, 0.005692822393029928, -0.03496894612908363, -0.04611920192837715, 0.005192663986235857, -0.01377341989427805, -0.06135338172316551, -0.02854006178677082, -0.025520358234643936, 0.022062182426452637, 0.06877873837947845, -0.0073644551448524, 0.012800846248865128, -0.020376069471240044, 0.05230894684791565, -0.014332687482237816, -0.05460778623819351, -0.033139873296022415, 0.05111020430922508, -0.011862998828291893, 0.009926567785441875, 0.05612305924296379, 0.001783472835086286, 0.04076821357011795, -0.02133766934275627, 0.013836205936968327, -0.034273117780685425, -0.046283792704343796, 0.008276540786027908, 0.002225178759545088, 0.017558546736836433, -0.028382495045661926, -0.012226325459778309, -0.023536216467618942, -0.024944916367530823, -0.05693773180246353, 0.004552951082587242, 0.09884682297706604, 0.0008432914037257433, -0.012070078402757645, -0.012789953500032425, 0.014983043074607849, -0.020361294969916344, -0.0009748259326443076, 0.0030029478948563337, -0.02519536390900612, 0.024395596235990524, 0.0035660150460898876, 0.015912359580397606, -0.009207600727677345, -0.05237381160259247, 0.009546271525323391, 0.0009276277269236743, -0.015960579738020897, 0.045897696167230606, -0.03306000307202339, 0.00950632058084011, 0.023941272869706154, -0.03688192740082741, 0.02557043544948101, 0.004594519268721342, -0.02944318950176239, 0.01913180574774742, 0.0029357895255088806, 0.0005084072472527623, -0.03687018156051636, 0.004277857486158609, 0.09195446223020554, 0.024127988144755363, -0.02788037806749344, 0.03479352220892906, -0.011827429756522179, 0.059170402586460114, 0.005217140540480614, 0.014509012922644615, 0.016873501241207123, 0.021991107612848282, 0.05504578351974487, -0.023851260542869568, 0.018901264294981956, 0.049001388251781464, -0.01491688471287489, -0.03511621803045273, -0.06328292936086655, -0.002198731293901801, -0.04225041717290878, 0.044468894600868225, -0.013589893467724323, -0.03756336495280266, -0.0020694739650934935, -0.03002515248954296, 0.032200515270233154, 0.0039022606797516346, 0.009988203644752502, 0.002377929864451289, 0.04422590509057045, 0.00240393471904099, -0.021426795050501823, 0.032857269048690796, 0.01974460296332836, 0.006548019591718912, 0.007326286286115646, 0.05087381973862648, 0.016499850898981094, -0.02877091057598591, 0.01809215173125267, -0.005971985869109631, 0.0009000157588161528, 0.006324247922748327, -0.031767986714839935, -0.03161714971065521, 0.040714699774980545, -0.00828165840357542, -0.00777231901884079, 0.043971914798021317, -0.009655718691647053, -0.051365576684474945, -0.013489628210663795, -0.0023768669925630093, -0.01977597177028656, -0.022201990708708763, 0.005815255455672741, -0.004732978530228138, 0.02519572712481022, -0.010542867705225945, 0.007226927671581507, 0.02555088885128498, 0.004590923432260752, 0.03482019156217575, -0.012759656645357609, -0.0019149939762428403, -0.014067177660763264, 0.017287608236074448, -0.014750090427696705, 0.001345359836705029, -0.03847002238035202, -0.015509868040680885, 0.007062679622322321, -0.007531851530075073, 0.0041663385927677155, -0.014652448706328869, 0.04627562686800957, -0.024062715470790863, 0.00001635138687561266, 0.02868652157485485, 0.011847680434584618, 0.00428406149148941, -0.023562053218483925, -0.039363931864500046, 0.011597204022109509, -0.0215144045650959, 0.043384626507759094, 0.025824300944805145, 0.004794316831976175, -0.037022754549980164, -0.0432441309094429, -0.016315313056111336, -0.05201149731874466, 0.02718236856162548, -0.005271053407341242, -0.029688656330108643, -0.013797539286315441, -0.017155632376670837, 0.021563183516263962, 0.04081187769770622, -0.06205103546380997, 0.04471864923834801, 0.015719832852482796, 0.007548780180513859, -0.029525741934776306, -0.02610567770898342, 0.07452405989170074, 0.01805979385972023, 0.009619709104299545, 0.05132211744785309, 0.045586518943309784, -0.014117653481662273, 0.0015497931744903326, 0.020768195390701294, -0.002213699510321021, -0.0002545349416323006, -0.02993541769683361, -0.0441150926053524, -0.01908711902797222, -0.013257904909551144, -0.0007376713328994811, -0.014342418871819973, -0.01258852705359459, -0.01647457852959633, -0.016251545399427414, -0.027046557515859604, -0.040588293224573135, -0.016529034823179245, 0.04531557485461235, 0.003345323959365487, 0.022457532584667206, -0.000035531109460862353, 0.0023354128934442997, 0.006059802137315273, 0.01815333031117916, 0.03765459731221199, -0.006550539750605822, -0.04541764035820961, -0.013803299516439438, -0.005841450300067663, 0.021541379392147064, -0.02179531566798687, -0.06877291947603226, -0.006410567089915276, 0.031675782054662704, -0.031071854755282402, -0.0036820541135966778, -0.01839374750852585, -0.019828150048851967, 0.020969951525330544, 0.005924176890403032, 0.025937199592590332, -0.03432048484683037, -0.03466520085930824, 0.030494656413793564, -0.01138462033122778, -0.003674764186143875, -0.002503562020137906, 0.013531440868973732, 0.010293850675225258, 0.037734102457761765, -0.040459077805280685, 0.01940670982003212, -0.021321790292859077, 0.015840547159314156, 0.006951827555894852, 0.017457686364650726, -0.023782648146152496, -0.02307896316051483, -0.002250218065455556, -0.0002607489877846092, -0.0463159903883934, -0.002466283505782485, 0.06602905690670013, 0.020074881613254547, -0.009336323477327824, 0.005694674327969551, 0.020730741322040558, 0.010680582374334335, 0.0037257224321365356, -0.02543008327484131, 0.023849574849009514, -0.014849893748760223, 0.0009566351654939353, -0.00412419019266963, 0.014880728907883167 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
Download a model from the Hub The coolest feature of this integration is that you can now very easily load a saved model from Hub to Stable-baselines3. In order to do that you just need to copy the repo-id that contains your saved model and the name of the saved model zip file in the repo. For instancesb3/demo-hf-CartPole-v1: python import gym from huggingface_sb3 import load_from_hub from stable_baselines3 import PPO from stable_baselines3.common.evaluation import evaluate_policy # Retrieve the model from the hub
[ -0.018794232979416847, -0.02923564799129963, -0.05100633576512337, 0.03903273120522499, 0.062230370938777924, 0.006765484344214201, 0.009426598437130451, -0.000757513684220612, -0.07633285969495773, -0.02805343270301819, -0.0205742996186018, 0.0008378202328458428, -0.01330530270934105, 0.006897583603858948, -0.014670363627374172, -0.11409123986959457, 0.016273481771349907, -0.024328401312232018, -0.03746236488223076, 0.050538402050733566, 0.01916462369263172, -0.052873626351356506, -0.024035630747675896, 0.027902470901608467, -0.040779922157526016, -0.058133624494075775, 0.05329025909304619, 0.02169388346374035, 0.0094678346067667, -0.03126110881567001, -0.035129208117723465, -0.047617968171834946, -0.007106841076165438, -0.05391254276037216, 0.07124165445566177, 0.06432472169399261, -0.07446718215942383, 0.032018840312957764, 0.04118448123335838, -0.08442523330450058, 0.0188868697732687, 0.07425107061862946, -0.05922946706414223, 0.04160081967711449, 0.07134813815355301, -0.04058564081788063, -0.12327843904495239, 0.04235883802175522, -0.0419989712536335, 0.0189626794308424, -0.10453412681818008, 0.04749083146452904, 0.008590105921030045, -0.00897173397243023, 0.021088477224111557, -0.023338546976447105, -0.03483660891652107, -0.036703694611787796, 0.015894923359155655, 0.03123491443693638, 0.0035681177396327257, 0.05109388753771782, 0.02477431856095791, 0.036603476852178574, 0.005320493597537279, 0.058015864342451096, -0.03724968805909157, -0.029238618910312653, -0.02640892006456852, -0.05428696423768997, 0.01874019019305706, -0.035114649683237076, 0.01625635102391243, 0.008868858218193054, 0.026456428691744804, -0.056667160242795944, -0.013240514323115349, 0.08012988418340683, 0.08404204249382019, -0.017775677144527435, 0.04130053147673607, -0.028622686862945557, -0.036342717707157135, 0.03257608041167259, 0.05207591503858566, 0.04078895226120949, -0.010809614323079586, -0.08980812877416611, -0.040674131363630295, 0.043126434087753296, -0.021115832030773163, -0.06167289987206459, -0.049861785024404526, 0.02504090406000614, 0.07278624176979065, 0.02038249932229519, 0.012591044418513775, -0.023365559056401253, -0.015603609383106232, -0.056938376277685165, 0.023428190499544144, -0.05394328013062477, -0.019528962671756744, -0.07575525343418121, 0.008147623389959335, 0.008192028850317001, -0.04226430132985115, -0.14707344770431519, -0.004792605526745319, -0.017526425421237946, 0.0343162827193737, -0.05013037845492363, -0.01801663264632225, 0.08710764348506927, -0.042735569179058075, 0.03628616780042648, -0.015724727883934975, -0.008891133591532707, -0.003719963598996401, 0.02263001725077629, -0.02164270542562008, 0.10674150288105011, 0.009619713760912418, -0.011910711415112019, 0.11727151274681091, 0.16087032854557037, -0.01947709731757641, -0.034045714884996414, 0.005316175986081362, -0.0004103647079318762, 0.02121054381132126, -0.011808312498033047, 0.03762277960777283, -0.026757407933473587, 0.009622270241379738, -0.015477851033210754, -0.007893630303442478, -0.04162207618355751, 0.013969648629426956, 0.0380333848297596, 0.023012345656752586, 0.06562469154596329, -0.021454282104969025, -0.01898132637143135, 0.03691721335053444, -0.008930196054279804, -0.006943488027900457, 0.04381067678332329, 0.040852855890989304, 0.007950994186103344, -0.03233353793621063, 0.07762004435062408, 0.018945198506116867, -0.06102779135107994, -0.012474175542593002, 0.008512584492564201, 0.002461093245074153, 0.024804558604955673, -0.04723147302865982, 0.008797576650977135, -0.024251259863376617, -0.003014566609635949, -0.07400774955749512, -0.008985515683889389, 0.02667193114757538, 0.02139868028461933, 0.028361817821860313, -0.008324588648974895, 0.06472177058458328, -0.05698949471116066, 0.07570747286081314, -0.08680117130279541, 0.04826279729604721, 0.018012870103120804, 0.008717771619558334, 0.048431433737277985, 0.10459312796592712, 0.03504430875182152, 0.011724789626896381, 0.010763912461698055, -0.04858149215579033, 0.0628812164068222, 0.03708336874842644, 0.01813632622361183, 0.06292214244604111, -0.05142185464501381, 0.030604097992181778, 0.019594816491007805, 0.032552316784858704, 0.062028057873249054, 0.03593013063073158, -0.02578771486878395, 0.10781269520521164, -0.02546580322086811, 0.03586481511592865, -0.0036948337219655514, -0.0023401067592203617, 0.05257277935743332, 0.03970853611826897, 0.015968170017004013, -0.01160024106502533, 0.023768123239278793, 0.0006358929676935077, -0.023292645812034607, -0.006588985212147236, 0.02069847658276558, -0.021096276119351387, -0.03946694731712341, 0.032880429178476334, 0.03924279659986496, -0.021917356178164482, -0.08861520141363144, 0.09159832447767258, -0.13159944117069244, 0.0049354624934494495, -0.03797031566500664, -0.05324849113821983, 0.015511550940573215, -0.013819283805787563, -0.012475552037358284, 0.17123264074325562, 0.011041696183383465, 0.07402170449495316, 0.0032891130540519953, -0.03527818247675896, -0.01872866600751877, 0.026446109637618065, 0.06285403668880463, 0.02640511468052864, -0.02989894151687622, -0.029306333512067795, -0.05120718479156494, -0.060751691460609436, 0.025863967835903168, 0.012596126645803452, -0.018225857987999916, 0.006352372467517853, 0.017787599936127663, -0.04273685812950134, 0.018490351736545563, 0.02090158499777317, -0.0339537151157856, -0.00939697865396738, 0.024069136008620262, 0.038870491087436676, 0.009581558406352997, 0.054389942437410355, 0.020670918747782707, -0.09609927237033844, 0.0035903810057789087, -0.06457782536745071, 0.013111858628690243, 0.02632742188870907, 0.018878068774938583, 0.005891161505132914, 0.012946432456374168, 0.0064598508179187775, 0.0168351661413908, 0.005362821742892265, 0.06220116466283798, -0.008644438348710537, -0.013910125941038132, -0.049861785024404526, -0.039597608149051666, -0.009401742368936539, -0.014665058813989162, -0.009322965517640114, -0.009883430786430836, -0.022971713915467262, -0.06972727924585342, 0.02371448278427124, -0.035603366792201996, -0.0030514956451952457, 0.01844210736453533, 0.04274062439799309, 0.03642619773745537, 0.045106835663318634, -0.02111341618001461, -0.040179479867219925, -0.020886024460196495, 0.013569213449954987, -0.0404759980738163, 0.02156483754515648, -0.0017616881523281336, 0.05967148765921593, 0.03984038159251213, 0.054706744849681854, -0.04704185575246811, -0.039635069668293, 0.03372449800372124, 0.0404723584651947, 0.02935457043349743, 0.009612183086574078, 0.0007922004442662001, 0.022323736920952797, 0.03268866240978241, 0.0014267140068113804, -0.040478434413671494, -0.014711283147335052, -0.008801848627626896, -0.006995628587901592, 0.0008803031523711979, 0.04212723672389984, 0.0077646649442613125, -0.030113646760582924, 0.017539499327540398, 0.021027222275733948, -0.05856846272945404, -0.08102111518383026, 0.004135227296501398, -0.01804509200155735, -0.01168751623481512, 0.004531246609985828, -0.009227806702256203, 0.0014903831761330366, 0.009489662013947964, -0.010395289398729801, 0.04325909912586212, 0.0027815154753625393, 0.018019307404756546, 0.004561309702694416, -0.005774930119514465, -0.012900264002382755, 0.0004914157907478511, 0.03209342435002327, 0.012204581871628761, 0.04370306059718132, 0.037182021886110306, -0.052181586623191833, 0.0012829351471737027, 0.007885538041591644, -0.01361773256212473, -0.014957976527512074, -0.02469920739531517, 0.049254026263952255, -0.002351227914914489, -0.03995167464017868, -0.048010628670454025, 0.043234288692474365, -0.04175693169236183, 0.002814575796946883, -0.017518997192382812, -0.05853674188256264, -0.02833857573568821, -0.008276693522930145, 0.019857965409755707, 0.028426656499505043, -0.01637791469693184, -0.011109997518360615, 0.005308425985276699, 0.016878614202141762, 0.000785541080404073, -0.0009798718383535743, -0.01518669817596674, 0.018339967355132103, 0.041036639362573624, -0.014054795727133751, -0.037474241107702255, -0.06108688563108444, -0.02813906967639923, 0.010179798118770123, 0.04799976944923401, -0.018805457279086113, 0.028813933953642845, 0.005174766760319471, 0.007446018513292074, 0.006480103358626366, -0.03817179799079895, -0.08633596450090408, 0.012289156205952168, -0.008340694941580296, -0.06752454489469528, 0.011809824034571648, 0.030528806149959564, 0.005810741800814867, -0.006709041073918343, -0.03130703046917915, 0.011486082337796688, 0.0013492220314219594, 0.029215428978204727, -0.023371132090687752, 0.009068376384675503, -0.023227659985423088, -0.007245319429785013, 0.019805699586868286, -0.058259326964616776, 0.040801770985126495, 0.01666584052145481, -0.019737476482987404, 0.013528375886380672, 0.01718098297715187, -0.023107880726456642, -0.014406883157789707, -0.004840532783418894, 0.052701592445373535, -0.0009006712934933603, 0.021482665091753006, 0.017580199986696243, 0.004451428074389696, -0.00937871914356947, -0.010738151147961617, -0.01688181608915329, -0.008725299499928951, -0.054047416895627975, 0.017768394201993942, 0.03602822870016098, 0.002319934545084834, -0.006104214582592249, -0.011849491856992245, -0.022478647530078888, -0.02326861210167408, 0.02010142244398594, -0.008797013200819492, -0.0039001458790153265, -0.005657965317368507, -0.009877319447696209, 0.002377744298428297, -0.026233451440930367, -0.01713814027607441, -0.009725315496325493, -0.01638432778418064, -0.02089555934071541, 0.01374688372015953, 0.05715808644890785, -0.010532014071941376, -0.03811042755842209, -0.03719606623053551, 0.05559274181723595, -0.02413184382021427, 0.006887751631438732, 0.03438860550522804, -0.039644379168748856, -0.020891772583127022, -0.005623113829642534, 0.005027093458920717, -0.007741017732769251, -0.003150947391986847, 0.01471712626516819, -0.013586260378360748, -0.01387720461934805, 0.04510224610567093, -0.01352777797728777, 0.01357960607856512, 0.00027328464784659445, 0.02573513239622116, 0.0252201147377491, 0.007352782879024744, -0.001569068874232471, -0.010639261454343796, -0.014025268144905567, 0.05694219097495079, -0.014538366347551346, 0.005801632069051266, 0.03980913385748863, -0.03747188672423363, 0.03420610725879669, -0.03445923328399658, 0.016613231971859932, 0.029260877519845963, 0.0115534458309412, -0.02586318366229534, -0.03334302082657814, 0.0547613687813282, 0.00009121079347096384, 0.018053140491247177, -0.002465988975018263, -0.006975369527935982, 0.023580102249979973, -0.03477505221962929, 0.01450189296156168, 0.01630472205579281, 0.02240653522312641, -0.005833267234265804, 0.02440958097577095, 0.008685125969350338, -0.04882580414414406, -0.029518624767661095, -0.018448369577527046, -0.005250745452940464, 0.008534511551260948, 0.016889043152332306, -0.05672730877995491, -0.02642197161912918, 0.07296891510486603, 0.026702260598540306, 0.008948501199483871, 0.01592603139579296, 0.019325535744428635, -0.025476504117250443, -0.018386732786893845, 0.05830582603812218, -0.036346640437841415, 0.014184562489390373, 0.029723210260272026, 0.06875978410243988, 0.051112622022628784, 0.013525513932108879, -0.02668631449341774, -0.009838571771979332, 0.01652713306248188, 0.010734792798757553, -0.001125881914049387, -0.024171655997633934, -0.03000209480524063, 0.0071921562775969505, 0.0019451436819508672, -0.018958309665322304, -0.051973070949316025, 0.016008950769901276, 0.06354425847530365, -0.031647417694330215, -0.020184116438031197, 0.0112516600638628, -0.0069797770120203495, -0.008215791545808315, 0.019613832235336304, 0.04669387266039848, -0.004578114952892065, -0.0030145621858537197, 0.012956940568983555, -0.004425166640430689, -0.0140854362398386, 0.012242844328284264, -0.04349513724446297, -0.04703108221292496, 0.018157195299863815, -0.02052880823612213, 0.02310020476579666, -0.0316457599401474, -0.043873872607946396, -0.014841635711491108, -0.003337692469358444, 0.008603150025010109, -0.08169521391391754, 0.031246578320860863, 0.004714732989668846, 0.0055161393247544765, 0.036505524069070816, 0.0330364853143692, -0.021056491881608963, 0.005389168858528137, -0.018503261730074883, 0.04569526016712189, -0.013722315430641174, -0.020007863640785217, 0.046288974583148956, 0.04824360832571983, -0.012780623510479927, -0.0013457546010613441, 0.004659109748899937, -0.08003251999616623, 0.029837418347597122, -0.05839290842413902, 0.059554558247327805, 0.09410881996154785, 0.013439911417663097, 0.020548148080706596, -0.00846503023058176, 0.003972889855504036, 0.02240343764424324, -0.028404923155903816, 0.0007590939640067518, -0.02460058405995369, 0.02490568719804287, 0.008333149366080761, -0.008550234138965607, -0.0067897578701376915, 0.019072536379098892, 0.010155458003282547, 0.0031127342954277992, -0.016045941039919853, 0.01359760295599699, -0.016091717407107353, -0.009842492640018463, -0.01664210855960846, -0.08824128657579422, 0.014290032908320427, -0.01671048253774643, 0.02015535533428192, 0.038193248212337494, -0.04272254928946495, 0.027908310294151306, -0.0059796045534312725, 0.007786205969750881, 0.025742171332240105, 0.045522093772888184, -0.027822701260447502, 0.022318394854664803, 0.02081199549138546, 0.04800625890493393, 0.034117575734853745, 0.01956118270754814, 0.005277873948216438, 0.04031108319759369, 0.050122518092393875, -0.013331239111721516, 0.04679574817419052, 0.06072234734892845, -0.02387506514787674, 0.0013710384955629706, -0.020280122756958008, -0.010159273631870747, -0.00675062695518136, 0.0295626912266016, 0.021126899868249893, -0.010189625434577465, -0.00032383151119574904, -0.016498703509569168, 0.001528695342130959, 0.0333748422563076, 0.04816688969731331, -0.005454265512526035, 0.001446126843802631, 0.03858305886387825, 0.010842427611351013, 0.009417633526027203, 0.015010770410299301, 0.017001129686832428, -0.01144727785140276, 0.000864915840793401, 0.0057811858132481575, -0.015041666105389595, 0.010166013613343239, 0.04157057777047157, 0.012316647917032242, -0.00956485141068697, -0.053494829684495926, 0.03325244039297104, 0.008363387547433376, -0.006854434497654438, -0.0283990278840065, 0.03327666595578194, -0.014559903182089329, -0.01706915907561779, -0.03437180072069168, -0.017211640253663063, -0.04540334641933441, 0.014863327145576477, 0.027177564799785614, 0.03000926785171032, 0.009301437996327877, -0.0491609089076519, -0.012634498067200184, 0.020220395177602768, 0.04504704847931862, 0.016877690330147743, 0.005238033831119537, -0.011482476256787777, -0.017343467101454735, 0.01659790612757206, -0.009791640564799309, 0.010724537074565887, 0.020161891356110573, -0.010905636474490166, -0.014453875832259655, 0.03401220217347145, 0.03786790743470192, 0.05713653564453125, 0.044818274676799774, 0.016078948974609375, -0.007136794272810221, -0.03344248607754707, -0.0038880575448274612, -0.009383823722600937, 0.04329941049218178, -0.026553258299827576, 0.001668787095695734, 0.007711903192102909, 0.03963174670934677, 0.061307843774557114, -0.007968030869960785, -0.006816389039158821, -0.00653174240142107, 0.006363601889461279, -0.004218874033540487, 0.0030340596567839384, 0.04588060453534126, -0.03602389246225357, -0.005854960530996323, 0.029628166928887367, 0.005670707207173109, 0.06393192708492279, -0.018078729510307312, -0.02512335032224655, 0.07295829802751541, -0.01710423454642296, 0.025083081796765327, -0.0016484257066622376, 0.08582642674446106, 0.016083091497421265, 0.012981905601918697, 0.05262220650911331, -0.004042480606585741, -0.006588222924619913, -0.010814827866852283, 0.03478362411260605, -0.03959950804710388, -0.03432857245206833, -0.03603970631957054, -0.04137977212667465, -0.011094101704657078, 0.006868839729577303, -0.0413321852684021, 0.011564371176064014, -0.030996501445770264, -0.010429777204990387, -0.007759869564324617, -0.04800082743167877, -0.011603111401200294, -0.017880558967590332, 0.023004824295639992, 0.03517777472734451, 0.019235344603657722, 0.02431921474635601, -0.030598342418670654, 0.02297959104180336, -0.03554747998714447, 0.05679144710302353, 0.024722445756196976, 0.013035042211413383, -0.03375940024852753, -0.02496686950325966, 0.013203081674873829, 0.03360128402709961, -0.08232852816581726, 0.01828700676560402, -0.017936421558260918, -0.012716945260763168, -0.06420985609292984, -0.0034574326127767563, 0.0184228103607893, 0.015927894040942192, 0.009150938130915165, -0.029849812388420105, -0.04390449449419975, -0.024424053728580475, -0.012552439235150814, -0.019488928839564323, -0.016016589477658272, -0.07223141193389893, -0.0015571024268865585, -0.009233013726770878, -0.0020350501872599125, -0.020918240770697594, -0.018101761117577553, -0.04256998375058174, -0.008243350312113762, 0.0070219486951828, -0.026542767882347107, -0.053078874945640564, 0.017170662060379982, 0.06745041906833649, -0.013918505050241947, -0.012818966060876846, 0.011877131648361683, 0.035488031804561615, -0.0308493971824646, -0.012297007255256176, 0.005140576045960188, 0.020578695461153984, 0.0005536997341550887, -0.047620099037885666, -0.0105205113068223, 0.019879058003425598, -0.028556333854794502, -0.08100220561027527, -0.035626333206892014, -0.006556560285389423 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
Conclusion We're excited to see what you're working on with Stable-baselines3 and try your models in the Hub 😍. And we would love to hear your feedback 💖. 📧 Feel free to [reach us](mailto:[email protected]). Finally, we would like to thank the SB3 team and in particular [Antonin Raffin](https://araffin.github.io/) for their precious help for the integration of the library 🤗.
[ 0.04599161446094513, -0.01654084026813507, 0.06585900485515594, 0.0047148242592811584, 0.05002879351377487, 0.03902490809559822, -0.003536313772201538, 0.01670365408062935, -0.07440768927335739, -0.11797995865345001, -0.009905974380671978, 0.018826009705662727, -0.011267055757343769, 0.0032223460730165243, -0.04378025606274605, -0.024519966915249825, 0.04926113411784172, -0.0005498997052200139, -0.002376025076955557, 0.045873116701841354, -0.030798712745308876, -0.0419241264462471, 0.005447749048471451, -0.025104837492108345, -0.01616828329861164, -0.06608449667692184, 0.05879073590040207, 0.007506086956709623, -0.007052300032228231, 0.002466866048052907, -0.06117874011397362, -0.004482689313590527, -0.005442581605166197, -0.0616510733962059, 0.048571571707725525, 0.021120591089129448, -0.09830767661333084, 0.0681675374507904, 0.024924736469984055, -0.03156520798802376, 0.018450725823640823, -0.010387910529971123, -0.05386026203632355, 0.0332922525703907, 0.04241412878036499, -0.06040414422750473, -0.1928344964981079, 0.07663853466510773, 0.009137769229710102, 0.007537413388490677, -0.07116907835006714, 0.0731334537267685, -0.02268102951347828, -0.0008644541376270354, 0.0032567980233579874, -0.013371179811656475, -0.009628954343497753, -0.072051502764225, 0.045500826090574265, 0.0006760764517821372, 0.010769241489470005, -0.006215832661837339, 0.02042202837765217, 0.011391163803637028, 0.028100501745939255, 0.08442824333906174, -0.02620760165154934, -0.01164287980645895, -0.030957484617829323, 0.020854029804468155, 0.06657487899065018, 0.011364103294909, -0.012642541900277138, -0.014552794396877289, 0.030931441113352776, 0.017040332779288292, -0.021727832034230232, 0.029755793511867523, 0.01902010291814804, -0.0017590406350791454, 0.005488929338753223, -0.021965576335787773, 0.05288124457001686, 0.07492954283952713, -0.014038999564945698, 0.05179250240325928, 0.08571141958236694, -0.08221041411161423, -0.014427350834012032, 0.020125042647123337, -0.04466577246785164, -0.12221494317054749, 0.011083004996180534, 0.03045509196817875, 0.032030198723077774, -0.02757936902344227, 0.007024306803941727, -0.007209408096969128, -0.009836210869252682, -0.04616626724600792, 0.012549486011266708, -0.026353711262345314, -0.011516989208757877, -0.09747663140296936, 0.006505488883703947, 0.003492794930934906, -0.0018411759519949555, -0.10407117009162903, -0.039489950984716415, -0.020970752462744713, 0.03384065255522728, -0.031239019706845284, 0.007984478957951069, 0.04374653846025467, -0.07085535675287247, 0.07384754717350006, -0.0768011063337326, -0.006759850308299065, 0.015255659818649292, 0.02907947264611721, 0.03266526758670807, 0.11189597100019455, 0.004285138566046953, 0.01569943130016327, 0.034130632877349854, 0.10872329771518707, -0.0006835891981609166, -0.016321728006005287, -0.03239532560110092, -0.03473879024386406, -0.00038660739664919674, -0.04184553772211075, 0.037342485040426254, 0.002112181391566992, -0.021433185786008835, -0.06591396033763885, -0.021176449954509735, -0.06123527139425278, 0.037152841687202454, 0.05555523931980133, 0.017993519082665443, 0.02232079580426216, -0.013592232018709183, 0.06578521430492401, 0.06820610910654068, -0.010158187709748745, -0.0893980860710144, 0.06568294763565063, -0.03523190692067146, -0.04097754508256912, 0.021216757595539093, 0.05221514031291008, -0.09087155014276505, -0.0354587659239769, -0.01463479083031416, 0.05157793313264847, -0.0044235168024897575, -0.04572096839547157, -0.04923105984926224, 0.03088083304464817, 0.00016182777471840382, -0.012704959139227867, -0.07581672817468643, -0.005703743547201157, 0.08737393468618393, -0.025838203728199005, 0.013770136050879955, 0.015375811606645584, 0.006369768176227808, -0.03568211570382118, 0.055546462535858154, -0.04714716225862503, 0.05594839155673981, -0.02626516856253147, -0.02322457917034626, 0.02821970544755459, 0.10208404064178467, 0.030026467517018318, 0.03957029804587364, 0.015291682444512844, -0.055572621524333954, 0.051575854420661926, 0.06039711460471153, 0.03849632665514946, 0.04367038980126381, -0.03896576538681984, 0.03918309509754181, 0.02528240531682968, -0.01510982308536768, 0.026114126667380333, -0.036088164895772934, -0.006950180511921644, 0.11676815897226334, -0.012782411649823189, 0.00974796712398529, -0.03486273065209389, -0.02840998023748398, 0.10202653706073761, 0.027604252099990845, 0.07309938967227936, 0.02205948531627655, 0.024184174835681915, 0.04570193216204643, -0.0036414002534002066, -0.018305344507098198, 0.04226088896393776, 0.02716796100139618, -0.04098949953913689, 0.014056509360671043, 0.06710328906774521, -0.004730449989438057, -0.11720619350671768, 0.05691210553050041, -0.07617687433958054, -0.024381939321756363, -0.02832203358411789, -0.010439612902700901, -0.019329706206917763, 0.03682933747768402, -0.031222866848111153, 0.18515004217624664, 0.011983816511929035, 0.025608070194721222, 0.004296399187296629, -0.029932525008916855, 0.05082643777132034, 0.10251127183437347, 0.07220679521560669, 0.06446923315525055, -0.07644227892160416, 0.012945042923092842, -0.06429890543222427, -0.04127185791730881, 0.04353848844766617, -0.013145647943019867, 0.002345190616324544, -0.009824865497648716, -0.05072402209043503, 0.007084032520651817, -0.026367826387286186, 0.005703600123524666, 0.0062444014474749565, 0.014553100802004337, 0.057783935219049454, -0.02529771439731121, -0.04869518056511879, 0.04790273308753967, -0.009942762553691864, -0.08251149952411652, 0.01123039796948433, -0.05154476314783096, 0.07026316225528717, -0.038590338081121445, -0.02245360054075718, 0.04109816625714302, 0.04201803728938103, 0.01916716806590557, 0.0006881890003569424, -0.026393121108412743, 0.04315919056534767, 0.027751604095101357, -0.011445840820670128, -0.013245598413050175, -0.0401875302195549, -0.013949882239103317, -0.019680891185998917, -0.009049560874700546, -0.026265854015946388, -0.008175925351679325, 0.00039558851858600974, 0.022295041009783745, -0.032988302409648895, 0.0397871769964695, 0.040723685175180435, 0.012214963324368, 0.006577085237950087, 0.02638235129415989, -0.01844797097146511, -0.031195709481835365, -0.022550217807292938, -0.013637660071253777, -0.03722235932946205, 0.04998501390218735, 0.01680799573659897, 0.04785390570759773, 0.008887418545782566, 0.019937071949243546, -0.02512439340353012, -0.04464676231145859, -0.00506481621414423, 0.007749209180474281, 0.03158053755760193, 0.009887970052659512, -0.03980877622961998, 0.0322057344019413, 0.02555093728005886, -0.017827022820711136, -0.011613729409873486, -0.02077583782374859, 0.006653869524598122, -0.008780091069638729, 0.012521437369287014, -0.012756585143506527, 0.021569667384028435, -0.013382922857999802, 0.03036610595881939, 0.006284466478973627, 0.005525972228497267, -0.11069396883249283, -0.020376568660140038, 0.0013960490468889475, 0.04310736805200577, -0.016750995069742203, -0.050243910402059555, 0.021589359268546104, -0.06127401068806648, 0.006120877806097269, 0.022488469257950783, 0.007345064077526331, 0.021202392876148224, 0.023383965715765953, -0.005227663088589907, -0.028622150421142578, -0.029261544346809387, 0.02911967597901821, 0.0033031797502189875, 0.050998348742723465, -0.005416002124547958, -0.02530578337609768, 0.002298603765666485, 0.0009697090135887265, 0.006794457323849201, -0.02489335462450981, 0.006645538844168186, 0.02521764487028122, 0.03018500842154026, 0.015544596128165722, -0.02396300993859768, -0.010120293125510216, -0.005751655902713537, -0.006854876410216093, 0.014883278869092464, -0.0652659460902214, 0.000010676245437934995, -0.030443809926509857, 0.004601634107530117, 0.013488116674125195, 0.01314051914960146, 0.012643339112401009, 0.02371411770582199, 0.001876570051535964, -0.008262420073151588, 0.010231342166662216, -0.01857525110244751, 0.012672580778598785, 0.017283517867326736, 0.03232528641819954, -0.01589694619178772, -0.018838882446289062, 0.027542786672711372, -0.011362086981534958, 0.0687129870057106, 0.011876329779624939, 0.04279021918773651, -0.04665388911962509, 0.01765947788953781, 0.02560684271156788, -0.0031673877965658903, -0.039415813982486725, 0.015218324027955532, -0.009889853186905384, -0.016134334728121758, -0.011295168660581112, 0.02965535596013069, 0.005637156777083874, -0.019510991871356964, -0.02450762316584587, 0.03469499945640564, 0.03161820024251938, 0.04997511953115463, -0.024636922404170036, 0.005388499703258276, -0.020870892331004143, 0.005091944709420204, 0.006489581428468227, -0.06468337029218674, 0.05849931761622429, -0.0001521296362625435, -0.022917984053492546, -0.01445617713034153, 0.000384996528737247, -0.021911606192588806, -0.0067133172415196896, 0.011981924995779991, 0.03201271966099739, 0.0020509848836809397, 0.0225217342376709, 0.029218217357993126, -0.011093941517174244, -0.02072778530418873, 0.01478592399507761, -0.032942257821559906, -0.010139234364032745, -0.019349070265889168, 0.05574968457221985, 0.016871819272637367, 0.03892389312386513, 0.0047025056555867195, 0.03985586017370224, -0.03751625493168831, 0.018368281424045563, -0.019771113991737366, 0.02202007919549942, 0.06401818990707397, -0.04881760850548744, -0.04324081912636757, 0.000247289048274979, -0.0229099839925766, 0.01781495101749897, -0.05718879774212837, -0.0041779703460633755, -0.01244775578379631, 0.01815812475979328, 0.030899906530976295, -0.02127690613269806, -0.05189822241663933, -0.02406948059797287, 0.043449271470308304, -0.014597278088331223, 0.0007984264520928264, 0.009465791285037994, 0.0108171496540308, 0.007104973308742046, -0.04597180336713791, -0.02800682559609413, 0.00794400367885828, 0.013469492085278034, 0.006344569846987724, 0.006463026627898216, -0.027888692915439606, 0.00015831520431675017, -0.011615313589572906, 0.012605850584805012, 0.03260989487171173, -0.032563019543886185, 0.03709077835083008, 0.001729678246192634, -0.04011048004031181, -0.025878775864839554, -0.0019814707338809967, 0.028933802619576454, -0.04323940351605415, 0.00549094844609499, 0.03355561941862106, -0.0347924530506134, 0.020011166110634804, -0.010130287148058414, 0.04354802519083023, 0.043035365641117096, -0.03872058540582657, -0.04880482330918312, -0.01602734997868538, 0.010905805043876171, -0.027483979240059853, -0.016826177015900612, -0.01680006831884384, -0.005844517610967159, 0.023422785103321075, -0.04523567855358124, 0.010568011552095413, -0.0056915623135864735, 0.01656709611415863, -0.003992599435150623, -0.027487939223647118, 0.00002998316631419584, -0.06310916692018509, -0.01572388969361782, -0.009448228403925896, -0.01377219520509243, 0.005021164193749428, 0.007232779171317816, -0.03564444184303284, -0.02204277366399765, 0.0569666251540184, 0.03769969195127487, 0.004990623332560062, 0.013219742104411125, 0.041470304131507874, -0.03562430292367935, 0.020219499245285988, 0.04123416543006897, -0.02841208688914776, 0.02583739534020424, 0.050803061574697495, 0.04495125636458397, 0.02967853844165802, -0.002526884898543358, 0.037877365946769714, -0.026477592065930367, -0.004160704556852579, 0.023536674678325653, 0.0020530633628368378, -0.017938779667019844, -0.01283335778862238, 0.01557204034179449, -0.0005453843623399734, -0.018481265753507614, -0.0311037078499794, 0.030184293165802956, 0.05467033386230469, -0.021162400022149086, -0.02250266820192337, 0.01654965989291668, 0.023878982290625572, 0.03548136353492737, -0.008894070982933044, 0.06084432825446129, -0.026614593341946602, -0.0013006713707000017, 0.02631201408803463, 0.015211712568998337, -0.02218238078057766, 0.02347000129520893, -0.03919212892651558, -0.04438798129558563, 0.007731996942311525, 0.012088393792510033, 0.03509002551436424, -0.0008269743411801755, -0.013597195968031883, -0.02502906136214733, -0.0009986202931031585, 0.029339689761400223, -0.04528799280524254, -0.011660744436085224, 0.025199836120009422, -0.011128980666399002, 0.03740277141332626, 0.007888211868703365, -0.012490754015743732, 0.007072811480611563, 0.02514006569981575, 0.00063510233303532, -0.015504657290875912, -0.0574553981423378, 0.011749837547540665, 0.03946348652243614, 0.01345890574157238, 0.01199753861874342, -0.018200816586613655, -0.0397697351872921, -0.004159827250987291, -0.07422856241464615, 0.056365832686424255, 0.0838407352566719, -0.016951479017734528, -0.006708680186420679, -0.014607989229261875, 0.006281442474573851, 0.043991558253765106, -0.015893498435616493, -0.012651908211410046, 0.02371266484260559, 0.048760537058115005, -0.014809492975473404, -0.022294797003269196, -0.010915565304458141, -0.018365755677223206, -0.0019023028435185552, -0.054257411509752274, 0.001297059003263712, 0.028539622202515602, -0.03634960949420929, 0.010970503091812134, 0.03611379861831665, -0.04374246299266815, 0.022285129874944687, 0.002282144967466593, 0.008593786507844925, 0.035031795501708984, 0.02008810080587864, -0.020277440547943115, -0.013421673327684402, -0.01669349893927574, 0.02238667570054531, 0.050933606922626495, -0.00721677765250206, -0.007264727260917425, 0.04876699671149254, 0.032560769468545914, 0.05085371062159538, 0.020876476541161537, 0.03146437555551529, 0.01045940164476633, 0.06968039274215698, -0.002691067988052964, 0.03643070161342621, 0.049671515822410583, -0.06403975188732147, -0.01738605834543705, -0.04441237449645996, -0.034901585429906845, -0.001969227334484458, 0.01631617173552513, 0.016216086223721504, 0.015463178046047688, 0.024795589968562126, -0.020830826833844185, 0.018199706450104713, 0.011873829178512096, 0.02999972365796566, 0.017331041395664215, 0.016202222555875778, 0.051353346556425095, 0.0016947472468018532, -0.021535050123929977, 0.0063715167343616486, 0.006530102342367172, -0.034096427261829376, 0.0248740054666996, -0.0014893244951963425, -0.0038453920278698206, -0.02784377709031105, -0.013663574121892452, -0.01190780010074377, -0.04790034890174866, 0.006531700026243925, 0.01477516908198595, 0.04275967925786972, -0.004123270511627197, 0.009155182167887688, 0.009531562216579914, -0.016902059316635132, -0.03582647815346718, -0.01762031950056553, 0.015666456893086433, -0.014503177255392075, 0.017825819551944733, -0.0016196990618482232, 0.03868628293275833, 0.002990921726450324, -0.008922205306589603, 0.023804137483239174, 0.04551638662815094, 0.027796385809779167, 0.03500552102923393, -0.03854302689433098, -0.03755094110965729, -0.029241429641842842, 0.03845471143722534, -0.021987158805131912, -0.009392754174768925, -0.002769172191619873, -0.02121765725314617, -0.024582259356975555, 0.02033473365008831, 0.00935295782983303, -0.0040215919725596905, 0.040330927819013596, -0.0038898319471627474, -0.028345610946416855, 0.011959307827055454, 0.015387453138828278, -0.0053464933298528194, -0.017026985064148903, -0.053536996245384216, -0.0015604340005666018, -0.031135959550738335, 0.028759198263287544, 0.041306838393211365, 0.021874262019991875, -0.05135810747742653, -0.05160605534911156, -0.03344787284731865, -0.00013459520414471626, 0.02335468865931034, 0.01987268216907978, -0.010460259392857552, -0.05399630218744278, -0.022392956539988518, -0.005666227545589209, 0.03136910870671272, -0.03247484192252159, 0.017279451712965965, 0.052874818444252014, -0.02954658679664135, 0.000024169030439225025, 0.004089740104973316, 0.07559151202440262, 0.04948745295405388, 0.028982989490032196, 0.04853669926524162, 0.024495629593729973, 0.02424468845129013, -0.030083749443292618, 0.003123131114989519, -0.020943449810147285, -0.014463361352682114, -0.03530203551054001, -0.011130987666547298, 0.007101748138666153, -0.02114167809486389, -0.014080461114645004, -0.012439572252333164, -0.0318489708006382, 0.016931068152189255, -0.02518044225871563, -0.019894083961844444, -0.021296469494700432, 0.014622711576521397, 0.039657577872276306, 0.028957143425941467, 0.03290015086531639, 0.011253353208303452, -0.018886549398303032, 0.04616766422986984, -0.0023012999445199966, 0.03593842312693596, 0.041045911610126495, 0.008510005660355091, -0.0088190957903862, -0.02065570279955864, 0.007458754349499941, -0.02017459273338318, -0.08933025598526001, -0.009009352885186672, 0.009814473800361156, -0.0030342035461217165, -0.024494802579283714, 0.025589749217033386, -0.01019695308059454, 0.013329992070794106, 0.05234534665942192, -0.008479500189423561, -0.05426143854856491, -0.010313604958355427, -0.029751475900411606, -0.020356781780719757, 0.01909211277961731, -0.03283323347568512, 0.012600460089743137, 0.029036015272140503, 0.009392370469868183, -0.03731158748269081, -0.0070067900232970715, -0.022490043193101883, 0.006298013962805271, 0.012132059782743454, -0.01964377798140049, -0.04617494344711304, 0.02341432496905327, 0.007627062499523163, -0.003781014122068882, -0.04626931995153427, 0.02767464518547058, 0.025779010728001595, -0.03432657569646835, -0.052093878388404846, -0.005738662555813789, 0.0022607448045164347, -0.030868250876665115, -0.008498133160173893, -0.004237661138176918, 0.04209902137517929, 0.013841749168932438, -0.052754152566194534, -0.008140652440488338, -0.005348128266632557 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
# Welcome Stable-baselines3 to the Hugging Face Hub 🤗 At Hugging Face, we are contributing to the ecosystem for Deep Reinforcement Learning researchers and enthusiasts. That’s why we’re happy to announce that we integrated Stable-Baselines3 to the Hugging Face Hub. Stable-Baselines3 is one of the most popular PyTorch Deep Reinforcement Learning library that makes it easy to train and test your agents in a variety of environments (Gym, Atari, MuJoco, Procgen...). With this integration, you can now host your saved models 💾 and load powerful models from the community. In this article, we’re going to show how you can do it.
[ 0.01841694489121437, -0.029065879061818123, 0.03124229423701763, 0.01107165776193142, 0.03823387995362282, 0.02216101810336113, 0.02387704700231552, 0.04135235399007797, -0.10136809200048447, -0.10113734751939774, -0.04631601646542549, 0.028022712096571922, -0.013027213513851166, 0.023875370621681213, 0.02153133414685726, -0.0970088467001915, 0.03398912027478218, -0.02954896353185177, -0.0579356923699379, 0.04551522433757782, -0.01576222851872444, -0.05223245173692703, -0.027094079181551933, -0.024858128279447556, -0.057489220052957535, -0.06096561625599861, 0.03223379701375961, -0.030363263562321663, 0.029522953554987907, -0.02501237764954567, -0.07492999732494354, -0.015355856157839298, 0.04254700616002083, -0.020414935424923897, 0.09533542394638062, 0.058382391929626465, -0.11937514692544937, 0.045564450323581696, 0.004184867721050978, -0.05032290890812874, 0.023241102695465088, 0.01687481999397278, -0.051305729895830154, 0.05547918379306793, 0.007597953546792269, -0.03017921932041645, -0.15092921257019043, 0.083465076982975, -0.01568489335477352, -0.05303436890244484, -0.08458220213651657, 0.06890585273504257, -0.02922865003347397, 0.0021090356167405844, 0.003137684892863035, -0.007292600814253092, 0.003986834082752466, -0.04709966480731964, 0.04103165119886398, 0.026844315230846405, 0.026488207280635834, 0.050272054970264435, 0.012220355682075024, 0.05443229898810387, -0.02786272205412388, 0.04180776700377464, 0.0017561352578923106, -0.05180859565734863, -0.01412813551723957, -0.020501114428043365, 0.04654907062649727, 0.05566631257534027, -0.025303538888692856, -0.03655312582850456, 0.023877838626503944, -0.057068485766649246, -0.07956565916538239, 0.03927053138613701, 0.01314958743751049, 0.011763827875256538, -0.0132638243958354, -0.031590536236763, 0.015544461086392403, 0.10131042450666428, 0.008185223676264286, 0.0773104578256607, 0.04064410924911499, -0.10691385716199875, -0.036081016063690186, 0.06040528416633606, -0.018611013889312744, -0.09284697473049164, 0.01179584488272667, 0.0037173088639974594, 0.0481959767639637, 0.0021640099585056305, -0.05353880301117897, -0.022382069379091263, -0.007105336058884859, -0.06126147881150246, -0.0053621744737029076, -0.061407092958688736, 0.005831380374729633, -0.12429182976484299, -0.007462038192898035, 0.03676316887140274, 0.004064746201038361, -0.09162939339876175, -0.034469686448574066, -0.02134278230369091, 0.009325931780040264, -0.05690232664346695, -0.010000725276768208, 0.09561312198638916, -0.061633918434381485, 0.07888954132795334, -0.06642359495162964, -0.011879279278218746, 0.01097988709807396, 0.022364400327205658, 0.011539571918547153, 0.08327887952327728, -0.01107155904173851, 0.046485841274261475, -0.004985435400158167, 0.122460275888443, 0.011593921110033989, -0.02346115931868553, 0.011054113507270813, 0.0037352184299379587, 0.027269672602415085, -0.0395420603454113, 0.04789423197507858, -0.009131472557783127, -0.004388733766973019, -0.044700440019369125, -0.02053678222000599, -0.059549327939748764, 0.045380014926195145, 0.050194911658763885, -0.003890522290021181, 0.023060237988829613, -0.008318671025335789, -0.008982681669294834, 0.07663475722074509, -0.038544949144124985, -0.05582192912697792, 0.07466863095760345, 0.018790237605571747, -0.0357615128159523, -0.00454013841226697, 0.03110482729971409, -0.04963749274611473, -0.07998083531856537, -0.016374031081795692, 0.047127608209848404, -0.05275944620370865, -0.010367732495069504, -0.008319944143295288, 0.022398002445697784, -0.034559573978185654, -0.06366905570030212, -0.04674431309103966, -0.013601318933069706, 0.07777495682239532, -0.00978555902838707, 0.01702624000608921, 0.007478630170226097, 0.05393471196293831, 0.014319016598165035, 0.04896164685487747, -0.03910991922020912, 0.05075535923242569, -0.00964641384780407, -0.026477793231606483, 0.02184242010116577, 0.056251030415296555, 0.0739736333489418, 0.053246963769197464, 0.012672859244048595, -0.06332780420780182, 0.04252893850207329, 0.06111136078834534, 0.011132954619824886, 0.036408182233572006, -0.05517186224460602, 0.04396563395857811, -0.0039262291975319386, 0.014460910111665726, 0.03832937404513359, 0.010851915925741196, 0.0829009860754013, 0.06484243273735046, 0.005862568039447069, 0.06060217320919037, -0.00890740193426609, -0.031153978779911995, 0.07410430163145065, 0.04470434784889221, 0.06259524077177048, 0.02128284052014351, -0.030586328357458115, 0.023167964071035385, -0.0379863865673542, -0.019137196242809296, 0.019505038857460022, -0.008742217905819416, -0.036302369087934494, 0.005258123390376568, 0.021003609523177147, 0.03708101063966751, -0.08414334803819656, 0.04840748384594917, -0.058706045150756836, 0.007514738943427801, -0.042222071439027786, -0.04097859188914299, 0.00898064486682415, 0.01948654092848301, -0.023016903549432755, 0.18416595458984375, -0.03428630530834198, 0.05441702902317047, 0.03719889372587204, -0.0662708431482315, 0.04380997270345688, 0.07112669944763184, 0.056944992393255234, 0.05337582156062126, -0.05190064385533333, -0.004997241776436567, -0.0403367355465889, -0.05642839893698692, 0.0312485471367836, -0.03738081455230713, -0.03265301138162613, 0.0366351455450058, -0.005312746856361628, 0.015108371153473854, -0.0009754252969287336, 0.013973030261695385, -0.023544564843177795, 0.03747684881091118, 0.037238720804452896, 0.030850397422909737, -0.03472832590341568, 0.04422181472182274, -0.023932471871376038, -0.058213308453559875, -0.017225859686732292, -0.0655156672000885, 0.004632800817489624, 0.01758784055709839, 0.0286038126796484, 0.027983974665403366, 0.07846123725175858, 0.024221019819378853, 0.02049521915614605, -0.0012183587532490492, 0.06123858317732811, 0.031361788511276245, 0.011398674920201302, -0.0020434088073670864, -0.0387602299451828, -0.01752614974975586, -0.02510637603700161, 0.000704703910741955, -0.004654415883123875, -0.013365674763917923, -0.026880502700805664, 0.0585724376142025, -0.040022458881139755, 0.01340270135551691, -0.011434928514063358, 0.019651608541607857, 0.038195401430130005, 0.05359051376581192, -0.002499242778867483, -0.04620804637670517, -0.0008661012398079038, -0.03432552516460419, -0.05176793411374092, 0.04157277196645737, 0.011182252317667007, 0.030938897281885147, 0.020875781774520874, 0.0173003189265728, -0.011657148599624634, -0.029657533392310143, 0.010862001217901707, 0.04593595117330551, 0.03868459537625313, -0.0024723203387111425, -0.005499558988958597, 0.0312659814953804, 0.005184682551771402, 0.028708653524518013, -0.05596880987286568, -0.034052733331918716, 0.001441565458662808, -0.0029354721773415804, -0.014525307342410088, -0.002370200352743268, 0.033498674631118774, 0.010919686406850815, 0.0209673959761858, 0.021240418776869774, -0.021364031359553337, -0.09225941449403763, -0.032339707016944885, -0.024173777550458908, 0.016482632607221603, 0.008175891824066639, -0.06083868071436882, 0.02003106102347374, -0.023573124781250954, 0.020747365429997444, 0.039939332753419876, 0.005595862865447998, 0.0013194885104894638, 0.002527075819671154, 0.02865823358297348, -0.04435032233595848, -0.018835213035345078, 0.04233928397297859, -0.005107563454657793, 0.03906698524951935, -0.01316823810338974, -0.03609735146164894, 0.04234423488378525, 0.015705062076449394, 0.0016489082481712103, -0.029231371358036995, -0.013472302816808224, 0.044288791716098785, 0.019262300804257393, -0.02422397769987583, -0.032116346061229706, -0.009090815670788288, -0.008044490590691566, -0.0038608303293585777, 0.0013365435879677534, -0.06968333572149277, -0.0013816154096275568, -0.005835407879203558, 0.012768231332302094, 0.03875868394970894, -0.01615176908671856, 0.003944477532058954, 0.011599957942962646, -0.006775194313377142, -0.02780834212899208, 0.02706604078412056, -0.013654005713760853, -0.022738346830010414, 0.020190803334116936, 0.005982804577797651, -0.044045340269804, -0.033469025045633316, -0.005780523642897606, 0.0011397273046895862, 0.06757308542728424, -0.007731078192591667, 0.02846594527363777, -0.013234666548669338, 0.0036817467771470547, 0.006593167316168547, -0.015022574923932552, -0.06152578815817833, 0.017514683306217194, -0.0029833181761205196, -0.051448579877614975, 0.0035489602014422417, 0.0029417856130748987, -0.008500614203512669, -0.047112058848142624, -0.015973974019289017, 0.0025621727108955383, 0.025313450023531914, 0.02317844144999981, -0.023463115096092224, 0.0038206002209335566, -0.07554125040769577, -0.013627392239868641, 0.017800018191337585, -0.06739526242017746, 0.05142224207520485, 0.010026159696280956, -0.026269113644957542, -0.008476019836962223, 0.005103648640215397, -0.019764892756938934, -0.004937588237226009, -0.03362539783120155, 0.021837281063199043, -0.01802719756960869, 0.004678986966609955, 0.03818550705909729, -0.011431188322603703, -0.014577609486877918, -0.013390740379691124, -0.018428713083267212, 0.017609840258955956, -0.011577920988202095, 0.03058275766670704, 0.037831034511327744, 0.04275243356823921, 0.02898980677127838, 0.02261991612613201, -0.06020530313253403, 0.027234887704253197, -0.02654026262462139, -0.009830715134739876, 0.0328783355653286, -0.02076316624879837, -0.007614992558956146, 0.0005095949163660407, -0.014105290174484253, 0.012678444385528564, -0.015721600502729416, -0.005173642188310623, -0.02658400498330593, 0.07188655436038971, 0.002435029949992895, -0.012506727129220963, -0.019335012882947922, -0.029030555859208107, 0.02962932549417019, -0.016066186130046844, 0.027605436742305756, 0.035669535398483276, 0.018754130229353905, 0.0019425601931288838, -0.035778582096099854, -0.004241774789988995, -0.007845236919820309, 0.026328664273023605, -0.03632059320807457, -0.01378354150801897, 0.008756411261856556, 0.03363665193319321, 0.02846456877887249, 0.0032496540807187557, -0.010009324178099632, -0.013814443722367287, 0.022936847060918808, -0.01865188591182232, -0.033866770565509796, -0.03445211052894592, 0.0029324046336114407, 0.055513955652713776, -0.054274506866931915, 0.018502499908208847, 0.022211816161870956, -0.043376389890909195, 0.027707722038030624, -0.01994071528315544, 0.04769177362322807, 0.03402496501803398, -0.007492243777960539, -0.046485330909490585, -0.024897128343582153, 0.05515298619866371, -0.05037402734160423, -0.04290978983044624, 0.006397915538400412, -0.011507194489240646, 0.02134673297405243, -0.013848988339304924, -0.006298952270299196, 0.018249833956360817, 0.018289273604750633, 0.018545694649219513, -0.011074962094426155, 0.015270357951521873, -0.06694876402616501, -0.011186925694346428, -0.015390596352517605, -0.02319345809519291, 0.004144478123635054, 0.005137650296092033, -0.033262722194194794, -0.002639885526150465, 0.06434009224176407, 0.0286922138184309, 0.014529004693031311, 0.000786076532676816, 0.014766547828912735, -0.012916473671793938, 0.007815402932465076, 0.03531162068247795, -0.0299212709069252, 0.027249380946159363, 0.017330434173345566, 0.04712607339024544, 0.04155523329973221, 0.011993976309895515, 0.006874647457152605, -0.009383408352732658, 0.00643862783908844, -0.0006350616458803415, 0.013933910988271236, 0.02693064883351326, 0.0058002048172056675, -0.006467014085501432, 0.017623530700802803, 0.0016067641554400325, -0.05730428174138069, -0.0011636863928288221, 0.03268107399344444, -0.008777599781751633, 0.01914786361157894, 0.013881930150091648, 0.008975538425147533, -0.008316123858094215, 0.007308183237910271, 0.05544278025627136, -0.02693386934697628, 0.022949518635869026, 0.03483112156391144, 0.027185283601284027, -0.00943613238632679, 0.02261311747133732, -0.03836481273174286, -0.045672595500946045, -0.01291270274668932, -0.01962932012975216, 0.019748259335756302, -0.019383346661925316, -0.008433018811047077, -0.01613304764032364, -0.03995893895626068, 0.013044298626482487, -0.06394094228744507, -0.0021789392922073603, -0.0004946626140736043, 0.015901261940598488, 0.01509654987603426, 0.031680066138505936, 0.011487526819109917, 0.03453299403190613, 0.010466549545526505, 0.018745938315987587, -0.03126475214958191, -0.0532505139708519, 0.040507737547159195, 0.0540139265358448, -0.007622977718710899, -0.031120747327804565, 0.0014929786557331681, -0.03156980127096176, -0.00417366111651063, -0.05644535645842552, 0.0493561215698719, 0.07766969501972198, 0.011542103253304958, 0.01561451144516468, -0.02790597826242447, 0.00611859280616045, 0.03289760276675224, -0.018338603898882866, -0.03609168156981468, 0.03844621777534485, 0.03579108789563179, 0.020036619156599045, -0.019644176587462425, 0.000007094604370649904, -0.00015070346125867218, 0.004134620074182749, -0.026008915156126022, 0.009761979803442955, 0.03749370947480202, -0.03999429568648338, -0.009850943461060524, 0.02576521784067154, -0.06286948919296265, -0.001792490715160966, 0.007976492866873741, 0.012257472611963749, 0.022095056250691414, 0.014029445126652718, 0.028896514326334, 0.017597679048776627, -0.020053565502166748, 0.027966702356934547, 0.04643143340945244, -0.026383910328149796, 0.01717323251068592, 0.023055993020534515, 0.03691934049129486, 0.03530535474419594, 0.002012191340327263, 0.02930937334895134, 0.02088572457432747, 0.03909547999501228, -0.013253889046609402, 0.03534149378538132, 0.07630322128534317, -0.029823504388332367, -0.03479088842868805, -0.033358946442604065, -0.03617499768733978, 0.00379395205527544, 0.020185960456728935, 0.03207095339894295, -0.013486688956618309, 0.007346628233790398, -0.013732419349253178, 0.020051689818501472, 0.04305054992437363, 0.024903370067477226, 0.0127142034471035, 0.036777615547180176, 0.048219628632068634, 0.038240741938352585, 0.03693601116538048, -0.025011012330651283, 0.014075363986194134, -0.0222796518355608, 0.011668533086776733, 0.042799632996320724, 0.003023661905899644, -0.021496938541531563, 0.03305670619010925, 0.00032832834403961897, -0.03302460163831711, -0.006779226008802652, -0.005189014598727226, 0.006774398032575846, 0.04968106746673584, 0.008969572372734547, 0.008612150326371193, 0.008861015550792217, -0.0004474003508221358, -0.02803420089185238, -0.008936941623687744, -0.011209624819457531, 0.02001875452697277, -0.003403204958885908, 0.01051800325512886, 0.016892896965146065, -0.011814623139798641, 0.01042892225086689, 0.01355915330350399, 0.02232646755874157, 0.025702593848109245, -0.016303135082125664, -0.031595245003700256, -0.022703370079398155, 0.018455861136317253, -0.003604388330131769, 0.013066335581243038, -0.011942153796553612, -0.005574468988925219, -0.00386216351762414, 0.055820103734731674, -0.0008094043005257845, 0.008681663312017918, 0.02733217552304268, 0.013585603795945644, -0.016766466200351715, -0.013921470381319523, 0.012048144824802876, -0.04190071299672127, 0.030780259519815445, -0.03079088218510151, 0.023174716159701347, -0.010485445149242878, 0.04028064385056496, 0.06168396398425102, 0.021652039140462875, -0.04348425194621086, -0.038863006979227066, -0.006044813431799412, -0.015961620956659317, -0.01139149721711874, 0.034191861748695374, -0.00734638562425971, -0.04901806265115738, -0.00932662095874548, -0.010301406495273113, 0.013375697657465935, -0.030129391700029373, 0.03662867099046707, 0.06296984851360321, 0.001406146795488894, -0.010888958349823952, 0.02269773744046688, 0.059014610946178436, 0.05646760016679764, 0.022138649597764015, 0.044994570314884186, 0.004887045361101627, 0.0017156825633719563, -0.026544416323304176, 0.011979656293988228, -0.025038255378603935, -0.01387367770075798, -0.034723490476608276, -0.008442198857665062, 0.00016328284982591867, -0.028323307633399963, -0.010338760912418365, 0.0059227105230093, -0.030775118619203568, 0.011664457619190216, -0.022274522110819817, -0.007593468762934208, -0.011545594781637192, 0.02468358911573887, 0.02895239368081093, 0.050556331872940063, 0.014772556722164154, 0.020270204171538353, -0.033923517912626266, 0.02901976928114891, 0.0028886825311928988, 0.014450202696025372, 0.04488583281636238, -0.03673392906785011, -0.010193898342549801, -0.03691583499312401, -0.00855099968612194, 0.03315996751189232, -0.0838637724518776, 0.011132417246699333, 0.020549798384308815, 0.0005490579060278833, -0.05017504841089249, -0.0010576472850516438, -0.0066785975359380245, 0.005288038402795792, 0.019962377846240997, -0.02071244642138481, -0.06167588382959366, -0.01874564029276371, -0.04611537232995033, -0.035309311002492905, 0.013143905438482761, -0.06794825196266174, -0.006573330610990524, 0.008420680649578571, -0.020122800022363663, -0.025269586592912674, 0.0024484670720994473, -0.011237379163503647, -0.018683122470974922, 0.012930573895573616, -0.04944249987602234, -0.06340813636779785, 0.02272324450314045, 0.03263552114367485, 0.0009126100922003388, -0.04026743769645691, 0.0113596236333251, 0.022272294387221336, -0.03489082306623459, 0.001556232338771224, 0.004655792843550444, 0.03697040677070618, -0.01878889463841915, -0.009101956151425838, 0.0029353208374232054, 0.0526914969086647, -0.002672635717317462, -0.050443414598703384, -0.023105842992663383, -0.031246116384863853 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
Installation To use stable-baselines3 with Hugging Face Hub, you just need to install these 2 libraries: bash pip install huggingface_hub pip install huggingface_sb3
[ 0.0004715284158010036, -0.006684393621981144, 0.052849337458610535, 0.011138968169689178, 0.04919269680976868, 0.015877658501267433, 0.010206876322627068, 0.05830303952097893, -0.06645071506500244, -0.11351655423641205, -0.026029124855995178, 0.05393489450216293, 0.01457405649125576, 0.0644446611404419, 0.02000284008681774, -0.03486626595258713, 0.03359752148389816, -0.006743010599166155, -0.0668134093284607, 0.050406139343976974, 0.02274909056723118, -0.011230971664190292, 0.021127525717020035, -0.01675565354526043, -0.012714054435491562, -0.08421694487333298, 0.03886505216360092, 0.021260371431708336, -0.034065283834934235, -0.0044666496105492115, -0.08402185142040253, -0.03573356196284294, 0.03172309324145317, -0.050367794930934906, 0.09653724730014801, 0.04326844587922096, -0.12405093759298325, 0.05440704897046089, 0.05213800445199013, -0.015739917755126953, -0.007152161095291376, -0.024842845275998116, -0.05735494941473007, 0.03049086034297943, 0.01700422912836075, -0.04839672893285751, -0.18637295067310333, 0.08320979028940201, 0.008644167333841324, -0.008704157546162605, -0.07398239523172379, 0.09989515691995621, -0.004289327654987574, -0.030864251777529716, 0.01363028772175312, -0.025928964838385582, -0.04411376640200615, -0.04967689886689186, 0.036139022558927536, 0.028160661458969116, 0.05372431129217148, 0.01262230146676302, -0.011859809048473835, 0.018913976848125458, -0.020086996257305145, 0.049073606729507446, -0.02964760921895504, -0.02708575315773487, -0.053856994956731796, 0.01085993554443121, 0.030685046687722206, 0.029497284442186356, -0.016647031530737877, -0.02620682306587696, 0.01887950673699379, -0.04124821722507477, -0.015892060473561287, 0.031383972615003586, 0.04008280485868454, 0.027212103828787804, 0.026780376210808754, -0.011848775669932365, 0.00885840319097042, 0.09751520305871964, -0.02643672749400139, 0.07327375560998917, 0.04934678599238396, -0.04703110456466675, -0.046138182282447815, 0.08381377905607224, -0.03523501381278038, -0.06963831931352615, -0.03725158050656319, 0.030804486945271492, 0.03278329595923424, -0.015382987447082996, -0.00824473612010479, 0.004159198142588139, 0.0011065955040976405, -0.03125933185219765, 0.006979759782552719, -0.018050799146294594, 0.023411452770233154, -0.07708162069320679, 0.007374404929578304, 0.0034009690862149, 0.021898308768868446, -0.05759625881910324, -0.03983398526906967, -0.03918052464723587, 0.04068053141236305, -0.0603703036904335, 0.022140270099043846, 0.06587862968444824, -0.06442289799451828, 0.10777608305215836, -0.025250844657421112, -0.013930886052548885, 0.05050518363714218, 0.044049590826034546, 0.0417155995965004, 0.11242610216140747, -0.0014921168331056833, 0.0059435321018099785, 0.07012014836072922, 0.12174718081951141, -0.007618728093802929, -0.020694175735116005, -0.015124347060918808, -0.024474119767546654, -0.0007929859566502273, -0.01774587109684944, 0.06637000292539597, -0.02419176511466503, -0.014939352869987488, -0.05391406640410423, 0.008686156943440437, -0.031884800642728806, 0.0023344969376921654, 0.026276057586073875, 0.01852949522435665, 0.05788305774331093, -0.014836713671684265, 0.062081657350063324, 0.03550983965396881, -0.012736041098833084, -0.07029390335083008, 0.05117534473538399, -0.030217809602618217, -0.009055963717401028, 0.006073725409805775, 0.043326236307621, -0.05132641643285751, -0.03735402598977089, 0.002620816696435213, 0.04475189745426178, -0.004813171457499266, -0.051064494997262955, -0.041243329644203186, -0.0020415496546775103, -0.011697427369654179, -0.018514422699809074, -0.09371834248304367, -0.018207965418696404, 0.07717025279998779, -0.06256157904863358, 0.01230702456086874, 0.01602962240576744, 0.05262167006731033, -0.004662558902055025, 0.06705290824174881, -0.05939759686589241, 0.04487966001033783, -0.03028823807835579, 0.02319057285785675, 0.008979755453765392, 0.07870987057685852, 0.07357306033372879, -0.015192459337413311, 0.007838891819119453, -0.05175543949007988, 0.07846689224243164, 0.013332588598132133, 0.05722879618406296, 0.05064564198255539, -0.05561621114611626, -0.016120469197630882, 0.032281603664159775, 0.03960282355546951, 0.02775338478386402, 0.008313272148370743, -0.05173042416572571, 0.06397523730993271, 0.006731162779033184, 0.03391246497631073, -0.02294584922492504, -0.01623968407511711, 0.0862569808959961, 0.039323851466178894, 0.061617206782102585, -0.023487800732254982, -0.005843891762197018, 0.015849635004997253, 0.021968483924865723, -0.022939171642065048, 0.0962260439991951, -0.022511150687932968, -0.06019075587391853, 0.044901203364133835, 0.06900878250598907, -0.011053566820919514, -0.1319989114999771, 0.05943964049220085, -0.06338691711425781, -0.0070563131012022495, -0.029813650995492935, -0.009688179939985275, -0.026500115171074867, 0.03781626746058464, 0.012113550677895546, 0.14313580095767975, 0.009287269786000252, 0.0456051342189312, 0.03408702835440636, -0.07947438210248947, 0.009180646389722824, 0.0842045322060585, 0.04175311699509621, 0.06823825091123581, -0.059894055128097534, 0.007799922022968531, -0.06139728054404259, -0.014752267859876156, 0.053849734365940094, -0.022252453491091728, -0.014168969355523586, 0.010833613574504852, -0.009151206351816654, 0.02520930953323841, -0.0003812730428762734, 0.01733267307281494, -0.04090125858783722, 0.007571985479444265, 0.001404659589752555, -0.014593195170164108, -0.01412386354058981, 0.04082589969038963, -0.022048048675060272, -0.08095984905958176, -0.01185227744281292, -0.05134822800755501, 0.017696192488074303, -0.01888039894402027, 0.02216557040810585, 0.031907469034194946, 0.1039847657084465, 0.011115984059870243, -0.00747935613617301, -0.029936784878373146, 0.0383317656815052, 0.016346078366041183, -0.0066719502210617065, -0.025467457249760628, -0.046867791563272476, -0.03873660787940025, 0.006353678647428751, 0.0004087696725036949, -0.009339544922113419, -0.04779307544231415, -0.005522892344743013, 0.02882682904601097, -0.0361795499920845, 0.029189925640821457, 0.032087769359350204, 0.010793674737215042, -0.005113360937684774, 0.03157023712992668, -0.025692960247397423, -0.03400251641869545, -0.0007838827441446483, -0.0008073057979345322, -0.00851371232420206, 0.03855615481734276, 0.012372261844575405, 0.013797950930893421, 0.019309507682919502, 0.024392371997237206, -0.04192264378070831, -0.022410383448004723, 0.008477701805531979, 0.0029123432468622923, 0.04635218530893326, 0.02588261105120182, -0.027607403695583344, 0.0245836079120636, 0.03709244355559349, 0.022155020385980606, -0.008287927135825157, -0.002169540151953697, 0.010044915601611137, 0.009078102186322212, 0.025304410606622696, -0.005784623324871063, -0.0029661552980542183, -0.04757695272564888, 0.028725173324346542, -0.005094226449728012, -0.018631011247634888, -0.10558507591485977, -0.02091827429831028, 0.0007668279577046633, 0.06363287568092346, -0.006269934121519327, -0.05064031854271889, 0.043446172028779984, -0.030909525230526924, 0.052137237042188644, 0.017476549372076988, 0.0007279345882125199, 0.021636128425598145, 0.02283628284931183, 0.013373412191867828, -0.029519105330109596, -0.0315709114074707, 0.033099763095378876, -0.012183155864477158, 0.03451675921678543, -0.0037506588269025087, -0.04664752632379532, 0.021094879135489464, 0.005416219588369131, -0.002938517602160573, -0.01312470156699419, -0.008038717322051525, 0.04071223363280296, 0.03883076086640358, -0.008830512873828411, -0.03423094376921654, 0.008870234712958336, -0.0033655036240816116, -0.03757321462035179, 0.002198093105107546, -0.04951554909348488, -0.008278798311948776, 0.0005717941676266491, 0.0045019397512078285, 0.02732815034687519, -0.004628027323633432, -0.011408679187297821, -0.004710790701210499, -0.000984090380370617, -0.0230232123285532, -0.03219185024499893, -0.03467153012752533, -0.0025650823954492807, -0.0036995576228946447, -0.010530751198530197, -0.024136090651154518, -0.05186769738793373, -0.005090692080557346, -0.015870602801442146, 0.04897060617804527, 0.02906864508986473, 0.030791833996772766, -0.01375871803611517, 0.03563764691352844, 0.01760938949882984, 0.005159227177500725, -0.08333277702331543, 0.030200904235243797, -0.013717679306864738, -0.03765624016523361, -0.005786075722426176, 0.017266271635890007, 0.003714996390044689, -0.004865264520049095, 0.009845301508903503, -0.009064308367669582, 0.012044074945151806, 0.030012520030140877, -0.028079548850655556, 0.018691597506403923, -0.029221298173069954, -0.006299808621406555, -0.007685808464884758, -0.061590809375047684, 0.05375416949391365, -0.0008785092504695058, -0.019368261098861694, -0.013644238002598286, 0.010930427350103855, -0.012578106485307217, -0.01715007983148098, -0.002181856194511056, 0.01898554153740406, 0.0034654797054827213, 0.02032056450843811, 0.028826897963881493, -0.021461214870214462, -0.010838476940989494, 0.020473478361964226, -0.04916265234351158, -0.00523581774905324, -0.03135288134217262, 0.021250052377581596, 0.017115160822868347, 0.0024560107849538326, 0.03303191810846329, 0.020838990807533264, -0.04013792797923088, 0.014711820520460606, -0.05009767785668373, -0.0029617517720907927, 0.027325063943862915, -0.048064954578876495, -0.02569667436182499, -0.0034178197383880615, -0.026666318997740746, 0.01952197588980198, -0.04975220188498497, 0.0005556471296586096, -0.042867254465818405, 0.034191250801086426, 0.01098561566323042, -0.019807159900665283, -0.043243952095508575, -0.04577478766441345, 0.06564313918352127, 0.012825407087802887, 0.039705052971839905, -0.020449362695217133, -0.02302863821387291, -0.00003074414053116925, -0.02469440922141075, 0.012602684088051319, 0.024389712139964104, 0.0121591342613101, 0.0077193379402160645, 0.008992349728941917, -0.013282973319292068, 0.028573928400874138, -0.012270113453269005, 0.022401908412575722, -0.005625791382044554, -0.012240234762430191, 0.0026640589348971844, 0.02308383397758007, -0.041458144783973694, -0.03230767324566841, 0.001449601142667234, 0.0829923078417778, -0.051702991127967834, 0.03662605583667755, 0.030912747606635094, -0.06316527724266052, 0.01691829040646553, -0.03184924274682999, 0.04339137300848961, 0.05577559024095535, -0.01764439232647419, -0.012099848128855228, 0.004023085813969374, 0.015001819469034672, -0.036752574145793915, -0.01753712259232998, 0.007846567779779434, -0.0001449397241231054, 0.01780417189002037, -0.05008891597390175, -0.0340077169239521, 0.011796492151916027, 0.0026472893077880144, 0.002966837724670768, -0.016032034531235695, 0.021999849006533623, -0.1002630889415741, -0.018455300480127335, 0.0067011271603405476, -0.00864376686513424, 0.02162940800189972, 0.0008911238983273506, -0.04706106334924698, -0.00632858881726861, 0.05620749294757843, 0.041472602635622025, 0.003657849272713065, 0.002995442831888795, 0.02870044857263565, -0.018391268327832222, 0.009715941734611988, 0.03399999067187309, -0.012328176759183407, -0.006056758109480143, 0.047727905213832855, 0.04849034547805786, 0.023905912414193153, 0.004352910444140434, 0.0055165719240903854, -0.006575017236173153, 0.0025165362749248743, 0.04297422245144844, -0.015786677598953247, -0.002281521912664175, -0.018190691247582436, 0.01552004087716341, -0.017153417691588402, 0.0038628457114100456, -0.045089393854141235, -0.0023234582040458918, 0.04554746672511101, -0.010220947675406933, -0.034994181245565414, 0.023768886923789978, -0.011722112074494362, 0.0018525758059695363, 0.0017462673131376505, 0.05872907117009163, -0.01920745149254799, -0.0012573526473715901, 0.004151488188654184, -0.003199359169229865, -0.037318576127290726, -0.004095783922821283, -0.0473029762506485, -0.03604605793952942, -0.005764702335000038, 0.0037184373941272497, 0.03198177367448807, -0.03860248625278473, 0.002819458721205592, -0.021767383441329002, -0.024294830858707428, 0.005008293315768242, -0.035374004393815994, 0.003387603210285306, 0.018523510545492172, 0.005076342262327671, 0.061678074300289154, 0.013462187722325325, -0.019538510590791702, 0.005970068275928497, 0.03674186021089554, 0.045230042189359665, -0.00034290074836462736, -0.038532551378011703, -0.0011575486278161407, 0.019482016563415527, 0.022194646298885345, -0.0040284148417413235, 0.014145085588097572, -0.039168279618024826, -0.03139486908912659, -0.04749314486980438, 0.0054061985574662685, 0.08672086149454117, 0.011196954175829887, -0.0008119075791910291, -0.00005650592356687412, -0.0005716996383853257, 0.010177160613238811, -0.0022919001057744026, -0.025281140580773354, 0.039048489183187485, 0.047136757522821426, -0.006370402406901121, -0.01255325973033905, -0.014423673041164875, -0.007993598468601704, 0.0035629773046821356, -0.04363708570599556, 0.02457989752292633, 0.01871410757303238, -0.04411040619015694, 0.006638808641582727, 0.027282100170850754, -0.04832875728607178, -0.012354214675724506, 0.030719447880983353, 0.0039210692048072815, 0.03464307263493538, -0.010783407837152481, 0.0075496891513466835, -0.03553207218647003, -0.01823406107723713, 0.03604753687977791, 0.06057419255375862, -0.04112841933965683, 0.018732119351625443, 0.01683337613940239, 0.01648278534412384, 0.03078436851501465, -0.01609518565237522, -0.003854018170386553, 0.035438645631074905, 0.08081848174333572, 0.005468782037496567, 0.04173346236348152, 0.05313427001237869, -0.03890940174460411, 0.00016300971037708223, -0.04396568611264229, -0.021182958036661148, -0.013264929875731468, 0.011728936806321144, 0.021697252988815308, 0.014828013256192207, 0.014063699170947075, -0.01909678801894188, 0.02210931107401848, 0.03203049674630165, 0.03883501514792442, 0.0014880375238135457, 0.0195098128169775, 0.03344327211380005, 0.010029728524386883, 0.0020085645373910666, 0.019291499629616737, -0.00825196411460638, -0.008063515648245811, 0.06071797013282776, 0.028118079528212547, 0.01838582009077072, -0.008988012559711933, -0.001737307058647275, 0.0021327596623450518, -0.01157930213958025, -0.02560681663453579, -0.010465417988598347, 0.04197971150279045, -0.02627524547278881, -0.0171916875988245, 0.014497176744043827, -0.0012000474380329251, -0.004519904963672161, -0.030948808416724205, 0.012502463534474373, -0.010178395546972752, 0.008921599946916103, -0.018279792740941048, 0.03236178308725357, 0.016807381063699722, -0.0014380835928022861, 0.014919975772500038, 0.02302294410765171, 0.02697870507836342, -0.012199941091239452, -0.023677583783864975, -0.0374869666993618, -0.04471782594919205, 0.01867503672838211, -0.05787228047847748, 0.008055196143686771, 0.00973015557974577, -0.016653796657919884, -0.03419084474444389, 0.015329165384173393, -0.006793695967644453, 0.007834617048501968, 0.03196985647082329, 0.014744055457413197, -0.036072541028261185, -0.004027612507343292, 0.01749451458454132, 0.0019030735129490495, 0.0016722659347578883, -0.03570626676082611, 0.019172707572579384, -0.03647438809275627, 0.03921109065413475, 0.053432025015354156, -0.007435610517859459, -0.01723395846784115, -0.05040054768323898, -0.00006183888035593554, -0.008164231665432453, -0.028646836057305336, 0.045949552208185196, -0.016890043392777443, -0.015284285880625248, -0.002184778917580843, 0.00010416756413178518, 0.022034136578440666, -0.010627863928675652, 0.03411727026104927, 0.047420684248209, -0.012050672434270382, -0.004287253599613905, 0.004960245918482542, 0.07325492054224014, 0.044683825224637985, 0.017514992505311966, 0.04596838355064392, 0.010019643232226372, 0.040102846920490265, -0.015271518379449844, 0.010893287137150764, -0.0433184914290905, -0.011977977119386196, -0.05627268925309181, -0.03454058617353439, 0.013979642651975155, -0.05330090597271919, -0.029024425894021988, 0.0072664981707930565, -0.02045765146613121, 0.0024545565247535706, -0.03414379805326462, -0.022261304780840874, -0.008450295776128769, 0.04268140345811844, 0.03547370433807373, 0.06391304731369019, 0.02799946255981922, 0.009737091138958931, -0.02532152086496353, 0.03030596673488617, 0.004552268423140049, 0.020122705027461052, 0.018004031851887703, 0.0031474237330257893, -0.01404141541570425, -0.010920564644038677, 0.016431033611297607, 0.0045008109882473946, -0.08420144021511078, 0.02598811686038971, -0.00585212791338563, -0.033633336424827576, -0.0280217994004488, -0.0006645148969255388, 0.0007422712515108287, 0.006310404743999243, 0.06556462496519089, -0.01828114129602909, -0.06146882474422455, 0.027162563055753708, -0.015899555757641792, -0.026537403464317322, -0.008669997565448284, -0.04882260039448738, 0.019062301144003868, 0.003737635677680373, 0.0027202318888157606, -0.031272877007722855, -0.016273917630314827, -0.03299544006586075, -0.0018517213175073266, 0.011567571200430393, -0.03846414387226105, -0.05967191234230995, -0.009918482974171638, 0.05097793787717819, -0.021995844319462776, -0.054181989282369614, 0.03541983664035797, 0.008722737431526184, -0.028915440663695335, -0.008690401911735535, -0.009532607160508633, -0.006438749842345715, -0.05232467129826546, 0.002813054481521249, -0.0006762880948372185, 0.032902393490076065, 0.005231436342000961, -0.044411931186914444, 0.0054156300611793995, 0.004894091747701168 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
Sharing a model to the Hub In just a minute, you can get your saved model in the Hub. First, you need to be logged in to Hugging Face to upload a model: - If you're using Colab/Jupyter Notebooks: python from huggingface_hub import notebook_login notebook_login() - Else: bash huggingface-cli login Then, in this example, we train a PPO agent to play CartPole-v1 and push it to a new repo ThomasSimonini/demo-hf-CartPole-v1 `````python from huggingface_sb3 import push_to_hub from stable_baselines3 import PPO # Define a PPO model with MLP policy network model = PPO("MlpPolicy", "CartPole-v1", verbose=1) # Train it for 10000 timesteps model.learn(total_timesteps=10_000) # Save the model model.save("ppo-CartPole-v1") # Push this saved model to the hf repo # If this repo does not exists it will be created
[ -0.053956933319568634, -0.02496551163494587, -0.02287176623940468, -0.012283345684409142, 0.06811770051717758, -0.005845304578542709, -0.02477138862013817, 0.019334441050887108, -0.04586182162165642, -0.00041004770901054144, -0.04019278287887573, 0.014271995052695274, 0.04349712282419205, 0.03839212283492088, -0.02385978400707245, -0.1154194101691246, 0.01229710690677166, -0.015314463526010513, -0.05051262304186821, 0.03413521870970726, -0.007389819715172052, -0.07502800971269608, 0.02128242328763008, 0.004358089994639158, -0.044967882335186005, -0.07619060575962067, 0.06495063006877899, 0.029323194175958633, 0.04885367304086685, 0.003326710080727935, -0.02451428584754467, -0.024943916127085686, 0.010680776089429855, -0.030537674203515053, 0.08571925014257431, 0.04492396488785744, -0.0879131406545639, 0.05988581106066704, 0.05084313824772835, -0.04276403412222862, 0.01019088551402092, 0.031092381104826927, -0.07211677730083466, 0.0648132860660553, 0.01934952661395073, -0.050499606877565384, -0.09099522978067398, 0.03701969236135483, 0.005876332521438599, -0.004285522736608982, -0.09568420052528381, 0.028059205040335655, -0.01655539497733116, 0.0025303203146904707, 0.009313936345279217, 0.009461564011871815, -0.04061933234333992, -0.0744260847568512, -0.03863348439335823, 0.04668518528342247, 0.0570206418633461, 0.014555759727954865, 0.0411333404481411, 0.0770472064614296, -0.002574077108874917, 0.039056576788425446, -0.00024724629474803805, -0.026242880150675774, -0.055871788412332535, -0.03955424204468727, 0.0011616632109507918, -0.050078023225069046, -0.02655051276087761, -0.006069549825042486, 0.02601216919720173, -0.039564475417137146, -0.019030120223760605, 0.03286304324865341, 0.09458547085523605, 0.03607115522027016, 0.025402577593922615, -0.0012417788384482265, -0.010412710718810558, 0.019749002531170845, 0.07488706707954407, 0.04934213310480118, -0.020776355639100075, -0.0478593148291111, -0.04093046113848686, 0.047567833214998245, -0.03684363141655922, -0.04496287181973457, -0.04941137135028839, 0.04619138687849045, 0.10200008749961853, 0.035710666328668594, -0.036515962332487106, -0.006136687938123941, -0.0091642364859581, -0.017923427745699883, -0.014601069502532482, -0.05818094313144684, -0.021970069035887718, -0.04885748401284218, -0.01411150861531496, 0.014254827052354813, 0.006552559789270163, -0.12147169560194016, -0.037782978266477585, -0.029769819229841232, 0.005228832829743624, -0.016027502715587616, -0.03371958062052727, 0.06466962397098541, -0.058056239038705826, 0.017153840512037277, 0.0011661876924335957, -0.005337992683053017, -0.01900234818458557, 0.08067473769187927, 0.0076966662891209126, 0.06508183479309082, -0.02383095771074295, 0.005556014832109213, 0.0706549882888794, 0.12228798866271973, -0.04596315324306488, -0.027377929538488388, 0.011477859690785408, -0.03570161014795303, 0.008824351243674755, -0.009811344556510448, 0.013949832879006863, -0.03830713406205177, 0.03358565643429756, -0.03155189007520676, 0.022382520139217377, -0.019623223692178726, 0.04800591617822647, 0.017332760617136955, -0.01142797153443098, 0.11920195817947388, 0.016487685963511467, -0.036475181579589844, 0.0974746122956276, 0.007289226166903973, -0.03249881789088249, 0.0642438530921936, -0.0066097211092710495, -0.029994485899806023, -0.07535319030284882, 0.040549732744693756, 0.052515216171741486, -0.053971949964761734, -0.01239234209060669, 0.029708102345466614, -0.018800845369696617, 0.03314521908760071, 0.00346481055021286, 0.036352597177028656, 0.030027160421013832, -0.0312751866877079, -0.06832679361104965, -0.01929267682135105, 0.014117792248725891, 0.021044500172138214, 0.029685018584132195, -0.020629780367016792, 0.04557938501238823, -0.060083676129579544, 0.04789397865533829, -0.05786478891968727, 0.053005266934633255, -0.007787854410707951, 0.023236948996782303, 0.08041704446077347, 0.07824824005365372, 0.06227685138583183, -0.006734748370945454, 0.0025942425709217787, -0.027542883530259132, 0.07524053007364273, -0.017122767865657806, 0.02770770899951458, 0.05479650944471359, -0.08457927405834198, -0.0022254949435591698, 0.06810597330331802, 0.011974455788731575, 0.03949921578168869, 0.02700025402009487, -0.035404566675424576, 0.08370470255613327, -0.062050044536590576, 0.049135733395814896, -0.03369523212313652, -0.031925104558467865, 0.053489286452531815, 0.03227300941944122, 0.002618098398670554, 0.001237063785083592, 0.02826751209795475, 0.014723164029419422, -0.052125584334135056, -0.027137231081724167, 0.026886198669672012, -0.03657829388976097, -0.0947524830698967, 0.03633638471364975, -0.017437521368265152, 0.006789016537368298, -0.07078752666711807, 0.08069266378879547, -0.09700942784547806, 0.03145578131079674, -0.05784992501139641, -0.05721640586853027, 0.0036293279845267534, 0.00024563344777561724, -0.003744526067748666, 0.20126260817050934, 0.037961769849061966, 0.033457301557064056, 0.017781976610422134, -0.013525685295462608, 0.0029659548308700323, 0.00889824703335762, 0.07724868506193161, 0.08554821461439133, -0.039207179099321365, -0.09108065068721771, -0.05851079896092415, -0.03144121170043945, 0.022527623921632767, 0.03139630705118179, -0.03174842149019241, 0.045931316912174225, 0.022902440279722214, -0.07663773000240326, 0.023601839318871498, 0.02262360043823719, -0.03595548868179321, -0.00644739530980587, 0.0010496722534298897, -0.006160453427582979, 0.04386866092681885, 0.05460907146334648, 0.0460335910320282, -0.010406030341982841, 0.010576113127171993, -0.09625742584466934, 0.023708298802375793, 0.0035175762604922056, 0.03193902596831322, 0.021537089720368385, -0.011269260197877884, 0.007388153579086065, -0.0014582604635506868, 0.00041827632230706513, 0.05447566136717796, -0.01721641607582569, 0.005100118461996317, -0.07973213493824005, -0.018244322389364243, -0.0198473259806633, -0.029807744547724724, 0.0065123774111270905, -0.017553554847836494, -0.022451844066381454, -0.03592221811413765, 0.03610561415553093, -0.033244576305150986, 0.03154106065630913, -0.0005176513222977519, 0.004341628402471542, 0.015634987503290176, 0.018311044201254845, -0.020828938111662865, -0.031477294862270355, -0.007139032706618309, 0.02511349692940712, -0.053095754235982895, 0.014438122510910034, 0.0159103125333786, 0.059913426637649536, 0.029306236654520035, -0.0033244036603718996, -0.06511002779006958, -0.0062416233122348785, 0.041009288281202316, 0.0330033041536808, 0.02037503756582737, 0.0018875800305977464, 0.00018551207904238254, -0.02749624103307724, 0.0073737818747758865, -0.01843220368027687, -0.03896922990679741, 0.008695871569216251, 0.005155524704605341, -0.00503923837095499, 0.025104910135269165, 0.04271431639790535, -0.013011299073696136, -0.02796606346964836, 0.027675198391079903, 0.03118583746254444, -0.0466681532561779, -0.08141154795885086, -0.00921369157731533, -0.037536729127168655, 0.005625395569950342, 0.021972162649035454, -0.0011917086085304618, 0.02533680573105812, 0.0065461453050374985, -0.002032793592661619, 0.023414576426148415, 0.009560996666550636, 0.01816646382212639, -0.005492062773555517, -0.0133662736043334, -0.023173097521066666, 0.004127934109419584, 0.00639507919549942, 0.01647479459643364, 0.02916497178375721, 0.05753032863140106, -0.06943284720182419, 0.007227758411318064, 0.014995023608207703, -0.02082083560526371, -0.011228222399950027, -0.05422123894095421, 0.0368630513548851, -0.005799898877739906, -0.025243069976568222, -0.049353569746017456, 0.000297466351184994, -0.05287415161728859, -0.051260560750961304, -0.02776181697845459, -0.05365263670682907, -0.0076413871720433235, -0.009708401747047901, 0.025529971346259117, 0.017258629202842712, -0.014639620669186115, -0.018289849162101746, -0.01762605644762516, 0.020898131653666496, 0.014919765293598175, -0.007219309918582439, 0.003035034518688917, 0.015382652170956135, 0.031818877905607224, 0.004089006222784519, -0.042373862117528915, -0.02290194109082222, 0.006757811643183231, 0.02916019968688488, 0.017778852954506874, -0.0045890798792243, 0.03787916898727417, -0.009318237192928791, 0.006005205679684877, -0.020684219896793365, -0.02006029337644577, -0.08016268163919449, 0.00414875615388155, -0.04321141913533211, -0.07703867554664612, -0.00045831839088350534, 0.05687445029616356, 0.009469562210142612, -0.00638872804120183, -0.030480513349175453, 0.03022368997335434, 0.006431795656681061, 0.018640298396348953, 0.007005041930824518, 0.007789438124746084, -0.0210801400244236, -0.0010602198308333755, 0.010836219415068626, -0.05130237713456154, 0.042256489396095276, 0.001939940033480525, -0.002466402482241392, 0.007545782718807459, -0.005261487793177366, -0.01689068228006363, -0.012105422094464302, -0.013022788800299168, 0.0444856621325016, 0.0030992995016276836, 0.014883681200444698, 0.03306719288229942, 0.011316889896988869, -0.013180159963667393, -0.006876187864691019, 0.0009282345417886972, -0.005151671357452869, -0.06468594074249268, 0.010755167342722416, 0.06976979970932007, -0.034509822726249695, -0.00580339040607214, -0.007298992946743965, -0.03050914779305458, -0.03822149708867073, 0.007668733596801758, -0.015927733853459358, 0.012206300161778927, -0.015789000317454338, -0.02520056813955307, 0.008470593020319939, -0.018529444932937622, -0.052891481667757034, 0.008720191195607185, -0.01838531345129013, -0.01595880836248398, 0.02281724289059639, 0.05648665875196457, -0.03739997372031212, 0.004677784629166126, -0.056449003517627716, 0.04235910251736641, -0.02596130222082138, -0.01111544668674469, 0.005114909261465073, -0.05079202353954315, 0.0288062933832407, 0.03814069181680679, 0.027833756059408188, -0.033525727689266205, 0.0002990135399159044, 0.006269785575568676, -0.022403959184885025, -0.001362063456326723, 0.03857603296637535, -0.008744757622480392, -0.017335930839180946, 0.01847001351416111, -0.014203621074557304, 0.03228788822889328, 0.03741808608174324, -0.005677701905369759, 0.01950209215283394, 0.02416100725531578, 0.05669092759490013, -0.010996519587934017, 0.01864149048924446, 0.02835640124976635, -0.034564319998025894, 0.018789565190672874, -0.019718538969755173, 0.00952744111418724, 0.012645408511161804, 0.05077803134918213, -0.015898237004876137, -0.021059053018689156, 0.08179586380720139, -0.013206678442656994, 0.020217997953295708, -0.01082894578576088, 0.0021724835969507694, 0.013565720058977604, -0.05454706773161888, -0.010496003553271294, 0.006912732031196356, 0.06505338102579117, 0.0031869339291006327, 0.025863664224743843, 0.017054427415132523, -0.06893930584192276, -0.012083617970347404, -0.006248985882848501, 0.0016049012774601579, 0.021091600880026817, 0.023345118388533592, -0.060811784118413925, -0.011253063566982746, 0.08188454806804657, 0.04856786131858826, -0.006815098226070404, -0.027772637084126472, 0.014999929815530777, -0.04291786253452301, -0.009258844889700413, 0.021909136325120926, -0.030674133449792862, 0.018444182351231575, 0.003219095291569829, 0.06970684230327606, 0.07852603495121002, 0.0038569315802305937, -0.005000777076929808, -0.01707712933421135, -0.001852841000072658, -0.0005014454945921898, -0.011978104710578918, -0.01618359610438347, -0.022304199635982513, -0.024814246222376823, -0.010052316822111607, 0.01671815663576126, -0.010500650852918625, 0.009010685607790947, 0.057822421193122864, -0.0482487790286541, -0.0012124001514166594, 0.02631009928882122, -0.013601801358163357, -0.024963170289993286, 0.016218824312090874, -0.0007304710452444851, 0.0015318664954975247, 0.0008163448073901236, -0.002951881382614374, 0.013057425618171692, 0.00001918243469845038, -0.004726416431367397, -0.02078775316476822, -0.044606421142816544, 0.008570359088480473, 0.0025280870031565428, 0.06095876172184944, -0.025370975956320763, -0.011438259854912758, -0.002745511708781123, -0.033287182450294495, 0.02305011637508869, -0.04575100541114807, 0.024088671430945396, 0.025391673669219017, 0.00899362564086914, 0.021689830347895622, 0.03946467861533165, -0.01563786342740059, 0.004646151326596737, 0.001054721069522202, 0.03675096854567528, 0.021165436133742332, -0.019460177049040794, 0.018440833315253258, 0.021000465378165245, -0.0012144881766289473, -0.0006668183486908674, -0.016927752643823624, -0.061781395226716995, 0.02182943746447563, -0.07677087932825089, 0.03844181448221207, 0.08210080862045288, 0.00243668956682086, -0.02474752999842167, 0.013540579006075859, -0.004871002864092588, 0.011385475285351276, -0.009456700645387173, -0.007573094684630632, -0.010829370468854904, 0.006578091531991959, 0.018374498933553696, 0.014470679685473442, 0.007499820552766323, 0.012870377860963345, 0.012284943833947182, -0.04175230488181114, -0.015954403206706047, 0.019652580842375755, 0.0053423806093633175, -0.0032566243316978216, -0.007522763684391975, -0.07261921465396881, 0.007673144806176424, 0.021636556833982468, 0.034173838794231415, 0.028019167482852936, -0.03138728812336922, 0.02187052182853222, -0.02662206068634987, 0.01764102652668953, 0.0385047122836113, 0.03710106015205383, -0.05410080403089523, 0.054840024560689926, 0.0224032960832119, 0.040527671575546265, 0.00875304825603962, 0.0072051286697387695, 0.032751936465501785, 0.04204131290316582, 0.0667673721909523, -0.002687878906726837, 0.030395912006497383, 0.04901255667209625, 0.0028432635590434074, -0.0058531141839921474, -0.017462588846683502, 0.006765768863260746, 0.014991043135523796, 0.0405767560005188, 0.017462795600295067, -0.04312688857316971, -0.004432756919413805, -0.013985250145196915, -0.00006480625597760081, 0.024466058239340782, 0.025376848876476288, -0.039753932505846024, 0.019640853628516197, 0.057510413229465485, 0.00781811960041523, 0.010833454318344593, -0.004404066596180201, 0.010101369582116604, 0.002365322783589363, 0.015386664308607578, 0.014858998358249664, -0.014293411746621132, -0.006700886879116297, 0.025589732453227043, -0.004584610927850008, -0.00777398981153965, -0.04904827103018761, -0.00415206840261817, 0.007100269664078951, 0.011737465858459473, -0.05330154672265053, 0.03689903765916824, 0.01607470214366913, 0.010955504141747952, -0.018533693626523018, 0.006156603340059519, -0.009130068123340607, 0.002265848685055971, 0.00608723284676671, 0.018133897334337234, -0.006865048781037331, -0.026889696717262268, -0.015422159805893898, 0.009404271841049194, 0.02775159664452076, 0.009258915670216084, 0.0007270965725183487, -0.013321968726813793, -0.02627354860305786, 0.004337295889854431, -0.02326621115207672, 0.0022829000372439623, 0.016209881752729416, -0.01091223955154419, -0.020506935194134712, 0.037479981780052185, 0.028251443058252335, 0.0615660659968853, 0.06222933903336525, 0.02486620657145977, 0.04000065475702286, -0.024920327588915825, -0.001059864996932447, -0.014852174557745457, 0.02613980695605278, -0.010581220500171185, 0.009629332460463047, 0.01714789681136608, 0.06954116374254227, 0.06238231062889099, 0.01039154827594757, 0.012650899589061737, -0.030952952802181244, -0.00561554403975606, 0.005502833053469658, -0.005159873049706221, 0.0169990137219429, -0.007833234034478664, 0.010527879931032658, 0.021588509902358055, 0.016033485531806946, 0.0064045749604702, -0.020490342751145363, -0.012263664975762367, 0.06435812264680862, -0.02138153277337551, 0.035317689180374146, 0.010133886709809303, 0.052365951240062714, 0.015715932473540306, -0.014091720804572105, 0.05842497572302818, -0.022460592910647392, -0.009566196240484715, -0.04046003893017769, 0.029228800907731056, -0.04243941605091095, -0.030993375927209854, -0.011754337698221207, -0.04961929842829704, -0.011857000179588795, -0.0008847910212352872, -0.024722693488001823, 0.011549077928066254, -0.06348783522844315, -0.04738344997167587, -0.004303458146750927, -0.010059419088065624, -0.00037556083407253027, -0.019735703244805336, 0.036195989698171616, 0.06206287071108818, 0.018464110791683197, 0.01297850627452135, -0.02935045398771763, 0.001266745268367231, -0.00741172581911087, 0.03660893440246582, 0.029581500217318535, 0.004036061931401491, -0.02328464575111866, -0.015601948834955692, -0.008977703750133514, 0.02508513443171978, -0.07017829269170761, 0.0239899680018425, -0.004253035876899958, -0.004098033532500267, -0.05950064957141876, -0.019896186888217926, 0.019260359928011894, -0.016540082171559334, 0.022846689447760582, -0.007853645831346512, -0.04572197422385216, -0.019556842744350433, 0.0235749538987875, -0.021498609334230423, -0.0061714788898825645, -0.04984305799007416, -0.0211676973849535, -0.012929292395710945, -0.004339807201176882, -0.014636787585914135, -0.00858815386891365, -0.042871832847595215, 0.033449653536081314, -0.008844130672514439, -0.038741808384656906, -0.029917234554886818, -0.005463692359626293, 0.043149013072252274, -0.013934770599007607, -0.0161820650100708, 0.007930736057460308, 0.030073832720518112, -0.029953081160783768, 0.003114234423264861, 0.02160799689590931, 0.022624986246228218, 0.01177226286381483, -0.05147135257720947, -0.01650894619524479, 0.02887042425572872, -0.01802206225693226, -0.07738550007343292, -0.06293358653783798, -0.007060813717544079 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
What's next? In the coming weeks and months, we will be extending the ecosystem by: - Integrating [RL-baselines3-zoo](https://github.com/DLR-RM/rl-baselines3-zoo) - Uploading [RL-trained-agents models](https://github.com/DLR-RM/rl-trained-agents/tree/master) into the Hub: a big collection of pre-trained Reinforcement Learning agents using stable-baselines3 - Integrating other Deep Reinforcement Learning libraries - Implementing Decision Transformers 🔥 - And more to come 🥳 The best way to keep in touch is to [join our discord server](https://discord.gg/YRAq8fMnUG) to exchange with us and with the community. And if you want to dive deeper, we wrote a tutorial where you’ll learn: - How to train a Deep Reinforcement Learning lander agent to land correctly on the Moon 🌕 - How to upload it to the Hub 🚀 ![gif](assets/47_sb3/lunarlander.gif) - How to download and use a saved model from the Hub that plays Space Invaders 👾. ![gif](assets/47_sb3/spaceinvaders.gif) 👉 [The tutorial](https://github.com/huggingface/huggingface_sb3/blob/main/Stable_Baselines_3_and_Hugging_Face_%F0%9F%A4%97_tutorial.ipynb)
[ 0.0435887835919857, -0.044110313057899475, 0.0006034690886735916, 0.0617472305893898, 0.05901233106851578, 0.016321487724781036, 0.02353587932884693, 0.06796760112047195, -0.07279358804225922, -0.08391080051660538, -0.08260198682546616, 0.029582178220152855, -0.018371406942605972, -0.003707847325131297, 0.06491655856370926, -0.05768311396241188, -0.004840667825192213, -0.03222796693444252, -0.046609725803136826, 0.044699955731630325, -0.030895059928297997, -0.03854275867342949, -0.0020773718133568764, 0.022458001971244812, -0.03266346454620361, -0.06333237886428833, 0.03039141371846199, 0.03507155925035477, 0.03567182645201683, 0.022310063242912292, -0.06419249624013901, -0.06076289713382721, -0.02843792550265789, -0.0167178213596344, 0.020780498161911964, 0.031477734446525574, -0.1269068419933319, 0.0032466601114720106, 0.039340585470199585, -0.04670810326933861, 0.015647253021597862, 0.008498805575072765, -0.03959767147898674, 0.049852948635816574, 0.03350754827260971, -0.005095767788589001, -0.16496579349040985, 0.04166750982403755, 0.028681060299277306, -0.044035252183675766, -0.06558167189359665, 0.05008195340633392, -0.009654596447944641, -0.0348842479288578, 0.019247382879257202, -0.04584710672497749, 0.011917867697775364, -0.07966308295726776, 0.02906164899468422, 0.012874351814389229, 0.06230250746011734, 0.0003749643510673195, 0.019215481355786324, 0.02225126512348652, -0.02988070622086525, 0.02832823246717453, 0.0502711683511734, -0.04092991352081299, -0.05328429862856865, -0.020802229642868042, 0.03416113555431366, 0.032501861453056335, -0.06688545644283295, 0.008380020037293434, 0.01846618950366974, -0.029070617631077766, -0.06869667023420334, 0.06845944374799728, 0.004866637289524078, 0.02296305075287819, 0.0015060622245073318, 0.009127253666520119, 0.02416541613638401, 0.016085777431726456, -0.005874757654964924, 0.014454574324190617, 0.030118875205516815, -0.042599745094776154, -0.00674213794991374, 0.06813351064920425, -0.04838002473115921, -0.08519046753644943, -0.012439768761396408, 0.023635640740394592, 0.07131471484899521, -0.03579733520746231, -0.04819755256175995, 0.014454170130193233, -0.012394502758979797, -0.08121106773614883, 0.012556676752865314, -0.044203970581293106, -0.031140482053160667, -0.12669940292835236, 0.011686761863529682, 0.021326743066310883, -0.014532336965203285, -0.09201803803443909, -0.061726801097393036, -0.015522905625402927, 0.020600296556949615, -0.030561067163944244, 0.007691995240747929, 0.0657840222120285, -0.02430976741015911, 0.0602833591401577, -0.04249044135212898, -0.01245817355811596, 0.010383710265159607, 0.042834486812353134, 0.03303392603993416, 0.020611701533198357, -0.014344152063131332, 0.05212772637605667, -0.027816275134682655, 0.07335727661848068, -0.05787969380617142, -0.042221829295158386, -0.06668844819068909, -0.09134512394666672, 0.06728111952543259, -0.016064660623669624, -0.002202784875407815, 0.0031740819104015827, -0.07239490002393723, -0.07501545548439026, -0.0033158783335238695, -0.07438410818576813, 0.06814011931419373, -0.000511729798745364, -0.045749176293611526, 0.015187312848865986, 0.022380392998456955, 0.010507788509130478, 0.07742734998464584, -0.048894450068473816, -0.11141369491815567, 0.036174654960632324, -0.041644081473350525, -0.028567735105752945, -0.03591514006257057, 0.031566403806209564, -0.03599673509597778, -0.07975561916828156, -0.03455260768532753, 0.019909391179680824, -0.025577964261174202, -0.032315947115421295, 0.008881302550435066, 0.08284703642129898, -0.02475767582654953, -0.022557567805051804, -0.04006527364253998, 0.02644580416381359, 0.039091806858778, 0.0037957492750138044, -0.0032661750447005033, -0.0009696413180790842, 0.03772595152258873, -0.052269842475652695, 0.030043024569749832, -0.02184211276471615, 0.088404081761837, -0.014315109699964523, 0.025241920724511147, 0.034110333770513535, 0.07924655079841614, 0.030788622796535492, 0.028045423328876495, 0.0027730620931833982, -0.028656335547566414, 0.04369591176509857, -0.00035285469493828714, 0.029650649055838585, 0.018325332552194595, -0.038596391677856445, 0.065910205245018, 0.033037375658750534, 0.02898108959197998, 0.0277553778141737, 0.011973097920417786, 0.06279856711626053, 0.051287658512592316, -0.0008364031673409045, 0.040028974413871765, -0.022733746096491814, 0.005327087361365557, 0.07270616292953491, 0.016771936789155006, 0.10088632255792618, 0.010849633254110813, 0.022562677040696144, 0.04527999088168144, -0.01984512247145176, -0.02592959627509117, 0.00915332231670618, -0.008371650241315365, -0.07800927758216858, 0.00901268795132637, 0.00015645220992155373, -0.025382038205862045, -0.06782755255699158, 0.026520075276494026, -0.057247113436460495, 0.035008754581213, -0.05170765146613121, -0.04501526802778244, 0.007486160844564438, -0.04471372067928314, -0.08210790902376175, 0.15551456809043884, -0.040967997163534164, 0.028495168313384056, 0.08341686427593231, 0.002908802591264248, 0.05537174642086029, 0.0895107313990593, 0.0385616272687912, 0.050501879304647446, -0.002670378889888525, -0.014521894045174122, -0.059337105602025986, -0.06653209030628204, -0.009029866196215153, -0.03173784911632538, -0.028628870844841003, -0.002132010878995061, -0.07300723344087601, -0.03469080105423927, 0.03330767899751663, -0.026772603392601013, -0.07070225477218628, 0.04654645547270775, 0.04750082641839981, 0.0019476646557450294, 0.025759059935808182, 0.11362361162900925, 0.009333416819572449, -0.04950262978672981, -0.01569449156522751, -0.09391126781702042, 0.07522875815629959, -0.028198063373565674, 0.03989298641681671, 0.0035342122428119183, 0.07182461768388748, 0.02152501977980137, 0.0013340209843590856, -0.0007457977044396102, 0.05273981764912605, -0.00036878048558719456, -0.02502056583762169, -0.023677874356508255, -0.041711051017045975, 0.0028624602127820253, -0.020646272227168083, 0.010616321116685867, 0.009699540212750435, -0.019125528633594513, -0.017211897298693657, 0.0344378761947155, -0.03219744935631752, 0.0291135236620903, -0.0030442748684436083, 0.010520335286855698, 0.03375152125954628, 0.02112865261733532, -0.022376203909516335, -0.030555734410881996, -0.012171924114227295, -0.022687507793307304, -0.044728633016347885, 0.044686295092105865, 0.046350397169589996, 0.046581465750932693, 0.006603690329939127, -0.007363608106970787, -0.0004501212388277054, -0.032385967671871185, 0.035402584820985794, 0.05941785126924515, 0.002556009218096733, -0.02030702866613865, 0.0053737228736281395, -0.007986873388290405, -0.022537007927894592, 0.030356891453266144, -0.04418379068374634, -0.0026467235293239355, 0.031039081513881683, -0.027082663029432297, -0.010407717898488045, 0.003686395939439535, -0.02745569683611393, 0.008941548876464367, 0.0317520797252655, 0.027798030525445938, 0.018633369356393814, -0.09175465255975723, -0.0045881071127951145, 0.003600980620831251, 0.05189381167292595, -0.012922911904752254, -0.038913946598768234, 0.007635294459760189, -0.034344010055065155, 0.0037811154033988714, -0.0009609932312741876, 0.002107841894030571, -0.0010895339073613286, 0.016365893185138702, -0.0007822449551895261, -0.01947876811027527, 0.003560285549610853, 0.07243502140045166, 0.003330577863380313, 0.024554740637540817, 0.0041373614221811295, -0.07433682680130005, 0.030596576631069183, -0.01463962160050869, -0.009573137387633324, -0.019367096945643425, -0.016675857827067375, 0.06620604544878006, 0.0353364460170269, -0.004483883734792471, -0.01754007674753666, -0.028517866507172585, -0.018077058717608452, -0.0021244690287858248, -0.00017313743592239916, -0.060556959360837936, -0.018468743190169334, -0.03989711031317711, 0.018099403008818626, 0.023694882169365883, 0.023626718670129776, -0.003892917651683092, -0.027070090174674988, -0.035865891724824905, 0.0036081664729863405, -0.004148591309785843, 0.009350008331239223, 0.03463033214211464, 0.03015284612774849, 0.013523217290639877, -0.011400667019188404, 0.0041979169473052025, 0.03843238204717636, 0.030835626646876335, 0.04320907220244408, -0.04162402078509331, -0.012334481813013554, -0.025813613086938858, 0.026575246825814247, 0.005341629032045603, -0.0201722402125597, -0.050265148282051086, 0.02379044145345688, -0.013776385225355625, -0.016564473509788513, 0.022677723318338394, 0.021968789398670197, 0.026718586683273315, -0.059722088277339935, -0.028528926894068718, -0.0032742340117692947, -0.023767855018377304, 0.055562734603881836, 0.018728170543909073, 0.0008143999730236828, -0.03724460303783417, -0.005040853284299374, 0.01620045304298401, -0.038728635758161545, 0.048482734709978104, 0.03171528875827789, -0.03904177248477936, -0.04070364311337471, -0.025860296562314034, -0.000400329299736768, -0.020905446261167526, -0.02712734043598175, 0.05398699268698692, -0.028732191771268845, -0.015390862710773945, 0.03146753087639809, -0.0029520762618631124, -0.03889186680316925, 0.027635691687464714, -0.021558968350291252, 0.04372411221265793, 0.0019434451824054122, 0.00635521998628974, 0.023358909413218498, 0.0389847494661808, 0.023326104506850243, -0.0013155536726117134, -0.06778288632631302, 0.02040557749569416, -0.029050445184111595, 0.03057676926255226, 0.03303622826933861, 0.008450333960354328, -0.03508850559592247, 0.007764975540339947, 0.012221843004226685, 0.019534876570105553, -0.01632631942629814, -0.022751836106181145, -0.027431325986981392, 0.017945095896720886, 0.003347015706822276, -0.017314905300736427, 0.017446544021368027, -0.04050047695636749, 0.03298039361834526, -0.03461829572916031, -0.03246813639998436, -0.01569194532930851, 0.013656295835971832, 0.00585519801825285, -0.022823719307780266, 0.01083509624004364, -0.030152494087815285, 0.028727836906909943, -0.0010627286974340677, 0.01154360268265009, -0.049855682998895645, 0.02264799363911152, 0.031999461352825165, 0.00811065174639225, 0.028289062902331352, 0.023883823305368423, 0.021228043362498283, 0.015152360312640667, -0.003309669904410839, -0.042073361575603485, 0.025272442027926445, 0.04517623782157898, -0.055732518434524536, 0.00838458351790905, 0.005072551779448986, 0.013146761804819107, -0.000024195760488510132, -0.02138116955757141, 0.022458666935563087, 0.03995300456881523, -0.017958225682377815, -0.002974247792735696, -0.023494286462664604, 0.05944862589240074, -0.04316454380750656, 0.007588480599224567, 0.0012700855731964111, -0.008297848515212536, 0.01348862610757351, -0.03191439062356949, 0.03335758298635483, -0.0036213435232639313, 0.06528383493423462, 0.059501033276319504, -0.008221756666898727, -0.014061259105801582, -0.039830613881349564, -0.012207948602735996, -0.011094695888459682, -0.02122764103114605, 0.010419018566608429, -0.01127533707767725, -0.010004863142967224, 0.028490714728832245, 0.046935033053159714, 0.03232697769999504, 0.018005385994911194, -0.026300543919205666, 0.03070915676653385, -0.05117249861359596, 0.009101121686398983, 0.039136771112680435, -0.022256314754486084, 0.012520961463451385, 0.0017619661521166563, 0.06369669735431671, 0.0012546172365546227, 0.021807890385389328, 0.030963843688368797, -0.01134572084993124, 0.025250039994716644, -0.0027146677020937204, 0.018778404220938683, -0.009689541533589363, 0.017888307571411133, 0.012653520330786705, -0.005285053513944149, -0.004881188273429871, -0.0066381883807480335, 0.013468383811414242, 0.012587844394147396, -0.021715689450502396, 0.01610609143972397, 0.028489060699939728, -0.005542685743421316, 0.01672353595495224, 0.013195914216339588, 0.017965268343687057, -0.03190290927886963, 0.01672397553920746, 0.00156000058632344, -0.03275679051876068, -0.018980685621500015, 0.009645032696425915, -0.04399687051773071, -0.025387611240148544, 0.004986519925296307, 0.0061769974417984486, 0.08850855380296707, -0.04313751310110092, -0.017274627462029457, 0.008422041311860085, -0.016288140788674355, -0.0008050708565860987, -0.04547049477696419, -0.017864933237433434, 0.024367615580558777, 0.004960933234542608, -0.012737445533275604, 0.06330084055662155, -0.00954904593527317, 0.055145759135484695, 0.017665591090917587, 0.0030543908942490816, 0.004883335903286934, -0.057285476475954056, 0.023837562650442123, 0.022677350789308548, -0.015145600773394108, -0.018557198345661163, -0.041680529713630676, -0.014254968613386154, -0.05498667433857918, -0.07568787783384323, 0.051612429320812225, 0.074683278799057, 0.0022747251205146313, -0.01652207225561142, -0.01906879059970379, 0.03227310627698898, 0.048309970647096634, -0.030912769958376884, -0.011845417320728302, -0.010965593159198761, 0.06158560514450073, 0.010944560170173645, 0.0006691902526654303, -0.005208783317357302, -0.04348798468708992, -0.0039170775562524796, -0.04221094027161598, 0.017041489481925964, 0.022384904325008392, 0.02317453920841217, -0.004207998979836702, 0.020670486614108086, -0.02646617963910103, 0.006292169447988272, 0.022605901584029198, 0.03468652069568634, 0.02891078032553196, 0.01463110838085413, 0.025288671255111694, -0.0027485257014632225, -0.058086808770895004, 0.03567495942115784, 0.007410596124827862, -0.022156434133648872, -0.005080170929431915, 0.014991861768066883, 0.02253131754696369, 0.032089848071336746, 0.0166335292160511, 0.03890445455908775, 0.004879008047282696, 0.012662505730986595, 0.008280785754323006, 0.0505492202937603, 0.041070252656936646, -0.026071181520819664, 0.012761684134602547, -0.002981067867949605, 0.0002732098218984902, 0.007670127786695957, 0.020532740280032158, 0.0697171688079834, -0.005145377013832331, -0.0014457738725468516, 0.0010533395688980818, 0.03562372550368309, 0.039218224585056305, 0.01742730103433132, 0.02467210218310356, -0.005634606815874577, 0.06626512855291367, 0.010696296580135822, 0.052258290350437164, -0.0026200732681900263, -0.001252305693924427, -0.0004869660479016602, 0.03789635747671127, -0.002300601452589035, 0.01647769659757614, -0.017424868419766426, 0.04607601836323738, 0.019679812714457512, 0.014253874309360981, -0.006051325239241123, 0.01398724690079689, -0.033004458993673325, 0.0026687360368669033, 0.0063175312243402, 0.0023700138553977013, -0.012461217120289803, -0.02527083083987236, -0.021822093054652214, 0.013158224523067474, 0.00664046173915267, -0.007222409825772047, 0.040168244391679764, 0.0011074123904109001, 0.009185812436044216, -0.03625793382525444, 0.0187061857432127, 0.020510490983724594, 0.012675509788095951, -0.003772437572479248, -0.002923090010881424, -0.022985728457570076, -0.0021070661023259163, 0.03125124052166939, -0.012135089375078678, -0.012907304801046848, -0.011864005587995052, -0.06443412601947784, -0.002319217659533024, 0.04665547236800194, 0.0038225746247917414, 0.01667080447077751, 0.01756863109767437, 0.030070584267377853, 0.002299771411344409, 0.023412952199578285, 0.014300945214927197, -0.025730572640895844, 0.010648317635059357, -0.030971208587288857, 0.04412487894296646, -0.034209202975034714, 0.026765335351228714, 0.07278405129909515, 0.048603564500808716, -0.04215206578373909, -0.01416384894400835, 0.003507290966808796, 0.0263817198574543, -0.01778748817741871, 0.040667008608579636, 0.0053639039397239685, -0.012835011817514896, -0.01935509406030178, -0.015147826634347439, 0.00029356585582718253, -0.04883768409490585, 0.013141686096787453, 0.032637037336826324, -0.016242431476712227, -0.05096712335944176, 0.04321179911494255, 0.03739984706044197, 0.031773269176483154, 0.03325912356376648, 0.036142993718385696, 0.0010461646597832441, 0.011148866266012192, -0.028633302077651024, 0.017366595566272736, 0.0006504128105007112, -0.013862593099474907, -0.03666190057992935, 0.0010783682810142636, -0.026184823364019394, 0.008418968878686428, -0.015740633010864258, 0.030962252989411354, -0.020524417981505394, -0.009480737149715424, -0.007146477699279785, 0.028267187997698784, -0.0005093783838674426, 0.0013306224718689919, 0.02751232497394085, 0.0405285619199276, 0.009893106296658516, -0.0022979076020419598, 0.0017974467482417822, 0.031516142189502716, 0.012523657642304897, 0.021722234785556793, 0.0517575703561306, -0.017960183322429657, 0.0017628895584493876, 0.004138569813221693, -0.015909645706415176, 0.03132383152842522, -0.07119099050760269, 0.027524368837475777, 0.016594046726822853, 0.011736923828721046, -0.0399937778711319, 0.011406498029828072, -0.033704034984111786, 0.013393983244895935, 0.025160279124975204, -0.03839968517422676, -0.07522866874933243, -0.019838349893689156, -0.02870970591902733, -0.03982221707701683, 0.02242792584002018, -0.06293324381113052, 0.028302514925599098, -0.016344957053661346, 0.010212408378720284, -0.06628414988517761, 0.03240576386451721, -0.018661512061953545, 0.012575388886034489, -0.036791399121284485, -0.027187222614884377, -0.04032149165868759, 0.01907534711062908, 0.02398977428674698, 0.004162490367889404, -0.028332611545920372, 0.0708656758069992, 0.033384278416633606, -0.0269511416554451, 0.004358300473541021, -0.0036259989719837904, 0.02921099029481411, 0.009281089529395103, 0.019476719200611115, 0.003125786082819104, 0.03091343678534031, 0.010293608531355858, -0.017156105488538742, -0.047182388603687286, 0.006030600517988205 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
Would you like to integrate your library to the Hub? This integration is possible thanks to the [huggingface_hub`](https://github.com/huggingface/huggingface_hub) library which has all our widgets and the API for all our supported libraries. If you would like to integrate your library to the Hub, we have a guide for you!
[ 0.011898119002580643, -0.012339652515947819, 0.056593939661979675, -0.0336802639067173, 0.09271766990423203, 0.009152076207101345, -0.01024006400257349, 0.0881551057100296, 0.000779774331022054, -0.06993338465690613, -0.05822904780507088, 0.03974153473973274, 0.004894515965133905, 0.09388455748558044, 0.010578109882771969, -0.029248453676700592, 0.05905531346797943, -0.012701899744570255, -0.0008911784389056265, 0.027133993804454803, 0.011216355487704277, -0.06886423379182816, 0.027450265362858772, -0.016378730535507202, -0.016687585040926933, -0.08647887408733368, 0.044392116367816925, 0.029302559792995453, 0.03577013686299324, 0.0010559288784861565, -0.07535923272371292, -0.02113058790564537, 0.019283929839730263, -0.073832206428051, 0.032195962965488434, 0.04872911050915718, -0.1533159613609314, 0.05035480111837387, 0.05433578044176102, 0.013052462600171566, -0.009105873294174671, -0.015558438375592232, -0.05844375118613243, 0.04579228535294533, 0.010317246429622173, -0.06769107282161713, -0.20899131894111633, 0.098446786403656, 0.022851115092635155, -0.014921463094651699, -0.09239973872900009, 0.05730618163943291, 0.014407072216272354, 0.00595539016649127, 0.04627012088894844, -0.007229855749756098, -0.014885978773236275, -0.08159919083118439, -0.007653222884982824, 0.0018715281039476395, 0.05147073045372963, 0.010982867330312729, 0.01425481028854847, 0.06917954236268997, 0.013703572563827038, 0.05415581166744232, -0.009634171612560749, -0.0017026158748194575, -0.038246091455221176, 0.0035022313240915537, 0.011787443421781063, -0.024236876517534256, -0.023516809567809105, -0.036156605929136276, 0.039407990872859955, -0.032517775893211365, -0.03482623025774956, 0.028819454833865166, 0.05285486951470375, 0.002254482125863433, 0.013897116295993328, -0.02796722762286663, 0.026285765692591667, 0.049296941608190536, 0.0372767448425293, 0.0517924539744854, -0.005233402363955975, -0.06713481992483139, -0.052343644201755524, 0.0636439248919487, -0.03178602084517479, -0.1450691521167755, -0.019810711964964867, 0.018549324944615364, 0.08281603455543518, -0.007970919832587242, 0.025659842416644096, 0.017967309802770615, 0.0069584231823682785, 0.017893264070153236, -0.027945952489972115, -0.04590035602450371, -0.002073055598884821, -0.05358714982867241, -0.02505544386804104, 0.019633721560239792, 0.018183285370469093, -0.09510688483715057, -0.030938591808080673, 0.0039149061776697636, 0.012651338241994381, -0.0690729096531868, 0.01442247349768877, 0.06198875978589058, -0.023988239467144012, 0.06366642564535141, 0.006916587706655264, 0.0008231793763116002, -0.015531713142991066, 0.034884098917245865, 0.01980011537671089, 0.10086401551961899, -0.005903844255954027, 0.019772104918956757, 0.05463777482509613, 0.09363250434398651, -0.0045092180371284485, -0.0067629688419401646, -0.028141213580965996, -0.06977518647909164, 0.03494023531675339, 0.01696079596877098, 0.055039502680301666, -0.03333091735839844, -0.016146952286362648, -0.04267572984099388, -0.015880577266216278, -0.0642811581492424, 0.02120002917945385, -0.01808345317840576, 0.00013589116861112416, 0.07706650346517563, -0.0324714258313179, 0.021536877378821373, 0.03529325872659683, 0.0001705309987301007, -0.057213734835386276, 0.059453193098306656, -0.03417278081178665, -0.011668442748486996, -0.03673532232642174, 0.051317982375621796, -0.01648050732910633, 0.007505046669393778, -0.08857249468564987, 0.0439114011824131, -0.0012157689779996872, -0.012872914783656597, -0.058135025203228, 0.011698059737682343, -0.02450820989906788, 0.007914870046079159, -0.07947512716054916, -0.02182665467262268, 0.02236315980553627, -0.009260409511625767, 0.009479602798819542, -0.0456533320248127, 0.030467862263321877, -0.08625976741313934, 0.025600671768188477, -0.0791124552488327, -0.011806094087660313, -0.008400673046708107, -0.014230971224606037, 0.04179989919066429, 0.06951114535331726, 0.06272529810667038, -0.04946446791291237, 0.024864984676241875, -0.03037082776427269, 0.04742002487182617, -0.01957615092396736, 0.03752744570374489, 0.024262825027108192, -0.03904515132308006, -0.016724560409784317, 0.025593070313334465, 0.002554749371483922, -0.017672725021839142, 0.000472697225632146, -0.06414901465177536, 0.053268902003765106, 0.03019491583108902, 0.046753816306591034, -0.01238943636417389, -0.03718949481844902, 0.13209235668182373, 0.01723848283290863, 0.06781446188688278, 0.05690593272447586, 0.004672232083976269, 0.029468988999724388, -0.017818570137023926, -0.011065111495554447, 0.0009146161610260606, 0.0020661752205342054, -0.032441552728414536, -0.0010698472615331411, -0.008564193733036518, 0.03082011267542839, -0.10452032834291458, 0.0704205334186554, -0.04826584830880165, 0.015334507450461388, -0.050641823559999466, -0.017395388334989548, 0.01354299671947956, 0.02204062230885029, -0.019974838942289352, 0.20152099430561066, -0.015773048624396324, 0.02288275770843029, 0.02565893344581127, -0.02197868563234806, 0.03733358159661293, 0.08025141805410385, 0.07489276677370071, 0.06979048997163773, -0.07233923673629761, -0.03559919446706772, -0.07518133521080017, -0.07185523211956024, 0.019243735820055008, -0.038488730788230896, -0.026827754452824593, 0.06043355539441109, -0.024570118635892868, 0.01531270332634449, 0.010634300298988819, 0.004319937899708748, -0.06312132626771927, -0.031424880027770996, 0.031048698350787163, 0.03525777906179428, -0.020232923328876495, 0.03332379460334778, 0.017779063433408737, -0.032875414937734604, -0.008948232047259808, -0.04921076074242592, 0.03415939584374428, 0.041570790112018585, -0.036182861775159836, 0.049050990492105484, 0.04102979972958565, 0.004340933635830879, -0.031219009310007095, -0.01945619098842144, 0.05899335816502571, 0.008658125065267086, -0.024155693128705025, -0.04283579811453819, -0.061101410537958145, -0.03368647024035454, -0.03824165090918541, -0.026971882209181786, 0.02184118516743183, -0.024043912068009377, 0.017623547464609146, 0.04141978174448013, -0.025503510609269142, 0.032737985253334045, 0.002509292447939515, 0.0006819259142503142, 0.027388451620936394, 0.03032139129936695, -0.007374926935881376, -0.032871052622795105, -0.005954645574092865, 0.014888333156704903, -0.052130747586488724, 0.040340855717659, 0.030711889266967773, 0.022202564403414726, 0.0055144294165074825, -0.009715141728520393, -0.042364783585071564, -0.035124827176332474, 0.032999154180288315, 0.000028616977942874655, 0.028867186978459358, 0.030146023258566856, -0.024113483726978302, -0.0007184000569395721, -0.009491424076259136, 0.02220766805112362, 0.011973554268479347, -0.02020682953298092, 0.009456006810069084, -0.004164170473814011, 0.02406737394630909, 0.008242749609053135, -0.02323753945529461, -0.04723123833537102, 0.04189334437251091, 0.01703501120209694, -0.007111521437764168, -0.11180238425731659, -0.05583912879228592, -0.019394563511013985, 0.02444648928940296, -0.04162215068936348, -0.0271621011197567, 0.0008488308521918952, -0.0253517497330904, 0.01925607956945896, 0.008766548708081245, 0.014987966977059841, 0.016350524500012398, 0.02774079144001007, -0.013017598539590836, -0.005155583843588829, -0.01779305376112461, -0.008057662285864353, 0.021501580253243446, 0.05547723174095154, 0.040226686745882034, -0.05940781533718109, 0.01565423235297203, 0.006830933969467878, -0.015205709263682365, -0.01800341159105301, -0.05527365952730179, 0.04885636270046234, -0.004261304624378681, 0.021647652611136436, -0.048852309584617615, 0.019338684156537056, -0.006471123546361923, -0.04015299677848816, -0.010196425020694733, -0.06814666837453842, -0.004358024336397648, -0.010575138963758945, -0.007307790219783783, 0.044655971229076385, 0.013360870070755482, 0.008977861143648624, 0.016999028623104095, 0.02749059721827507, -0.022724701091647148, 0.010484372265636921, 0.0022094398736953735, -0.02594621852040291, 0.03689458221197128, 0.02418811060488224, -0.0037003150209784508, -0.022449364885687828, 0.005297159776091576, 0.020596997812390327, 0.0393327921628952, 0.00014356661995407194, 0.021626565605401993, -0.006377669982612133, 0.037586744874715805, 0.002275340026244521, -0.030320292338728905, -0.04887713864445686, -0.005176878068596125, -0.016363976523280144, -0.0321330688893795, -0.03932742401957512, 0.03648346662521362, -0.024498917162418365, 0.016535280272364616, -0.005509612616151571, 0.013383532874286175, 0.008960933424532413, 0.029604114592075348, 0.0028636734932661057, 0.016413243487477303, -0.00649226363748312, -0.002123825252056122, -0.008658431470394135, -0.04197779297828674, 0.0711958110332489, 0.01554007176309824, -0.025922659784555435, -0.003766897600144148, -0.010812151245772839, 0.0038393614813685417, -0.030232246965169907, 0.0039472877979278564, 0.03711196780204773, -0.0034666380379348993, 0.01684313453733921, 0.03910773620009422, 0.004759145434945822, -0.02404780127108097, 0.0019491419661790133, -0.02734648436307907, -0.005665228236466646, 0.016238879412412643, 0.03368481248617172, 0.03403333202004433, 0.0019315455574542284, 0.0281178280711174, 0.034215860068798065, -0.013286490924656391, -0.032755959779024124, 0.015020349994301796, 0.01522937510162592, 0.052744898945093155, -0.02630651742219925, -0.05331285670399666, 0.056620098650455475, -0.016892489045858383, 0.02656722255051136, -0.04307932406663895, -0.014239729382097721, -0.012107765302062035, 0.03882233053445816, -0.012151513248682022, -0.0001895130699267611, -0.018021246418356895, -0.042877163738012314, 0.03785933926701546, -0.017956886440515518, 0.02362404391169548, -0.02502177096903324, -0.03914330154657364, -0.013478788547217846, -0.0029830369167029858, 0.03198452666401863, -0.021122906357049942, 0.00823074672371149, -0.0012438367120921612, -0.004951889626681805, -0.021942615509033203, 0.021401485428214073, 0.001076547778211534, 0.003347231773659587, 0.007667183876037598, -0.008147643879055977, 0.026569625362753868, 0.01925659365952015, -0.04276909679174423, -0.023888174444437027, -0.006038573104888201, 0.03062511421740055, -0.028002405539155006, 0.041748348623514175, 0.005125054623931646, -0.07187613844871521, 0.010004842653870583, -0.03703157231211662, 0.02523396722972393, 0.02102949656546116, -0.021458610892295837, -0.024832574650645256, 0.04161040112376213, 0.026806160807609558, -0.009996912442147732, 0.012068835087120533, 0.011094245128333569, -0.005635391920804977, 0.05118704214692116, -0.00925268605351448, 0.0026361485943198204, -0.015684645622968674, 0.02531682886183262, -0.0003983414208050817, 0.006528477184474468, -0.004013442900031805, -0.06030132994055748, -0.01306186057627201, 0.003792321775108576, -0.002119449432939291, 0.005908929742872715, 0.0014397751074284315, -0.03617855906486511, -0.019948329776525497, 0.0627393126487732, 0.03626440837979317, -0.009571823291480541, 0.009933019056916237, 0.021547235548496246, -0.0494145005941391, 0.008685518987476826, 0.03796001896262169, -0.0029841233044862747, -0.005460089072585106, 0.019083302468061447, 0.05353790149092674, 0.045786745846271515, -0.007025678176432848, 0.023361334577202797, -0.006184635683894157, -0.02655988745391369, 0.016763493418693542, -0.0250866562128067, 0.01379774883389473, -0.03903347626328468, 0.004865169059485197, -0.01582888327538967, 0.0028922627680003643, -0.01648520864546299, 0.0030626754742115736, 0.05082881450653076, -0.041025154292583466, 0.0034359379205852747, 0.024444865062832832, 0.00016933929873630404, 0.026563389226794243, -0.031597767025232315, 0.03369273617863655, -0.0313112773001194, -0.01950620859861374, -0.00026637574774213135, 0.012312894687056541, -0.010598513297736645, 0.011647514067590237, -0.0031637195497751236, -0.04393819347023964, 0.003739196341484785, 0.008430075831711292, 0.05425546318292618, -0.016233069822192192, 0.002483763499185443, -0.027988210320472717, -0.023620115593075752, 0.03876195847988129, -0.021463138982653618, 0.0008559637935832143, -0.011074778623878956, -0.019802024587988853, 0.02753111906349659, 0.04563654586672783, -0.03326175734400749, 0.011171061545610428, 0.027358364313840866, 0.023539118468761444, 0.016615895554423332, -0.05832066386938095, 0.019413143396377563, 0.0415065698325634, -0.0011134077794849873, 0.026588289067149162, -0.002547571202740073, -0.043265439569950104, -0.0034584379754960537, -0.046385928988456726, 0.010318472981452942, 0.10244668275117874, 0.018765892833471298, 0.004107777960598469, 0.0013202233240008354, 0.03392638638615608, 0.0003111064725089818, 0.00809938833117485, -0.0288190096616745, 0.00015581758634652942, 0.03214436396956444, 0.017564969137310982, 0.009853797033429146, 0.004162659868597984, -0.017047911882400513, 0.0025209940504282713, -0.04462539404630661, 0.006904971320182085, 0.017426621168851852, -0.04023651406168938, -0.0011840933002531528, -0.020710185170173645, -0.06348858773708344, -0.013597086071968079, 0.028963956981897354, 0.013848389498889446, 0.056091729551553726, 0.01115226000547409, -0.00017290077812504023, -0.022236162796616554, -0.03425981104373932, 0.020133450627326965, 0.04923184588551521, -0.02473117597401142, 0.04293254017829895, 0.029182035475969315, 0.05695316195487976, 0.03555829077959061, 0.010210901498794556, 0.02762138657271862, 0.03277327120304108, 0.05725500360131264, -0.004075316246598959, 0.07751663029193878, 0.02628076821565628, -0.012566491030156612, -0.003921381663531065, -0.027011537924408913, 0.000834737962577492, -0.00277519878000021, 0.004430341999977827, 0.009149919264018536, 0.012713702395558357, -0.01291828416287899, -0.01506350189447403, 0.020571544766426086, 0.011111457832157612, 0.034811072051525116, 0.0028131266590207815, 0.003430203767493367, 0.057275932282209396, 0.001865909667685628, 0.012008124962449074, 0.001619567978195846, -0.009081273339688778, -0.0002791632723528892, 0.057911962270736694, 0.013164548203349113, 0.0181416068226099, -0.04374359920620918, -0.012700414285063744, 0.03889770805835724, -0.02344960719347, -0.023487670347094536, -0.012154986150562763, 0.0031983982771635056, -0.040285129100084305, -0.029360609129071236, 0.015859123319387436, -0.029666589573025703, -0.01706056296825409, 0.00685330992564559, 0.024341123178601265, -0.017269548028707504, -0.015130640007555485, 0.0008140737190842628, 0.03817586973309517, 0.00858393032103777, 0.0063634878024458885, -0.0015511311357840896, 0.0623985156416893, 0.028900813311338425, 0.00726303132250905, -0.03463248908519745, -0.023217899724841118, -0.029796427115797997, -0.0027213399298489094, -0.004975029733031988, -0.013254908844828606, 0.006827903911471367, -0.025458334013819695, -0.02587486244738102, 0.04601489007472992, -0.0020554796792566776, 0.033829465508461, 0.011787157505750656, 0.031582266092300415, -0.03694711625576019, 0.010717852972447872, 0.011734840460121632, 0.0005216941935941577, 0.004603930748999119, -0.02488492801785469, 0.015154963359236717, -0.010312128812074661, 0.004993116017431021, 0.033293887972831726, 0.006093238014727831, -0.03557547926902771, -0.037168581038713455, 0.009054688736796379, -0.023965563625097275, -0.009994706138968468, 0.0577322393655777, -0.004637232515960932, -0.014055092819035053, 0.023750899359583855, -0.014826134778559208, 0.015336605720221996, -0.0004079361679032445, 0.020701302215456963, 0.06247633695602417, -0.027311764657497406, -0.011457384563982487, -0.00019744096789509058, 0.05426982790231705, 0.040879104286432266, 0.00920022651553154, 0.03930925577878952, 0.0266698207706213, 0.0017896915087476373, -0.028855103999376297, 0.028318945318460464, -0.02847788669168949, -0.014295588247478008, -0.01861906796693802, -0.03552577644586563, -0.0002715324517339468, -0.04880078136920929, 0.000343895866535604, -0.010457837954163551, -0.04204288497567177, -0.002762609627097845, -0.014483406208455563, -0.01800846867263317, -0.01891305483877659, 0.016690954566001892, 0.025273999199271202, 0.04526536166667938, 0.049332763999700546, 0.008374962024390697, -0.006656887475401163, 0.02816111035645008, 0.013527211733162403, 0.011340172961354256, 0.03482285887002945, 0.03620527312159538, -0.025779200717806816, -0.03157484903931618, 0.010165673680603504, -0.0007894936134107411, -0.04001827910542488, 0.06051919236779213, 0.0032321831677109003, -0.008642551489174366, -0.039871860295534134, 0.0015587742673233151, 0.03503250330686569, 0.012783804908394814, 0.04902288317680359, -0.03062489442527294, -0.028078850358724594, 0.003353764535859227, 0.0008330013952217996, -0.030673323199152946, 0.003943555522710085, -0.06819245219230652, -0.013609361834824085, 0.024441013112664223, -0.01123632863163948, 0.0025286166928708553, 0.010219545103609562, -0.02283523790538311, 0.036503568291664124, -0.0035257753916084766, -0.028148535639047623, -0.045283593237400055, -0.0009351528715342283, 0.05186856910586357, -0.023347189649939537, -0.03062431886792183, 0.02522222138941288, 0.013801892288029194, -0.033943966031074524, 0.010637495666742325, -0.006725202314555645, -0.013566659763455391, -0.003161749104037881, 0.013807636685669422, -0.02346617542207241, 0.07250680774450302, -0.00111963483504951, -0.06403791904449463, -0.03850526362657547, -0.0073165129870176315 ]
Welcome Stable-baselines3 to the Hugging Face Hub 🤗
ThomasSimonini
January 21, 2022
sb3
open-source-collab, rl
https://huggingface.co/blog/sb3
repo_id = id of the model repository from the Hugging Face Hub (repo_id = {organization}/{repo_name})
[ 0.013746742159128189, 0.01566493697464466, 0.011955236084759235, -0.02796909585595131, 0.0017325564986094832, 0.056306108832359314, 0.007527926936745644, 0.019134534522891045, -0.027297647669911385, -0.00039376047789119184, -0.078371562063694, 0.04724914953112602, 0.024419598281383514, 0.09496144205331802, -0.04301184043288231, -0.003698239102959633, 0.025475185364484787, -0.009530221112072468, -0.02514607086777687, 0.051111817359924316, -0.0007421482005156577, -0.017398592084646225, 0.04007386416196823, -0.02153288945555687, -0.035738587379455566, -0.047426365315914154, 0.011653308756649494, -0.02473754994571209, 0.00012215405877213925, 0.046191029250621796, -0.09017403423786163, -0.049951616674661636, 0.042088959366083145, -0.028248151764273643, 0.047111548483371735, 0.0766906589269638, -0.11877506226301193, -0.012737852521240711, 0.01959637552499771, 0.02240300551056862, -0.0061048162169754505, -0.0426609143614769, -0.021600862964987755, 0.0365002304315567, 0.053927257657051086, -0.052714332938194275, -0.14087626338005066, 0.13403037190437317, 0.009215204045176506, 0.010680207051336765, -0.04318219795823097, 0.04225765913724899, -0.04749172925949097, -0.023420242592692375, 0.02076801471412182, -0.057907409965991974, -0.06993456184864044, -0.0927131250500679, -0.010313114151358604, -0.005619226489216089, 0.015305792912840843, 0.030421581119298935, 0.03526085987687111, 0.06878248602151871, 0.03194499760866165, 0.0516539141535759, 0.009817230515182018, -0.010561040602624416, -0.018044209107756615, 0.025783339515328407, 0.015479138121008873, -0.004672633949667215, 0.02000580169260502, 0.006328061688691378, 0.004956099204719067, -0.028743285685777664, -0.0005973955849185586, 0.08205635845661163, 0.06645786762237549, 0.09464839100837708, -0.013115144334733486, -0.013988248072564602, 0.04550691321492195, 0.02845539152622223, 0.06683129072189331, 0.05392572283744812, -0.00850707944482565, -0.051155515015125275, -0.03469448909163475, 0.04924301430583, -0.030766978859901428, -0.06517636775970459, -0.01697469875216484, -0.04936600849032402, 0.06406759470701218, -0.06601473689079285, 0.07137677073478699, -0.011213226243853569, 0.017334910109639168, 0.0548725388944149, 0.00046092638513073325, -0.034349557012319565, 0.011422969400882721, -0.021571632474660873, -0.03178716450929642, -0.0172985028475523, -0.0307965949177742, -0.10299111902713776, -0.06650902330875397, -0.07676754891872406, 0.00793803296983242, 0.011835278011858463, -0.0063808877021074295, 0.10244474560022354, -0.017425233498215675, 0.0738971084356308, -0.05256403610110283, -0.03422378748655319, 0.016910754144191742, 0.02790130488574505, 0.005259131547063589, 0.10117319971323013, 0.010970213450491428, -0.00011768808326451108, 0.04648217558860779, 0.08144950866699219, -0.03973131254315376, -0.001217768876813352, -0.04135197773575783, -0.0038966659922152758, -0.016225606203079224, -0.014032998122274876, 0.04184383898973465, 0.030143050476908684, 0.0012616238091140985, -0.08100029081106186, 0.02040225826203823, -0.018489960581064224, 0.07820422947406769, 0.0022503877989947796, 0.015342234633862972, 0.05038006231188774, -0.036881864070892334, 0.07738824933767319, 0.032693102955818176, 0.01254604198038578, -0.04990497976541519, 0.021635916084051132, 0.006835488602519035, 0.04166500270366669, 0.014867874793708324, 0.07765158265829086, 0.027470434084534645, -0.031013689935207367, 0.016021728515625, 0.04139534756541252, -0.001208024681545794, -0.014166244305670261, -0.007393309846520424, 0.037349190562963486, 0.0170157328248024, 0.03868827596306801, -0.1034059077501297, -0.011585870757699013, -0.011682267300784588, 0.021855158731341362, 0.018318694084882736, 0.018646318465471268, 0.03494296222925186, -0.05920885503292084, 0.011687583290040493, -0.053792815655469894, 0.06001606956124306, 0.006056247744709253, 0.011083175428211689, 0.02987641468644142, -0.0008970809285528958, 0.018448971211910248, 0.008451311849057674, 0.022105183452367783, -0.020526904612779617, 0.0479770302772522, -0.0344892218708992, -0.00888199731707573, 0.06152826175093651, -0.07483293116092682, 0.013546264730393887, 0.02363559603691101, 0.017446940764784813, 0.02962697669863701, 0.005621758289635181, -0.07793186604976654, 0.06765644997358322, -0.0029656686820089817, 0.03988534212112427, -0.01864311657845974, -0.031052859500050545, 0.07764901220798492, 0.0025823877658694983, 0.00734670227393508, -0.019941838458180428, -0.04489012062549591, 0.017450004816055298, -0.0636884942650795, 0.03627428412437439, 0.021948613226413727, 0.011416497640311718, -0.08302938938140869, 0.08131387084722519, 0.03148944303393364, 0.009901408106088638, -0.040012456476688385, 0.10867733508348465, -0.08569690585136414, 0.0410679467022419, -0.025822466239333153, -0.0798259973526001, -0.006903111469000578, -0.005436376668512821, 0.032263025641441345, 0.20189844071865082, -0.031714215874671936, -0.024468660354614258, -0.030892301350831985, -0.0367327518761158, 0.03250599652528763, 0.021524587646126747, 0.07070089131593704, 0.05838673934340477, -0.0725826844573021, -0.030127791687846184, -0.02978566102683544, -0.01218603365123272, 0.02573847770690918, 0.04531032219529152, -0.10363062471151352, 0.021559886634349823, 0.023060861974954605, 0.02706291899085045, -0.0020823837257921696, -0.03638043627142906, -0.042449742555618286, -0.00870057474821806, 0.057851944118738174, 0.05572953820228577, 0.0023910612799227238, 0.02294217050075531, 0.004470520187169313, -0.07919634133577347, 0.03270271047949791, -0.09143165498971939, 0.0172447357326746, 0.03551773726940155, -0.024605121463537216, 0.05748378112912178, 0.0016622632974758744, -0.01265593059360981, 0.0012728475267067552, -0.040112316608428955, 0.058212634176015854, 0.018966317176818848, 0.010267235338687897, -0.054941337555646896, -0.04374411329627037, -0.041200172156095505, -0.04691246896982193, -0.03432178124785423, 0.008476504124701023, -0.019347067922353745, 0.022077083587646484, 0.014311136677861214, -0.023224590346217155, 0.01980412006378174, 0.018527673557400703, -0.011053664609789848, 0.02258521504700184, 0.012020056135952473, -0.00560090271756053, -0.004233169369399548, 0.0008403638494201005, -0.001815411145798862, -0.051846690475940704, 0.023125087842345238, 0.042106837034225464, 0.021150723099708557, -0.010494544170796871, 0.0167697761207819, -0.04711143299937248, -0.0035836456809192896, -0.012009110301733017, -0.02155154198408127, 0.06418309360742569, 0.02197876200079918, -0.01729748398065567, -0.017192812636494637, 0.024793514981865883, 0.043050020933151245, 0.022616369649767876, 0.006151056382805109, 0.0018523252801969647, -0.021869059652090073, 0.0006580219487659633, 0.012098372913897038, -0.03142356872558594, -0.01783311367034912, 0.05718628317117691, 0.02330568991601467, -0.004268978722393513, -0.09966816753149033, -0.04876489192247391, -0.029414493590593338, 0.02349179983139038, 0.003985763993114233, 0.0023413924500346184, 0.010016575455665588, -0.0006479790899902582, -0.0014897839864715934, 0.03360004723072052, 0.011612780392169952, -0.008988112211227417, 0.07129919528961182, 0.000653364579193294, -0.05539071932435036, -0.035170502960681915, -0.004678308963775635, 0.013499239459633827, 0.00472114235162735, 0.006689011584967375, -0.06366593390703201, -0.003644062438979745, -0.009661765769124031, -0.004831092897802591, 0.014448219910264015, -0.02100524678826332, 0.012572694569826126, 0.0007069794228300452, 0.0016030691331252456, -0.04654035344719887, 0.026731077581644058, -0.030058538541197777, -0.025457212701439857, -0.0288705937564373, -0.04363016039133072, 0.012170541100203991, -0.016675617545843124, -0.0348336435854435, 0.0018355096690356731, 0.030527263879776, -0.013895591720938683, 0.028424320742487907, 0.057750802487134933, -0.002775397850200534, 0.001224518520757556, -0.025458568707108498, -0.0264192633330822, 0.0006552450940944254, -0.006696443539112806, -0.024638168513774872, -0.04828580841422081, -0.021561358124017715, 0.024877334013581276, 0.016045359894633293, 0.028382975608110428, 0.016865624114871025, 0.03020433336496353, 0.038697488605976105, 0.014226209372282028, 0.011729404330253601, -0.023822464048862457, -0.011575384996831417, 0.004005738068372011, -0.04685993120074272, -0.05587872117757797, 0.002463490702211857, -0.007149320561438799, 0.031535886228084564, 0.006791544612497091, 0.054780397564172745, 0.0020199911668896675, -0.015163530595600605, -0.02625105157494545, 0.0192117840051651, -0.028890620917081833, -0.01737961918115616, -0.003764958120882511, -0.04598141834139824, 0.03228706493973732, -0.03862009197473526, -0.04618282616138458, 0.02038009837269783, 0.011548214592039585, 0.02360856905579567, -0.04568789526820183, -0.00917759258300066, 0.04651579260826111, -0.012631935067474842, 0.03154894337058067, 0.016972851008176804, -0.02910236269235611, -0.02911146730184555, 0.03349388763308525, 0.005242207553237677, -0.03076348826289177, -0.018559306859970093, 0.017794201150536537, 0.03068135678768158, -0.01718500442802906, 0.018982673063874245, 0.013875046744942665, -0.025505121797323227, -0.01400668267160654, 0.017927013337612152, 0.004381137900054455, 0.016881177201867104, 0.0010822651674970984, -0.053438249975442886, -0.0013618553057312965, -0.02215954288840294, -0.025532349944114685, -0.03155867010354996, -0.015161529183387756, -0.0569164864718914, 0.0006705027772113681, 0.0481792688369751, 0.02275189757347107, -0.03031652420759201, -0.013177366927266121, 0.05978149548172951, -0.05522922798991203, 0.018858306109905243, -0.009168005548417568, -0.03329102322459221, 0.030433041974902153, -0.012742431834340096, 0.03876107558608055, -0.0007083910168148577, 0.027449877932667732, -0.007700714282691479, -0.013077045790851116, -0.025441370904445648, 0.03729744255542755, -0.014857006259262562, -0.010256889276206493, 0.01812344416975975, 0.0029989539179950953, 0.027570487931370735, -0.016253676265478134, -0.02398970164358616, -0.008946987800300121, 0.02385086379945278, 0.026677722111344337, -0.0171795841306448, 0.009945154190063477, 0.008607265539467335, -0.05660802870988846, -0.027380038052797318, -0.008910649456083775, 0.04552612826228142, 0.05258627608418465, 0.03493073955178261, -0.03810140863060951, 0.03094123862683773, 0.06394464522600174, -0.007989787496626377, 0.01807990111410618, 0.014604917727410793, 0.00027903428417630494, 0.039473701268434525, -0.05627020448446274, -0.03040369786322117, 0.0030193047132343054, 0.06903379410505295, -0.0121705187484622, -0.0035812491551041603, -0.005286341067403555, -0.047392599284648895, -0.007153044920414686, 0.009864834137260914, -0.02261364832520485, 0.0017261483008041978, -0.0004964173422195017, -0.04882150888442993, -0.03719407692551613, 0.0559367798268795, 0.03769722580909729, -0.006810593884438276, -0.024655085057020187, -0.007734882179647684, -0.03649205341935158, 0.033181000500917435, 0.06346588581800461, -0.011691654101014137, -0.02088349312543869, 0.028312088921666145, 0.029149772599339485, 0.02723020128905773, 0.016133757308125496, 0.010062769055366516, 0.0014655118575319648, -0.011188804171979427, 0.005312486086040735, -0.021564463153481483, 0.0038983148988336325, -0.03955456241965294, -0.028471671044826508, -0.017004260793328285, -0.05140986666083336, -0.027398722246289253, 0.03562574088573456, 0.09029214829206467, -0.03612598776817322, -0.015302874147891998, 0.010427829809486866, -0.00048294366570189595, 0.0292497705668211, 0.019040435552597046, 0.01010613888502121, -0.01590540073812008, -0.013311406597495079, -0.028657276183366776, -0.0419638529419899, -0.021026359871029854, 0.03323720768094063, -0.03370702639222145, -0.013815709389746189, -0.027785489335656166, -0.0021698283962905407, 0.05830815061926842, -0.03737477585673332, -0.012028435245156288, -0.010459192097187042, 0.003461363958194852, 0.014363362453877926, -0.03318753093481064, 0.0054964302107691765, 0.06680504232645035, 0.013103456236422062, 0.04512016475200653, 0.013730501756072044, -0.06215659901499748, -0.006099692080169916, 0.009132979437708855, -0.0013919782359153032, 0.017961084842681885, -0.0324031263589859, 0.025301488116383553, 0.025718826800584793, 0.01519028376787901, -0.0006002194131724536, 0.017827291041612625, -0.036378465592861176, -0.013240759260952473, 0.0002424184640403837, -0.000666725798510015, 0.03278809040784836, 0.020104320719838142, 0.03681230917572975, 0.02526973932981491, 0.030901504680514336, -0.014871451072394848, 0.027050375938415527, -0.005184222012758255, -0.005945554468780756, 0.04388164356350899, 0.0026477142237126827, -0.007753212470561266, -0.02364407666027546, 0.015389274805784225, -0.017183860763907433, -0.03187616169452667, -0.007238038815557957, 0.04549282789230347, -0.012346802279353142, 0.05625522881746292, -0.037043191492557526, -0.046929847449064255, -0.01797267235815525, 0.011720472946763039, 0.033781830221414566, 0.04887320473790169, 0.027170121669769287, -0.004575627855956554, -0.014285220764577389, -0.020099282264709473, -0.014868251048028469, 0.06532850861549377, -0.04714841768145561, 0.05161973834037781, -0.006497158668935299, 0.05348104238510132, 0.053945392370224, 0.03179004043340683, 0.01126942876726389, 0.0022786047775298357, 0.037047937512397766, -0.0019105197861790657, 0.04233361408114433, 0.024103311821818352, -0.008727672509849072, 0.02826693467795849, -0.022924263030290604, -0.01696275919675827, -0.012458333745598793, 0.033287808299064636, 0.023120123893022537, 0.014038107357919216, 0.04831545799970627, -0.014778022654354572, 0.0329110287129879, -0.01208572555333376, 0.018123267218470573, -0.02161252126097679, -0.026071203872561455, 0.028657615184783936, -0.015213970094919205, -0.0019241501577198505, 0.062008086591959, -0.009981025941669941, 0.020450035110116005, 0.013660158030688763, -0.0030622652266174555, -0.005696945358067751, 0.02430913597345352, -0.006158293224871159, 0.00732396449893713, -0.058567214757204056, -0.057263199239969254, -0.013994784094393253, 0.020173965021967888, -0.01729954034090042, -0.04977310448884964, 0.0017688286025077105, 0.04165830835700035, 0.014690827578306198, -0.024545518681406975, 0.018483666703104973, -0.0006170785054564476, -0.04166180640459061, 0.0043654232285916805, 0.037354037165641785, -0.008234499953687191, -0.010613412596285343, 0.040178634226322174, 0.010529130697250366, 0.042999811470508575, -0.01443646289408207, -0.038125816732645035, 0.01914382167160511, -0.06424164772033691, -0.013449291698634624, -0.025084640830755234, -0.013640837743878365, -0.008963732980191708, 0.006303632631897926, 0.009469056501984596, 0.008832774125039577, 0.015976404771208763, 0.027642851695418358, 0.024875586852431297, 0.021906910464167595, -0.0569600835442543, 0.0459178127348423, 0.010388785973191261, 0.0016334551619365811, -0.006600948050618172, -0.02244577743113041, -0.001210259273648262, 0.012335806153714657, 0.023836933076381683, 0.03787771984934807, 0.00042613083496689796, -0.02716185338795185, -0.05333478003740311, 0.0024859607219696045, -0.053205568343400955, -0.023537546396255493, 0.03184328228235245, 0.008233293890953064, -0.016497042030096054, 0.020495733246207237, -0.005030055530369282, -0.00869961641728878, -0.03152542933821678, 0.015285818837583065, 0.04047653079032898, -0.032904572784900665, -0.002006322145462036, 0.0005395890329964459, 0.015798525884747505, 0.024248424917459488, 0.01388857327401638, 0.04150635004043579, -0.013460313901305199, 0.016582239419221878, -0.046431247144937515, 0.05990874394774437, -0.02403896674513817, -0.01382109709084034, -0.001657555578276515, -0.05854261294007301, -0.01225675456225872, -0.015565718524158001, -0.021302074193954468, 0.01243505533784628, -0.04886956885457039, -0.03215104341506958, 0.00905273575335741, 0.01463757362216711, -0.015398552641272545, 0.042851921170949936, 0.06419360637664795, 0.04632497951388359, 0.06413114070892334, 0.020655222237110138, -0.029987210407853127, -0.005640012212097645, -0.02808675728738308, -0.008467278443276882, 0.03267931193113327, 0.0032030842266976833, -0.04156104847788811, 0.02965691313147545, 0.015192356891930103, -0.00239543872885406, -0.0669403150677681, 0.04346375912427902, 0.003406501142308116, -0.028313495218753815, -0.027892736718058586, 0.013331763446331024, 0.0015265292022377253, 0.007422538939863443, 0.03224341943860054, -0.027048159390687943, 0.0013216184452176094, -0.0506838858127594, 0.016664043068885803, -0.04482632130384445, 0.02865753509104252, -0.039553750306367874, 0.025964535772800446, 0.0398239828646183, -0.012926734052598476, 0.0222857054322958, 0.006300419569015503, -0.032640665769577026, -0.009575058706104755, -0.0169792752712965, -0.018732033669948578, -0.020498929545283318, -0.0013567648129537702, 0.0262281633913517, -0.03251698985695839, -0.02323157899081707, -0.023713452741503716, 0.01617455668747425, -0.07102957367897034, 0.0026226972695440054, -0.022740788757801056, 0.002285051392391324, -0.009768328629434109, -0.02606920339167118, -0.05180666968226433, 0.0322561040520668, 0.0005436287028715014, -0.024422328919172287, 0.00035595279769040644, 0.04494883865118027 ]
Supercharged Searching on the Hugging Face Hub
muellerzr
January 25, 2022
searching-the-hub
guide
https://huggingface.co/blog/searching-the-hub
# Supercharged Searching on the Hugging Face Hub The huggingface_hub library is a lightweight interface that provides a programmatic approach to exploring the hosting endpoints Hugging Face provides: models, datasets, and Spaces. Up until now, searching on the Hub through this interface was tricky to pull off, and there were many aspects of it a user had to "just know" and get accustomed to. In this article, we will be looking at a few exciting new features added to huggingface_hub to help lower that bar and provide users with a friendly API to search for the models and datasets they want to use without leaving their Jupyter or Python interfaces. > Before we begin, if you do not have the latest version of the huggingface_hub library on your system, please run the following cell: python !pip install huggingface_hub -U
[ 0.008433323353528976, 0.005724642425775528, 0.0335860513150692, -0.0054794615134596825, 0.0417717806994915, 0.03153977170586586, 0.006825122516602278, 0.040136754512786865, -0.03992952033877373, -0.022737428545951843, -0.1078970804810524, 0.029932567849755287, -0.004524893593043089, 0.03678296506404877, 0.05632689595222473, -0.07104536145925522, 0.03174076974391937, -0.040410712361335754, -0.010941282846033573, 0.09772828966379166, 0.031606968492269516, -0.04421265050768852, 0.05754404515028, -0.005716828163713217, -0.057022031396627426, -0.08950316905975342, 0.012181743048131466, -0.002995169721543789, -0.018090249970555305, 0.02188396453857422, -0.10070120543241501, -0.018514404073357582, 0.015765467658638954, -0.049701888114213943, 0.031048310920596123, 0.004214380867779255, -0.14415974915027618, 0.03971463441848755, 0.04327598959207535, -0.009684656746685505, -0.030596168711781502, -0.039323460310697556, -0.051657550036907196, 0.035121068358421326, 0.005175823345780373, -0.02380698174238205, -0.1919613480567932, 0.08671373873949051, -0.006460400763899088, -0.05392315611243248, -0.08843729645013809, 0.07449463754892349, 0.02924230694770813, -0.010676122270524502, 0.03829709067940712, -0.029692143201828003, -0.02013297751545906, -0.08251848071813583, 0.04806122928857803, 0.018462559208273888, 0.030808372423052788, 0.030495891347527504, -0.0009885816834867, 0.07107720524072647, 0.004615312907844782, 0.026422249153256416, -0.017441336065530777, 0.014387327246367931, -0.05241836607456207, -0.021663909777998924, 0.035143591463565826, 0.03140202909708023, -0.02782103791832924, -0.024879056960344315, 0.007429532706737518, -0.016029564663767815, -0.019920991733670235, 0.020258169621229172, 0.027774035930633545, -0.018614929169416428, -0.004417463205754757, 0.017847102135419846, -0.0026006039697676897, 0.03802055865526199, 0.04627818241715431, 0.05181766301393509, -0.0385827012360096, -0.0430181510746479, -0.04742972180247307, 0.08299965411424637, -0.018899869173765182, -0.1232834979891777, 0.027158433571457863, 0.0026388238184154034, 0.06757347285747528, -0.02491145394742489, 0.04980707913637161, -0.004377552308142185, 0.04436270147562027, -0.006324949208647013, -0.04241294413805008, -0.06199497729539871, 0.036484494805336, -0.07164466381072998, -0.028824983164668083, -0.016662441194057465, 0.013121607713401318, -0.06773713231086731, -0.04604198783636093, 0.009293626993894577, -0.005148071795701981, -0.04713080823421478, -0.047773636877536774, 0.09678030759096146, -0.012631799094378948, 0.05798863247036934, 0.0017675358103588223, 0.02476114220917225, -0.022831998765468597, 0.014310530386865139, 0.024411333724856377, 0.0979815423488617, 0.03393532708287239, 0.008317538537085056, 0.06682789325714111, 0.08032085001468658, -0.002738356590270996, 0.04118867591023445, 0.050481200218200684, -0.013219531625509262, 0.029461460188031197, -0.031986601650714874, 0.059198614209890366, 0.022431470453739166, -0.003854114096611738, 0.0016895224107429385, 0.02023255079984665, -0.03976544737815857, 0.024907341226935387, -0.01833988167345524, 0.02107064425945282, 0.03378555178642273, -0.000054554344387724996, -0.01770283281803131, 0.0426965206861496, 0.008251623250544071, -0.07276129722595215, 0.009372098371386528, -0.02442167140543461, -0.01117001287639141, -0.03526764363050461, 0.03902270644903183, 0.011677122674882412, -0.019365888088941574, -0.03520805761218071, 0.02661183848977089, -0.024802813306450844, -0.03309130668640137, -0.01850944012403488, -0.017279332503676414, -0.022055352106690407, 0.002075393218547106, -0.08031851798295975, -0.029757481068372726, 0.03000492975115776, 0.03047829121351242, 0.01459478959441185, -0.016872063279151917, 0.011764555238187313, -0.007060210220515728, -0.009125971235334873, -0.06956381350755692, 0.07221386581659317, 0.001957479165866971, 0.004906847607344389, 0.05551643297076225, 0.09347554296255112, 0.031626589596271515, -0.049071330577135086, 0.03554587811231613, -0.03397132828831673, 0.08674272894859314, -0.026924675330519676, 0.0574401319026947, 0.058346543461084366, -0.09675043821334839, -0.005970896687358618, 0.0833137035369873, -0.006421134807169437, -0.019583117216825485, -0.01955069787800312, -0.03675159811973572, 0.058538760989904404, -0.004518532659858465, 0.019641783088445663, -0.02581910789012909, -0.05772549286484718, 0.08371791243553162, 0.01872691512107849, 0.01586206816136837, 0.05107006058096886, 0.013482771813869476, 0.025600936263799667, -0.05797318369150162, -0.027281809598207474, 0.032902684062719345, -0.03157076984643936, -0.06286123394966125, -0.018380094319581985, 0.028421036899089813, 0.05129760876297951, -0.1505497694015503, 0.054790984839200974, -0.06786098331212997, -0.0034918244928121567, -0.05025918036699295, -0.014466187916696072, 0.02889348194003105, 0.012474866583943367, -0.000822358881123364, 0.182047501206398, -0.0092906029894948, 0.01014903374016285, 0.03224063292145729, -0.054011229425668716, 0.0635957270860672, 0.0954660177230835, 0.026066854596138, 0.051898326724767685, -0.0552385188639164, -0.03282061964273453, -0.0283419918268919, -0.033595792949199677, 0.03045780397951603, -0.012711780145764351, -0.022349489852786064, 0.07390329986810684, -0.0007786779897287488, 0.02480364963412285, 0.04122600704431534, -0.02226053923368454, -0.03950634226202965, 0.009102997370064259, 0.03783454746007919, 0.025950394570827484, -0.058177027851343155, 0.07991770654916763, -0.0021582820918411016, -0.05258424952626228, 0.027021095156669617, -0.02663973905146122, 0.004417728632688522, 0.003534878371283412, -0.016674388200044632, 0.028371185064315796, 0.06094144284725189, -0.004018351901322603, 0.005153346341103315, -0.027527710422873497, 0.08019059151411057, 0.021716998890042305, -0.02528066374361515, -0.044357966631650925, -0.049698542803525925, -0.03147835284471512, 0.001969180768355727, 0.022298527881503105, 0.016587257385253906, 0.01063055731356144, -0.021979836747050285, 0.025535836815834045, -0.020085249096155167, 0.015433781780302525, -0.006854400038719177, -0.013249045237898827, 0.015860002487897873, 0.028291992843151093, 0.009543988853693008, -0.006035082042217255, -0.021323706954717636, -0.020459646359086037, -0.015866434201598167, 0.058111708611249924, 0.031795110553503036, 0.03136472776532173, -0.013273182325065136, -0.0162326879799366, -0.024373386055231094, -0.032112281769514084, 0.00998300313949585, -0.019600633531808853, 0.016927562654018402, 0.023570047691464424, -0.004806051030755043, 0.001118263229727745, -0.012193519622087479, 0.03156689181923866, -0.014969231560826302, -0.020223289728164673, 0.030206022784113884, -0.0012553817359730601, 0.017946438863873482, -0.012166273780167103, -0.010688361711800098, -0.014759126119315624, 0.039814118295907974, -0.008312295190989971, -0.010070143267512321, -0.10685267299413681, -0.020991962403059006, -0.04445749521255493, -0.0011868347646668553, -0.0354866199195385, -0.02840573340654373, 0.032978177070617676, 0.009327791631221771, 0.032409071922302246, -0.004094705916941166, -0.014585400000214577, 0.013772227801382542, 0.0224887877702713, 0.0047998991794884205, -0.003516766708344221, 0.0028572161681950092, -0.013462125323712826, 0.022684888914227486, 0.04730066657066345, 0.023266566917300224, -0.03523750975728035, 0.021188754588365555, 0.03651897609233856, -0.02641981840133667, -0.012325453571975231, -0.06541284918785095, 0.03810664266347885, 0.015589931979775429, -0.008201472461223602, -0.052149295806884766, -0.008061498403549194, -0.022589290514588356, -0.07142716646194458, 0.02773340418934822, -0.024532973766326904, -0.012384473346173763, 0.004089888650923967, -0.006980105768889189, 0.012365195900201797, 0.012416405603289604, -0.007220759522169828, 0.028284283354878426, 0.04359917715191841, -0.00914272852241993, 0.007374448236078024, -0.042382773011922836, -0.03967546299099922, 0.0006612598081119359, 0.009265453554689884, -0.04974338412284851, -0.04885564744472504, -0.003629541490226984, -0.002495781285688281, 0.048187993466854095, 0.002107557374984026, 0.019575094804167747, 0.013713741675019264, 0.011097004637122154, -0.018630949780344963, -0.0051378109492361546, -0.07247084379196167, 0.03341583535075188, 0.0010309210047125816, -0.018237367272377014, -0.030838316306471825, 0.05073035508394241, -0.02984740026295185, 0.027815895155072212, -0.02418052963912487, 0.036717064678668976, -0.008193355053663254, 0.03127836436033249, 0.021113798022270203, 0.010632278397679329, 0.011317608878016472, 0.003972634207457304, -0.009466806426644325, -0.04453613609075546, 0.05336868017911911, 0.02965674363076687, -0.02423359639942646, -0.026171129196882248, -0.04208020493388176, 0.0172706451267004, 0.00482289819046855, -0.022216107696294785, 0.027147261425852776, -0.005571041721850634, 0.021044213324785233, 0.033792171627283096, -0.022610927000641823, -0.04595912620425224, 0.03583491966128349, -0.03476781025528908, 0.009176872670650482, -0.0044762440957129, 0.021153952926397324, 0.030244218185544014, 0.011637709103524685, -0.004248153883963823, 0.038615692406892776, -0.03049556165933609, -0.046441223472356796, 0.020477937534451485, -0.019732527434825897, 0.045468442142009735, -0.05476036295294762, -0.03627100586891174, -0.003646967699751258, -0.011882851831614971, -0.009557978250086308, -0.03318549320101738, 0.016510097309947014, -0.02255975268781185, 0.053207140415906906, 0.023135706782341003, -0.007598266936838627, -0.004450804553925991, -0.01911480352282524, 0.03549175709486008, -0.026482682675123215, 0.049527980387210846, -0.029350068420171738, -0.05141974613070488, 0.004197703208774328, 0.027692021802067757, 0.02713782712817192, -0.004007895011454821, 0.02083846926689148, -0.02078142762184143, -0.011010084301233292, 0.00776606984436512, 0.01726657524704933, -0.008126298896968365, 0.015515584498643875, 0.014833600260317326, -0.026491660624742508, 0.016888262704014778, 0.008482818491756916, -0.004566127434372902, -0.024185379967093468, -0.016907427459955215, 0.026024887338280678, -0.016275610774755478, 0.0399574413895607, 0.003514713142067194, -0.08266013860702515, 0.01072575431317091, -0.022648382931947708, 0.021605050191283226, 0.03280046209692955, 0.011425955221056938, -0.02070157788693905, 0.026325125247240067, 0.053082242608070374, -0.008392971009016037, 0.008615242317318916, 0.008187470026314259, -0.014712970703840256, 0.028354641050100327, -0.03223234415054321, -0.018482431769371033, 0.012847143225371838, 0.013387144543230534, -0.010043341666460037, -0.012095603160560131, 0.0239004697650671, -0.060255471616983414, -0.02648705057799816, -0.00013071000284980983, -0.0439605712890625, 0.014102084562182426, 0.01752454601228237, -0.0418899804353714, -0.008222438395023346, 0.0667375698685646, 0.04949649050831795, 0.004972419235855341, 0.0076307570561766624, 0.023234199732542038, -0.06444014608860016, 0.002225043484941125, 0.011494598351418972, 0.012103879824280739, 0.03562074899673462, 0.023777680471539497, 0.024926524609327316, 0.05669966712594032, 0.0018138443119823933, 0.0039833178743720055, 0.007239664904773235, -0.014927864074707031, 0.024280909448862076, 0.0006874874816276133, 0.003910600207746029, -0.01020642090588808, 0.008300538174808025, 0.010090918280184269, -0.0028991878498345613, -0.017784621566534042, 0.0038595604710280895, 0.0014436158817261457, -0.04619654268026352, 0.0013540673535317183, 0.02173512428998947, 0.010300629772245884, -0.0004786696226801723, -0.03199312463402748, 0.004928733222186565, -0.04855070635676384, -0.005860095378011465, -0.02215546928346157, -0.02224973775446415, 0.0010734432144090533, 0.029966630041599274, -0.019846124574542046, -0.02411315031349659, 0.011748778633773327, 0.015692075714468956, 0.03955201804637909, -0.034821487963199615, -0.014397965744137764, -0.037631310522556305, -0.022849811241030693, 0.007436898071318865, -0.06681760400533676, -0.0011154311941936612, 0.011714682914316654, -0.0032924828119575977, 0.035925086587667465, 0.026100413873791695, 0.008016642183065414, 0.03439898043870926, 0.02958020567893982, 0.020394066348671913, -0.0013647116720676422, -0.03786198049783707, 0.021387401968240738, 0.036593154072761536, 0.013931315392255783, 0.01845223642885685, -0.0032657431438565254, -0.03523119166493416, -0.005983895622193813, -0.02936703711748123, 0.05599676072597504, 0.07000663131475449, 0.011492875404655933, 0.03385259956121445, 0.00867047905921936, 0.022231489419937134, 0.012075680308043957, -0.016792528331279755, 0.020549729466438293, 0.039862342178821564, 0.015526051633059978, 0.019460702314972878, 0.003691651625558734, -0.0011802364606410265, 0.01642846316099167, 0.01296928245574236, -0.05256358161568642, 0.018931368365883827, 0.038573313504457474, -0.03281465545296669, 0.028139833360910416, 0.021055536344647408, -0.06088171526789665, -0.02070537582039833, -0.0015148353995755315, 0.0066683473996818066, 0.04130714014172554, -0.01632108725607395, 0.011752322316169739, -0.026628004387021065, -0.04031292349100113, 0.05067194253206253, 0.07274667918682098, -0.025551490485668182, 0.029929745942354202, 0.03138190135359764, 0.08949761092662811, 0.054838765412569046, -0.00017788699187804013, 0.016601072624325752, 0.026341089978814125, 0.06283155083656311, 0.012723074294626713, 0.07340900599956512, 0.013064437545835972, -0.029751628637313843, 0.015544269233942032, -0.0022456583101302385, 0.0037992498837411404, 0.007008382119238377, -0.021653639152646065, 0.043308764696121216, -0.005305957049131393, 0.0134840477257967, -0.04709731042385101, 0.006907208357006311, 0.00664797518402338, -0.0042463503777980804, -0.022879505529999733, 0.01156540960073471, 0.017708607017993927, 0.00485491706058383, 0.02026979625225067, 0.0333135649561882, 0.005057720933109522, -0.008846298791468143, 0.056434448808431625, 0.023507649078965187, 0.022821499034762383, -0.02313319407403469, 0.026621093973517418, 0.02359481155872345, -0.0494956411421299, -0.04225979372859001, 0.016942940652370453, -0.01307343877851963, 0.011398449540138245, -0.025907209143042564, 0.02005583606660366, -0.017483599483966827, -0.009714078158140182, -0.030680058524012566, 0.03153660520911217, -0.018263371661305428, 0.005498733837157488, 0.016995027661323547, 0.018190041184425354, 0.022286243736743927, -0.010376050136983395, 0.023056520149111748, 0.04553905501961708, 0.0425419919192791, -0.026847368106245995, -0.013953003101050854, -0.04532512277364731, -0.032640837132930756, 0.021835807710886, -0.003979852888733149, -0.003357844427227974, -0.02383619174361229, -0.014826083555817604, -0.0418151319026947, 0.04768286645412445, 0.016144027933478355, 0.01696210727095604, -0.002386461477726698, 0.02015363797545433, -0.0328633114695549, 0.0058534471318125725, -0.0011443141847848892, 0.0021102610044181347, 0.007680349983274937, -0.047314051538705826, 0.00001400300970999524, -0.03445382043719292, 0.027118152007460594, 0.04905470088124275, -0.0012028439668938518, -0.031789399683475494, -0.043628863990306854, 0.001159417792223394, -0.036784663796424866, -0.05152072384953499, 0.07765056937932968, -0.031117094680666924, 0.012987146154046059, 0.028355473652482033, -0.013311699032783508, -0.024531394243240356, -0.019450897350907326, 0.010156179778277874, 0.06851766258478165, -0.012472975999116898, -0.03083164058625698, 0.014238985255360603, 0.04782063513994217, 0.030443204566836357, 0.0438113659620285, 0.004807719495147467, 0.012218926101922989, 0.01765843853354454, -0.031652797013521194, 0.01451442576944828, -0.033416979014873505, -0.01861676201224327, -0.039272140711545944, -0.027317211031913757, -0.023930000141263008, -0.015691187232732773, -0.00920806173235178, -0.023069242015480995, -0.03823409229516983, 0.004939052276313305, 0.014924734830856323, -0.02616138942539692, -0.03305894508957863, -0.0025269556790590286, 0.016478752717375755, 0.038617365062236786, 0.01281016692519188, 0.02683674544095993, -0.0036154191475361586, 0.020079923793673515, -0.02719675377011299, 0.019239287823438644, 0.0405866913497448, -0.004830791614949703, -0.027379119768738747, -0.056062158197164536, -0.017570775002241135, 0.050103116780519485, -0.07161495834589005, 0.05173460766673088, -0.0010383453918620944, 0.01467333734035492, -0.0718856230378151, 0.00815571565181017, 0.046200357377529144, -0.011319552548229694, 0.030809668824076653, -0.036540113389492035, -0.03657491132616997, 0.021452413871884346, 0.018831603229045868, -0.040509216487407684, -0.018850097432732582, -0.048294615000486374, 0.002776207635179162, 0.033616844564676285, -0.009700513444840908, 0.015198064036667347, -0.01960364542901516, 0.02050534076988697, 0.0024006615858525038, -0.004363702144473791, -0.022457143291831017, -0.039850227534770966, -0.0074498457834124565, 0.053378812968730927, -0.041590139269828796, 0.021330950781702995, 0.015135587193071842, 0.0005230758106335998, -0.02684726193547249, 0.021475626155734062, 0.00441080192103982, 0.016215045005083084, -0.025000855326652527, 0.030422508716583252, -0.0012111917603760958, 0.07505322247743607, 0.005682262592017651, -0.011427721008658409, -0.030916210263967514, -0.02330763265490532 ]
Supercharged Searching on the Hugging Face Hub
muellerzr
January 25, 2022
searching-the-hub
guide
https://huggingface.co/blog/searching-the-hub
Taking it up a Notch We saw how we could use the ModelSearchArguments and DatasetSearchArguments to remove the guesswork from when we want to search the Hub, but what about if we have a very complex, messy query? Such as: I want to search for all models trained for both text-classification and zero-shot classification, were trained on the Multi NLI and GLUE datasets, and are compatible with both PyTorch and TensorFlow (a more exact query to get the above model). To setup this query, we'll make use of the ModelFilter class. It's designed to handle these types of situations, so we don't need to scratch our heads: python >>> filt = ModelFilter( >>> task = ["text-classification", "zero-shot-classification"], >>> trained_dataset = [model_args.dataset.multi_nli, model_args.dataset.glue], >>> library = ['pytorch', 'tensorflow'] >>> ) >>> api.list_models(filt) [ModelInfo: { modelId: Jiva/xlm-roberta-large-it-mnli sha: c6e64469ec4aa17fedbd1b2522256f90a90b5b86 lastModified: 2021-12-10T14:56:38.000Z tags: ['pytorch', 'xlm-roberta', 'text-classification', 'it', 'dataset:multi_nli', 'dataset:glue', 'arxiv:1911.02116', 'transformers', 'tensorflow', 'license:mit', 'zero-shot-classification'] pipeline_tag: zero-shot-classification siblings: [ModelFile(rfilename='.gitattributes'), ModelFile(rfilename='README.md'), ModelFile(rfilename='config.json'), ModelFile(rfilename='pytorch_model.bin'), ModelFile(rfilename='sentencepiece.bpe.model'), ModelFile(rfilename='special_tokens_map.json'), ModelFile(rfilename='tokenizer.json'), ModelFile(rfilename='tokenizer_config.json')] config: None private: False downloads: 680 library_name: transformers likes: 1 }] Very quickly we see that it's a much more coordinated approach for searching through the API, with no added headache for you!
[ -0.05934677645564079, -0.026815881952643394, 0.0025306681636720896, 0.09020669758319855, -0.004240559879690409, 0.029677188023924828, -0.022260703146457672, 0.018209245055913925, -0.04604453220963478, 0.01845218986272812, -0.0682273805141449, 0.03258800506591797, -0.03522084280848503, 0.06451406329870224, 0.029349394142627716, -0.014543513767421246, 0.0711994543671608, 0.016694718971848488, 0.0037897243164479733, 0.10017118602991104, 0.07169115543365479, -0.03516222536563873, 0.04974570497870445, 0.016106046736240387, -0.045447081327438354, -0.1056060940027237, 0.012789329513907433, 0.017549103125929832, -0.05384080111980438, 0.06757460534572601, -0.08548395335674286, 0.014273536391556263, -0.04047464579343796, -0.03330644592642784, -0.019666187465190887, 0.030855193734169006, -0.08345496654510498, 0.013484425842761993, 0.04233492910861969, 0.002267280360683799, -0.044591475278139114, -0.044396597892045975, -0.011953245848417282, 0.03352414071559906, 0.011437129229307175, 0.01269775815308094, -0.12132050096988678, 0.06320499628782272, -0.012538418173789978, -0.00977617222815752, -0.0295159462839365, 0.046287186443805695, 0.019660841673612595, 0.0070819612592458725, 0.004816627129912376, -0.06114667281508446, -0.012449882924556732, -0.10439370572566986, 0.05642807111144066, 0.037541378289461136, -0.015409013256430626, 0.03485170751810074, -0.02037900686264038, 0.06606719642877579, 0.007013386581093073, 0.0006267858552746475, -0.00684839952737093, 0.017510492354631424, -0.08541881293058395, -0.0049822404980659485, 0.050830502063035965, 0.013101090677082539, -0.0006439838907681406, -0.04287594184279442, -0.01151131559163332, -0.0518043152987957, -0.0551157221198082, 0.013271232135593891, 0.015049478970468044, 0.019123999401926994, -0.05198569595813751, 0.04684903472661972, 0.035535890609025955, 0.015001027844846249, 0.04749990254640579, 0.023147478699684143, 0.0037038156297057867, 0.00180053838994354, -0.012437678873538971, 0.04604742303490639, 0.011210660450160503, -0.11614412814378738, 0.018408089876174927, -0.02179814502596855, 0.03058563731610775, -0.05883324518799782, 0.04628130421042442, 0.030540399253368378, -0.003109102137386799, 0.01838911697268486, 0.007763095665723085, -0.09231100231409073, -0.0008708041859790683, -0.0067383162677288055, -0.054157450795173645, -0.018171822652220726, -0.010620055720210075, -0.06186182051897049, -0.08209307491779327, 0.032622113823890686, -0.008431240916252136, 0.006757148541510105, -0.09324381500482559, 0.08450783044099808, -0.0011816525366157293, -0.034984901547431946, -0.022592369467020035, 0.032446347177028656, -0.039422906935214996, 0.025080041959881783, 0.002785567194223404, 0.11808796972036362, 0.04087114706635475, 0.04303891956806183, 0.06596612185239792, 0.050549574196338654, -0.008967559784650803, 0.042896728962659836, 0.03652266040444374, -0.007771557196974754, 0.01640511304140091, 0.04434363543987274, 0.02952737919986248, 0.05344458296895027, -0.009530567564070225, -0.018736422061920166, 0.022061172872781754, -0.05342628434300423, -0.020538846030831337, 0.01879548840224743, -0.023682646453380585, 0.04523000866174698, -0.0486835353076458, -0.043161291629076004, 0.033358097076416016, -0.005079982802271843, -0.01405434962362051, 0.012760838493704796, 0.038755692541599274, -0.00018004808225668967, -0.05734667927026749, 0.06948306411504745, 0.0410742461681366, -0.09903872758150101, -0.03284308314323425, 0.04111718386411667, 0.006250360514968634, 0.00031797075644135475, 0.0181647427380085, 0.021962421014904976, 0.021899905055761337, 0.05527327209711075, -0.03494291752576828, 0.021276770159602165, -0.023465793579816818, -0.030495312064886093, 0.062229547649621964, -0.04553184658288956, -0.018373776227235794, 0.021311702206730843, -0.03960030525922775, -0.02328965812921524, 0.11004156619310379, -0.04414121061563492, 0.033395152539014816, 0.01249645370990038, 0.04720998555421829, 0.02316499687731266, -0.029382141306996346, 0.008822082541882992, -0.008111776784062386, 0.03232717886567116, -0.07945644110441208, 0.050399940460920334, 0.046995218843221664, -0.030617430806159973, 0.005769031587988138, 0.003760449355468154, -0.02123844064772129, 0.05024366453289986, -0.05955048277974129, 0.0037810937501490116, 0.14996588230133057, -0.009258373640477657, -0.010795516893267632, -0.012898938730359077, -0.00870268139988184, 0.08564673364162445, 0.051614925265312195, -0.03155973181128502, 0.027194369584321976, -0.012355603277683258, -0.016576040536165237, -0.08963834494352341, 0.002063147258013487, 0.0328209213912487, -0.06795188039541245, -0.07308005541563034, -0.04483345150947571, 0.02577061951160431, 0.06925460696220398, -0.12837262451648712, 0.018944967538118362, -0.06610104441642761, 0.01612892374396324, 0.028276054188609123, -0.03967884182929993, 0.016293201595544815, 0.02721249870955944, -0.03802506998181343, 0.20087897777557373, -0.0002690673863980919, -0.030054351314902306, -0.003833085997030139, -0.026240553706884384, 0.025601444765925407, 0.030081309378147125, 0.032375652343034744, -0.003693314967676997, -0.07759232819080353, 0.009001429192721844, -0.042270760983228683, 0.005158324260264635, 0.04991684854030609, -0.02801184542477131, -0.009964672848582268, 0.04161322861909866, 0.006429693195968866, 0.02302648313343525, -0.007217088248580694, -0.0005045103607699275, -0.0012486036866903305, -0.04379754886031151, 0.05463755130767822, 0.012421139515936375, -0.05271587893366814, 0.09432464092969894, -0.02924923039972782, -0.006582923233509064, -0.016276400536298752, -0.005606768652796745, 0.03159969300031662, -0.00947133731096983, -0.04952758178114891, 0.03037186525762081, 0.033916786313056946, -0.0032651491928845644, -0.014246209524571896, -0.0030321048106998205, 0.04673721268773079, 0.030359037220478058, -0.003644871059805155, -0.057381752878427505, -0.056190043687820435, 0.028533151373267174, -0.007788927759975195, 0.05635259672999382, 0.00418156897649169, 0.05752945318818092, -0.030870258808135986, 0.0015544083435088396, -0.023427912965416908, 0.048703283071517944, 0.000144616438774392, -0.01487176213413477, 0.03652527183294296, -0.018918702378869057, 0.015952521935105324, -0.027742953971028328, -0.035332366824150085, 0.004202369134873152, -0.01638559065759182, 0.05062912032008171, 0.027765586972236633, 0.0009723552502691746, -0.003096882486715913, -0.010581172071397305, -0.011460315436124802, -0.015503006055951118, -0.0005989816272631288, 0.004623004700988531, 0.02629239670932293, 0.03700566664338112, -0.03384057804942131, -0.04452945664525032, 0.026249755173921585, -0.006642586551606655, -0.03432774543762207, 0.00015450427599716932, -0.000180005983565934, -0.042226385325193405, 0.020825276151299477, 0.017420850694179535, -0.007442525587975979, -0.009707543067634106, 0.053667426109313965, 0.017422037199139595, -0.0025574287865310907, -0.08276905864477158, -0.019429434090852737, -0.021892108023166656, -0.021577531471848488, -0.035534970462322235, -0.016914324834942818, 0.0367082841694355, 0.006474116817116737, -0.02803175523877144, -0.04938162863254547, -0.011409563943743706, 0.037114642560482025, 0.02840672805905342, 0.008731101639568806, -0.01596151292324066, 0.032710373401641846, -0.03410912677645683, 0.011165947653353214, 0.026621514931321144, 0.014298917725682259, -0.011721844784915447, 0.02268415503203869, 0.029828399419784546, -0.016172567382454872, -0.03480091318488121, 0.015208292752504349, 0.0018148983363062143, -0.012720799073576927, -0.006013182457536459, -0.05600796267390251, -0.012507340870797634, -0.050172481685876846, -0.0944550633430481, -0.000585574540309608, -0.02483547292649746, -0.019392864778637886, 0.022255398333072662, 0.008838248439133167, 0.023697422817349434, 0.014735684730112553, -0.008165981620550156, 0.014914431609213352, 0.012799552641808987, 0.015498270280659199, -0.016675777733325958, -0.045376673340797424, -0.03669995442032814, -0.02241452783346176, 0.02387167140841484, -0.079151950776577, -0.08711352199316025, -0.009618561714887619, -0.023038405925035477, 0.04257907718420029, 0.012414366938173771, -0.020273061469197273, -0.0037853452377021313, 0.002649220172315836, -0.005065396893769503, -0.02054879441857338, -0.037921275943517685, 0.036392565816640854, -0.007208808325231075, -0.013546768575906754, -0.009525616653263569, 0.021460026502609253, 0.020456556230783463, 0.02173956111073494, -0.03571229428052902, 0.02322346717119217, -0.003940479829907417, 0.04765571281313896, 0.0029302765615284443, -0.0011250241659581661, -0.009770589880645275, 0.002885333728045225, 0.008098047226667404, -0.048475876450538635, 0.05173192545771599, -0.0061071948148310184, -0.06780339777469635, -0.046122368425130844, -0.02698637917637825, -0.012704034335911274, -0.007346792612224817, 0.0018659891793504357, 0.0014277967857196927, -0.02483171783387661, 0.011568230576813221, -0.008314375765621662, -0.04061485454440117, -0.04870018735527992, 0.05029900372028351, -0.02773251198232174, -0.026643097400665283, -0.0037173584569245577, 0.018565112724900246, 0.045162998139858246, -0.009052903391420841, -0.022757478058338165, -0.024914871901273727, -0.04024697095155716, -0.0579708106815815, 0.0017910810420289636, -0.003401170251891017, 0.030629407614469528, -0.02510426752269268, 0.013857551850378513, -0.024508116766810417, -0.029777739197015762, -0.01067540142685175, -0.02061290107667446, -0.013722000643610954, 0.006093892268836498, 0.049284618347883224, 0.005835102405399084, 0.007579387631267309, -0.015740972012281418, -0.011499269865453243, -0.008589533157646656, -0.027279091998934746, 0.02079879865050316, 0.008386773988604546, -0.05166944861412048, 0.014531021006405354, -0.007097864989191294, 0.03928014636039734, 0.001659736386500299, 0.06287248432636261, -0.021918373182415962, -0.015028868801891804, -0.021161988377571106, 0.04602409899234772, -0.020723285153508186, 0.015627672895789146, 0.010299380868673325, -0.006091435439884663, 0.013210691511631012, -0.021514110267162323, -0.017834164202213287, -0.04367700591683388, 0.004472259897738695, -0.02589728683233261, -0.010370604693889618, 0.028383970260620117, 0.01699608378112316, -0.02180127054452896, 0.0012417241232469678, -0.03978246822953224, 0.024905191734433174, 0.041418079286813736, 0.047258976846933365, 0.0030652435962110758, 0.0035893996246159077, 0.04164385423064232, 0.005832283291965723, 0.01743975654244423, -0.0381111204624176, 0.0072297267615795135, 0.04839733988046646, -0.022221393883228302, -0.03992657735943794, 0.01503046415746212, 0.020261434838175774, 0.017558598890900612, 0.04697846621274948, -0.0013261559652164578, -0.02987273409962654, -0.032421376556158066, 0.010796803049743176, -0.031164824962615967, 0.013361942023038864, 0.06017308682203293, -0.03620435670018196, 0.008146925829350948, 0.05217298865318298, 0.033411093056201935, -0.00044178595999255776, -0.0026298623997718096, 0.03698078170418739, -0.05033852159976959, -0.02827710472047329, 0.08181540668010712, 0.04809347912669182, 0.0007553647155873477, 0.007626958191394806, 0.015447852201759815, 0.05690382793545723, 0.01979517564177513, 0.00021241893409751356, -0.004317658953368664, -0.009123820811510086, -0.008976349607110023, -0.005310629960149527, 0.030065791681408882, -0.027521157637238503, 0.018373843282461166, -0.01219607051461935, -0.0468122772872448, 0.005708728916943073, 0.028622817248106003, 0.006879928056150675, -0.009924480691552162, 0.015197531320154667, 0.028934815898537636, -0.016384683549404144, 0.013591436669230461, 0.0033099818974733353, -0.003386593423783779, -0.031004181131720543, -0.0032302706968039274, -0.020666930824518204, -0.009809873066842556, 0.04805140942335129, 0.029033809900283813, 0.0011236495338380337, 0.020411694422364235, -0.003446282120421529, 0.01655859313905239, 0.046225205063819885, -0.017765922471880913, -0.03814961016178131, -0.006920678075402975, 0.02239445224404335, 0.010942568071186543, -0.05400417000055313, 0.0003567636013031006, 0.019202541559934616, 0.012376129627227783, 0.048548489809036255, 0.008663916029036045, 0.01863890141248703, -0.014199070632457733, 0.012022752314805984, -0.005683153867721558, 0.00740075996145606, -0.022223392501473427, 0.015115227550268173, 0.08570700138807297, -0.0637601763010025, 0.000022383064788300544, -0.014452316798269749, -0.023710688576102257, 0.002181339543312788, -0.03745211288332939, 0.05440015345811844, 0.03645702823996544, 0.02865750528872013, 0.037842828780412674, 0.03125203773379326, 0.05303323268890381, 0.03034910559654236, -0.035961125046014786, 0.027363380417227745, 0.024340473115444183, 0.02714064158499241, 0.07068359851837158, -0.01741885393857956, 0.01290078740566969, 0.0219864621758461, -0.03776788339018822, -0.015092756599187851, -0.0022501132916659117, 0.04825126379728317, -0.052427709102630615, 0.045015592128038406, 0.003163515357300639, -0.08608311414718628, -0.04053612798452377, -0.023661822080612183, 0.04419947788119316, 0.021438293159008026, -0.00985284149646759, 0.02150614932179451, 0.02237054519355297, 0.00699838250875473, 0.02337769791483879, 0.0536818727850914, -0.02197820506989956, 0.0277529489248991, 0.028693629428744316, 0.08165377378463745, 0.005136259365826845, -0.016875609755516052, 0.021594271063804626, 0.018702728673815727, 0.05838577449321747, 0.047762431204319, 0.008671618066728115, -0.022497259080410004, 0.0045517138205468655, 0.0424119271337986, -0.05347386375069618, -0.012292555533349514, 0.022460849955677986, 0.017562901601195335, 0.045807354152202606, -0.008680595085024834, 0.022915057837963104, -0.04000704362988472, 0.0017181298462674022, -0.016715269535779953, -0.013090449385344982, 0.008546258322894573, 0.016943329945206642, 0.004963976331055164, 0.00021095680131111294, 0.019055642187595367, 0.035579897463321686, -0.016362544149160385, 0.003265272593125701, 0.03195757046341896, 0.017772193998098373, 0.007728842552751303, 0.03380648046731949, 0.01474770624190569, 0.048237722367048264, -0.04624013230204582, -0.02887183241546154, 0.06614348292350769, 0.027957255020737648, 0.018100732937455177, -0.03055471181869507, 0.04271091893315315, -0.04690307006239891, 0.005718872882425785, -0.06124819815158844, -0.0027033216319978237, -0.03314729034900665, 0.011442869901657104, -0.01823086105287075, -0.011402847245335579, 0.009738558903336525, -0.03432689234614372, 0.01705280877649784, 0.015469824895262718, 0.053916189819574356, 0.030075538903474808, -0.009231585077941418, -0.007397924549877644, -0.03660229593515396, -0.010167465545237064, 0.008152629248797894, -0.02517561987042427, -0.047915246337652206, -0.03825289383530617, -0.028551125898957253, -0.004579547327011824, -0.015197718515992165, 0.032089050859212875, -0.019683994352817535, 0.021286677569150925, 0.015219168737530708, -0.006960665341466665, -0.012516719289124012, -0.05076556280255318, 0.058823563158512115, -0.02257290482521057, -0.011767851188778877, -0.011384591460227966, 0.014688712544739246, 0.03026680275797844, 0.009782934561371803, 0.00581010477617383, -0.019630178809165955, -0.021677974611520767, -0.017322244122624397, 0.006412777118384838, 0.05486903339624405, -0.01193434651941061, 0.022498242557048798, 0.014305523596704006, -0.017296241596341133, -0.02300368994474411, -0.014261595904827118, -0.05345674231648445, 0.07016483694314957, 0.01320053730159998, -0.01980067417025566, -0.0007912446744740009, 0.012483693659305573, 0.05319206789135933, 0.0349683053791523, 0.002242137910798192, -0.005662697833031416, -0.0007986858836375177, -0.0071764071471989155, -0.0168044101446867, -0.0019884156063199043, -0.05789593234658241, -0.02201620675623417, -0.0395059734582901, -0.01866142451763153, 0.05329086259007454, -0.0011565415188670158, -0.021640930324792862, -0.052462171763181686, -0.016491880640387535, -0.005670350976288319, 0.00022835447452962399, -0.07032158225774765, 0.01490988489240408, 0.009812850505113602, 0.04951316490769386, -0.02794206701219082, 0.0057121384888887405, -0.003404488554224372, 0.01088805589824915, -0.049438267946243286, 0.02090298756957054, 0.04627864062786102, -0.0200244951993227, -0.020548135042190552, -0.008181842975318432, 0.027941901236772537, -0.016734080389142036, -0.009226156398653984, 0.0017495584907010198, 0.04714208096265793, -0.013318516314029694, -0.03248698264360428, 0.019786609336733818, 0.03681628406047821, 0.011134895496070385, 0.0382232666015625, -0.007911264896392822, -0.00785263441503048, 0.005627846345305443, -0.005048415157943964, -0.059567298740148544, -0.022211113944649696, -0.012062144465744495, 0.02005607821047306, -0.003027196042239666, -0.02211783081293106, 0.034162163734436035, -0.01601734198629856, 0.012681101448833942, -0.007580444682389498, -0.035854991525411606, -0.006226343102753162, -0.04358160123229027, -0.0322754830121994, 0.05836343765258789, -0.0401550717651844, 0.03690556064248085, 0.03673700615763664, 0.025593336671590805, -0.004231118597090244, 0.02249416522681713, -0.0068083093501627445, 0.042839474976062775, 0.02674837037920952, -0.006638916675001383, -0.011577721685171127, 0.011151098646223545, 0.05710376426577568, 0.014596466906368732, -0.004977510776370764, -0.03502999618649483 ]
Supercharged Searching on the Hugging Face Hub
muellerzr
January 25, 2022
searching-the-hub
guide
https://huggingface.co/blog/searching-the-hub
Situating the Problem: First, let's imagine the scenario you are in. You'd like to find all models hosted on the Hugging Face Hub for Text Classification, were trained on the GLUE dataset, and are compatible with PyTorch. You may simply just open https://huggingface.co/models and use the widgets on there. But this requires leaving your IDE and scanning those results, all of which requires a few button clicks to get you the information you need. What if there were a solution to this without having to leave your IDE? With a programmatic interface, it also could be easy to see this being integrated into workflows for exploring the Hub. This is where the huggingface_hub comes in. For those familiar with the library, you may already know that we can search for these type of models. However, getting the query right is a painful process of trial and error. Could we simplify that? Let's find out!
[ 0.02270466648042202, -0.015082865953445435, 0.004923270549625158, 0.010681207291781902, 0.014854633249342442, 0.04792504757642746, 0.01654869318008423, 0.06090672314167023, -0.05002645403146744, -0.010814618319272995, -0.07660084217786789, 0.0616263709962368, -0.0032133073545992374, 0.07958853989839554, 0.05411436781287193, -0.058204058557748795, 0.0621287077665329, -0.023835038766264915, -0.0005800783983431756, 0.04980262741446495, 0.021786481142044067, -0.05420925095677376, 0.025640079751610756, 0.011087890714406967, -0.10222893953323364, -0.0815461277961731, 0.03544129058718681, -0.025139061734080315, 0.006582216825336218, 0.020224332809448242, -0.08262743800878525, 0.03134414926171303, -0.004935253877192736, -0.05338776111602783, -0.0015810277545824647, 0.06551703065633774, -0.10951487720012665, 0.04908810183405876, 0.05108775198459625, -0.016805374994874, -0.03876599669456482, -0.03579767420887947, -0.05293701961636543, 0.05057057738304138, 0.009064510464668274, 0.014554292894899845, -0.1935112178325653, 0.08941053599119186, 0.008478269912302494, -0.008362133987247944, -0.10233807563781738, 0.07371050119400024, -0.01316442433744669, 0.0435112863779068, 0.003265179693698883, -0.015647931024432182, -0.010703468695282936, -0.09434143453836441, 0.031538378447294235, 0.011337370611727238, -0.0010954808676615357, 0.0510912649333477, 0.019939713180065155, 0.06976645439863205, 0.013864277862012386, 0.04258650913834572, -0.023798340931534767, -0.02530909888446331, -0.05704425275325775, 0.02599666826426983, 0.03526430204510689, 0.01613585278391838, -0.03260418027639389, -0.035937439650297165, -0.0011298460885882378, -0.021996842697262764, -0.040606170892715454, 0.04295887053012848, 0.026504725217819214, -0.03469408303499222, 0.0017967462772503495, -0.003752889111638069, 0.02232966385781765, 0.03941577672958374, 0.08790659159421921, 0.01198331918567419, -0.059198327362537384, -0.07819502055644989, -0.06026525795459747, 0.05866493284702301, 0.01682279258966446, -0.09275925159454346, -0.020250463858246803, 0.010509257204830647, 0.06461326032876968, -0.021012675017118454, 0.017979640513658524, 0.03942934796214104, -0.021625658497214317, 0.006057315040379763, 0.007647941820323467, -0.05999438092112541, -0.01259640883654356, -0.05549347400665283, -0.03889431804418564, -0.03528458625078201, -0.0015116240829229355, -0.09497483819723129, -0.03654095530509949, 0.028985103592276573, -0.011245711706578732, -0.03202885016798973, -0.03912920132279396, 0.08404850959777832, -0.0404416099190712, 0.023330872878432274, 0.0057009425945580006, 0.03623698651790619, -0.017984876409173012, 0.0041276547126472, -0.0077331713400781155, 0.11987181752920151, -0.013596365228295326, 0.017621520906686783, 0.0646112710237503, 0.07392960041761398, 0.003779612947255373, 0.0015091814566403627, 0.02879844419658184, -0.035193972289562225, 0.008010906167328358, 0.028030984103679657, 0.05683230608701706, -0.012299860827624798, 0.006856721360236406, 0.018402855843305588, -0.015535082668066025, -0.04472126066684723, -0.014623328112065792, 0.029224274680018425, 0.019480550661683083, 0.08055921643972397, -0.019927706569433212, 0.017405139282345772, 0.03726959973573685, 0.015174240805208683, -0.06217844784259796, 0.037658438086509705, -0.03167611360549927, 0.02331649512052536, -0.10702454298734665, 0.03813369944691658, 0.016956640407443047, -0.030621053650975227, -0.07446166127920151, 0.06568337976932526, 0.003684571711346507, -0.018983891233801842, -0.026898056268692017, -0.034790605306625366, -0.0210811085999012, 0.0005581267760135233, -0.0921657532453537, -0.010076558217406273, -0.0325920470058918, 0.005152694880962372, 0.017615417018532753, -0.03980812430381775, 0.027092289179563522, -0.01853562705218792, 0.027470367029309273, -0.047787394374608994, 0.041200678795576096, -0.04836929216980934, 0.022180398926138878, -0.010010028257966042, 0.05535482242703438, 0.025554373860359192, -0.021843258291482925, 0.02697274275124073, -0.0398612804710865, 0.027917051687836647, -0.036607563495635986, 0.03514215722680092, 0.05059163644909859, -0.052528295665979385, 0.002931426279246807, 0.047833219170570374, 0.006419256329536438, 0.009240478277206421, -0.015000095590949059, -0.042298976331949234, 0.0906406119465828, -0.018274979665875435, 0.02771941013634205, -0.007459546905010939, -0.05399464815855026, 0.12532322108745575, 0.020106201991438866, 0.017767474055290222, 0.06879157572984695, -0.005581704434007406, -0.004396009724587202, -0.07620544731616974, -0.004240898415446281, 0.003661331022158265, -0.015473934821784496, -0.04919416829943657, -0.02815227024257183, 0.0066275326535105705, 0.014950270764529705, -0.12488146871328354, 0.08691459149122238, -0.06519441306591034, 0.01902269385755062, 0.006709403358399868, -0.056844230741262436, 0.046574100852012634, 0.030775507912039757, -0.0007111248560249805, 0.21238569915294647, -0.04578128457069397, -0.00316794216632843, -0.016304168850183487, -0.05374966561794281, 0.03633688762784004, 0.04780391976237297, 0.06610248982906342, 0.06172497197985649, -0.08222370594739914, -0.028980018571019173, -0.05478280037641525, -0.0016846677754074335, -0.015153753571212292, -0.03369088098406792, -0.0570683553814888, 0.041996169835329056, -0.016062293201684952, 0.020643746480345726, 0.048254746943712234, -0.002061807084828615, -0.0329572856426239, 0.02883056178689003, 0.044715847820043564, 0.03778654336929321, -0.052510108798742294, 0.044516146183013916, 0.023074178025126457, -0.03860069438815117, -0.0020468044094741344, -0.06237783282995224, 0.01947997882962227, 0.002428865060210228, -0.02352023497223854, 0.01615697331726551, 0.014120257459580898, 0.004971069749444723, -0.018384624272584915, -0.00052555714501068, 0.08546168357133865, 0.01593708246946335, -0.035922929644584656, -0.046021830290555954, -0.05563657358288765, -0.015577591024339199, -0.02360241301357746, -0.009105471894145012, 0.03284604474902153, 0.031509239226579666, -0.0025391951203346252, 0.013894456438720226, -0.008430832996964455, 0.044591695070266724, 0.0004038247570861131, -0.0018278578063473105, 0.056410353630781174, -0.0010966160334646702, 0.00796517264097929, -0.03004063293337822, -0.01728122867643833, -0.014646168798208237, -0.07833395153284073, 0.039132580161094666, 0.02327868901193142, 0.02439284510910511, 0.007250943686813116, 0.009161301888525486, -0.023261841386556625, -0.039373185485601425, 0.038822975009679794, 0.014120451174676418, 0.036816999316215515, 0.032620690762996674, -0.006731031928211451, -0.004306335002183914, -0.015734737738966942, 0.042254094034433365, 0.003602969227358699, -0.04212251678109169, 0.01467850897461176, -0.03169602155685425, 0.015873929485678673, 0.010112565942108631, -0.029058121144771576, -0.018616093322634697, 0.035844992846250534, 0.029110558331012726, -0.025130800902843475, -0.09301164746284485, -0.0025094542652368546, -0.046521008014678955, 0.00998000893741846, -0.01386782806366682, -0.02290397696197033, 0.029088998213410378, 0.013121049851179123, 0.019771428778767586, 0.0013515765313059092, 0.001319303410127759, 0.01515102107077837, 0.022990955039858818, 0.01169696543365717, -0.032072700560092926, 0.011119608767330647, -0.007571863941848278, 0.029770195484161377, 0.05717572197318077, 0.049521613866090775, -0.0364588238298893, 0.023318996652960777, -0.0028215134516358376, -0.0049314978532493114, -0.015918994322419167, -0.051815010607242584, 0.0060391719453036785, 0.002745747333392501, 0.02834935672581196, -0.06387821584939957, 0.036266475915908813, -0.04293704777956009, -0.05737827718257904, 0.015175742097198963, -0.04039125144481659, -0.02254495769739151, 0.03640669211745262, 0.005111359525471926, 0.013339360244572163, 0.004455630201846361, -0.011725432239472866, 0.02660965733230114, 0.02924918197095394, -0.02610681764781475, -0.01508483849465847, -0.02060074359178543, -0.05146218463778496, 0.028450315818190575, 0.006415387615561485, -0.037642769515514374, -0.041151851415634155, 0.005183756351470947, 0.021863708272576332, 0.05813831835985184, 0.0033862462732940912, 0.020377706736326218, 0.007895467802882195, 0.015463678166270256, 0.00200526206754148, 0.0017278577433899045, -0.0712648555636406, 0.0034369495697319508, -0.015856381505727768, -0.05599138140678406, -0.054067082703113556, 0.02018936537206173, -0.006383745931088924, 0.019547445699572563, -0.030030304566025734, 0.0232907235622406, 0.007497870828956366, 0.03871292993426323, -0.012363677844405174, 0.002834412967786193, 0.014357809908688068, 0.011260203085839748, -0.015654632821679115, -0.06442289799451828, 0.08207753300666809, 0.025540927425026894, -0.021229609847068787, -0.01352895237505436, -0.015480626374483109, 0.0021486994810402393, 0.01406609732657671, 0.0062041194178164005, 0.015369442291557789, -0.0054426053538918495, 0.0057797739282250404, 0.02365877851843834, -0.011068399995565414, -0.03674498572945595, 0.036739446222782135, 0.008138551376760006, -0.008678247220814228, 0.007869062013924122, 0.021111533045768738, 0.04414569213986397, 0.013336137868463993, -0.015456936322152615, -0.013699028640985489, -0.029961321502923965, -0.03961864486336708, 0.01317688636481762, -0.009225020185112953, 0.029037244617938995, -0.0191575288772583, -0.006258662324398756, 0.015113268978893757, -0.05587213858962059, -0.023162368685007095, -0.008648463524878025, -0.021885303780436516, -0.01999638043344021, 0.04477297142148018, 0.031359829008579254, 0.004479205701500177, 0.0071210297755897045, -0.07866145670413971, 0.007794858422130346, -0.038013357669115067, 0.04860082268714905, -0.02860376238822937, -0.023221489042043686, -0.004310577176511288, 0.0021396365482360125, 0.03717508912086487, 0.006700994912534952, 0.02522481605410576, -0.016135990619659424, -0.013202519156038761, -0.013780579902231693, 0.015639150515198708, -0.011236360296607018, 0.036583539098501205, 0.010233189910650253, 0.01353980228304863, 0.00502512464299798, 0.004465503618121147, -0.009016252122819424, -0.029982777312397957, -0.0014400735963135958, 0.013004262000322342, -0.016826145350933075, 0.004930610302835703, 0.0064904335886240005, -0.05632564797997475, 0.018480511382222176, -0.02334008179605007, 0.015722785145044327, 0.01356309000402689, 0.005641533527523279, -0.0347454659640789, 0.05931200087070465, 0.07480869442224503, -0.014017495326697826, -0.0006947165238671005, 0.0031386855989694595, -0.005381723865866661, 0.031944405287504196, -0.010620241984724998, -0.006098981946706772, 0.013771658763289452, 0.04018331691622734, 0.0251941978931427, -0.007797151803970337, -0.015333046205341816, -0.04083619639277458, -0.019046766683459282, 0.013785633258521557, -0.022715646773576736, 0.02422105148434639, 0.021269163116812706, -0.02570120431482792, -0.0345325767993927, 0.05842005833983421, 0.0775671973824501, 0.010594048537313938, -0.023309601470828056, 0.006941430736333132, -0.05560654401779175, -0.021972522139549255, 0.048385217785835266, 0.012277708388864994, 0.02000558190047741, 0.022336946800351143, 0.051972903311252594, 0.07461177557706833, 0.001143655157648027, 0.00519612105563283, 0.005018968600779772, 0.010585005395114422, 0.029772324487566948, -0.022759882733225822, 0.024427590891718864, -0.035502251237630844, 0.01982043869793415, -0.012796079739928246, 0.006077362224459648, -0.02998778037726879, 0.001604539924301207, 0.0023390178102999926, -0.04329889640212059, 0.006391563452780247, 0.040664855390787125, 0.00009963804768631235, 0.015483998693525791, -0.011112612672150135, 0.0210097823292017, -0.02328302152454853, -0.004038693383336067, -0.007353449240326881, -0.019094478338956833, 0.0048350924625992775, 0.0022821256425231695, -0.016734065487980843, 0.012498902156949043, 0.01612422615289688, 0.019178735092282295, 0.04634431004524231, -0.014048926532268524, -0.01851056143641472, -0.010194492526352406, -0.00413376884534955, 0.0372796356678009, -0.0716710239648819, 0.006268670782446861, 0.007292487192898989, 0.007198468316346407, 0.04473975673317909, 0.03614898771047592, 0.007940853014588356, 0.005979891866445541, 0.01720244064927101, 0.01696781814098358, -0.028587594628334045, -0.036230411380529404, 0.008399155922234058, 0.016430754214525223, -0.01967526227235794, 0.0013792653335258365, -0.0018054082756862044, -0.04331148788332939, 0.01580062322318554, -0.03500821813941002, 0.03801794722676277, 0.07008221745491028, 0.03308265283703804, 0.05297723412513733, 0.023288043215870857, 0.0368959866464138, 0.005208513233810663, -0.01885448954999447, 0.01181183010339737, 0.01759008690714836, 0.015780868008732796, 0.014590369537472725, 0.007188600488007069, -0.0016102766385301948, 0.00968697015196085, 0.02362697571516037, -0.049100298434495926, 0.011193773709237576, 0.030838971957564354, -0.02961982972919941, 0.02613396756350994, -0.009969141334295273, -0.07187574356794357, -0.03372502326965332, -0.01008496806025505, 0.0010804907651618123, 0.039613302797079086, -0.006517600268125534, 0.004665815271437168, -0.015640128403902054, -0.0310677383095026, 0.021122653037309647, 0.07373150438070297, -0.00047712988452985883, 0.02457987144589424, 0.024745414033532143, 0.07597208768129349, 0.016916988417506218, -0.0033058575354516506, 0.0014986490132287145, 0.023083537817001343, 0.05644369125366211, -0.0078012291342020035, 0.05189055949449539, -0.011402607895433903, -0.007969142869114876, 0.008755350485444069, -0.01487032976001501, -0.0070550027303397655, -0.0020884794648736715, -0.004031438380479813, 0.019844701513648033, -0.0184660404920578, 0.01370603684335947, -0.031148573383688927, 0.047816962003707886, 0.011411579325795174, 0.026911159977316856, 0.008019168861210346, 0.010170461609959602, 0.02367401495575905, -0.011701601557433605, 0.015497678890824318, 0.013835330493748188, 0.010249055922031403, 0.007035399787127972, 0.01907476596534252, 0.04224685579538345, 0.03180403634905815, -0.020732544362545013, -0.00009020586730912328, 0.011147326789796352, -0.03849567472934723, -0.016729356721043587, 0.04815660044550896, 0.008269109763205051, 0.0032183900475502014, -0.027455560863018036, 0.02938314527273178, -0.03815978765487671, 0.025462839752435684, -0.019665224477648735, 0.017517374828457832, -0.036050572991371155, -0.015412629581987858, 0.01932830922305584, 0.031869083642959595, 0.0018282044911757112, -0.017842723056674004, 0.007504886947572231, 0.0055235871113836765, 0.024098072201013565, 0.002293518977239728, -0.025801705196499825, -0.024125339463353157, -0.032851263880729675, -0.003066935110837221, 0.021705467253923416, -0.02059546858072281, -0.01780848205089569, -0.009709356352686882, -0.016954319551587105, 0.06111026182770729, 0.01910347491502762, 0.05562948063015938, -0.020427335053682327, 0.024988215416669846, -0.031653646379709244, 0.034129537642002106, -0.020119765773415565, -0.007594704627990723, 0.012942396104335785, -0.01886686310172081, -0.010760833509266376, -0.00972189661115408, 0.017189182341098785, 0.01334800198674202, 0.00654832785949111, -0.01376537699252367, -0.03895191848278046, -0.004320049658417702, -0.019715629518032074, -0.0400853268802166, 0.049689166247844696, 0.0002738556358963251, 0.01934293657541275, 0.014721699990332127, 0.007898752577602863, 0.006436965428292751, -0.009894090704619884, -0.040409334003925323, 0.06759191304445267, -0.006440185010433197, -0.009241484105587006, -0.00782354548573494, 0.04950110614299774, 0.04201199859380722, -0.01031078677624464, 0.025360465049743652, 0.023615209385752678, 0.014188256114721298, -0.031757697463035583, 0.05703486502170563, -0.018970102071762085, 0.0018071410013362765, -0.05551581084728241, -0.055120691657066345, -0.0067580160684883595, 0.0007427556556649506, 0.007162437774240971, -0.016334427520632744, -0.05355602502822876, 0.015885312110185623, -0.006651076953858137, -0.03122972883284092, -0.04774649813771248, -0.0028349992353469133, 0.018830254673957825, 0.04463844746351242, -0.006546712480485439, 0.012086455710232258, -0.01586327701807022, 0.04817958176136017, -0.03272063657641411, 0.03391101211309433, 0.04401417076587677, 0.023338545113801956, -0.02842702344059944, -0.0202639177441597, -0.03038569539785385, 0.029889486730098724, -0.04265623539686203, 0.04137473925948143, 0.04482201859354973, 0.012968863360583782, -0.05138199403882027, 0.015106867998838425, 0.03398530185222626, -0.00027532505919225514, 0.025297697633504868, -0.032300736755132675, -0.03647369518876076, 0.021354075521230698, -0.0008579606073908508, -0.03407259285449982, -0.025683721527457237, -0.044558797031641006, 0.010020454414188862, 0.029955780133605003, -0.01766706258058548, 0.026176415383815765, -0.015978913754224777, -0.0036897012032568455, 0.016563227400183678, -0.039168830960989, -0.01782192848622799, -0.03936947137117386, -0.017649127170443535, 0.06245947629213333, -0.032226186245679855, -0.0012301115784794092, 0.00848742388188839, -0.01294978428632021, -0.02102815918624401, 0.01642821915447712, -0.011031169444322586, 0.017117120325565338, -0.004566752351820469, 0.009398204274475574, -0.004677902907133102, 0.06488481163978577, -0.0019007510272786021, -0.035081300884485245, -0.03509770333766937, -0.04065464064478874 ]
Supercharged Searching on the Hugging Face Hub
muellerzr
January 25, 2022
searching-the-hub
guide
https://huggingface.co/blog/searching-the-hub
Concluding thoughts Hopefully by now you have a brief understanding of how this new searching API can directly impact your workflow and exploration of the Hub! Along with this, perhaps you know of a place in your code where the AttributeDictionary might be useful for you to use. From here, make sure to check out the official documentation on Searching the Hub Efficiently and don't forget to give us a star!
[ 0.0031227446161210537, 0.018860474228858948, 0.08227408677339554, 0.006784411612898111, 0.07456684112548828, 0.017911171540617943, 0.03536456078290939, 0.07227779179811478, -0.026232879608869553, -0.09983779489994049, -0.05705581232905388, 0.019586633890867233, -0.019553745165467262, 0.03609634190797806, 0.012642803601920605, 0.010668061673641205, 0.0583345852792263, -0.03420461714267731, -0.038976553827524185, 0.05804648622870445, 0.03918728232383728, 0.00981239601969719, 0.09126878529787064, -0.03921034187078476, 0.006501154974102974, -0.05503295734524727, -0.0028730197809636593, -0.019335083663463593, -0.09193091094493866, 0.000619409023784101, -0.037880536168813705, 0.010658279992640018, 0.053458862006664276, -0.02804119884967804, -0.0427943654358387, -0.004013299010694027, -0.06285817176103592, 0.02079600840806961, 0.026120739057660103, -0.02254091575741768, -0.039778679609298706, -0.09448767453432083, -0.01811952143907547, 0.0021486736368387938, 0.029605187475681305, 0.029945941641926765, -0.27068620920181274, 0.040242504328489304, 0.017952384427189827, -0.019823819398880005, -0.07452116906642914, 0.022967927157878876, 0.012618486769497395, 0.0165841206908226, 0.04089869558811188, -0.01056714728474617, -0.03307260945439339, -0.08315354585647583, 0.04498859494924545, 0.022745732218027115, 0.017228800803422928, -0.010703804902732372, -0.03241236135363579, 0.036684345453977585, 0.06115099415183067, 0.04887909069657326, 0.010221200063824654, 0.05096057429909706, -0.0599336139857769, 0.03909064829349518, 0.009792311117053032, 0.026737289503216743, -0.04942760244011879, -0.023390134796500206, -0.024440471082925797, -0.05953025072813034, -0.037618059664964676, 0.049545224756002426, 0.03460375964641571, -0.003649337450042367, -0.025068098679184914, 0.040435124188661575, 0.00916407909244299, -0.0042540039867162704, 0.035984188318252563, 0.043223123997449875, 0.022519871592521667, 0.015434758737683296, -0.03516616299748421, 0.014437506906688213, 0.00015573982091154903, -0.1060124859213829, 0.0037026056088507175, 0.018987275660037994, 0.06500977277755737, -0.08769015967845917, 0.09518017619848251, 0.006792489904910326, 0.018117355182766914, 0.01713418774306774, -0.04270196706056595, -0.03529903292655945, -0.0312928706407547, -0.02067330665886402, -0.0027910214848816395, -0.024745773524045944, 0.003794486867263913, -0.08756418526172638, -0.006740366108715534, 0.07066655904054642, -0.007562595885246992, 0.046218547970056534, -0.015238924883306026, 0.08278843015432358, 0.015111721120774746, 0.05415956303477287, -0.002483104122802615, -0.003983678761869669, -0.07484850287437439, 0.03183317184448242, -0.00044909160351380706, 0.11023876816034317, 0.042681481689214706, 0.029925227165222168, 0.0574052631855011, 0.0027224253863096237, -0.006453250534832478, 0.041474394500255585, -0.04654890298843384, -0.029504287987947464, 0.011968118138611317, -0.011750376783311367, 0.04208150878548622, -0.01524041686207056, -0.05833055078983307, -0.03139370679855347, -0.06854292005300522, 0.004447793588042259, -0.005235796794295311, -0.042410679161548615, 0.017785241827368736, 0.01768180914223194, -0.06119257211685181, 0.013102679513394833, 0.016827063634991646, 0.008490495383739471, -0.03590033948421478, -0.009663068689405918, -0.051752835512161255, -0.0014182768063619733, -0.032391488552093506, 0.08792911469936371, 0.018010210245847702, -0.06145193427801132, -0.01336148101836443, 0.040300894528627396, 0.02371377870440483, -0.02626854181289673, -0.08351064473390579, 0.01698685996234417, -0.01554566528648138, 0.04230042174458504, -0.02274002507328987, 0.013913030736148357, -0.0017479711677879095, 0.026549629867076874, 0.06941518187522888, -0.07648809254169464, 0.0026908947620540857, -0.017267994582653046, -0.0013161858078092337, -0.043601054698228836, 0.05373753234744072, -0.05541778728365898, -0.00372724118642509, 0.06473679095506668, 0.07042625546455383, 0.01691410131752491, -0.05401960760354996, 0.008622079156339169, -0.020707696676254272, 0.06869501620531082, -0.022137455642223358, 0.035075102001428604, 0.016601569950580597, -0.061304185539484024, 0.05639658123254776, 0.07851734012365341, -0.03246041014790535, -0.03456925228238106, -0.058486271649599075, -0.06398813426494598, 0.04963303357362747, -0.001538713346235454, -0.038354337215423584, -0.041774049401283264, -0.003117300570011139, 0.10390786081552505, 0.05569753795862198, 0.04108979180455208, 0.05975229665637016, -0.004829488229006529, 0.04654981940984726, -0.05276266112923622, -0.05273643508553505, 0.006394779775291681, 0.011061392724514008, -0.034330155700445175, 0.012724957428872585, 0.023073719814419746, 0.03821607306599617, -0.12061533331871033, 0.042884353548288345, -0.12713579833507538, 0.0014237487921491265, -0.005837352480739355, -0.004429848864674568, 0.04191569238901138, 0.014884501695632935, -0.057086676359176636, 0.15704260766506195, 0.018076127395033836, 0.004457306582480669, 0.0768250823020935, -0.021809063851833344, 0.0695706456899643, 0.030224764719605446, 0.033466264605522156, 0.03342600166797638, -0.05165174975991249, -0.025987377390265465, 0.01372468937188387, -0.020828554406762123, 0.025865795090794563, -0.01294333953410387, 0.018670547753572464, 0.024713870137929916, -0.0172848179936409, 0.06564013659954071, 0.01160748302936554, -0.02414035238325596, -0.045975614339113235, 0.000646238389890641, 0.07465841621160507, 0.02763545885682106, 0.01171130035072565, 0.04782629385590553, 0.006713073700666428, -0.03924315422773361, 0.03528293967247009, -0.0604294016957283, 0.020241400226950645, 0.042657043784856796, -0.035348162055015564, 0.05617512762546539, 0.026267722249031067, 0.00005092019637231715, -0.03393055126070976, -0.018928509205579758, 0.02236718311905861, 0.022616757079958916, -0.006139141973108053, -0.043400976806879044, -0.03898042067885399, -0.00265267351642251, 0.022767139598727226, 0.02304677851498127, 0.020878225564956665, 0.010509226471185684, 0.019812418147921562, -0.008194169960916042, -0.00574933597818017, 0.002216130029410124, -0.02009717747569084, 0.0020896715577691793, -0.0037722173146903515, 0.0220915786921978, 0.004219486843794584, -0.0004449893895071, -0.03552961349487305, -0.031363990157842636, -0.04936058446764946, 0.041713543236255646, 0.007440133951604366, 0.04445718601346016, -0.05531990900635719, -0.007242198567837477, -0.010277992114424706, -0.03543722257018089, -0.018250977620482445, -0.0042356885969638824, 0.0175422802567482, 0.001718365354463458, 0.011143926531076431, -0.0012260489165782928, 0.003949680365622044, 0.0028010746464133263, 0.011411501094698906, -0.018416183069348335, -0.023697860538959503, -0.016936153173446655, 0.003734766971319914, 0.01885942742228508, -0.04770014062523842, -0.04467311128973961, 0.061274196952581406, -0.01287965290248394, 0.002613671123981476, -0.13011404871940613, -0.020379364490509033, -0.02788691781461239, 0.018484514206647873, -0.0288002360612154, -0.014998205937445164, 0.04626716300845146, -0.012994278222322464, -0.005782843567430973, -0.03289152681827545, -0.016303176060318947, 0.02522142045199871, 0.018417248502373695, -0.017775122076272964, -0.02162087708711624, 0.03676777333021164, -0.015652352944016457, 0.01412468682974577, 0.007378811948001385, 0.004156178329139948, -0.021586677059531212, 0.013145244680345058, -0.006658643484115601, -0.03493684530258179, -0.017818953841924667, -0.01354984287172556, 0.007534084375947714, 0.03830963000655174, 0.01508001983165741, -0.05628345161676407, 0.005375029984861612, -0.0028626853600144386, -0.05468015372753143, 0.013849710114300251, -0.02636779472231865, 0.008764242753386497, 0.0042815743945539, 0.009954766370356083, -0.007941420190036297, 0.046565763652324677, 0.025357700884342194, 0.01218077540397644, 0.049497250467538834, 0.02791372686624527, 0.005592925474047661, -0.002063541207462549, -0.013510470278561115, 0.0025176985654979944, 0.03529176488518715, -0.043308112770318985, -0.060262273997068405, -0.001753528486005962, -0.034500427544116974, 0.03336683660745621, 0.017468316480517387, -0.014052845537662506, -0.011801246553659439, -0.010799916461110115, 0.0040212273597717285, -0.017229601740837097, -0.022337300702929497, 0.015300698578357697, -0.0011370977154001594, -0.007395298685878515, -0.041159093379974365, 0.03530663624405861, -0.020712852478027344, 0.05795581638813019, -0.026110395789146423, 0.0037643432151526213, -0.007575765252113342, 0.0429910384118557, 0.03360862657427788, 0.013712160289287567, -0.017761627212166786, 0.03275075554847717, -0.011636486276984215, 0.005510019604116678, 0.07612845301628113, 0.019893867895007133, -0.00005853531547472812, -0.001293396344408393, -0.04619966819882393, -0.004999289754778147, 0.008474016562104225, 0.023158488795161247, 0.030421733856201172, -0.002734856680035591, -0.03264786675572395, 0.019911115989089012, -0.01186017133295536, -0.01268020924180746, 0.011914044618606567, -0.005400571506470442, -0.000527976721059531, 0.010477608069777489, 0.056038204580545425, -0.004550142213702202, 0.0007061698124743998, -0.0008286963566206396, 0.007369587197899818, 0.0059916055761277676, -0.019302302971482277, 0.006690356880426407, 0.013287749141454697, 0.040903568267822266, -0.041016943752765656, -0.05222581699490547, 0.028919823467731476, -0.0036965126637369394, 0.01315267663449049, -0.06000261753797531, -0.007560781668871641, -0.03180162236094475, -0.008480334654450417, 0.025304360315203667, 0.004516280721873045, -0.004405040293931961, -0.04608297720551491, 0.026043426245450974, -0.05399781093001366, 0.039602894335985184, -0.011161969043314457, -0.013953710906207561, -0.033799342811107635, 0.02853182516992092, 0.01896764524281025, -0.014232764020562172, 0.0307414960116148, -0.007321201730519533, 0.018508853390812874, 0.013879045844078064, 0.0006633391603827477, -0.02855377458035946, 0.01701302081346512, 0.013602874241769314, -0.013310510665178299, 0.012363693676888943, -0.019796553999185562, -0.05880584567785263, -0.025708502158522606, -0.004500173963606358, -0.005702978931367397, -0.004771937150508165, 0.04022206366062164, 0.012645797803997993, -0.04235180839896202, -0.029971135780215263, 0.008539271540939808, 0.009287981316447258, 0.07974696159362793, -0.027770621702075005, -0.02333381585776806, 0.003267609514296055, 0.018855445086956024, -0.009397169575095177, -0.009045697748661041, 0.003987012896686792, -0.03114660084247589, 0.041573699563741684, 0.012963276356458664, -0.012574042193591595, -0.02411334589123726, 0.017631620168685913, 0.007017354480922222, 0.01847168430685997, -0.00422279629856348, -0.005227257031947374, 0.015032687224447727, 0.0025596818886697292, -0.018922947347164154, 0.03194783255457878, 0.006604719441384077, -0.02225269190967083, 0.02659446932375431, 0.04551229625940323, 0.02651081793010235, 0.0527704581618309, 0.036773715168237686, 0.017368506640195847, -0.043329548090696335, -0.025935746729373932, 0.03787502273917198, -0.0032786629162728786, -0.014875760301947594, -0.0015041932929307222, 0.032510899007320404, 0.02190685085952282, -0.0033048558980226517, 0.004903398919850588, -0.037149298936128616, 0.0003504814812913537, 0.00290141929872334, -0.00633685477077961, 0.05180540680885315, -0.04049481078982353, 0.014868419617414474, -0.016491077840328217, -0.02840711735188961, -0.009272457100450993, 0.04039471596479416, 0.05695849657058716, -0.03184252604842186, 0.018841631710529327, -0.021212613210082054, 0.009967813268303871, 0.0328669473528862, -0.030237285420298576, -0.04147343710064888, -0.03771980106830597, -0.015456292778253555, 0.010623304173350334, -0.027746450155973434, -0.01835830695927143, 0.0377640537917614, -0.024187862873077393, -0.0024887153413146734, 0.032923344522714615, 0.014570392668247223, 0.04439988359808922, 0.01729508675634861, -0.0036068016197532415, -0.02396959438920021, 0.036091070622205734, 0.03652406856417656, -0.05085514485836029, 0.03457660600543022, 0.010813872329890728, -0.016400950029492378, 0.03138327598571777, 0.04517558589577675, -0.015156743116676807, 0.01694599725306034, 0.0592641644179821, 0.016948478296399117, 0.005721678026020527, -0.054558247327804565, 0.013263998553156853, 0.014948664233088493, 0.0003609810082707554, 0.010331260971724987, 0.0002250044490210712, -0.039958663284778595, -0.0005894110654480755, -0.036061909049749374, 0.04589459300041199, 0.022632580250501633, 0.06588537991046906, 0.0122572872787714, 0.008335050195455551, 0.02920691855251789, -0.01609891839325428, -0.004075516015291214, 0.002428146079182625, 0.0015854673692956567, -0.004079945385456085, 0.010652156546711922, -0.022170472890138626, 0.018290070816874504, -0.004118957091122866, -0.01569235883653164, -0.03254729136824608, 0.044152405112981796, 0.06604336202144623, -0.03159284219145775, 0.0267954058945179, -0.012998389080166817, -0.09389831870794296, -0.03503064066171646, -0.009026631712913513, -0.01879970356822014, 0.026704374700784683, 0.028122801333665848, -0.0027984764892607927, -0.011705168522894382, -0.034688789397478104, 0.042611368000507355, 0.04983825236558914, -0.008220057934522629, 0.01632765866816044, 0.0235144030302763, 0.090058833360672, 0.02187744341790676, 0.0059246220625936985, -0.004694551695138216, 0.026920678094029427, 0.02596907503902912, 0.02653527818620205, 0.04925113171339035, -0.036642272025346756, 0.0018940357258543372, 0.025182701647281647, -0.02204134874045849, 0.008961108513176441, -0.016451602801680565, -0.012909088283777237, 0.027738971635699272, 0.019366543740034103, 0.029367052018642426, -0.06154333055019379, -0.02247968688607216, -0.015018302015960217, -0.010405708104372025, -0.007532014045864344, 0.0015008148038759828, -0.0033707115799188614, 0.0004979623481631279, 0.029879020527005196, 0.04359598830342293, -0.03170651197433472, -0.023850688710808754, 0.06624045222997665, -0.006390618626028299, 0.009594456292688847, -0.03106212243437767, -0.00959798600524664, 0.026234179735183716, 0.004443508107215166, -0.02959417924284935, 0.02946372516453266, 0.03024466335773468, 0.013046245090663433, -0.012468837201595306, 0.00013656872033607215, -0.006589635740965605, -0.0583195723593235, 0.0053028082475066185, 0.007573573384433985, -0.03889930620789528, 0.004185439553111792, 0.021369142457842827, 0.02626223675906658, -0.017496680840849876, -0.023543287068605423, 0.02989708073437214, 0.04466208070516586, 0.05279731750488281, 0.04115959629416466, -0.029129793867468834, -0.012386934831738472, -0.028866708278656006, 0.02141738124191761, -0.008693543262779713, 0.013301254250109196, -0.011202896013855934, -0.02390385791659355, -0.03323259949684143, -0.003024056786671281, 0.01699008420109749, 0.06883919984102249, -0.03014964424073696, 0.06440218538045883, -0.027481181547045708, 0.03184770792722702, -0.02713874913752079, 0.027470281347632408, 0.013421018607914448, 0.005300705786794424, -0.006489044986665249, -0.0214550718665123, -0.0026561440899968147, 0.04844788461923599, -0.012238042429089546, -0.043291375041007996, -0.021130168810486794, -0.00625953683629632, -0.019473804160952568, -0.0028198601212352514, 0.01884007453918457, -0.009001228027045727, 0.015653470531105995, 0.025816740468144417, -0.01841738447546959, -0.0278345737606287, -0.033553801476955414, -0.011213580146431923, 0.04756171256303787, -0.02319650910794735, 0.012355362996459007, -0.019297722727060318, 0.06257651001214981, 0.024737132713198662, 0.012169476598501205, 0.04412344470620155, -0.0027033581864088774, 0.03054872713983059, -0.0276481993496418, -0.007007344160228968, -0.014671197161078453, -0.021913304924964905, -0.022286687046289444, -0.012086937204003334, -0.035213716328144073, -0.012842103838920593, -0.013705174438655376, 0.003945893608033657, -0.06479072570800781, -0.013198609463870525, 0.029867952689528465, 0.005564110819250345, -0.0530339851975441, 0.007167460396885872, 0.04669899120926857, 0.0030397125519812107, 0.04176061972975731, 0.012460068799555302, 0.023306287825107574, -0.0055262246169149876, 0.004965829662978649, 0.029712485149502754, 0.0471319779753685, 0.04539932683110237, -0.034654054790735245, -0.058707885444164276, 0.029933534562587738, -0.011512122116982937, -0.05186240002512932, 0.057176921516656876, 0.03505440056324005, -0.026550520211458206, -0.03319954127073288, 0.03667140007019043, 0.00617372989654541, 0.013012770563364029, 0.03528575226664543, -0.004845176357775927, -0.020023271441459656, 0.02220773696899414, 0.018796514719724655, -0.03703034669160843, -0.027273118495941162, -0.029974982142448425, 0.005498730111867189, 0.01218522246927023, -0.0009969953680410981, -0.009709745645523071, 0.0009959704475477338, -0.014796308241784573, 0.002168932231143117, 0.008150873705744743, -0.01367017813026905, -0.06510177254676819, -0.02659398317337036, 0.012574726715683937, -0.06331676989793777, -0.008289160206913948, 0.06481019407510757, 0.0018364563584327698, -0.00886158924549818, 0.02462100423872471, -0.0114910788834095, 0.006281678564846516, 0.03236367180943489, 0.06017746031284332, 0.01226875651627779, 0.0520404614508152, 0.039932772517204285, -0.02401174232363701, -0.00911957211792469, -0.004871337208896875 ]
Supercharged Searching on the Hugging Face Hub
muellerzr
January 25, 2022
searching-the-hub
guide
https://huggingface.co/blog/searching-the-hub
What is the magic? Very briefly we'll talk about the underlying magic at play that gives us this enum-dictionary-like datatype, the AttributeDictionary. Heavily inspired by the AttrDict class from the fastcore library, the general idea is we take a normal dictionary and supercharge it for exploratory programming by providing tab-completion for every key in the dictionary. As we saw earlier, this gets even stronger when we have nested dictionaries we can explore through, such as model_args.dataset.glue! > For those familiar with JavaScript, we mimic how the object class is working. This simple utility class can provide a much more user-focused experience when exploring nested datatypes and trying to understand what is there, such as the return of an API request! As mentioned before, we expand on the AttrDict in a few key ways: - You can delete keys with del model_args[key] or with del model_args.key - That clean __repr__ we saw earlier One very important concept to note though, is that if a key contains a number or special character it must be indexed as a dictionary, and not as an object. python >>> from huggingface_hub.utils.endpoint_helpers import AttributeDictionary A very brief example of this is if we have an AttributeDictionary with a key of 3_c: python >>> d = {"a":2, "b":3, "3_c":4} >>> ad = AttributeDictionary(d) python >>> # As an attribute >>> ad.3_c File "", line 2 ad.3_c ^ SyntaxError: invalid token python >>> # As a dictionary key >>> ad["3_c"] 4
[ -0.01909150928258896, -0.006126993335783482, 0.06587580591440201, 0.006873258855193853, 0.049090638756752014, 0.020045019686222076, 0.07274183630943298, 0.04901698976755142, -0.03356421738862991, -0.04789241775870323, -0.08657031506299973, 0.010901439003646374, -0.05346991494297981, 0.09620779007673264, 0.00709034688770771, 0.004350557923316956, 0.04730450361967087, -0.0008483279380016029, -0.0567810945212841, 0.07600213587284088, 0.005359151400625706, -0.05881731957197189, 0.08252615481615067, -0.07917913049459457, 0.01498517394065857, -0.07297687232494354, 0.0005186474299989641, 0.0005022248369641602, -0.05271650850772858, 0.053521525114774704, -0.11034857481718063, 0.03434191271662712, -0.056568801403045654, -0.010211399756371975, 0.04235055670142174, -0.053906023502349854, -0.06804890930652618, -0.011850477196276188, 0.013571731746196747, -0.03819886967539787, 0.019558092579245567, -0.0652257576584816, -0.0403878316283226, 0.016031725332140923, 0.03920839726924896, -0.011387106031179428, -0.1961279958486557, 0.04574545845389366, -0.03345369175076485, -0.0530688613653183, -0.09964650124311447, 0.008134930394589901, -0.040489643812179565, 0.012925450690090656, 0.02345462515950203, -0.019317204132676125, -0.036379408091306686, -0.004859528504312038, 0.07832257449626923, -0.003490555565804243, -0.02147582732141018, 0.02336333878338337, -0.016004836186766624, -0.024073481559753418, 0.06554203480482101, 0.03759964555501938, -0.045790817588567734, 0.05962887406349182, -0.03182216361165047, 0.020382527261972427, 0.0004657891404349357, -0.006627593655139208, -0.05237065255641937, -0.04127402976155281, -0.04414255544543266, -0.047336772084236145, -0.01889735274016857, 0.0516999177634716, 0.05540900304913521, 0.0003213750896975398, 0.018565461039543152, 0.06093093752861023, 0.04862072318792343, 0.07479330897331238, 0.07985638082027435, 0.012111437506973743, 0.013130705803632736, -0.040312714874744415, -0.12160322070121765, 0.04048561304807663, -0.05917787551879883, -0.09696055203676224, 0.023057296872138977, 0.03277265653014183, 0.0164310485124588, -0.05143427103757858, 0.0016820539021864533, 0.007001425139605999, 0.029021980240941048, 0.02461489662528038, -0.012711649760603905, -0.05975442752242088, -0.031130768358707428, -0.029874203726649284, -0.04306671395897865, 0.03299807757139206, -0.010217396542429924, -0.009072327055037022, -0.025811178609728813, 0.009648781269788742, -0.044169459491968155, 0.02326071821153164, -0.025942282751202583, 0.07833844423294067, -0.0409877635538578, 0.024934982880949974, -0.07027196884155273, 0.00768362358212471, -0.022113751620054245, 0.013615366071462631, 0.019408755004405975, 0.020504862070083618, 0.010949480347335339, 0.013080010190606117, 0.0432165153324604, 0.023352382704615593, 0.014962426386773586, 0.062404561787843704, 0.026518099009990692, 0.01691250503063202, 0.04943211004137993, 0.0015695692272856832, 0.07379709929227829, -0.006944796536117792, -0.041050996631383896, -0.02199515514075756, -0.03433835506439209, 0.006307704374194145, 0.032009683549404144, 0.011099616065621376, -0.004431539680808783, 0.0122474804520607, -0.03505362197756767, -0.044572606682777405, -0.00789689738303423, -0.00837446004152298, -0.03768188878893852, 0.08352506905794144, -0.002729233354330063, 0.007187050301581621, -0.01696908287703991, 0.040880654007196426, 0.05953201279044151, 0.025761449709534645, 0.015336254611611366, 0.06450166553258896, 0.021830955520272255, -0.03391676023602486, -0.08161814510822296, -0.0009262425010092556, -0.021817408502101898, -0.02217363566160202, -0.0184237789362669, 0.021754223853349686, 0.005646351259201765, 0.010831735096871853, -0.02191256731748581, 0.020761694759130478, 0.00413034250959754, 0.002825690433382988, -0.009354549460113049, -0.08394473791122437, 0.05339118465781212, -0.019417112693190575, -0.027676232159137726, 0.07254593074321747, -0.003003285499289632, 0.013456161133944988, -0.013704302720725536, 0.02661094069480896, -0.00880293920636177, 0.024698881432414055, 0.01683509722352028, 0.03315989673137665, 0.022978801280260086, 0.03285612165927887, 0.057315174490213394, 0.016829153522849083, -0.02620767615735531, 0.03446221724152565, -0.0460265651345253, 0.011402703821659088, 0.07685594260692596, -0.034903429448604584, 0.07069732248783112, -0.04654731601476669, -0.10867736488580704, 0.09120174497365952, 0.066999152302742, 0.03228636831045151, 0.06909577548503876, -0.00603663083165884, 0.03717781975865364, -0.058491721749305725, -0.012131728231906891, 0.00077114935265854, 0.06053394824266434, -0.06091202795505524, 0.03265717998147011, 0.005933020263910294, 0.058263398706912994, -0.06947936117649078, 0.011907161213457584, -0.0879303589463234, -0.026656972244381905, 0.014054725877940655, -0.034340281039476395, -0.00011462371912784874, 0.010861415416002274, -0.042463518679142, 0.12331344187259674, -0.054616764187812805, 0.02528715319931507, -0.051181912422180176, 0.008020676672458649, 0.04692154750227928, 0.020911185070872307, 0.05157390981912613, 0.06607913225889206, -0.05943945050239563, 0.01558779552578926, -0.04011467844247818, -0.03586448356509209, -0.021763360127806664, -0.019113898277282715, -0.057629041373729706, 0.07599498331546783, -0.001990908058360219, 0.06007303670048714, -0.012907258234918118, -0.04316360875964165, -0.008463767357170582, 0.01993383839726448, 0.022935429587960243, -0.004039614461362362, -0.01261329185217619, 0.12074754387140274, 0.03483330085873604, -0.08331238478422165, 0.019916720688343048, -0.06992808729410172, 0.05100966617465019, 0.07422900944948196, 0.018661290407180786, 0.03430849686264992, 0.022351626306772232, -0.0033187835942953825, 0.021298857405781746, -0.05736527964472771, 0.04442591592669487, 0.01163224596530199, -0.04545655474066734, -0.0886702835559845, -0.027922438457608223, -0.011221139691770077, -0.01309828832745552, -0.007472582161426544, 0.06274469941854477, 0.05918305367231369, 0.00893880520015955, 0.03776049241423607, -0.018743036314845085, 0.03666960820555687, 0.006335824728012085, 0.015806322917342186, 0.049293067306280136, 0.027842214331030846, -0.032224107533693314, 0.0025187788996845484, -0.04973341152071953, -0.06792841851711273, -0.009493212215602398, 0.032044511288404465, 0.023796692490577698, 0.00045653062989003956, -0.02389862760901451, 0.0013793651014566422, -0.023422906175255775, -0.04750509187579155, -0.00651638675481081, -0.02074481174349785, 0.04398108646273613, -0.01658950373530388, -0.026248622685670853, 0.00924611184746027, 0.02828497812151909, -0.02085784263908863, 0.00426354119554162, -0.005920757073909044, 0.014895433560013771, 0.012582940049469471, -0.009348355233669281, 0.006854585837572813, -0.024172134697437286, -0.0021926274057477713, 0.07192983478307724, -0.010582197457551956, 0.047527533024549484, -0.10513603687286377, -0.019502803683280945, -0.04087584838271141, -0.02839807979762554, -0.011023232713341713, -0.021048735827207565, 0.060797031968832016, 0.061246976256370544, 0.013856293633580208, -0.002734149806201458, 0.008762386627495289, 0.025981344282627106, 0.04324290528893471, 0.006188482511788607, -0.004669124260544777, -0.019632091745734215, -0.008983312174677849, -0.018371669575572014, 0.05495316535234451, 0.0016907176468521357, -0.022846465930342674, 0.0052488334476947784, -0.02662106789648533, 0.005242438521236181, -0.015276988968253136, -0.06369953602552414, 0.07060713320970535, 0.05325505882501602, -0.003524992149323225, -0.0601489283144474, 0.02731551229953766, -0.03237416595220566, -0.009500104933977127, 0.01802927441895008, -0.01158579345792532, -0.015950996428728104, 0.024973945692181587, -0.044339027255773544, -0.025659170001745224, 0.016141371801495552, -0.0021194382570683956, 0.009271394461393356, 0.005400285590440035, 0.01890573836863041, 0.007423638366162777, -0.015712304040789604, -0.007119756657630205, -0.03681553900241852, -0.019725605845451355, -0.02292482741177082, -0.025241641327738762, -0.013494781218469143, 0.0016732397489249706, 0.06808741390705109, 0.0017940670950338244, 0.07149151712656021, 0.03151717409491539, -0.01249710749834776, 0.01358572393655777, 0.014029416255652905, -0.013223265297710896, 0.018145283684134483, -0.04225292056798935, -0.0027335993945598602, -0.03769582509994507, 0.026558635756373405, 0.0012173316208645701, 0.017906630411744118, -0.03552238270640373, 0.020763183012604713, -0.04588538408279419, 0.00867069698870182, -0.02713155932724476, -0.004738977644592524, 0.020491549745202065, -0.020257839933037758, -0.02293870784342289, -0.027129333466291428, 0.047058604657649994, 0.014139661565423012, -0.04292024299502373, -0.00406670942902565, -0.029087090864777565, 0.047584887593984604, 0.051892004907131195, 0.021335380151867867, 0.027501976117491722, -0.0369996540248394, 0.00529563520103693, -0.010638990439474583, 0.01525635551661253, -0.00399534497410059, -0.008483574725687504, 0.0013834800338372588, -0.019085705280303955, 0.030945923179388046, 0.010083061642944813, -0.017886823043227196, 0.002313432516530156, -0.02145281992852688, 0.0068537769839167595, -0.05330333858728409, -0.05301140621304512, -0.004438324365764856, -0.027406957000494003, 0.039856914430856705, -0.06829153746366501, -0.05161465331912041, 0.056454453617334366, -0.037147194147109985, -0.02625468373298645, -0.012828967534005642, 0.005018755327910185, -0.00020927836885675788, 0.029910126700997353, 0.014237101189792156, -0.027019351720809937, -0.0011855935445055366, -0.0193652231246233, 0.007557530887424946, 0.03410070016980171, 0.023175708949565887, -0.002571333898231387, -0.026615433394908905, 0.0036383552942425013, -0.015842614695429802, 0.01712973229587078, 0.009799308143556118, -0.000918857054784894, -0.01563744992017746, -0.0062615531496703625, 0.01661057025194168, -0.008563966490328312, -0.03136071935296059, -0.013770871795713902, 0.015691256150603294, 0.0217340849339962, 0.0032999508548527956, 0.010928934440016747, -0.062404461205005646, -0.021262099966406822, -0.05054907500743866, -0.016511114314198494, -0.02430306002497673, 0.011789142154157162, -0.02580474130809307, -0.011943700723350048, 0.03077695518732071, -0.03624892979860306, 0.02991887554526329, 0.031121492385864258, -0.0007114012259989977, -0.011615274474024773, -0.012410538271069527, -0.024973733350634575, -0.03701195865869522, -0.0021441567223519087, 0.008564851246774197, -0.01405621599406004, 0.0626753568649292, 0.0006448262720368803, 0.00331244058907032, -0.02433749847114086, -0.01209914218634367, 0.008032566867768764, 0.011727799661457539, -0.011374390684068203, -0.025349587202072144, 0.017052819952368736, 0.01004836242645979, -0.020274244248867035, 0.03877950832247734, -0.016325457021594048, 0.011063533835113049, -0.018743371590971947, 0.033852871507406235, 0.022950148209929466, 0.01977161318063736, 0.008807632140815258, 0.026883607730269432, -0.024750465527176857, 0.0031949339900165796, 0.0283656008541584, 0.00589332589879632, 0.03367162495851517, 0.006070678122341633, 0.007491660304367542, 0.06349274516105652, 0.017944425344467163, 0.005489297676831484, 0.00021558428124990314, -0.014731107279658318, -0.0025454123970121145, -0.05032595619559288, 0.037881992757320404, -0.031135791912674904, -0.03890024870634079, 0.02882431074976921, -0.013669965788722038, -0.04868049919605255, -0.003809534478932619, 0.05486823990941048, -0.011104286648333073, 0.00928496289998293, 0.040927302092313766, 0.01429225318133831, 0.004847813863307238, -0.002216495107859373, -0.018457379192113876, -0.0392807275056839, 0.007166511844843626, -0.04907131567597389, 0.004569675773382187, -0.021052498370409012, 0.01302630826830864, -0.03078661486506462, -0.00857020914554596, 0.03248808532953262, 0.006624955218285322, 0.01266210526227951, -0.005944610107690096, 0.050614602863788605, -0.031234873458743095, 0.03756359964609146, 0.027803370729088783, -0.04463659226894379, 0.015093806199729443, 0.024396654218435287, 0.021710427477955818, 0.004256114829331636, 0.04881877079606056, 0.0033273801673203707, -0.042625878006219864, 0.029140295460820198, -0.008798176422715187, 0.023449331521987915, -0.023632068186998367, 0.008525040931999683, 0.0722239539027214, -0.04218520596623421, 0.004792554769665003, -0.0001628730824450031, -0.060605451464653015, 0.0014709954848513007, -0.013629086315631866, 0.01760408654808998, 0.04925891384482384, 0.017234599217772484, -0.029797513037919998, -0.009141507558524609, 0.025272827595472336, -0.01446034386754036, 0.04885461926460266, -0.005343577358871698, -0.004462894983589649, -0.017415767535567284, 0.02122855745255947, -0.04633578658103943, 0.005130949895828962, -0.01923317089676857, 0.0141944270581007, -0.003351216670125723, 0.021389400586485863, 0.045575760304927826, -0.028918690979480743, 0.03433652222156525, 0.005450766067951918, -0.055053308606147766, 0.006680898368358612, 0.0016741506988182664, -0.0027547867503017187, 0.047427572309970856, 0.01758243329823017, 0.023795297369360924, -0.02150897867977619, -0.05281202495098114, 0.021917402744293213, 0.04618808627128601, 0.026412660256028175, 0.017652278766036034, 0.04120595008134842, 0.048512741923332214, 0.05394889786839485, -0.0015299143269658089, -0.014418387785553932, 0.0031106125097721815, 0.09158141165971756, 0.03274700045585632, 0.049536220729351044, -0.005497013218700886, -0.027816995978355408, 0.07111851871013641, -0.017238076776266098, 0.0076350076124072075, -0.018543606624007225, -0.014035729691386223, 0.027514278888702393, -0.01855969987809658, 0.056435465812683105, -0.05215932056307793, 0.011174275539815426, -0.0013419141760095954, 0.006854844279587269, -0.02415606379508972, -0.0005624016048386693, -0.0014881540555506945, -0.0030153337866067886, 0.010835499502718449, 0.04279545694589615, -0.002701244782656431, -0.00941380299627781, 0.05490061268210411, -0.004057052079588175, 0.027307352051138878, -0.007486230693757534, -0.0035217704717069864, 0.04813612997531891, -0.00617134477943182, -0.013718819245696068, 0.001327020232565701, 0.0023987065069377422, 0.047123976051807404, 0.007245681248605251, -0.0663737878203392, -0.04176659509539604, 0.017089542001485825, -0.015665002167224884, -0.012421272695064545, -0.01664770022034645, 0.009380328468978405, 0.06466101109981537, 0.03583025187253952, -0.005536534357815981, -0.04501120746135712, 0.015573261305689812, 0.01931459829211235, 0.012746458873152733, 0.04302230477333069, -0.014672481454908848, 0.020150724798440933, -0.051600370556116104, 0.006432974711060524, 0.013407872058451176, 0.047882016748189926, -0.014931481331586838, -0.039442725479602814, 0.0047022090293467045, -0.023770764470100403, 0.02743600308895111, 0.03946468234062195, 0.010900437831878662, 0.06776975095272064, -0.023189101368188858, 0.009213092736899853, -0.01962403953075409, -0.01063177827745676, -0.03075464256107807, -0.04864094406366348, -0.005031486041843891, -0.002846002811565995, 0.03576909750699997, 0.054611869156360626, 0.03829760476946831, -0.06892825663089752, -0.03914706036448479, -0.021879564970731735, -0.04561488702893257, 0.01604476012289524, 0.03589767962694168, -0.03654557093977928, -0.0382915735244751, 0.018122293055057526, 0.0005903021083213389, -0.00473784189671278, -0.03251383826136589, -0.03531978279352188, 0.03929382190108299, -0.026722751557826996, -0.019111260771751404, 0.013516325503587723, 0.03411879763007164, 0.013773582875728607, 0.019572969526052475, 0.03527180105447769, 0.0018642846262082458, 0.024175308644771576, -0.013648906722664833, 0.046036750078201294, -0.026045724749565125, 0.03292589634656906, -0.03220042213797569, -0.0006405861349776387, 0.003956175409257412, -0.044314805418252945, 0.009100575000047684, 0.032284632325172424, -0.04884416610002518, 0.03506327047944069, -0.006536821369081736, 0.006411574315279722, -0.013063867576420307, 0.05315282940864563, 0.05287126824259758, 0.01818958856165409, 0.005305760074406862, 0.03735414892435074, -0.011674496345221996, 0.020249754190444946, -0.006393308285623789, -0.021645793691277504, 0.056845031678676605, 0.003803332569077611, 0.01091444119811058, -0.05319921672344208, -0.05593269690871239, -0.012693437747657299, -0.026232613250613213, 0.022269003093242645, -0.0028499511536210775, -0.01336685474961996, 0.012263462878763676, 0.015042558312416077, 0.012690654955804348, -0.004595394246280193, 0.013960332609713078, 0.009022099897265434, -0.012172630988061428, 0.01947212778031826, -0.0007432768470607698, -0.06697641313076019, -0.024767974391579628, -0.024336179718375206, 0.004185875412076712, 0.037970203906297684, -0.001058459165506065, 0.00389215094037354, 0.02475809119641781, 0.018062293529510498, 0.019264396280050278, -0.003874804126098752, -0.026757899671792984, -0.017068343237042427, -0.02171061746776104, 0.01005160715430975, -0.051616910845041275, 0.021343762055039406, 0.009546891786158085, -0.017028694972395897, -0.019340138882398605, 0.028323832899332047, -0.04491091147065163, -0.004862631671130657, 0.0015050872461870313, 0.009424842894077301, 0.011729869991540909, 0.05155863240361214, 0.027577590197324753, 0.0073437197133898735, -0.0279852245002985, 0.02284270152449608 ]
Supercharged Searching on the Hugging Face Hub
muellerzr
January 25, 2022
searching-the-hub
guide
https://huggingface.co/blog/searching-the-hub
Finding what we need First we'll import the HfApi, which is a class that helps us interact with the backend hosting for Hugging Face. We can interact with the models, datasets, and more through it. Along with this, we'll import a few helper classes: the ModelFilter and ModelSearchArguments python from huggingface_hub import HfApi, ModelFilter, ModelSearchArguments api = HfApi() These two classes can help us frame a solution to our above problem. The ModelSearchArguments class is a namespace-like one that contains every single valid parameter we can search for! Let's take a peek: python >>> model_args = ModelSearchArguments() >>> model_args Available Attributes or Keys: * author * dataset * language * library * license * model_name * pipeline_tag We can see a variety of attributes available to us (more on how this magic is done later). If we were to categorize what we wanted, we could likely separate them out as: - pipeline_tag (or task): Text Classification - dataset: GLUE - library: PyTorch Given this separation, it would make sense that we would find them within our model_args we've declared: python >>> model_args.pipeline_tag.TextClassification 'text-classification' python >>> model_args.dataset.glue 'dataset:glue' python >>> model_args.library.PyTorch 'pytorch' What we begin to notice though is some of the convience wrapping we perform here. ModelSearchArguments (and the complimentary DatasetSearchArguments) have a human-readable interface with formatted outputs the API wants, such as how the GLUE dataset should be searched with dataset:glue. This is key because without this "cheat sheet" of knowing how certain parameters should be written, you can very easily sit in frustration as you're trying to search for models with the API! Now that we know what the right parameters are, we can search the API easily: python >>> models = api.list_models(filter = ( >>> model_args.pipeline_tag.TextClassification, >>> model_args.dataset.glue, >>> model_args.library.PyTorch) >>> ) >>> print(len(models)) 140 We find that there were 140 matching models that fit our criteria! (at the time of writing this). And if we take a closer look at one, we can see that it does indeed look right: python >>> models[0] ModelInfo: { modelId: Jiva/xlm-roberta-large-it-mnli sha: c6e64469ec4aa17fedbd1b2522256f90a90b5b86 lastModified: 2021-12-10T14:56:38.000Z tags: ['pytorch', 'xlm-roberta', 'text-classification', 'it', 'dataset:multi_nli', 'dataset:glue', 'arxiv:1911.02116', 'transformers', 'tensorflow', 'license:mit', 'zero-shot-classification'] pipeline_tag: zero-shot-classification siblings: [ModelFile(rfilename='.gitattributes'), ModelFile(rfilename='README.md'), ModelFile(rfilename='config.json'), ModelFile(rfilename='pytorch_model.bin'), ModelFile(rfilename='sentencepiece.bpe.model'), ModelFile(rfilename='special_tokens_map.json'), ModelFile(rfilename='tokenizer.json'), ModelFile(rfilename='tokenizer_config.json')] config: None private: False downloads: 680 library_name: transformers likes: 1 } It's a bit more readable, and there's no guessing involved with "Did I get this parameter right?" > Did you know you can also get the information of this model programmatically with its model ID? Here's how you would do it: > python > api.model_info('Jiva/xlm-roberta-large-it-mnli') >
[ 0.00467261066660285, 0.020120058208703995, -0.017886916175484657, 0.019701223820447922, 0.03999081999063492, 0.07024448364973068, 0.03801339119672775, 0.012536264955997467, -0.05601285398006439, -0.030049750581383705, -0.07142460346221924, 0.05259903147816658, -0.018468204885721207, 0.08264876157045364, 0.03419296443462372, -0.05486574023962021, 0.07876092940568924, 0.034241288900375366, -0.020976290106773376, 0.11083246022462845, 0.012657061219215393, 0.013175037689507008, 0.03257837891578674, 0.03069405071437359, 0.014864484779536724, -0.11773467808961868, 0.003973867744207382, 0.032809384167194366, 0.01762601174414158, 0.05137080326676369, -0.14309579133987427, 0.0060629225336015224, -0.05236973986029625, -0.07541465014219284, 0.020517712458968163, 0.05739389732480049, -0.08894117176532745, 0.028745118528604507, 0.06151675060391426, -0.001067720353603363, -0.0162065252661705, -0.032989200204610825, -0.05463976413011551, 0.010328971780836582, -0.009283746592700481, -0.007994728162884712, -0.157647043466568, 0.08690289407968521, 0.0032326262444257736, 0.007939774543046951, -0.06472888588905334, 0.06590231508016586, 0.011048644781112671, 0.04083662107586861, 0.033296287059783936, -0.050923705101013184, -0.013074367307126522, -0.06846244633197784, -0.019614327698946, 0.039132144302129745, 0.005041207652539015, 0.0517929345369339, 0.02246187999844551, 0.049074601382017136, 0.012979683466255665, 0.006780039519071579, -0.04482223466038704, -0.0176444910466671, -0.06054973974823952, -0.051029521971940994, 0.05014603212475777, -0.012963742017745972, -0.019413355737924576, -0.05533510819077492, -0.04853356257081032, -0.06150136515498161, -0.056098323315382004, 0.0007765411864966154, 0.010231689549982548, 0.05092299357056618, -0.028594134375452995, 0.02476656809449196, 0.001039547729305923, 0.05666861683130264, 0.05324177071452141, -0.0032083599362522364, -0.0012809197651222348, -0.057754840701818466, -0.032648589462041855, 0.06219061464071274, -0.025512410327792168, -0.1034766212105751, -0.01421645563095808, -0.02205173671245575, 0.06979969888925552, -0.02341349609196186, 0.026209773495793343, 0.03336798772215843, 0.037335652858018875, 0.004872615449130535, -0.006929590832442045, -0.0616680271923542, -0.0009299410157836974, -0.027992093935608864, -0.01093344297260046, 0.004109246656298637, 0.007622579112648964, -0.05387326329946518, -0.09722159057855606, -0.0181428249925375, 0.014229822903871536, -0.024346716701984406, -0.056338831782341, 0.1054181456565857, -0.045531947165727615, 0.06765807420015335, -0.022719725966453552, -0.007003869395703077, -0.06325669586658478, 0.031598690897226334, 0.006659386213868856, 0.09168975800275803, 0.0096790362149477, 0.014703418128192425, 0.06690236926078796, 0.11026232689619064, 0.01745789870619774, 0.03998439013957977, 0.031870972365140915, -0.04215298593044281, 0.02756570652127266, -0.030568575486540794, 0.03179355710744858, 0.025156382471323013, -0.01438856590539217, -0.029861612245440483, 0.021886400878429413, -0.04956301301717758, 0.011194763705134392, -0.011749674566090107, 0.058393217623233795, 0.05881727486848831, -0.028355460613965988, -0.019535062834620476, 0.01906834915280342, 0.013732033781707287, -0.05873972922563553, 0.03527993708848953, -0.019635243341326714, -0.008077532984316349, -0.0640384703874588, 0.060401737689971924, 0.06792015582323074, 0.0003172510187141597, -0.013375279493629932, 0.005334127694368362, 0.03635699674487114, 0.012814232148230076, -0.024169428274035454, -0.01410836074501276, -0.0023225988261401653, 0.012382017448544502, -0.07560393214225769, 0.01768958941102028, 0.00529114343225956, 0.024144180119037628, 0.010714521631598473, 0.05080042779445648, -0.033772457391023636, 0.020001687109470367, -0.019545594230294228, -0.05175390467047691, 0.03682294487953186, -0.0499458871781826, 0.059651557356119156, -0.005520773120224476, 0.03900628536939621, 0.019218165427446365, 0.009327915497124195, 0.05547000467777252, -0.047900114208459854, 0.06604966521263123, -0.054645415395498276, 0.03917884826660156, 0.027002783492207527, -0.031741343438625336, 0.02471124939620495, 0.003299048636108637, 0.005820154212415218, 0.026538535952568054, -0.050713248550891876, -0.04038791358470917, 0.10380139946937561, -0.02447829209268093, 0.06889870762825012, -0.02055210806429386, -0.032567646354436874, 0.08330687135457993, 0.029212169349193573, 0.008633051067590714, 0.05510205775499344, 0.026421349495649338, 0.0028720111586153507, -0.020848168060183525, -0.03252100199460983, 0.012157343327999115, -0.03520781174302101, -0.0662771463394165, -0.007118935231119394, 0.013631470501422882, 0.041531965136528015, -0.11590220779180527, 0.04272221028804779, -0.10596899688243866, -0.00391864450648427, -0.036421358585357666, -0.04436373710632324, -0.013493758626282215, 0.016339421272277832, -0.04308547079563141, 0.1703522950410843, -0.018225885927677155, -0.009024329483509064, -0.03242332488298416, -0.00760541670024395, 0.004312903620302677, 0.1109086200594902, 0.08190437406301498, 0.03915712982416153, -0.1168941929936409, -0.027024956420063972, -0.021975362673401833, -0.040743328630924225, 0.01216901745647192, -0.043259818106889725, -0.05149681493639946, 0.0839022621512413, -0.0022430671378970146, 0.030365925282239914, 0.011736064217984676, -0.008395303972065449, -0.03361165523529053, 0.006821809336543083, 0.017421312630176544, 0.00428188918158412, -0.02800382673740387, 0.0756639763712883, 0.028502576053142548, -0.06299202144145966, 0.027170836925506592, -0.030575314536690712, 0.04067423194646835, 0.02573540061712265, -0.021825697273015976, 0.007142953108996153, 0.06005305051803589, -0.011070535518229008, 0.0013950651045888662, -0.013908290304243565, 0.08634161949157715, 0.017164241522550583, -0.01889372244477272, -0.047853194177150726, -0.05412775278091431, -0.02280021458864212, -0.02766377106308937, 0.011255137622356415, 0.024870222434401512, 0.008138989098370075, 0.03319709002971649, 0.025270536541938782, -0.01558940764516592, 0.06221604719758034, -0.002268344396725297, 0.015620709396898746, 0.04466385766863823, 0.024144306778907776, 0.005871094763278961, -0.022106487303972244, -0.02340620383620262, 0.0009103142074309289, -0.018183358013629913, 0.012839226983487606, 0.037383340299129486, 0.00321238674223423, -0.0040339198894798756, -0.021459190174937248, -0.016844449564814568, -0.015586862340569496, 0.03296462073922157, 0.010271566919982433, 0.04363245889544487, 0.010266301222145557, -0.0467732734978199, -0.037279460579156876, 0.0251019150018692, 0.02041909657418728, -0.009442029520869255, 0.00024501036386936903, 0.04088345542550087, -0.03451604023575783, 0.021888650953769684, 0.0030379032250493765, 0.002586286747828126, -0.010664496570825577, 0.03660404309630394, -0.02423090487718582, 0.00009974070417229086, -0.09135761111974716, -0.04038318246603012, -0.031223537400364876, 0.02409312315285206, -0.007056216709315777, -0.017358412966132164, 0.046162378042936325, 0.015257121995091438, -0.0003036806592717767, -0.007178083527833223, 0.002790872473269701, 0.03294618800282478, 0.040310878306627274, 0.026351984590291977, -0.03759200498461723, 0.0067033362574875355, -0.005815682467073202, -0.01733226701617241, 0.06657732278108597, -0.012461504898965359, -0.02602032944560051, 0.04060492292046547, 0.028435902670025826, 0.004360412247478962, -0.02484254725277424, -0.03917637839913368, 0.033402375876903534, -0.0017732681008055806, 0.002225379226729274, -0.05452701821923256, -0.0057060434482991695, -0.0034520686604082584, -0.030322428792715073, -0.017105577513575554, -0.015815408900380135, -0.00843333825469017, -0.007937811315059662, 0.022185733541846275, -0.017107635736465454, 0.022866100072860718, -0.025075741112232208, 0.009602738544344902, 0.02206338383257389, 0.0064467778429389, 0.021256178617477417, -0.048126470297575, -0.031785838305950165, -0.020612897351384163, 0.02011387050151825, -0.04305003955960274, -0.0434417650103569, -0.029650596901774406, -0.006615379359573126, 0.03230379521846771, 0.012385603971779346, 0.018862172961235046, 0.04278750345110893, 0.01252829097211361, -0.019654417410492897, -0.018721221014857292, -0.055739156901836395, -0.030074818059802055, -0.05446480214595795, -0.021144529804587364, -0.019829638302326202, 0.036038532853126526, 0.0011972595239058137, 0.008413161151111126, -0.03783205524086952, 0.019785042852163315, -0.04634932056069374, 0.05880436673760414, -0.0039678714238107204, 0.002693434478715062, -0.007035449147224426, -0.01502997986972332, -0.032455071806907654, -0.05564607307314873, 0.03504911810159683, 0.027249731123447418, -0.03431912511587143, -0.023926101624965668, -0.019300110638141632, -0.0011914545902982354, 0.024916132912039757, -0.0002815071784425527, 0.03245992586016655, -0.053590260446071625, 0.03386394679546356, 0.03289279714226723, -0.009907331317663193, -0.03881313279271126, 0.010333032347261906, -0.013207335025072098, -0.02033918909728527, 0.024770649150013924, 0.04405155032873154, 0.009375903755426407, 0.006695362739264965, -0.011047313921153545, -0.017116358503699303, -0.04511651769280434, -0.01616787537932396, 0.012618397362530231, -0.017157798632979393, 0.006694306153804064, -0.04677916690707207, -0.06237570941448212, 0.03671741113066673, -0.032277803868055344, -0.022576836869120598, -0.008155298419296741, 0.0011817453196272254, -0.01302921399474144, 0.02986338920891285, 0.03630037233233452, -0.0227265153080225, 0.008677748963236809, -0.03585096076130867, 0.030563069507479668, -0.0060842218808829784, -0.000796094594988972, -0.00839210208505392, -0.0440974161028862, 0.018765460699796677, -0.014299439266324043, 0.03476976603269577, 0.028327135369181633, 0.012088637799024582, 0.010663115419447422, -0.007916430942714214, -0.043639782816171646, 0.025573698803782463, -0.027055222541093826, -0.004336652811616659, 0.042930617928504944, -0.02926601469516754, 0.01821633242070675, 0.0159061960875988, -0.002871464006602764, -0.025509554892778397, -0.027764039114117622, 0.019449206069111824, -0.00360919744707644, 0.020785456523299217, -0.0028576727490872145, -0.0749080628156662, 0.024031203240156174, -0.011177431792020798, 0.022748684510588646, 0.02037150412797928, 0.009744521230459213, -0.019695846363902092, 0.022209089249372482, 0.04607037827372551, 0.01416701078414917, 0.005459774285554886, 0.01823212206363678, -0.023330101743340492, 0.04904450103640556, -0.018794890493154526, -0.038378048688173294, 0.007784716784954071, 0.01982833445072174, -0.014093352481722832, -0.008548726327717304, -0.0054629091173410416, -0.06278715282678604, -0.03671678528189659, -0.03328496590256691, -0.01653255708515644, 0.014068666845560074, 0.04750498756766319, -0.03139973059296608, -0.024366049095988274, 0.05321387201547623, 0.06071626394987106, 0.04112248495221138, -0.03208674117922783, -0.011471076868474483, -0.0441659651696682, -0.04030923917889595, 0.04380365461111069, 0.003175176912918687, -0.0186372771859169, 0.04269535094499588, 0.0404285229742527, 0.04252041131258011, 0.016721870750188828, 0.005076843313872814, -0.008418578654527664, -0.04146873950958252, 0.020581256598234177, -0.01651611365377903, 0.002755384659394622, -0.05652661249041557, 0.015445373021066189, 0.010978558100759983, 0.003724670270457864, -0.02760545164346695, 0.017506597563624382, 0.0314740352332592, -0.008056554943323135, -0.005307396873831749, 0.0303004439920187, 0.008515486493706703, -0.008549604564905167, -0.032245274633169174, 0.07667368650436401, -0.046952422708272934, -0.0231836698949337, -0.03362388536334038, -0.018781930208206177, -0.011408801190555096, 0.01078413613140583, -0.029716426506638527, -0.021615633741021156, 0.02767084911465645, 0.025865502655506134, 0.04940783232450485, 0.0037677010986953974, -0.024363012984395027, -0.01017648633569479, -0.018127353861927986, 0.03154519945383072, -0.05010624974966049, 0.011718051508069038, -0.002278791042044759, 0.011322722770273685, 0.01396387629210949, 0.004371422342956066, -0.003641367657110095, -0.007014082744717598, 0.052221596240997314, -0.017188917845487595, 0.009570371359586716, -0.06602485477924347, 0.03127134591341019, 0.0635685920715332, -0.017747705802321434, -0.0062093595042824745, 0.012550953775644302, -0.032996613532304764, -0.010611431673169136, -0.004325114190578461, 0.052346229553222656, 0.06958100944757462, 0.031067494302988052, 0.012234263122081757, -0.002374120056629181, 0.0033057222608476877, 0.027823589742183685, -0.005533750634640455, 0.005722827278077602, 0.00580571498721838, 0.026496892794966698, 0.004353229887783527, 0.03297742083668709, 0.013663270510733128, 0.020184095948934555, 0.0009189706761389971, -0.07772602140903473, -0.03568045049905777, 0.015986522659659386, -0.024643724784255028, 0.02788560464978218, -0.007430126890540123, -0.06479638069868088, 0.007835257798433304, 0.005695736967027187, -0.002628532238304615, 0.05460786446928978, -0.0011424773838371038, 0.039266541600227356, -0.007131650578230619, -0.015471155755221844, 0.004354627337306738, 0.03460555151104927, -0.006415388081222773, 0.007477093953639269, 0.02474595606327057, 0.06204250082373619, 0.04070494696497917, 0.010204527527093887, 0.0358496718108654, 0.029463881626725197, 0.09772035479545593, 0.04346201568841934, 0.04827797785401344, 0.013481298461556435, -0.05605284124612808, 0.037178121507167816, -0.03415536880493164, -0.006759913172572851, -0.019814204424619675, 0.0035456956829875708, 0.03328419849276543, -0.01529959961771965, 0.031769759953022, -0.024537933990359306, 0.039177071303129196, -0.011044061742722988, -0.0222181286662817, 0.023733412846922874, 0.029877115041017532, 0.004320415202528238, -0.043575871735811234, -0.010038578882813454, 0.016362786293029785, -0.013286936096847057, -0.03161997348070145, 0.035360656678676605, 0.02113962545990944, 0.008251670747995377, 0.016934353858232498, -0.00637328764423728, 0.01393235381692648, -0.029523732140660286, -0.028186211362481117, 0.01660107634961605, -0.017498929053544998, -0.011442630551755428, -0.02834739349782467, 0.016635604202747345, -0.03943266719579697, 0.0012408253969624639, -0.04855900630354881, 0.04006608575582504, -0.019864467903971672, 0.006261845584958792, 0.029825080186128616, 0.02146836183965206, 0.031330615282058716, -0.006959664169698954, 0.027695491909980774, 0.03752642869949341, 0.017036734148859978, 0.003807046450674534, -0.01612881012260914, -0.015496672131121159, -0.04694705829024315, 0.013437916524708271, 0.01065231952816248, 0.003025757148861885, -0.016032453626394272, -0.03279092162847519, -0.01648646965622902, 0.003745059249922633, 0.028044141829013824, 0.0354253314435482, 0.01619560457766056, 0.03481186926364899, -0.00402727909386158, 0.014778949320316315, -0.004964921623468399, 0.04414965957403183, 0.01582171581685543, -0.01990167237818241, 0.006302704568952322, 0.009862287901341915, 0.02976536937057972, 0.008208091370761395, 0.029438907280564308, -0.016165154054760933, -0.04234463348984718, -0.030772434547543526, -0.013869884423911572, -0.04994682967662811, 0.06976346671581268, -0.017671311274170876, -0.004280406516045332, 0.02943349815905094, 0.008304599672555923, -0.001421961234882474, -0.018537411466240883, -0.01600324921309948, 0.037882979959249496, -0.003909835126250982, -0.03936487436294556, 0.007000925485044718, 0.021549398079514503, 0.01748497784137726, 0.023664375767111778, 0.02269560843706131, 0.0007586114224977791, 0.010525213554501534, 0.010825040750205517, 0.04269557446241379, -0.03713594004511833, -0.006790023762732744, -0.04570109769701958, -0.023353558033704758, -0.0011497385567054152, 0.03624622896313667, -0.007131760939955711, 0.02700134366750717, -0.04723585397005081, -0.016018351539969444, -0.0050547425635159016, -0.028879649937152863, -0.015011576004326344, -0.011404282413423061, 0.023873882368206978, 0.03391195461153984, -0.015782199800014496, 0.0308030154556036, -0.018143855035305023, 0.030521759763360023, -0.017856832593679428, 0.013798021711409092, 0.04764970391988754, -0.009732626378536224, 0.004201728384941816, -0.01792045682668686, -0.0090554878115654, 0.02024359069764614, -0.04797417297959328, 0.01207770500332117, 0.025246869772672653, 0.004252009093761444, -0.007543844636529684, -0.0012644627131521702, 0.03774625435471535, 0.0407705157995224, 0.003273204667493701, -0.03259189799427986, -0.020481599494814873, 0.006147449370473623, 0.023632515221834183, -0.05188225209712982, -0.025116881355643272, -0.02628827653825283, -0.005424116272479296, 0.025850441306829453, -0.010414011776447296, 0.040403373539447784, -0.03085385449230671, 0.019099920988082886, -0.004726853221654892, -0.04131787270307541, -0.013894131407141685, -0.041847456246614456, -0.03561573475599289, 0.06466242671012878, -0.01879354938864708, 0.005261008162051439, 0.020897775888442993, 0.030981475487351418, -0.02635914832353592, 0.021706687286496162, -0.037343114614486694, -0.018850689753890038, -0.028194554150104523, 0.018520746380090714, -0.04005390778183937, 0.030619798228144646, 0.03756743669509888, 0.002831315388903022, -0.029514160007238388, -0.005569771397858858 ]
Making automatic speech recognition work on large files with Wav2Vec2 in 🤗 Transformers
Narsil
February 1, 2022
asr-chunking
guide, research, audio
https://huggingface.co/blog/asr-chunking
# Making automatic speech recognition work on large files with Wav2Vec2 in 🤗 Transformers Tl;dr: This post explains how to use the specificities of the Connectionist Temporal Classification (CTC) architecture in order to achieve very good quality automatic speech recognition (ASR) even on arbitrarily long files or during live inference. Wav2Vec2 is a popular pre-trained model for speech recognition. Released in September 2020 by Meta AI Research, the novel architecture catalyzed progress in self-supervised pretraining for speech recognition, e.g. G. Ng et al., 2021, Chen et al, 2021, Hsu et al., 2021 and Babu et al., 2021. On the Hugging Face Hub, Wav2Vec2's most popular pre-trained checkpoint currently amounts to over 250,000 monthly downloads. Wav2Vec2 is at its core a transformers models and one caveat of transformers is that it usually has a finite amount of sequence length it can handle. Either because it uses position encodings (not the case here) or simply because the cost of attention in transformers is actually O(n²) in sequence_length, meaning that using very large sequence_length explodes in complexity/memory. So you cannot run with finite hardware (even a very large GPU like A100), simply run Wav2Vec2 on an hour long file. Your program will crash. Let's try it ! bash pip install transformers python from transformers import pipeline # This will work on any of the thousands of models at # https://huggingface.co/models?pipeline_tag=automatic-speech-recognition pipe = pipeline(model="facebook/wav2vec2-base-960h") # The Public Domain LibriVox file used for the test #!wget https://ia902600.us.archive.org/8/items/thecantervilleghostversion_2_1501_librivox/thecantervilleghostversion2_01_wilde_128kb.mp3 -o very_long_file.mp3 pipe("very_long_file.mp3") # Crash out of memory ! pipe("very_long_file.mp3", chunk_length_s=10) # This works and prints a very long string ! # This whole blogpost will explain how to make things work Simple Chunking --------------- The simplest way to achieve inference on very long files would be to simply chunk the initial audio into shorter samples, let's say 10 seconds each, run inference on those, and end up with a final reconstruction. This is efficient computationally but usually leads to subpar results, the reason being that in order to do good inference, the model needs some context, so around the chunking border, inference tends to be of poor quality. Look at the following diagram: There are ways to try and work around the problem in a general fashion, but they are never entirely robust. You can try to chunk only when you encounter silence but you may have a non silent audio for a long time (a song, or noisy café audio). You can also try to cut only when there's no voice but it requires another model and this is not an entirely solved problem. You could also have a continous voice for a very long time. As it turns out, CTC structure, which is used by Wav2Vec2, can be exploited in order to achieve very robust speech recognition even on very long files without falling into those pitfalls. Chunking with stride -------------------- Wav2Vec2 uses the CTC algorithm, which means that every frame of audio is mapped to a single letter prediction (logit). That's the main feature we're going to use in order to add a stride. This link explains it in the image context, but it's the same concept for audio. Because of this property, we can: - Start doing inference on overlapping chunks so that the model actually has proper context in the center. - Drop the inferenced logits on the side. - Chain the logits without their dropped sides to recover something extremely close to what the model would have predicted on the full length audio. This is not technically 100% the same thing as running the model on the whole file so it is not enabled by default, but as you saw in the earlier example you need only to add chunk_length_s to your pipeline for it to work. In practice, we observed that most of the bad inference is kept within the strides, which get dropped before inference, leading to a proper inference of the full text. Let's note that you can choose every argument of this technique: python from transformers import pipeline pipe = pipeline(model="facebook/wav2vec2-base-960h") # stride_length_s is a tuple of the left and right stride length. # With only 1 number, both sides get the same stride, by default # the stride_length on one side is 1/6th of the chunk_length_s output = pipe("very_long_file.mp3", chunk_length_s=10, stride_length_s=(4, 2)) Chunking with stride on LM augmented models ------------------------------------------- In transformers, we also added support for adding LM to Wav2Vec2 in order to boost the WER performance of the models without even finetuning. See this excellent blogpost explaining how it works. It turns out, that the LM works directly on the logits themselves, so we can actually apply the exact same technique as before without any modification ! So chunking large files on these LM boosted models still works out of the box. Live inference -------------- A very nice perk of using a CTC model like Wav2vec2, is that it is a single pass model, so it is very fast. Especially on GPU. We can exploit that in order to do live inference. The principle is exactly the same as regular striding, but this time we can feed the pipeline data as it is coming in and simply use striding on full chunks of length 10s for instance with 1s striding to get proper context. That requires running much more inference steps than simple file chunking, but it can make the live experience much better because the model can print things as you are speaking, without having to wait for X seconds before seeing something displayed.
[ 0.0054288567043840885, -0.04109491407871246, -0.007765893824398518, -0.03226766362786293, -0.007324103266000748, -0.015972398221492767, 0.03850492835044861, 0.02037283405661583, -0.04442163556814194, -0.05787810683250427, -0.0865907371044159, 0.08338895440101624, -0.029174696654081345, 0.0554882287979126, -0.02197924815118313, -0.06822233647108078, 0.06737540662288666, 0.0005712443962693214, -0.01269545778632164, 0.028952840715646744, -0.04595136269927025, -0.0054967342875897884, 0.06626460701227188, 0.04995531588792801, -0.04001075029373169, 0.030386753380298615, 0.018311211839318275, 0.031570371240377426, -0.01413324847817421, -0.005191038362681866, -0.15085822343826294, -0.028105249628424644, 0.024196822196245193, -0.021986939013004303, 0.0034191233571618795, 0.01902066543698311, -0.1235126331448555, 0.01920078881084919, 0.044240184128284454, -0.030381489545106888, 0.039315365254879, 0.0424579419195652, -0.07428105920553207, 0.011843114160001278, 0.04285185784101486, 0.04224503040313721, -0.08287815749645233, 0.05564114823937416, 0.012243043631315231, -0.06189853698015213, -0.022352008149027824, 0.09689296036958694, -0.04454316198825836, 0.03525080531835556, 0.02485758811235428, -0.00909595750272274, 0.006000668276101351, -0.02239174395799637, -0.03758611902594566, -0.00790386088192463, 0.017326554283499718, -0.07026289403438568, -0.03733494132757187, -0.014455367811024189, 0.053506672382354736, 0.01828880049288273, -0.0361948125064373, 0.06341881304979324, -0.030610179528594017, -0.0012686443515121937, 0.04459455981850624, 0.022693395614624023, 0.007770937867462635, -0.06984389573335648, -0.049874793738126755, 0.010312385857105255, 0.023974832147359848, 0.04336140677332878, 0.05649841949343681, 0.04767203703522682, 0.0005321471253409982, 0.06705216318368912, 0.05160578712821007, 0.03958987444639206, 0.02444734238088131, 0.00787922739982605, 0.03528749570250511, -0.063942551612854, -0.09787575155496597, -0.011324417777359486, 0.04197216406464577, -0.09328379482030869, -0.059513889253139496, -0.021318307146430016, -0.028905479237437248, 0.02122410759329796, -0.04686804488301277, 0.03366803005337715, 0.008975688368082047, -0.023970607668161392, 0.012447637505829334, -0.03139113262295723, 0.04820290580391884, -0.0785217434167862, -0.060257673263549805, 0.11769896745681763, -0.04533720389008522, 0.0014777692267671227, -0.03393634036183357, -0.0021996379364281893, -0.003675989108160138, -0.013061444275081158, -0.03128432109951973, 0.021690096706151962, -0.11105220764875412, -0.007556885480880737, 0.033861543983221054, -0.018334390595555305, 0.02413565292954445, 0.02196354791522026, -0.04295166954398155, 0.09848356992006302, 0.06524375826120377, -0.01168361958116293, 0.017569996416568756, -0.02137424424290657, 0.026478808373212814, -0.051177699118852615, 0.018951529636979103, -0.03947485610842705, 0.04793962836265564, -0.015053138136863708, 0.05546891689300537, 0.029622875154018402, 0.0068704052828252316, -0.012937947176396847, 0.027365846559405327, -0.04600413143634796, 0.02439805679023266, 0.005124974064528942, 0.011383119970560074, 0.04197606071829796, 0.028997786343097687, -0.013266438618302345, 0.08780580013990402, -0.02103433944284916, -0.07396206259727478, 0.04063234478235245, 0.023392846807837486, 0.029087645933032036, -0.09474228322505951, 0.08514150232076645, -0.038247328251600266, -0.09711156040430069, -0.012154101394116879, 0.05726252868771553, -0.009295844472944736, 0.029902668669819832, -0.055995117872953415, -0.00038255081744864583, 0.0022051106207072735, 0.02994793839752674, -0.049783531576395035, -0.023081626743078232, 0.00629009585827589, -0.07638926059007645, -0.009214024990797043, 0.004805558826774359, 0.02967149391770363, 0.03793976828455925, 0.03317246213555336, -0.018789855763316154, 0.030551301315426826, -0.052699506282806396, -0.007161819376051426, 0.046422019600868225, 0.007217493373900652, 0.08120439201593399, 0.01904897578060627, -0.08971177786588669, -0.036443207412958145, 0.0811685174703598, 0.006472405046224594, 0.05136477202177048, 0.058731306344270706, -0.012395579367876053, 0.0710097998380661, -0.021544000133872032, -0.0015611060662195086, 0.01852935180068016, 0.040691621601581573, -0.08564706891775131, 0.05003504455089569, 0.004800193477421999, 0.018802452832460403, 0.019568772986531258, 0.010810240171849728, 0.08099447190761566, 0.0375397764146328, 0.03765636682510376, 0.03417849540710449, 0.022620905190706253, 0.026105185970664024, 0.01014308724552393, -0.01859714835882187, 0.03624015301465988, -0.025122011080384254, -0.11589471995830536, 0.029450727626681328, 0.0206782016903162, 0.058173056691884995, -0.055204588919878006, 0.04254130274057388, -0.075544074177742, -0.06616608053445816, -0.06330648809671402, 0.010633585974574089, 0.043189384043216705, 0.005840796511620283, -0.034190766513347626, 0.06582267582416534, -0.08480874449014664, -0.049377117305994034, -0.03123345784842968, -0.06700410693883896, 0.06933017820119858, 0.02893529087305069, 0.06403766572475433, 0.05955539643764496, -0.07974836230278015, -0.04987715557217598, -0.04262346774339676, -0.09701251983642578, 0.0030667318496853113, 0.003930238075554371, -0.04349635913968086, 0.02681753598153591, 0.009890996851027012, -0.00626858975738287, 0.05868900939822197, -0.018087055534124374, -0.033107925206422806, -0.023989740759134293, 0.06409206241369247, -0.05410727858543396, -0.019326869398355484, 0.06825575977563858, 0.0157302375882864, 0.014713368378579617, 0.027026798576116562, -0.06611812859773636, 0.0676327496767044, -0.0445784367620945, -0.019534790888428688, -0.005341187585145235, 0.06628938019275665, 0.03613476827740669, -0.022111928090453148, -0.02651028148829937, 0.019362658262252808, -0.008097239769995213, 0.016255417838692665, -0.009394568391144276, -0.01683206669986248, -0.03242705017328262, -0.08962397277355194, 0.0013559635262936354, 0.020167449489235878, 0.03364884853363037, -0.004315796308219433, -0.020721707493066788, 0.006229247897863388, 0.00919006485491991, -0.01943408139050007, 0.013249500654637814, 0.03754972293972969, 0.028575701639056206, 0.02045837603509426, -0.0039070285856723785, -0.02895953692495823, -0.0021938318386673927, 0.001720636966638267, 0.02229589782655239, -0.015476811677217484, 0.02687370963394642, 0.011974163353443146, 0.02223893441259861, -0.013354511931538582, -0.022874878719449043, 0.013016192242503166, -0.004615472164005041, 0.05635673552751541, 0.031258486211299896, -0.04616270586848259, -0.0011659094598144293, 0.04184979200363159, 0.02768426015973091, -0.033121656626462936, 0.02780798263847828, 0.029141081497073174, -0.025100499391555786, -0.013043138198554516, -0.02216593362390995, 0.007304272148758173, -0.00020156735263299197, 0.00018754007760435343, 0.0028672812040895224, -0.0004741760203614831, -0.07669071108102798, -0.0015207843389362097, -0.0286822821944952, -0.021055901423096657, 0.023130405694246292, 0.002088171662762761, 0.02892959676682949, 0.005147458054125309, -0.00923825055360794, 0.015846775844693184, -0.007346291560679674, 0.04720133915543556, 0.02778223715722561, 0.012022568844258785, -0.0007737813866697252, -0.022112902253866196, -0.015312282368540764, -0.010876934044063091, 0.05227344110608101, 0.002036847174167633, -0.026504021137952805, 0.019060561433434486, -0.004053277894854546, 0.014636790379881859, -0.005721844732761383, 0.007803274784237146, 0.00843860860913992, 0.0078064617700874805, 0.019436679780483246, -0.042473405599594116, -0.017978955060243607, -0.050540532916784286, 0.005595913156867027, -0.0019107037223875523, -0.035698823630809784, -0.04500070959329605, -0.01184490229934454, 0.00814182497560978, 0.016335800290107727, -0.004149222280830145, 0.012049584649503231, -0.031533535569906235, -0.009454246610403061, -0.02135998196899891, 0.0176618080586195, 0.021804291754961014, 0.004054546821862459, -0.02175641991198063, 0.00368807977065444, -0.04890760779380798, -0.01605510339140892, -0.025839945301413536, -0.005450802855193615, 0.03532327711582184, 0.011665555648505688, -0.010339146479964256, 0.02528398111462593, 0.023886730894446373, 0.03154675289988518, -0.0522187165915966, -0.027223192155361176, 0.005218827165663242, 0.02038799226284027, -0.010782717727124691, 0.02451752871274948, 0.01878395304083824, 0.012491975910961628, -0.03752825781702995, 0.014233123511075974, 0.02015027403831482, 0.02203163132071495, 0.012000801973044872, 0.009400729089975357, -0.004046215210109949, -0.05353844165802002, 0.0377063974738121, -0.00398207176476717, -0.004787561018019915, 0.048522546887397766, 0.054743800312280655, -0.09350431710481644, -0.040311697870492935, -0.05215724930167198, 0.025223564356565475, 0.005950608290731907, 0.039939284324645996, 0.04532359912991524, -0.012408168986439705, 0.05754498392343521, -0.013055493123829365, 0.0015707487473264337, 0.029908563941717148, -0.03988714888691902, -0.043313849717378616, -0.022454416379332542, -0.03165210410952568, -0.005182955879718065, 0.017503688111901283, -0.00019378536671865731, -0.0326729416847229, -0.005962904542684555, -0.05285998806357384, -0.00409422442317009, -0.05284681171178818, 0.011170671321451664, 0.012717965990304947, -0.04460931941866875, -0.0039854105561971664, 0.012989915907382965, 0.007383125368505716, 0.0017134237568825483, -0.025257619097828865, 0.011387452483177185, 0.00423418777063489, 0.0315675362944603, -0.005854773335158825, -0.02499373070895672, -0.05056960880756378, -0.012218835763633251, 0.011565285734832287, -0.003652204992249608, 0.018535766750574112, -0.02277846448123455, 0.0016316486289724708, 0.04598614200949669, 0.01937118172645569, 0.03314086049795151, 0.012229262851178646, -0.025369159877300262, -0.0033626812510192394, -0.006967785302549601, 0.018271422013640404, 0.041002560406923294, -0.015132584609091282, -0.012898729182779789, -0.00043203646782785654, 0.012993400916457176, 0.017368245869874954, 0.009735737927258015, -0.0011773058213293552, -0.04489511623978615, -0.03777501359581947, -0.011839980259537697, -0.009455030784010887, 0.009630227461457253, -0.023408031091094017, -0.0039204484783113, -0.01138901337981224, -0.04607035219669342, 0.014618468470871449, 0.044317714869976044, -0.011581715196371078, 0.015140585601329803, 0.016677215695381165, 0.013524014502763748, -0.014448166824877262, -0.0026308586820960045, 0.024818994104862213, 0.0612182542681694, 0.04752180725336075, -0.0283192228525877, -0.0024928294587880373, -0.035608891397714615, 0.038951631635427475, 0.019266940653324127, 0.018543189391493797, -0.009239490143954754, -0.09226635843515396, -0.0024341410025954247, -0.00710061751306057, -0.053223904222249985, -0.009772371500730515, 0.027974754571914673, 0.017057064920663834, -0.023450102657079697, 0.033413201570510864, -0.00812226440757513, 0.015971798449754715, -0.031807057559490204, -0.024862123653292656, 0.0002974966773763299, -0.01110790390521288, -0.0011185675393790007, 0.007639765739440918, -0.002550777280703187, 0.01167457364499569, 0.017757700756192207, 0.10014400631189346, -0.006902957800775766, 0.019124887883663177, 0.03909073397517204, -0.02462066151201725, 0.024306390434503555, -0.03156764805316925, -0.0010055615566670895, -0.03969578817486763, 0.05690275505185127, 0.014584940858185291, -0.0491398461163044, -0.015778740867972374, 0.022668885067105293, 0.0382213331758976, -0.027271641418337822, -0.025047192350029945, -0.00006076782301533967, -0.005475959274917841, -0.010188983753323555, -0.014025503769516945, 0.0035118062514811754, -0.005013512447476387, 0.0075193773955106735, -0.00981555413454771, 0.001823817496187985, 0.002847494324669242, -0.021822912618517876, -0.005772984120994806, 0.0074138883501291275, 0.07224306464195251, 0.03470434620976448, 0.04708154872059822, -0.06824369728565216, -0.020164547488093376, -0.012926480732858181, -0.013243738561868668, 0.0038819247856736183, -0.021032817661762238, 0.029487572610378265, 0.01486204657703638, -0.01135084219276905, -0.019935576245188713, -0.014379181899130344, -0.023728108033537865, 0.014476376585662365, 0.053597137331962585, 0.0020566352177411318, -0.056842923164367676, -0.02364291250705719, 0.03176804259419441, 0.01673939824104309, -0.0007741717854514718, 0.007494308985769749, 0.0008741823839955032, -0.004141443874686956, 0.07124459743499756, -0.023729344829916954, -0.002539057284593582, 0.01627776026725769, -0.013109881430864334, -0.011011107824742794, -0.008149850182235241, 0.059508536010980606, 0.02908289059996605, -0.02357150986790657, -0.02045339159667492, -0.0007133864564821124, 0.01890392042696476, -0.0233146995306015, 0.038754984736442566, 0.02891099452972412, -0.0060660624876618385, -0.0026160485576838255, -0.10804558545351028, -0.025737235322594643, 0.021217314526438713, 0.01703302003443241, -0.013783151283860207, 0.0354839451611042, -0.029597807675600052, 0.017423180863261223, 0.059933874756097794, 0.024209288880228996, -0.022514140233397484, -0.02158045396208763, -0.008340499363839626, -0.0003135317820124328, -0.003271946217864752, 0.03702939674258232, 0.05304925516247749, 0.012578856199979782, -0.002429592190310359, 0.056031547486782074, 0.02236235700547695, 0.0412420928478241, -0.02623899094760418, -0.016002800315618515, 0.0371396541595459, 0.04763695225119591, 0.0008024648996070027, 0.029587775468826294, -0.013334043323993683, 0.007309460546821356, 0.0032585388980805874, 0.033138588070869446, -0.010603182949125767, -0.0077406978234648705, 0.024199141189455986, 0.010684841312468052, 0.0247635580599308, 0.0430852510035038, -0.049277715384960175, 0.08259932696819305, 0.016400357708334923, 0.03693258389830589, -0.009851454757153988, 0.03981045261025429, 0.03772478550672531, 0.018619462847709656, 0.0119888074696064, 0.015694938600063324, -0.01127887424081564, -0.007194214034825563, 0.03803081065416336, 0.016856346279382706, 0.07351775467395782, 0.030074182897806168, -0.03939414396882057, 0.02289377897977829, -0.03483249992132187, -0.011922202073037624, 0.02756471373140812, -0.022905567660927773, -0.017673274502158165, 0.0003850091015920043, 0.004892912693321705, -0.011645766906440258, 0.06165572628378868, -0.02541743963956833, -0.025374721735715866, 0.003673844737932086, -0.017293676733970642, -0.0030653653666377068, 0.026856081560254097, -0.012063504196703434, -0.043069809675216675, -0.002997141797095537, -0.026740483939647675, 0.028187220916152, 0.03302031010389328, -0.021469203755259514, -0.03640734404325485, 0.017324799671769142, -0.04776880890130997, 0.008049114607274532, 0.04190119355916977, -0.03235306590795517, -0.026008307933807373, -0.0004700175195466727, 0.020760465413331985, -0.011235370300710201, 0.006462906487286091, -0.005690795369446278, 0.010418111458420753, -0.033914580941200256, -0.003744580550119281, -0.015191290527582169, -0.005973138380795717, -0.01364897470921278, -0.0026831403374671936, 0.042398858815431595, 0.006367778405547142, -0.0037942526396363974, 0.05775522440671921, 0.024187447503209114, -0.008419645018875599, -0.05074985697865486, -0.026623642072081566, -0.026078607887029648, -0.0416627898812294, 0.06133439019322395, 0.019355183467268944, -0.009191560558974743, -0.023199213668704033, -0.041440993547439575, 0.014329089783132076, -0.002317842561751604, -0.03086794540286064, 0.01774471253156662, 0.018584121018648148, -0.005858391989022493, 0.009170779027044773, 0.02379302866756916, 0.07070399820804596, 0.043011877685785294, 0.008820862509310246, 0.002891582204028964, 0.0036080768331885338, -0.04042141139507294, -0.0026902363169938326, -0.027873462066054344, -0.025356397032737732, -0.055849816650152206, -0.027034690603613853, -0.02111407369375229, 0.019669929519295692, -0.026465248316526413, -0.004063011147081852, -0.0342203825712204, 0.02630033902823925, -0.05045432224869728, -0.007217967417091131, 0.0026224437169730663, 0.00014406970876734704, 0.0046485792845487595, 0.04342876002192497, 0.017001910135149956, 0.043029073625802994, -0.041623033583164215, 0.0006756513612344861, -0.016789907589554787, 0.008793307468295097, 0.05699363723397255, 0.0318734310567379, -0.017006635665893555, -0.02027849666774273, -0.03144565224647522, 0.013786626979708672, -0.035406436771154404, -0.02551019936800003, -0.03822474926710129, -0.02110842429101467, -0.018643995746970177, 0.07531018555164337, 0.011685460805892944, 0.0033226683735847473, 0.05796164646744728, -0.01138800848275423, -0.06083379313349724, 0.014569159597158432, -0.011718510650098324, -0.05006228759884834, 0.014334456995129585, 0.011793801560997963, 0.020278217270970345, 0.07509136199951172, 0.029792068526148796, 0.020134972408413887, 0.02674785628914833, -0.007216772064566612, 0.026395704597234726, -0.0011197862913832068, -0.04490993544459343, -0.051856376230716705, -0.02769828960299492, 0.026990290731191635, -0.03277178108692169, -0.03266460821032524, 0.07587526738643646, 0.0009218488703481853, -0.025078216567635536, -0.009374480694532394, -0.013472205027937889, 0.017822541296482086, 0.04156298562884331, 0.006362904794514179, -0.019587542861700058, 0.049933236092329025, 0.04024572670459747, 0.02770925872027874, -0.04200846329331398, 0.011899481527507305 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
1. Activate GPU and Install Dependencies As a first step, let's set up Google Colab to use a GPU (instead of CPU) to train the model much faster. You can do this by going to the menu, clicking on 'Runtime' > 'Change runtime type', and selecting 'GPU' as the Hardware accelerator. Once you do this, you should check if GPU is available on our notebook by running the following code: python import torch torch.cuda.is_available() Then, install the libraries you will be using in this tutorial: python !pip install datasets transformers huggingface_hub You should also install git-lfs to use git in our model repository: python !apt-get install git-lfs
[ 0.011694543994963169, -0.017759084701538086, 0.02023710310459137, 0.045290764421224594, 0.06041662395000458, 0.028068233281373978, -0.006564320530742407, 0.0556231364607811, 0.011276050470769405, -0.07516642659902573, -0.039701197296381, 0.08474145084619522, -0.025527451187372208, 0.08179103583097458, 0.03795245662331581, -0.06762360036373138, 0.05061253905296326, -0.017360899597406387, -0.0035734183620661497, 0.09149453788995743, 0.05809997394680977, -0.03097708895802498, 0.03737012296915054, 0.022879835218191147, -0.045445267111063004, -0.11436566710472107, 0.032787520438432693, 0.041009604930877686, -0.025362739339470863, 0.006896961946040392, -0.10210912674665451, 0.014184849336743355, 0.030936548486351967, -0.050404779613018036, -0.007698965258896351, 0.01580420695245266, -0.0991123616695404, 0.030645295977592468, 0.1200881376862526, -0.0052739097736775875, -0.020904984325170517, 0.01602470688521862, -0.06533069908618927, 0.081758052110672, -0.022881874814629555, -0.004982149228453636, -0.14593935012817383, 0.05784962698817253, -0.023900074884295464, -0.04739929735660553, -0.057732123881578445, 0.07135641574859619, 0.008995392359793186, -0.03056301362812519, 0.013612699694931507, 0.01301753893494606, -0.003248860128223896, -0.026627525687217712, -0.014249786734580994, -0.006712750997394323, 0.07668569684028625, 0.010395818389952183, -0.04506729170680046, 0.04432114586234093, 0.014410313218832016, -0.0464216023683548, -0.01502105314284563, -0.00368183059617877, -0.050942327827215195, -0.052740179002285004, 0.02452877350151539, -0.043345626443624496, -0.01672353968024254, -0.04108278825879097, -0.04233817383646965, -0.03201545029878616, 0.00164896622300148, 0.03534994646906853, 0.08957143872976303, 0.09591421484947205, -0.018226200714707375, -0.006442305166274309, 0.020874036476016045, 0.10223189741373062, 0.05252772942185402, 0.027753209695219994, 0.015101955272257328, -0.025554627180099487, -0.03159094974398613, 0.07943865656852722, 0.0073167323134839535, -0.085074283182621, -0.0014657131396234035, 0.019994346424937248, 0.07169413566589355, -0.029267024248838425, -0.006172808352857828, 0.029755929484963417, -0.009098915383219719, -0.044866181910037994, -0.0047476692125201225, -0.08486397564411163, 0.00022119932691566646, -0.029129382222890854, -0.02322668395936489, 0.0022705330047756433, -0.0738542228937149, -0.06311093270778656, -0.0380566343665123, -0.01821230538189411, -0.03232559561729431, -0.0062468512915074825, -0.02993646077811718, 0.0613618902862072, -0.08231523633003235, 0.06723938137292862, 0.013738810084760189, 0.006263265386223793, -0.02992800809442997, 0.04242433235049248, -0.03906462341547012, 0.12419309467077255, 0.032435424625873566, 0.041116006672382355, 0.007699924986809492, 0.09586098790168762, 0.0016817880095914006, 0.0198809877038002, -0.025891698896884918, -0.029105929657816887, 0.09815514087677002, -0.037580229341983795, 0.048591967672109604, -0.03761035203933716, 0.01027926430106163, -0.059502340853214264, -0.011418611742556095, -0.052618637681007385, -0.0286977868527174, 0.029604604467749596, 0.0031454868149012327, 0.049388498067855835, 0.00257773045450449, 0.054319266229867935, 0.06998942792415619, -0.052429646253585815, -0.08192285150289536, 0.062037110328674316, -0.01389262918382883, -0.01223714742809534, -0.1091308668255806, 0.06372017413377762, -0.06554987281560898, -0.027163684368133545, -0.017862746492028236, 0.10044148564338684, -0.017621159553527832, -0.018117545172572136, -0.05079992860555649, -0.007198312319815159, -0.03710601106286049, -0.024259110912680626, -0.08979776501655579, -0.00820076186209917, 0.032304078340530396, -0.04140602797269821, 0.0443669855594635, -0.01870349608361721, 0.03100593388080597, 0.00718182697892189, 0.003957461100071669, -0.04454248771071434, 0.049701008945703506, 0.00233388040214777, 0.0011181285372003913, 0.04947061464190483, 0.06220631301403046, 0.03480324521660805, -0.011872139759361744, -0.041904937475919724, -0.033009614795446396, 0.056132856756448746, -0.020739000290632248, 0.06773505359888077, 0.05336065962910652, -0.11674986034631729, 0.015428555198013783, -0.022380724549293518, 0.020203156396746635, -0.03063814528286457, 0.006029033567756414, -0.03817141428589821, 0.05279470607638359, -0.021617848426103592, 0.0526277981698513, -0.07250437885522842, -0.00113521923776716, 0.06797809153795242, 0.0035482007078826427, 0.03026885911822319, 0.018888745456933975, -0.035415101796388626, 0.034774620085954666, 0.009721596725285053, -0.008199005387723446, -0.014046522788703442, 0.006064590997993946, -0.08268710225820541, 0.046801526099443436, -0.017600800842046738, -0.044365204870700836, -0.13483957946300507, 0.0690888836979866, -0.044660672545433044, 0.020370380952954292, -0.03426704555749893, -0.011725959368050098, 0.009141560643911362, 0.04718542471528053, 0.010737313888967037, 0.14512906968593597, -0.031413812190294266, -0.0038960587698966265, -0.0016525324899703264, -0.04570192098617554, 0.02321334183216095, 0.08009940385818481, 0.039443790912628174, 0.07718531042337418, -0.044713299721479416, -0.0384913831949234, -0.09875959903001785, -0.0018833312205970287, 0.06373155862092972, -0.029529279097914696, -0.03580205887556076, -0.015580285340547562, -0.012278682552278042, -0.005821601953357458, -0.021046418696641922, 0.014253919012844563, -0.06154010444879532, -0.014230242930352688, -0.004607518669217825, 0.00016395254351664335, -0.017516981810331345, 0.034029725939035416, 0.03904832527041435, 0.03238127380609512, -0.05694015324115753, -0.036981429904699326, -0.0454271137714386, -0.02272484265267849, 0.030607115477323532, -0.0013950157444924116, 0.04408993199467659, -0.004836277570575476, -0.007706711068749428, 0.0011407305719330907, 0.0714162141084671, 0.00698896124958992, 0.007486173417419195, -0.051310304552316666, -0.03129754588007927, -0.02494901418685913, -0.022423075512051582, -0.0077303494326770306, -0.016864871606230736, -0.00020131428027525544, -0.010329198092222214, 0.005016741808503866, -0.008981041610240936, 0.04975423216819763, 0.019705072045326233, -0.004170226864516735, 0.03571942448616028, 0.003505636239424348, -0.014793342910706997, -0.040770404040813446, -0.056166864931583405, 0.012313668616116047, -0.04144429415464401, 0.023430779576301575, -0.0015871749492362142, 0.020862432196736336, 0.005261298269033432, -0.005443277303129435, -0.03839678689837456, -0.03101281262934208, 0.02159780077636242, -0.01713305152952671, 0.01936023123562336, 0.0009332905756309628, -0.04889054596424103, -0.0003870746004395187, -0.0013565038098022342, 0.009282139129936695, -0.031381938606500626, -0.01805870793759823, 0.024305814877152443, -0.029544493183493614, -0.02077270671725273, 0.03915403410792351, -0.03327949717640877, -0.031824979931116104, 0.026598896831274033, 0.0050810351967811584, 0.02437412552535534, -0.10420800000429153, -0.0372413732111454, -0.007992302998900414, 0.035418953746557236, 0.004903145134449005, -0.07265844196081161, 0.024391932412981987, 0.017809707671403885, -0.012408225797116756, -0.011435792781412601, -0.0362199991941452, 0.032685503363609314, 0.015915481373667717, 0.019110163673758507, -0.0030890482012182474, -0.004113712813705206, 0.02033834159374237, 0.005729192867875099, 0.011954553425312042, 0.026608817279338837, -0.0644683688879013, 0.041423242539167404, -0.015477652661502361, -0.0016560067888349295, -0.004759486764669418, 0.007077600806951523, 0.02214304357767105, 0.04108492657542229, 0.02056346833705902, -0.02636822685599327, -0.008603309281170368, -0.034058865159749985, -0.020553871989250183, 0.018419086933135986, -0.012429923750460148, 0.014081119559705257, -0.002401964971795678, 0.017442137002944946, 0.026010237634181976, 0.042128536850214005, 0.015847843140363693, 0.0067563531920313835, 0.01614515669643879, -0.023735487833619118, 0.02184927649796009, 0.004514961503446102, -0.015216297470033169, 0.010463781654834747, 0.01628483645617962, -0.01087026484310627, -0.029562000185251236, 0.021292228251695633, 0.019341301172971725, 0.01006285846233368, 0.0014985533198341727, 0.02488006092607975, -0.004667091649025679, 0.04583641514182091, 0.04661599174141884, -0.014159449376165867, -0.08945570886135101, 0.00903741642832756, 0.006877169478684664, -0.0029396559111773968, -0.020482027903199196, 0.02466464601457119, 0.03844748064875603, 0.0035346827935427427, -0.01765304058790207, 0.020928340032696724, -0.026304500177502632, 0.04061659798026085, 0.027777088806033134, 0.010001559741795063, -0.017512962222099304, -0.0021704197861254215, -0.016580188646912575, -0.026938660070300102, 0.06460104882717133, 0.054076410830020905, -0.03918289393186569, -0.06259463727474213, -0.010234144516289234, -0.02602829597890377, 0.00036956192343495786, 0.009344182908535004, 0.013825834728777409, -0.04348233714699745, 0.015732334926724434, 0.047311268746852875, -0.0011876887874677777, -0.027548767626285553, -0.0040049003437161446, -0.057198185473680496, 0.009837823919951916, -0.007775628939270973, 0.006877074018120766, 0.012460135854780674, -0.00479285791516304, 0.020328175276517868, -0.0003364946460351348, -0.017794394865632057, 0.007617602124810219, 0.03697159141302109, 0.01382217276841402, 0.040520079433918, -0.027589013800024986, -0.008343583904206753, -0.0005302518256939948, 0.005245553329586983, 0.016161290928721428, -0.00946845579892397, -0.011273415759205818, -0.028183676302433014, 0.025495557114481926, 0.03528956323862076, -0.023927584290504456, -0.022582100704312325, -0.035152532160282135, 0.041594065725803375, -0.039210245013237, 0.034553881734609604, -0.03362378478050232, -0.040949635207653046, 0.030257314443588257, 0.0270706657320261, 0.03372473269701004, 0.03663696348667145, -0.01618233695626259, 0.00416193762794137, -0.0362393856048584, -0.014084819704294205, 0.0060088541358709335, 0.020792558789253235, -0.0007560387020930648, 0.0009990219259634614, -0.0006330193718895316, -0.006033711135387421, -0.004571401048451662, -0.017304053530097008, -0.03456246480345726, 0.013587266206741333, 0.08092471957206726, -0.02567763440310955, 0.03284803032875061, 0.020892243832349777, -0.03408711776137352, 0.030130617320537567, -0.042305778712034225, 0.02311067096889019, 0.024393785744905472, -0.01925378479063511, -0.016585301607847214, 0.042921241372823715, 0.04092028737068176, 0.0005037799128331244, -0.014944961294531822, 0.035280149430036545, -0.0011575054377317429, 0.04680141061544418, -0.029716476798057556, -0.0060666888020932674, -0.008697512559592724, 0.0351039320230484, 0.007659886963665485, 0.0039449771866202354, 0.006164249032735825, -0.07979214191436768, -0.019929885864257812, -0.0020754686556756496, -0.01303012017160654, 0.008550534956157207, 0.00003806642416748218, -0.04978026822209358, 0.029969729483127594, 0.03453413024544716, 0.06235269457101822, 0.003955748397856951, -0.006904313340783119, 0.024826403707265854, -0.030932070687413216, -0.010622676461935043, 0.001365849282592535, 0.02257394604384899, 0.014953208155930042, 0.026181429624557495, 0.044877875596284866, 0.03611796721816063, 0.02241167053580284, 0.007129418198019266, -0.004005175083875656, -0.02394554764032364, 0.03167472407221794, -0.05132155120372772, 0.01008180808275938, -0.03513519838452339, -0.002769490471109748, 0.0267996396869421, -0.008261334151029587, -0.014468567445874214, 0.011647933162748814, 0.030660409480333328, -0.015667730942368507, -0.012858723290264606, 0.04950005188584328, 0.022571086883544922, -0.01833895593881607, -0.013867875561118126, 0.036325808614492416, -0.0017141507705673575, 0.014200928620994091, 0.00008440748206339777, -0.007095471955835819, -0.01673150807619095, -0.030314810574054718, -0.010378516279160976, -0.019554583355784416, 0.017733464017510414, 0.026113731786608696, 0.04825090244412422, -0.03379592299461365, 0.0005944675649516284, -0.01957373134791851, -0.007703395094722509, 0.018972480669617653, -0.03162800148129463, -0.007149125449359417, 0.04489612951874733, -0.02208825573325157, 0.028231196105480194, 0.044918615370988846, -0.004317651502788067, -0.01338682696223259, 0.05637819692492485, 0.03217345476150513, 0.01903730258345604, 0.027221890166401863, 0.005295462906360626, 0.054495908319950104, -0.0054397182539105415, -0.02471066080033779, -0.03400601074099541, -0.020406978204846382, 0.005976143293082714, -0.033971186727285385, 0.008978353813290596, 0.07639312744140625, 0.015851110219955444, 0.009732656180858612, -0.003284212900325656, 0.0265987329185009, 0.015215295366942883, 0.01845378242433071, 0.012915761210024357, -0.008216256275773048, -0.002098759403452277, 0.009250796400010586, -0.00909583643078804, 0.018744351342320442, 0.028063813224434853, 0.011979532428085804, -0.05524793267250061, 0.021777156740427017, 0.03585059568285942, -0.02399376593530178, 0.02083158679306507, -0.002521043410524726, -0.061681993305683136, -0.020292537286877632, 0.02811335027217865, 0.03788889944553375, 0.043839577585458755, -0.017915206030011177, 0.0007764209876768291, 0.002357048913836479, -0.019249655306339264, 0.032287079840898514, 0.06590941548347473, -0.05356377363204956, 0.032139044255018234, 0.02564915642142296, 0.04101010039448738, 0.01670094206929207, -0.010718462988734245, 0.013849102891981602, 0.028713511303067207, 0.07449062913656235, 0.009824126027524471, 0.044773321598768234, 0.02196396328508854, -0.002791582839563489, -0.04285293444991112, -0.032841380685567856, -0.02777916006743908, -0.01690632477402687, 0.005013999529182911, 0.026026049628853798, 0.0034735724329948425, -0.01267599780112505, -0.03389233350753784, 0.029046684503555298, 0.052868686616420746, 0.05854003131389618, -0.01091198530048132, 0.02162085473537445, 0.01953081600368023, 0.009276372380554676, 0.02511736936867237, 0.0026982331182807684, 0.00047792430268600583, 0.019356608390808105, 0.04541266709566116, 0.011684251949191093, 0.0610194131731987, 0.022050686180591583, -0.012378581799566746, -0.010354829020798206, 0.009285042062401772, -0.015855154022574425, 0.015670407563447952, 0.009541071020066738, -0.02003466710448265, -0.035933613777160645, -0.002680624835193157, -0.03998624160885811, 0.009213368408381939, -0.03885260224342346, -0.009423988871276379, -0.019540822133421898, -0.021897360682487488, -0.01612943597137928, 0.006960553582757711, 0.017619160935282707, 0.022958805784583092, 0.012460924685001373, 0.03289785981178284, -0.014698084443807602, -0.008065033704042435, -0.008727854117751122, -0.028605550527572632, -0.015253963880240917, -0.02190515026450157, -0.017420565709471703, 0.013840718194842339, -0.04603203386068344, 0.009647942148149014, -0.004945487715303898, 0.024466777220368385, -0.030704302713274956, 0.026243703439831734, 0.00729535985738039, 0.014705709181725979, -0.02036689780652523, 0.0452173575758934, -0.000015962310499162413, -0.028598133474588394, 0.06190083175897598, -0.031814537942409515, 0.013571206480264664, -0.02251316048204899, 0.03232099115848541, 0.04866870120167732, 0.011616336181759834, -0.0019555429462343454, -0.07986842095851898, 0.0030047991313040257, -0.009751349687576294, -0.04341075196862221, 0.04969232901930809, -0.004130292683839798, 0.00018212861323263496, 0.014919708482921124, 0.006137045565992594, 0.025143958628177643, 0.0018474310636520386, 0.02516995556652546, 0.028754428029060364, -0.0009656258043833077, -0.023061884567141533, -0.005746996495872736, 0.03186514973640442, 0.0034393302630633116, -0.008529461920261383, 0.04563009738922119, 0.02106434479355812, 0.008080867119133472, -0.019711855798959732, 0.027402784675359726, -0.03988567367196083, 0.014328749850392342, -0.03205367550253868, -0.041628576815128326, -0.013123196549713612, -0.024726135656237602, -0.013141880743205547, 0.016252584755420685, -0.032742924988269806, -0.015554684214293957, -0.003835734212771058, 0.011668739840388298, 0.011339211836457253, -0.00028554804157465696, 0.04187893122434616, 0.07621850073337555, 0.006259576417505741, -0.0019224112620577216, -0.045778706669807434, -0.007648258004337549, -0.0019790269434452057, 0.03509610518813133, 0.058265022933483124, 0.010450531728565693, -0.011986838653683662, -0.02213452383875847, -0.006621201988309622, 0.033856526017189026, -0.0373457632958889, 0.015961863100528717, -0.026329781860113144, -0.002265511080622673, -0.041520293802022934, -0.020565133541822433, 0.03454970568418503, 0.02943023480474949, 0.03294721618294716, -0.019316647201776505, -0.04580914229154587, 0.02356908470392227, 0.022504976019263268, -0.0468117818236351, -0.015869462862610817, -0.0178648941218853, -0.006668783258646727, -0.004183599259704351, -0.0011227866634726524, 0.013560843653976917, 0.004652934614568949, -0.02597011625766754, -0.008720209822058678, 0.023933855816721916, -0.03895184025168419, -0.05496000126004219, -0.027999643236398697, 0.043058495968580246, -0.03164025396108627, -0.03186104819178581, 0.016001351177692413, -0.005412525963038206, -0.00239242403768003, 0.005693749524652958, 0.010941128246486187, 0.018588155508041382, 0.004587420728057623, 0.029840512201189995, -0.023810237646102905, 0.043345075100660324, 0.0008077832171693444, -0.02673230692744255, -0.022980274632573128, -0.025804325938224792 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
3. Training the model Now that the preprocessing is done, you can go ahead and train your model 🚀 You will be throwing away the pretraining head of the DistilBERT model and replacing it with a classification head fine-tuned for sentiment analysis. This enables you to transfer the knowledge from DistilBERT to your custom model 🔥 For training, you will be using the Trainer API, which is optimized for fine-tuning Transformers🤗 models such as DistilBERT, BERT and RoBERTa. First, let's define DistilBERT as your base model: python from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased", num_labels=2) Then, let's define the metrics you will be using to evaluate how good is your fine-tuned model (accuracy and f1 score): python import numpy as np from datasets import load_metric def compute_metrics(eval_pred): load_accuracy = load_metric("accuracy") load_f1 = load_metric("f1") logits, labels = eval_pred predictions = np.argmax(logits, axis=-1) accuracy = load_accuracy.compute(predictions=predictions, references=labels)["accuracy"] f1 = load_f1.compute(predictions=predictions, references=labels)["f1"] return {"accuracy": accuracy, "f1": f1} Next, let's login to your Hugging Face account so you can manage your model repositories. notebook_login will launch a widget in your notebook where you'll need to add your Hugging Face token: python from huggingface_hub import notebook_login notebook_login() You are almost there! Before training our model, you need to define the training arguments and define a Trainer with all the objects you constructed up to this point: python from transformers import TrainingArguments, Trainer repo_name = "finetuning-sentiment-model-3000-samples" training_args = TrainingArguments( output_dir=repo_name, learning_rate=2e-5, per_device_train_batch_size=16, per_device_eval_batch_size=16, num_train_epochs=2, weight_decay=0.01, save_strategy="epoch", push_to_hub=True, ) trainer = Trainer( model=model, args=training_args, train_dataset=tokenized_train, eval_dataset=tokenized_test, tokenizer=tokenizer, data_collator=data_collator, compute_metrics=compute_metrics, ) Now, it's time to fine-tune the model on the sentiment analysis dataset! 🙌 You just have to call the train() method of your Trainer: python trainer.train() And voila! You fine-tuned a DistilBERT model for sentiment analysis! 🎉 Training time depends on the hardware you use and the number of samples in the dataset. In our case, it took almost 10 minutes using a GPU and fine-tuning the model with 3,000 samples. The more samples you use for training your model, the more accurate it will be but training could be significantly slower. Next, let's compute the evaluation metrics to see how good your model is: python trainer.evaluate() In our case, we got 88% accuracy and 89% f1 score. Quite good for a sentiment analysis model just trained with 3,000 samples!
[ 0.013693610206246376, 0.02622445859014988, -0.03851304575800896, -0.009906657040119171, 0.05415944382548332, 0.0913824737071991, 0.07455980777740479, 0.06016905978322029, -0.032565221190452576, -0.014704705215990543, -0.07378097623586655, 0.06509461253881454, 0.0011467492440715432, 0.0380777046084404, 0.04447551071643829, -0.0699104443192482, 0.07042349129915237, -0.01881868578493595, -0.012528541497886181, 0.029114533215761185, -0.011057945899665356, -0.08215836435556412, 0.015871118754148483, 0.04413890838623047, 0.005132698453962803, -0.0680621787905693, 0.09105150401592255, 0.05128534138202667, -0.07619224488735199, 0.020162882283329964, -0.10133374482393265, -0.029741644859313965, -0.047656022012233734, -0.05184914544224739, -0.007339663337916136, 0.03618063032627106, -0.0630844458937645, 0.03865975886583328, 0.0649009719491005, -0.01062210276722908, -0.04208782687783241, -0.0314592607319355, -0.03168383240699768, 0.03371182829141617, -0.014501933939754963, -0.06754012405872345, -0.13586367666721344, 0.06087449938058853, 0.01850888505578041, -0.06202191486954689, -0.04248204454779625, 0.09794136136770248, -0.019759804010391235, 0.03216870129108429, 0.01361861266195774, -0.020553940907120705, 0.011961841024458408, -0.03511705994606018, -0.00826309435069561, 0.0482601560652256, -0.016947979107499123, 0.03411095216870308, -0.05422534793615341, 0.029202373698353767, 0.03843682259321213, 0.04412142559885979, -0.034719567745923996, 0.03283236548304558, -0.08683687448501587, -0.0452713817358017, 0.031907036900520325, -0.068719282746315, -0.019827203825116158, -0.03291725367307663, -0.0066458783112466335, 0.015902291983366013, 0.009403733536601067, -0.0012212879955768585, -0.014297391287982464, 0.04094649478793144, -0.012451008893549442, -0.050111785531044006, 0.002208758145570755, 0.03185080736875534, 0.05980050563812256, 0.06129908189177513, 0.051491934806108475, -0.04752681776881218, -0.06150372698903084, 0.04942377284169197, -0.06277820467948914, -0.05765208974480629, -0.007763025350868702, 0.0007172243786044419, 0.07339123636484146, -0.001144585432484746, -0.048315245658159256, 0.006951000075787306, -0.03628184646368027, -0.0455007441341877, 0.02942528948187828, -0.05888049304485321, -0.0009614236187189817, -0.07045561820268631, -0.0050494433380663395, 0.06157028302550316, -0.0037096396554261446, -0.10082832723855972, -0.04509420692920685, 0.012608602643013, 0.015087535604834557, -0.01009872741997242, -0.012943637557327747, 0.0616815946996212, -0.09456915408372879, 0.026677340269088745, 0.011210634373128414, -0.02198110893368721, 0.010287896730005741, 0.012481067329645157, 0.031669918447732925, 0.055902134627103806, -0.00013229406613390893, -0.05151953920722008, -0.03859018534421921, 0.08016340434551239, -0.006934208795428276, 0.007447982206940651, 0.05952678248286247, -0.01962873712182045, -0.008853656239807606, -0.029214100912213326, 0.0654781386256218, -0.00022502988576889038, -0.030042000114917755, -0.09018008410930634, 0.008335631340742111, -0.0577583909034729, 0.06270363181829453, 0.04645514115691185, 0.015785537660121918, 0.08873037993907928, -0.07212328165769577, -0.04307786747813225, 0.0399174839258194, -0.005224195774644613, -0.04302801564335823, 0.06910116225481033, 0.010601055808365345, 0.04614075645804405, -0.11561700701713562, 0.021187137812376022, -0.016619252040982246, -0.07667717337608337, 0.022294573485851288, 0.09688816219568253, -0.06734831631183624, -0.03410102427005768, -0.08165594190359116, 0.04766884446144104, -0.007474993821233511, 0.03440853953361511, -0.048110317438840866, 0.0034718355163931847, 0.005308342631906271, -0.032774437218904495, 0.04115132987499237, 0.04756283015012741, 0.003213288728147745, 0.015744874253869057, 0.034133102744817734, -0.03439651429653168, 0.026614706963300705, -0.03744395822286606, 0.026593763381242752, 0.07379703968763351, 0.020737623795866966, 0.020372111350297928, -0.0379830040037632, -0.0065004900097846985, 0.018299899995326996, 0.10864810645580292, -0.005778457038104534, 0.05384846031665802, 0.052607808262109756, -0.07462403923273087, 0.01598561741411686, -0.05492817983031273, -0.07052536308765411, 0.02244979701936245, 0.00717557268217206, 0.00961003452539444, 0.059862758964300156, -0.013747168704867363, 0.07080427557229996, -0.03925696387887001, -0.03641632944345474, 0.06222276762127876, -0.024104317650198936, 0.008894694969058037, 0.03825938329100609, -0.02067018486559391, 0.04529528692364693, -0.026304734870791435, 0.012627625837922096, -0.028124546632170677, -0.03077908791601658, -0.030316242948174477, 0.023944387212395668, 0.039777547121047974, 0.01582702063024044, -0.1478586196899414, 0.009368371218442917, -0.0785837396979332, -0.04936177283525467, -0.026798337697982788, -0.02094634622335434, -0.03640773147344589, -0.01063329353928566, -0.025942325592041016, 0.1377997249364853, -0.04107919707894325, 0.0031734085641801357, 0.01397490780800581, -0.018699349835515022, 0.005269952584058046, 0.06482166051864624, 0.03909580782055855, 0.06856372952461243, -0.06770895421504974, -0.07734908163547516, -0.06453675031661987, -0.02316313236951828, 0.025258341804146767, -0.023494435474276543, -0.04141201451420784, 0.006008889991790056, 0.030945707112550735, -0.006369572598487139, 0.038992639631032944, -0.0006188554689288139, -0.00652170367538929, -0.029919283464550972, 0.05033276230096817, -0.00043863357859663665, 0.030720466747879982, 0.02481973171234131, 0.03194638714194298, -0.028339944779872894, -0.04181752726435661, -0.034850869327783585, 0.08357304334640503, -0.009270010516047478, 0.0031094574369490147, 0.031888771802186966, 0.006437994539737701, 0.0026908947620540857, 0.03537381440401077, -0.021344561129808426, 0.08226994425058365, 0.0002747965045273304, -0.01843567192554474, -0.026370037347078323, -0.019024567678570747, 0.011527306400239468, -0.03959357738494873, -0.023140568286180496, 0.008032731711864471, 0.022101430222392082, -0.001166404108516872, -0.0019456524169072509, -0.023134205490350723, 0.04512415826320648, 0.02300550788640976, 0.01689932495355606, 0.05361219495534897, 0.014249124564230442, 0.003416321938857436, -0.0061176917515695095, 0.00006833959923824295, -0.00501296017318964, -0.03899489715695381, 0.016110846772789955, 0.017397098243236542, -0.009561860002577305, -0.0025070393458008766, -0.00774950347840786, -0.024675685912370682, -0.02314394898712635, 0.03690847381949425, 0.0383220873773098, 0.03158880025148392, -0.015129944309592247, -0.040712665766477585, -0.005519117694348097, 0.01479722186923027, 0.010101847350597382, -0.0038628848269581795, 0.02403954043984413, 0.038337111473083496, -0.018679356202483177, -0.002449846128001809, -0.015617022290825844, 0.014764638617634773, -0.04162207990884781, 0.0143739003688097, 0.043156176805496216, 0.006944074761122465, -0.08570245653390884, -0.006870462093502283, 0.011826097965240479, 0.00664904061704874, 0.006679476238787174, -0.027340108528733253, 0.025469953194260597, -0.025699332356452942, -0.036276675760746, 0.019119085744023323, 0.019614659249782562, 0.03619522228837013, 0.029232531785964966, -0.003988597076386213, 0.006308343261480331, -0.027177004143595695, 0.021079985424876213, -0.03498051315546036, 0.03523643687367439, 0.04150157421827316, -0.035665176808834076, 0.047319527715444565, -0.009753399528563023, 0.0037818115670233965, -0.014051162637770176, -0.02126426436007023, 0.036333709955215454, -0.0032723569311201572, 0.02682403102517128, -0.025449195876717567, 0.028061117976903915, -0.00611109146848321, -0.02828516624867916, 0.005789404734969139, -0.022615836933255196, -0.03555350750684738, -0.012690743431448936, 0.04414014518260956, 0.0036896567326039076, 0.02269296906888485, 0.010426892898976803, 0.01937773823738098, -0.0075533427298069, 0.025867527350783348, 0.04817458987236023, -0.009001347236335278, 0.03169691935181618, -0.013482773676514626, -0.01685097999870777, -0.018519166857004166, -0.023635247722268105, -0.014301268383860588, -0.014091165736317635, 0.04758498817682266, -0.022872500121593475, 0.020379913970828056, 0.03120069019496441, 0.025713535025715828, 0.015223178081214428, -0.008909271098673344, -0.018264317885041237, 0.04746139794588089, -0.016063649207353592, -0.0159774087369442, 0.0015413325745612383, 0.028632527217268944, -0.011717802844941616, -0.021519552916288376, -0.004624095279723406, 0.04627275466918945, -0.010777443647384644, 0.053023431450128555, 0.018129272386431694, 0.007906940765678883, -0.025402557104825974, -0.01542116329073906, -0.04855957254767418, 0.006731330417096615, 0.024121636524796486, 0.027809584513306618, -0.0024871393106877804, -0.0009172570426017046, -0.019883453845977783, -0.04185645654797554, 0.044325098395347595, 0.004050219897180796, 0.0032828818075358868, -0.045780718326568604, 0.003522663377225399, 0.030320391058921814, 0.043730515986680984, 0.02950308844447136, -0.025218801572918892, -0.02508862130343914, -0.008893177844583988, -0.0028582150116562843, 0.01548831444233656, -0.006773860193789005, -0.0010824936907738447, 0.0065467762760818005, 0.06429695338010788, -0.009809485636651516, 0.007517486810684204, 0.020521944388747215, 0.026006724685430527, 0.005623369477689266, -0.06092014163732529, -0.06303279846906662, 0.05065169185400009, -0.0419984795153141, -0.008153526112437248, 0.029004188254475594, 0.023013895377516747, -0.04564706236124039, 0.030648693442344666, 0.03900192305445671, -0.04000949114561081, 0.007620536256581545, 0.0047441450878977776, 0.06425638496875763, -0.011979379691183567, 0.005422836635261774, -0.03160349279642105, -0.029245933517813683, 0.06746131926774979, 0.0024811190087348223, 0.0325276218354702, 0.03097560815513134, -0.032874513417482376, -0.03431593254208565, 0.011977322399616241, -0.04060987010598183, -0.0018455178942531347, 0.004826614633202553, 0.01050885021686554, 0.020039016380906105, -0.011797999031841755, 0.01090887002646923, 0.04339136928319931, 0.007729447912424803, -0.02905496023595333, -0.020397081971168518, 0.01697840355336666, -0.009418098255991936, 0.03444785624742508, -0.016932236030697823, -0.02680997923016548, 0.015642695128917694, -0.024437865242362022, 0.007360370829701424, -0.007917218841612339, 0.01555266696959734, -0.030098458752036095, -0.007183796726167202, 0.02097385749220848, -0.007992246188223362, -0.009843576699495316, -0.004620328079909086, -0.00009746461728354916, 0.03498438745737076, 0.007673300337046385, 0.018437886610627174, -0.02232966013252735, 0.012400731444358826, 0.013279769569635391, 0.01990719698369503, -0.01974775455892086, -0.043101441115140915, -0.0066966647282242775, 0.009390311315655708, -0.010670519433915615, 0.03261737897992134, 0.006892233621329069, -0.03697632625699043, 0.012025709263980389, 0.07007939368486404, 0.01655745506286621, -0.008659157902002335, -0.03465578332543373, 0.014039023779332638, -0.017389358952641487, -0.01572788879275322, -0.013544571585953236, 0.009082971140742302, -0.004328315146267414, 0.032767750322818756, 0.05138387158513069, 0.021526118740439415, -0.011616072617471218, 0.005049940664321184, 0.006451230961829424, -0.017784928902983665, 0.020579885691404343, -0.05519687384366989, -0.017955999821424484, -0.02848220244050026, -0.02276785299181938, 0.02301090583205223, -0.04569287598133087, -0.03260194510221481, -0.008520281873643398, 0.04878807067871094, -0.02016368880867958, 0.006298291962593794, 0.04707846790552139, 0.013306941837072372, -0.03362710028886795, -0.05270496383309364, 0.03157844394445419, -0.026294348761439323, 0.007207935210317373, 0.0023364508524537086, 0.02332337573170662, 0.0215724129229784, 0.0070782252587378025, -0.014611355029046535, -0.037481579929590225, 0.038027387112379074, 0.057649221271276474, 0.02116698957979679, -0.020279597491025925, -0.030228473246097565, -0.025204133242368698, 0.012154598720371723, -0.005492482800036669, -0.07065796852111816, 0.02193409577012062, 0.008869048207998276, -0.018426965922117233, 0.029790936037898064, 0.009959409013390541, -0.01532779261469841, 0.00643913121894002, 0.03398175537586212, 0.03897065669298172, -0.04273885861039162, -0.042563870549201965, 0.032559238374233246, 0.017958644777536392, -0.047923844307661057, 0.0011760641355067492, -0.016406096518039703, -0.014556250534951687, -0.006506461650133133, -0.028230814263224602, 0.010543313808739185, 0.04070647805929184, -0.0284190122038126, 0.028369002044200897, 0.015331011265516281, 0.018687738105654716, 0.002313258359208703, -0.0034639216028153896, 0.005323505960404873, 0.004351531155407429, 0.032173752784729004, -0.009913919493556023, 0.003998953383415937, 0.034192029386758804, 0.01557918917387724, -0.0010989373549818993, -0.06895402073860168, 0.020456761121749878, -0.008568794466555119, -0.01296471431851387, 0.017259811982512474, -0.008035831153392792, -0.06644705682992935, 0.010094239376485348, 0.015434793196618557, 0.01947171799838543, 0.0180130023509264, 0.01812986470758915, 0.012601316906511784, 0.02006351761519909, -0.03822878375649452, -0.005604186095297337, 0.0720997080206871, -0.02323722094297409, -0.005181850399821997, 0.013225454837083817, 0.015741044655442238, 0.06256542354822159, 0.044608086347579956, 0.005402266979217529, -0.013522552326321602, 0.027010634541511536, 0.04248528182506561, 0.004555025603622198, 0.0501781702041626, 0.0035135119687765837, 0.007673017680644989, -0.05604249984025955, -0.0267183855175972, -0.0034579115454107523, -0.000480402639368549, 0.05154372379183769, -0.0012373144272714853, 0.005935035180300474, -0.004747570957988501, 0.07044943422079086, 0.042678143829107285, 0.04923750460147858, -0.01032930426299572, 0.05308900028467178, 0.055430151522159576, 0.04413748160004616, 0.0001842110068537295, 0.013038446195423603, -0.007139476016163826, -0.07140681147575378, -0.0028287421446293592, 0.005247151479125023, 0.023308753967285156, 0.021074283868074417, -0.001590666244737804, 0.035470061004161835, -0.00107227498665452, -0.010369048453867435, 0.06254369765520096, -0.010036175139248371, 0.015064205043017864, -0.02434317208826542, 0.03372376412153244, -0.023838579654693604, 0.03971492871642113, 0.020365789532661438, 0.010053638368844986, 0.023559989407658577, -0.010488247498869896, -0.018300388008356094, 0.05287419259548187, 0.017204053699970245, -0.03735516592860222, -0.01635560765862465, 0.00045004169805906713, 0.008074011653661728, 0.00012385657464619726, -0.013592258095741272, -0.05726860091090202, -0.06492985039949417, -0.030679665505886078, -0.02614557556807995, 0.05446687340736389, -0.0012240165378898382, -0.019258417189121246, -0.006322820205241442, -0.007342651952058077, 0.0062525467947125435, 0.0032834226731210947, 0.0033654682338237762, 0.008999460376799107, -0.016026657074689865, 0.018352968618273735, 0.017230521887540817, -0.032722409814596176, 0.024997808039188385, -0.03752894699573517, 0.0028099389746785164, 0.03227802738547325, 0.03659500926733017, -0.00411313446238637, 0.048548705875873566, -0.0676698088645935, -0.0174698643386364, 0.022838259115815163, 0.04536835104227066, -0.013740001246333122, 0.03829420357942581, 0.011450664140284061, 0.015360509045422077, 0.012754182331264019, -0.03312945365905762, -0.036395568400621414, 0.006129900924861431, 0.0004218493413645774, 0.06474515050649643, -0.02027319185435772, -0.057244475930929184, 0.005638818256556988, 0.011402865871787071, 0.020195653662085533, 0.008292202837765217, 0.05832298472523689, -0.005496960133314133, 0.04110492393374443, -0.053608864545822144, 0.035353921353816986, -0.04265297204256058, -0.0036212655249983072, -0.05005064234137535, -0.02360711619257927, -0.0010314175160601735, 0.009808743372559547, -0.027999594807624817, 0.018110550940036774, -0.055474620312452316, -0.0012061985908076167, -0.08278410136699677, -0.03162255883216858, 0.029497351497411728, 0.017169330269098282, 0.06344301253557205, 0.052987389266490936, 0.00014100309635978192, 0.029364963993430138, -0.0605500303208828, 0.0015354554634541273, -0.013409965671598911, -0.004508740268647671, 0.010291808284819126, -0.009836040437221527, 0.008003167808055878, -0.01873202994465828, 0.00024158002634067088, 0.029776008799672127, -0.045145947486162186, -0.03167679160833359, 0.004730120301246643, -0.02142273262143135, -0.03701619803905487, -0.008896877057850361, 0.04151620715856552, 0.003433879464864731, 0.04089650511741638, -0.014262355864048004, -0.030669910833239555, 0.015485409647226334, 0.02963702753186226, -0.07140257209539413, 0.04196295142173767, -0.026772743090987206, 0.006340449210256338, 0.03396863862872124, 0.01121362391859293, 0.026679305359721184, 0.011291513219475746, -0.0006741933757439256, 0.012309856712818146, 0.002180673647671938, -0.021569272503256798, -0.04871238023042679, 0.009330343455076218, 0.05690843239426613, -0.011498450301587582, -0.049232497811317444, 0.013407034799456596, -0.010970942676067352, -0.04060754552483559, -0.016248591244220734, -0.033478911966085434, 0.02669084630906582, 0.023214126005768776, 0.002862073015421629, -0.03681593015789986, 0.04849874600768089, 0.024543317034840584, -0.011468994431197643, -0.04740285500884056, 0.005461947526782751 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
2. How to Use Pre-trained Sentiment Analysis Models with Python Now that we have covered what sentiment analysis is, we are ready to play with some sentiment analysis models! 🎉 On the Hugging Face Hub, we are building the largest collection of models and datasets publicly available in order to democratize machine learning 🚀. In the Hub, you can find more than 27,000 models shared by the AI community with state-of-the-art performances on tasks such as sentiment analysis, object detection, text generation, speech recognition and more. The Hub is free to use and most models have a widget that allows to test them directly on your browser! There are more than 215 sentiment analysis models publicly available on the Hub and integrating them with Python just takes 5 lines of code: python pip install -q transformers from transformers import pipeline sentiment_pipeline = pipeline("sentiment-analysis") data = ["I love you", "I hate you"] sentiment_pipeline(data) This code snippet uses the pipeline class to make predictions from models available in the Hub. It uses the default model for sentiment analysis to analyze the list of texts data and it outputs the following results: python [{'label': 'POSITIVE', 'score': 0.9998}, {'label': 'NEGATIVE', 'score': 0.9991}] You can use a specific sentiment analysis model that is better suited to your language or use case by providing the name of the model. For example, if you want a sentiment analysis model for tweets, you can specify the model id: python specific_model = pipeline(model="finiteautomata/bertweet-base-sentiment-analysis") specific_model(data) You can test these models with your own data using this Colab notebook: The following are some popular models for sentiment analysis models available on the Hub that we recommend checking out: - Twitter-roberta-base-sentiment is a roBERTa model trained on ~58M tweets and fine-tuned for sentiment analysis. Fine-tuning is the process of taking a pre-trained large language model (e.g. roBERTa in this case) and then tweaking it with additional training data to make it perform a second similar task (e.g. sentiment analysis). - Bert-base-multilingual-uncased-sentiment is a model fine-tuned for sentiment analysis on product reviews in six languages: English, Dutch, German, French, Spanish and Italian. - Distilbert-base-uncased-emotion is a model fine-tuned for detecting emotions in texts, including sadness, joy, love, anger, fear and surprise. Are you interested in doing sentiment analysis in languages such as Spanish, French, Italian or German? On the Hub, you will find many models fine-tuned for different use cases and ~28 languages. You can check out the complete list of sentiment analysis models here and filter at the left according to the language of your interest.
[ 0.012903498485684395, -0.039145033806562424, 0.009456533938646317, -0.010259449481964111, 0.031114544719457626, 0.1391584575176239, 0.026510991156101227, 0.09188981354236603, 0.007702942937612534, -0.0075383963994681835, -0.06842266768217087, 0.09488577395677567, -0.023430069908499718, 0.05545978248119354, 0.032715797424316406, -0.08477064222097397, 0.06100759282708168, 0.03591302037239075, -0.005002455785870552, 0.03790275380015373, -0.009537101723253727, -0.05701598525047302, 0.020622126758098602, -0.0059159137308597565, 0.013620012439787388, -0.0594043992459774, 0.109403595328331, 0.041587844491004944, -0.07023845613002777, -0.029321955516934395, -0.10333076864480972, 0.03969699889421463, -0.03557213395833969, -0.011258469894528389, 0.022324254736304283, 0.06558375805616379, -0.10096468776464462, 0.08785202354192734, 0.03938910737633705, 0.030880803242325783, -0.00451374938711524, -0.048270244151353836, -0.03514398634433746, 0.02470303513109684, -0.009897096082568169, -0.047509048134088516, -0.1443430483341217, 0.10055544227361679, 0.02020236663520336, -0.03576482832431793, -0.0550251267850399, 0.13400687277317047, -0.014221318066120148, 0.00449327751994133, 0.0012842052383348346, -0.01919236220419407, -0.021272221580147743, -0.07315325736999512, 0.01615964062511921, 0.05431753396987915, 0.018927371129393578, 0.02864926867187023, -0.015210275538265705, 0.02413015253841877, 0.023632243275642395, 0.020752083510160446, -0.06623056530952454, 0.05169019103050232, -0.05794428661465645, -0.04943786561489105, 0.0033930393401533365, -0.03764130920171738, -0.03348754718899727, -0.042961250990629196, -0.013305183500051498, -0.014374862425029278, -0.0000044265557335165795, 0.008547009900212288, 0.013499499298632145, 0.008044609799981117, 0.0185798779129982, -0.017814207822084427, 0.012740795500576496, 0.015646925196051598, 0.10784073173999786, 0.05447689816355705, 0.05194390192627907, -0.0013754817191511393, -0.06167992949485779, 0.09523025155067444, -0.037133753299713135, -0.07960446923971176, 0.03560592606663704, -0.03362647071480751, 0.034049876034259796, -0.01565953902900219, -0.01751195453107357, 0.03735653683543205, -0.022822534665465355, -0.0006045090267434716, 0.005420248955488205, -0.056703198701143265, 0.029177159070968628, -0.06894291937351227, -0.00026314513524994254, 0.05320976302027702, 0.031110582873225212, -0.053926654160022736, -0.016755860298871994, -0.02048736810684204, 0.0009405454038642347, -0.04307364672422409, -0.024287434294819832, 0.0764613077044487, -0.07957365363836288, 0.04781294986605644, 0.019114147871732712, -0.007417884189635515, -0.009820017963647842, 0.01013780664652586, 0.009024355560541153, 0.06899354606866837, 0.040220730006694794, -0.01524670235812664, -0.01289334986358881, 0.08635924756526947, -0.00997763592749834, 0.015553085133433342, 0.04803317412734032, -0.024562453851103783, 0.03960518538951874, 0.017122026532888412, 0.0720004215836525, -0.00947008840739727, -0.03275042027235031, -0.05260448902845383, -0.0036925124004483223, -0.08700788021087646, 0.05106589198112488, -0.005833042785525322, 0.0006038987194187939, 0.07556173950433731, -0.07423903048038483, 0.029214518144726753, 0.06297016888856888, 0.006979095749557018, -0.07105035334825516, 0.07245172560214996, 0.0034087400417774916, 0.004450541455298662, -0.132286936044693, 0.03119741566479206, -0.01751129701733589, -0.07909458130598068, -0.02736723981797695, 0.06523331254720688, -0.03341463953256607, -0.05543673783540726, -0.03180459141731262, 0.001698161824606359, 0.027354901656508446, 0.04435543343424797, -0.04793187230825424, 0.0017073698109015822, 0.03186926618218422, -0.00016701314598321915, 0.012369265779852867, 0.006247819866985083, 0.023548118770122528, 0.05503841117024422, 0.04360278695821762, -0.04112349450588226, 0.12144062668085098, -0.03126150742173195, 0.027131885290145874, 0.03612105920910835, 0.019696807488799095, -0.014290062710642815, -0.008458897471427917, -0.00532059371471405, -0.025065794587135315, 0.10639554262161255, 0.0017117415554821491, 0.012612072750926018, 0.06548798084259033, -0.07740473747253418, 0.023394862189888954, -0.06527266651391983, -0.0076219444163143635, 0.01402364857494831, -0.005102234426885843, -0.0033894020598381758, 0.04021501913666725, 0.021728776395320892, 0.06577426940202713, -0.04702414199709892, 0.009357777424156666, 0.07608257234096527, 0.012985501438379288, -0.016644950956106186, 0.0514981746673584, -0.05448132008314133, 0.0533551350235939, -0.023092038929462433, 0.020973557606339455, -0.00611915672197938, -0.026781490072607994, -0.02061431296169758, 0.016753342002630234, 0.009199902415275574, 0.022780202329158783, -0.09778943657875061, 0.015078241936862469, -0.04720456153154373, 0.004791900049895048, -0.023882538080215454, -0.034931883215904236, 0.01344761811196804, -0.00019762849842663854, -0.005660548340529203, 0.16920316219329834, -0.004683662671595812, 0.017313212156295776, -0.03851866349577904, -0.03770093992352486, 0.006411300972104073, 0.04772593453526497, 0.0718168392777443, 0.0635545626282692, -0.03448042646050453, -0.030601827427744865, -0.05407531559467316, -0.0024651088751852512, -0.004633309319615364, -0.05564478412270546, -0.041297659277915955, 0.04167236387729645, 0.004796368069946766, -0.030021771788597107, 0.005319471005350351, -0.010673659853637218, -0.005452478304505348, -0.0440102256834507, 0.08181852102279663, -0.028165500611066818, 0.003626273013651371, 0.06070968136191368, 0.0001604664430487901, -0.05635473504662514, 0.003472114447504282, -0.05104633793234825, 0.039016105234622955, -0.00739445723593235, -0.009111749939620495, 0.01557519193738699, 0.030214529484510422, 0.03661392629146576, 0.022966761142015457, -0.0101386196911335, 0.0628335177898407, 0.00309600867331028, -0.024512948468327522, -0.012228023260831833, -0.041474610567092896, 0.013370257802307606, -0.03379897400736809, -0.008819003589451313, -0.021170277148485184, -0.006962898653000593, 0.017239756882190704, 0.015062661841511726, -0.028660211712121964, 0.04268795624375343, 0.018004992976784706, -0.0038116660434752703, 0.06460411101579666, 0.0016783428145572543, 0.025063227862119675, -0.03924191743135452, -0.02742871642112732, -0.01276424527168274, -0.04224352538585663, 0.011171605437994003, 0.005061859264969826, 0.017126772552728653, -0.03019227273762226, -0.025537285953760147, -0.048335880041122437, -0.005381315015256405, 0.03982273116707802, 0.035872627049684525, 0.031865861266851425, -0.020340120419859886, -0.04001603275537491, -0.018417539075016975, 0.018808025866746902, 0.004325452726334333, 0.04140332713723183, -0.008100881241261959, 0.06304194033145905, -0.010086914524435997, -0.011177659966051579, -0.01604451984167099, -0.012922641821205616, -0.050001583993434906, 0.02014889195561409, 0.05499119311571121, 0.023523898795247078, -0.09112849086523056, 0.0025068356189876795, 0.0039891572669148445, -0.013033256866037846, 0.014764908701181412, -0.041840244084596634, 0.08016450703144073, 0.0012554284185171127, -0.022395538166165352, 0.02596339024603367, -0.013361294753849506, 0.017103765159845352, 0.00401628902181983, 0.03110882081091404, -0.037544962018728256, -0.016984939575195312, -0.01761281117796898, -0.000004935966899211053, 0.05244675651192665, 0.049701325595378876, -0.058469828218221664, 0.04372527822852135, -0.00399607652798295, -0.003538355464115739, -0.04434138536453247, -0.019122878089547157, 0.02764599584043026, -0.005945504643023014, 0.052346207201480865, -0.022625217214226723, 0.03246382996439934, -0.0472753532230854, -0.03206269443035126, 0.014208401553332806, -0.02568287029862404, -0.014690572395920753, 0.0012741161044687033, 0.031180087476968765, 0.020078402012586594, 0.024578101933002472, -0.030994506552815437, 0.009986165910959244, 0.02045985497534275, 0.0074608162976801395, 0.023251643404364586, -0.0018798874225467443, -0.027188744395971298, -0.01759421080350876, -0.017917374148964882, -0.019260544329881668, -0.04732803627848625, -0.018359702080488205, -0.014036549255251884, 0.03966797888278961, 0.00403720373287797, 0.010510090738534927, 0.011765263974666595, 0.01584981009364128, -0.007746507879346609, 0.0005452920449897647, -0.04600995406508446, 0.02763546071946621, -0.017221417278051376, -0.026877189055085182, -0.027829274535179138, -0.015794990584254265, 0.01648603193461895, 0.010234087705612183, 0.03125106915831566, 0.02294723130762577, -0.004183213692158461, 0.041696272790431976, 0.006740738172084093, 0.011460097506642342, -0.03564347326755524, 0.0022541084326803684, -0.012172503396868706, -0.018123621121048927, 0.04288493096828461, 0.03609362989664078, 0.004766521044075489, -0.04311762750148773, -0.03381701931357384, -0.04088230058550835, 0.018664637580513954, -0.0031482328195124865, 0.027832234278321266, -0.0448395311832428, 0.023187121376395226, 0.055546775460243225, 0.005872892215847969, -0.013722289353609085, -0.003246554872021079, -0.004273875616490841, -0.021857550367712975, -0.00671949191018939, 0.012360639870166779, -0.010623941197991371, -0.013156067579984665, -0.010533913038671017, 0.059413522481918335, 0.0074902791529893875, -0.03197717294096947, -0.010953686200082302, 0.05202767997980118, 0.03499482199549675, -0.06676413118839264, -0.029303742572665215, 0.01464361697435379, -0.03689456731081009, -0.010431977920234203, 0.014251225627958775, 0.024964865297079086, -0.010971146635711193, 0.0410006158053875, 0.03902494162321091, -0.013631178066134453, -0.006936352699995041, -0.013966416008770466, 0.0363478921353817, -0.022983677685260773, -0.0013811941025778651, -0.04355856776237488, -0.025651825591921806, 0.024205602705478668, 0.004189825616776943, 0.06364475190639496, 0.016565747559070587, -0.019769294187426567, -0.012293379753828049, 0.015030059032142162, -0.0284107718616724, 0.004128959029912949, 0.0016601142706349492, 0.004022759385406971, -0.018488166853785515, -0.011049316264688969, -0.01602238602936268, 0.01764756254851818, -0.017269426956772804, -0.017789285629987717, -0.02449437603354454, 0.029385695233941078, 0.009731043130159378, 0.02653244324028492, -0.00989723764359951, -0.05304929241538048, -0.013427810743451118, -0.01216417271643877, -0.007611933164298534, 0.027061039581894875, 0.015807993710041046, -0.04032975062727928, -0.03267684206366539, 0.03239944204688072, -0.03489759936928749, -0.021353820338845253, 0.02919318899512291, 0.00822544563561678, 0.05492933839559555, 0.023487690836191177, -0.009313900955021381, -0.008500351570546627, 0.019102146849036217, -0.015018540434539318, -0.027287796139717102, -0.014180113561451435, -0.059908077120780945, -0.01696615107357502, 0.024257108569145203, -0.008143401704728603, 0.014110404998064041, 0.017994321882724762, -0.040761806070804596, 0.0024811027105897665, 0.05525888502597809, 0.019650883972644806, -0.01802927255630493, -0.04267871379852295, 0.02819412760436535, -0.044621121138334274, -0.014866524375975132, -0.01090236660093069, 0.03066469170153141, -0.007186871487647295, 0.0417204312980175, 0.007556148339062929, 0.049614064395427704, 0.02402910217642784, 0.014912926591932774, -0.019242141395807266, -0.0048346142284572124, 0.02893306314945221, -0.02894902415573597, -0.015061399899423122, -0.01615362986922264, -0.005939178168773651, 0.023990405723452568, -0.03973083570599556, -0.022884558886289597, 0.004888355266302824, 0.05316155031323433, -0.018358049914240837, 0.003977240063250065, 0.035118889063596725, 0.00037500119651667774, -0.03162739798426628, -0.04069200158119202, 0.02354683168232441, -0.05982314422726631, 0.008568326011300087, -0.017481397837400436, 0.012745632790029049, 0.022028960287570953, -0.007875349372625351, -0.00471844244748354, -0.027818094938993454, 0.013508893549442291, 0.023922210559248924, 0.0322132408618927, -0.02451843023300171, -0.00827969703823328, -0.07255175709724426, 0.007012680172920227, 0.02100600115954876, -0.044093672186136246, 0.014215813018381596, -0.002628764370456338, -0.007919915951788425, 0.022749749943614006, 0.018283270299434662, -0.011787588708102703, 0.02024833671748638, 0.05489140748977661, 0.014492307789623737, -0.03027200885117054, -0.04418906569480896, 0.013996385969221592, 0.014629333280026913, -0.028728649020195007, -0.01480715349316597, -0.020670609548687935, -0.025025993585586548, -0.008659633807837963, -0.046986646950244904, 0.0011710749240592122, 0.03269755095243454, -0.0364929623901844, 0.006776010617613792, 0.010125324130058289, -0.020232927054166794, 0.048164594918489456, -0.0077651082538068295, 0.003713971236720681, 0.012417403981089592, 0.03703257068991661, 0.027892425656318665, -0.004253088962286711, 0.019362248480319977, 0.012436655350029469, 0.002272329293191433, -0.06775561720132828, 0.009650340303778648, 0.045074667781591415, -0.006818744353950024, 0.01798887364566326, 0.02378734201192856, -0.05681464821100235, -0.031236758455634117, 0.02375098317861557, 0.05848773568868637, 0.04017752408981323, -0.0005493764765560627, -0.004462381824851036, -0.010908957570791245, -0.011241531930863857, -0.010411822237074375, 0.07082006335258484, -0.04921398684382439, 0.021435102447867393, 0.03327885642647743, 0.0057106646709144115, 0.05808045715093613, 0.016453411430120468, 0.008652856573462486, 0.010838272050023079, 0.07944470643997192, 0.04400989040732384, 0.012769876047968864, 0.004752170294523239, -0.024844814091920853, 0.005547032691538334, -0.07839139550924301, -0.022350987419486046, -0.019456176087260246, 0.022569406777620316, 0.018569348379969597, -0.011293227784335613, 0.004625965375453234, -0.009802108630537987, 0.04483950883150101, 0.02688971906900406, 0.038882698863744736, 0.01562021765857935, 0.0572475828230381, 0.05273747071623802, 0.00931501667946577, 0.01236593909561634, 0.005360055714845657, -0.012731091119349003, -0.032938823103904724, 0.012829930521547794, 0.021819191053509712, 0.04027885943651199, -0.008179744705557823, 0.020107118412852287, 0.022671349346637726, -0.032878801226615906, -0.02691303752362728, 0.030266856774687767, -0.02124062366783619, 0.008519886992871761, -0.018214046955108643, 0.015240300446748734, -0.017746495082974434, -0.007256273180246353, -0.011639468371868134, 0.0012548293452709913, 0.01612076908349991, 0.0011181440204381943, -0.018958931788802147, 0.03560807183384895, 0.028108298778533936, -0.022733144462108612, -0.0027854281943291426, 0.006366450805217028, 0.01941971480846405, 0.02047153376042843, -0.0163292083889246, -0.031437113881111145, -0.034596458077430725, -0.06791191548109055, -0.019772130995988846, 0.03165104240179062, -0.02181672304868698, -0.005824548192322254, -0.002857699990272522, -0.005572383292019367, -0.027411218732595444, 0.01680976152420044, 0.008999133482575417, 0.007039923686534166, -0.02234416827559471, -0.01620296575129032, -0.014432988129556179, -0.0264565609395504, 0.0017243495676666498, -0.048483047634363174, -0.011489706113934517, -0.02263975515961647, 0.011831477284431458, 0.021935924887657166, 0.036939602345228195, -0.013071920722723007, -0.02219812013208866, 0.010671033523976803, 0.011804642155766487, -0.009448532946407795, -0.009266887791454792, 0.011777682229876518, -0.007752276957035065, 0.037247590720653534, -0.037869468331336975, -0.009940290823578835, -0.0008263837080448866, 0.008640400134027004, 0.03808329254388809, 0.005323844961822033, -0.023451127111911774, -0.01109557319432497, 0.009907218627631664, 0.03264432027935982, 0.028588276356458664, 0.04416952654719353, -0.027465421706438065, 0.055369846522808075, -0.04376270994544029, 0.015086646191775799, -0.05451783165335655, -0.0023330245167016983, -0.047995295375585556, -0.017789218574762344, -0.03223205730319023, 0.01699630171060562, -0.04746223986148834, 0.007615996524691582, -0.05559882894158363, 0.0023258745204657316, -0.0645093098282814, 0.008878633379936218, 0.013996745459735394, 0.03683270514011383, 0.041760534048080444, 0.0765414759516716, -0.0012131788535043597, 0.01748712919652462, -0.037619028240442276, -0.013747942633926868, -0.06518445909023285, 0.0011853707255795598, -0.0053160772658884525, 0.009645293466746807, -0.01674005016684532, 0.0006514906417578459, 0.010054820217192173, 0.016606783494353294, -0.01956123113632202, 0.0022022081539034843, 0.017723023891448975, -0.04284573346376419, -0.049501899629831314, -0.006346388719975948, 0.005976648535579443, -0.011285320855677128, 0.048078153282403946, -0.005792840849608183, -0.008376671932637691, 0.018763313069939613, 0.0027071787044405937, -0.07994873076677322, -0.0014351499266922474, -0.035749658942222595, 0.0009547005756758153, 0.027336785569787025, 0.015178979374468327, 0.03767882287502289, -0.008808568120002747, 0.008637625724077225, 0.005720652174204588, 0.017904365435242653, -0.020656775683164597, -0.057799261063337326, -0.004603969398885965, 0.062393173575401306, -0.021746980026364326, -0.027617618441581726, 0.007994990795850754, -0.007223715540021658, -0.048472996801137924, 0.00354130775667727, 0.002466931939125061, 0.018959365785121918, 0.019854707643389702, 0.020309746265411377, -0.026356713846325874, 0.056414034217596054, 0.01699947565793991, 0.00471712788566947, -0.018174778670072556, 0.021666420623660088 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
b. Training a sentiment model with AutoNLP AutoNLP is a tool to train state-of-the-art machine learning models without code. It provides a friendly and easy-to-use user interface, where you can train custom models by simply uploading your data. AutoNLP will automatically fine-tune various pre-trained models with your data, take care of the hyperparameter tuning and find the best model for your use case. All models trained with AutoNLP are deployed and ready for production. Training a sentiment analysis model using AutoNLP is super easy and it just takes a few clicks 🤯. Let's give it a try! As a first step, let's get some data! You'll use Sentiment140, a popular sentiment analysis dataset that consists of Twitter messages labeled with 3 sentiments: 0 (negative), 2 (neutral), and 4 (positive). The dataset is quite big; it contains 1,600,000 tweets. As you don't need this amount of data to get your feet wet with AutoNLP and train your first models, we have prepared a smaller version of the Sentiment140 dataset with 3,000 samples that you can download from here. This is how the dataset looks like: Sentiment 140 dataset Next, let's create a new project on AutoNLP to train 5 candidate models: Creating a new project on AutoNLP Then, upload the dataset and map the text column and target columns: Adding a dataset to AutoNLP Once you add your dataset, go to the "Trainings" tab and accept the pricing to start training your models. AutoNLP pricing can be as low as $10 per model: Adding a dataset to AutoNLP After a few minutes, AutoNLP has trained all models, showing the performance metrics for all of them: Trained sentiment analysis models by AutoNLP The best model has 77.87% accuracy 🔥 Pretty good for a sentiment analysis model for tweets trained with just 3,000 samples! All these models are automatically uploaded to the Hub and deployed for production. You can use any of these models to start analyzing new data right away by using the pipeline class as shown in previous sections of this post.
[ 0.0035858566407114267, -0.034663282334804535, 0.05018755793571472, 0.05529500171542168, 0.051674116402864456, 0.1344590187072754, 0.02408549003303051, 0.07051973044872284, 0.0008259510505013168, -0.019024290144443512, -0.08111182600259781, 0.09574345499277115, -0.02370925061404705, 0.01613996922969818, 0.03689952194690704, -0.04974573850631714, 0.037265099585056305, 0.009976712055504322, 0.016155187040567398, 0.00536689069122076, -0.04498269408941269, -0.05012187361717224, 0.07204815745353699, -0.014904594980180264, 0.04864225909113884, -0.03170555830001831, 0.09382369369268417, 0.03999580442905426, -0.0701107457280159, -0.037584561854600906, -0.10988298058509827, 0.047437477856874466, -0.05340787023305893, -0.0018126160139217973, 0.02564895898103714, 0.04314425587654114, -0.057438600808382034, 0.05835200846195221, 0.05412422865629196, -0.04303976520895958, -0.0700133666396141, -0.0034741514828056097, -0.01987011358141899, 0.07105657458305359, -0.008299700915813446, -0.03320860490202904, -0.15541251003742218, 0.03443872556090355, 0.02940172702074051, -0.03699888288974762, -0.05082100257277489, 0.10259024798870087, -0.009553822688758373, 0.05303143709897995, -0.05648941174149513, 0.010338405147194862, 0.015360078774392605, -0.06967142224311829, 0.022547155618667603, 0.025062473490834236, 0.04748952388763428, -0.014026646502315998, 0.03026086650788784, 0.03994462639093399, 0.02919212356209755, -0.028960907831788063, -0.055159054696559906, 0.07998326420783997, -0.09982988983392715, -0.04147504270076752, -0.020996905863285065, -0.04714633896946907, -0.017655935138463974, -0.024608096107840538, 0.012938574887812138, -0.007874288596212864, 0.014630754478275776, -0.013095487840473652, -0.016159972175955772, 0.024746248498558998, 0.026246163994073868, 0.024512818083167076, 0.04606102406978607, 0.019843436777591705, 0.07974544167518616, 0.02595346048474312, 0.040572311729192734, 0.004674775525927544, -0.016107654199004173, 0.0598437637090683, 0.004917621612548828, -0.09530720114707947, 0.04525186866521835, -0.03429357707500458, 0.02118094451725483, 0.0016638411907479167, 0.0029712908435612917, 0.08987180143594742, -0.007082213647663593, -0.002451665233820677, -0.020398611202836037, -0.0027743240352720022, 0.009572193026542664, -0.04897725582122803, -0.011727418750524521, 0.0536118783056736, 0.04715593904256821, -0.05332004651427269, -0.0015521866735070944, 0.0404668003320694, -0.017522035166621208, -0.010382679291069508, -0.030395084992051125, 0.034410834312438965, -0.10573062300682068, 0.03031519614160061, 0.05128638818860054, -0.03578504920005798, -0.01022408902645111, -0.011044446378946304, 0.006965744309127331, 0.03695913404226303, 0.029351191595196724, -0.0036982984747737646, -0.014689887873828411, 0.040998298674821854, 0.012783175334334373, 0.0036081811413168907, 0.0038144977297633886, -0.0042548575438559055, 0.02933807298541069, 0.021837381646037102, 0.049548711627721786, -0.004470955580472946, 0.013998061418533325, -0.04323175549507141, -0.01377988699823618, -0.10585946589708328, 0.06467021256685257, 0.03912404552102089, -0.02591557241976261, 0.06686638295650482, -0.04504659026861191, 0.016741834580898285, 0.06892949342727661, 0.029009103775024414, -0.057878635823726654, 0.011748453602194786, 0.01952914521098137, 0.023476310074329376, -0.11701881885528564, 0.025618158280849457, 0.0009388498729094863, -0.10648168623447418, 0.05166487395763397, 0.046837273985147476, -0.02301487699151039, -0.07270313054323196, -0.05224373936653137, 0.05666574090719223, 0.003704049391672015, 0.006930497940629721, -0.04194195941090584, 0.010851285420358181, 0.012374124489724636, -0.02868082746863365, -0.016845230013132095, 0.03546547889709473, 0.01074762549251318, 0.009186960756778717, 0.06608790904283524, -0.03868129849433899, 0.08161306381225586, -0.04295055568218231, 0.07377296686172485, 0.008328159339725971, 0.011099511757493019, 0.012568059377372265, -0.018183758482336998, -0.014488272368907928, -0.009682229720056057, 0.07308997958898544, -0.00027628635871224105, 0.020594706758856773, 0.06915021687746048, -0.0803440660238266, 0.006938680075109005, -0.04307439550757408, -0.024767812341451645, -0.011544224806129932, 0.013640997931361198, -0.013355743139982224, 0.037499163299798965, -0.0009082097676582634, 0.046378958970308304, -0.048713430762290955, 0.003221051301807165, 0.11085493862628937, 0.02691870555281639, 0.005452331621199846, 0.07195117324590683, -0.057804785668849945, 0.05428183823823929, -0.01877531222999096, 0.005270348396152258, 0.003246668493375182, -0.030373146757483482, 0.013634064234793186, -0.005192434415221214, 0.0047452133148908615, -0.01613687351346016, -0.13102424144744873, 0.04332904890179634, -0.04283653944730759, -0.022137528285384178, -0.0006753815105184913, -0.005878025200217962, 0.05074668303132057, 0.02195575088262558, -0.01732783392071724, 0.2045009434223175, -0.04985477402806282, -0.02398071065545082, 0.0010220992844551802, -0.06404241919517517, 0.012765340507030487, 0.062249552458524704, 0.03692048043012619, 0.09900234639644623, -0.03627127408981323, -0.028296515345573425, -0.07335261255502701, 0.007513074204325676, -0.018956271931529045, -0.02513527311384678, -0.021828915923833847, 0.05705465003848076, -0.021056855097413063, 0.0201422069221735, 0.014634351246058941, 0.012684158980846405, 0.029807643964886665, -0.04839032143354416, 0.09546561539173126, -0.057084470987319946, 0.01950063370168209, 0.1275133341550827, -0.009899113327264786, -0.05339416489005089, -0.030078312382102013, -0.03236191347241402, 0.04608779028058052, 0.01281286496669054, -0.02702915482223034, -0.012699713930487633, -0.013972715474665165, 0.05100058764219284, -0.02217370830476284, -0.01926136389374733, 0.054361071437597275, -0.011556128039956093, -0.03311948850750923, -0.014836977235972881, -0.039204131811857224, 0.04314947500824928, -0.03519490361213684, -0.014307042583823204, 0.012467525899410248, 0.019042570143938065, 0.007633204571902752, -0.004555398132652044, -0.003660492831841111, 0.024476496502757072, 0.02862531878054142, -0.017251010984182358, 0.05146186798810959, 0.015456653200089931, 0.003222195664420724, -0.03214836120605469, -0.0479075126349926, -0.014440242201089859, -0.04393963888287544, 0.017762335017323494, 0.0064019751735031605, 0.02870611846446991, -0.0374167263507843, 0.0010802471078932285, -0.032070696353912354, -0.0035692171659320593, 0.024226238951086998, 0.02334100380539894, 0.01791904680430889, -0.01559766661375761, -0.010458667762577534, 0.007176583632826805, 0.0016336719272658229, -0.026910612359642982, 0.02145027555525303, 0.007101773284375668, 0.052755653858184814, -0.00025973000447265804, 0.011301377788186073, -0.02391671948134899, -0.014595448970794678, -0.05725672468543053, 0.029829882085323334, 0.040688175708055496, 0.005998492706567049, -0.09989392012357712, 0.0005911995540373027, -0.0018971111858263612, -0.03784456104040146, 0.039657436311244965, -0.04724695533514023, 0.0767001062631607, -0.029464146122336388, -0.030583838000893593, 0.01514615211635828, -0.0031891348771750927, 0.014047508127987385, 0.0319984033703804, 0.014064890332520008, -0.029695475473999977, 0.0022358086425811052, 0.0027453701477497816, -0.009890716522932053, 0.031376276165246964, 0.042107630521059036, -0.06462890654802322, 0.04896695539355278, 0.009961050003767014, 0.0167691633105278, -0.034923866391181946, 0.018644629046320915, 0.03335530683398247, 0.014066820032894611, 0.0129785081371665, -0.016155332326889038, 0.02580631710588932, -0.03709181770682335, -0.04575099050998688, 0.04091290757060051, -0.022369705140590668, -0.03138333559036255, 0.020129213109612465, 0.05323919281363487, 0.018790993839502335, -0.0017844476969912648, -0.03722754493355751, -0.006988487206399441, 0.01992648094892502, 0.0063680498860776424, -0.00020598896662704647, 0.0034922377672046423, -0.017491593956947327, 0.01715279556810856, 0.004389711655676365, -0.03329310566186905, -0.01789093017578125, -0.020695846527814865, 0.001825429149903357, 0.039611492305994034, -0.003803541185334325, -0.008212922140955925, 0.021904252469539642, -0.005118732340633869, 0.027094652876257896, -0.0033471209462732077, -0.03059380315244198, 0.03600625693798065, -0.010831397026777267, -0.046949658542871475, -0.04547114670276642, 0.002591222757473588, 0.02410116232931614, 0.017132261767983437, 0.01603221520781517, 0.012259446084499359, -0.0020645156037062407, 0.058210283517837524, 0.029431696981191635, 0.0070531717501580715, 0.00046002084854990244, 0.0042442437261343, -0.01419532485306263, -0.029920514672994614, 0.06219601631164551, 0.054021287709474564, -0.010915733873844147, -0.023179512470960617, -0.046485744416713715, -0.03072422556579113, 0.005726621951907873, -0.006865981500595808, 0.016275960952043533, -0.03376685455441475, 0.0210675448179245, 0.04591976851224899, 0.0027965339832007885, 0.020245138555765152, -0.0002086636086460203, -0.009946382604539394, -0.022263001650571823, -0.009686603210866451, 0.01935751922428608, -0.01712435483932495, 0.0029281419701874256, -0.017890211194753647, 0.063900426030159, 0.0155554274097085, -0.04381560534238815, -0.007143324241042137, 0.03458655625581741, 0.026553187519311905, -0.050635926425457, 0.005146299954503775, 0.04424923658370972, -0.004824195988476276, 0.005113948602229357, 0.012662372551858425, -0.016106214374303818, -0.0005922300624661148, 0.04949507862329483, 0.0139620965346694, -0.04983864352107048, 0.010822399519383907, -0.00699470704421401, 0.011238403618335724, -0.007962297648191452, 0.003913608845323324, -0.04224435240030289, -0.017037803307175636, 0.021418504416942596, 0.010826134122908115, 0.049940887838602066, 0.020344244316220284, -0.04062565043568611, -0.03278996795415878, 0.011622711084783077, -0.029792681336402893, -0.02804705500602722, -0.011509144678711891, -0.007999641820788383, 0.0036241579800844193, -0.03045628033578396, 0.022103412076830864, 0.022558193653821945, -0.009872723370790482, -0.017082329839468002, 0.0013576892670243979, -0.0019094678573310375, -0.020006168633699417, 0.022375158965587616, 0.008021208457648754, -0.0511476956307888, -0.012187914922833443, 0.008926420472562313, -0.004808878526091576, 0.002992170862853527, 0.010832826606929302, -0.04922943189740181, -0.016311490908265114, 0.016616640612483025, -0.04364582523703575, -0.010684503242373466, -0.014627868309617043, -0.022757021710276604, 0.03818511590361595, 0.021688349545001984, -0.01292021106928587, -0.02682117372751236, -0.012896817177534103, -0.0018812688067555428, 0.0028186722192913294, -0.0009780630934983492, -0.029826752841472626, -0.02425123006105423, 0.021137023344635963, -0.009513568133115768, 0.02882283367216587, 0.030234169214963913, -0.015336330980062485, 0.00537265045568347, 0.03898102045059204, 0.010053381323814392, 0.013531571254134178, -0.03958309441804886, 0.009393659420311451, -0.04377871751785278, 0.0005452634650282562, -0.02437199093401432, 0.027045946568250656, -0.02444138191640377, 0.017986832186579704, 0.035618893802165985, 0.04341212660074234, 0.0070418077521026134, 0.022107070311903954, -0.02839977666735649, -0.00004293203528504819, 0.00122526241466403, -0.03273116797208786, 0.0030387756414711475, -0.01180741935968399, 0.03681076690554619, 0.007819280959665775, -0.043140195310115814, -0.01993640698492527, -0.0020459811203181744, 0.030655259266495705, -0.027364492416381836, -0.037666767835617065, 0.0240738894790411, 0.03609739989042282, -0.02602890133857727, -0.0643131285905838, 0.021316150203347206, -0.02764912135899067, -0.009931574575603008, -0.021918412297964096, 0.009154175408184528, -0.006034572143107653, -0.008249640464782715, -0.023883070796728134, -0.038725338876247406, 0.03224613517522812, 0.009487798437476158, 0.02592768520116806, 0.012223795056343079, -0.018293781206011772, -0.07475239783525467, -0.008101535961031914, 0.03785664215683937, -0.04692620411515236, 0.015194076113402843, -0.018764490261673927, 0.0124745424836874, -0.0017003933899104595, 0.012957915663719177, -0.040553126484155655, 0.02939561754465103, 0.025577910244464874, 0.03016127273440361, -0.04640084132552147, -0.020899329334497452, 0.024967718869447708, 0.008830452337861061, -0.02952232025563717, -0.04472487419843674, -0.016490625217556953, -0.01736145280301571, -0.0030405065044760704, -0.07339213788509369, 0.03520882502198219, 0.03057735040783882, -0.03147833049297333, -0.009415781125426292, 0.010018356144428253, -0.015792857855558395, 0.022157583385705948, -0.02665119431912899, 0.015883076936006546, 0.03030637837946415, 0.045733291655778885, 0.014493009075522423, 0.013352490030229092, 0.022083396092057228, -0.027531173080205917, -0.006214015651494265, -0.06322966516017914, 0.01734699122607708, 0.05714400112628937, -0.022550247609615326, 0.007576662581413984, 0.006872587837278843, -0.05143951624631882, -0.022189615294337273, 0.028072703629732132, 0.060180965811014175, 0.013564311899244785, -0.035354867577552795, 0.01397083792835474, -0.010190002620220184, -0.005416039377450943, -0.03540465980768204, 0.07370738685131073, -0.04341551661491394, 0.05564412847161293, 0.013104164972901344, 0.010095523670315742, 0.017810815945267677, -0.005640885327011347, 0.0021805777214467525, -0.0025853454135358334, 0.044043660163879395, 0.0539514534175396, -0.00558980880305171, 0.01298443041741848, 0.007064072880893946, -0.029453465715050697, -0.028927022591233253, -0.005108560901135206, -0.04763985797762871, 0.030291181057691574, 0.03941652551293373, -0.025403540581464767, -0.025607841089367867, 0.01933356747031212, 0.03626449033617973, 0.029264774173498154, 0.040872592478990555, -0.001966015435755253, 0.046040721237659454, 0.04628845676779747, 0.01686220057308674, 0.031020771712064743, 0.021679405122995377, -0.011887342669069767, -0.04153615981340408, 0.013734463602304459, 0.05255337432026863, 0.04114196076989174, -0.011355268768966198, -0.018622590228915215, 0.02398505061864853, -0.020470866933465004, -0.007223431020975113, 0.020425742492079735, 0.004899987485259771, 0.00024131788813974708, -0.015449906699359417, 0.031109459698200226, -0.010140511207282543, -0.00564506184309721, -0.0025991613510996103, -0.009646084159612656, 0.0054536848329007626, -0.003908626735210419, -0.03422567993402481, 0.04332417622208595, 0.0007334121619351208, -0.026888128370046616, -0.04151946306228638, -0.020924292504787445, -0.005137719679623842, -0.0034071390982717276, -0.016048165038228035, -0.0452534444630146, -0.0381113700568676, -0.043422698974609375, -0.0074680461548268795, 0.03488704562187195, -0.022921428084373474, -0.015729252249002457, 0.013734052889049053, -0.0011885225540027022, -0.028146130964159966, -0.005679414141923189, 0.010051943361759186, 0.009132768958806992, -0.02348211407661438, -0.026305552572011948, -0.02778611332178116, -0.02647947147488594, 0.027677513659000397, -0.0620729960501194, -0.0008371834992431104, -0.019715523347258568, -0.019095083698630333, 0.018189050257205963, 0.054370857775211334, -0.00024598752497695386, -0.04130668193101883, 0.005913344211876392, -0.005853929556906223, -0.005546108819544315, 0.002426629886031151, 0.002398408018052578, 0.01390848308801651, 0.01466455589979887, -0.031095396727323532, -0.03660618141293526, -0.002317555481567979, 0.008153075352311134, 0.06610437482595444, 0.005399081856012344, -0.025844981893897057, 0.016452603042125702, 0.0004717179399449378, 0.004054801072925329, 0.01869698241353035, 0.03186018392443657, -0.0020659007132053375, 0.02766924723982811, -0.049937713891267776, 0.029353883117437363, -0.009099631570279598, 0.007926718331873417, -0.04900495335459709, -0.05570793151855469, -0.02313944138586521, 0.03933621197938919, -0.03913382440805435, 0.0038774108979851007, -0.04113011062145233, 0.0033975273836404085, -0.07093541324138641, 0.015072562731802464, -0.024725640192627907, 0.018088389188051224, 0.03800976648926735, 0.0274006687104702, -0.006836434826254845, 0.0215609110891819, -0.01921476051211357, -0.0013310146750882268, -0.026348089799284935, 0.04844275489449501, 0.012153498828411102, 0.015066473744809628, 0.0018868494080379605, 0.008450519293546677, 0.027782989665865898, -0.0050010476261377335, 0.009947847574949265, -0.00020452523312997073, 0.0229484923183918, -0.008512770757079124, -0.04149913787841797, -0.008392083458602428, -0.0001904029049910605, -0.016062287613749504, 0.04349840059876442, -0.001743329456076026, 0.004268620628863573, 0.014848464168608189, 0.023921240121126175, -0.0792439877986908, 0.008538633584976196, -0.01936318539083004, -0.029080115258693695, 0.028955532237887383, 0.0342433787882328, 0.05267249792814255, -0.011170729994773865, -0.019436096772551537, -0.0013046682579442859, 0.015641318634152412, -0.0017388162668794394, -0.05775837600231171, -0.01730375550687313, 0.06949692964553833, -0.021520107984542847, -0.0334523469209671, 0.012432514689862728, -0.009226413443684578, 0.006260722875595093, -0.030727241188287735, 0.013402683660387993, 0.018392475321888924, 0.005354354623705149, 0.02173471637070179, -0.01336372084915638, 0.05191809684038162, 0.046928923577070236, -0.005464069079607725, -0.017853684723377228, 0.004346137400716543 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
3. Search for tweets using Tweepy At this point, you are ready to start using the Twitter API to collect tweets 🎉. You will use Tweepy Cursor to extract 1,000 tweets mentioning #NFTs: python # Helper function for handling pagination in our search and handle rate limits def limit_handled(cursor): while True: try: yield cursor.next() except tweepy.RateLimitError: print('Reached rate limite. Sleeping for >15 minutes') time.sleep(15 * 61) except StopIteration: break # Define the term you will be using for searching tweets query = '#NFTs' query = query + ' -filter:retweets' # Define how many tweets to get from the Twitter API count = 1000 # Let's search for tweets using Tweepy search = limit_handled(tweepy.Cursor(api.search, q=query, tweet_mode='extended', lang='en', result_type="recent").items(count))
[ 0.0654464140534401, 0.029132194817066193, 0.03690515086054802, -0.03895075246691704, 0.03527252748608589, 0.07110176980495453, 0.02231789194047451, 0.09025444835424423, -0.03146820142865181, 0.007325867190957069, -0.03357890620827675, 0.06488938629627228, 0.05352179333567619, 0.024564722552895546, 0.052490103989839554, -0.03101508691906929, 0.052622098475694656, -0.02121632918715477, 0.035901982337236404, -0.005142922047525644, 0.024387173354625702, 0.005781916435807943, 0.07745072990655899, -0.05365012213587761, 0.006687135901302099, -0.037242431193590164, -0.045177362859249115, 0.046290744096040726, -0.07315973937511444, -0.014223672449588776, -0.09646820276975632, 0.07595380395650864, 0.033420808613300323, -0.034208230674266815, 0.006813397631049156, 0.006100919097661972, -0.11544077843427658, 0.06295845657587051, 0.08725183457136154, -0.007166081108152866, -0.036916814744472504, -0.11127614974975586, -0.006428562104701996, 0.03018995188176632, 0.015695469453930855, 0.000698073476087302, -0.10748130828142166, 0.05957905575633049, 0.04383260756731033, -0.09240929037332535, -0.010928230360150337, 0.1553741693496704, -0.002843257738277316, 0.01099475845694542, -0.04238494485616684, 0.05326339229941368, -0.013792270794510841, -0.09789536148309708, -0.009855911135673523, 0.03633919730782509, 0.05161507800221443, -0.00589612266048789, 0.039519988000392914, 0.04935483634471893, 0.033654406666755676, -0.012974277138710022, -0.016841566190123558, 0.08455068618059158, -0.053863365203142166, 0.022019153460860252, 0.10386896133422852, -0.04912997782230377, -0.06667830049991608, -0.001027641468681395, -0.028948785737156868, -0.013062218204140663, -0.010691861622035503, 0.03488800302147865, 0.03693794831633568, 0.10574057698249817, -0.018058305606245995, 0.001584316254593432, 0.03926032781600952, 0.000549830961972475, 0.08333670347929001, -0.016613321378827095, -0.019460078328847885, 0.01586134545505047, -0.011494909413158894, 0.011885563842952251, 0.03263169527053833, -0.06913559138774872, 0.023255717009305954, -0.06022437661886215, -0.010955791920423508, 0.00981032196432352, 0.019095122814178467, 0.018520526587963104, 0.004115537274628878, 0.03770240768790245, -0.021868182346224785, -0.06797768920660019, 0.0005572726367972791, -0.06699366867542267, -0.06956330686807632, 0.03309980779886246, 0.037385739386081696, -0.04952838271856308, -0.008919037878513336, -0.037653181701898575, -0.05359621345996857, 0.05419439449906349, -0.08558222651481628, 0.04282024875283241, -0.02090333215892315, 0.07048758119344711, 0.060170453041791916, 0.04254607483744621, -0.11133886128664017, 0.037200845777988434, 0.03529106080532074, 0.07678555697202682, 0.05297661945223808, -0.01550325844436884, 0.029927393421530724, 0.012946012429893017, -0.0005855505587533116, 0.045070845633745193, -0.01687171868979931, -0.03870196267962456, 0.08911986649036407, 0.06973106414079666, 0.047049738466739655, -0.022027993574738503, -0.07885804772377014, -0.018370868638157845, -0.07058565318584442, -0.045112404972314835, 0.044979535043239594, 0.010753960348665714, 0.028963539749383926, -0.054015152156353, -0.05894492566585541, 0.0611262246966362, 0.018127212300896645, -0.007864625193178654, -0.037562571465969086, 0.001857079449109733, -0.03350941091775894, 0.0003055111737921834, -0.09720384329557419, 0.02543669566512108, 0.01186725776642561, -0.030379682779312134, -0.04621552675962448, -0.006528698373585939, 0.018385691568255424, -0.012539447285234928, -0.005945979617536068, 0.013412520289421082, 0.01716245524585247, 0.033397167921066284, 0.023388341069221497, -0.06776772439479828, 0.06387380510568619, -0.020239386707544327, 0.026486722752451897, 0.042861126363277435, 0.004949198104441166, 0.03562638536095619, -0.03740621358156204, 0.02480626292526722, 0.012075461447238922, -0.019232645630836487, 0.05191698297858238, 0.048952385783195496, 0.07109461724758148, -0.08596058189868927, -0.022240856662392616, -0.01812145486474037, -0.012780334800481796, -0.0055975401774048805, -0.03811914846301079, 0.06875908374786377, -0.020629165694117546, -0.10865360498428345, 0.05981859192252159, 0.05098189041018486, 0.03534107655286789, -0.026489511132240295, 0.020721057429909706, -0.084658183157444, 0.0005273498827591538, 0.00006576623127330095, -0.010703695006668568, -0.032247528433799744, 0.036666691303253174, 0.046564292162656784, -0.014249498955905437, 0.02278314158320427, 0.005715281702578068, -0.012741221114993095, 0.053890425711870193, -0.05385439842939377, -0.04573153331875801, 0.01856520213186741, -0.031226150691509247, -0.060106173157691956, -0.005608542822301388, 0.0171461571007967, 0.011627511121332645, -0.0819840058684349, 0.04475463181734085, -0.1290573626756668, 0.034274473786354065, 0.016838597133755684, 0.024479055777192116, 0.0639699324965477, -0.019464585930109024, -0.014476372860372066, 0.12578091025352478, 0.010975804179906845, 0.02442910149693489, -0.02200726792216301, -0.06137016788125038, 0.014388599433004856, 0.04692333564162254, -0.004113179165869951, 0.03087248094379902, -0.0772968977689743, -0.06679762899875641, 0.02189478650689125, -0.01592477411031723, 0.04457656666636467, 0.03645189106464386, -0.023306796327233315, 0.008287127129733562, -0.044890619814395905, 0.005513389594852924, -0.036606624722480774, 0.05898113548755646, -0.02381598949432373, -0.02924993447959423, 0.06393998116254807, 0.001017207046970725, -0.025494355708360672, 0.0720079094171524, -0.04185343533754349, 0.0016237860545516014, -0.0069868131540715694, -0.004097332712262869, -0.0016187257133424282, 0.006640916224569082, -0.028536196798086166, 0.04434826597571373, 0.055462561547756195, -0.03114580363035202, -0.01703881099820137, 0.010689632035791874, 0.040399592369794846, 0.000996782211586833, 0.017571143805980682, 0.027177169919013977, -0.012981053441762924, -0.01411839947104454, 0.010034697130322456, -0.025636404752731323, -0.023775558918714523, 0.008347272872924805, -0.012100933119654655, 0.038400691002607346, -0.02216140553355217, 0.009347684681415558, 0.03079608641564846, -0.016696259379386902, 0.005458889063447714, 0.003585701808333397, 0.03054925613105297, -0.006750640459358692, -0.045438021421432495, -0.010213558562099934, -0.007323435507714748, 0.05807473137974739, 0.01479948777705431, 0.03373853489756584, -0.013213206082582474, -0.02452339418232441, -0.015782993286848068, 0.004189872648566961, -0.011355762369930744, -0.009921092540025711, -0.025213520973920822, 0.01788640394806862, -0.01027115248143673, 0.025944022461771965, 0.018655430525541306, -0.008942303247749805, 0.02331649139523506, -0.03685549646615982, 0.022875340655446053, -0.024266082793474197, -0.03975335508584976, -0.014145431108772755, -0.03381170704960823, -0.04037344455718994, 0.047993648797273636, 0.013654224574565887, 0.024177750572562218, -0.09907085448503494, 0.006348297465592623, -0.03875995799899101, 0.025189703330397606, -0.014281113632023335, 0.033709388226270676, 0.04852866008877754, 0.011917737312614918, 0.04265230521559715, 0.0012382902204990387, -0.010504040867090225, 0.02759752795100212, 0.0006679418729618192, 0.0021872816141694784, -0.0023998459801077843, -0.005120894405990839, -0.01775158755481243, 0.03018486686050892, 0.04695148766040802, 0.061303529888391495, -0.03912154212594032, 0.07466684281826019, -0.010680538602173328, -0.009936144575476646, -0.019796552136540413, -0.01203315518796444, -0.012720935977995396, 0.005249720998108387, 0.0005669876700267196, -0.037639591842889786, 0.006272544153034687, -0.03275025263428688, -0.07266219705343246, -0.002119251061230898, -0.06469015032052994, 0.00003771937554120086, 0.021595552563667297, -0.05788146331906319, 0.004643409978598356, 0.028829749673604965, -0.0351642481982708, 0.002831939607858658, -0.012230024673044682, 0.007240824401378632, 0.022535551339387894, -0.012959185987710953, -0.04535330832004547, -0.003180277766659856, 0.02430817484855652, -0.056312259286642075, -0.03518018126487732, -0.011234262026846409, -0.04195506125688553, -0.010745042003691196, 0.02082780748605728, -0.007805955596268177, -0.03131990134716034, 0.009926843456923962, 0.023258589208126068, 0.013692552223801613, 0.009260238148272038, 0.027277322486042976, 0.04118185117840767, 0.006209571845829487, -0.05661645159125328, 0.03191930055618286, -0.013332712464034557, 0.018098285421729088, -0.010910805314779282, 0.01437171921133995, 0.0030093714594841003, 0.01783275604248047, 0.034613385796546936, 0.01026717945933342, -0.010396739467978477, 0.03331166133284569, -0.016456205397844315, 0.04643906652927399, 0.0638391450047493, 0.04273373633623123, -0.00792175717651844, 0.009457958862185478, -0.0394691564142704, 0.03258967399597168, 0.03597727417945862, -0.003793808165937662, 0.01037357933819294, -0.020056849345564842, 0.024546878412365913, 0.04191625863313675, -0.006675696466118097, -0.024508384987711906, 0.012616467662155628, 0.01952015794813633, -0.029694195836782455, 0.013011692091822624, 0.056360404938459396, 0.007499420549720526, 0.03394078090786934, 0.02373761683702469, 0.059736475348472595, -0.026152662932872772, 0.010098499245941639, -0.005277029238641262, 0.00583988893777132, -0.0120973726734519, -0.07075776159763336, -0.007672334089875221, 0.02163851447403431, -0.009347121231257915, 0.020540520548820496, -0.04682626575231552, 0.028090234845876694, -0.015122762881219387, 0.006202014163136482, 0.05090975761413574, 0.023070432245731354, -0.022580670192837715, -0.041536763310432434, 0.01919535920023918, -0.047747280448675156, 0.00699040200561285, -0.03809398040175438, 0.016007060185074806, -0.014658457599580288, 0.00966043584048748, 0.04553937911987305, -0.011088693514466286, -0.05955948308110237, 0.0017045201966539025, 0.0037954458966851234, 0.0052168420515954494, -0.06107399985194206, -0.01235170103609562, 0.05910804867744446, 0.013837899081408978, -0.014703945256769657, -0.05017373338341713, 0.02536460943520069, -0.039679475128650665, -0.031843602657318115, 0.00811950583010912, -0.03293457254767418, -0.008157528005540371, -0.016199856996536255, 0.01384393498301506, -0.05626005306839943, -0.027545960620045662, -0.015215272083878517, 0.005873646587133408, 0.007124695461243391, -0.01016470231115818, 0.004777880385518074, 0.0028708341997116804, 0.047880254685878754, -0.017781080678105354, 0.029369989410042763, 0.010107587091624737, 0.0021413308568298817, 0.02772543393075466, 0.012896706350147724, -0.012867728248238564, 0.004837424959987402, 0.025749024003744125, 0.0017038913210853934, -0.03495163097977638, -0.008934437297284603, -0.013347362168133259, 0.02225903607904911, -0.0035326818469911814, -0.023567361757159233, 0.03941316157579422, 0.05067768320441246, 0.026545951142907143, 0.003571777604520321, 0.033461764454841614, 0.006801988929510117, 0.01961023360490799, -0.04263022169470787, -0.033840373158454895, -0.036944564431905746, -0.02200556918978691, -0.019928790628910065, -0.010877343825995922, 0.00503007136285305, 0.00800101924687624, 0.022193657234311104, 0.038274623453617096, -0.004523818381130695, 0.04408947378396988, -0.039971690624952316, -0.018403533846139908, -0.0009660896030254662, -0.04070056229829788, 0.03661874309182167, -0.04135000705718994, -0.005931674037128687, 0.012496997602283955, -0.03645937517285347, -0.02766565978527069, 0.047171637415885925, 0.004525387194007635, -0.030627697706222534, -0.019017742946743965, 0.02993423491716385, 0.08500837534666061, -0.015461156144738197, -0.04432287439703941, -0.0008732265559956431, -0.011295194737613201, -0.008258524350821972, -0.02168668992817402, -0.03584843873977661, 0.01479630172252655, 0.01888815127313137, -0.021834377199411392, 0.002865132177248597, 0.014371590688824654, 0.005385525058954954, 0.05146624520421028, 0.000908196612726897, -0.021649986505508423, 0.002075737342238426, 0.028950601816177368, 0.06117072328925133, -0.026551514863967896, 0.021162770688533783, -0.001602707663550973, 0.020600423216819763, 0.026337241753935814, 0.02404974400997162, -0.05048002302646637, 0.04564442113041878, 0.03354474902153015, 0.004289185628294945, -0.024508487433195114, -0.015081517398357391, 0.06871058791875839, 0.021185513585805893, 0.010846327990293503, -0.029862871393561363, -0.021020105108618736, -0.042909812182188034, -0.0005124482559040189, -0.0027591243851929903, -0.019161714240908623, 0.03242117166519165, 0.023600680753588676, -0.02740895189344883, -0.023594072088599205, -0.012445771135389805, 0.03094569407403469, -0.034204695373773575, 0.014926653355360031, 0.024253515526652336, -0.0007750451914034784, -0.008212372660636902, -0.02159823663532734, 0.022609610110521317, 0.0027567290235310793, 0.023420609533786774, -0.047788504511117935, 0.005268929526209831, 0.03797430172562599, 0.023633502423763275, 0.019175676628947258, 0.01432839222252369, -0.004730392713099718, -0.015294318087399006, -0.013458332978188992, 0.02392922155559063, 0.052467066794633865, -0.038187965750694275, -0.010986237786710262, -0.007614848203957081, 0.005825145170092583, 0.0030847094021737576, 0.08120168000459671, -0.04609399661421776, 0.04100454971194267, 0.0037249522283673286, 0.045940909534692764, -0.012853487394750118, -0.010800343006849289, -0.00730314152315259, 0.010197104886174202, 0.009270342998206615, 0.062193870544433594, 0.04361456260085106, 0.01851789467036724, -0.01084810122847557, -0.01437588781118393, -0.033399228006601334, 0.006995752453804016, -0.00945389736443758, -0.014565236866474152, 0.06037371605634689, -0.030733466148376465, 0.04774707555770874, -0.03785759210586548, 0.05138357728719711, -0.015742288902401924, 0.026239965111017227, 0.009570196270942688, 0.014570383355021477, -0.005329065956175327, 0.017173368483781815, 0.05981721356511116, 0.020925460383296013, -0.001151641015894711, -0.025480171665549278, 0.029928022995591164, 0.02419513277709484, 0.025565968826413155, 0.015400118194520473, -0.008509872481226921, -0.007251835893839598, -0.04947390779852867, -0.04495576396584511, 0.014030001126229763, 0.012377285398542881, 0.00598133122548461, -0.02693982981145382, 0.010036618448793888, -0.044258423149585724, -0.0077485740184783936, -0.01455506682395935, -0.03109932132065296, -0.0007770722731947899, -0.04225093871355057, -0.008771594613790512, 0.02197430469095707, -0.0388510525226593, 0.0038033106829971075, 0.019936712458729744, 0.04496673867106438, -0.0013071009889245033, -0.005489955190569162, -0.03151062875986099, 0.015363220125436783, -0.01890113204717636, -0.005950042977929115, 0.020074350759387016, 0.007103579584509134, -0.03184373304247856, -0.008901800960302353, -0.02263103984296322, -0.026653116568922997, -0.0010149346198886633, 0.04307829216122627, 0.005837908014655113, 0.03216417878866196, -0.010328635573387146, 0.020657038316130638, 0.004752539098262787, -0.009084293618798256, 0.007012553978711367, 0.010721422731876373, -0.023948021233081818, -0.04104432091116905, 0.02786853536963463, 0.027261851355433464, -0.01444967184215784, -0.016142331063747406, 0.001259361393749714, 0.04058203473687172, -0.034750670194625854, -0.07285013794898987, 0.07020778208971024, -0.004570411518216133, 0.007290971465408802, 0.0439005121588707, -0.04428901523351669, -0.0079807098954916, -0.03867628425359726, -0.003643651958554983, 0.05406324565410614, -0.009423520416021347, 0.00019398400036152452, -0.0038890119176357985, -0.012672726064920425, 0.011125227436423302, -0.025597617030143738, 0.022438354790210724, 0.003796017961576581, -0.005477522499859333, -0.011952288448810577, -0.03216898813843727, -0.02675401046872139, 0.0009662992088124156, -0.07815921306610107, -0.017778685316443443, -0.050891343504190445, -0.006555614527314901, -0.018862806260585785, -0.0014044406125321984, -0.04940863326191902, 0.014828155748546124, -0.00025708030443638563, -0.02449972555041313, 0.0323164276778698, -0.03225281089544296, -0.00838196836411953, 0.01724885031580925, 0.013994483277201653, 0.022253528237342834, 0.03145790472626686, -0.011160027235746384, -0.03018924407660961, 0.01153980940580368, 0.02807466872036457, 0.028678208589553833, -0.013830493204295635, -0.02133810706436634, 0.004239471163600683, -0.010396323166787624, -0.017744898796081543, 0.0433003194630146, 0.01290283165872097, -0.0252734012901783, -0.007798613980412483, 0.003392394632101059, -0.011532656848430634, 0.0015902018640190363, 0.03498492389917374, -0.007745994254946709, -0.007058525457978249, 0.0049483501352369785, 0.06697855144739151, -0.01472347043454647, -0.015236900188028812, 0.00681988475844264, -0.059692710638046265, 0.034717854112386703, -0.036841124296188354, 0.003987714182585478, 0.011108322069048882, 0.013620528392493725, 0.015223458409309387, 0.019225802272558212, -0.02219279482960701, -0.030295660719275475, -0.005616712849587202, 0.019914016127586365, -0.0701834112405777, -0.0436619333922863, 0.04169697314500809, -0.0007033696747384965, -0.053441453725099564, 0.007724436931312084, 0.02131500653922558, 0.02525480091571808, 0.0014762514038011432, 0.048985328525304794, -0.027970075607299805, 0.02231369912624359, -0.012587297707796097, 0.0056102219969034195, -0.003903732169419527, -0.02965155616402626 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
# Getting Started with Sentiment Analysis using Python Sentiment analysis is the automated process of tagging data according to their sentiment, such as positive, negative and neutral. Sentiment analysis allows companies to analyze data at scale, detect insights and automate processes. In the past, sentiment analysis used to be limited to researchers, machine learning engineers or data scientists with experience in natural language processing. However, the AI community has built awesome tools to democratize access to machine learning in recent years. Nowadays, you can use sentiment analysis with a few lines of code and no machine learning experience at all! 🤯 In this guide, you'll learn everything to get started with sentiment analysis using Python, including: 1. What is sentiment analysis? 2. How to use pre-trained sentiment analysis models with Python 3. How to build your own sentiment analysis model 4. How to analyze tweets with sentiment analysis Let's get started! 🚀
[ 0.03238030523061752, -0.010093746706843376, 0.02427344210445881, -0.003186633111909032, 0.05280118063092232, 0.11937599629163742, -0.0035724954213947058, 0.08742153644561768, 0.015836579725146294, 0.003503842046484351, -0.0925464928150177, 0.07360513508319855, -0.020092125982046127, 0.04894533008337021, 0.034291066229343414, -0.03997175768017769, 0.07120644301176071, -0.004382751882076263, 0.036842118948698044, 0.008739753626286983, -0.02869698777794838, 0.011442712508141994, 0.007096475455909967, -0.00865539163351059, 0.023532738909125328, -0.03796035051345825, 0.09116960316896439, 0.03662889450788498, -0.06622390449047089, -0.028960775583982468, -0.10141243785619736, 0.05796009674668312, -0.05640876293182373, -0.013755014166235924, 0.011840756051242352, 0.05873895436525345, -0.0961846187710762, 0.06762909889221191, 0.0633796975016594, -0.028416307643055916, -0.028510812669992447, -0.07334791868925095, -0.09135502576828003, -0.005667028483003378, -0.05226738005876541, -0.04909911006689072, -0.18475700914859772, 0.08201055228710175, -0.0006826045573689044, -0.04267348721623421, -0.04272286966443062, 0.13604585826396942, -0.041009459644556046, 0.00473310612142086, -0.07679767906665802, 0.04015609994530678, 0.0004244571609888226, -0.026744812726974487, -0.0024914382956922054, 0.03927897289395332, 0.02897893637418747, 0.02629452385008335, -0.022533269599080086, 0.026505297049880028, 0.018274351954460144, 0.011933072470128536, -0.014512758702039719, 0.07377710193395615, -0.06623168289661407, -0.027473628520965576, 0.00807292852550745, -0.017325347289443016, -0.06088054180145264, -0.010570192709565163, -0.020785637199878693, -0.027955280616879463, 0.02747676707804203, 0.030917266383767128, -0.015390957705676556, 0.020430007949471474, 0.034969575703144073, 0.04280651733279228, 0.05220646411180496, 0.019990677013993263, 0.1501549333333969, 0.014835056848824024, 0.03662126138806343, 0.010810382664203644, -0.013712628744542599, 0.06263439357280731, 0.016611356288194656, -0.09132951498031616, 0.05769340693950653, -0.03944201394915581, 0.044151946902275085, -0.040067918598651886, -0.01613694243133068, 0.06369273364543915, -0.02689923718571663, 0.001533536589704454, -0.0006884082104079425, -0.039825309067964554, 0.04355376586318016, -0.06572132557630539, 0.0050920420326292515, 0.07648641616106033, 0.046965185552835464, -0.007420229725539684, -0.05465321242809296, -0.013072165660560131, -0.041964102536439896, -0.005403589457273483, -0.045834947377443314, 0.0990087240934372, -0.04927024990320206, 0.05883381515741348, 0.02444186806678772, -0.006103284191340208, -0.02660553529858589, -0.013797587715089321, 0.022164015099406242, 0.05390722304582596, 0.040809839963912964, 0.021201886236667633, -0.06569036096334457, 0.051570866256952286, 0.001996636390686035, 0.016332756727933884, 0.03115626610815525, -0.018854595720767975, -0.011035347357392311, 0.014535576105117798, 0.05010585859417915, -0.0208041463047266, -0.05792313441634178, -0.051343727856874466, -0.04320777580142021, -0.06182551383972168, 0.043885186314582825, -0.007319426164031029, 0.02747843973338604, 0.06701608002185822, -0.045461200177669525, 0.0581023208796978, 0.019372740760445595, 0.016021041199564934, -0.07487060129642487, 0.002297252183780074, -0.01792963221669197, 0.008624108508229256, -0.11743982881307602, -0.012503525242209435, -0.02683255635201931, -0.06590794771909714, 0.006236906163394451, 0.04498262703418732, -0.011202073656022549, -0.05066393315792084, -0.03710884973406792, 0.00811410415917635, 0.059149645268917084, 0.0005218027508817613, -0.03308744356036186, 0.017305608838796616, 0.06364070624113083, -0.026979906484484673, 0.02050296775996685, 0.027357997372746468, -0.003946029115468264, 0.04888916015625, 0.011585782282054424, -0.038794778287410736, 0.07336333394050598, -0.046239785850048065, 0.047860510647296906, 0.009124132804572582, -0.006691152695566416, -0.043521299958229065, -0.017355693504214287, -0.005261512938886881, -0.01477340329438448, 0.0910407230257988, -0.008963184431195259, 0.01472968515008688, 0.031579770147800446, -0.06281303614377975, 0.024289829656481743, -0.05521523579955101, 0.02068950980901718, -0.03389298543334007, -0.043289829045534134, -0.02190605364739895, 0.028176121413707733, -0.013787252828478813, 0.055103007704019547, -0.04424147307872772, 0.027324233204126358, 0.09090027958154678, -0.0036315678153187037, 0.00430813804268837, 0.03327416256070137, -0.06021212041378021, 0.06026617810130119, -0.03912418708205223, -0.005690729711204767, 0.016115374863147736, 0.024646753445267677, 0.008021903224289417, 0.01547282375395298, 0.02594880759716034, -0.016787242144346237, -0.07739173620939255, 0.013262336142361164, -0.04275686293840408, 0.015165005810558796, 0.006268894765526056, -0.03419262170791626, 0.07028310000896454, 0.04588257893919945, -0.029357435181736946, 0.1613158881664276, -0.07604999095201492, 0.035378847271203995, -0.0015465497272089124, -0.04020388424396515, -0.013987792655825615, 0.08702943474054337, 0.03971152380108833, 0.05738505348563194, -0.04477414861321449, -0.013059587217867374, 0.00562738161534071, -0.03654303401708603, -0.027063807472586632, -0.06289543211460114, -0.014684141613543034, 0.06405005604028702, 0.012628422118723392, 0.007227172143757343, -0.008279492147266865, -0.013757223263382912, 0.003422167617827654, -0.03271479159593582, 0.034644242376089096, -0.015541927888989449, -0.003666304750367999, 0.10939204692840576, -0.06467738747596741, -0.07189873605966568, 0.051518514752388, 0.005481529515236616, 0.023135917261242867, 0.03164157643914223, 0.017847472801804543, -0.03678283840417862, -0.007724722381681204, 0.04918723925948143, -0.01582750305533409, 0.000593780423514545, 0.04509908705949783, -0.011836225166916847, -0.039084192365407944, 0.0031818344723433256, -0.04524799808859825, 0.013464287854731083, -0.0007258225232362747, -0.0013314604293555021, -0.014928639866411686, -0.005261651705950499, 0.02778984047472477, 0.026385007426142693, -0.02263219654560089, 0.03939197584986687, 0.018018826842308044, -0.02227126434445381, 0.022377120330929756, -0.004304895177483559, 0.012696421705186367, -0.026989012956619263, -0.036999527364969254, -0.027043316513299942, -0.04719550535082817, 0.0073761530220508575, 0.008627932518720627, 0.019588861614465714, -0.04773738235235214, -0.030279267579317093, -0.004101263824850321, 0.003909355960786343, 0.04989004507660866, 0.011103710159659386, -0.011963234283030033, -0.036639243364334106, -0.001532495254650712, -0.004961580038070679, 0.015573835000395775, -0.005350666586309671, 0.04871257394552231, -0.013850931078195572, 0.05074481666088104, 0.020007513463497162, -0.016266867518424988, -0.004525935743004084, -0.045519862323999405, -0.07327687740325928, 0.014777508564293385, 0.04859994351863861, 0.0019069303525611758, -0.10103751718997955, 0.0003821702557615936, 0.007899333722889423, -0.02104021981358528, 0.026065539568662643, -0.03032742813229561, 0.07851187139749527, 0.010602008551359177, -0.023168884217739105, 0.007659191731363535, -0.036652542650699615, 0.012715878896415234, 0.0010553656611591578, 0.03904370591044426, 0.0100069185718894, -0.010675224475562572, -0.0014689279487356544, 0.021753154695034027, 0.05030602216720581, 0.038632284849882126, -0.03469615802168846, 0.06741649657487869, 0.004362798295915127, 0.015466112643480301, -0.04911516606807709, -0.005835929419845343, 0.016628339886665344, 0.015476066619157791, 0.005685892421752214, -0.018440138548612595, 0.033276431262493134, -0.02104266546666622, -0.06582438945770264, 0.019122904166579247, -0.0009509171359241009, -0.013403519988059998, 0.013138984329998493, -0.003358017886057496, -0.0012038348941132426, 0.023374270647764206, -0.03993120416998863, 0.019954578951001167, 0.03117021918296814, -0.025320403277873993, 0.003125862218439579, -0.021354328840970993, -0.03109409660100937, -0.02277986891567707, -0.01679609902203083, -0.011320870369672775, -0.0202489010989666, -0.020024580880999565, -0.003761433996260166, 0.03217843547463417, -0.007912026718258858, -0.008408940397202969, 0.02263849973678589, 0.010011172853410244, 0.00004139238444622606, 0.03118584118783474, -0.04066796228289604, 0.003440611530095339, 0.013387409970164299, -0.04239226132631302, -0.04417141154408455, 0.019569091498851776, 0.014229215681552887, 0.017284812405705452, 0.03509151190519333, 0.008366868831217289, 0.0021862408611923456, 0.02288195863366127, 0.011706573888659477, 0.00895498227328062, -0.03326224908232689, 0.01564452424645424, -0.014345280826091766, -0.007759357336908579, 0.06422852724790573, 0.05101344734430313, -0.0051095373928546906, -0.059885475784540176, -0.02145577222108841, -0.0541854165494442, 0.021725090220570564, 0.013543577864766121, 0.010003498755395412, -0.04441455006599426, -0.01062814798206091, 0.05931922793388367, 0.03995213285088539, -0.006211990024894476, 0.008213331922888756, 0.0039016001392155886, -0.014480937272310257, 0.016406510025262833, 0.03704851120710373, -0.021402213722467422, 0.016627011820673943, -0.00688194390386343, 0.040560413151979446, -0.011813776567578316, -0.05323323607444763, -0.016742335632443428, 0.031874880194664, 0.004361629951745272, -0.05897734686732292, -0.020645447075366974, 0.02641325630247593, -0.03511178866028786, -0.011835497803986073, 0.006733446381986141, 0.0105549031868577, -0.011455324478447437, 0.05637486279010773, 0.051053740084171295, -0.020979605615139008, -0.0430874340236187, -0.011092199012637138, 0.04011571779847145, -0.01213367935270071, -0.0006119342288002372, -0.03176227957010269, -0.004709138534963131, 0.006640879902988672, -0.016809845343232155, 0.056034114211797714, 0.010390887968242168, -0.03674742206931114, -0.04789881780743599, 0.02645544707775116, -0.038775842636823654, -0.028027277439832687, 0.002783239586278796, 0.012881514616310596, -0.026173869147896767, -0.0027076604310423136, 0.0024006825406104326, 0.0214160718023777, -0.042678117752075195, -0.007136944681406021, -0.015953894704580307, 0.021980417892336845, 0.004371786955744028, 0.0009371855994686484, 0.006183929275721312, -0.0677528977394104, -0.0058213588781654835, 0.015076384879648685, -0.009229718707501888, -0.014047057367861271, 0.021010465919971466, -0.04341037571430206, -0.01735920086503029, -0.007953091524541378, -0.03858659043908119, -0.008169529028236866, 0.018397288396954536, -0.01358101423829794, 0.03588274121284485, 0.0034374550450593233, -0.04421169310808182, -0.002959138248115778, -0.021798554807901382, -0.005606508813798428, -0.05954807996749878, -0.04275817796587944, -0.050232261419296265, 0.015582161955535412, 0.03386685624718666, 0.005413970910012722, 0.04863285273313522, 0.025862054899334908, -0.04002980887889862, -0.003892110660672188, 0.028712419793009758, 0.024527696892619133, 0.018515601754188538, -0.05784943699836731, 0.01841137371957302, -0.04143000766634941, -0.0255722813308239, -0.01964690536260605, 0.004721561912447214, -0.007068989798426628, 0.03868837654590607, 0.029939986765384674, 0.013833865523338318, 0.017494237050414085, 0.03446213901042938, -0.038453951478004456, -0.02926933392882347, 0.0030320726800709963, -0.03415622562170029, -0.024245619773864746, -0.012701756320893764, 0.017607655376195908, 0.006733653601258993, -0.03292251378297806, -0.04289420321583748, -0.0034005348570644855, 0.034738052636384964, -0.0011834214674308896, -0.005809813737869263, 0.014906621538102627, 0.016598384827375412, -0.02645408734679222, -0.048021670430898666, 0.010234302841126919, -0.05544550344347954, 0.005475361831486225, -0.019285306334495544, -0.0051888879388570786, -0.004029375035315752, -0.026820776984095573, -0.007935704663395882, 0.001424937741830945, 0.003090856596827507, -0.0048067159950733185, 0.004538282752037048, -0.028203999623656273, -0.0009955086279660463, -0.05750874802470207, 0.03174422308802605, 0.038106851279735565, -0.03884866088628769, 0.015576941892504692, 0.006553457118570805, 0.022071998566389084, -0.00891023874282837, 0.034355342388153076, -0.00945064052939415, 0.04803731292486191, 0.030803333967924118, -0.008498051203787327, -0.02631995640695095, -0.051723700016736984, 0.012182767502963543, 0.005429466720670462, -0.02147357165813446, -0.025405878201127052, -0.011088172905147076, -0.0002819056389853358, -0.018606841564178467, -0.032963648438453674, -0.0002722381323110312, 0.02931138128042221, -0.033638812601566315, 0.0008498849929310381, 0.0022747814655303955, -0.013139292597770691, 0.03812810406088829, -0.01055891253054142, 0.014478695578873158, 0.054392680525779724, 0.048180729150772095, 0.042320746928453445, -0.005546353757381439, 0.01685221493244171, -0.005972050130367279, 0.005606469232589006, -0.05114217475056648, 0.03655415028333664, 0.005284171085804701, 0.0004704857710748911, 0.01050487905740738, 0.03644351661205292, -0.02566317655146122, -0.0034592426382005215, 0.027625421062111855, 0.04152291268110275, 0.03345150873064995, 0.016350194811820984, 0.02489086240530014, -0.0037977469619363546, 0.0052948505617678165, -0.027345841750502586, 0.08323144912719727, -0.0649593397974968, 0.06122658774256706, 0.004258858039975166, 0.022672435268759727, 0.043889980763196945, 0.013035403564572334, 0.019753390923142433, -0.008479383774101734, 0.09147246927022934, 0.04704098030924797, -0.005188815761357546, 0.00042471723281778395, -0.033186253160238266, -0.011179155670106411, -0.052872251719236374, -0.02988990768790245, -0.0035264340694993734, 0.019792119041085243, 0.05592552199959755, -0.015382878482341766, 0.014950830489397049, -0.00907016173005104, 0.04080720618367195, 0.03182799741625786, 0.0331815741956234, 0.00977043155580759, 0.03211263567209244, 0.054328449070453644, 0.007732687052339315, 0.004195267800241709, 0.039286717772483826, -0.012400934472680092, -0.018703650683164597, 0.0022805940825492144, 0.04223724082112312, 0.04289686307311058, -0.0024269376881420612, 0.01644310913980007, 0.036100469529628754, -0.027391834184527397, 0.027462534606456757, -0.005383018404245377, -0.03633466362953186, -0.00018187507521361113, 0.0032853835728019476, -0.011840471997857094, 0.008058998733758926, -0.00392888393253088, 0.0044143954291939735, 0.014335934072732925, 0.045704666525125504, -0.020776843652129173, -0.024538913741707802, 0.027766376733779907, 0.020878814160823822, -0.01211210060864687, -0.022360047325491905, -0.009733937680721283, 0.007378387730568647, -0.00926445797085762, -0.03167767450213432, -0.03860849514603615, -0.04585530236363411, -0.035289403051137924, -0.026150457561016083, 0.02772848680615425, -0.011991950683295727, -0.018372325226664543, 0.006967699155211449, -0.013028627261519432, -0.060183342546224594, 0.03687366470694542, 0.016727842390537262, 0.03478487208485603, -0.03271932527422905, -0.016667131334543228, -0.04333963245153427, -0.03743412718176842, -0.009930312633514404, 0.004160952754318714, 0.013344007544219494, -0.03134128078818321, -0.012386158108711243, -0.007802617270499468, 0.0128791444003582, -0.013066796585917473, 0.0060972291976213455, 0.030017482116818428, 0.013847536407411098, -0.015088875778019428, -0.010070689022541046, 0.010357428342103958, -0.00717577850446105, 0.04675276577472687, -0.035159334540367126, -0.006837365683168173, 0.01145403552800417, 0.022007836028933525, 0.03651480749249458, 0.00009353939822176471, -0.006350458599627018, -0.005949807353317738, 0.008080068975687027, 0.02931310422718525, 0.01079722959548235, 0.01969628408551216, -0.01438836008310318, 0.02129066176712513, -0.04884425550699234, 0.010153291746973991, -0.03318939730525017, -0.003964579198509455, -0.03186097368597984, -0.0276788342744112, -0.014222616329789162, 0.03691524267196655, -0.0279756560921669, 0.0008245817734859884, -0.07339981198310852, -0.00020791628048755229, -0.04021475836634636, 0.0017611311050131917, 0.005766461603343487, 0.009150977246463299, 0.03237854316830635, 0.04242928698658943, 0.00005323054574546404, 0.05156887695193291, -0.017408274114131927, 0.001932658487930894, -0.04961805418133736, 0.028239822015166283, 0.009550141170620918, 0.013305051252245903, -0.007944736629724503, 0.004914483986794949, 0.019684797152876854, -0.016415607184171677, -0.014864872209727764, 0.008108209818601608, 0.054850634187459946, -0.02191721275448799, -0.04290737211704254, 0.014442081563174725, -0.01329803466796875, -0.00551493838429451, 0.038388691842556, -0.010722660459578037, -0.01201687566936016, 0.030821891501545906, -0.002068488858640194, -0.057392895221710205, -0.004133415408432484, 0.029457198455929756, -0.004712637513875961, 0.02301718108355999, 0.030936921015381813, 0.04333116486668587, -0.002722647972404957, 0.014069115743041039, 0.0043885717168450356, 0.012355903163552284, -0.01247116643935442, -0.05160035192966461, -0.019180065020918846, 0.05352369323372841, -0.009312666952610016, -0.018254542723298073, 0.007452005986124277, -0.016161903738975525, -0.026481127366423607, 0.025051388889551163, 0.030064130201935768, 0.01581934280693531, 0.04082563519477844, 0.024489199742674828, -0.02014455571770668, 0.08093111962080002, 0.022404856979846954, 0.030353303998708725, 0.0035395349841564894, 0.02451440691947937 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
5. Explore the results of sentiment analysis How are people talking about NFTs on Twitter? Are they talking mostly positively or negatively? Let's explore the results of the sentiment analysis to find out! First, let's load the results on a dataframe and see examples of tweets that were labeled for each sentiment: python import pandas as pd # Load the data in a dataframe df = pd.DataFrame(tweets) pd.set_option('display.max_colwidth', None) # Show a tweet for each sentiment display(df[df["sentiment"] == 'POS'].head(1)) display(df[df["sentiment"] == 'NEU'].head(1)) display(df[df["sentiment"] == 'NEG'].head(1)) Output: Tweet: @NFTGalIery Warm, exquisite and elegant palette of charming beauty Its price is 2401 ETH. \nhttps://t.co/Ej3BfVOAqc\n#NFTs #NFTartists #art #Bitcoin #Crypto #OpenSeaNFT #Ethereum #BTC Sentiment: POS Tweet: How much our followers made on #Crypto in December:\n#DAPPRadar airdrop — $200\nFree #VPAD tokens — $800\n#GasDAO airdrop — up to $1000\nStarSharks_SSS IDO — $3500\nCeloLaunch IDO — $3000\n12 Binance XMas #NFTs — $360 \nTOTAL PROFIT: $8500+\n\nJoin and earn with us https://t.co/fS30uj6SYx Sentiment: NEU Tweet: Stupid guy #2\nhttps://t.co/8yKzYjCYIl\n\n#NFT #NFTs #nftcollector #rarible https://t.co/O4V19gMmVk Sentiment: NEG Then, let's see how many tweets you got for each sentiment and visualize these results: python # Let's count the number of tweets by sentiments sentiment_counts = df.groupby(['sentiment']).size() print(sentiment_counts) # Let's visualize the sentiments fig = plt.figure(figsize=(6,6), dpi=100) ax = plt.subplot(111) sentiment_counts.plot.pie(ax=ax, autopct='%1.1f%%', startangle=270, fontsize=12, label="") Interestingly, most of the tweets about NFTs are positive (56.1%) and almost none are negative (2.0%): Sentiment analysis result of NFTs tweets Finally, let's see what words stand out for each sentiment by creating a word cloud: python from wordcloud import WordCloud from wordcloud import STOPWORDS # Wordcloud with positive tweets positive_tweets = df['tweet'][df["sentiment"] == 'POS'] stop_words = ["https", "co", "RT"] + list(STOPWORDS) positive_wordcloud = WordCloud(max_font_size=50, max_words=100, background_color="white", stopwords = stop_words).generate(str(positive_tweets)) plt.figure() plt.title("Positive Tweets - Wordcloud") plt.imshow(positive_wordcloud, interpolation="bilinear") plt.axis("off") plt.show() # Wordcloud with negative tweets negative_tweets = df['tweet'][df["sentiment"] == 'NEG'] stop_words = ["https", "co", "RT"] + list(STOPWORDS) negative_wordcloud = WordCloud(max_font_size=50, max_words=100, background_color="white", stopwords = stop_words).generate(str(negative_tweets)) plt.figure() plt.title("Negative Tweets - Wordcloud") plt.imshow(negative_wordcloud, interpolation="bilinear") plt.axis("off") plt.show() Some of the words associated with positive tweets include Discord, Ethereum, Join, Mars4 and Shroom: Word cloud for positive tweets In contrast, words associated with negative tweets include: cookies chaos, Solana, and OpenseaNFT: Word cloud for negative tweets And that is it! With just a few lines of python code, you were able to collect tweets, analyze them with sentiment analysis and create some cool visualizations to analyze the results! Pretty cool, huh?
[ 0.05232451483607292, 0.010562269017100334, 0.045916616916656494, -0.03282022848725319, 0.0450437068939209, 0.07244182378053665, -0.011417030356824398, 0.10916876792907715, -0.007939946837723255, -0.03558314964175224, -0.0015502625610679388, 0.03650771826505661, -0.01601155288517475, 0.03429264575242996, -0.01782742701470852, -0.00038018738268874586, 0.04996135085821152, -0.02899470366537571, 0.10507074743509293, -0.021380767226219177, -0.0178358294069767, -0.022768666967749596, 0.03220178559422493, -0.044268909841775894, 0.03511979803442955, -0.06637875735759735, 0.049075860530138016, 0.03255816176533699, -0.11986430734395981, 0.04376194253563881, -0.10400772094726562, 0.07831579446792603, -0.04079197347164154, 0.004760554526001215, 0.011045531369745731, -0.030655303969979286, -0.14487005770206451, 0.09364509582519531, 0.07189256697893143, -0.022091040387749672, -0.04296864941716194, -0.11385918408632278, -0.026545753702521324, 0.05742514878511429, 0.010690977796912193, -0.050124213099479675, -0.14410237967967987, 0.09483359754085541, 0.003742136061191559, -0.027748404070734978, -0.0167545136064291, 0.11400707811117172, -0.05785553902387619, -0.00923591572791338, -0.05481373518705368, 0.01468678005039692, -0.028336193412542343, -0.0017777233151718974, 0.0562666580080986, -0.01170270424336195, 0.03244462236762047, -0.02270711585879326, 0.007674568798393011, 0.02545255236327648, 0.01775714010000229, -0.008884812705218792, -0.009806274436414242, 0.12099858373403549, -0.047077931463718414, -0.004984629340469837, 0.021464264020323753, 0.007546618115156889, -0.058161765336990356, -0.021494071930646896, 0.004905045498162508, 0.045061979442834854, 0.02378016524016857, 0.006448157597333193, -0.008658370934426785, -0.004550967365503311, -0.0021209423430263996, 0.04662197828292847, 0.05549151077866554, 0.04439709708094597, 0.11013714969158173, -0.01576920598745346, 0.053643785417079926, 0.028397750109434128, -0.05829916149377823, 0.08393137156963348, 0.008174227550625801, -0.038414496928453445, 0.05543002486228943, 0.017633633688092232, 0.030377380549907684, -0.03254595771431923, 0.03400562331080437, -0.01721659116446972, -0.034923676401376724, 0.02622278966009617, 0.016063163056969643, -0.039225317537784576, 0.030624954029917717, -0.08626037836074829, -0.014165154658257961, 0.027235522866249084, 0.03943296894431114, -0.06078816577792168, -0.0029515991918742657, -0.02893545664846897, -0.04529695585370064, 0.008135957643389702, 0.0033102696761488914, 0.060449324548244476, -0.0494534894824028, 0.10058491677045822, 0.00823420099914074, 0.010863734409213066, -0.0402899868786335, 0.03679490461945534, 0.05182693153619766, 0.10687459260225296, 0.040115755051374435, -0.01830156520009041, -0.042929623275995255, -0.002443955047056079, 0.0018957746215164661, 0.04512732848525047, -0.03144615888595581, -0.022259458899497986, -0.006316338200122118, 0.02870015986263752, 0.02967538870871067, -0.0094531811773777, -0.07274114340543747, -0.10638687014579773, -0.07265261560678482, -0.0797475054860115, 0.05679750815033913, -0.06156521290540695, -0.03752940148115158, 0.0422709658741951, -0.07007120549678802, 0.09348639845848083, 0.04413359984755516, 0.003539599245414138, -0.049767907708883286, -0.0124027319252491, -0.023801062256097794, -0.00871571246534586, -0.07387860864400864, -0.017416981980204582, 0.03290338069200516, -0.10522373765707016, 0.024914097040891647, 0.04392993822693825, 0.02987608313560486, -0.06006429344415665, -0.03406473621726036, 0.056369930505752563, 0.029178228229284286, -0.04250841960310936, 0.0419258251786232, -0.036658111959695816, 0.05019101873040199, 0.0004640945408027619, -0.014311082661151886, 0.057249583303928375, -0.043640051037073135, 0.046116095036268234, 0.029549285769462585, -0.048840731382369995, 0.061186328530311584, -0.01949111372232437, 0.03001982346177101, 0.032594431191682816, 0.002085416577756405, -0.05375901237130165, -0.0410146601498127, -0.006875365972518921, -0.017753876745700836, 0.04076745733618736, -0.018675269559025764, 0.030647819861769676, 0.009511969983577728, -0.07965938001871109, 0.02169097773730755, -0.01963549107313156, 0.05854301527142525, -0.010216780006885529, -0.030555468052625656, -0.044230930507183075, 0.02252173237502575, -0.03235037624835968, 0.009677719324827194, -0.020783603191375732, 0.019505834206938744, 0.02838706411421299, 0.029959900304675102, -0.027964996173977852, 0.009582949802279472, -0.01159427035599947, 0.07581872493028641, -0.04473857581615448, -0.006120037753134966, 0.001360207563266158, 0.004473753739148378, -0.01766638271510601, 0.00043732812628149986, 0.0007298951968550682, -0.0176954697817564, -0.08914808183908463, 0.029331795871257782, -0.04359929636120796, 0.01530058216303587, -0.013016690500080585, 0.011929892934858799, 0.09483696520328522, 0.01015511155128479, 0.0004833337152376771, 0.14160791039466858, -0.026655303314328194, 0.06947880238294601, -0.02635456994175911, -0.026648519560694695, 0.024608345702290535, 0.05568811669945717, 0.026317326352000237, 0.04070814326405525, -0.03872270882129669, -0.07275162637233734, 0.012705529108643532, -0.052802979946136475, -0.02624126523733139, -0.03954651951789856, 0.020653437823057175, 0.0036839444655925035, -0.006293418351560831, 0.03363772854208946, -0.03411787003278732, -0.03140760213136673, -0.009561379440128803, -0.03082730621099472, 0.07635866105556488, -0.049310352653265, -0.033719222992658615, 0.0644405409693718, -0.030315915122628212, -0.09237878769636154, 0.00002627485810080543, -0.004931531380861998, 0.059937186539173126, -0.042961325496435165, -0.008743722923099995, 0.018265530467033386, -0.0019625183194875717, 0.026804344728589058, -0.014692934229969978, -0.021789638325572014, 0.028079042211174965, -0.03352150321006775, -0.021191531792283058, 0.017487388104200363, -0.04645058140158653, -0.0015298958169296384, 0.012806519865989685, -0.023161977529525757, -0.00008328987314598635, -0.012980478815734386, 0.021854199469089508, 0.03002046048641205, -0.009528642520308495, 0.01684373989701271, 0.013995861634612083, -0.029794426634907722, -0.027540994808077812, 0.03536085784435272, 0.008096207864582539, -0.009980435483157635, -0.03737590089440346, -0.0002214041305705905, -0.0354902483522892, 0.022799035534262657, 0.02537582814693451, 0.005376540124416351, -0.03723098710179329, -0.030539628118276596, 0.018194567412137985, 0.012148719280958176, 0.03051137924194336, 0.009663159027695656, 0.017366666346788406, 0.017484569922089577, -0.0041986508294939995, 0.0034024647902697325, -0.01600543037056923, -0.03152671456336975, 0.07804182171821594, -0.03369435667991638, 0.06126564368605614, -0.006870670709758997, -0.01710560731589794, -0.04179945960640907, -0.03626008704304695, -0.051701124757528305, 0.05680128186941147, 0.04471699893474579, 0.030865095555782318, -0.0988282784819603, 0.04236467927694321, 0.032894574105739594, 0.02698145993053913, -0.001520243939012289, -0.009269618429243565, 0.07689082622528076, -0.009870215319097042, -0.0009973326232284307, -0.010150892660021782, 0.0008961950661614537, -0.0030719495844095945, -0.0027814952190965414, -0.007998310960829258, 0.022131796926259995, -0.005115385167300701, 0.024059303104877472, 0.05767100676894188, 0.07714714109897614, 0.05358905717730522, -0.06896143406629562, 0.04724034667015076, -0.028022361919283867, 0.004909098148345947, -0.06326016783714294, -0.0030306645203381777, 0.03185774385929108, 0.0045536537654697895, 0.014205826446413994, -0.011049493215978146, -0.001121871406212449, 0.0036647035740315914, -0.03292417153716087, 0.018904734402894974, -0.02812056802213192, -0.015595052391290665, 0.0033872034400701523, -0.042722370475530624, 0.002640588441863656, 0.04832009598612785, -0.003572948509827256, 0.03669846057891846, 0.000009496688107901718, -0.005707641132175922, 0.015173973515629768, -0.00436853151768446, -0.02592180296778679, -0.01791314035654068, -0.005859962664544582, -0.029951130971312523, 0.002394957235082984, -0.01944730430841446, -0.041448261588811874, 0.03937910869717598, -0.02618054486811161, -0.007869856432080269, -0.01708374358713627, 0.000636995246168226, 0.028926478698849678, 0.0016496487660333514, -0.0313393734395504, 0.02584828995168209, 0.03659438714385033, 0.0028427240904420614, -0.0614413358271122, 0.002317664446309209, -0.0029464184772223234, 0.04476254805922508, 0.029416833072900772, -0.002028252463787794, -0.004397112410515547, 0.04067795351147652, 0.013858765363693237, 0.010395890101790428, -0.004507243167608976, 0.00914925616234541, -0.012206382118165493, 0.01814771071076393, 0.07081454992294312, 0.03302647918462753, -0.036913372576236725, -0.0148739879950881, -0.012319051660597324, 0.00021821055270265788, 0.028684111312031746, -0.017935005947947502, -0.0044593303464353085, -0.006378392223268747, -0.009116665460169315, 0.06249184161424637, 0.01685122586786747, -0.024992622435092926, 0.012614425271749496, 0.014778041280806065, -0.06072298064827919, -0.006355758290737867, 0.03400770574808121, -0.008660764433443546, 0.026151401922106743, 0.03425546735525131, 0.09057074040174484, -0.03428395465016365, -0.02673923969268799, -0.006943774409592152, 0.025239532813429832, 0.015449274331331253, -0.07010885328054428, 0.012826886028051376, 0.01926383003592491, -0.0441293865442276, 0.003938113804906607, -0.010820155963301659, 0.029409222304821014, -0.04051028564572334, 0.04479914903640747, 0.061421871185302734, -0.04239310696721077, 0.021799592301249504, 0.004006735980510712, 0.0023695125710219145, 0.02298782579600811, -0.020240357145667076, -0.03082209825515747, 0.00020956102525815368, 0.005547817330807447, 0.036769963800907135, 0.03693775832653046, 0.03174445033073425, -0.07727944850921631, -0.012985787354409695, 0.029708851128816605, -0.0411403626203537, -0.02650551311671734, -0.006260658614337444, 0.02418615110218525, 0.0020054616034030914, -0.0072381081990897655, -0.025495924055576324, 0.04385652020573616, -0.03872894495725632, 0.0005230734241195023, -0.012803120538592339, -0.0009695850894786417, -0.019386498257517815, -0.03795219957828522, -0.0024826955050230026, -0.04322691261768341, 0.005897355265915394, 0.017491228878498077, 0.0020208724308758974, 0.015582405030727386, 0.021598508581519127, -0.060588300228118896, -0.021852925419807434, 0.0006333152414299548, -0.01683454029262066, 0.016386624425649643, -0.014691116288304329, -0.022069023922085762, 0.024168014526367188, 0.0035859623458236456, -0.00926520861685276, -0.01844022423028946, 0.022528085857629776, 0.007971590384840965, -0.052903059870004654, -0.0005523135187104344, -0.02912653423845768, -0.002192325657233596, 0.01179493684321642, -0.03676515817642212, 0.03698216378688812, 0.025757528841495514, -0.00040017307037487626, 0.017838411033153534, -0.004439449403434992, 0.0012112273834645748, -0.014225522056221962, -0.010951172560453415, 0.005044504534453154, -0.042412012815475464, -0.02131553553044796, -0.03995136544108391, 0.005740721710026264, -0.0035107024013996124, 0.07043103873729706, 0.031332556158304214, 0.06481872498989105, -0.01405077613890171, 0.03842001408338547, -0.019449584186077118, -0.010880392976105213, -0.021894479170441628, -0.060915783047676086, -0.0026164778973907232, 0.005706221796572208, 0.026011090725660324, 0.03722645714879036, -0.022540543228387833, -0.01601765863597393, 0.009160894900560379, 0.03418298438191414, -0.01683737523853779, 0.0010309132048860192, -0.008381933905184269, 0.05388028174638748, -0.02107040397822857, -0.02984311431646347, 0.03509030118584633, -0.052896227687597275, 0.030442656949162483, -0.03434378281235695, -0.046129100024700165, -0.006235218141227961, 0.0399266816675663, -0.023665810003876686, -0.015282552689313889, -0.0214675460010767, -0.0043581398203969, 0.053968627005815506, 0.049969710409641266, -0.00376112456433475, -0.046816300600767136, 0.018130306154489517, 0.03050730749964714, -0.05249808728694916, 0.023381603881716728, 0.0026327716186642647, 0.008681421168148518, -0.035564299672842026, -0.0009404662996530533, -0.018757158890366554, 0.03905477002263069, 0.04272720590233803, -0.020682787522673607, -0.012773299589753151, -0.03829324617981911, 0.035768430680036545, 0.047250546514987946, -0.007494669407606125, -0.018630310893058777, -0.01436344813555479, 0.003164218971505761, -0.031820524483919144, -0.03572021797299385, 0.01320519857108593, 0.04415244609117508, -0.006847403012216091, -0.021140556782484055, 0.026804087683558464, 0.00821021106094122, 0.024514662101864815, 0.005520487204194069, 0.020660294219851494, 0.030440784990787506, 0.03423034027218819, 0.003217390039935708, -0.022482886910438538, 0.018682634457945824, -0.009394613094627857, -0.008190973661839962, -0.05400894209742546, 0.012139401398599148, 0.02955443225800991, -0.005759727209806442, 0.007486814633011818, 0.02798408828675747, -0.045665137469768524, 0.002934162737801671, 0.013396562077105045, 0.021454807370901108, 0.042018335312604904, 0.0025333005469292402, 0.02488316409289837, -0.026885652914643288, 0.010957101359963417, -0.0010635331273078918, 0.08195927739143372, -0.06187324598431587, 0.0014987214235588908, 0.02746829204261303, 0.010159931145608425, 0.02517905831336975, 0.03435799106955528, -0.008524568751454353, -0.002700969809666276, 0.052825167775154114, 0.01931414194405079, 0.021583376452326775, -0.008960859850049019, -0.024274984374642372, -0.029143327847123146, -0.034771714359521866, -0.04015181213617325, 0.021234776824712753, 0.02660621702671051, 0.023985005915164948, -0.03871551901102066, 0.008745855651795864, -0.03882582485675812, 0.0372890904545784, -0.003926621749997139, 0.041849780827760696, -0.004503489937633276, 0.03699139133095741, 0.02459423430263996, 0.01678135246038437, 0.010255624540150166, 0.016408121213316917, -0.017270436510443687, -0.01971026137471199, -0.006261087954044342, -0.008010368794202805, 0.056731704622507095, 0.00042898781248368323, -0.0022213084157556295, -0.027125734835863113, -0.03581243008375168, 0.03394399955868721, 0.011000057682394981, -0.003554748371243477, -0.0119786337018013, 0.025211665779352188, 0.010714040137827396, -0.010823867283761501, 0.0016165650449693203, 0.013956219889223576, -0.0197439081966877, 0.015587146393954754, -0.013619579374790192, -0.01434931717813015, 0.03542875498533249, -0.015116140246391296, -0.03126976266503334, 0.007187936920672655, 0.0008858876535668969, 0.02378121390938759, 0.042223598808050156, -0.03764121234416962, -0.019534088671207428, -0.00991677213460207, -0.014410056173801422, -0.02134569175541401, 0.011674153618514538, -0.02764110267162323, -0.02899661287665367, 0.01042783260345459, -0.026905842125415802, -0.030416131019592285, 0.013592250645160675, 0.016929782927036285, -0.0013299788115546107, -0.01363280601799488, -0.008420846424996853, -0.003741696709766984, 0.015675904229283333, -0.024851594120264053, 0.002041697036474943, -0.015118462964892387, -0.02728729508817196, -0.0031117242760956287, 0.007667600642889738, 0.0011357525363564491, -0.027683200314641, 0.015237794257700443, 0.042340878397226334, 0.03471047431230545, -0.025890497490763664, -0.011570481583476067, 0.02026454359292984, 0.005288804415613413, 0.007743993308395147, -0.035916347056627274, 0.009302976541221142, -0.014939794316887856, 0.05094679817557335, 0.04072700813412666, -0.009190168231725693, -0.001978832995519042, 0.0016835960559546947, 0.001218709396198392, -0.004966615233570337, -0.010151548311114311, 0.0022125951945781708, -0.003708052448928356, 0.013402242213487625, -0.021937279030680656, 0.05161776766180992, -0.03326089307665825, -0.000417581555666402, -0.05010635405778885, -0.007751725148409605, -0.03467776998877525, 0.02675633877515793, -0.03939072787761688, 0.012940467335283756, -0.07503464072942734, 0.022254642099142075, 0.00592141505330801, -0.0032307899091392756, 0.00033680658088997006, -0.0016116644255816936, 0.029173914343118668, 0.033287495374679565, 0.02963145636022091, 0.01823236234486103, -0.013193472288548946, -0.01281316950917244, -0.03906525298953056, 0.024485107511281967, 0.00039762130472809076, 0.024305032566189766, -0.012862218543887138, -0.01598169282078743, 0.0430336520075798, -0.04493865743279457, 0.03075878880918026, 0.02231941930949688, 0.04218029975891113, -0.004579532891511917, -0.008050542324781418, 0.006931554991751909, -0.004501964431256056, -0.0019801531452685595, 0.05608469247817993, -0.0023744867648929358, 0.01931888237595558, 0.029629036784172058, 0.01934860274195671, -0.05158035457134247, 0.010743193328380585, 0.023361170664429665, -0.014052721671760082, 0.03378802165389061, 0.00511067733168602, 0.002136731520295143, -0.00471162423491478, -0.007020294666290283, -0.04523823410272598, 0.009874545969069004, -0.028638847172260284, -0.024584034457802773, -0.01462101936340332, -0.0013356166891753674, -0.04478460177779198, -0.03265286982059479, 0.009662636555731297, -0.00922483578324318, -0.053674109280109406, 0.03373946622014046, 0.03686995804309845, 0.031122444197535515, -0.017023203894495964, 0.027128195390105247, 0.0005686310469172895, 0.034369613975286484, 0.010919959284365177, -0.00018542827456258237, 0.020166583359241486, 0.016571300104260445 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
5. Wrapping up Sentiment analysis with Python has never been easier! Tools such as 🤗Transformers and the 🤗Hub makes sentiment analysis accessible to all developers. You can use open source, pre-trained models for sentiment analysis in just a few lines of code 🔥 Do you want to train a custom model for sentiment analysis with your own data? Easy peasy! You can fine-tune a model using Trainer API to build on top of large language models and get state-of-the-art results. If you want something even easier, you can use AutoNLP to train custom machine learning models by simply uploading data. If you have questions, the Hugging Face community can help answer and/or benefit from, please ask them in the Hugging Face forum. Also, join our discord server to talk with us and with the Hugging Face community.
[ 0.05996284261345863, -0.02690276689827442, 0.03558487817645073, -0.025126880034804344, 0.04238292947411537, 0.08916526287794113, 0.014786399900913239, 0.07461779564619064, -0.006392117124050856, -0.027314921841025352, -0.1074417382478714, 0.0630352571606636, -0.041911642998456955, 0.03693438693881035, 0.024769380688667297, -0.06793258339166641, 0.05186942219734192, 0.004472355358302593, 0.03417088836431503, 0.012649045325815678, -0.05272701382637024, -0.040979206562042236, 0.01733909174799919, 0.00253189611248672, -0.007151206489652395, -0.06056895852088928, 0.06470080465078354, 0.02902389131486416, -0.051698945462703705, -0.016665402799844742, -0.11246982216835022, 0.008222869597375393, -0.07410323619842529, -0.004945933818817139, 0.01946166530251503, 0.028382116928696632, -0.11444929987192154, 0.07343482226133347, 0.046137887984514236, 0.00885456521064043, -0.008554046042263508, -0.025171268731355667, -0.07338917255401611, 0.04500330984592438, -0.03483361750841141, -0.04809044674038887, -0.1880829781293869, 0.08168333023786545, 0.004859129898250103, -0.024508558213710785, -0.0794091671705246, 0.11611293256282806, -0.03599430248141289, 0.04924602061510086, -0.025086358189582825, -0.013686972670257092, 0.023930512368679047, -0.0657806470990181, -0.025080719962716103, 0.018487446010112762, 0.024834955111145973, 0.0025634339544922113, 0.008347878232598305, 0.007918019779026508, 0.03193116560578346, 0.032957617193460464, -0.046277474611997604, 0.032421890646219254, -0.08054294437170029, -0.04148150607943535, 0.034093402326107025, -0.03096083365380764, -0.033475667238235474, -0.027227645739912987, -0.00644346047192812, -0.02455236203968525, 0.017988301813602448, 0.004121583886444569, 0.009950757957994938, 0.018033934757113457, 0.02890508621931076, -0.0011182889575138688, 0.05796615406870842, 0.01909259520471096, 0.09048351645469666, 0.031301792711019516, 0.0588890016078949, -0.027540389448404312, -0.03385184332728386, 0.061623018234968185, 0.015874305739998817, -0.06853215396404266, 0.028910165652632713, -0.0028968676924705505, 0.06568586081266403, -0.011807809583842754, -0.029097430408000946, 0.06329025328159332, -0.0144504988566041, -0.01368302758783102, -0.007319377735257149, -0.05061792954802513, 0.004698858130723238, -0.07452977448701859, -0.022022301331162453, 0.027617720887064934, 0.04180362820625305, -0.07737021893262863, -0.044676005840301514, -0.0016335450345650315, -0.017986737191677094, -0.012850411236286163, -0.006825542077422142, 0.06159498170018196, -0.08694668859243393, 0.05977175757288933, 0.02254025824368, -0.022940611466765404, -0.04128176346421242, 0.0035204968880861998, 0.015210112556815147, 0.060706883668899536, 0.021931473165750504, 0.014104261063039303, -0.03054565005004406, 0.03827603533864021, 0.014629745855927467, 0.015914663672447205, 0.0385616272687912, -0.027853451669216156, -0.005681591108441353, 0.02152385376393795, 0.06589764356613159, -0.0037178662605583668, -0.003646031953394413, -0.07579179108142853, 0.00019734297529794276, -0.09293791651725769, 0.03941516950726509, 0.02438201755285263, -0.016423478722572327, 0.08589253574609756, -0.023322386667132378, 0.06691087037324905, 0.03088167868554592, 0.024046633392572403, -0.09878487139940262, 0.06289996951818466, 0.012865803204476833, 0.006257323548197746, -0.0959768146276474, 0.008325555361807346, 0.0008761342032812536, -0.06843818724155426, 0.002323659835383296, 0.0712127834558487, -0.056959118694067, -0.05764942988753319, -0.01923152431845665, 0.012888889759778976, 0.015222234651446342, 0.03205886855721474, -0.0575936995446682, -0.00449424609541893, 0.04561156406998634, -0.030847234651446342, 0.016651473939418793, 0.027200203388929367, -0.0005642335745505989, 0.03343551605939865, 0.009726032614707947, -0.019716672599315643, 0.07658701390028, -0.05145025625824928, 0.00439020711928606, 0.025107091292738914, 0.03443584591150284, 0.02944718860089779, -0.009093167260289192, 0.018846163526177406, -0.014051212929189205, 0.07897716015577316, 0.012300925329327583, 0.025083158165216446, 0.03783632069826126, -0.04258884862065315, 0.0073502860032022, -0.08516309410333633, 0.0011085382429882884, -0.04005489498376846, -0.0027807990554720163, 0.001959446584805846, 0.022817324846982956, -0.01212592888623476, 0.08243847638368607, -0.05403156578540802, 0.0005108374170958996, 0.11112135648727417, 0.0043389699421823025, 0.014961954206228256, 0.05261586606502533, -0.06463854014873505, 0.047540370374917984, -0.03548924997448921, 0.010975223034620285, -0.021118277683854103, -0.003719799919053912, -0.026684200391173363, -0.018052395433187485, -0.012061434797942638, -0.0008652584510855377, -0.11835487186908722, 0.04981847479939461, -0.05676279217004776, -0.036376845091581345, -0.005456428974866867, -0.033363960683345795, 0.043011609464883804, 0.011778421700000763, -0.011258739978075027, 0.19396327435970306, -0.0649234727025032, 0.0012283551041036844, -0.020871609449386597, -0.03925042226910591, 0.05681847408413887, 0.06013832613825798, 0.05551033467054367, 0.07743150740861893, -0.06504064053297043, -0.04646974802017212, -0.08586101233959198, -0.05090031772851944, -0.012550062499940395, -0.04734879732131958, -0.005613960325717926, 0.06902705132961273, -0.024777408689260483, 0.005502720363438129, 0.009469914250075817, -0.026761682704091072, -0.00537666492164135, 0.004445560276508331, 0.060718245804309845, -0.020766476169228554, -0.014377234503626823, 0.08557704836130142, -0.010186149738729, -0.06226421147584915, 0.03516761586070061, -0.03272904455661774, 0.07427813857793808, 0.005588163621723652, 0.022486940026283264, 0.009496495127677917, -0.0010041848290711641, 0.03338479995727539, -0.012612194754183292, -0.010906553827226162, 0.07111101597547531, 0.004337753169238567, -0.0579143650829792, -0.010305315256118774, -0.045191265642642975, 0.01688321679830551, -0.04572565481066704, 0.0006879997672513127, -0.007916154339909554, 0.02071753889322281, 0.039491526782512665, 0.020718349143862724, -0.015706682577729225, 0.04024401679635048, 0.01284695416688919, 0.00502319959923625, 0.05114679038524628, 0.02384033612906933, 0.012881421484053135, -0.018550381064414978, -0.030175870284438133, -0.019136114045977592, -0.06112772598862648, 0.016480205580592155, 0.02090582251548767, 0.0313379168510437, -0.05578074976801872, -0.022526314482092857, -0.008663362823426723, -0.016552278771996498, 0.05210810527205467, 0.021617939695715904, 0.0256649237126112, -0.0021615123841911554, -0.021252162754535675, 0.0049629551358520985, -0.014650956727564335, 0.007421273738145828, 0.03807124122977257, 0.00006299793312791735, 0.06261095404624939, 0.007355240639299154, -0.005062553100287914, -0.0034271636977791786, -0.023047488182783127, -0.038746293634176254, 0.004664039239287376, 0.048216309398412704, 0.019643176347017288, -0.10325521230697632, -0.006048549897968769, -0.0059134382754564285, -0.022475160658359528, 0.027797603979706764, -0.028884917497634888, 0.05291128531098366, -0.02067769318819046, -0.025505762547254562, 0.04322228580713272, 0.003783999942243099, 0.01863686554133892, 0.04291066154837608, 0.02052569016814232, -0.03140600025653839, -0.018029503524303436, 0.00008496659575030208, 0.011291315779089928, 0.05604323744773865, 0.03994239121675491, -0.05174444988369942, 0.07155799865722656, -0.0022245377767831087, -0.0104660140350461, -0.060014232993125916, -0.009259454905986786, 0.029221780598163605, 0.0062318057753145695, 0.015297969803214073, -0.03217693045735359, 0.0059652021154761314, -0.03138691186904907, -0.04673025757074356, 0.0009672967717051506, -0.014985107816755772, -0.023144762963056564, 0.016656262800097466, 0.04264303296804428, 0.018123043701052666, 0.025792837142944336, -0.0214303620159626, 0.005010660737752914, 0.010950163006782532, -0.017082717269659042, 0.012009459547698498, -0.012672267854213715, -0.0028537216130644083, 0.0002701823541428894, -0.005418230313807726, -0.04006337374448776, -0.0020541558042168617, -0.02686818316578865, 0.01285452488809824, 0.032745361328125, -0.005906331818550825, 0.005575395189225674, 0.017589926719665527, 0.016397085040807724, 0.005773706827312708, 0.014458049088716507, -0.05120246484875679, 0.014569368213415146, -0.008232513442635536, -0.03795010969042778, -0.02540619671344757, 0.02780340425670147, 0.02032659202814102, -0.011150182224810123, 0.020627692341804504, 0.04031809791922569, 0.006616875063627958, 0.03318415954709053, -0.00870443880558014, 0.00622892938554287, -0.02977817878127098, 0.021377038210630417, -0.016338815912604332, -0.01323093380779028, 0.06499279290437698, 0.05041825771331787, -0.020170046016573906, -0.05987880751490593, -0.022250257432460785, -0.02306656911969185, 0.00013042587670497596, -0.001264172256924212, 0.007229105569422245, -0.020620549097657204, -0.0044119954109191895, 0.0663297027349472, 0.04241878539323807, -0.029745539650321007, 0.01774071343243122, 0.008153893053531647, 0.011127951554954052, -0.016102811321616173, 0.023925844579935074, 0.02145216427743435, 0.02235843427479267, -0.016243334859609604, 0.0493081659078598, -0.013335319235920906, -0.03343512862920761, 0.002597813494503498, 0.024380045011639595, 0.02271994948387146, -0.05463616922497749, -0.001999972388148308, 0.05058133229613304, -0.023675767704844475, -0.0301272701472044, 0.002706858329474926, 0.012061914429068565, -0.025426581501960754, 0.05453622713685036, 0.026204809546470642, -0.02824700064957142, -0.00558067811653018, -0.011865578591823578, 0.044855453073978424, -0.01856984756886959, 0.011450307443737984, -0.010665806010365486, -0.024509837850928307, 0.03588629141449928, 0.006113150157034397, 0.03460266813635826, 0.008467848412692547, -0.01831165887415409, -0.006321475375443697, 0.007798234466463327, -0.03869470953941345, -0.0017818891210481524, 0.020523076876997948, 0.021788323298096657, 0.019254358485341072, -0.01486868318170309, 0.02193358540534973, 0.006557764485478401, -0.02426168881356716, -0.034764744341373444, -0.018894417211413383, 0.015603515319526196, -0.012974327430129051, 0.0006034325924701989, -0.009349219501018524, -0.05594979599118233, -0.000960032339207828, -0.0020139238331466913, 0.009434507228434086, 0.01131775975227356, 0.014884088188409805, -0.04864298552274704, -0.011641299352049828, 0.031230103224515915, -0.030299806967377663, -0.03380327299237251, 0.015599199570715427, -0.01258761901408434, 0.04075378552079201, 0.00804008450359106, 0.003615560242906213, -0.024167250841856003, 0.007964731194078922, -0.010320762172341347, -0.03370502218604088, 0.0007145359413698316, -0.04329352453351021, 0.0032460056245326996, 0.023387519642710686, -0.0035410106647759676, 0.05484333261847496, 0.02361544594168663, -0.04091237857937813, -0.005335221067070961, 0.058914992958307266, 0.010523101314902306, 0.019021309912204742, -0.06436461955308914, 0.020574776455760002, -0.032896071672439575, -0.014096676371991634, 0.002785530174151063, -0.0009261566447094083, -0.00012881199654657394, 0.02588551864027977, 0.05395874008536339, 0.05642971023917198, 0.01304293517023325, 0.030298521742224693, -0.029940880835056305, -0.0038005926180630922, -0.008977001532912254, -0.051533207297325134, 0.0031348145566880703, -0.035525280982255936, -0.0018879702547565103, -0.017339136451482773, -0.026599954813718796, -0.023277148604393005, 0.002305456204339862, 0.03135788440704346, -0.02449653670191765, -0.017509253695607185, 0.025199545547366142, 0.04194357991218567, -0.02024739421904087, -0.05275464802980423, 0.02243346907198429, -0.04846986383199692, -0.007668456062674522, -0.0029620779678225517, 0.025083430111408234, -0.014156523160636425, -0.016046548262238503, -0.004258034750819206, -0.02648516371846199, 0.009770646691322327, 0.001073186402209103, 0.0013966854894533753, 0.006717984564602375, -0.021108461543917656, -0.07733197510242462, -0.003961449488997459, 0.03999575227499008, -0.038937073200941086, 0.0007081980002112687, 0.00401122635230422, -0.00016390028758905828, 0.006058042868971825, 0.044290173798799515, -0.02309590019285679, 0.015955571085214615, 0.04434673860669136, 0.015541442669928074, -0.029747914522886276, -0.049802396446466446, 0.03072229027748108, 0.006049772258847952, -0.025666670873761177, -0.011802561581134796, -0.003902709810063243, 0.009092195890843868, 0.004669761750847101, -0.024726882576942444, 0.017925307154655457, 0.03266691043972969, -0.003755035810172558, -0.004725638777017593, 0.0010279108537361026, -0.017894545570015907, 0.02497357688844204, 0.032601941376924515, -0.024079417809844017, 0.04611523821949959, 0.035304635763168335, 0.01901274360716343, -0.0078298794105649, 0.017825398594141006, -0.02718927711248398, -0.0017551520140841603, -0.1003488078713417, 0.014906773343682289, 0.034585803747177124, -0.02185683697462082, 0.01355628203600645, 0.03208217769861221, -0.04250039532780647, -0.002566446317359805, -0.0029912751633673906, 0.04978540539741516, 0.03580876439809799, 0.0038304883055388927, 0.011120754294097424, -0.007933889515697956, -0.012991029769182205, 0.0018118660664185882, 0.07038836926221848, -0.018103687092661858, 0.018062913790345192, 0.012205981649458408, 0.023002777248620987, 0.05313003808259964, 0.019119994714856148, 0.0068468921817839146, 0.013980967923998833, 0.057438191026449203, 0.03670820966362953, 0.014220653101801872, 0.020210903137922287, -0.03741811588406563, -0.0001952833408722654, -0.04417140781879425, -0.014290373772382736, -0.02964024804532528, 0.015932874754071236, 0.03530831262469292, -0.025869540870189667, -0.005410501267760992, -0.020318182185292244, 0.03759080544114113, 0.029856102541089058, 0.04791848734021187, 0.0153596680611372, 0.026887431740760803, 0.07604655623435974, 0.027892112731933594, 0.029638653621077538, 0.03593755513429642, -0.004227046389132738, -0.004362113308161497, 0.026401376351714134, 0.04068884998559952, 0.02970097027719021, 0.0007011682027950883, 0.002601113636046648, 0.04966501519083977, -0.007572229020297527, 0.012307267636060715, 0.014885993674397469, -0.01681109331548214, -0.010391890071332455, -0.006983491592109203, 0.01399191189557314, -0.007740098051726818, 0.012521755881607533, 0.0009288242436014116, -0.002681206911802292, 0.03808179497718811, 0.0014384117675945163, -0.010218794457614422, 0.05315624922513962, 0.023669205605983734, -0.009267522022128105, -0.01966557651758194, -0.01437615416944027, 0.015355146490037441, 0.005105261225253344, -0.02904769591987133, -0.039513010531663895, -0.04372817650437355, -0.046106208115816116, -0.020283130928874016, 0.017721647396683693, -0.005933099426329136, -0.04970133304595947, 0.0033862062264233828, 0.01748001202940941, -0.03519873321056366, 0.021943625062704086, 0.006937475875020027, 0.006870944984257221, -0.03660682961344719, 0.00026797832106240094, -0.03132970258593559, -0.02781488001346588, -0.005847913213074207, -0.03752227500081062, 0.010108386166393757, 0.003782514715567231, -0.007091339211910963, 0.014305985532701015, 0.02161465957760811, -0.015379726886749268, -0.026212019845843315, 0.02147548273205757, 0.03328665345907211, -0.0003524349885992706, 0.022645119577646255, 0.020960133522748947, -0.007721216417849064, 0.02850853092968464, -0.009077475406229496, -0.051173776388168335, -0.013810931704938412, 0.0031245138961821795, 0.047613151371479034, -0.005816672928631306, -0.036776352673769, -0.003608471481129527, 0.03186211735010147, 0.02000802382826805, 0.013189166784286499, 0.015764690935611725, -0.001273158355616033, 0.018504615873098373, -0.0668085590004921, 0.04488315433263779, -0.041461192071437836, 0.021387789398431778, -0.0663812980055809, -0.05374795198440552, -0.026550617069005966, 0.02579287812113762, 0.0023785787634551525, -0.015258694998919964, -0.05357508733868599, 0.013779310509562492, -0.044924844056367874, -0.0045943190343678, 0.015699781477451324, 0.029715722426772118, 0.036734677851200104, 0.04387003928422928, -0.020437918603420258, 0.032073866575956345, -0.022608593106269836, 0.0031080027110874653, -0.034251101315021515, 0.02023404836654663, 0.028680775314569473, 0.011542253196239471, -0.011462057009339333, -0.02001003734767437, 0.0031778367701917887, 0.0026239354629069567, -0.0160590298473835, -0.005939777009189129, 0.0063704270869493484, -0.01147784199565649, -0.053312744945287704, -0.016172267496585846, 0.011352368630468845, -0.0277390293776989, 0.051395200192928314, 0.0015540322056040168, -0.009120089001953602, 0.018163412809371948, 0.015565752051770687, -0.06019601598381996, 0.04660544916987419, -0.00987424049526453, 0.016517924144864082, 0.027832413092255592, 0.03832954168319702, 0.03588741645216942, -0.0030430955812335014, -0.004433040041476488, -0.0007737871492281556, 0.01367815863341093, -0.0181706752628088, -0.04004459083080292, -0.013572975061833858, 0.059502363204956055, 0.000037102778151165694, -0.03747134283185005, 0.02620634250342846, -0.038388900458812714, -0.021196141839027405, -0.02409421093761921, 0.020275793969631195, 0.01673169806599617, 0.02207931876182556, 0.007078709080815315, -0.008829140104353428, 0.06449099630117416, 0.032297082245349884, -0.004311840515583754, -0.033732615411281586, 0.006333576049655676 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
a. Fine-tuning model with Python In this tutorial, you'll use the IMDB dataset to fine-tune a DistilBERT model for sentiment analysis. The IMDB dataset contains 25,000 movie reviews labeled by sentiment for training a model and 25,000 movie reviews for testing it. DistilBERT is a smaller, faster and cheaper version of BERT. It has 40% smaller than BERT and runs 60% faster while preserving over 95% of BERT’s performance. You'll use the IMDB dataset to fine-tune a DistilBERT model that is able to classify whether a movie review is positive or negative. Once you train the model, you will use it to analyze new data! ⚡️ We have created this notebook so you can use it through this tutorial in Google Colab.
[ -0.026757752522826195, -0.006379018537700176, -0.046442076563835144, 0.02019844949245453, 0.06729011982679367, 0.061671894043684006, 0.0036980044096708298, 0.010332351550459862, 0.006892798468470573, -0.0015213137958198786, -0.04332289844751358, 0.042163360863924026, -0.0052939848974347115, 0.017265761271119118, 0.07542113214731216, -0.013380960561335087, 0.07219800353050232, 0.010833079926669598, -0.003966707736253738, 0.01051189936697483, -0.012375321239233017, -0.09068607538938522, 0.026656577363610268, 0.028661098331212997, 0.005239296704530716, -0.0005208461079746485, 0.08315511047840118, 0.03271707519888878, -0.11959485709667206, 0.011752263642847538, -0.05829613655805588, 0.017724420875310898, -0.02530568279325962, 0.01947631873190403, -0.059947241097688675, 0.019863760098814964, -0.038644593209028244, 0.04306745156645775, 0.016447458416223526, -0.0030962624587118626, -0.050332240760326385, -0.0654626414179802, -0.028575239703059196, 0.02626178413629532, -0.03745646774768829, -0.030446290969848633, -0.08727824687957764, 0.038857314735651016, 0.005686641205102205, -0.07851775735616684, -0.07252027094364166, 0.07867688685655594, 0.022884758189320564, -0.023697149008512497, -0.026434004306793213, -0.023152729496359825, 0.07243762910366058, -0.05344582349061966, 0.018242724239826202, 0.09952639043331146, 0.04070793837308884, -0.007397637236863375, -0.011989439837634563, -0.028415948152542114, 0.011351129040122032, 0.04809301719069481, -0.06031307205557823, 0.03200497850775719, -0.04023080691695213, -0.06914804130792618, 0.03064754046499729, -0.01090400479733944, -0.06166018545627594, -0.006016049534082413, -0.005356503184884787, -0.029364246875047684, 0.016928866505622864, -0.020373087376356125, -0.039880357682704926, -0.004995512776076794, -0.030817653983831406, -0.00997813418507576, 0.0003608572296798229, 0.04312819242477417, 0.06132158264517784, 0.024334194138646126, 0.04496027156710625, -0.0348895788192749, -0.10785629600286484, -0.012408919632434845, -0.056674737483263016, -0.06088033318519592, 0.01374673843383789, -0.02975292317569256, 0.0500151552259922, -0.04765976592898369, -0.05331259220838547, 0.005110464058816433, -0.01025361567735672, 0.008905881084501743, 0.0491836778819561, -0.0748865157365799, 0.0651908591389656, -0.0767383724451065, -0.026189295575022697, 0.05651788413524628, -0.03022650070488453, -0.040347326546907425, -0.0716957300901413, 0.039367228746414185, -0.02562318928539753, 0.03128242492675781, -0.060928765684366226, 0.08802566677331924, -0.06018897518515587, -0.001593486755155027, 0.029566043987870216, -0.02522990107536316, -0.0354599766433239, 0.026908988133072853, 0.012170442380011082, 0.04356195777654648, 0.044345322996377945, -0.0083084125071764, -0.06029244884848595, 0.0701141357421875, -0.03356644883751869, 0.04393204301595688, 0.028179576620459557, 0.010703351348638535, 0.05169328302145004, -0.03218001127243042, 0.051908012479543686, -0.031164366751909256, -0.060202885419130325, -0.05899570509791374, -0.08070556074380875, -0.025048960000276566, 0.007165838498622179, 0.050741925835609436, 0.06614052504301071, 0.08187304437160492, -0.08981329202651978, -0.016960348933935165, 0.03647215664386749, 0.0027735710609704256, -0.021551277488470078, 0.05889236554503441, 0.029028775170445442, -0.02358945459127426, -0.12144650518894196, 0.05382959917187691, -0.01657942496240139, -0.11710293591022491, 0.01351025141775608, 0.08842109888792038, -0.042000818997621536, -0.01465236023068428, 0.0003050711238756776, 0.029537875205278397, 0.05711061507463455, 0.014004508964717388, -0.028725504875183105, -0.07610934972763062, -0.0003044448094442487, -0.03021419607102871, 0.02548949606716633, 0.04889208823442459, -0.04854811728000641, 0.007711604703217745, -0.007962502539157867, -0.017829015851020813, 0.06468931585550308, -0.00746314087882638, 0.01662801206111908, 0.013035474345088005, -0.0038835578598082066, 0.02012096717953682, -0.050293222069740295, -0.027411434799432755, -0.012882878072559834, 0.041684914380311966, 0.02029426395893097, 0.05024115368723869, 0.07709573954343796, -0.05328909307718277, 0.06914762407541275, -0.048563215881586075, -0.013625294901430607, -0.009746238589286804, -0.01824290305376053, 0.008630459196865559, 0.0881737619638443, 0.002578210085630417, 0.04534657299518585, -0.04657788947224617, -0.035059984773397446, 0.004022597800940275, 0.0474795326590538, -0.06909587234258652, -0.010162350721657276, -0.046634476631879807, 0.06509856879711151, -0.006613471079617739, 0.05383874848484993, -0.00020184805907774717, -0.00874269288033247, -0.005778344348073006, -0.021038588136434555, 0.016833405941724777, 0.0411200188100338, -0.1118854507803917, 0.023718973621726036, -0.08835504949092865, 0.019243961200118065, -0.015476412139832973, -0.024625863879919052, -0.001316219917498529, 0.031969185918569565, -0.0051584551110863686, 0.12775230407714844, -0.02573920600116253, -0.004863495007157326, -0.04415677860379219, -0.020102186128497124, -0.02084815502166748, 0.08892940729856491, 0.027913890779018402, 0.11766482889652252, 0.013248374685645103, -0.03830209746956825, 0.018257658928632736, -0.011494741775095463, 0.03633366897702217, -0.0466606430709362, -0.03586505725979805, -0.009599771350622177, 0.035948049277067184, 0.0070571498945355415, 0.016557520255446434, -0.00780413718894124, 0.045721523463726044, -0.0841764286160469, 0.10267472267150879, -0.02420206554234028, 0.028400326147675514, 0.04590020701289177, -0.0029328414238989353, -0.0024163287598639727, -0.04871416464447975, -0.02869744971394539, 0.02716847136616707, -0.012433895841240883, -0.019179748371243477, -0.04082658886909485, 0.01352290716022253, 0.018677713349461555, 0.041670043021440506, 0.015203653834760189, 0.07002246379852295, -0.008642639964818954, -0.012698862701654434, -0.01939244009554386, -0.01457500271499157, 0.03800361603498459, -0.010637139901518822, -0.034113235771656036, 0.009643481113016605, -0.010234993882477283, -0.005935703404247761, -0.01521397102624178, -0.004142375197261572, 0.03931986168026924, 0.04527422785758972, 0.014566641300916672, 0.07107892632484436, 0.025078751146793365, 0.001563854981213808, -0.04948567971587181, -0.0072681112214922905, 0.008799916133284569, -0.04495188966393471, 0.0048454697243869305, 0.02174241654574871, 0.005114395637065172, 0.010937272571027279, -0.025277169421315193, -0.027302972972393036, 0.011542010121047497, 0.007358863018453121, 0.039523109793663025, 0.03372914716601372, -0.011380328796803951, -0.016278890892863274, 0.005017971619963646, 0.019552083685994148, -0.021662933751940727, 0.018738633021712303, 0.0008870886522345245, 0.027764907106757164, -0.001884583500213921, 0.012203066609799862, -0.05701984092593193, -0.006686728447675705, -0.025021888315677643, 0.03997116908431053, 0.041491247713565826, -0.005141368135809898, -0.07288851588964462, 0.01623273268342018, 0.02081413008272648, -0.03223119676113129, 0.018070733174681664, -0.057935915887355804, 0.055883537977933884, -0.01688797026872635, -0.039781708270311356, 0.022830955684185028, -0.004835088271647692, 0.02062908187508583, 0.005819159094244242, 0.02732214331626892, 0.030589250847697258, -0.05597199127078056, -0.00245656562037766, 0.0024639093317091465, 0.029649442061781883, 0.03714217245578766, -0.060458071529865265, 0.045652877539396286, 0.008529317565262318, -0.01685153879225254, -0.0037934354040771723, -0.009380723349750042, -0.0168454609811306, 0.016264157369732857, 0.025794224813580513, -0.00182612263597548, 0.039474643766880035, -0.009304107166826725, -0.058685820549726486, 0.01247408241033554, 0.0017624497413635254, -0.007736793253570795, 0.016300197690725327, 0.025460410863161087, 0.02553330920636654, 0.04225274547934532, -0.009107334539294243, 0.020080888643860817, 0.02055939845740795, 0.012551309540867805, 0.026899348944425583, -0.0033763269893825054, -0.025154870003461838, -0.0031435093842446804, -0.011799546889960766, -0.023570746183395386, -0.016565801575779915, 0.0076036881655454636, -0.022155193611979485, 0.08613225817680359, -0.028548767790198326, 0.010409404523670673, 0.03069332428276539, -0.027188893407583237, 0.021256232634186745, 0.022745534777641296, 0.0022861165925860405, 0.07000036537647247, -0.00774241890758276, -0.014755701646208763, -0.0049137454479932785, -0.010215346701443195, 0.0013335493858903646, 0.01422955933958292, -0.030755046755075455, -0.01406977791339159, -0.003021416487172246, 0.01256049145013094, 0.040699850767850876, -0.0009000083664432168, -0.019984759390354156, -0.0005406017880886793, -0.006682322360575199, 0.00428527919575572, -0.015189425088465214, 0.03585537150502205, 0.005903394892811775, -0.03367200866341591, -0.01721985824406147, -0.022661730647087097, 0.07789124548435211, -0.030568813905119896, -0.02094614878296852, -0.09251289814710617, 0.0253224465996027, -0.007954916916787624, 0.02204841561615467, 0.04438626021146774, -0.03203298896551132, 0.03135862201452255, -0.013465967029333115, -0.008282016962766647, 0.011158090084791183, 0.020609671249985695, -0.0029098675586283207, -0.0045573716051876545, 0.05086923763155937, 0.0032610304187983274, -0.022488467395305634, -0.004356022458523512, 0.01888078637421131, 0.013065172359347343, -0.06074226647615433, -0.020669378340244293, -0.004522107075899839, -0.006698426324874163, -0.041928134858608246, 0.04267410188913345, 0.0023041784297674894, -0.018031349405646324, 0.04760998487472534, 0.04031573235988617, -0.00304932938888669, 0.021715816110372543, 0.006488192826509476, 0.030936384573578835, 0.012144004926085472, 0.00635508494451642, 0.022687410935759544, -0.011521419510245323, 0.03563535213470459, -0.014446442015469074, 0.05753764137625694, 0.01952957734465599, -0.022998997941613197, -0.024187350645661354, -0.02861601486802101, -0.03091488964855671, -0.030701780691742897, 0.010133658535778522, -0.00200889864936471, -0.05725238099694252, 0.0037333189975470304, 0.014600441791117191, 0.0061876182444393635, -0.008815156295895576, 0.03589186072349548, -0.0220466461032629, 0.031426046043634415, -0.009573468007147312, 0.0149357495829463, -0.023878803476691246, 0.01913076639175415, 0.010382961481809616, -0.01668141782283783, 0.03667857497930527, -0.01563400961458683, 0.013584292493760586, -0.0163172148168087, -0.03563208505511284, -0.005382404197007418, 0.005017038434743881, -0.008041705936193466, 0.01822701282799244, -0.021838583052158356, 0.05779893696308136, 0.022022955119609833, 0.02333880588412285, -0.04360990971326828, 0.015787987038493156, 0.02240024507045746, 0.027346108108758926, 0.0015137559967115521, -0.03550310432910919, 0.003031267784535885, -0.0034116737078875303, -0.005800611339509487, 0.03594512492418289, 0.0029176976531744003, 0.001164065906777978, 0.016426077112555504, 0.03783203661441803, 0.013804578222334385, -0.027111059054732323, -0.03695840388536453, 0.010520895011723042, -0.0485895499587059, -0.029582448303699493, -0.03527699038386345, 0.03257898986339569, 0.020659906789660454, 0.04866017773747444, 0.031787317246198654, 0.03474777191877365, 0.02048715204000473, -0.01612873002886772, -0.005664164200425148, -0.013876636512577534, -0.006659889593720436, -0.04760238155722618, -0.006181391887366772, 0.010017667897045612, -0.018501434475183487, 0.026720471680164337, -0.013238823972642422, -0.04022382199764252, 0.03517216444015503, 0.02090890146791935, -0.018042774870991707, -0.007097050081938505, 0.02861313708126545, -0.01207483559846878, -0.03659207001328468, -0.06173679605126381, 0.0313822478055954, -0.07345062494277954, 0.0301866065710783, -0.0168322641402483, -0.001051053055562079, -0.022453952580690384, -0.0019736499525606632, -0.01620594970881939, -0.03289688751101494, -0.012538766488432884, 0.04068341478705406, 0.011224109679460526, -0.029839374125003815, -0.01605502888560295, -0.01727249287068844, 0.05532506853342056, -0.03765992075204849, -0.05065760388970375, 0.043556999415159225, 0.01607408933341503, 0.001996941864490509, 0.026581836864352226, 0.021985741332173347, -0.005832785274833441, 0.00575566990301013, 0.027543451637029648, -0.017451157793402672, -0.04673315957188606, -0.04193038120865822, 0.03867581486701965, 0.038894008845090866, -0.021519670262932777, -0.009846899658441544, -0.039441850036382675, -0.024676034227013588, -0.031051404774188995, -0.04976605996489525, 0.05112644284963608, 0.02797241508960724, -0.009580746293067932, 0.06698727607727051, -0.027919868007302284, -0.001800752361305058, 0.031940966844558716, -0.057132624089717865, 0.03429611399769783, 0.03381867706775665, 0.03929173946380615, 0.05857003107666969, -0.019670594483613968, 0.04269004985690117, 0.026858463883399963, 0.008735708892345428, -0.018546434119343758, 0.05464327707886696, 0.009473130106925964, -0.018649768084287643, 0.013959876261651516, 0.020984673872590065, -0.05626250430941582, -0.006665866822004318, 0.015294843353331089, -0.007334054913371801, 0.0010522084776312113, 0.02005854994058609, 0.012295580469071865, 0.05785689502954483, 0.0013430865947157145, -0.028334395959973335, 0.04827449470758438, -0.019680676981806755, -0.028130032122135162, 0.06420178711414337, 0.034443292766809464, 0.049395110458135605, 0.014170868322253227, 0.010126343928277493, 0.030798589810729027, 0.006295789033174515, 0.06405109167098999, -0.013342632912099361, 0.058158859610557556, -0.0022274788934737444, 0.023428108543157578, -0.06211770325899124, -0.03242811933159828, 0.018651556223630905, -0.028673339635133743, 0.08369827270507812, 0.016627779230475426, -0.02598133124411106, -0.04504650831222534, 0.05713951587677002, 0.01163365226238966, 0.02164650708436966, 0.02072976529598236, 0.02792404219508171, 0.0015142731135711074, 0.016879497095942497, -0.018550224602222443, -0.010190312750637531, -0.04436604306101799, -0.044273488223552704, -0.00471842335537076, 0.017589649185538292, 0.013035865500569344, 0.006438242271542549, -0.03494001924991608, 0.015922894701361656, -0.0398431159555912, 0.0308059249073267, 0.03170859068632126, -0.020283333957195282, 0.0014979967381805182, 0.01750781759619713, -0.003547385800629854, -0.029968103393912315, 0.02100570686161518, 0.012810898944735527, 0.005730274599045515, 0.012063403613865376, 0.0024312189780175686, -0.02750219777226448, -0.006872217170894146, 0.009170008823275566, -0.008974522352218628, -0.05969176068902016, 0.019737141206860542, 0.0015101097524166107, 0.0516049861907959, -0.028682218864560127, -0.036984145641326904, -0.050393372774124146, -0.03335339203476906, -0.019831031560897827, 0.0479440875351429, -0.025018781423568726, -0.03226052224636078, 0.0019766148179769516, -0.050869978964328766, -0.03599364310503006, -0.014779992401599884, -0.004614583216607571, 0.04792288318276405, -0.011910161934792995, 0.017202282324433327, 0.004422869998961687, -0.047872144728899, 0.027338974177837372, -0.044259969145059586, -0.009070329368114471, 0.026955749839544296, 0.041073646396398544, -0.02195962890982628, 0.03895020857453346, -0.04528855159878731, -0.01686738058924675, 0.036241963505744934, 0.02285056747496128, -0.05808786675333977, -0.004141440149396658, 0.05404621735215187, 0.04685339704155922, 0.01654087007045746, -0.04547010734677315, -0.010320784524083138, -0.0089293597266078, 0.0020634480752050877, 0.046427275985479355, -0.0071666971780359745, -0.045862048864364624, -0.01360371895134449, -0.01688818447291851, 0.010669315233826637, -0.004310623276978731, 0.02576608397066593, -0.012467528693377972, 0.04201926290988922, -0.03262386843562126, 0.031482890248298645, 0.01047608908265829, -0.021186012774705887, -0.025240490213036537, -0.009192543104290962, -0.004779720213264227, 0.028055287897586823, -0.06250476837158203, -0.0002688653767108917, -0.07138891518115997, -0.016084693372249603, -0.042763616889715195, -0.021835464984178543, -0.038813114166259766, 0.017692796885967255, 0.04366537928581238, 0.0871066227555275, 0.04212700203061104, 0.020540591329336166, -0.05355844274163246, 0.0010214552748948336, -0.03574204444885254, 0.03283324092626572, 0.023842526599764824, -0.014321903698146343, -0.024921858683228493, -0.0195306409150362, 0.01759214885532856, 0.026809411123394966, -0.030363311991095543, -0.056125883013010025, 0.04444269463419914, 0.014842000789940357, -0.02761455439031124, -0.01674564927816391, 0.0394480861723423, 0.024542750790715218, 0.021151579916477203, 0.05556756630539894, -0.0038403712678700686, 0.009332518093287945, 0.007831256836652756, -0.05523766577243805, 0.013839375227689743, 0.009871406480669975, -0.04249457269906998, 0.03331771865487099, -0.011210561729967594, 0.023185623809695244, -0.0013780705630779266, 0.02987455017864704, -0.003536912379786372, -0.012653719633817673, -0.02391801029443741, -0.012560514733195305, 0.026890980079770088, 0.009904657490551472, 0.003583430079743266, -0.028794635087251663, 0.006401372607797384, 0.029975684359669685, -0.020212169736623764, 0.019064897671341896, 0.008546502329409122, 0.027699297294020653, 0.004117255564779043, 0.032366883009672165, -0.05332818254828453, 0.05097661539912224, 0.03421567752957344, 0.013811737298965454, -0.0048948414623737335, 0.002744021127000451 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
4. Analyzing new data with the model Now that you have trained a model for sentiment analysis, let's use it to analyze new data and get 🤖 predictions! This unlocks the power of machine learning; using a model to automatically analyze data at scale, in real-time ⚡️ First, let's upload the model to the Hub: python trainer.push_to_hub() Now that you have pushed the model to the Hub, you can use it pipeline class to analyze two new movie reviews and see how your model predicts its sentiment with just two lines of code 🤯: python from transformers import pipeline sentiment_model = pipeline(model="federicopascual/finetuning-sentiment-model-3000-samples") sentiment_model(["I love this move", "This movie sucks!"]) These are the predictions from our model: python [{'label': 'LABEL_1', 'score': 0.9558}, {'label': 'LABEL_0', 'score': 0.9413}] In the IMDB dataset, Label 1 means positive and Label 0 is negative. Quite good! 🔥
[ 0.01757519319653511, -0.05690091848373413, -0.003973318729549646, -0.021527057513594627, 0.07180024683475494, 0.07949604839086533, -0.004820988047868013, 0.06790615618228912, -0.0017191076185554266, -0.0016824410995468497, -0.037131406366825104, 0.057416729629039764, -0.015735330060124397, 0.08750156313180923, 0.06550510972738266, -0.043395522981882095, 0.05054139345884323, 0.008862687274813652, 0.038724787533283234, 0.029499761760234833, -0.002115767216309905, -0.049483321607112885, 0.043712589889764786, 0.00808511022478342, 0.018231697380542755, -0.024470165371894836, 0.08059626072645187, 0.04734862968325615, -0.09734222292900085, 0.005756597965955734, -0.11018338054418564, 0.021245285868644714, -0.04841935262084007, -0.006999331992119551, -0.04750484600663185, 0.04426734149456024, -0.09010344743728638, 0.05391303077340126, 0.0488121435046196, -0.041987448930740356, 0.004998495336622, 0.009274239651858807, -0.07107345014810562, 0.0025927452370524406, -0.025427313521504402, -0.05958913266658783, -0.1932128220796585, 0.05392729863524437, 0.007726845797151327, -0.028402404859662056, -0.044457193464040756, 0.129149928689003, -0.033780064433813095, -0.00101818039547652, -0.04096629098057747, 0.004109316039830446, -0.010704121552407742, -0.05433177947998047, 0.020703881978988647, 0.055167581886053085, 0.028328217566013336, 0.038118522614240646, 0.013243935070931911, -0.024779463186860085, 0.017526520416140556, -0.03670024871826172, 0.008492429740726948, 0.035011570900678635, -0.07259984314441681, -0.07006017118692398, 0.021096929907798767, -0.03721541911363602, -0.021386122331023216, -0.014775506220757961, -0.00670801755040884, -0.024616068229079247, 0.015904653817415237, 0.014919084496796131, 0.029354415833950043, 0.008390496484935284, -0.0075500523671507835, -0.032768674194812775, -0.031167909502983093, 0.013639724813401699, 0.06670787185430527, 0.028365403413772583, 0.08844649791717529, -0.013456547632813454, -0.06389645487070084, 0.06375229358673096, -0.0009034878457896411, -0.09013823419809341, 0.030546439811587334, 0.007059335708618164, 0.03364770486950874, -0.009933066554367542, -0.014577103778719902, 0.01635977439582348, -0.05488228052854538, -0.012788907624781132, -0.03273768723011017, -0.06447891891002655, 0.024801017716526985, -0.07139025628566742, 0.03812497854232788, 0.008182591758668423, 0.011870041489601135, -0.059562601149082184, -0.045148540288209915, 0.019990310072898865, -0.039548780769109726, 0.018310189247131348, -0.03582518920302391, 0.06134422495961189, -0.033217329531908035, 0.028878657147288322, 0.0024336883798241615, -0.043642546981573105, -0.05214632675051689, 0.056007020175457, 0.0009742750553414226, 0.058150872588157654, 0.04631951451301575, 0.04394059628248215, -0.04675153270363808, 0.050677429884672165, -0.00960575696080923, 0.026018092408776283, 0.032068122178316116, -0.004375951364636421, 0.015001568011939526, -0.03464672714471817, 0.05418359488248825, -0.012405972927808762, -0.011394062079489231, -0.04786175116896629, -0.025814173743128777, -0.07541113346815109, -0.013749328441917896, 0.007381018716841936, 0.03489546850323677, 0.07374464720487595, -0.05339445918798447, 0.015764709562063217, 0.060713931918144226, -0.016863536089658737, -0.06057917699217796, 0.04240380972623825, 0.03300180658698082, -0.00028963066870346665, -0.09603676199913025, 0.02978496439754963, -0.007365470286458731, -0.13010013103485107, 0.00569267338141799, 0.05623917654156685, -0.02564486674964428, -0.02247660420835018, -0.007215462159365416, 0.02712658978998661, 0.061377886682748795, 0.047892916947603226, -0.02028539776802063, -0.013892794027924538, 0.03580229729413986, -0.0026362594217061996, 0.028429675847291946, -0.0043007745407521725, 0.05123059079051018, 0.04904627054929733, 0.023463638499379158, -0.0199311301112175, 0.06168442219495773, -0.014586773701012135, -0.016957849264144897, 0.04910469055175781, 0.000021193583961576223, -0.0022942577488720417, -0.05493774265050888, -0.02172449231147766, -0.01233670487999916, 0.10982579737901688, -0.02199810929596424, 0.03860531374812126, 0.05818095803260803, -0.06172589957714081, 0.022696087136864662, -0.03660636767745018, -0.04468567669391632, -0.006901003420352936, -0.028634747490286827, -0.005350612569600344, 0.03751109167933464, 0.013990080915391445, 0.05203109607100487, -0.03243696689605713, 0.005500138271600008, 0.046437788754701614, 0.018831294029951096, -0.040004607290029526, 0.02594410628080368, -0.023073405027389526, 0.06863921135663986, -0.0379054881632328, 0.041357722133398056, -0.0007835297146812081, 0.005424830596894026, -0.03451620414853096, -0.003794735297560692, 0.019307607784867287, -0.05573168024420738, -0.12266388535499573, 0.0131036676466465, -0.06222756952047348, -0.0010307615157216787, -0.01603958010673523, -0.08139296621084213, 0.058153700083494186, -0.0064229159615933895, -0.01671895571053028, 0.14547625184059143, -0.04856644943356514, -0.016738342121243477, -0.03855300694704056, -0.01153014600276947, -0.008571234531700611, 0.042923953384160995, 0.03731054440140724, 0.05321153625845909, -0.004384392872452736, -0.03987451642751694, -0.0067493305541574955, -0.07535267621278763, -0.0276841651648283, -0.03629501536488533, -0.025899961590766907, 0.015004445798695087, 0.034957405179739, -0.007503080181777477, -0.0027968687936663628, -0.0073606777004897594, 0.046353425830602646, -0.034451618790626526, 0.10594639182090759, -0.04238392412662506, 0.031017089262604713, 0.1391734778881073, 0.009183133020997047, -0.05639944225549698, 0.0007074487511999905, -0.05908020958304405, 0.049679700285196304, 0.01608835533261299, -0.03553229942917824, -0.011663317680358887, -0.021470775827765465, 0.04137253016233444, 0.01083769928663969, 0.00006493875116575509, 0.055998023599386215, 0.003748613875359297, -0.033163659274578094, -0.006650111172348261, -0.03939598798751831, 0.0134937334805727, -0.019633950665593147, -0.027155859395861626, -0.012559011578559875, -0.015111749991774559, 0.0003911553940270096, 0.03353820741176605, -0.045980919152498245, 0.026578284800052643, -0.0018361031543463469, 0.012403903529047966, 0.049610551446676254, 0.03486860916018486, 0.05497724190354347, -0.0009223588276654482, -0.031227128580212593, -0.0187410656362772, -0.03003213368356228, 0.020159946754574776, 0.021592022851109505, 0.04515860974788666, -0.022918738424777985, -0.021614907309412956, -0.009768425486981869, 0.006454447750002146, 0.01547727920114994, 0.015541641041636467, 0.033412232995033264, -0.004906201269477606, -0.013055919669568539, -0.01727760024368763, 0.016504082828760147, 0.013768929988145828, 0.023844219744205475, -0.014030584134161472, 0.042173393070697784, -0.01804199069738388, -0.0005534897791221738, -0.022520696744322777, -0.010970430448651314, -0.06004025787115097, 0.026849642395973206, 0.03998677060008049, 0.006462594959884882, -0.09557785838842392, -0.006642186548560858, -0.00193855504039675, -0.054586440324783325, 0.046631697565317154, -0.0573648139834404, 0.055815327912569046, 0.025375865399837494, -0.024166280403733253, 0.027966344729065895, -0.00027520093135535717, -0.009458910673856735, -0.007775879465043545, 0.020304497331380844, -0.04052004590630531, -0.012125683017075062, -0.009320652112364769, -0.002977220341563225, 0.03710872307419777, 0.05327845737338066, -0.03871634230017662, 0.027705565094947815, -0.0019139415817335248, -0.021730298176407814, -0.05860613286495209, 0.01177813857793808, 0.04764294624328613, 0.03545879200100899, 0.010969899594783783, -0.011480090208351612, 0.0008491912158206105, -0.04598123952746391, -0.03658208250999451, 0.02382332645356655, 0.018653392791748047, 0.0010020012268796563, -0.00579397426918149, 0.01321006566286087, -0.010345438495278358, 0.0272207148373127, -0.02144363336265087, 0.02447425201535225, 0.0359099842607975, -0.008358276449143887, 0.002316215541213751, -0.002040702849626541, 0.005603878293186426, -0.037467896938323975, -0.002479466376826167, -0.02910611964762211, -0.04695196822285652, -0.004137276206165552, 0.0045309653505682945, 0.04440603032708168, -0.023119064047932625, -0.00596576277166605, 0.01126449927687645, -0.011549324728548527, 0.014204942621290684, 0.03098938800394535, -0.008989067748188972, 0.023014428094029427, -0.0023839061614125967, -0.009636303409934044, -0.02009008266031742, 0.022505715489387512, 0.020904021337628365, 0.04781334847211838, 0.016323432326316833, -0.01850927621126175, -0.00932964589446783, 0.02946378104388714, 0.004536914173513651, 0.013538647443056107, -0.020219076424837112, 0.015029438771307468, 0.013762169517576694, -0.013208716176450253, 0.04135902225971222, 0.046796783804893494, 0.0042850482277572155, -0.0819820910692215, -0.04871959984302521, -0.01688741147518158, 0.040059998631477356, 0.015411654487252235, 0.03786211833357811, -0.07135124504566193, -0.02488941140472889, 0.010060605593025684, 0.04887596517801285, -0.015565427951514721, -0.009737287648022175, 0.008927608840167522, -0.025450080633163452, 0.002845142502337694, 0.010562044568359852, -0.012472551316022873, 0.016422521322965622, -0.027406254783272743, 0.03641239553689957, -0.029331909492611885, -0.024327289313077927, -0.013660240918397903, 0.031166454777121544, 0.03217756748199463, -0.03880872204899788, 0.01551757100969553, 0.01795250177383423, -0.05707833170890808, -0.0025793525855988264, 0.024724867194890976, 0.012416073121130466, -0.02813141420483589, 0.03692423552274704, 0.0386795736849308, -0.046929728239774704, -0.005728716962039471, 0.012496069073677063, 0.040564507246017456, -0.01704813539981842, 0.0003690265293698758, -0.02860727533698082, -0.03793901205062866, 0.015005869790911674, 0.024306273087859154, 0.055780548602342606, 0.019364334642887115, -0.05289779230952263, -0.015155568718910217, 0.01996416598558426, 0.013036204501986504, -0.017479179427027702, -0.0005607064231298864, 0.01294918917119503, -0.0008119359845295548, 0.010612978599965572, -0.010120490565896034, -0.004873695783317089, -0.017490217462182045, -0.012433336116373539, -0.030116839334368706, 0.02054581232368946, -0.008706104010343552, 0.013593838550150394, -0.04145307093858719, -0.02807658538222313, -0.006292226258665323, -0.005140076391398907, 0.00355885224416852, 0.03265557065606117, 0.02870582602918148, -0.03989603742957115, -0.020801302045583725, 0.04158249497413635, -0.027214011177420616, -0.04686346650123596, -0.023153582587838173, -0.018640385940670967, 0.045104555785655975, 0.01284179650247097, -0.001764765358529985, -0.013247312046587467, -0.015181338414549828, -0.015952961519360542, 0.003526511834934354, -0.03138961270451546, -0.09829715639352798, 0.0164717398583889, 0.031123004853725433, -0.012409243732690811, 0.026984941214323044, 0.010584243573248386, -0.03213045373558998, -0.024842023849487305, 0.03795260563492775, 0.03377341106534004, -0.004003338515758514, -0.01965012587606907, 0.02084512636065483, -0.027985360473394394, -0.05388297885656357, 0.007811416871845722, 0.031464532017707825, 0.013575848191976547, 0.07191360741853714, 0.00939967855811119, 0.03402934968471527, 0.007232540752738714, 0.004139674827456474, -0.01469238381832838, -0.015584016218781471, -0.01792784407734871, -0.03117990307509899, -0.017274001613259315, -0.022128436714410782, 0.033300790935754776, -0.0023886177223175764, -0.036394134163856506, 0.0012812656350433826, 0.006210348103195429, 0.03812633082270622, -0.00958452932536602, -0.026854904368519783, 0.03804789111018181, 0.023310214281082153, -0.016951994970440865, -0.010740000754594803, 0.010735229589045048, -0.03862084820866585, 0.023933159187436104, -0.01595066674053669, -0.0027817352674901485, 0.013773975893855095, 0.009420917369425297, -0.00422010850161314, -0.015999916940927505, 0.007593107875436544, 0.027473650872707367, 0.02321087196469307, -0.006712416652590036, 0.002726161852478981, -0.050597961992025375, 0.013006683439016342, -0.001924706157296896, -0.06372688710689545, 0.03362128138542175, -0.0019882963970303535, -0.00874285027384758, 0.033424414694309235, 0.045370832085609436, 0.0006704236730001867, -0.014593102969229221, 0.03844105079770088, 0.01665383204817772, -0.02828393504023552, -0.031069336459040642, 0.023568185046315193, 0.041991543024778366, -0.03640532121062279, -0.009429341182112694, -0.02261362597346306, -0.023019365966320038, 0.006389358546584845, -0.05747934430837631, 0.051186297088861465, 0.03209339454770088, -0.0024826317094266415, 0.003897018264979124, -0.02198418229818344, -0.01381098385900259, 0.05557018890976906, -0.023224372416734695, 0.038635239005088806, 0.01591298170387745, 0.02005220390856266, 0.06070505082607269, 0.006825013551861048, 0.018203336745500565, 0.020776566118001938, 0.008112999610602856, -0.06870951503515244, -0.004665759392082691, 0.01709768734872341, 0.014220400713384151, 0.040050629526376724, 0.05198483169078827, -0.045876406133174896, 0.016395678743720055, 0.015484652481973171, 0.035801347345113754, 0.055459342896938324, 0.014603360556066036, 0.016394522041082382, -0.003289406420662999, 0.0005376937915571034, -0.01992478407919407, 0.07166913151741028, -0.04948839545249939, 0.024568496271967888, 0.056084249168634415, 0.01760716922581196, 0.02795221470296383, 0.008474620059132576, 0.03649095818400383, 0.01825820840895176, 0.045374609529972076, 0.06672673672437668, -0.003125789575278759, 0.04849964752793312, 0.010010609403252602, 0.043468594551086426, -0.028464991599321365, -0.006410111207515001, -0.00473613478243351, 0.01525483001023531, 0.04446021839976311, -0.03773098438978195, 0.010161529295146465, -0.030426885932683945, 0.041332803666591644, 0.011836906895041466, 0.02015279419720173, 0.006709419656544924, 0.024173982441425323, 0.07370493561029434, 0.03292923420667648, -0.007905877195298672, 0.018858307972550392, -0.029803991317749023, -0.011896937154233456, 0.007451030891388655, -0.005455534905195236, 0.01900024525821209, -0.011164195835590363, 0.0034804921597242355, 0.020301057025790215, -0.020256932824850082, 0.010213288478553295, 0.010785574093461037, -0.02065582573413849, -0.028473086655139923, -0.012563446536660194, 0.014645895920693874, -0.025167075917124748, 0.00518476776778698, 0.02339286357164383, 0.003654696512967348, -0.029568856582045555, -0.007663804106414318, -0.03193681314587593, 0.06060109660029411, -0.009634234942495823, -0.0002504615404177457, -0.03122454322874546, -0.0033517898991703987, 0.02887490577995777, 0.041507549583911896, 0.0031411221716552973, -0.02539241872727871, -0.04975152015686035, -0.02791655622422695, -0.029486890882253647, 0.018552402034401894, -0.031571149826049805, -0.03988736495375633, 0.004319240339100361, -0.033502764999866486, -0.021753527224063873, 0.04461561143398285, 0.011829466558992863, 0.028845714405179024, -0.010681900195777416, -0.007266728673130274, -0.016548193991184235, -0.06500644981861115, 0.04108358919620514, -0.03308643773198128, -0.02404319867491722, -0.009519186802208424, -0.006925251800566912, -0.002402323530986905, 0.04507125914096832, -0.005206721369177103, -0.016668429598212242, 0.04247448965907097, 0.01942393183708191, -0.014391721226274967, 0.008673630654811859, 0.003925164695829153, 0.0005268426612019539, 0.048617858439683914, -0.014129266142845154, -0.011985464952886105, -0.001622235868126154, 0.04572737216949463, 0.05402284115552902, -0.008637366816401482, -0.0013104110257700086, 0.004766941070556641, 0.029863663017749786, 0.035370275378227234, 0.01647317223250866, 0.013182134367525578, -0.03070068545639515, 0.021137872710824013, -0.023320956155657768, 0.04155510291457176, -0.0022000696044415236, -0.016470689326524734, -0.03477514162659645, -0.034752894192934036, 0.009821191430091858, 0.05125156417489052, -0.08429385721683502, 0.03412836045026779, -0.061301909387111664, -0.043126728385686874, -0.030659908428788185, -0.0016734421951696277, -0.0003485408378764987, 0.0432465635240078, 0.060551565140485764, 0.04644440859556198, 0.011463827453553677, 0.01998070254921913, -0.05920953303575516, -0.024749096482992172, -0.04705601558089256, 0.054301150143146515, 0.005271655507385731, -0.004484238103032112, -0.025300918146967888, 0.017432212829589844, 0.02724584750831127, 0.004609663970768452, -0.04256303608417511, -0.010233939625322819, 0.05026206374168396, -0.022606685757637024, -0.08163275569677353, -0.02590089477598667, 0.023893656209111214, -0.004430779255926609, 0.04907872527837753, -0.016599470749497414, -0.017575565725564957, 0.026283850893378258, -0.0034230027813464403, -0.0640874058008194, -0.021470380946993828, 0.0029856543987989426, 0.016400635242462158, 0.006209755782037973, 0.03715602681040764, 0.032655879855155945, -0.0014605562901124358, 0.011315526440739632, 0.023614484816789627, 0.009310993365943432, -0.01830344647169113, -0.04614729806780815, 0.00180268834810704, 0.04728948697447777, -0.0000884373439475894, -0.04307068884372711, 0.020104501396417618, -0.005918541923165321, -0.032244544476270676, -0.010008342564105988, 0.02551676519215107, 0.053868670016527176, 0.00851973332464695, 0.009395821020007133, -0.031357765197753906, 0.04608692601323128, 0.01839381456375122, -0.039098773151636124, -0.013123397715389729, -0.029974106699228287 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
1. What is Sentiment Analysis? Sentiment analysis is a natural language processing technique that identifies the polarity of a given text. There are different flavors of sentiment analysis, but one of the most widely used techniques labels data into positive, negative and neutral. For example, let's take a look at these tweets mentioning @VerizonSupport: - "dear @verizonsupport your service is straight 💩 in dallas.. been with y’all over a decade and this is all time low for y’all. i’m talking no internet at all." → Would be tagged as "Negative". - "@verizonsupport ive sent you a dm" → would be tagged as "Neutral". - "thanks to michelle et al at @verizonsupport who helped push my no-show-phone problem along. order canceled successfully and ordered this for pickup today at the apple store in the mall." → would be tagged as "Positive". Sentiment analysis allows processing data at scale and in real-time. For example, do you want to analyze thousands of tweets, product reviews or support tickets? Instead of sorting through this data manually, you can use sentiment analysis to automatically understand how people are talking about a specific topic, get insights for data-driven decisions and automate business processes. Sentiment analysis is used in a wide variety of applications, for example: - Analyze social media mentions to understand how people are talking about your brand vs your competitors. - Analyze feedback from surveys and product reviews to quickly get insights into what your customers like and dislike about your product. - Analyze incoming support tickets in real-time to detect angry customers and act accordingly to prevent churn.
[ 0.010019424371421337, -0.03040345013141632, 0.061201728880405426, -0.004751700442284346, 0.11511703580617905, 0.0991932675242424, -0.0055383071303367615, 0.11779551953077316, 0.014112129807472229, -0.02306024543941021, -0.08574990928173065, 0.09211300313472748, -0.0014936666702851653, 0.04587160050868988, -0.010805826634168625, -0.005013360641896725, 0.07734329998493195, 0.02705923281610012, 0.050563160330057144, -0.016178937628865242, -0.03965899348258972, -0.009480924345552921, 0.01831238530576229, -0.016480114310979843, 0.04972082003951073, -0.023248285055160522, 0.05728556215763092, 0.011505862697958946, -0.09848403930664062, -0.03227600082755089, -0.08242220431566238, 0.04762047901749611, -0.05424303561449051, -0.014404629357159138, -0.013046568259596825, 0.012007865123450756, -0.10044784843921661, 0.07859142124652863, 0.025436706840991974, -0.02969171293079853, -0.0612892284989357, -0.08528902381658554, -0.06326981633901596, 0.011225239373743534, -0.060340795665979385, -0.04485475271940231, -0.2109796404838562, 0.12306391447782516, -0.02159607782959938, -0.019676370546221733, -0.05110448971390724, 0.10257190465927124, -0.04195298254489899, 0.030121615156531334, -0.06934378296136856, 0.029497064650058746, -0.011841551400721073, -0.027048170566558838, 0.030988536775112152, 0.0021619622129946947, 0.043382544070482254, -0.010458439588546753, -0.009182794019579887, 0.012103675864636898, 0.04471345245838165, -0.003425518749281764, -0.018317416310310364, 0.045445092022418976, -0.09065601974725723, -0.0391983762383461, -0.013136038556694984, -0.015969950705766678, -0.051917437463998795, 0.01687823049724102, 0.016396738588809967, 0.01010572537779808, 0.021613456308841705, 0.03807118535041809, -0.016079556196928024, -0.0035164777655154467, 0.0009468296193517745, 0.020415769889950752, 0.04244837537407875, 0.06776659935712814, 0.0997653380036354, -0.015169331803917885, 0.092714324593544, 0.04433459788560867, 0.0004760070296470076, 0.06487275660037994, 0.031340133398771286, -0.09707734733819962, 0.07093523442745209, -0.0056120529770851135, -0.011029619723558426, -0.06363540142774582, 0.038314338773489, 0.011900385841727257, -0.01933448016643524, 0.0077948421239852905, -0.032519564032554626, -0.005512462928891182, 0.05772655829787254, -0.019885249435901642, 0.013284599408507347, 0.03903915733098984, 0.0484151616692543, -0.03797329217195511, -0.029986949637532234, 0.025576818734407425, -0.040807273238897324, 0.02304200455546379, 0.03427332267165184, 0.04887814447283745, -0.06142086535692215, 0.08274117112159729, 0.05147979408502579, 0.011620898731052876, -0.011916947551071644, 0.02915377914905548, 0.016154248267412186, 0.08207499235868454, 0.01966019533574581, 0.009382200427353382, -0.04467897489666939, 0.025464363396167755, 0.03371288254857063, 0.013094338588416576, -0.022907279431819916, -0.020477037876844406, -0.0033086154144257307, 0.01013907603919506, -0.008924392983317375, 0.02066746912896633, -0.06936652958393097, -0.043040890246629715, -0.027549324557185173, -0.05539897456765175, 0.06079701706767082, -0.016549816355109215, 0.025774113833904266, 0.058990661054849625, -0.06023630499839783, 0.04199233278632164, 0.04622288793325424, -0.04724220559000969, -0.06287789344787598, 0.01240659411996603, -0.013681028038263321, -0.005201568827033043, -0.06978797167539597, 0.01825280487537384, -0.009533998556435108, -0.0830458253622055, 0.014309270307421684, 0.05443619191646576, 0.019616637378931046, -0.05983969569206238, -0.04548601433634758, 0.006761550437659025, 0.0005388280260376632, 0.010486253537237644, -0.011701256968080997, 0.013043875806033611, 0.054049208760261536, 0.01051588635891676, -0.0009398119291290641, 0.04656580090522766, -0.031156063079833984, -0.005072050262242556, 0.0355391800403595, -0.047272998839616776, 0.07540580630302429, -0.05440617352724075, 0.005861655808985233, 0.04142400249838829, 0.016858607530593872, -0.015730099752545357, -0.032380785793066025, 0.011921992525458336, -0.014333309605717659, 0.06918223202228546, 0.01803532987833023, 0.023694217205047607, 0.02536701038479805, -0.05251447856426239, 0.03860604763031006, -0.053341932594776154, -0.00829729437828064, 0.009940522722899914, -0.07593908160924911, -0.03927793353796005, 0.03803011402487755, 0.01362166553735733, 0.035901062190532684, -0.10153917223215103, 0.011548972688615322, 0.13985100388526917, 0.008877594955265522, 0.0012427495094016194, 0.046125128865242004, -0.052052516490221024, 0.0722179114818573, -0.06521652638912201, -0.03470460698008537, 0.009577752090990543, 0.053650643676519394, 0.030518289655447006, -0.006214743014425039, 0.008068484254181385, -0.04606210067868233, -0.13015922904014587, 0.010945048183202744, -0.036029037088155746, 0.01005086861550808, -0.004728496074676514, -0.015882128849625587, 0.06567095965147018, 0.05935598909854889, -0.03247234597802162, 0.14678075909614563, -0.06889086216688156, -0.0016073568258434534, 0.01835872232913971, -0.014064229093492031, -0.0008676508441567421, 0.07572448998689651, 0.04197688028216362, 0.05453857034444809, 0.006035815924406052, -0.011934205889701843, 0.027436217293143272, -0.030240381136536598, -0.0519295334815979, -0.03401249274611473, 0.02335779182612896, 0.037990979850292206, 0.024729128926992416, 0.033345744013786316, 0.005893528927117586, -0.04448844864964485, -0.0018321617972105742, 0.002930884948000312, 0.09392166882753372, -0.023193418979644775, -0.02632918395102024, 0.05756250396370888, -0.047214653342962265, -0.038562387228012085, 0.017013097181916237, -0.022446807473897934, 0.055678751319646835, 0.012774800881743431, 0.013820174150168896, 0.012236077338457108, -0.029607268050312996, 0.0574059821665287, 0.008049137890338898, 0.011180348694324493, 0.02450227178633213, -0.016279004514217377, -0.04089755192399025, 0.035846877843141556, -0.05110148712992668, 0.014256350696086884, 0.0013584971893578768, 0.0014274357818067074, 0.009403795003890991, -0.0019760839641094208, 0.0648902952671051, 0.04179847612977028, -0.0036118526477366686, 0.04222886264324188, 0.029672883450984955, -0.023567209020256996, 0.015547393821179867, 0.012540444731712341, 0.008704136125743389, -0.018178356811404228, -0.024163322523236275, -0.02697322517633438, -0.042477693408727646, 0.028263358399271965, 0.02609744295477867, 0.0452670119702816, -0.036291662603616714, -0.012891671620309353, -0.009778272360563278, -0.01092368084937334, 0.033361125737428665, 0.013354037888348103, -0.017466681078076363, -0.022376833483576775, -0.0006336348014883697, 0.038096021860837936, -0.00913457851856947, -0.029021665453910828, 0.05905156210064888, -0.047428399324417114, 0.035651855170726776, 0.014657470397651196, -0.00009983828203985468, -0.029024748131632805, -0.044705748558044434, -0.05950000137090683, 0.03548154607415199, 0.026103166863322258, 0.010538403876125813, -0.12539413571357727, -0.014747011475265026, 0.020611265674233437, -0.013045240193605423, 0.016667069867253304, -0.04011019691824913, 0.08561720699071884, 0.0011093366192653775, 0.0047716000117361546, 0.024403471499681473, -0.005094660446047783, 0.01367171574383974, 0.018556127324700356, -0.006156182382255793, -0.01268076803535223, -0.014705904759466648, 0.014562945812940598, 0.0010994136100634933, 0.016984404996037483, 0.04184771329164505, -0.030122533440589905, 0.05993309244513512, 0.010424548760056496, -0.0022502734791487455, -0.06319984793663025, 0.010430720634758472, 0.03286687657237053, 0.027562987059354782, 0.004827785771340132, -0.021006472408771515, 0.02558094635605812, 0.0008526305900886655, -0.05744399130344391, 0.042668260633945465, 0.002627893816679716, -0.018740717321634293, 0.002720097778365016, 0.009058447554707527, -0.00978237483650446, 0.04896777495741844, -0.007347107864916325, 0.03662233427166939, 0.026866890490055084, 0.012496920302510262, -0.02246270515024662, -0.012572009116411209, -0.019715234637260437, -0.028105517849326134, -0.03030632995069027, -0.004208005499094725, -0.029066720977425575, -0.03571877256035805, -0.01944625750184059, 0.040049389004707336, -0.02659616991877556, -0.012042684480547905, -0.008966799825429916, -0.03697933629155159, 0.003959137946367264, 0.009485822170972824, -0.0353422611951828, 0.027128027752041817, 0.011945596896111965, -0.03778045251965523, -0.06002894043922424, 0.011212479323148727, 0.003658692119643092, 0.02297050878405571, 0.00048679416067898273, 0.03507993742823601, 0.02507943846285343, 0.03393114358186722, 0.011835388839244843, 0.008830243721604347, -0.013161400333046913, 0.0032764794304966927, -0.04408697038888931, -0.009770535863935947, 0.06659109890460968, 0.031050022691488266, -0.013096912764012814, -0.047400034964084625, -0.03377131000161171, -0.06640395522117615, 0.008525327779352665, 0.0009024566970765591, 0.017326125875115395, -0.008160710334777832, -0.015545137226581573, 0.062334831804037094, 0.04688354209065437, 0.002657943172380328, -0.003098758403211832, 0.005134885665029287, -0.01201687753200531, 0.007351489271968603, 0.03402964025735855, -0.050801970064640045, 0.01295694150030613, -0.007182590197771788, 0.03668731078505516, -0.013001840561628342, -0.03473565727472305, -0.01594744436442852, 0.036538273096084595, 0.033915042877197266, -0.056472744792699814, -0.010683376342058182, 0.02236061356961727, -0.024487195536494255, -0.0073196496814489365, 0.021066276356577873, 0.003253125585615635, -0.017326856032013893, 0.05095081776380539, 0.016883397474884987, -0.04383908957242966, -0.014404813759028912, -0.019007131457328796, 0.03480736166238785, -0.008701053448021412, 0.009938876144587994, -0.04919455572962761, -0.013374032452702522, 0.0020599544513970613, -0.006399191915988922, 0.04509567841887474, 0.0025302371941506863, -0.034798674285411835, -0.025205133482813835, 0.018690474331378937, -0.017872557044029236, 0.011622064746916294, 0.017802635207772255, 0.013882902450859547, -0.022430073469877243, 0.005074788816273212, 0.01788482628762722, -0.0006575895240530372, -0.047769397497177124, 0.0069578224793076515, -0.029283832758665085, 0.004915331490337849, -0.01319669745862484, 0.01757510006427765, -0.002136440947651863, -0.05798529461026192, -0.008189646527171135, 0.0117759108543396, -0.0023030524607747793, -0.008196628652513027, 0.005701974965631962, -0.05865566432476044, -0.008946545422077179, -0.001880065887235105, -0.056154944002628326, 0.0058630057610571384, 0.0013870486291125417, -0.03246702626347542, 0.04381512477993965, -0.003818230703473091, -0.025738531723618507, -0.028822625055909157, -0.013326670974493027, -0.01378980278968811, -0.025484446436166763, -0.015796536579728127, -0.01465929951518774, -0.03129830211400986, 0.02030252479016781, -0.00957074761390686, 0.01643245667219162, 0.012239768169820309, -0.029734663665294647, 0.002836451167240739, 0.02729939855635166, 0.008144107647240162, 0.010739301331341267, -0.011964933946728706, 0.01895996555685997, -0.04322149604558945, -0.009082111530005932, -0.03875844180583954, 0.045269403606653214, -0.011540587060153484, 0.03474992513656616, 0.05272778496146202, 0.023854808881878853, 0.002813503844663501, 0.0501561164855957, -0.0463402234017849, -0.008997379802167416, 0.00886061042547226, -0.039340827614068985, -0.014761878177523613, 0.0017962971469387412, 0.021519595757126808, 0.02781614661216736, -0.010813348926603794, 0.0011624910403043032, -0.01593935862183571, 0.054317768663167953, 0.0052161007188260555, -0.008118231780827045, 0.004813766106963158, 0.01304693054407835, -0.016876401379704475, -0.05851622298359871, -0.029070014134049416, -0.02779236063361168, -0.026442846283316612, -0.007892865687608719, -0.010779016651213169, -0.001699303393252194, -0.027652259916067123, -0.015201705507934093, -0.02799043245613575, -0.014405232854187489, 0.011390910483896732, 0.010013377293944359, 0.004575403872877359, 0.0027741584926843643, -0.07177242636680603, 0.03230792284011841, 0.026829609647393227, -0.04806317389011383, 0.025670424103736877, -0.03438739851117134, 0.003076807362958789, 0.013175668194890022, 0.02217091992497444, 0.01007721945643425, 0.006092009134590626, 0.030854331329464912, -0.002757139503955841, 0.004580584354698658, -0.03719644993543625, 0.018554044887423515, 0.004609846044331789, -0.017491156235337257, -0.030764034017920494, -0.019731447100639343, -0.013285857625305653, -0.005659070331603289, -0.03560955077409744, 0.014953899197280407, 0.03621358796954155, -0.016901008784770966, -0.002640374004840851, 0.008427477441728115, -0.003455169266089797, 0.029530275613069534, 0.01617332547903061, -0.007308586034923792, 0.038379475474357605, 0.0410253144800663, 0.03286726400256157, -0.014407990500330925, 0.011658930219709873, -0.015904398635029793, -0.015152069739997387, -0.06403426826000214, 0.02200014889240265, 0.01829211600124836, -0.043639980256557465, 0.000979946693405509, 0.037344563752412796, -0.014464037492871284, 0.007424389477819204, 0.04400508105754852, 0.030116286128759384, 0.02469407021999359, 0.03912932798266411, 0.030754635110497475, -0.011207629926502705, -0.011810634285211563, -0.0105687091127038, 0.06978310644626617, -0.07009938359260559, 0.05412864685058594, 0.029241079464554787, 0.021441396325826645, 0.03298167511820793, -0.003698491957038641, 0.017459949478507042, -0.003161459229886532, 0.06324411928653717, 0.032198525965213776, 0.022342603653669357, -0.027996661141514778, -0.028810225427150726, -0.01871240884065628, -0.027837608009576797, -0.007157893851399422, -0.04953193664550781, -0.0020698655862361193, 0.04623556509613991, 0.004211580380797386, 0.010592843405902386, -0.018398933112621307, 0.005779467057436705, -0.01659233868122101, 0.03995818644762039, -0.004431401379406452, 0.01653960533440113, 0.05345042422413826, 0.019655440002679825, 0.018054082989692688, 0.03039523959159851, -0.021015146747231483, 0.00015020057617221028, 0.022478360682725906, 0.007730997633188963, 0.04043310508131981, -0.0043383315205574036, -0.029926791787147522, 0.04202417656779289, -0.012222180142998695, 0.02936866693198681, -0.010369298979640007, -0.017636504024267197, 0.009464887902140617, -0.007793452590703964, 0.002828500932082534, 0.025143323466181755, -0.01484240498393774, 0.026944663375616074, 0.03313994035124779, 0.03932928666472435, 0.01206241361796856, -0.017125017940998077, 0.04589305818080902, 0.004642881918698549, -0.021083824336528778, -0.019873803481459618, -0.01503698155283928, -0.0015483214519917965, 0.011516226455569267, -0.03604902699589729, -0.043652527034282684, -0.022412706166505814, -0.015057912096381187, -0.008795664645731449, -0.004044613800942898, -0.013263557106256485, -0.002579690655693412, -0.0016849621897563338, -0.01657603122293949, -0.045138612389564514, 0.02167518436908722, 0.019074497744441032, 0.003364604664966464, -0.03341364115476608, 0.006314725149422884, -0.02944003976881504, -0.009920296259224415, -0.036195844411849976, -0.01135269831866026, 0.006281575653702021, -0.0514434278011322, -0.007544281892478466, -0.011177998967468739, 0.021269528195261955, -0.01643252559006214, 0.023210229352116585, 0.019641388207674026, 0.0012455396354198456, 0.019923025742173195, -0.029188573360443115, 0.017720168456435204, -0.02358297072350979, 0.03438890725374222, -0.040580976754426956, -0.02230135351419449, 0.007516948506236076, 0.05619741603732109, 0.032548584043979645, -0.006396005861461163, 0.00025393240503035486, -0.0290256068110466, 0.026551933959126472, 0.02786014974117279, 0.004303355235606432, 0.0313880629837513, 0.023812832310795784, 0.012188481166958809, -0.061117298901081085, 0.02925846353173256, -0.02377507835626602, 0.008127782493829727, -0.007973600178956985, -0.02347966656088829, -0.03898758441209793, 0.030617693439126015, -0.017329631373286247, -0.009667880833148956, -0.057889167219400406, -0.0007497176411561668, -0.01890462264418602, 0.009346074424684048, -0.005457740742713213, 0.007031853776425123, 0.03569581359624863, 0.008055479265749454, 0.008889696560800076, 0.0008386835688725114, -0.002691285451874137, -0.0204815361648798, -0.050946615636348724, 0.028669338673353195, 0.03270173817873001, 0.01711106114089489, -0.011367086321115494, -0.015062373131513596, 0.04328261688351631, -0.02669910341501236, -0.009221109561622143, 0.000628212932497263, 0.07081179320812225, -0.013971013948321342, 0.0001549808803247288, 0.01210575457662344, -0.0037950538098812103, 0.0012808223254978657, 0.03048679046332836, -0.01252716314047575, 0.003694897750392556, 0.02424376644194126, 0.001711880206130445, -0.07419842481613159, 0.01190932933241129, 0.02505844086408615, 0.027554208412766457, 0.049480337649583817, 0.04734279215335846, 0.031272053718566895, -0.013373606838285923, -0.0036302125081419945, -0.008884661830961704, 0.01467428170144558, -0.016560880467295647, -0.042257409542798996, -0.0047857197932899, 0.00983950961381197, -0.027782566845417023, -0.04769397899508476, 0.02111305110156536, -0.024182241410017014, -0.02485354244709015, -0.010504175908863544, 0.016340967267751694, -0.006884606555104256, 0.013928801752626896, 0.03690139949321747, -0.014496780931949615, 0.04847414419054985, 0.032648537307977676, 0.02395770326256752, 0.013159573078155518, 0.010733451694250107 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
2. Preprocess data You need data to fine-tune DistilBERT for sentiment analysis. So, let's use 🤗Datasets library to download and preprocess the IMDB dataset so you can then use this data for training your model: python from datasets import load_dataset imdb = load_dataset("imdb") IMDB is a huge dataset, so let's create smaller datasets to enable faster training and testing: python small_train_dataset = imdb["train"].shuffle(seed=42).select([i for i in list(range(3000))]) small_test_dataset = imdb["test"].shuffle(seed=42).select([i for i in list(range(300))]) To preprocess our data, you will use DistilBERT tokenizer: python from transformers import AutoTokenizer tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased") Next, you will prepare the text inputs for the model for both splits of our dataset (training and test) by using the map method: python def preprocess_function(examples): return tokenizer(examples["text"], truncation=True) tokenized_train = small_train_dataset.map(preprocess_function, batched=True) tokenized_test = small_test_dataset.map(preprocess_function, batched=True) To speed up training, let's use a data_collator to convert your training samples to PyTorch tensors and concatenate them with the correct amount of padding: python from transformers import DataCollatorWithPadding data_collator = DataCollatorWithPadding(tokenizer=tokenizer)
[ 0.019358763471245766, 0.029071321710944176, -0.017878465354442596, 0.06999994814395905, 0.049827657639980316, 0.08678384870290756, 0.059311140328645706, 0.030959032475948334, -0.0034514216240495443, -0.006329489406198263, -0.1097169890999794, 0.04307468608021736, 0.024632729589939117, -0.0074909888207912445, 0.04053139314055443, -0.033734481781721115, 0.0966654047369957, -0.0010016716551035643, 0.03868429362773895, 0.03692762181162834, 0.003068956546485424, -0.05241714417934418, 0.04647565633058548, 0.06227762624621391, 0.020135141909122467, -0.041266150772571564, 0.05169133469462395, 0.04948965832591057, -0.083126500248909, 0.03385544195771217, -0.11679289489984512, -0.005595299415290356, -0.031017018482089043, 0.0008746811072342098, -0.030837826430797577, 0.024543868377804756, -0.052997421473264694, 0.08349086344242096, 0.05987315624952316, -0.002829264383763075, -0.011360235512256622, -0.03512100502848625, -0.04906703531742096, 0.0194686409085989, -0.04527486488223076, -0.054473213851451874, -0.15581266582012177, 0.07266146689653397, -0.008315409533679485, -0.05826926231384277, -0.047721002250909805, 0.07120060920715332, -0.02054782025516033, 0.0147245479747653, 0.012864498421549797, 0.018719058483839035, 0.014486388303339481, -0.06358161568641663, 0.03705266863107681, 0.03551564738154411, 0.01937313936650753, 0.015187459997832775, -0.021044403314590454, 0.009474510326981544, 0.043308500200510025, 0.04825320839881897, -0.04107941314578056, 0.04999951645731926, -0.05630134046077728, -0.0920247882604599, 0.07148011773824692, -0.007800508290529251, -0.07141994684934616, -0.03584930673241615, 0.03428005054593086, 0.0002571275399532169, 0.0026897185016423464, 0.023359155282378197, -0.013607500120997429, 0.030600830912590027, -0.030058100819587708, -0.018794214352965355, 0.02847808040678501, 0.0330086387693882, 0.07328667491674423, 0.048375703394412994, 0.05303632840514183, -0.016613559797406197, -0.07006058096885681, 0.027700792998075485, -0.04212865233421326, -0.08530473709106445, 0.0038994268979877234, -0.006516310852020979, 0.034914515912532806, -0.03170427307486534, -0.044540081173181534, -0.00015865960449445993, -0.049595147371292114, 0.022363943979144096, 0.036457885056734085, -0.06252720206975937, 0.04274594038724899, -0.05451783537864685, -0.029867136850953102, 0.051256291568279266, -0.024305520579218864, -0.0437597818672657, -0.007182043045759201, 0.016480963677167892, -0.00228021084330976, 0.015586480498313904, 0.00689692422747612, 0.060892485082149506, -0.05383637547492981, -0.03370950371026993, -0.0005615690024569631, 0.022723227739334106, -0.03888396546244621, 0.035117994993925095, 0.030905768275260925, 0.05473151430487633, 0.028444675728678703, -0.012769592925906181, -0.07157441228628159, 0.04610677808523178, 0.014995818957686424, 0.00966536533087492, 0.04389313980937004, 0.04263666644692421, -0.023890232667326927, -0.010834255255758762, 0.02977965958416462, -0.01695850118994713, -0.06060017645359039, -0.10345972329378128, -0.03294266387820244, -0.04368498921394348, 0.05261247232556343, -0.004178857896476984, 0.035730257630348206, 0.09298820048570633, -0.10024258494377136, -0.020892877131700516, -0.0007391596445813775, -0.014599762856960297, -0.0491507425904274, 0.06138728931546211, 0.02465909533202648, 0.005621323827654123, -0.06928449124097824, 0.051807161420583725, -0.026580816134810448, -0.06687940657138824, 0.038945652544498444, 0.08487256616353989, -0.08196194469928741, -0.04473448544740677, -0.07004640251398087, 0.019155921414494514, 0.016253594309091568, 0.02461905963718891, -0.03524834290146828, -0.03376829996705055, 0.010127386078238487, -0.06544183939695358, 0.032304681837558746, 0.018396276980638504, -0.004889180883765221, -0.0014996936079114676, -0.009591970592737198, -0.024756241589784622, 0.04110829159617424, -0.037417709827423096, 0.016958782449364662, 0.08698931336402893, -0.015141939744353294, 0.02051777020096779, -0.038623493164777756, -0.00013156367640476674, -0.012381385080516338, 0.054999493062496185, -0.02292005531489849, 0.05496400222182274, 0.07867182791233063, -0.06305553764104843, 0.06132577359676361, -0.052687741816043854, -0.05563637614250183, 0.06301791965961456, -0.041684072464704514, -0.028804484754800797, 0.04827861115336418, 0.002579932566732168, 0.07240524888038635, -0.03941848501563072, -0.013804598711431026, 0.032031212002038956, -0.005615617148578167, 0.01992928981781006, -0.01535915955901146, -0.030200783163309097, -0.007057861890643835, -0.04043450579047203, 0.018506713211536407, -0.030838893726468086, -0.022959966212511063, -0.053596802055835724, 0.022349901497364044, -0.01361624151468277, -0.006727524567395449, -0.12052271515130997, 0.039210088551044464, -0.09672344475984573, -0.03796188160777092, -0.03250895440578461, -0.05121435597538948, -0.015057086944580078, 0.02675471641123295, 0.01956329494714737, 0.16467708349227905, -0.06508491188287735, 0.04679717496037483, 0.010858999565243721, -0.026785533875226974, 0.036226965487003326, 0.08554133772850037, 0.03075418807566166, 0.09092196822166443, -0.029727904126048088, -0.029814083129167557, -0.03539794683456421, -0.0017075891373679042, 0.04337264224886894, -0.05391787737607956, -0.0716639906167984, 0.0035814926959574223, 0.033976007252931595, -0.008460907265543938, -0.013388842344284058, 0.011355404742062092, -0.00926227867603302, -0.06200793758034706, 0.05008718743920326, -0.01438953448086977, 0.03197252377867699, 0.050545115023851395, -0.04510543867945671, -0.028921475633978844, -0.06087648868560791, -0.026919042691588402, 0.07023721188306808, -0.0005110975471325219, -0.031359486281871796, 0.024150047451257706, 0.02169150300323963, 0.03931400179862976, 0.058559488505125046, -0.011555274948477745, 0.054948851466178894, -0.00008600283763371408, -0.03573461249470711, -0.015060191974043846, -0.05251435190439224, 0.009408718906342983, -0.017826370894908905, 0.00565761374309659, 0.01419039722532034, 0.0032693338580429554, -0.011622890830039978, -0.01692240871489048, -0.017152458429336548, 0.028617214411497116, 0.04851984605193138, -0.0003467031929176301, 0.050881341099739075, -0.0035256617702543736, 0.01584061048924923, -0.021765628829598427, -0.0008583398885093629, -0.010809044353663921, -0.03718295320868492, 0.015389187261462212, 0.026211857795715332, -0.009948056191205978, 0.004555573686957359, -0.0262006726115942, -0.016754910349845886, -0.01261017844080925, 0.02534618228673935, 0.01998882181942463, 0.027571549639105797, 0.027865229174494743, -0.04185735061764717, 0.015242844820022583, 0.011084550991654396, -0.0038088266737759113, 0.01363972295075655, -0.000517524778842926, 0.025028951466083527, -0.02827528677880764, 0.007003790698945522, -0.03422950580716133, 0.04247451201081276, -0.02184016816318035, 0.031664345413446426, -0.005921884905546904, 0.01707812398672104, -0.09653940796852112, 0.012277940288186073, 0.022613851353526115, 0.007358517497777939, -0.0052764457650482655, -0.06849002093076706, 0.030545620247721672, -0.026318615302443504, -0.04558362811803818, 0.04559326171875, 0.016471993178129196, 0.006211734376847744, -0.00922674871981144, -0.010947338305413723, 0.025061704218387604, -0.038048580288887024, -0.007065832614898682, 0.0050429715774953365, 0.05274500697851181, 0.0428878515958786, -0.015150563791394234, 0.030211951583623886, 0.02822774089872837, 0.022235454991459846, -0.017152322456240654, -0.001533118193037808, 0.042950380593538284, 0.037251099944114685, 0.020055096596479416, -0.006949211470782757, 0.02457241341471672, 0.0016257131937891245, -0.038579437881708145, -0.012214909307658672, -0.0035820205230265856, -0.04553985968232155, -0.012938547879457474, 0.013667705468833447, -0.0024934373795986176, 0.050518132746219635, -0.011441758833825588, 0.019426194950938225, 0.01578383706510067, 0.0018178989412263036, 0.046940047293901443, -0.017892206087708473, -0.00933784432709217, -0.006053600925952196, -0.01876925490796566, -0.04616384953260422, -0.013650794513523579, -0.03252851590514183, 0.021196862682700157, 0.05923515185713768, -0.006114736199378967, -0.004455308895558119, 0.03795695677399635, 0.04059915244579315, 0.031405191868543625, 0.009308083914220333, 0.024402782320976257, 0.06795558333396912, -0.017305875197052956, -0.008282048627734184, -0.022949162870645523, 0.048859842121601105, 0.012324882671236992, 0.027838123962283134, -0.02580978162586689, 0.039486486464738846, -0.014502286911010742, 0.041570793837308884, 0.010299148969352245, 0.0030753931496292353, -0.05065779760479927, 0.02484181523323059, -0.02500779740512371, -0.011828181333839893, 0.02550145983695984, 0.04195481166243553, -0.011061713099479675, -0.040831077843904495, -0.03297703340649605, -0.04719167202711105, 0.020343691110610962, 0.0028564853128045797, -0.03370899334549904, -0.053142648190259933, 0.021138595417141914, 0.011237524449825287, 0.03664880245923996, 0.035648081451654434, 0.01765391416847706, -0.007899555377662182, -0.008957316167652607, -0.015230735763907433, 0.010543690994381905, -0.028695521876215935, 0.008785122074186802, 0.01752733252942562, 0.06777088344097137, -0.031137052923440933, -0.02014169469475746, -0.009342163801193237, 0.027074666693806648, -0.033195625990629196, -0.07604142278432846, -0.033094633370637894, 0.019615409895777702, -0.020559445023536682, -0.0039839125238358974, 0.036827508360147476, -0.0028177809435874224, -0.011462429538369179, 0.02897402085363865, 0.050659798085689545, -0.033497340977191925, -0.0017220855224877596, 0.009699862450361252, 0.05894623324275017, -0.02815064787864685, 0.01921594701707363, -0.021223464980721474, -0.015404554083943367, 0.028189806267619133, -0.05677454173564911, 0.02971769869327545, 0.014126215130090714, -0.03528044372797012, -0.03192080929875374, -0.025184057652950287, -0.014416368678212166, -0.026738347485661507, -0.0027015870437026024, 0.002286319388076663, -0.018672285601496696, 0.004998792428523302, 0.0025974044110625982, 0.021740812808275223, -0.033807188272476196, 0.008110083639621735, -0.03944213315844536, 0.003564410610124469, 0.001211914699524641, 0.0166911780834198, -0.00672270217910409, 0.0011427828576415777, -0.004034474957734346, -0.018213337287306786, 0.006608123425394297, 0.0056413160637021065, 0.015259324572980404, -0.026045124977827072, 0.005238453857600689, 0.026036614552140236, -0.010917199775576591, -0.010262868367135525, 0.023611189797520638, 0.02153378166258335, 0.01832091435790062, 0.005520803853869438, 0.010905577801167965, -0.04346179589629173, 0.004304020199924707, -0.0029894255567342043, -0.010495919734239578, -0.003525983775034547, -0.043323226273059845, 0.008746962063014507, 0.0005608538049273193, -0.01903918758034706, 0.0416131429374218, -0.013859766535460949, -0.0348813496530056, 0.017145121470093727, 0.03345414623618126, -0.003695355961099267, 0.011694474145770073, -0.031108379364013672, -0.00022459309548139572, -0.0414462573826313, -0.038250088691711426, -0.001834291499108076, 0.0328206866979599, -0.01966463401913643, 0.0382935032248497, 0.010003089904785156, 0.027025917544960976, -0.0008024484268389642, 0.03459960222244263, -0.02304363064467907, -0.022859275341033936, 0.018018942326307297, -0.060301028192043304, -0.003388213226571679, -0.0011907045263797045, -0.031745873391628265, 0.012155561707913876, -0.012144962325692177, -0.019933931529521942, 0.018732503056526184, 0.07862702757120132, -0.006637700367718935, 0.010557638481259346, 0.03181130811572075, -0.01269452553242445, -0.02282647229731083, -0.03070756047964096, 0.019731350243091583, -0.06871245801448822, 0.037812333554029465, 0.01868680864572525, 0.00615300377830863, 0.00641009584069252, -0.00277329352684319, 0.004141249693930149, -0.04308241233229637, 0.00395306758582592, 0.02111600898206234, 0.03227091208100319, -0.015044772066175938, -0.02168026566505432, -0.01783939078450203, 0.04890618100762367, -0.004690746311098337, -0.03760053589940071, 0.023275231942534447, 0.024473609402775764, -0.022726019844412804, 0.033319711685180664, -0.0014529622858390212, -0.004610945004969835, 0.009323404170572758, 0.05813977122306824, 0.010976077057421207, -0.029330868273973465, -0.027105990797281265, 0.0430154874920845, 0.021371740847826004, -0.06626084446907043, 0.0030213261488825083, -0.04278742894530296, -0.015706965699791908, 0.010384410619735718, -0.025900399312376976, 0.02800295688211918, 0.0102693447843194, -0.020702453330159187, 0.03115561418235302, -0.0005388857680372894, 0.019264619797468185, -0.008115566335618496, -0.05504653975367546, -0.010153451934456825, 0.021320469677448273, 0.02370821312069893, 0.015499448403716087, -0.004287657327950001, 0.03725563362240791, 0.043160706758499146, -0.002074143849313259, -0.05522764474153519, 0.02958216890692711, -0.006694554816931486, -0.004092384595423937, 0.013470020145177841, 0.0029239978175610304, -0.05736678093671799, -0.004533031955361366, -0.004386757500469685, 0.014807282947003841, 0.060587748885154724, 0.020142892375588417, 0.02131103351712227, 0.03443047031760216, 0.016765238717198372, -0.024824075400829315, 0.05031738057732582, -0.03866839036345482, 0.001009465311653912, 0.03407788276672363, 0.06130443513393402, 0.06612318009138107, 0.0500171072781086, -0.015818070620298386, -0.00704491650685668, 0.011560400016605854, 0.06508515775203705, -0.004859596025198698, 0.0366278775036335, 0.022241728380322456, 0.005823061801493168, -0.04100155085325241, -0.01719171740114689, 0.011554914526641369, -0.011395453475415707, 0.03944247588515282, 0.0036606495268642902, -0.002755622612312436, -0.01067811157554388, 0.06938955187797546, 0.027395956218242645, 0.027925699949264526, 0.0028590126894414425, 0.04535244032740593, 0.053235653787851334, 0.03631243854761124, 0.00443849666044116, 0.014515521936118603, -0.034143976867198944, -0.04370301216840744, 0.006775676738470793, 0.007971396669745445, 0.027767987921833992, 0.022275622934103012, 0.010354832746088505, 0.03360896185040474, -0.007803270593285561, 0.017815683037042618, 0.04090114310383797, 0.008824883960187435, -0.01635504700243473, -0.007704547140747309, 0.0302172489464283, -0.027179470285773277, 0.014952132478356361, -0.008192552253603935, 0.012974115088582039, 0.036595579236745834, 0.0020917837973684072, -0.037980012595653534, 0.020607102662324905, -0.015916427597403526, -0.0492071732878685, -0.02746228128671646, -0.0028499518521130085, 0.008315112441778183, 0.017222639173269272, -0.01413250993937254, -0.025449449196457863, -0.031086333096027374, -0.03312429413199425, -0.011406742967665195, 0.046898603439331055, -0.035625383257865906, -0.04255475848913193, -0.013084407895803452, -0.01981867291033268, -0.0034176979679614305, -0.003979763947427273, -0.0010349992662668228, 0.024589739739894867, 0.0059831044636666775, 0.021392855793237686, 0.02324094995856285, -0.02206531912088394, 0.03607633337378502, -0.045831725001335144, 0.007578269578516483, 0.012577420100569725, 0.05032000690698624, 0.009883432649075985, 0.03407242149114609, -0.06050248071551323, -0.046446628868579865, 0.04517702758312225, 0.017152469605207443, -0.01568191684782505, 0.012061521410942078, 0.011969910934567451, 0.009283674880862236, 0.008575940504670143, -0.02681625448167324, -0.040539223700761795, -0.003323835087940097, 0.00869253370910883, 0.0780804306268692, -0.028612367808818817, -0.03480532765388489, -0.0182817280292511, 0.009249569848179817, 0.026963869109749794, 0.018565120175480843, 0.029146891087293625, -0.001373058301396668, 0.018249748274683952, -0.04337294399738312, 0.03177349641919136, -0.0447390191257, 0.001249530934728682, -0.0207352451980114, -0.02831757627427578, -0.023011701181530952, 0.00530982343479991, -0.03422760218381882, -0.00958237238228321, -0.09042862802743912, 0.007652992848306894, -0.06277459114789963, -0.015304207801818848, -0.013161513954401016, 0.015952477231621742, 0.04985176771879196, 0.060399170964956284, 0.02636355720460415, 0.05230655521154404, -0.07493119686841965, -0.006222513038665056, -0.0019216706277802587, -0.008636719547212124, 0.009563704952597618, 0.006630307529121637, -0.005070950370281935, -0.007641279138624668, 0.016690609976649284, 0.017465943470597267, -0.0411040224134922, -0.03388608992099762, 0.03301279619336128, -0.01911318674683571, -0.0174296572804451, 0.007597140036523342, 0.05680839717388153, 0.03271639719605446, 0.020971493795514107, 0.00761669036000967, -0.03171595185995102, 0.024802304804325104, 0.023325294256210327, -0.09454658627510071, 0.02410692535340786, -0.02269984968006611, 0.009415105916559696, 0.014658503234386444, 0.0017643385799601674, 0.03084941767156124, 0.012926213443279266, 0.016939088702201843, -0.015662290155887604, 0.011250793002545834, -0.034487899392843246, -0.031040268018841743, -0.00037380779394879937, 0.044741515070199966, 0.001928363461047411, -0.01805710233747959, 0.054929330945014954, -0.020845724269747734, -0.0505041740834713, 0.002084829146042466, -0.0009012047084979713, 0.05536936596035957, 0.02226642519235611, 0.00021495972760021687, -0.03828524425625801, 0.035854972898960114, 0.04776248335838318, -0.009922861121594906, -0.03272707760334015, 0.01456189900636673 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
1. Install dependencies First, let's install all the libraries you will use in this tutorial: !pip install -q transformers tweepy wordcloud matplotlib
[ 0.0462128110229969, 0.007915804162621498, 0.10073865205049515, 0.04546065255999565, 0.11341620981693268, 0.08595848083496094, 0.028765521943569183, 0.07568573206663132, 0.010867889039218426, -0.06000998243689537, -0.0394364595413208, 0.0680137500166893, -0.003987729549407959, 0.07099966704845428, 0.03069332055747509, -0.0078085316345095634, 0.06215139105916023, 0.0077606686390936375, -0.012048124335706234, 0.032209619879722595, 0.011260095983743668, -0.03769383579492569, 0.028430169448256493, -0.022969679906964302, 0.033743180334568024, -0.10362257063388824, 0.04869568720459938, 0.06684800982475281, -0.021340535953640938, 0.012609164230525494, -0.1017182320356369, -0.0069041866809129715, 0.018506919965147972, -0.03219873458147049, -0.011915305629372597, 0.047816161066293716, -0.101925790309906, 0.07508346438407898, 0.04297726973891258, -0.07118362933397293, -0.0034768006298691034, -0.04056495800614357, -0.07407210767269135, 0.009724940173327923, -0.03868329897522926, -0.04298214241862297, -0.22373883426189423, 0.0853532999753952, -0.009305772371590137, -0.04463590309023857, -0.053167421370744705, 0.08468223363161087, 0.041947778314352036, -0.013974950648844242, 0.002847919939085841, 0.0017203943571075797, 0.015805261209607124, -0.06466950476169586, -0.05408560857176781, 0.026358436793088913, 0.06986391544342041, 0.011513021774590015, -0.021087242290377617, 0.047271646559238434, 0.03683916851878166, -0.0050490801222622395, -0.03812616318464279, 0.07189688831567764, -0.062038853764534, -0.044990938156843185, 0.03459271043539047, -0.059410229325294495, -0.05053945258259773, -0.05291195586323738, 0.028835250064730644, -0.041888825595378876, 0.03790837898850441, 0.03139372542500496, 0.045007310807704926, 0.06798458099365234, -0.0006615975289605558, 0.006166120991110802, 0.0656052902340889, 0.07757487148046494, 0.022419948130846024, -0.06280238926410675, 0.03153608366847038, 0.010778464376926422, -0.06037313491106033, 0.045807115733623505, -0.01816142350435257, -0.09808290004730225, -0.018868111073970795, 0.00047496246406808496, 0.015311334282159805, -0.014400581829249859, 0.0052588582038879395, -0.012373232282698154, 0.013728995807468891, -0.020412568002939224, -0.031033659353852272, -0.009069876745343208, 0.034525178372859955, -0.041492708027362823, -0.005377007182687521, 0.02392823062837124, 0.014388707466423512, -0.05592183768749237, -0.026699917390942574, -0.009446351788938046, -0.027183368802070618, 0.04302835091948509, 0.030399516224861145, 0.07373848557472229, -0.0491824746131897, 0.09964986145496368, 0.044800352305173874, 0.04952717944979668, -0.014161301776766777, 0.0281378123909235, 0.012110810726881027, 0.06635664403438568, 0.053556036204099655, -0.0022613899782299995, 0.025081835687160492, 0.07630157470703125, -0.011920404620468616, 0.020942440256476402, -0.07322510331869125, -0.06942879408597946, 0.08099442720413208, 0.01204212848097086, 0.04265284910798073, -0.05203443393111229, -0.015376667492091656, -0.08724164962768555, -0.02520935796201229, 0.0034919907338917255, -0.006996338255703449, -0.009909268468618393, 0.04658026248216629, 0.07849059253931046, -0.04535137116909027, 0.10738532990217209, -0.007762950379401445, -0.013819084502756596, -0.0917079970240593, 0.015244427137076855, -0.02099631354212761, 0.020571613684296608, -0.022396767511963844, 0.05812494829297066, -0.06080906465649605, -0.03631085902452469, 0.012646027840673923, 0.04456592723727226, 0.01855858787894249, 0.03205079585313797, -0.05990739166736603, -0.05776689946651459, 0.02157006971538067, 0.013183229602873325, -0.04220288246870041, -0.0045878891833126545, 0.051012828946113586, -0.08100166916847229, 0.03200559690594673, 0.022837700322270393, 0.008386905305087566, -0.028837772086262703, -0.021205423399806023, -0.047760218381881714, 0.051991939544677734, 0.023897424340248108, 0.0035104642156511545, 0.024429181590676308, 0.05848304182291031, 0.028357544913887978, -0.004642941057682037, 0.010249091312289238, -0.017624331638216972, 0.07656020671129227, -0.05925045907497406, 0.05099261924624443, 0.03735806420445442, -0.052554916590452194, 0.02796853706240654, -0.026065677404403687, 0.04504938796162605, -0.014932265505194664, -0.06196432188153267, -0.07966743409633636, 0.07059420645236969, 0.022276990115642548, 0.03885095939040184, -0.02692875638604164, -0.011055110022425652, 0.06893952935934067, 0.05255546793341637, 0.06270477175712585, 0.0030605485662817955, -0.006399533711373806, 0.063898466527462, -0.028408022597432137, -0.03223513439297676, 0.04670000821352005, 0.004618301056325436, -0.07912351936101913, 0.03001551516354084, -0.011657631024718285, -0.05376790836453438, -0.10314898192882538, 0.04204123094677925, -0.0864386036992073, 0.04617803543806076, -0.039136774837970734, -0.00996560137718916, -0.0003752076590899378, 0.014134438708424568, 0.012362341396510601, 0.09331652522087097, -0.029828201979398727, -0.0040675620548427105, 0.025644583627581596, -0.04874233156442642, 0.06585673242807388, 0.07211793214082718, 0.021071061491966248, 0.08368203043937683, -0.09468554705381393, -0.06375011801719666, -0.029420075938105583, -0.02480880729854107, 0.05879911035299301, 0.012453880161046982, -0.0034684205893427134, -0.012220251373946667, -0.036365918815135956, 0.005909474566578865, -0.06272024661302567, 0.032854560762643814, 0.0009909896180033684, -0.06639537960290909, 0.018570153042674065, 0.003669468918815255, -0.02906237170100212, 0.04631948471069336, -0.01781829260289669, -0.014420503750443459, -0.0024190768599510193, -0.031592585146427155, 0.007246840745210648, 0.019213687628507614, -0.008610354736447334, 0.03983921930193901, 0.05831221863627434, -0.012686366215348244, 0.001655492465943098, -0.016236497089266777, 0.039449408650398254, -0.028141645714640617, 0.014298061840236187, 0.004875734448432922, -0.059530891478061676, -0.02283448539674282, -0.0027354613412171602, -0.009624860249459743, 0.0005920424009673297, -0.014903217554092407, -0.01818709261715412, 0.009487301111221313, -0.04869847372174263, 0.05603816732764244, 0.027803007513284683, -0.01656712405383587, -0.006067256908863783, 0.023670589551329613, 0.00830549094825983, 0.008459948934614658, -0.035283736884593964, 0.011029974557459354, -0.012994898483157158, 0.02015306055545807, 0.019444862380623817, 0.026637062430381775, 0.0017108932370319963, 0.01697614975273609, -0.0021547237411141396, -0.023215187713503838, 0.015111814253032207, -0.04055314138531685, 0.029369961470365524, -0.027656879276037216, -0.0411868579685688, 0.007310602813959122, 0.010908437892794609, 0.010557042434811592, 0.022313183173537254, -0.028081495314836502, 0.012299117632210255, -0.007258954923599958, -0.011566721834242344, 0.010641951113939285, -0.018242938444018364, -0.06658663600683212, 0.015128005295991898, 0.0007334488327614963, -0.013886128552258015, -0.13759975135326385, -0.04062864929437637, 0.008136830292642117, 0.055002447217702866, -0.027280183508992195, -0.015294985845685005, 0.055431757122278214, -0.007267821580171585, -0.022895263507962227, 0.004992856178432703, -0.011531559750437737, 0.018081367015838623, -0.03344017639756203, 0.0058607617393136024, 0.025538494810461998, -0.03667986020445824, -0.0017591665964573622, 0.03192390128970146, 0.03841933608055115, 0.028833463788032532, -0.02265023998916149, 0.06716705858707428, -0.008891422301530838, 0.007726823911070824, -0.007671253755688667, -0.0033440992701798677, 0.036451760679483414, 0.05920174717903137, 0.00423600384965539, -0.020456582307815552, -0.021762283518910408, 0.004032159224152565, -0.023720791563391685, 0.03527222201228142, -0.045606598258018494, -0.013984499499201775, -0.0072578745894134045, 0.001995168626308441, 0.020203815773129463, 0.04634564742445946, -0.015117418952286243, -0.00575958751142025, 0.016850914806127548, 0.010354958474636078, -0.02183377929031849, 0.010225586593151093, -0.025041287764906883, 0.017774412408471107, 0.01259771641343832, 0.0005703336792066693, -0.017771709710359573, -0.03122723288834095, -0.009424629621207714, 0.01724238507449627, -0.00016926352691370994, 0.00499890698119998, 0.01820584386587143, 0.046641793102025986, 0.031035687774419785, -0.02223547361791134, -0.03334827348589897, 0.040771275758743286, 0.017442947253584862, -0.041300877928733826, -0.008676638826727867, 0.05507110804319382, -0.021352048963308334, 0.03271305933594704, 0.02637743018567562, 0.02149057574570179, -0.022611482068896294, 0.02664968930184841, -0.004976953845471144, 0.01720914989709854, -0.02452988177537918, 0.02366715297102928, -0.0367741622030735, 0.0013279523700475693, 0.07876966148614883, 0.016544325277209282, -0.01869085617363453, -0.055909160524606705, -0.00812746025621891, 0.002415848895907402, -0.005345440935343504, 0.03378138691186905, 0.025405004620552063, -0.027287498116493225, 0.02158418484032154, 0.04785230755805969, 0.02800106257200241, -0.022939106449484825, 0.023649057373404503, -0.017793145030736923, -0.018292633816599846, -0.021071074530482292, 0.04138266295194626, -0.029929369688034058, -0.023735476657748222, 0.002246827818453312, 0.028423456475138664, -0.010288509540259838, -0.0274774432182312, 0.02729516662657261, -0.015276450663805008, -0.0007627404411323369, -0.02259943075478077, -0.019051967188715935, 0.0051668910309672356, 0.007668108679354191, 0.020890336483716965, -0.05400719493627548, 0.011080305092036724, -0.04752056300640106, 0.0023745009675621986, 0.03941003605723381, 0.0021009729243814945, -0.023719098418951035, -0.028749292716383934, 0.03121754340827465, -0.023656625300645828, 0.03192566707730293, -0.02221895195543766, -0.02711906097829342, -0.028365790843963623, -0.011474685743451118, 0.054305072873830795, 0.011532397009432316, -0.02420376054942608, 0.015633976086974144, -0.022373057901859283, -0.03885311260819435, -0.009180101566016674, -0.005810102913528681, 0.01839548349380493, -0.004217278677970171, 0.009791463613510132, 0.022963957861065865, 0.016034182161092758, -0.036120060831308365, -0.01802321895956993, -0.0046578967012465, 0.05801839753985405, -0.03761275112628937, 0.007768123410642147, -0.02896992862224579, -0.044954486191272736, 0.008172489702701569, -0.019846122711896896, -0.005398886278271675, -0.0042450265027582645, 0.0017772758146747947, -0.0010647004237398505, 0.02485658787190914, 0.01539667323231697, -0.0034748471807688475, -0.0020085398573428392, -0.0016655594808980823, -0.012458537705242634, 0.06081249564886093, -0.025320202112197876, -0.04117601364850998, -0.021026547998189926, 0.016046086326241493, -0.013374675065279007, 0.002093062037602067, 0.013827321119606495, -0.04495721310377121, -0.010491016320884228, 0.0036654805298894644, -0.00880825612694025, 0.012992349453270435, 0.018050417304039, -0.012628438882529736, 0.02570224367082119, 0.020784856751561165, 0.007205218076705933, 0.0025986621621996164, -0.0008524238364771008, 0.006690138019621372, -0.024142026901245117, -0.03092557191848755, -0.003775632008910179, -0.007476107217371464, -0.05119677260518074, 0.03478126600384712, 0.039336953312158585, 0.007631335873156786, 0.016354495659470558, 0.053477589040994644, -0.026537390425801277, -0.015608356334269047, -0.001246485859155655, -0.041172053664922714, 0.007221497129648924, -0.027946313843131065, 0.022176256403326988, 0.017102133482694626, -0.024602064862847328, -0.017438748851418495, 0.020240237936377525, 0.03151911869645119, 0.004001183435320854, -0.04624711722135544, 0.05863296613097191, 0.014416721649467945, -0.016667835414409637, -0.0209344569593668, 0.04957396537065506, -0.023028260096907616, 0.003260691650211811, -0.00030232721474021673, -0.011688551865518093, -0.035942405462265015, -0.06381432712078094, -0.021164409816265106, -0.02855902537703514, 0.025362428277730942, 0.026118947193026543, 0.041240960359573364, -0.008232303895056248, -0.0006474726251326501, 0.0012841075658798218, 0.04226638004183769, 0.04408903792500496, -0.01285602804273367, -0.0372336283326149, 0.03298451378941536, -0.014818058349192142, 0.03685688227415085, 0.03973047435283661, -0.0007615708163939416, -0.0011591378133744001, 0.04167376458644867, 0.01112748309969902, -0.0040138172917068005, -0.0652693659067154, 0.023164479061961174, 0.016887612640857697, -0.0003975930158048868, -0.009437426924705505, -0.020360495895147324, -0.04854082316160202, -0.025298861786723137, -0.009372236207127571, 0.008975369855761528, 0.08349280804395676, 0.006268467754125595, 0.009816361591219902, -0.0008510843035764992, 0.010297314263880253, 0.002932483097538352, -0.0189603753387928, -0.006156285759061575, 0.004222320858389139, 0.020709550008177757, 0.018607107922434807, -0.00482128607109189, 0.0209658220410347, -0.005916849710047245, 0.009314694441854954, -0.049813251942396164, 0.02872459590435028, -0.0022408890072256327, -0.0051922970451414585, 0.0037776511162519455, 0.029459964483976364, -0.03388575464487076, -0.025717467069625854, 0.02219802513718605, 0.008395419456064701, 0.058401431888341904, 0.006448601372539997, -0.0030142469331622124, -0.01904631033539772, -0.03532284125685692, 0.033901557326316833, 0.018281329423189163, -0.02706572413444519, 0.02118411287665367, 0.015928203240036964, 0.03311220183968544, 0.025240721181035042, -0.01153489388525486, -0.00949111394584179, 0.03804197534918785, 0.058439966291189194, 0.015407964587211609, 0.04504165053367615, 0.007299305405467749, -0.018078915774822235, -0.020658528432250023, -0.03082725591957569, -0.0071207997389137745, -0.03632888197898865, 0.032480090856552124, 0.02291662059724331, -0.006872032303363085, 0.0021954241674393415, -0.03930724412202835, 0.04599006846547127, 0.0036181199830025434, 0.057558465749025345, 0.00024090993974823505, 0.005204947665333748, 0.03551515191793442, 0.007484911475330591, 0.00458889314904809, -0.004882423207163811, 0.0033380654640495777, 0.006072979420423508, 0.052971720695495605, 0.00986743438988924, 0.025024741888046265, -0.007340633776038885, -0.02470548264682293, 0.022430844604969025, -0.036130279302597046, -0.011557508260011673, -0.013650167733430862, 0.01896367222070694, -0.05939069390296936, -0.03869502991437912, 0.00859074667096138, -0.05574918910861015, -0.03196687251329422, -0.012766942381858826, -0.0036842755507677794, -0.011254974640905857, -0.03679291158914566, -0.009842419065535069, 0.013278082013130188, 0.014331658370792866, -0.00896249245852232, -0.014070042409002781, 0.04863838851451874, -0.005384703166782856, 0.021538952365517616, -0.0060079884715378284, -0.027815626934170723, -0.02566499449312687, 0.009019773453474045, -0.011440693400800228, 0.0012600868940353394, 0.005785592831671238, -0.02419295348227024, -0.004258802160620689, -0.007484414614737034, -0.031045695766806602, 0.023892758414149284, 0.024475237354636192, 0.03290300816297531, -0.049341075122356415, 0.04655448719859123, -0.0018773896154016256, 0.0007976451888680458, -0.005987711250782013, -0.006017656996846199, 0.013192333281040192, -0.018646737560629845, 0.0015164592768996954, 0.0228132177144289, -0.0017200487200170755, -0.013570576906204224, -0.04122329130768776, 0.05884633585810661, 0.002409842098131776, -0.01767248660326004, 0.03983844444155693, 0.005734856706112623, 0.024222588166594505, 0.015730274841189384, -0.004509981721639633, 0.02940400317311287, -0.027203625068068504, 0.020432213321328163, 0.0011614587856456637, -0.02538657747209072, -0.0025145895779132843, -0.015603916719555855, 0.06455466151237488, 0.004551482852548361, 0.013023308478295803, 0.04008710756897926, 0.0323992557823658, 0.020791133865714073, -0.012918880209326744, 0.017438171431422234, -0.02586963027715683, 0.009442181326448917, -0.04933592677116394, -0.03139610216021538, -0.020810699090361595, -0.040121618658304214, -0.02193487249314785, 0.02303997427225113, -0.06708423048257828, -0.01612110435962677, -0.03838656097650528, -0.017396369948983192, 0.024984603747725487, 0.014869488775730133, 0.03152089938521385, 0.04609494283795357, 0.03360394015908241, 0.011259770952165127, 0.0051088775508105755, 0.01263224333524704, 0.011635406874120235, 0.011875246651470661, 0.030533025041222572, 0.036568962037563324, -0.015548034571111202, -0.051315490156412125, 0.03534902632236481, -0.004161242861300707, -0.03408797085285187, 0.013943452388048172, -0.0033229722175747156, -0.04867644980549812, -0.006535199470818043, -0.03178679570555687, 0.010366869159042835, 0.02704024873673916, -0.0023730145767331123, -0.0013599691446870565, -0.02032272145152092, 0.04148459434509277, 0.030446732416749, -0.05755917727947235, 0.014735011383891106, 0.03116239607334137, -0.015241035260260105, 0.0034773421939462423, 0.0022431460674852133, 0.0010755998082458973, -0.003997789695858955, -0.03008626401424408, -0.0058244364336133, 0.04094790294766426, -0.029187478125095367, -0.0317983515560627, -0.008075742051005363, 0.05520864203572273, -0.051630619913339615, -0.03336726129055023, 0.04706843942403793, 0.019222375005483627, -0.02630203403532505, -0.015174434520304203, 0.02356577105820179, 0.0020719945896416903, -0.040455278009176254, 0.05031471326947212, -0.014065990224480629, 0.06702109426259995, 0.021982021629810333, -0.020480580627918243, 0.004443929996341467, 0.04265608265995979 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
2. Set up Twitter API credentials Next, you will set up the credentials for interacting with the Twitter API. First, you'll need to sign up for a developer account on Twitter. Then, you have to create a new project and connect an app to get an API key and token. You can follow this step-by-step guide to get your credentials. Once you have the API key and token, let's create a wrapper with Tweepy for interacting with the Twitter API: python import tweepy # Add Twitter API key and secret consumer_key = "XXXXXX" consumer_secret = "XXXXXX" # Handling authentication with Twitter auth = tweepy.AppAuthHandler(consumer_key, consumer_secret) # Create a wrapper for the Twitter API api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
[ 0.10229939222335815, 0.08208022266626358, 0.05499112233519554, -0.024597836658358574, 0.05306369811296463, 0.0893063098192215, 0.0409759059548378, 0.10196052491664886, 0.0038935430347919464, -0.013404768891632557, -0.004859690088778734, 0.0879817083477974, 0.014292221516370773, 0.017821157351136208, 0.0031164423562586308, -0.04191259667277336, 0.04087236151099205, -0.008303303271532059, 0.024687929078936577, -0.006499100476503372, -0.03817034512758255, -0.01673801802098751, -0.008692008443176746, -0.033073101192712784, 0.010339632630348206, -0.056107308715581894, 0.021105093881487846, 0.06984332203865051, -0.05026143789291382, -0.014425776898860931, -0.046055298298597336, 0.035812780261039734, 0.047392502427101135, -0.0694633200764656, 0.049292225390672684, 0.047300178557634354, -0.09374666959047318, 0.06867887079715729, 0.07852528244256973, -0.0006320290267467499, -0.019707242026925087, -0.07164156436920166, -0.04648728668689728, 0.049027327448129654, -0.039406780153512955, -0.01870441809296608, -0.177567258477211, 0.08560548722743988, 0.07914399355649948, -0.06866563111543655, -0.05443969741463661, 0.14185644686222076, 0.03408214449882507, 0.01987873762845993, 0.038262780755758286, 0.02676582522690296, -0.025244729593396187, -0.07408615946769714, -0.030566846951842308, 0.015581117942929268, 0.11005212366580963, 0.0024047556798905134, 0.034126657992601395, 0.028977759182453156, 0.026291456073522568, 0.009651836939156055, -0.013625402934849262, 0.040032655000686646, -0.0636494979262352, -0.002131801564246416, 0.040790949016809464, -0.0804537981748581, -0.0626167580485344, -0.024614205583930016, -0.012855804525315762, -0.07953614741563797, 0.03151380643248558, 0.0826411172747612, 0.08515085279941559, 0.07196022570133209, -0.015533572994172573, -0.02045425958931446, -0.020989390090107918, 0.022077364847064018, 0.033437587320804596, 0.0034944345243275166, -0.0030152411200106144, -0.012663226574659348, 0.01740230619907379, 0.028356391936540604, -0.003769493894651532, -0.06164025887846947, -0.006682686507701874, -0.04147820174694061, 0.011560495011508465, 0.026419412344694138, 0.014971070922911167, 0.06671085208654404, -0.002865628572180867, -0.006024227477610111, -0.059405308216810226, -0.031954076141119, -0.015907838940620422, -0.07472257316112518, -0.0468076653778553, 0.07917311787605286, 0.03763649985194206, -0.004359860438853502, 0.005319059360772371, -0.008395384065806866, -0.013501172885298729, 0.05891714245080948, -0.02001894637942314, 0.029328472912311554, -0.028927862644195557, 0.07567347586154938, 0.034225139766931534, -0.0045082662254571915, -0.08241529017686844, 0.020606355741620064, 0.043344009667634964, 0.029740214347839355, 0.03579656779766083, 0.001661561313085258, 0.0469844825565815, 0.04670648276805878, -0.01996602676808834, 0.009933176450431347, -0.003869955660775304, -0.047149524092674255, 0.06909017264842987, 0.06826355308294296, 0.08353837579488754, -0.02143147587776184, -0.044193245470523834, 0.02232041209936142, -0.056416161358356476, -0.022699564695358276, 0.06157521530985832, -0.000490690057631582, 0.02874661237001419, 0.03012075275182724, -0.044275376945734024, 0.06527625769376755, -0.013438260182738304, 0.05600016936659813, -0.04132943972945213, -0.005190253257751465, 0.018819987773895264, 0.01637468859553337, -0.02517588436603546, -0.010976840741932392, -0.010252594016492367, -0.021374525502324104, -0.009625171311199665, 0.005490276496857405, 0.034895382821559906, -0.013803440146148205, -0.035644300282001495, 0.00602128216996789, 0.07116001099348068, -0.001852222252637148, -0.052606742829084396, -0.025693895295262337, 0.0578736886382103, 0.007674924097955227, 0.01062689907848835, -0.009443683549761772, 0.022067377343773842, -0.031807150691747665, -0.044892266392707825, -0.02434009313583374, 0.009976477362215519, 0.019231731072068214, 0.07739543169736862, 0.0204378142952919, 0.030301662161946297, -0.047234561294317245, -0.004415456205606461, 0.024386446923017502, -0.012500330805778503, 0.06970678269863129, -0.03865501284599304, 0.07190650701522827, -0.02021857351064682, -0.04879285767674446, 0.0004732936213258654, 0.011608805507421494, 0.004185142461210489, -0.015608753077685833, -0.009736621752381325, -0.07728412747383118, -0.0024832210037857294, -0.03468141332268715, 0.03656281530857086, -0.04199519753456116, 0.004471403546631336, 0.05521110072731972, 0.00046945540816523135, 0.06664825975894928, 0.01530076190829277, -0.03116397187113762, 0.00122725625988096, -0.05185438692569733, -0.04858456924557686, 0.0336114838719368, 0.05317750945687294, -0.060931503772735596, 0.025606773793697357, 0.02109714038670063, -0.012132025323808193, -0.07888109982013702, 0.0286026019603014, -0.11156015843153, 0.03766315430402756, 0.01571030728518963, 0.009225196205079556, 0.04370218887925148, 0.02913724072277546, 0.026587259024381638, 0.16024383902549744, -0.014792388305068016, 0.031824998557567596, 0.013829254545271397, -0.047082915902137756, 0.027645623311400414, 0.011593255214393139, 0.05277576670050621, 0.10400786250829697, -0.07648496329784393, -0.07774672657251358, -0.018577678129076958, -0.040811456739902496, 0.014357303269207478, 0.022305382415652275, -0.013828582130372524, -0.018350452184677124, -0.059516530483961105, 0.0033298414200544357, -0.07799359411001205, 0.06356797367334366, -0.039106182754039764, -0.10727149248123169, -0.014798386953771114, -0.019458379596471786, -0.027241241186857224, 0.1016339436173439, -0.02115553431212902, 0.0018481452716514468, -0.00360828242264688, -0.020245244726538658, 0.005531791597604752, 0.03198884800076485, -0.025683457031846046, 0.09064365923404694, 0.043817050755023956, -0.02298806980252266, 0.0073744794353842735, 0.02589588053524494, 0.01524514053016901, -0.0089991744607687, 0.012561531737446785, 0.010880935937166214, -0.032174888998270035, -0.05484004318714142, 0.02015816792845726, -0.018056722357869148, -0.009897486306726933, -0.029129590839147568, 0.005353011190891266, 0.029540449380874634, -0.049838557839393616, 0.0024728321004658937, 0.020534895360469818, -0.026794955134391785, 0.022489724680781364, -0.00039950350765138865, 0.012019720859825611, 0.0014664410846307874, -0.0276566781103611, 0.013475507497787476, -0.029956461861729622, 0.02884487621486187, 0.00693432567641139, 0.045494407415390015, -0.00986840482801199, -0.019013935700058937, -0.005101540591567755, -0.016122061759233475, 0.003520477330312133, -0.051131609827280045, 0.008253050968050957, -0.0179139394313097, 0.008532135747373104, 0.017631232738494873, 0.015005898661911488, -0.004347148817032576, 0.022947248071432114, -0.029396768659353256, 0.05082089453935623, -0.00839347392320633, -0.0174707043915987, -0.00134107971098274, -0.050127480179071426, -0.06829791516065598, 0.016459934413433075, 0.014647574163973331, -0.0319119393825531, -0.11005140841007233, 0.004769406281411648, -0.0075444714166224, 0.007995731197297573, 0.00007784600893501192, 0.038333404809236526, 0.056132350116968155, -0.006275503430515528, -0.005311955697834492, 0.012061160989105701, -0.024878744035959244, 0.0022728852927684784, -0.03405317664146423, -0.016680089756846428, -0.013788891956210136, -0.02207872085273266, 0.012187457643449306, 0.02412174642086029, 0.029780849814414978, 0.030510302633047104, -0.05089021846652031, 0.04169076308608055, 0.0045036980882287025, -0.022534247487783432, -0.01678447052836418, -0.022213030606508255, 0.01390896551311016, 0.03196188807487488, 0.01740812323987484, -0.01897861808538437, 0.008589639328420162, -0.03591197729110718, -0.01247012335807085, -0.006750862114131451, -0.06861403584480286, -0.006834589410573244, 0.012826777063310146, -0.04136734828352928, 0.03284712880849838, -0.004652152303606272, -0.06722753494977951, -0.0010167146101593971, -0.00535588338971138, -0.02878863736987114, 0.00530376797541976, -0.0033770883455872536, -0.03837355226278305, -0.003906778059899807, 0.03391279652714729, -0.011420647613704205, -0.025901446118950844, -0.005300599616020918, -0.036893609911203384, 0.024197962135076523, 0.0390646755695343, 0.0028351438231766224, -0.0029914795886725187, 0.03843347728252411, 0.020291464403271675, -0.022341197356581688, -0.01536707952618599, 0.0034634654875844717, 0.04524800553917885, -0.01737537421286106, -0.05609843134880066, 0.03915909677743912, 0.020599965006113052, 0.016150852665305138, 0.014985775575041771, 0.016807418316602707, -0.005931617226451635, 0.026218857616186142, -0.01614590920507908, 0.016431370750069618, 0.002155622001737356, 0.02294852025806904, -0.027879349887371063, 0.012337738648056984, 0.07810886204242706, 0.0421258807182312, 0.006826064549386501, -0.013951935805380344, 0.009717206470668316, 0.006730315275490284, 0.01571069285273552, 0.010778245516121387, 0.004765143617987633, -0.006617543287575245, 0.027557816356420517, 0.06054931879043579, -0.006020184140652418, -0.014995824545621872, 0.03294534981250763, 0.0072714961133897305, -0.014306253753602505, 0.03242262080311775, 0.08101347833871841, 0.022413140162825584, 0.011619620956480503, 0.029549017548561096, 0.04719754308462143, -0.008071261458098888, -0.02444174326956272, 0.020429909229278564, 0.03267347440123558, 0.014453379437327385, -0.060928329825401306, -0.05566192418336868, 0.014671612530946732, -0.013812459073960781, 0.0340486541390419, -0.023710884153842926, 0.008340093307197094, -0.02254166267812252, -0.01767590083181858, 0.05267433077096939, 0.00866642501205206, -0.023655148223042488, -0.014322554692626, 0.03430933877825737, -0.058239877223968506, 0.016776669770479202, -0.019585903733968735, -0.002672807080671191, 0.001432022894732654, -0.02034934051334858, 0.05304767191410065, -0.029011519625782967, -0.04924861341714859, 0.005386011675000191, -0.013925481587648392, -0.03605131059885025, -0.04109325259923935, -0.030706005170941353, -0.0009864394087344408, -0.01359062734991312, 0.020144345238804817, -0.011698133312165737, 0.04818030446767807, -0.04574098438024521, -0.020241042599081993, -0.0007176278159022331, 0.033191703259944916, -0.035327982157468796, 0.010575249791145325, 0.010795831680297852, -0.08479572087526321, -0.01830342784523964, 0.00036493258085101843, -0.0021494152024388313, -0.021809469908475876, -0.01497731450945139, 0.0012223616940900683, -0.0008239309536293149, 0.03509534150362015, -0.01911521889269352, 0.028001029044389725, 0.012737458571791649, -0.033477358520030975, 0.05626216158270836, 0.015459577552974224, -0.02298085018992424, 0.03558632358908653, -0.0008494649664498866, 0.006308015435934067, -0.001969986129552126, -0.034856561571359634, -0.026286736130714417, 0.010908260941505432, -0.011186942458152771, -0.03679144009947777, 0.038990139961242676, 0.014342713169753551, -0.000736894435249269, 0.027558261528611183, 0.0201723650097847, 0.008435621857643127, 0.031510986387729645, -0.04451501742005348, 0.007984772324562073, -0.018664078786969185, -0.016167577356100082, -0.016225049272179604, 0.0001859381009126082, -0.03159992769360542, 0.0037650924641638994, 0.058964796364307404, -0.002656626747921109, 0.030640002340078354, 0.07067104429006577, -0.040329061448574066, -0.02508920058608055, 0.0010729791829362512, -0.03708041086792946, 0.0265938863158226, -0.04803640767931938, -0.0016216111835092306, -0.020268578082323074, -0.0338420532643795, -0.030590934678912163, 0.011901152320206165, 0.04428021237254143, -0.0379905141890049, -0.022169141098856926, 0.053046368062496185, 0.03808934614062309, 0.00015898654237389565, 0.003855897579342127, 0.02414308860898018, -0.007849141955375671, -0.020448552444577217, -0.010249946266412735, 0.013213633559644222, -0.005710400640964508, 0.0034707740414887667, 0.009406788274645805, -0.04874294996261597, 0.025033963844180107, -0.01197560504078865, 0.03208703175187111, -0.009531563147902489, -0.021352559328079224, 0.003942310810089111, 0.03329557552933693, 0.08042524755001068, 0.022678624838590622, -0.016893424093723297, -0.004923249129205942, 0.03750282898545265, 0.021198540925979614, 0.04056977108120918, -0.023840833455324173, 0.017660293728113174, 0.044509101659059525, 0.026926293969154358, -0.004821357782930136, -0.046168114989995956, 0.013975811190903187, -0.010315227322280407, -0.01043552067130804, -0.0626872330904007, -0.0261585284024477, -0.033238206058740616, -0.01825614459812641, 0.014226270839571953, -0.013032886199653149, 0.049602728337049484, -0.00048291278653778136, 0.008253095671534538, -0.042492665350437164, 0.008837943896651268, 0.0002942483115475625, 0.006303280591964722, -0.01339637953788042, 0.018907921388745308, -0.014913554303348064, 0.012355097569525242, -0.03145564720034599, 0.04247712716460228, -0.02597109228372574, 0.029604924842715263, -0.06448513269424438, 0.014911836013197899, 0.02075512520968914, 0.01110539585351944, 0.002534194616600871, 0.011930347420275211, -0.021351568400859833, -0.0092496732249856, 0.008413465693593025, 0.026407960802316666, 0.03402645140886307, -0.014412005431950092, -0.03232588246464729, -0.029809892177581787, -0.04514550790190697, -0.0006857817643322051, 0.04507402703166008, -0.04328075423836708, 0.06328500807285309, -0.010716081596910954, 0.04094747453927994, -0.002134975278750062, 0.007509331684559584, 0.001019564806483686, 0.05118216201663017, 0.03412267193198204, 0.043932102620601654, 0.03302807733416557, 0.0022615378256887197, -0.03143809363245964, -0.017671098932623863, -0.005491879303008318, 0.03553571179509163, -0.006307422183454037, 0.015483014285564423, 0.02941155433654785, -0.04212202876806259, 0.04847270995378494, -0.030617741867899895, 0.05381977558135986, -0.020816128700971603, 0.03702494502067566, 0.014987976290285587, 0.01206788420677185, 0.03268678858876228, 0.0033130329102277756, -0.026937508955597878, 0.019734248518943787, -0.003920788411051035, -0.04802098870277405, 0.014519941061735153, 0.029925495386123657, 0.023025481030344963, -0.014734483323991299, 0.00579758919775486, 0.010815725661814213, -0.008604339323937893, -0.04026758670806885, -0.014592277817428112, 0.01623847894370556, -0.0564843975007534, 0.01563742756843567, -0.0005992763908579946, -0.04714024066925049, -0.011002586223185062, 0.006167576182633638, -0.029384706169366837, -0.01195951085537672, -0.05599341541528702, -0.00828383956104517, 0.011319092474877834, 0.0015413799555972219, -0.023353660479187965, -0.01976080983877182, 0.030852584168314934, -0.013501276262104511, -0.02250698395073414, -0.02592402510344982, -0.017241178080439568, -0.015876898542046547, 0.000813508580904454, 0.004096542485058308, 0.03238939121365547, -0.01490715704858303, -0.016064373776316643, -0.018046842887997627, 0.00469140475615859, -0.010446518659591675, 0.041904058307409286, 0.007990196347236633, 0.01564810797572136, -0.015938246622681618, 0.010904538445174694, 0.019534293562173843, -0.03518322855234146, -0.030143627896904945, 0.007705229800194502, -0.014167002402245998, -0.009724410250782967, 0.055523861199617386, -0.0007814528653398156, -0.006066245958209038, -0.0013298692647367716, -0.06782876700162888, 0.032083455473184586, -0.002171147847548127, -0.06778436154127121, 0.06572934985160828, 0.01452762633562088, 0.010469223372638226, 0.017722779884934425, -0.0005780645296908915, -0.010777040384709835, 0.0010075279278680682, 0.010815194807946682, 0.037594761699438095, -0.016976388171315193, -0.010658245533704758, -0.006269919686019421, 0.021367888897657394, 0.012538576498627663, -0.0013807157520204782, 0.04014907404780388, -0.011388811282813549, 0.005210963077843189, -0.023164385929703712, -0.040743593126535416, -0.017368381842970848, -0.01502991747111082, -0.03297341987490654, -0.04297161102294922, -0.03217409551143646, -0.03678731992840767, -0.0241928119212389, -0.015265497379004955, -0.06597137451171875, -0.023251857608556747, 0.001955004408955574, 0.011577687226235867, 0.027851462364196777, 0.00498570129275322, 0.009535067714750767, -0.001452238648198545, 0.007501929998397827, 0.038220882415771484, 0.003258130047470331, -0.024876685813069344, 0.0061632199212908745, 0.012789439409971237, -0.005780571140348911, 0.028827518224716187, -0.018466562032699585, 0.009825866669416428, 0.021773163229227066, -0.00016076462634373456, -0.00873520877212286, 0.03300983086228371, 0.008667068555951118, -0.028029872104525566, -0.023563329130411148, 0.01446589920669794, 0.011959636583924294, 0.019034473225474358, 0.014038772322237492, 0.009989101439714432, -0.002226271666586399, -0.00981154665350914, 0.004940594546496868, -0.02709556557238102, -0.024561069905757904, -0.005954811815172434, -0.03942965716123581, 0.01340851467102766, -0.01259757298976183, 0.005145624279975891, 0.04167119041085243, 0.01589108444750309, 0.03088909387588501, 0.04442432150244713, -0.04060147702693939, -0.02536678873002529, -0.023504555225372314, 0.070881187915802, -0.06860437244176865, -0.0538482666015625, 0.05704765021800995, -0.009911092929542065, -0.03513845056295395, -0.007138183806091547, 0.027287133038043976, -0.012876609340310097, -0.0014596341643482447, 0.0304695013910532, -0.02788127399981022, 0.06141362339258194, -0.001421451917849481, -0.0564887560904026, -0.02271169424057007, -0.007164139300584793 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
4. Run sentiment analysis on the tweets Now you can put our new skills to work and run sentiment analysis on your data! 🎉 You will use one of the models available on the Hub fine-tuned for sentiment analysis of tweets. Like in other sections of this post, you will use the pipeline class to make the predictions with this model: python from transformers import pipeline # Set up the inference pipeline using a model from the 🤗 Hub sentiment_analysis = pipeline(model="finiteautomata/bertweet-base-sentiment-analysis") # Let's run the sentiment analysis on each tweet tweets = [] for tweet in search: try: content = tweet.full_text sentiment = sentiment_analysis(content) tweets.append({'tweet': content, 'sentiment': sentiment[0]['label']}) except: pass
[ 0.0012615282321348786, -0.032429855316877365, 0.014987164177000523, 0.004854037892073393, 0.010285038501024246, 0.06444384902715683, 0.06314913928508759, 0.09604642540216446, 0.026063116267323494, -0.043919216841459274, -0.05536525696516037, 0.08481068909168243, 0.014420896768569946, 0.07007467746734619, 0.021784480661153793, -0.012911036610603333, 0.03450827673077583, 0.021854162216186523, 0.030101768672466278, 0.01184773538261652, 0.027006028220057487, -0.04639501869678497, 0.034715767949819565, 0.009900175966322422, 0.045280903577804565, -0.061969656497240067, 0.0971246212720871, 0.0422128364443779, -0.08211822062730789, 0.014376610517501831, -0.07902583479881287, 0.07306886464357376, -0.01181790605187416, -0.019975727424025536, -0.004956807941198349, 0.058207917958498, -0.10021638870239258, 0.07758073508739471, 0.06602124124765396, 0.002167316386476159, -0.04280916601419449, -0.05917195975780487, -0.04011683538556099, 0.002226149896159768, 0.0017632072558626533, -0.04285141080617905, -0.20323579013347626, 0.10911954194307327, 0.01906273141503334, -0.038214150816202164, -0.03147292137145996, 0.13170239329338074, 0.011698627844452858, 0.002154615009203553, -0.017957815900444984, 0.011560717597603798, -0.0023724455386400223, -0.08150267601013184, 0.0245195459574461, 0.076241135597229, 0.0026093246415257454, 0.021508580073714256, 0.0018167603993788362, 0.03392835333943367, 0.04611581563949585, -0.025750143453478813, -0.015551247633993626, 0.0614578053355217, -0.07111469656229019, -0.018467212095856667, -0.004056852776557207, -0.0022831305395811796, -0.035171687602996826, -0.01804150454699993, 0.023377707228064537, -0.0070021627470850945, -0.005218281876295805, 0.029740724712610245, 0.01985073648393154, -0.01694958657026291, -0.009711920283734798, -0.015104053542017937, 0.00008628125215182081, 0.0319940485060215, 0.10200212895870209, 0.051218949258327484, 0.06401710957288742, -0.031017731875181198, -0.07983429729938507, 0.11017414927482605, -0.01046266220510006, -0.12005754560232162, 0.024279512465000153, 0.002109365537762642, 0.04316699132323265, 0.00724227586761117, 0.004134643357247114, -0.030045902356505394, -0.04904695600271225, -0.0073686870746314526, -0.023708131164312363, -0.02384175918996334, -0.002228489378467202, -0.07480219006538391, 0.004818678367882967, 0.008365132845938206, 0.08628453314304352, -0.09292314946651459, -0.009248987771570683, -0.0033885089214891195, -0.016274629160761833, -0.023785043507814407, -0.020221395418047905, 0.08479798585176468, -0.028471769765019417, 0.07011411339044571, 0.030042055994272232, 0.004629965405911207, -0.018169354647397995, 0.005511910188943148, 0.034953780472278595, 0.10991846770048141, 0.06062386929988861, 0.0015177654568105936, 0.004554005805402994, 0.048985496163368225, -0.03250281140208244, 0.00667069386690855, 0.03844154626131058, 0.001649777521379292, 0.031630244106054306, 0.048697102814912796, 0.052421849220991135, -0.01665961928665638, -0.05210533365607262, -0.0609237439930439, -0.041472937911748886, -0.09600960463285446, 0.0356590561568737, 0.008943064138293266, 0.0012660921784117818, 0.060783751308918, -0.049275513738393784, 0.025016959756612778, -0.009703349322080612, -0.011160851456224918, -0.07567156851291656, 0.043319642543792725, 0.021537896245718002, 0.01811925880610943, -0.0983203873038292, 0.023932110518217087, 0.0006355803925544024, -0.09173285961151123, -0.0025839016307145357, 0.053148526698350906, 0.003008016850799322, -0.04054617881774902, -0.035367563366889954, 0.036193955689668655, 0.017553040757775307, 0.02878093346953392, -0.014019696973264217, 0.0048507582396268845, 0.025956420227885246, -0.023829394951462746, 0.03058701381087303, -0.021672448143363, 0.051298197358846664, 0.018993495032191277, 0.030980359762907028, -0.030392777174711227, 0.0773218497633934, -0.04626791924238205, 0.03094049170613289, 0.021425757557153702, 0.0069192443042993546, -0.022775517776608467, -0.04532162845134735, -0.03519464656710625, 0.006769018713384867, 0.12158247083425522, -0.03545791283249855, 0.04510482773184776, 0.020908042788505554, -0.04986018314957619, 0.02969418838620186, -0.0191330723464489, 0.028434230014681816, -0.012259932234883308, -0.011823133565485477, -0.05804210156202316, 0.04328005388379097, 0.0020652012899518013, 0.027940062806010246, -0.04522224888205528, 0.03017531894147396, 0.06679737567901611, 0.024705447256565094, -0.00019087226246483624, 0.030219625681638718, -0.027924295514822006, 0.052243903279304504, -0.055712487548589706, 0.0451565645635128, 0.011857792735099792, -0.03707275167107582, -0.04720282182097435, -0.013479682616889477, 0.020342068746685982, -0.0528285838663578, -0.10663258284330368, -0.009440567344427109, -0.08745282143354416, -0.014112652279436588, -0.049053553491830826, -0.026401203125715256, 0.042844053357839584, 0.004028573632240295, -0.008702672086656094, 0.15472723543643951, -0.002851412631571293, 0.01443517580628395, -0.0369897298514843, -0.014911467209458351, -0.018002977594733238, 0.06868070363998413, 0.03833135962486267, 0.03104829043149948, -0.04697417467832565, -0.023632243275642395, -0.01901792548596859, -0.011633927002549171, -0.008991289883852005, -0.033164314925670624, 0.0004583470872603357, 0.003125790972262621, 0.021292921155691147, -0.008529639802873135, -0.028999462723731995, -0.012745650485157967, -0.011886755004525185, -0.04998162388801575, 0.0533829890191555, -0.025342242792248726, -0.02733769826591015, 0.12772227823734283, -0.022753555327653885, -0.00014091961202211678, -0.01809523068368435, -0.013085590675473213, 0.02786514349281788, 0.010272492654621601, -0.06022733449935913, 0.02002001740038395, 0.017583182081580162, 0.020111510530114174, 0.011332087218761444, -0.011548394337296486, 0.05852749943733215, -0.01533296424895525, -0.03391776233911514, -0.006457590963691473, -0.06111981347203255, 0.006740209646522999, 0.005540704354643822, 0.003609677776694298, -0.024271544069051743, -0.01642593927681446, -0.013834301382303238, 0.03783267363905907, -0.02612820453941822, 0.03899889066815376, -0.004162271041423082, -0.0136328786611557, 0.02934889681637287, 0.021837109699845314, 0.041939958930015564, -0.008575348183512688, -0.035192083567380905, -0.013459921814501286, -0.05369573086500168, 0.019147010520100594, 0.0022499263286590576, -0.0010498178889974952, -0.021905433386564255, 0.0036943876184523106, -0.03060707449913025, 0.007060287985950708, 0.019697174429893494, 0.01481060404330492, 0.020330760627985, 0.0042953710071742535, -0.024631546810269356, -0.010424470528960228, 0.03662896901369095, 0.009434991516172886, 0.03149319812655449, -0.03838721290230751, 0.048604078590869904, -0.024219825863838196, 0.021351005882024765, -0.03871934860944748, -0.020364264026284218, -0.06924613565206528, 0.049214113503694534, 0.022251447662711143, 0.004313227254897356, -0.10345049202442169, 0.014666968025267124, 0.006523295305669308, -0.011371629312634468, -0.002534742932766676, -0.04478108882904053, 0.06441692262887955, -0.000271926837740466, -0.005695783067494631, 0.03228536993265152, -0.014223024249076843, -0.004508154466748238, -0.02188120037317276, -0.0027747892308980227, -0.015461934730410576, -0.030038652941584587, -0.015028124675154686, -0.015322304330766201, 0.0675702691078186, 0.04599727690219879, -0.035698726773262024, 0.027412420138716698, -0.0016739941202104092, -0.012628243304789066, -0.041443683207035065, -0.016426656395196915, 0.018763894215226173, 0.03863814100623131, 0.009905503131449223, -0.004026040900498629, 0.018630193546414375, -0.03478270024061203, -0.06147254258394241, 0.014857364818453789, -0.012882046401500702, -0.0069999685510993, -0.013872806914150715, -0.015794409438967705, 0.020107397809624672, 0.02661760523915291, -0.04257800802588463, 0.017617151141166687, 0.01867188885807991, -0.013313292525708675, -0.0011110231280326843, 0.011054148897528648, -0.01568613573908806, 0.009343261830508709, -0.01659994386136532, -0.01757609285414219, -0.04092391952872276, -0.021044254302978516, -0.0388643853366375, 0.025488976389169693, -0.01021208893507719, -0.000782245013397187, 0.03520363196730614, 0.007420828565955162, 0.01961216703057289, 0.002349538030102849, -0.03687530383467674, 0.024845721200108528, 0.017642352730035782, -0.02144174836575985, -0.02626701444387436, 0.03461526706814766, 0.025371430441737175, 0.057280655950307846, 0.030708204954862595, 0.015173796564340591, -0.012151972390711308, 0.049905117601156235, -0.009619005024433136, 0.013380853459239006, -0.031533095985651016, 0.016969406977295876, -0.00351323327049613, -0.0021502936724573374, 0.07301467657089233, 0.008001990616321564, 0.002883185399696231, -0.026583926752209663, -0.05044835805892944, -0.012135696597397327, 0.028975827619433403, 0.017100991681218147, 0.007778586819767952, -0.03197049722075462, 0.013975140638649464, 0.011403975076973438, 0.02497321180999279, -0.0460105799138546, -0.01893492601811886, -0.00620663957670331, -0.016327520832419395, 0.0053076730109751225, 0.03231078013777733, -0.0037345699965953827, -0.02162366919219494, 0.004732298199087381, 0.07502039521932602, -0.010531065985560417, -0.018872255459427834, 0.020626172423362732, 0.03639019653201103, 0.03793266415596008, -0.047304917126894, -0.013913728296756744, 0.02386210486292839, -0.03850293532013893, 0.008073276840150356, -0.013132257387042046, -0.0003312686749268323, 0.0033605233766138554, 0.03306466341018677, 0.03599212318658829, -0.011522726155817509, -0.0035195141099393368, -0.01460687443614006, 0.05877171829342842, -0.014687374234199524, 0.025674128904938698, -0.04360061138868332, -0.008075186982750893, 0.004759144503623247, 0.01444395910948515, 0.056145377457141876, 0.034091755747795105, -0.05241720750927925, -0.01831452175974846, 0.02006557211279869, -0.02559044025838375, -0.005195514298975468, 0.01195827778428793, 0.03256762772798538, -0.01818295754492283, 0.012456991709768772, -0.0017799970228224993, 0.02222931757569313, -0.028067275881767273, -0.036090366542339325, -0.014947409741580486, 0.01798355206847191, -0.01648549549281597, 0.004481012001633644, -0.011259492486715317, -0.07122188806533813, -0.025280354544520378, 0.0016136752674356103, -0.0092229088768363, 0.026664545759558678, 0.038006335496902466, -0.03948703780770302, -0.02291117236018181, 0.03849206492304802, -0.04547613486647606, -0.003722741734236479, -0.002151070861145854, -0.009936273097991943, 0.029771126806735992, 0.010574501007795334, 0.0017836716724559665, -0.018496818840503693, 0.007369789760559797, 0.011336734518408775, 0.004354363307356834, -0.03124028444290161, -0.08269698917865753, -0.000992279383353889, -0.007033818867057562, -0.045528486371040344, 0.028029661625623703, 0.031953148543834686, -0.007506880909204483, 0.006233065389096737, 0.041018448770046234, -0.0008134809322655201, -0.0012362300185486674, -0.016424236819148064, 0.013354153372347355, -0.04664383828639984, -0.0031780877616256475, -0.01905740052461624, 0.037872426211833954, -0.007344044279307127, 0.05759718269109726, 0.0007277994882315397, 0.02385619282722473, -0.015113621018826962, 0.01690041832625866, -0.007232001516968012, -0.023411503061652184, 0.005536019802093506, -0.04398706927895546, 0.013992443680763245, -0.004668628331273794, 0.034844882786273956, -0.002700359094887972, -0.05924445390701294, -0.01132891047745943, -0.006614759098738432, 0.024768391624093056, -0.018690412864089012, 0.0024901011493057013, 0.06324814260005951, 0.025024211034178734, -0.021876968443393707, -0.035816632211208344, 0.03161514922976494, -0.027116842567920685, 0.022649327293038368, -0.03446078300476074, -0.015081606805324554, 0.03574084863066673, 0.00812285766005516, -0.008987689390778542, -0.04478006064891815, 0.010991496033966541, 0.0016879407921805978, 0.03698087856173515, -0.018947850912809372, -0.00004865925438934937, -0.02849637344479561, 0.016324127092957497, 0.04207167774438858, -0.049226224422454834, 0.017767298966646194, -0.018596725538372993, 0.015993529930710793, 0.03167637437582016, 0.03495769947767258, -0.012919044122099876, 0.005192597862333059, 0.07572060823440552, 0.023644782602787018, -0.00232333573512733, -0.06557632982730865, 0.023646771907806396, 0.029112238436937332, -0.050830721855163574, -0.005569873843342066, -0.03302383795380592, -0.020778914913535118, -0.01815752685070038, -0.01229525450617075, 0.0132254334166646, 0.04334636032581329, -0.007313841488212347, -0.020251385867595673, 0.014898983761668205, 0.0015791915357112885, 0.04416458681225777, -0.005143460817635059, 0.02884838730096817, 0.015360144898295403, 0.04966866597533226, 0.024429792538285255, -0.015087989158928394, 0.026056846603751183, 0.030150244012475014, -0.01681990921497345, -0.07379280030727386, 0.00886517483741045, 0.05706816539168358, -0.008455918170511723, 0.019955415278673172, 0.011713359504938126, -0.03676588833332062, -0.02319733053445816, -0.00042428862070664763, 0.030294276773929596, 0.05054366588592529, -0.025309080258011818, -0.003106899792328477, 0.0189235620200634, -0.009464742615818977, -0.011078801937401295, 0.07348934561014175, -0.05747460573911667, 0.031538695096969604, 0.00870289746671915, 0.03751514479517937, 0.03156502917408943, 0.016251850873231888, 0.0059038070030510426, 0.002164542907848954, 0.057110827416181564, 0.023333633318543434, 0.030018258839845657, 0.03629584610462189, -0.01728869415819645, 0.012350834906101227, -0.06000132113695145, -0.03675215318799019, -0.01895003765821457, 0.004687026608735323, 0.039404675364494324, 0.0045890226028859615, 0.02078268676996231, -0.02937374636530876, 0.05478570982813835, 0.0006429851055145264, 0.03754687309265137, 0.006447124294936657, 0.036321766674518585, 0.0662972554564476, 0.000017898310034070164, 0.017778553068637848, 0.007655811961740255, -0.007746695540845394, -0.03227612376213074, 0.009393448010087013, 0.004959385842084885, 0.04043429344892502, -0.022045962512493134, 0.008165239356458187, -0.008689723908901215, -0.026317130774259567, -0.014331703074276447, 0.020602194592356682, -0.008882562629878521, -0.0064630513079464436, -0.021506398916244507, 0.010468730702996254, -0.010357854887843132, -0.006556054577231407, -0.0007202227134257555, 0.002963151317089796, -0.026082800701260567, -0.011007115244865417, -0.03819843381643295, 0.03833392634987831, -0.00039103670860640705, -0.03520900383591652, 0.004287803079932928, -0.014964042231440544, 0.04202261567115784, 0.03420177847146988, -0.0277970340102911, -0.007771673612296581, -0.02510434202849865, -0.015089597553014755, 0.0017510659527033567, 0.026890313252806664, -0.016258638352155685, -0.022486232221126556, -0.014354568906128407, 0.0034289779141545296, -0.02862822823226452, 0.043127674609422684, 0.011344220489263535, 0.030540604144334793, -0.04463452473282814, -0.037225279957056046, -0.016598805785179138, -0.0055403681471943855, 0.02274187281727791, -0.03531961515545845, -0.01687111333012581, -0.027433738112449646, 0.0005036517977714539, -0.0038758516311645508, -0.011678566224873066, -0.013367596082389355, 0.013611825183033943, 0.05148385837674141, 0.019793959334492683, -0.012819772586226463, 0.012726720422506332, -0.01711067371070385, 0.004781223833560944, 0.046759530901908875, -0.03187410905957222, 0.0010931154247373343, 0.004824348259717226, 0.007937430404126644, 0.052028488367795944, -0.01745958998799324, -0.010880951769649982, -0.015036042779684067, 0.020527049899101257, 0.024768633767962456, 0.016225973144173622, 0.03433111310005188, -0.02870423160493374, 0.026042679324746132, -0.04100885987281799, -0.0018513246905058622, -0.02708156779408455, -0.03343330696225166, -0.02628316543996334, -0.03353002667427063, -0.034073229879140854, 0.0013843473279848695, -0.05393623560667038, 0.03746071085333824, -0.07721522450447083, 0.016320891678333282, -0.026669491082429886, 0.021429715678095818, -0.02817310392856598, 0.025154128670692444, 0.03416161984205246, 0.03761853277683258, 0.022816454991698265, 0.012553077191114426, -0.03870869800448418, -0.02018754743039608, -0.0326969251036644, 0.02576824650168419, 0.03277937322854996, 0.04018086567521095, -0.037266675382852554, -0.0114429397508502, 0.04382551088929176, -0.0068566626869142056, -0.03123779408633709, 0.01976511813700199, 0.03350035473704338, -0.04892950505018234, -0.040163785219192505, -0.012215321883559227, 0.03943943604826927, -0.0035003921948373318, 0.044836483895778656, 0.011458953842520714, 0.0033248632680624723, 0.022421658039093018, 0.011861725710332394, -0.07925524562597275, -0.007788713555783033, -0.04036007076501846, -0.01125472690910101, 0.012913073413074017, 0.023598328232765198, 0.04250724986195564, -0.005802142899483442, 0.001938100322149694, 0.006115387659519911, -0.003979142755270004, -0.03906060382723808, -0.05584114417433739, -0.012758505530655384, 0.03648808225989342, -0.05554746091365814, 0.0004185356665402651, 0.04150238633155823, -0.01551322266459465, -0.050403136759996414, 0.008565370924770832, 0.009387817233800888, 0.02714051492512226, 0.007747262716293335, 0.045506566762924194, -0.02349792793393135, 0.014494727365672588, 0.038992997258901596, -0.002145407721400261, 0.006757428869605064, -0.02318316139280796 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
4. Analyzing Tweets with Sentiment Analysis and Python In this last section, you'll take what you have learned so far in this post and put it into practice with a fun little project: analyzing tweets about NFTs with sentiment analysis! First, you'll use Tweepy, an easy-to-use Python library for getting tweets mentioning #NFTs using the Twitter API. Then, you will use a sentiment analysis model from the 🤗Hub to analyze these tweets. Finally, you will create some visualizations to explore the results and find some interesting insights. You can use this notebook to follow this tutorial. Let’s jump into it!
[ 0.06805966049432755, 0.002326175570487976, 0.04461849480867386, -0.0439433678984642, 0.07458483427762985, 0.061366960406303406, -0.01396200992166996, 0.0919932872056961, -0.014922655187547207, -0.04744664579629898, -0.02868966944515705, 0.04299243912100792, 0.02186605893075466, 0.07002632319927216, 0.030164359137415886, -0.03119870461523533, 0.04545210674405098, 0.008532299660146236, 0.10825813561677933, -0.004133282229304314, -0.02760031446814537, -0.010319315828382969, 0.02088676206767559, -0.04075951501727104, 0.026958826929330826, -0.07473430037498474, 0.05989382416009903, 0.04683423042297363, -0.07900118827819824, -0.004929289221763611, -0.09773840755224228, 0.07904694974422455, -0.02898392453789711, -0.059177011251449585, 0.02231757901608944, 0.017666134983301163, -0.14411337673664093, 0.08597146719694138, 0.0716647133231163, 0.005270455963909626, -0.01703990437090397, -0.10267741978168488, -0.03379674255847931, 0.0354282483458519, 0.003922795411199331, -0.03670806810259819, -0.1451522707939148, 0.09055038541555405, 0.004020014777779579, -0.061573468148708344, -0.0001892284635687247, 0.1639995574951172, -0.058525651693344116, 0.022462841123342514, -0.026895882561802864, 0.05210772156715393, 0.0034290386829525232, -0.04923703894019127, 0.009379813447594643, 0.01443429198116064, 0.05057976767420769, -0.015855684876441956, 0.009708001278340816, 0.0164016280323267, 0.04305208846926689, -0.012941860593855381, -0.024023499339818954, 0.10030315816402435, -0.06223095953464508, -0.0003740610263776034, 0.037232041358947754, -0.01422965805977583, -0.06811179220676422, -0.0320303738117218, 0.005971074104309082, 0.021149175241589546, 0.015693996101617813, 0.05092979222536087, -0.026965318247675896, 0.04182339832186699, -0.0007500164210796356, 0.010028584860265255, 0.06465042382478714, 0.053426407277584076, 0.117080457508564, 0.009081377647817135, 0.0500643327832222, 0.014658447355031967, -0.05253966897726059, 0.05212511494755745, 0.01870701275765896, -0.07216610759496689, 0.024875126779079437, -0.002408789237961173, 0.04976730793714523, -0.0010434607975184917, 0.00803385116159916, 0.008524513803422451, -0.01285038236528635, -0.005256073549389839, -0.0013799379812553525, -0.05577768385410309, 0.012838546186685562, -0.08612872660160065, -0.006690436974167824, 0.06025752052664757, 0.07263648509979248, -0.0381021723151207, -0.04488178342580795, -0.03451485186815262, -0.04777560010552406, 0.0465291403234005, -0.03367298096418381, 0.0758434608578682, -0.015218212269246578, 0.08879134058952332, 0.03597118705511093, 0.021933963522315025, -0.03603896498680115, 0.06418405473232269, 0.008464979007840157, 0.08797658979892731, 0.060640186071395874, -0.013218574225902557, -0.0001229989720741287, 0.035044729709625244, 0.014488122425973415, 0.03471135348081589, -0.014174832962453365, -0.01119374018162489, 0.02396055869758129, 0.04113706201314926, 0.06174757704138756, -0.0022401863243430853, -0.02695242501795292, -0.08211211115121841, -0.07387188822031021, -0.07614253461360931, 0.05482899025082588, -0.011177485808730125, 0.01418698113411665, 0.009355652146041393, -0.06412792950868607, 0.07684329152107239, 0.004646830726414919, 0.01718919724225998, -0.06963226944208145, 0.017085762694478035, -0.0074965814128518105, -0.012732581235468388, -0.10468485206365585, -0.005994421895593405, 0.025862693786621094, -0.03491830453276634, -0.02272035926580429, 0.03410891070961952, 0.019749954342842102, -0.03290119022130966, -0.023502422496676445, 0.015665963292121887, 0.03998542204499245, -0.004461225587874651, -0.00999630056321621, -0.025354688987135887, 0.05193889141082764, -0.014566238038241863, 0.02669919840991497, 0.03585881367325783, -0.0025108144618570805, 0.05458012595772743, 0.011113665997982025, -0.005290196277201176, 0.05733061209321022, -0.028869910165667534, 0.04868418723344803, 0.04094879701733589, 0.0017369469860568643, -0.05819352716207504, -0.002460240386426449, 0.018358783796429634, -0.027006149291992188, 0.04019242525100708, -0.002591532887890935, 0.013070209883153439, -0.014217231422662735, -0.06544134020805359, 0.026920326054096222, -0.030721820890903473, 0.04901638627052307, -0.045092664659023285, -0.026631420478224754, -0.031027229502797127, 0.011334984563291073, 0.0011629005894064903, 0.037640027701854706, -0.017032532021403313, 0.0387406200170517, 0.056832220405340195, 0.008931539952754974, -0.009103271178901196, 0.01815960742533207, -0.04607672244310379, 0.033222053200006485, -0.03708566725254059, 0.015685545280575752, 0.004456722643226385, 0.0014447083231061697, -0.022180922329425812, 0.0019058143952861428, 0.027790937572717667, -0.01003922801464796, -0.07695531100034714, 0.03962843865156174, -0.06882414221763611, 0.02184213511645794, -0.00946152675896883, -0.02081367000937462, 0.09187428653240204, -0.01969563402235508, -0.017418764531612396, 0.16914598643779755, -0.01270946767181158, 0.06439387798309326, -0.034991152584552765, -0.024100013077259064, 0.02098911814391613, 0.05360303074121475, 0.027080079540610313, 0.06621052324771881, -0.04894647002220154, -0.0623023621737957, 0.014186332933604717, -0.025106707587838173, -0.03611329197883606, -0.027140479534864426, 0.0005015188362449408, 0.04108326882123947, -0.012772896327078342, 0.014797573909163475, -0.05742223188281059, 0.009011134505271912, -0.022418659180402756, -0.0537559948861599, 0.0748046338558197, -0.01806148886680603, 0.0007241898565553129, 0.10263026505708694, -0.05087822303175926, -0.06689666211605072, 0.026935720816254616, -0.013152671977877617, 0.05591895803809166, 0.002660252619534731, 0.0004594582424033433, -0.004336207173764706, 0.01650075428187847, 0.043675072491168976, 0.01171401422470808, -0.0038279539439827204, 0.05043044313788414, -0.011201664805412292, -0.0076047214679419994, 0.017288710922002792, -0.054271161556243896, -0.01984455995261669, -0.0005252286791801453, -0.015014393255114555, -0.02871716022491455, -0.0031811476219445467, 0.021076180040836334, 0.03387695550918579, -0.03711286187171936, 0.023577852174639702, 0.011175704188644886, -0.008708241395652294, -0.011774925515055656, 0.01270939502865076, 0.01945124752819538, -0.021499671041965485, -0.03220059722661972, -0.01317098643630743, -0.04596211761236191, 0.03776787221431732, -0.0011023568222299218, 0.03121691383421421, -0.056503452360630035, -0.03366212546825409, -0.014271989464759827, -0.0010548096615821123, 0.017657676711678505, -0.0031684639398008585, 0.0030408750753849745, 0.026579879224300385, 0.009187595918774605, 0.03052375465631485, 0.01287851482629776, -0.007566752377897501, 0.07441498339176178, -0.04246138408780098, 0.07038213312625885, 0.002402331680059433, -0.008581556379795074, -0.024651631712913513, -0.026283826678991318, -0.044511985033750534, 0.03191822022199631, 0.025192733854055405, 0.021006956696510315, -0.09746835380792618, 0.003228089539334178, 0.011206869967281818, 0.0036065292079001665, 0.015048054046928883, -0.013838240876793861, 0.07433172315359116, 0.008986623957753181, -0.008025850169360638, -0.01298478338867426, -0.004816344473510981, -0.007068954408168793, -0.013500569388270378, 0.006415313575416803, 0.012451102957129478, -0.006495482753962278, -0.0024353626649826765, 0.03192684426903725, 0.056293606758117676, 0.054245416074991226, -0.06709025055170059, 0.0665828064084053, -0.011071570217609406, -0.027320731431245804, -0.050565388053655624, -0.021447962149977684, 0.0217878557741642, -0.0034528772812336683, 0.0008402870735153556, 0.000282604421954602, 0.02132052183151245, -0.013369360007345676, -0.045764774084091187, 0.0023060552775859833, -0.05193866044282913, 0.00019357509154360741, 0.021137969568371773, -0.03819594532251358, 0.024710630998015404, 0.03892390802502632, -0.036595020443201065, 0.050488054752349854, 0.012218405492603779, -0.015053659677505493, 0.02402622252702713, -0.013041483238339424, -0.06261152774095535, -0.0010896050371229649, -0.012230905704200268, -0.02809152938425541, -0.00602128216996789, -0.028723595663905144, -0.04444992169737816, 0.018761208280920982, 0.011241879314184189, 0.015095601789653301, 0.018159108236432076, 0.01882302016019821, 0.03065158985555172, -0.0036499034613370895, -0.04018280655145645, 0.018414434045553207, 0.037524573504924774, -0.008231294341385365, -0.0603833831846714, 0.006661718711256981, 0.023874646052718163, 0.028311284258961678, 0.03298754245042801, -0.0076996502466499805, -0.009367469698190689, 0.031739674508571625, -0.015117814764380455, 0.015216590836644173, -0.0382070429623127, 0.019155114889144897, -0.028980065137147903, 0.00749628571793437, 0.05992104858160019, 0.03425261378288269, -0.009347711689770222, -0.03482965752482414, -0.030789723619818687, -0.016128091141581535, 0.03202611953020096, 0.0015340415993705392, 0.002756195841357112, -0.021005522459745407, -0.0003223296662326902, 0.06401436775922775, 0.03258073329925537, 0.0043134200386703014, 0.0005088121979497373, 0.01994917541742325, -0.04407774657011032, 0.010807645507156849, 0.05123685672879219, -0.00635782815515995, -0.0004249111225362867, 0.017526373267173767, 0.07350955903530121, -0.010598952881991863, -0.03787493705749512, -0.0013989470899105072, 0.005752237048000097, 0.009863121435046196, -0.050937335938215256, -0.0005633268738165498, 0.04080565646290779, -0.037389807403087616, -0.0047844345681369305, -0.010080141015350819, 0.007519714999943972, -0.008716236799955368, 0.04291212558746338, 0.035311322659254074, -0.018589630722999573, 0.01022427435964346, -0.008290919475257397, 0.014446450397372246, 0.0075925495475530624, 0.009429373778402805, -0.03314661607146263, -0.0037557410541921854, 0.005789863411337137, -0.01256143394857645, 0.030127113685011864, -0.0015310733579099178, -0.09005555510520935, -0.017782380804419518, 0.02676868624985218, -0.01390165090560913, -0.047270551323890686, -0.004922026302665472, 0.03841463848948479, 0.006287900265306234, -0.011241777800023556, -0.027452019974589348, 0.029933059588074684, -0.063587486743927, -0.026738304644823074, -0.036902040243148804, 0.007984086871147156, -0.017578810453414917, -0.023597175255417824, -0.008344179950654507, -0.052204277366399765, -0.007452515419572592, 0.009446163661777973, 0.004889223724603653, -0.003749680705368519, 0.012036287225782871, -0.01921718381345272, -0.03139406442642212, 0.010313565842807293, -0.012500058859586716, 0.003959706984460354, 0.007080742623656988, -0.015682941302657127, 0.04551519826054573, 0.03531750664114952, -0.03037220984697342, -0.00925709493458271, 0.004074317868798971, -0.026298275217413902, -0.05119208246469498, -0.033839643001556396, -0.05646485090255737, 0.004245062358677387, 0.01773562654852867, -0.008600307628512383, 0.04895870387554169, 0.03233449161052704, -0.0005469174357131124, 0.007999499328434467, 0.029945969581604004, 0.013933862559497356, 0.00801924429833889, -0.04128110781311989, -0.014663460664451122, -0.049926843494176865, -0.029931845143437386, -0.02701082080602646, -0.022983452305197716, -0.0030380229000002146, 0.05056687816977501, 0.04988858103752136, 0.04090351238846779, -0.009655207395553589, 0.0393572673201561, -0.0379713736474514, -0.00873705092817545, -0.030800074338912964, -0.04828357696533203, 0.008789636194705963, -0.008348727598786354, -0.0036021177656948566, 0.0033723656088113785, -0.0327756367623806, -0.04127717390656471, 0.03778599202632904, 0.02226911298930645, -0.019568011164665222, -0.009298649616539478, 0.01081397756934166, 0.05059156194329262, -0.027258189395070076, -0.06371289491653442, 0.04698373004794121, -0.03201504424214363, -0.0015630393754690886, -0.03139295428991318, -0.021724937483668327, -0.021078499034047127, 0.00036876791273243725, -0.01119596790522337, 0.0016302047297358513, -0.0008431337191723287, -0.0009495753329247236, 0.03188405930995941, 0.016627050936222076, -0.010847065597772598, -0.02756124921143055, 0.018866902217268944, 0.052152760326862335, -0.023434707894921303, -0.0005246312357485294, 0.00973240565508604, -0.015083682723343372, -0.0018919823924079537, 0.036419808864593506, -0.03860434889793396, 0.044397152960300446, 0.0634855255484581, -0.0011445848504081368, -0.01981932669878006, -0.05293687433004379, 0.04821496829390526, 0.029463602229952812, -0.014998285099864006, -0.01282113790512085, -0.03582099825143814, -0.03835858404636383, -0.025950051844120026, -0.02869807742536068, 0.0009420537389814854, 0.053581371903419495, -0.016949554905295372, -0.014590063132345676, 0.0022686244919896126, -0.015194825828075409, 0.03933198004961014, 0.0029574704822152853, -0.004531291779130697, 0.044981684535741806, 0.0443531759083271, 0.019824698567390442, -0.03644189611077309, 0.025477994233369827, -0.010848134756088257, -0.0124078169465065, -0.07511429488658905, 0.012268031015992165, 0.01280889566987753, -0.009487997740507126, 0.0035950206220149994, 0.04440070688724518, -0.046721648424863815, -0.007589004468172789, -0.004196493420749903, 0.03529316559433937, 0.04375560209155083, -0.03054255247116089, 0.010156157426536083, -0.01298126857727766, 0.009182662703096867, -0.0037084303330630064, 0.09122421592473984, -0.05458511412143707, 0.02031497284770012, -0.0012436241377145052, 0.026681983843445778, 0.025427239015698433, 0.020514292642474174, 0.02887287735939026, 0.006705692503601313, 0.03897259384393692, 0.03681531548500061, 0.020333552733063698, -0.00047586075379513204, -0.018672561272978783, -0.014944357797503471, -0.05540534108877182, -0.0654740035533905, -0.002457514638081193, 0.014445354230701923, 0.020056596025824547, -0.035408828407526016, -0.0021157879382371902, -0.027582962065935135, 0.0617411769926548, -0.016953755170106888, 0.044467292726039886, 0.0021133318077772856, 0.03432941064238548, 0.019871443510055542, 0.012241566553711891, 0.013478409498929977, 0.019598299637436867, -0.00582986231893301, -0.025893663987517357, 0.004664135631173849, 0.020035283640027046, 0.0535932257771492, -0.0002524896990507841, 0.037264782935380936, 0.02287193015217781, -0.03840196505188942, 0.009004323743283749, -0.01324591413140297, -0.012242489494383335, -0.015084724873304367, 0.0017953604692593217, -0.005653765518218279, -0.016833756119012833, -0.027078967541456223, 0.007250654976814985, -0.015840552747249603, 0.027100831270217896, -0.021491415798664093, -0.02687802165746689, 0.029477274045348167, -0.01486146915704012, -0.01722794584929943, 0.0025504152290523052, 0.01096591167151928, 0.010225418955087662, 0.015590577386319637, -0.04623866081237793, 0.006475789938122034, -0.019548838958144188, -0.011450017802417278, 0.005104901269078255, 0.007156313396990299, -0.029550913721323013, -0.02792814001441002, 0.0005564602906815708, -0.0023569876793771982, -0.0500195138156414, 0.02375742606818676, 0.02188071422278881, 0.03138585016131401, -0.026024390012025833, -0.017018673941493034, -0.015100432559847832, -0.02748870849609375, -0.011007068678736687, -0.00885049905627966, -0.010404741391539574, -0.02746634930372238, -0.005084178410470486, 0.017832886427640915, -0.008804809302091599, -0.02126101776957512, -0.009844507090747356, 0.030615586787462234, 0.012615951709449291, -0.022281240671873093, -0.008564874529838562, 0.023948343470692635, 0.02548222616314888, 0.03733496367931366, -0.06236864998936653, 0.01864999532699585, -0.014976640231907368, 0.02728305011987686, 0.031003400683403015, -0.008453079499304295, -0.013508285395801067, 0.0094303535297513, 0.01029269490391016, 0.014654516242444515, -0.013853567652404308, 0.010453748516738415, 0.009927845560014248, 0.010518941096961498, -0.03410494327545166, 0.02264678105711937, -0.041783031076192856, -0.006908740382641554, -0.04342515021562576, -0.02679797261953354, -0.03190774843096733, 0.03906453028321266, -0.02903095632791519, 0.013281422667205334, -0.0726165622472763, 0.019057780504226685, -0.027910659089684486, -0.0008395590703003109, 0.009637524373829365, 0.003542673774063587, 0.02574128471314907, 0.004178570117801428, -0.006960622500628233, 0.01880381628870964, -0.0407329797744751, -0.030250830575823784, -0.03864140063524246, 0.022493626922369003, 0.015648934990167618, 0.05368052423000336, -0.014784710481762886, -0.023037485778331757, 0.02240843139588833, -0.032399680465459824, 0.010327701456844807, 0.004683199804276228, 0.04502663016319275, -0.03484872356057167, -0.03662841022014618, -0.004618725273758173, -0.01851351000368595, -0.016836322844028473, 0.03387783467769623, 0.01856186054646969, -0.003916154615581036, 0.004195287823677063, 0.024281248450279236, -0.0606134757399559, -0.0051540774293243885, 0.0051824795082211494, -0.025427095592021942, 0.02986929938197136, 0.0011604988249018788, 0.025806356221437454, -0.005247915163636208, 0.010909792967140675, 0.0015243446687236428, 0.026132581755518913, -0.021961254999041557, -0.04919946938753128, -0.004955172073096037, 0.04243973270058632, -0.03820270299911499, -0.03275648504495621, 0.03083922527730465, -0.03139215335249901, -0.05705701932311058, 0.012315831147134304, 0.043280214071273804, 0.02049701102077961, 0.018338164314627647, 0.018315324559807777, -0.023026911541819572, 0.052264921367168427, 0.004825291223824024, 0.014340455643832684, -0.004301498644053936, -0.015225504525005817 ]
Getting Started with Sentiment Analysis using Python
FedericoPascual
February 2, 2022
sentiment-analysis-python
sentiment-analysis, nlp, guide
https://huggingface.co/blog/sentiment-analysis-python
3. Building Your Own Sentiment Analysis Model Using pre-trained models publicly available on the Hub is a great way to get started right away with sentiment analysis. These models use deep learning architectures such as transformers that achieve state-of-the-art performance on sentiment analysis and other machine learning tasks. However, you can fine-tune a model with your own data to further improve the sentiment analysis results and get an extra boost of accuracy in your particular use case. In this section, we'll go over two approaches on how to fine-tune a model for sentiment analysis with your own data and criteria. The first approach uses the Trainer API from the 🤗Transformers, an open source library with 50K stars and 1K+ contributors and requires a bit more coding and experience. The second approach is a bit easier and more straightforward, it uses AutoNLP, a tool to automatically train, evaluate and deploy state-of-the-art NLP models without code or ML experience. Let's dive in!
[ 0.055831167846918106, -0.0622062012553215, 0.029679108411073685, 0.01927153952419758, 0.05244175344705582, 0.10127237439155579, 0.0026971492916345596, 0.07186270505189896, 0.031425248831510544, -0.003537822049111128, -0.08224280178546906, 0.09379839897155762, -0.03678591549396515, 0.03773948922753334, 0.04918490722775459, -0.0630062147974968, 0.050708021968603134, 0.010878975503146648, 0.0067255268804728985, 0.007642457261681557, -0.026291536167263985, -0.062184613198041916, 0.03483057767152786, 0.013825491070747375, 0.027329057455062866, -0.050690483301877975, 0.11867372691631317, 0.0176040381193161, -0.06623434275388718, -0.03000960312783718, -0.07718735933303833, 0.02331983856856823, -0.049928490072488785, -0.012715143151581287, -0.013359767384827137, 0.04319778084754944, -0.07108749449253082, 0.05256497114896774, 0.049276772886514664, -0.026314161717891693, -0.05553077161312103, -0.019088320434093475, -0.048305388540029526, 0.05368291959166527, -0.0034042815677821636, -0.045242518186569214, -0.18834735453128815, 0.06912461668252945, -0.001548006315715611, -0.03538210690021515, -0.026853198185563087, 0.1077604815363884, -0.011633187532424927, 0.05915702506899834, -0.029087236151099205, 0.0013631278416141868, 0.01635444350540638, -0.0602717362344265, 0.0023229403886944056, 0.0468137301504612, 0.05106501281261444, 0.009395681321620941, -0.0017634769901633263, -0.0016470245318487287, 0.01705264300107956, -0.01595763862133026, -0.035986755043268204, 0.03982888534665108, -0.07910757511854172, -0.040448032319545746, -0.01210370659828186, -0.023801902309060097, 0.019694749265909195, -0.023846620693802834, -0.009347896091639996, -0.013000058010220528, 0.03801761567592621, 0.02860884740948677, 0.03592405840754509, 0.011186711490154266, 0.0029728494118899107, 0.011664671823382378, 0.014196723699569702, -0.0002952372014988214, 0.08140529692173004, 0.06047515571117401, 0.03852144256234169, 0.0009417985565960407, -0.03565891832113266, 0.053530894219875336, 0.015693971887230873, -0.10174046456813812, 0.045273520052433014, -0.000021008929252275266, 0.06426021456718445, 0.006294091697782278, -0.009725131094455719, 0.0676666647195816, -0.022837406024336815, -0.01489176880568266, -0.02988646738231182, 0.002893130062147975, -0.005022305529564619, -0.056547217071056366, 0.005620721727609634, 0.0342751145362854, 0.058088451623916626, -0.08184893429279327, -0.04286270961165428, 0.020823754370212555, -0.014582213945686817, -0.04454033449292183, -0.021583272144198418, 0.09648721665143967, -0.09115839004516602, 0.02427081950008869, 0.034132666885852814, -0.04465465247631073, -0.0019119175849482417, -0.008253666572272778, 0.002579860622063279, 0.08571073412895203, 0.023888323456048965, 0.019166823476552963, -0.013945591636002064, 0.053379468619823456, 0.021970467641949654, 0.014544511213898659, 0.02271215431392193, -0.019188379868865013, 0.013090909458696842, 0.005916623864322901, 0.024612441658973694, -0.007568232249468565, 0.003667467273771763, -0.05018748715519905, -0.014995998702943325, -0.09140747785568237, 0.038432035595178604, 0.03381187841296196, -0.02232792042195797, 0.0778418555855751, -0.052680209279060364, 0.0150529146194458, 0.06002332642674446, 0.014361703768372536, -0.0422162264585495, 0.055833183228969574, 0.028713656589388847, 0.02876431867480278, -0.09428314119577408, 0.04744311422109604, -0.016189614310860634, -0.09721114486455917, 0.025714732706546783, 0.06867296248674393, -0.01867094449698925, -0.050510223954916, -0.030933737754821777, 0.05088192597031593, 0.0012602112255990505, 0.027310365810990334, -0.03985486179590225, 0.032253485172986984, 0.015069754794239998, -0.049379851669073105, 0.010035540908575058, 0.02945442870259285, 0.04364500939846039, 0.02458002418279648, 0.04351338744163513, -0.023119881749153137, 0.09159345924854279, -0.04098011180758476, 0.025044700130820274, 0.01876828633248806, -0.003732668235898018, 0.03847930580377579, 0.013669757172465324, 0.008365594781935215, 0.0015973066911101341, 0.1034829393029213, -0.011161073110997677, 0.0367019958794117, 0.08817961812019348, -0.04628855735063553, 0.0024440160486847162, -0.07935629040002823, -0.040001723915338516, -0.0545058473944664, -0.018584927543997765, -0.011183612048625946, 0.04781835898756981, 0.03150830790400505, 0.06661028414964676, -0.036365799605846405, 0.017185190692543983, 0.09891973435878754, 0.03473059833049774, 0.014026555232703686, 0.06682012230157852, -0.08298391103744507, 0.034213367849588394, -0.03597811609506607, 0.012591213919222355, -0.03345365449786186, -0.0008883246337063611, 0.016712218523025513, 0.030394313856959343, -0.010395728051662445, -0.02250177599489689, -0.14126332104206085, 0.01349281519651413, -0.04449676349759102, -0.030194120481610298, -0.05582980811595917, -0.01936519145965576, 0.06818059831857681, 0.0006078673177398741, -0.014752749353647232, 0.1989801973104477, -0.00988039281219244, -0.009146247059106827, 0.015836503356695175, -0.04288549721240997, 0.03108205460011959, 0.0508330762386322, 0.029694879427552223, 0.07212796062231064, -0.009770011529326439, -0.02810894511640072, -0.0672815814614296, -0.035194121301174164, -0.03482140600681305, -0.04844421520829201, -0.003920144401490688, 0.059109557420015335, 0.00020859080541413277, 0.017681246623396873, 0.019126299768686295, -0.0010591407772153616, -0.0020606359466910362, -0.053969696164131165, 0.0885816439986229, -0.011349307373166084, 0.037606336176395416, 0.0901309922337532, -0.006582067348062992, -0.019722873345017433, 0.010089999064803123, -0.061191119253635406, 0.04937627911567688, 0.02416885830461979, 0.006657651625573635, -0.003852277295663953, 0.0004027442482765764, 0.03285040706396103, -0.0005795819452032447, -0.009704235009849072, 0.03511154651641846, 0.02313295751810074, -0.05161477252840996, -0.018922079354524612, -0.03519776090979576, 0.021851392462849617, -0.050078801810741425, -0.015585134737193584, -0.009227043949067593, 0.03153642266988754, 0.005017779767513275, -0.000007243611889862223, -0.025203395634889603, 0.017699051648378372, 0.012523280456662178, -0.020369291305541992, 0.052583348006010056, 0.007502833381295204, -0.008232376538217068, -0.011127155274152756, -0.04415234178304672, -0.012019245885312557, -0.054235294461250305, 0.028228970244526863, 0.03100375458598137, 0.02447512373328209, -0.04679940268397331, -0.016995903104543686, -0.02782684750854969, -0.016983527690172195, 0.013343153521418571, -0.0034148404374718666, 0.006381342187523842, -0.031322017312049866, -0.023030290380120277, -0.01365349255502224, 0.000856059486977756, -0.01007480826228857, 0.028144029900431633, -0.011036631651222706, 0.029069915413856506, -0.006751203443855047, 0.0014992287615314126, 0.02898203209042549, -0.04204384237527847, -0.04303278028964996, 0.031314924359321594, 0.05646030232310295, -0.010536364279687405, -0.09946053475141525, -0.015863316133618355, 0.000844595197122544, -0.022028326988220215, 0.05556432530283928, -0.0582340806722641, 0.04551319032907486, -0.01749507710337639, -0.03099522553384304, 0.03380241245031357, 0.0005754336598329246, -0.007417432963848114, 0.029973359778523445, 0.022570407018065453, -0.041554536670446396, -0.00048786861589178443, -0.01380618754774332, -0.0015675812028348446, 0.04436664655804634, 0.032685279846191406, -0.043493300676345825, 0.046108655631542206, -0.017427442595362663, 0.001863616518676281, -0.04656281694769859, 0.001380470464937389, 0.023061929270625114, 0.010347138158977032, 0.025931378826498985, -0.01137961633503437, 0.01845317706465721, -0.022754231467843056, -0.05987498164176941, 0.03162321075797081, -0.003814953612163663, -0.03422025963664055, 0.02433922328054905, 0.03457421436905861, 0.025947604328393936, 0.03169676661491394, -0.02859104610979557, 0.013631385751068592, 0.020863763988018036, -0.0003259667137172073, 0.0070472643710672855, 0.0019440995529294014, 0.010566391050815582, -0.009160714223980904, -0.023231329396367073, -0.04326898232102394, -0.01649891398847103, -0.01003882847726345, -0.005575481802225113, 0.0241710115224123, -0.017977438867092133, -0.008595499210059643, 0.020948488265275955, 0.01078330259770155, 0.015766972675919533, 0.004395880736410618, -0.047654889523983, 0.04613305255770683, -0.011178837157785892, -0.03645050525665283, -0.04317227751016617, -0.01023880671709776, 0.02893063612282276, 0.029810257256031036, 0.016748569905757904, 0.010388885624706745, -0.009088166989386082, 0.04041770100593567, 0.007869480177760124, 0.005164326634258032, -0.03243574872612953, 0.01728772185742855, -0.012803586199879646, 0.009862102568149567, 0.07336819171905518, 0.04665558785200119, 0.006907575763761997, -0.04647126421332359, -0.026527369394898415, -0.03548823669552803, 0.00949226412922144, -0.007257020566612482, 0.015670480206608772, -0.03403681516647339, -0.004737569019198418, 0.048042476177215576, 0.050920456647872925, 0.004925801884382963, -0.009533393196761608, -0.003236121963709593, 0.0010895973537117243, -0.009177915751934052, 0.006652464624494314, 0.005058239679783583, 0.009482263587415218, -0.023020975291728973, 0.04488295316696167, 0.007954658009111881, -0.03669608011841774, -0.001761074410751462, 0.031033458188176155, 0.011357050389051437, -0.036467619240283966, -0.015869030728936195, 0.04617389291524887, -0.014735784381628036, -0.0028151930309832096, -0.003654594300314784, 0.02256436087191105, -0.004281338304281235, 0.022880621254444122, 0.010559841990470886, -0.016344144940376282, 0.004508902318775654, -0.014216947369277477, 0.045454856008291245, 0.01392749510705471, 0.012975609861314297, -0.024356678128242493, -0.01766212284564972, 0.04360394924879074, -0.0038871970027685165, 0.04812069237232208, 0.028286242857575417, -0.03634104132652283, -0.01451259944587946, 0.03586900606751442, -0.031977273523807526, 0.012330916710197926, -0.003619037102907896, -0.017206376418471336, -0.0009704699623398483, -0.017281321808695793, 0.012445739470422268, -0.003566748695448041, -0.005009671673178673, -0.019776033237576485, -0.0038742092438042164, 0.013171510770916939, -0.005205598659813404, 0.0307460930198431, -0.006079311016947031, -0.04618663713335991, -0.01160206738859415, -0.0033904125448316336, -0.01499029528349638, 0.020061902701854706, 0.015504492446780205, -0.03599181026220322, -0.03797372430562973, -0.001830572378821671, -0.04021821916103363, -0.012595126405358315, -0.0028822387102991343, -0.01190544106066227, 0.039978332817554474, 0.008104842156171799, 0.007756609469652176, -0.027938786894083023, -0.006619555409997702, 0.0029823670629411936, -0.02025488391518593, -0.020732183009386063, -0.04722209647297859, -0.026631608605384827, 0.010004159063100815, 0.000377975549781695, 0.03600730374455452, 0.02731800638139248, -0.04553050175309181, 0.00484316423535347, 0.051583994179964066, 0.015560686588287354, 0.017161287367343903, -0.0287089254707098, 0.026161953806877136, -0.03721095994114876, -0.008120325393974781, -0.010719383135437965, 0.027962584048509598, 0.0026159065309911966, 0.043316684663295746, 0.05733856186270714, 0.041242390871047974, 0.013804948888719082, 0.010338930413126945, -0.015893831849098206, -0.010472632013261318, -0.006648453883826733, -0.03687741607427597, 0.00021792890038341284, -0.031922321766614914, 0.026477018371224403, -0.019001973792910576, -0.04104987904429436, -0.011976825073361397, 0.006946776062250137, 0.04415358975529671, -0.025248495861887932, -0.0156302060931921, 0.009710680693387985, 0.022756114602088928, -0.008408947847783566, -0.05867501348257065, 0.029118748381733894, -0.020880205556750298, -0.019818156957626343, -0.021120835095643997, 0.01924893446266651, 0.003223414532840252, 0.005000928416848183, -0.022501526400446892, -0.021248336881399155, 0.011014687828719616, 0.01746414415538311, 0.012759791687130928, -0.011072534136474133, -0.030640706419944763, -0.06470578908920288, -0.0027120125014334917, 0.00792749598622322, -0.05064058303833008, 0.014260427094995975, -0.01717478223145008, -0.015617535449564457, -0.024264290928840637, 0.02318587340414524, -0.04034179449081421, 0.019905082881450653, 0.04177563264966011, 0.03069063276052475, -0.034764114767313004, -0.05703271925449371, 0.01920798234641552, 0.02246668003499508, -0.02943827398121357, -0.03528468683362007, -0.02482815831899643, -0.014413596130907536, -0.008056305348873138, -0.0651923194527626, 0.024510443210601807, 0.014594935812056065, -0.006834466475993395, -0.008032272569835186, 0.0024550079833716154, -0.016552235931158066, 0.008958923630416393, -0.007610642351210117, -0.004077717661857605, 0.034817878156900406, 0.05289209261536598, 0.02410770021378994, -0.008225226774811745, -0.001189264701679349, -0.027728527784347534, -0.01155103649944067, -0.06241415813565254, 0.01679403893649578, 0.0453886054456234, -0.021537363529205322, 0.0020879830699414015, 0.03356960415840149, -0.056052420288324356, -0.018714264035224915, 0.005925978999584913, 0.05624130740761757, 0.017753683030605316, 0.011599934659898281, 0.01664968580007553, 0.004089741036295891, -0.013356538489460945, 0.00040533975698053837, 0.06830934435129166, -0.02072359435260296, 0.030196484178304672, -0.0037899850867688656, 0.00707999849691987, 0.05103889852762222, 0.007359654642641544, 0.004236860200762749, 0.029129935428500175, 0.06108458712697029, 0.03943592682480812, -0.010884341783821583, 0.018667709082365036, -0.01202111691236496, -0.014085131697356701, -0.049531999975442886, -0.014195897616446018, -0.057698581367731094, 0.008251892402768135, 0.020396094769239426, -0.02074800245463848, -0.02814708836376667, -0.015322857536375523, 0.026979483664035797, 0.030390294268727303, 0.02909504435956478, 0.008252805098891258, 0.053137198090553284, 0.07507351785898209, 0.0013418482849374413, 0.02348187565803528, 0.021014414727687836, -0.012099064886569977, -0.03343971073627472, 0.008510255254805088, 0.024137480184435844, 0.02533445693552494, -0.029401106759905815, -0.011184724047780037, 0.04363662004470825, -0.014942376874387264, -0.011113394051790237, 0.02201865240931511, -0.028660990297794342, 0.0037313690409064293, -0.01779473014175892, 0.025864576920866966, -0.009411988779902458, -0.008582000620663166, -0.004733784589916468, -0.010718243196606636, -0.006555354688316584, -0.0069106039591133595, -0.03263917565345764, 0.045809708535671234, 0.013850805349647999, -0.0004766948113683611, -0.023671632632613182, -0.014548629522323608, 0.011056103743612766, -0.005232672207057476, -0.03800122067332268, -0.05431269854307175, -0.058828432112932205, -0.05091851204633713, -0.011027715168893337, 0.034683793783187866, -0.010823837481439114, -0.03332751989364624, 0.01897120662033558, 0.010943052358925343, -0.04210246726870537, 0.013347276486456394, 0.004272058140486479, 0.00668569328263402, -0.05122034251689911, -0.016201898455619812, -0.03567078337073326, -0.042841341346502304, -0.0012071513338014483, -0.028776533901691437, 0.0222561527043581, -0.007027955260127783, -0.025778960436582565, 0.011304530315101147, 0.04444485157728195, -0.014731560833752155, -0.011394219473004341, 0.0374983586370945, 0.01238183956593275, 0.02038593217730522, 0.02264406718313694, 0.017385272309184074, 0.014689667150378227, 0.03057137317955494, -0.022518081590533257, -0.02742418833076954, -0.004553942009806633, 0.011702119372785091, 0.04915284737944603, -0.0006610161508433521, -0.05118056386709213, -0.017430927604436874, 0.025970645248889923, 0.010133007541298866, 0.028677955269813538, 0.03173104673624039, 0.008118352852761745, 0.013131317682564259, -0.05810600519180298, 0.029955537989735603, -0.03033222258090973, 0.016618791967630386, -0.054827671498060226, -0.07400094717741013, -0.019631775096058846, 0.06330367177724838, -0.030887426808476448, 0.004832289181649685, -0.07992374151945114, 0.0032810650300234556, -0.07761959731578827, -0.00539166945964098, -0.01949736475944519, 0.044704996049404144, 0.03601519390940666, 0.049672000110149384, 0.0075301555916666985, 0.020113220438361168, -0.03689681366086006, -0.009076756425201893, -0.04404277727007866, 0.02765440009534359, 0.038388777524232864, -0.01806805655360222, 0.009244725108146667, -0.005199502222239971, 0.0158765260130167, 0.009775780141353607, -0.017160076647996902, 0.02246231958270073, 0.03777331858873367, -0.023872340098023415, -0.04067876562476158, 0.008757298812270164, 0.02289685048162937, -0.018118128180503845, 0.034406233578920364, 0.004989053588360548, 0.0003963057533837855, 0.02475917711853981, 0.0036976702976971865, -0.06749376654624939, 0.01609632931649685, -0.028658943250775337, 0.003774937242269516, 0.005747389513999224, 0.0313931442797184, 0.027215417474508286, 0.002494589425623417, -0.008635658770799637, 0.007756511215120554, 0.0184086374938488, -0.005280009936541319, -0.06022452935576439, -0.03699413314461708, 0.05901717767119408, 0.010406624525785446, -0.04102630540728569, 0.021809490397572517, -0.02427719719707966, -0.01389122661203146, 0.004817236680537462, 0.038983073085546494, 0.03385835140943527, 0.03795020654797554, 0.016175800934433937, -0.03913780301809311, 0.0500299446284771, 0.023706210777163506, -0.014194712974131107, -0.036437295377254486, -0.01343619916588068 ]
Fine-Tune ViT for Image Classification with 🤗 Transformers
nateraw
February 11, 2022
fine-tune-vit
guide, cv
https://huggingface.co/blog/fine-tune-vit
Evaluate 📊 python metrics = trainer.evaluate(prepared_ds['validation']) trainer.log_metrics("eval", metrics) trainer.save_metrics("eval", metrics) Here were my evaluation results - Cool beans! Sorry, had to say it. * eval metrics *** epoch = 4.0 eval_accuracy = 0.985 eval_loss = 0.0637 eval_runtime = 0:00:02.13 eval_samples_per_second = 62.356 eval_steps_per_second = 7.97 Finally, if you want, you can push your model up to the hub. Here, we'll push it up if you specified push_to_hub=True in the training configuration. Note that in order to push to hub, you'll have to have git-lfs installed and be logged into your Hugging Face account (which can be done via huggingface-cli login). python kwargs = { "finetuned_from": model.config._name_or_path, "tasks": "image-classification", "dataset": 'beans', "tags": ['image-classification'], } if training_args.push_to_hub: trainer.push_to_hub('🍻 cheers', **kwargs) else: trainer.create_model_card(**kwargs) The resulting model has been shared to nateraw/vit-base-beans. I'm assuming you don't have pictures of bean leaves laying around, so I added some examples for you to give it a try! 🚀
[ 0.07075387239456177, 0.04876146465539932, -0.015706432983279228, -0.05972035974264145, 0.01761971227824688, 0.046748414635658264, 0.06469199806451797, 0.012553076259791851, -0.07029826194047928, 0.007846280001103878, -0.06732724606990814, 0.06806482374668121, -0.02583285979926586, -0.0019644831772893667, 0.009948773309588432, -0.08513995260000229, 0.043016161769628525, -0.010074960067868233, 0.001646804972551763, 0.06595250219106674, -0.03529847040772438, -0.07048226147890091, 0.009071939624845982, 0.043452125042676926, 0.0013505889801308513, 0.010890745557844639, 0.08087703585624695, 0.0385592095553875, 0.00008214215631596744, 0.02570667676627636, -0.07468288391828537, -0.013256778009235859, -0.0794386938214302, -0.022305794060230255, -0.004723798017948866, 0.08172378689050674, -0.08561553061008453, 0.056753624230623245, 0.07164750248193741, -0.04863107204437256, -0.014029628597199917, 0.026100771501660347, -0.019252145662903786, 0.06830064207315445, 0.024589890614151955, -0.07668691873550415, -0.09890211373567581, -0.010981365106999874, 0.03472711890935898, 0.006278364919126034, -0.05567125231027603, 0.0811324268579483, 0.0518464669585228, -0.01600022055208683, 0.014166136272251606, -0.012687279842793941, 0.0061103287152945995, -0.04670394957065582, 0.010798980481922626, 0.006849190220236778, -0.01997796632349491, 0.029000665992498398, -0.006464980076998472, 0.04264477640390396, 0.0030069220811128616, 0.03343131020665169, 0.007230894640088081, 0.07637567818164825, -0.02993541769683361, -0.03950047492980957, -0.005579377990216017, -0.022960035130381584, -0.0113602289929986, 0.004038874059915543, 0.025262048467993736, -0.05386887118220329, -0.037171751260757446, 0.0033261701464653015, 0.05957439914345741, 0.08382242918014526, -0.016359569504857063, -0.034652967005968094, -0.04303630068898201, 0.025294622406363487, 0.02682829275727272, 0.06902548670768738, 0.032284047454595566, -0.09778761863708496, -0.09315647184848785, 0.030165070667862892, -0.04315871000289917, -0.03344331309199333, -0.004346742294728756, -0.004025901667773724, 0.03221748024225235, -0.04539363086223602, -0.024003123864531517, 0.005228046793490648, -0.007092605344951153, -0.021417608484625816, 0.055465374141931534, -0.06739071756601334, 0.021790727972984314, -0.021290484815835953, -0.002846513641998172, 0.01209304854273796, -0.07335361838340759, -0.08677580207586288, -0.07540084421634674, 0.025999732315540314, 0.027745384722948074, -0.008691245689988136, -0.053449295461177826, 0.07650227844715118, -0.06250981241464615, -0.011486469767987728, -0.01642446778714657, 0.04792112112045288, -0.02355961501598358, 0.0046606240794062614, 0.04967905580997467, 0.09365159273147583, 0.07344213873147964, -0.006631218362599611, 0.011503232643008232, 0.042560264468193054, -0.016417667269706726, 0.057646069675683975, 0.05904562026262283, -0.020857950672507286, -0.001365370349958539, -0.023001031950116158, 0.0952812135219574, 0.012462029233574867, -0.05267641693353653, -0.06099272146821022, 0.008557703346014023, -0.06026102602481842, -0.01276305876672268, 0.049994319677352905, -0.054363276809453964, 0.08445281535387039, -0.027063598856329918, 0.03747798502445221, 0.05404122173786163, -0.001123812748119235, -0.00042734635644592345, 0.05899032577872276, 0.047884706407785416, -0.010491865687072277, -0.10393865406513214, 0.0763196349143982, 0.026148734614253044, -0.027113644406199455, -0.03317913040518761, 0.05838116630911827, -0.03632258251309395, 0.025804951786994934, -0.057542480528354645, 0.07666197419166565, -0.01704813353717327, 0.05615553259849548, -0.11037380248308182, 0.027610670775175095, 0.015537457540631294, 0.007628437597304583, 0.01839524134993553, -0.034393809735774994, 0.07295111566781998, -0.04219244793057442, 0.026841184124350548, -0.09211993962526321, 0.017785990610718727, 0.0006728324224241078, 0.01203467883169651, 0.043416578322649, 0.03911193832755089, 0.023923225700855255, 0.023953452706336975, -0.003251406131312251, -0.012182243168354034, 0.04769474267959595, -0.019556742161512375, 0.0010254299268126488, 0.09958041459321976, -0.03515879809856415, 0.009745026007294655, -0.06219835579395294, 0.07524965703487396, 0.027436187490820885, -0.05716634914278984, 0.01071513444185257, 0.030013833194971085, -0.046962670981884, -0.002162347314879298, -0.12366753816604614, 0.000845214060973376, 0.0868159607052803, 0.0610104575753212, -0.013690326362848282, 0.0004394720890559256, 0.0025007356889545918, 0.05822906643152237, -0.060213372111320496, -0.004641606938093901, 0.003231112379580736, -0.04382367059588432, -0.0905231460928917, 0.02418708987534046, 0.031226174905896187, 0.010723121464252472, -0.05519544705748558, 0.09902806580066681, -0.05711748078465462, -0.042845312505960464, -0.006060990039259195, 0.007602056488394737, -0.014440973289310932, -0.024932263419032097, 0.024768570438027382, 0.13639628887176514, -0.010658446699380875, 0.0231481920927763, -0.03363242745399475, 0.0022953234147280455, 0.02148335613310337, 0.0317361019551754, 0.09505593031644821, 0.05675124377012253, -0.0908738300204277, -0.03144140541553497, -0.04219742864370346, -0.05637473240494728, 0.06417668610811234, -0.03192592039704323, -0.025997333228588104, 0.07017312198877335, -0.018361376598477364, 0.05588751658797264, 0.005245912354439497, 0.003282277612015605, 0.007642572745680809, -0.011160864494740963, 0.020763974636793137, -0.004572965670377016, -0.00436916621401906, 0.07094655185937881, 0.009756344370543957, -0.07455607503652573, -0.055492643266916275, -0.021759890019893646, 0.05795646831393242, 0.028647392988204956, 0.007828247733414173, -0.029559653252363205, -0.03324536606669426, -0.01702895760536194, 0.016031980514526367, -0.03198947757482529, 0.06187937408685684, 0.008352523669600487, 0.006566441152244806, -0.041886817663908005, -0.0112465750426054, 0.029181910678744316, -0.016047947108745575, 0.03069128282368183, -0.0028199730440974236, 0.010271494276821613, -0.017183229327201843, 0.01777372509241104, -0.018045030534267426, 0.006913399323821068, -0.000036722867662319914, 0.051297083497047424, 0.017415432259440422, 0.007487107999622822, -0.006338162813335657, 0.0018557204166427255, -0.0013523687375709414, -0.007343820761889219, -0.010672696866095066, 0.001479024882428348, 0.015764763578772545, 0.027187535539269447, -0.011400868184864521, -0.016233408823609352, -0.015288067981600761, 0.0035433692391961813, 0.02121887356042862, 0.02582874707877636, 0.0557541660964489, 0.023007391020655632, -0.06427158415317535, 0.00027994398260489106, 0.005775256082415581, 0.011300604790449142, 0.0020840533543378115, 0.03084712103009224, 0.011547593399882317, -0.01431052852421999, 0.015279790386557579, 0.020468536764383316, 0.013283642940223217, -0.02480214089155197, -0.019173016771674156, 0.014880255796015263, 0.004939624108374119, -0.07707685977220535, 0.027093902230262756, 0.009268488734960556, -0.06284625828266144, 0.0020329291000962257, 0.001881975680589676, 0.0559585765004158, -0.001463497756049037, -0.027936968952417374, 0.027979878708720207, -0.00292326626367867, -0.002560849767178297, -0.004978593438863754, -0.005887443199753761, 0.010961893945932388, 0.00901845283806324, 0.002635236131027341, -0.03395142778754234, 0.03276868909597397, 0.003755507292225957, -0.06539642810821533, 0.008922683075070381, -0.030544528737664223, -0.012582927942276001, -0.00245102122426033, 0.011723845265805721, 0.03949129208922386, -0.011421951465308666, 0.009129024110734463, -0.04795373976230621, 0.00767408637329936, -0.05013927072286606, -0.015503562055528164, -0.038601215928792953, -0.02773185819387436, 0.015382274053990841, -0.015103125013411045, -0.020018097013235092, 0.012610282748937607, -0.00993425864726305, -0.04299294948577881, 0.0353391058743, 0.028126157820224762, -0.0425744391977787, 0.003840448334813118, 0.005121621768921614, 0.01411224715411663, 0.00038985119317658246, -0.038519345223903656, -0.0338384173810482, -0.016554243862628937, 0.017986152321100235, -0.01614272966980934, 0.06611642241477966, -0.03267806023359299, 0.006384053733199835, -0.005170724354684353, 0.01955334097146988, 0.006855305749922991, -0.020557686686515808, -0.07073188573122025, 0.022556668147444725, -0.03151598572731018, -0.04912290349602699, 0.004706162493675947, 0.0190743375569582, 0.0024048713967204094, -0.0015878280391916633, -0.020544234663248062, 0.051854029297828674, -0.061107952147722244, 0.033345967531204224, -0.008725259453058243, 0.01362011581659317, -0.01276281476020813, -0.03398996964097023, -0.0038704359903931618, -0.008753672242164612, 0.06677202880382538, 0.035442326217889786, 0.004007156006991863, -0.01795307733118534, 0.006247562821954489, -0.027603529393672943, -0.00948349665850401, 0.007331071421504021, 0.016367722302675247, -0.04501815512776375, 0.0557854026556015, 0.036848388612270355, 0.01900433376431465, -0.018191521987318993, -0.020196720957756042, -0.008231914602220058, -0.03268498182296753, -0.027427462860941887, 0.03504103422164917, 0.011742758564651012, -0.04108497500419617, 0.009177826344966888, -0.022054949775338173, -0.07564540207386017, 0.023987827822566032, 0.012466542422771454, 0.02738988772034645, 0.016533998772501945, -0.03145693242549896, -0.028572537004947662, 0.031809866428375244, -0.02514508180320263, -0.006954333744943142, -0.023711800575256348, -0.03508831188082695, -0.013808983378112316, 0.03279448673129082, 0.05046231672167778, -0.00603699404746294, -0.020621303468942642, -0.0008471342734992504, 0.06462366878986359, -0.026267120614647865, 0.014897909015417099, 0.009686693549156189, -0.038218047469854355, 0.0031556179746985435, -0.0006590688717551529, 0.006680541671812534, -0.041817791759967804, -0.00648110918700695, 0.007606447674334049, -0.020932091400027275, -0.016806144267320633, 0.018345355987548828, -0.01563750021159649, 0.0445411242544651, -0.025269614532589912, -0.0003597461909521371, -0.02906925603747368, 0.01643769070506096, 0.0014937513042241335, -0.024826107546687126, 0.021408209577202797, 0.034831833094358444, -0.014210105873644352, 0.0076604560017585754, 0.030196592211723328, -0.03589058294892311, 0.016709500923752785, -0.036000534892082214, 0.013584894128143787, -0.013408679515123367, 0.010444670915603638, -0.04528690502047539, 0.022723974660038948, 0.026849403977394104, -0.0030660235788673162, -0.04020357504487038, -0.003980209119617939, 0.008428679779171944, 0.033460572361946106, -0.0405285581946373, -0.0076646204106509686, 0.027598537504673004, -0.009151513688266277, -0.016334358602762222, 0.017736518755555153, 0.002418683608993888, -0.04655159264802933, 0.005171492695808411, -0.038466427475214005, 0.020098190754652023, 0.0013120146468281746, 0.004147363360971212, -0.03276655077934265, 0.00125408754684031, 0.025626176968216896, 0.016841094940900803, 0.019135499373078346, -0.02779574692249298, 0.02208828367292881, -0.01995796337723732, -0.01035621203482151, 0.04233010113239288, -0.01643786020576954, 0.03398478031158447, 0.019752688705921173, 0.012604455463588238, 0.020227275788784027, 0.012214449234306812, 0.03931872919201851, -0.005018511787056923, -0.027945561334490776, 0.06641271710395813, -0.040267463773489, 0.0014588389312848449, 0.003323131240904331, -0.002334320219233632, -0.02499876171350479, -0.03699920326471329, -0.03690332919359207, 0.037641581147909164, 0.011591121554374695, -0.04716851934790611, -0.034448642283678055, 0.006357457023113966, 0.005564159248024225, 0.003416235325857997, 0.021245814859867096, -0.002332013566046953, -0.04179270565509796, -0.0058646490797400475, -0.043578166514635086, -0.024044392630457878, 0.0378674641251564, 0.0058124614879488945, -0.005281160119920969, -0.004638208542019129, 0.03822248429059982, 0.005277668591588736, -0.017658108845353127, -0.0062256306409835815, -0.01747727394104004, -0.01984354853630066, -0.034736037254333496, 0.033366456627845764, -0.0019334661774337292, 0.03252427279949188, 0.023907797411084175, 0.016270391643047333, 0.05448856204748154, 0.012255160138010979, -0.020923158153891563, 0.0043724654242396355, 0.0066954693756997585, 0.018764253705739975, -0.01840917393565178, -0.037633270025253296, 0.05633478984236717, 0.0625433698296547, -0.02827819064259529, -0.018400244414806366, 0.017125505954027176, -0.0317121222615242, 0.02581464871764183, -0.012884152121841908, 0.08231509476900101, 0.04603737220168114, -0.014750175178050995, 0.01995413936674595, -0.00833586510270834, 0.015256218612194061, 0.07777909189462662, -0.009167764335870743, -0.0037602114025503397, 0.0027046597097069025, -0.004736820235848427, 0.003979172557592392, 0.026827270165085793, -0.005969615653157234, 0.02138577774167061, 0.023753691464662552, -0.020956480875611305, 0.007079476024955511, 0.0229289922863245, -0.024534637108445168, -0.005547603592276573, -0.026194298639893532, -0.04461928829550743, 0.011191406287252903, 0.04996801167726517, -0.03064407780766487, 0.03080454096198082, 0.008859149180352688, 0.05441412702202797, 0.05572831258177757, -0.020658237859606743, -0.023701107129454613, 0.03260286524891853, -0.02460956946015358, 0.04172002151608467, 0.012350114993751049, 0.030312122777104378, -0.014380988664925098, 0.0019109788117930293, 0.013956369832158089, -0.012202669866383076, 0.04663507267832756, -0.010389680042862892, 0.0419306606054306, 0.0388205423951149, 0.0301067978143692, 0.00996157806366682, -0.028471944853663445, -0.04666651040315628, -0.0117825698107481, 0.020830385386943817, 0.04446428269147873, 0.004780256189405918, 0.01609833724796772, -0.017235497012734413, 0.043443042784929276, 0.061915069818496704, 0.022128408774733543, 0.0127111142501235, -0.0028355878312140703, 0.06937466561794281, 0.006737669464200735, -0.013153049163520336, 0.01602345146238804, -0.011321422643959522, -0.038610897958278656, 0.060402289032936096, 0.014223732054233551, -0.03338140621781349, 0.019463542848825455, 0.032806187868118286, -0.002974907634779811, -0.013416814617812634, -0.005834079347550869, 0.04415817931294441, 0.019659869372844696, -0.0070206173695623875, -0.016808779910206795, -0.018925976008176804, -0.0289448332041502, 0.009114866144955158, -0.019001133739948273, -0.015101877972483635, -0.0018198962789028883, -0.020110657438635826, -0.003377777524292469, 0.03913545235991478, 0.028781132772564888, -0.024380844086408615, -0.011316283605992794, 0.020309684798121452, 0.0061888727359473705, 0.07865993678569794, -0.013291575945913792, -0.056120920926332474, -0.04160336032509804, -0.016282137483358383, -0.00979681871831417, 0.03405869007110596, 0.012141279876232147, -0.004387732595205307, -0.013929919339716434, 0.017406867817044258, 0.028749912977218628, 0.012740793637931347, 0.013517486862838268, 0.03137548640370369, -0.014405778609216213, 0.0060476986691355705, -0.016629351302981377, -0.05603805184364319, 0.033693473786115646, -0.023080119863152504, 0.01773957349359989, 0.004290047567337751, 0.0475420281291008, -0.005085073411464691, 0.006158143747597933, 0.001097825006581843, -0.034469280391931534, 0.0017233823891729116, -0.015973685309290886, -0.027984291315078735, 0.07126715034246445, 0.012000142596662045, 0.009810617193579674, 0.024527963250875473, -0.003903415286913514, -0.005801770836114883, 0.012539103627204895, -0.02079731784760952, 0.009695261716842651, -0.026623226702213287, 0.0048031918704509735, 0.005621522199362516, 0.0462077371776104, 0.05867115408182144, 0.0069188401103019714, 0.01200868096202612, -0.019980603829026222, 0.035947058349847794, -0.019162407144904137, 0.06749200075864792, -0.04015197977423668, -0.026096757501363754, -0.03435397893190384, -0.045053403824567795, -0.013360897079110146, -0.005686815362423658, -0.049118660390377045, 0.017817439511418343, -0.06465248763561249, -0.011492463760077953, -0.0011365521932020783, -0.022400785237550735, -0.010006898082792759, 0.0103988666087389, 0.045822810381650925, 0.055129524320364, 0.039487194269895554, -0.020300831645727158, -0.05151176452636719, 0.013038286939263344, -0.00572161003947258, 0.001161603955551982, 0.03773738071322441, -0.010658704675734043, 0.0086569394916296, -0.011753253638744354, 0.030234256759285927, 0.002674071816727519, -0.07358253002166748, -0.007292657159268856, -0.020300785079598427, -0.016221506521105766, -0.06377580761909485, 0.006928342394530773, 0.038149427622556686, 0.0005199693841859698, 0.032376326620578766, -0.02459629438817501, -0.039115097373723984, -0.025712808594107628, 0.0010792515240609646, -0.08230767399072647, 0.052876099944114685, -0.04087768495082855, -0.020652709528803825, -0.02326103113591671, -0.03227948769927025, -0.008009997196495533, 0.04373523220419884, -0.04404880851507187, -0.013194934464991093, -0.0471833162009716, -0.0012416125973686576, -0.01221918873488903, 0.03620682656764984, 0.02040361799299717, -0.03155423700809479, -0.03952057659626007, 0.0003178160113748163, -0.018308443948626518, -0.0482867993414402, -0.017112404108047485, -0.013277703896164894, 0.009215219877660275, 0.0382683128118515, -0.03537711128592491, -0.02780591882765293, 0.044052187353372574, 0.0247676782310009, -0.04881264269351959, -0.027281351387500763, 0.043617118149995804 ]
Fine-Tune ViT for Image Classification with 🤗 Transformers
nateraw
February 11, 2022
fine-tune-vit
guide, cv
https://huggingface.co/blog/fine-tune-vit
# Fine-Tune ViT for Image Classification with 🤗 Transformers Just as transformers-based models have revolutionized NLP, we're now seeing an explosion of papers applying them to all sorts of other domains. One of the most revolutionary of these was the Vision Transformer (ViT), which was introduced in June 2021 by a team of researchers at Google Brain. This paper explored how you can tokenize images, just as you would tokenize sentences, so that they can be passed to transformer models for training. It's quite a simple concept, really... 1. Split an image into a grid of sub-image patches 1. Embed each patch with a linear projection 1. Each embedded patch becomes a token, and the resulting sequence of embedded patches is the sequence you pass to the model. It turns out that once you've done the above, you can pre-train and fine-tune transformers just as you're used to with NLP tasks. Pretty sweet 😎. --- In this blog post, we'll walk through how to leverage 🤗 datasets to download and process image classification datasets, and then use them to fine-tune a pre-trained ViT with 🤗 transformers. To get started, let's first install both those packages. bash pip install datasets transformers
[ 0.03935768082737923, -0.084062360227108, 0.013901269994676113, 0.012747516855597496, 0.030985843390226364, 0.05128273740410805, 0.0014808722771704197, 0.06338275223970413, -0.033789850771427155, 0.020940914750099182, -0.07389497011899948, 0.12142813205718994, -0.031921230256557465, 0.06980880349874496, 0.0318741649389267, -0.004734341520816088, 0.07027897983789444, 0.024682510644197464, -0.037681929767131805, 0.022720949724316597, 0.022194810211658478, -0.10656697303056717, 0.043550584465265274, -0.037626296281814575, 0.030944470316171646, -0.006983024068176746, 0.023857356980443, 0.0006831733626313508, -0.02915136143565178, 0.014503601007163525, -0.13091127574443817, 0.0034932855051010847, -0.047713663429021835, -0.027402112260460854, -0.07149927318096161, 0.0147223686799407, -0.05674563720822334, -0.0260762982070446, 0.03855730593204498, -0.02209513634443283, -0.04052552953362465, -0.013284990563988686, 0.018094617873430252, 0.03385886922478676, 0.006120250094681978, -0.043707992881536484, -0.1418590098619461, 0.0863262340426445, -0.02459314465522766, 0.0009340982069261372, -0.036994799971580505, 0.05537506192922592, 0.03201370686292648, -0.05113835632801056, -0.009163212962448597, 0.015592735260725021, 0.03702092915773392, -0.0929909348487854, -0.008051794022321701, -0.0030359693337231874, 0.018558761104941368, -0.02369513548910618, -0.0027331418823450804, 0.017264816910028458, -0.012043903581798077, 0.038009945303201675, -0.07310765981674194, 0.04367214813828468, -0.031675200909376144, -0.05744558945298195, 0.017957502976059914, -0.01470677275210619, 0.04024982079863548, -0.002072651404887438, -0.061386190354824066, -0.01510870736092329, -0.027354469522833824, 0.018953118473291397, 0.03241090103983879, 0.008474125526845455, 0.00905343983322382, 0.059619318693876266, 0.039066705852746964, 0.03377712145447731, 0.03733383119106293, 0.04709256812930107, 0.031668759882450104, -0.03152637556195259, -0.08045370876789093, 0.06373666971921921, 0.01772431842982769, -0.10943014174699783, -0.04469903185963631, 0.0326833538711071, 0.04859327897429466, 0.018798621371388435, -0.010711020790040493, 0.0008021406247280538, -0.031495898962020874, -0.03384239599108696, 0.029567360877990723, 0.007932532578706741, 0.026235828176140785, -0.03428396210074425, -0.07331044226884842, 0.02058997191488743, -0.026299942284822464, -0.04817827418446541, -0.0719347670674324, -0.02175595611333847, 0.04727296531200409, 0.01610894687473774, 0.018052339553833008, 0.12777556478977203, -0.051938679069280624, -0.011154932901263237, 0.04437938705086708, -0.014239797368645668, -0.016448235139250755, 0.02313321642577648, 0.004228560253977776, 0.082667775452137, 0.08436532318592072, -0.03350812569260597, -0.04202524572610855, 0.030551550909876823, -0.010973643511533737, 0.03737509995698929, 0.0032901556696742773, 0.016832323744893074, 0.04780138283967972, -0.03723839297890663, 0.06379145383834839, 0.0180683396756649, -0.01091365423053503, -0.0629892349243164, 0.061460159718990326, -0.10323168337345123, 0.044349927455186844, -0.02352721057832241, 0.020124107599258423, 0.06930052489042282, -0.010658806189894676, -0.05078291520476341, 0.03538942709565163, -0.003956573083996773, -0.011520447209477425, 0.14450715482234955, 0.00834604911506176, 0.049459584057331085, -0.04540448635816574, 0.07460878044366837, 0.015172109007835388, -0.034558918327093124, 0.031194783747196198, 0.06576956063508987, 0.013090686872601509, -0.019756516441702843, -0.09009946882724762, -0.04862895980477333, -0.011751771904528141, -0.02620910108089447, -0.014970867894589901, 0.03903037682175636, -0.061071205884218216, -0.1046414002776146, 0.05112213268876076, 0.03159378841519356, 0.05353270098567009, 0.04145205020904541, 0.043957050889730453, -0.07120133191347122, 0.029979119077324867, -0.04196224361658096, 0.02270600013434887, 0.016991836950182915, 0.016211220994591713, 0.11001436412334442, -0.015815559774637222, -0.04370521754026413, -0.0070562721230089664, -0.017837828025221825, 0.027611933648586273, 0.052083466202020645, 0.009268853813409805, -0.05351356044411659, 0.0002419048541923985, -0.03713756427168846, 0.06712911278009415, 0.027566278353333473, -0.017820686101913452, 0.02064620889723301, 0.08425736427307129, -0.013665758073329926, 0.058694034814834595, -0.0213179811835289, -0.023230986669659615, 0.061691757291555405, 0.036169398576021194, 0.025349561125040054, -0.02116463892161846, -0.06946723163127899, -0.05341141298413277, -0.027172306552529335, 0.018505854532122612, -0.012813406996428967, -0.035533513873815536, -0.043968427926301956, 0.04517442360520363, 0.06379175186157227, 0.03058721497654915, -0.09322035312652588, 0.022503022104501724, -0.02654891461133957, 0.0368460975587368, 0.017477864399552345, -0.016948916018009186, 0.03460311517119408, 0.00004347049252828583, -0.07628586888313293, 0.08835120499134064, 0.05165616050362587, -0.021062973886728287, 0.02372821234166622, 0.00893738679587841, 0.03634331375360489, 0.06780090928077698, 0.0022927166428416967, 0.04725724831223488, -0.06016978994011879, -0.03319437801837921, -0.047464217990636826, -0.027002960443496704, -0.017041804268956184, -0.08706587553024292, -0.08998499065637589, 0.02455536462366581, 0.0722276121377945, 0.023000497370958328, -0.025570720434188843, -0.02095140889286995, -0.03661723807454109, -0.0755661129951477, 0.02121717855334282, 0.008276446722447872, 0.04717448726296425, 0.10066861659288406, 0.003767110640183091, 0.03422250971198082, -0.014896415174007416, -0.07697030156850815, 0.05150318145751953, -0.04974446818232536, -0.053468894213438034, 0.01015081163495779, 0.041284333914518356, 0.03762254863977432, 0.005270767025649548, -0.0398346446454525, 0.04981422796845436, -0.06092130392789841, 0.007881435565650463, -0.00896767433732748, -0.0357913114130497, -0.023690925911068916, -0.024100400507450104, 0.023806342855095863, 0.023985063657164574, 0.018217673525214195, -0.004468408413231373, -0.04838738590478897, 0.015921026468276978, 0.019977983087301254, 0.011587465181946754, -0.012693124823272228, 0.04015006870031357, 0.005972736049443483, -0.025234097614884377, 0.006349292583763599, 0.0019285021116957068, 0.013215587474405766, -0.04429883882403374, 0.016534222289919853, 0.048311419785022736, 0.0005926952580921352, -0.0028889505192637444, 0.0157069880515337, -0.03887785226106644, -0.020234299823641777, 0.0013507880503311753, 0.03068917989730835, 0.05676201730966568, 0.03476189821958542, 0.009517855010926723, -0.03774278610944748, 0.005835202056914568, -0.013216471299529076, -0.04817279055714607, -0.00645661074668169, 0.0337492935359478, 0.01821150816977024, 0.00704661849886179, 0.006353415083140135, -0.027471086010336876, -0.026238318532705307, 0.027148455381393433, 0.03834899514913559, 0.028815295547246933, -0.07378444075584412, -0.05975094065070152, 0.0010773660615086555, 0.007902641780674458, -0.038235489279031754, 0.0023234665859490633, 0.02130427397787571, -0.001974948449060321, 0.005356552544981241, -0.023760057985782623, 0.04217427223920822, 0.019530322402715683, 0.015574809163808823, 0.036459945142269135, -0.01044183038175106, 0.013577524572610855, 0.025700055062770844, -0.0034522663336247206, 0.019413987174630165, 0.06136556342244148, -0.05915505066514015, 0.029936958104372025, -0.004014879465103149, 0.05079187452793121, 0.0032975981011986732, 0.04660477861762047, 0.010571848601102829, 0.0016815824201330543, 0.0258938018232584, -0.017177289351820946, -0.009848546236753464, -0.020573653280735016, -0.010817127302289009, 0.050983726978302, -0.0558224655687809, -0.0011526414891704917, 0.037086181342601776, 0.01341811940073967, 0.02083570323884487, -0.00837921816855669, -0.00003488418951747008, 0.02998163364827633, 0.01793224737048149, -0.009884273633360863, 0.03885377198457718, -0.052371058613061905, -0.04203286021947861, -0.030813924968242645, -0.022166235372424126, -0.04902336373925209, -0.022703172639012337, 0.01880064234137535, 0.00887801218777895, 0.03949989378452301, 0.009943759068846703, 0.011572317220270634, 0.011618235148489475, 0.009772165678441525, 0.008244168013334274, -0.04643339663743973, -0.042874764651060104, 0.01980724185705185, -0.010873474180698395, 0.005286588333547115, -0.010822049342095852, 0.052871186286211014, 0.015625113621354103, 0.021441511809825897, 0.027825968340039253, 0.002017510123550892, -0.011105325073003769, 0.01844925433397293, -0.03180777654051781, -0.005199316889047623, -0.02759449928998947, 0.0036269533447921276, -0.02536298893392086, 0.0001774510310497135, 0.02005976065993309, 0.055228572338819504, -0.02899830788373947, -0.03499135375022888, -0.009551677852869034, -0.01763608306646347, 0.008800672367215157, 0.01561912801116705, -0.011367117054760456, -0.08324652165174484, 0.06031142175197601, -0.049234721809625626, 0.04049588739871979, -0.01753743551671505, -0.027864506468176842, -0.012063678354024887, -0.026457693427801132, -0.013178295455873013, -0.02986115962266922, 0.02880300208926201, -0.0002625700435601175, -0.06057834252715111, 0.01176469400525093, -0.03479481860995293, 0.022207139059901237, 0.026072395965456963, -0.01094241812825203, 0.013731821440160275, -0.05224309489130974, -0.019414208829402924, 0.0038234167732298374, 0.01845182105898857, -0.005024104379117489, -0.014103205874562263, 0.012901156209409237, -0.0016727626789361238, 0.019538793712854385, 0.015924520790576935, 0.013205230236053467, -0.012105732224881649, 0.00004304782851249911, -0.0012378230458125472, 0.02697085402905941, -0.006295242812484503, -0.013824516907334328, -0.028633803129196167, 0.04982588440179825, -0.007323300465941429, 0.021157070994377136, 0.05867764353752136, -0.02466627024114132, 0.017110204324126244, 0.007717544678598642, -0.029769498854875565, 0.03156325966119766, 0.00671946769580245, 0.022702118381857872, -0.021276915445923805, -0.029989786446094513, 0.010417045094072819, -0.010777099058032036, 0.008861340582370758, -0.009263463318347931, -0.01474097091704607, 0.023417877033352852, 0.0019045135704800487, 0.03218397498130798, -0.012996969744563103, -0.02313743159174919, -0.00618903199210763, 0.011018503457307816, 0.04865126684308052, 0.042656492441892624, 0.030315814539790154, -0.022680262103676796, -0.004163171164691448, 0.03105105087161064, -0.05785372853279114, -0.007800364401191473, 0.02222367934882641, 0.03180781751871109, 0.053239092230796814, 0.03176609054207802, 0.02069568820297718, -0.045200593769550323, 0.007372443098574877, 0.03034340590238571, -0.01323174312710762, 0.006436646915972233, -0.059106841683387756, -0.041007451713085175, 0.028158454224467278, 0.006378109101206064, 0.0031468868255615234, 0.009268421679735184, -0.015392552129924297, -0.029510866850614548, 0.014833817258477211, 0.005015309900045395, -0.004090821370482445, -0.03581918403506279, 0.00869371835142374, -0.02426319569349289, -0.036647405475378036, 0.01756342500448227, 0.01734399050474167, -0.003152549499645829, -0.0005464260466396809, 0.033371664583683014, 0.033431053161621094, -0.01953226886689663, -0.01593480445444584, 0.012629993259906769, -0.007776227314025164, 0.014328056946396828, -0.027897456660866737, -0.039592500776052475, -0.02307557500898838, -0.005902597680687904, 0.030996812507510185, -0.035077858716249466, -0.032420285046100616, 0.013462687842547894, 0.038545675575733185, 0.0013941498473286629, -0.00801489781588316, 0.02018125355243683, 0.015809115022420883, -0.04615398868918419, -0.02765735425055027, -0.03939845412969589, -0.05890345200896263, 0.06268510222434998, 0.006223818752914667, 0.006210343446582556, -0.0568336620926857, -0.03390485793352127, -0.017646418884396553, -0.016299927607178688, 0.0012460689758881927, 0.013662229292094707, 0.00919539388269186, -0.0366768054664135, -0.02499455213546753, 0.012283915653824806, 0.017858825623989105, 0.009397006593644619, -0.03441925346851349, 0.038706108927726746, 0.0009146177908405662, 0.0083385044708848, 0.034755200147628784, 0.006372167728841305, -0.0337967574596405, 0.016534006223082542, 0.038526467978954315, -0.021489327773451805, -0.022518519312143326, -0.031610649079084396, 0.033546123653650284, 0.053502872586250305, -0.03358154371380806, 0.02234376035630703, -0.03150356188416481, -0.07376343756914139, 0.02154633216559887, -0.04650883376598358, 0.01759134605526924, 0.021179888397455215, -0.006854647770524025, 0.024485524743795395, -0.000924990454223007, 0.0061889151111245155, 0.018869642168283463, -0.01014292798936367, -0.021549658849835396, 0.033652033656835556, -0.01649748533964157, 0.059735510498285294, 0.004110424313694239, -0.013764123432338238, 0.053951337933540344, -0.01653161644935608, -0.050664205104112625, 0.006289107259362936, 0.056809719651937485, 0.0052353860810399055, -0.017443910241127014, -0.0057529849000275135, -0.019150743260979652, -0.022974634543061256, 0.02584463730454445, -0.0022143074311316013, -0.011395138688385487, -0.03303764760494232, 0.0006285475683398545, -0.015511807054281235, -0.025258349254727364, 0.0032085103448480368, 0.0134190758690238, -0.005145843606442213, 0.038506049662828445, 0.02072027139365673, 0.02317846193909645, 0.08047592639923096, -0.005438028834760189, -0.0112225990742445, -0.00496498541906476, 0.05878598615527153, -0.011560105718672276, 0.029899589717388153, -0.002393071772530675, 0.016123488545417786, 0.01012094784528017, -0.042965713888406754, -0.029326368123292923, -0.05350783094763756, 0.03280234709382057, 0.044935327023267746, 0.011334815062582493, -0.019501008093357086, -0.01964353397488594, 0.0627201721072197, 0.05466160923242569, 0.04373902082443237, -0.01958462782204151, 0.025069834664463997, 0.02657383121550083, 0.011931224726140499, 0.026974041014909744, -0.008985012769699097, 0.011042270809412003, -0.03369632363319397, 0.036200862377882004, 0.028098221868276596, 0.04497680440545082, 0.011799924075603485, -0.006287108641117811, 0.03257157653570175, -0.00802379846572876, -0.06583204120397568, 0.013185434974730015, 0.012906394898891449, -0.0018803352722898126, -0.03688771650195122, 0.014342572540044785, -0.0710911899805069, 0.019580204039812088, -0.01949384994804859, 0.003954852931201458, -0.005499390419572592, -0.01694418676197529, 0.011675839312374592, 0.023787418380379677, -0.018453486263751984, -0.0037179847713559866, -0.028193941339850426, -0.015348101034760475, 0.018035421147942543, 0.011927446350455284, -0.0066370777785778046, -0.041475653648376465, 0.016497498378157616, -0.017961421981453896, 0.025210896506905556, 0.013308010995388031, -0.01488419808447361, -0.041715364903211594, -0.015539309941232204, 0.016750559210777283, -0.02609984390437603, 0.040565282106399536, 0.03440104424953461, -0.023172343149781227, -0.05994575843214989, 0.03336946293711662, -0.030905017629265785, -0.056388624012470245, -0.003937607631087303, -0.03735732659697533, -0.010944495908915997, 0.009638217277824879, 0.008230632171034813, 0.033763110637664795, 0.04727607220411301, 0.011815957725048065, -0.0275069959461689, -0.011989564634859562, 0.012584862299263477, -0.014544186182320118, 0.015409612096846104, 0.027227727696299553, 0.02393714152276516, 0.014709923416376114, 0.001648077042773366, 0.02741563320159912, 0.01792525313794613, 0.01352314930409193, 0.043400008231401443, 0.015467634424567223, -0.05352891609072685, -0.02017165720462799, 0.021328676491975784, 0.027071427553892136, 0.0032249370124191046, 0.008424310013651848, -0.0007530823349952698, 0.0279366634786129, -0.012698991224169731, 0.04344604164361954, -0.045839425176382065, -0.02479698695242405, -0.056476157158613205, -0.009614036418497562, -0.03940703347325325, 0.036741822957992554, -0.01903349533677101, 0.06523477286100388, -0.05299690365791321, 0.019915802404284477, -0.03796255216002464, -0.013132631778717041, -0.03035128489136696, -0.010637101717293262, 0.05910496786236763, 0.03577256202697754, 0.03842480853199959, -0.02790318801999092, -0.04791896790266037, -0.014717647805809975, -0.004151189234107733, 0.00020749750547111034, 0.02072829008102417, -0.03073776699602604, -0.0016945041716098785, -0.05333222821354866, 0.010852929204702377, -0.027664678171277046, -0.023148391395807266, 0.004468302708119154, 0.018519122153520584, -0.006029821466654539, 0.009461133740842342, 0.045934196561574936, 0.017382342368364334, 0.013857962563633919, 0.0021025431342422962, 0.04534360021352768, -0.014104779809713364, -0.0017293308628723025, -0.004983620718121529, -0.029962684959173203, 0.018199965357780457, -0.011295842938125134, 0.00754570635035634, -0.003657952416688204, 0.008211042732000351, 0.004993720445781946, -0.0156572163105011, -0.04529738426208496, 0.002243318594992161, -0.03619441017508507, -0.04767957702279091, -0.03378238528966904, 0.02764592319726944, 0.05335019901394844, -0.006138619035482407, -0.022046927362680435, 0.057239942252635956, 0.008272550068795681, 0.00030506832990795374, 0.025221867486834526, -0.02022359147667885, 0.01879509724676609, -0.03894452005624771, -0.007415923289954662, -0.03135930746793747, 0.055663224309682846, 0.021205756813287735, 0.014162170700728893, -0.012721125967800617, -0.012216911651194096 ]
Fine-Tune ViT for Image Classification with 🤗 Transformers
nateraw
February 11, 2022
fine-tune-vit
guide, cv
https://huggingface.co/blog/fine-tune-vit
Loading ViT Image Processor Now we know what our images look like and better understand the problem we're trying to solve. Let's see how we can prepare these images for our model! When ViT models are trained, specific transformations are applied to images fed into them. Use the wrong transformations on your image, and the model won't understand what it's seeing! 🖼 ➡️ 🔢 To make sure we apply the correct transformations, we will use a ViTImageProcessor initialized with a configuration that was saved along with the pretrained model we plan to use. In our case, we'll be using the google/vit-base-patch16-224-in21k model, so let's load its image processor from the Hugging Face Hub. python from transformers import ViTImageProcessor model_name_or_path = 'google/vit-base-patch16-224-in21k' processor = ViTImageProcessor.from_pretrained(model_name_or_path) You can see the image processor configuration by printing it. ViTImageProcessor { "do_normalize": true, "do_resize": true, "image_mean": [ 0.5, 0.5, 0.5 ], "image_std": [ 0.5, 0.5, 0.5 ], "resample": 2, "size": 224 } To process an image, simply pass it to the image processor's call function. This will return a dict containing pixel values, which is the numeric representation to be passed to the model. You get a NumPy array by default, but if you add the return_tensors='pt' argument, you'll get back torch tensors instead. python processor(image, return_tensors='pt') Should give you something like... { 'pixel_values': tensor([[[[ 0.2706, 0.3255, 0.3804, ...]]]]) } ...where the shape of the tensor is (1, 3, 224, 224).
[ 0.03574661538004875, -0.02940846048295498, 0.006788690574467182, -0.036042843014001846, -0.008429066278040409, 0.08467434346675873, 0.0536605529487133, 0.027808578684926033, -0.030541904270648956, -0.02115456573665142, -0.029004976153373718, 0.09116408973932266, -0.025834569707512856, 0.07292332500219345, 0.06494379788637161, -0.03689306974411011, 0.10854917019605637, 0.01038029883056879, -0.01804257743060589, 0.04928422346711159, 0.031536974012851715, -0.08296997100114822, 0.02228802815079689, 0.02041510120034218, 0.006112117785960436, -0.07995263487100601, 0.010847849771380424, 0.037573181092739105, 0.03601875901222229, -0.007355742156505585, -0.16779227554798126, -0.02160044200718403, -0.038430966436862946, -0.08607987314462662, -0.010706387460231781, 0.04137810319662094, -0.08075787872076035, 0.027163131162524223, 0.04278535023331642, 0.02783719263970852, 0.011827080510556698, -0.000404290301958099, -0.0372019037604332, 0.08059269189834595, 0.003365508047863841, -0.07310622930526733, -0.1033846065402031, 0.08658915013074875, 0.0011645430931821465, -0.005347770173102617, -0.04380391165614128, 0.05181482806801796, 0.020245008170604706, -0.036343611776828766, 0.008462217636406422, 0.004998926073312759, 0.013737071305513382, -0.046275507658720016, 0.044093649834394455, -0.02112211287021637, 0.06029980629682541, 0.0031458779703825712, -0.004887528717517853, 0.0647774338722229, -0.013025429099798203, 0.021103771403431892, 0.009092605672776699, 0.00008924486610339954, 0.01254182867705822, -0.028222834691405296, 0.02016197331249714, -0.056768689304590225, 0.05853551626205444, 0.00048323586815968156, -0.033386506140232086, 0.011780494824051857, -0.03691951185464859, 0.05868758633732796, 0.04007557034492493, 0.03473418951034546, 0.03428005054593086, 0.003561116987839341, 0.04597531259059906, 0.07272446900606155, 0.016003116965293884, 0.06817308068275452, 0.042682476341724396, -0.025580696761608124, -0.0547620952129364, 0.07782873511314392, -0.004410307854413986, -0.07409505546092987, 0.002107096603140235, 0.025079641491174698, 0.05702125281095505, -0.04208861663937569, -0.02198527380824089, -0.02194911241531372, 0.015038440003991127, 0.027499055489897728, -0.024465110152959824, 0.008988512679934502, 0.020366335287690163, -0.0030504916794598103, -0.058951254934072495, 0.004138278309255838, -0.0466022826731205, -0.06945127993822098, -0.06070118770003319, -0.017299653962254524, 0.006755522917956114, -0.010661046020686626, -0.02811969630420208, 0.045485854148864746, -0.07681069523096085, -0.020500147715210915, 0.012343992479145527, 0.0018719647778198123, -0.034458331763744354, 0.012796683236956596, 0.013818405568599701, 0.09541528671979904, 0.09270930290222168, -0.022499026730656624, -0.0010181181132793427, 0.05532198026776314, 0.004489366430789232, 0.05685373768210411, 0.02056732214987278, -0.01296629011631012, 0.03337177261710167, -0.012732707895338535, 0.09406698495149612, -0.012152484618127346, 0.015354732051491737, -0.04812474176287651, 0.04321274906396866, -0.09395525604486465, 0.021503234282135963, -0.055565379559993744, -0.004470344632863998, 0.022735416889190674, -0.0032915188930928707, 0.014290716499090195, 0.015358570963144302, -0.06099836528301239, -0.016882002353668213, 0.09771449863910675, 0.04319369047880173, 0.026570158079266548, -0.08378870785236359, 0.0646292045712471, 0.018080979585647583, -0.024124406278133392, 0.029653025791049004, 0.02683473378419876, -0.024577662348747253, -0.0617540143430233, -0.0810004398226738, -0.03653974458575249, 0.015921780839562416, 0.004816869739443064, -0.05992823466658592, -0.0007000932237133384, -0.013942783698439598, -0.011211280710995197, 0.034695301204919815, 0.03573808819055557, 0.08713922649621964, 0.02270798571407795, 0.0037864509504288435, -0.0760941281914711, -0.001343538286164403, 0.030518148094415665, 0.06009199097752571, 0.07763791084289551, 0.05419256538152695, 0.08818338811397552, -0.030528321862220764, -0.042954761534929276, -0.03810373321175575, 0.015725551173090935, -0.016180245205760002, 0.0372924841940403, 0.009434581734240055, -0.033339280635118484, -0.014252454042434692, -0.04516379162669182, 0.016338983550667763, 0.07501493394374847, -0.002739516319707036, -0.002679545199498534, 0.08105006068944931, -0.06998474150896072, 0.07695294916629791, -0.04845637083053589, -0.041151128709316254, 0.0654093325138092, -0.044631924480199814, 0.02894352562725544, -0.018075551837682724, -0.0914679765701294, -0.03449995070695877, -0.01623273827135563, 0.006735080853104591, -0.009811481460928917, 0.002750688698142767, -0.07811387628316879, 0.07186674326658249, 0.08486276119947433, 0.0018899653805419803, -0.0967654138803482, 0.07693027704954147, -0.0291006937623024, 0.02060830406844616, 0.032838381826877594, -0.03404943272471428, -0.06717744469642639, 0.05630182847380638, -0.055840082466602325, 0.07269895076751709, 0.0231443140655756, 0.03567390888929367, -0.005065246485173702, -0.016532177105545998, 0.04050789028406143, 0.02888873964548111, 0.06139097362756729, 0.05098680034279823, -0.08068563044071198, -0.028145838528871536, -0.08525637537240982, -0.057693853974342346, 0.04688892886042595, -0.041938211768865585, -0.05360421538352966, 0.04230629280209541, 0.09999406337738037, 0.041911862790584564, -0.0562450997531414, -0.014057367108762264, -0.06363555043935776, -0.0234181247651577, -0.03329513967037201, -0.017991425469517708, 0.009343753568828106, 0.08425888419151306, 0.028921594843268394, -0.05554637685418129, -0.04225942865014076, -0.009276596829295158, 0.03763953223824501, -0.014652999117970467, -0.04385099560022354, 0.013735379092395306, 0.03835897147655487, 0.035683419555425644, -0.005407659336924553, -0.03365805745124817, 0.04709874838590622, -0.04674115777015686, -0.013950328342616558, -0.04058500751852989, -0.020037267357110977, -0.018001025542616844, -0.03798343986272812, 0.02921169064939022, -0.014190913178026676, 0.029952162876725197, -0.004488695412874222, -0.017482509836554527, -0.016974540427327156, 0.02590569481253624, 0.008754389360547066, 0.012971809133887291, 0.027049729600548744, -0.022579604759812355, 0.000824898190330714, -0.021849073469638824, 0.006920138839632273, 0.02642664685845375, -0.004450363572686911, 0.006752603221684694, 0.0398588553071022, -0.0011688008671626449, -0.00005242681072559208, 0.0014942428097128868, -0.013711732812225819, -0.02359089069068432, 0.02507171966135502, 0.029544834047555923, 0.048068657517433167, 0.019253436475992203, -0.03886415809392929, -0.01774546690285206, 0.0389782190322876, 0.02098722569644451, -0.03158307820558548, 0.020316625013947487, 0.0075120944529771805, -0.004391442984342575, 0.0035633319057524204, 0.015005014836788177, 0.003955484367907047, -0.06864186376333237, 0.03174212574958801, 0.013344761915504932, 0.02323654666543007, -0.08849596977233887, -0.038671258836984634, 0.0365636982023716, -0.00025987974368035793, -0.054926659911870956, 0.008891673758625984, -0.0018497161800041795, 0.0073890057392418385, 0.020794983953237534, 0.0033051427453756332, 0.01603180170059204, 0.022003334015607834, 0.018236614763736725, 0.03624170646071434, -0.04715821519494057, -0.010446124710142612, 0.03993858024477959, -0.0016765333712100983, 0.01365194097161293, 0.01493138913065195, -0.061501387506723404, 0.024562399834394455, 0.016716523095965385, 0.017618516460061073, -0.005356286186724901, 0.027783073484897614, 0.04141276329755783, -0.007508908398449421, -0.0070995730347931385, -0.01413156371563673, -0.03896312788128853, -0.038795944303274155, 0.026936626061797142, 0.010480141267180443, -0.04737088829278946, 0.0037212681490927935, -0.026578914374113083, 0.005925138480961323, 0.020751411095261574, -0.013270844705402851, 0.0021536757703870535, 0.04539395868778229, 0.007067678961902857, -0.019224973395466805, 0.05568740516901016, -0.02006682939827442, -0.03806667774915695, -0.02977566421031952, -0.005352374166250229, -0.01771276444196701, -0.04078090563416481, 0.006584409158676863, 0.01726321130990982, 0.05645844712853432, 0.01937449537217617, 0.0038161631673574448, 0.0021975012496113777, 0.051447123289108276, 0.026722894981503487, -0.0637684166431427, -0.06900487840175629, -0.012463118880987167, -0.0007455248851329088, 0.002416065661236644, 0.006558998022228479, 0.03265059366822243, 0.03224635496735573, 0.010805445723235607, -0.007519816514104605, 0.014782408252358437, -0.014982625842094421, 0.010415807366371155, -0.03202959895133972, 0.0047017172910273075, -0.03952440619468689, -0.014225837774574757, -0.007392318919301033, 0.024162260815501213, 0.03254009038209915, 0.0187123641371727, -0.0271744467318058, -0.0034725896548479795, 0.0012807396706193686, -0.04393324628472328, -0.015437995083630085, 0.021768873557448387, -0.009586295112967491, -0.040976714342832565, 0.06286650896072388, 0.009276351891458035, 0.01360400766134262, -0.036831941455602646, 0.009295357391238213, -0.017962882295250893, -0.011783828027546406, 0.014791451394557953, -0.00012514223635662347, 0.024601833894848824, 0.026169611141085625, -0.01715032011270523, 0.008971364237368107, -0.06332080066204071, 0.0141378128901124, 0.016655931249260902, 0.03205464780330658, 0.03649121895432472, -0.051819585263729095, -0.037786610424518585, 0.023384638130664825, -0.02884245291352272, 0.020554697141051292, -0.04265876114368439, 0.010201225988566875, -0.010779778473079205, 0.05957815796136856, 0.06760315597057343, -0.023368213325738907, -0.029157275334000587, 0.0005436227656900883, 0.027936486527323723, -0.025941668078303337, 0.0167422853410244, -0.06298459321260452, -0.02539302408695221, 0.011623884551227093, -0.009098773822188377, -0.0034142902586609125, 0.019601117819547653, 0.004602033644914627, 0.02131829224526882, -0.02349247969686985, -0.018158873543143272, 0.02836405299603939, -0.0005511639756150544, 0.013670286163687706, -0.0032184836454689503, -0.05106835439801216, 0.001178412581793964, 0.008554115891456604, -0.013520482927560806, -0.02681676857173443, 0.01240162830799818, 0.0359794907271862, 0.021361973136663437, 0.04428117349743843, 0.02534627728164196, -0.03154191002249718, 0.010319463908672333, -0.04833774268627167, 0.050550125539302826, 0.03336632251739502, 0.02747242897748947, -0.04359517991542816, 0.04879852756857872, 0.02844509296119213, -0.029536278918385506, -0.012804489582777023, -0.00979763176292181, 0.003775669727474451, 0.007782686036080122, 0.01448991522192955, 0.0239874180406332, -0.008319946005940437, 0.01246776431798935, -0.0028010569512844086, -0.016323840245604515, 0.02164420299232006, -0.10005927085876465, -0.02171524241566658, 0.023449614644050598, -0.00005573995440499857, 0.0282895490527153, 0.015552845783531666, -0.04798964783549309, -0.004053645767271519, 0.03918246924877167, 0.02093004621565342, -0.004455594811588526, -0.03592050448060036, 0.007441009394824505, -0.012050998397171497, -0.019230389967560768, 0.028474219143390656, 0.011476400308310986, -0.019604792818427086, 0.01397177018225193, 0.00839638989418745, 0.020150043070316315, -0.0028686942532658577, 0.009173059836030006, -0.0007969955331645906, -0.006312755402177572, 0.04252319037914276, -0.02134806476533413, -0.02952871099114418, -0.032628133893013, -0.010872343555092812, -0.0008823176613077521, 0.009194028563797474, -0.032415591180324554, -0.0008716362644918263, 0.06188368424773216, -0.01247086189687252, -0.008816440589725971, 0.024158744141459465, 0.0225532203912735, -0.019212279468774796, -0.0067963628098368645, -0.020849641412496567, -0.015116928145289421, 0.03688201308250427, -0.002268977230414748, -0.0005413854960352182, -0.026499342173337936, -0.03741149604320526, -0.013624828308820724, -0.07232390344142914, 0.014142392203211784, -0.008372437208890915, 0.014089866541326046, 0.018037816509604454, -0.011007765308022499, -0.011011884547770023, -0.01116534136235714, 0.0031424076296389103, -0.05278612673282623, 0.02178584411740303, 0.008591984398663044, 0.022158725187182426, 0.03408181294798851, -0.0025055697187781334, -0.015588244423270226, 0.008770055137574673, 0.017423441633582115, 0.02209722250699997, -0.00947702769190073, -0.028912078589200974, 0.03339773789048195, 0.022366059944033623, -0.040696654468774796, -0.020620716735720634, -0.031423382461071014, -0.042557988315820694, 0.06636322289705276, -0.016277717426419258, -0.002447795355692506, 0.05588535591959953, -0.01942620798945427, 0.029627421870827675, 0.011127694509923458, -0.0038727656938135624, 0.03262021765112877, 0.02150002494454384, -0.019610749557614326, 0.013404134660959244, -0.010386421345174313, 0.02555193193256855, -0.008769121021032333, -0.004576981067657471, 0.05577191337943077, 0.0012296155327931046, -0.05886228755116463, 0.01788153499364853, 0.0026899653021246195, -0.0014895573258399963, 0.008620381355285645, -0.030318832024931908, -0.027410287410020828, -0.04355641454458237, 0.05923760309815407, 0.02416600100696087, 0.03469104692339897, -0.024325529113411903, -0.004963768646121025, 0.008152984082698822, -0.028498027473688126, 0.02016100101172924, 0.042846959084272385, -0.03829755634069443, 0.03010871633887291, -0.0016108171548694372, 0.013731459155678749, 0.035102374851703644, -0.0037020123563706875, -0.02804778702557087, -0.04017535224556923, 0.08189695328474045, 0.006103424821048975, 0.015856048092246056, 0.01566358655691147, 0.022897593677043915, 0.00569320609793067, -0.023727761581540108, -0.04885094240307808, -0.008787392638623714, 0.028571512550115585, 0.011046696454286575, -0.019799472764134407, -0.0016912597930058837, -0.0054175942204892635, 0.056371524930000305, 0.05694163218140602, 0.019743643701076508, -0.01745292916893959, 0.04172736406326294, 0.018214436247944832, 0.005512523930519819, 0.03381114453077316, -0.01975294202566147, 0.005825301166623831, -0.015125598758459091, 0.06571059674024582, 0.024507686495780945, 0.024922732263803482, 0.06399060785770416, 0.017418356612324715, 0.049496278166770935, 0.01533719152212143, -0.0705457404255867, -0.004312372766435146, 0.023851877078413963, -0.023658376187086105, -0.04407734423875809, 0.004530272446572781, -0.06387312710285187, 0.048682279884815216, -0.05898752808570862, -0.021504554897546768, 0.014632743783295155, -0.0038817739114165306, -0.03663019463419914, 0.04127154126763344, -0.03745783492922783, 0.0059346649795770645, 0.018048634752631187, 0.007919873110949993, 0.011701737530529499, -0.016877779737114906, -0.017315834760665894, -0.02296021580696106, 0.00854164082556963, -0.0067407540045678616, -0.014317394234240055, 0.023212367668747902, -0.0252876915037632, 0.007903311401605606, -0.011896772310137749, -0.01068920362740755, -0.00044143080594949424, 0.007173044141381979, -0.007208012510091066, 0.004772897809743881, -0.0463455468416214, 0.05548965185880661, 0.00804195087403059, -0.02255862206220627, -0.006504567805677652, -0.02487061358988285, -0.009260074235498905, -0.005404890514910221, 0.031079888343811035, 0.002159922616556287, 0.028285015374422073, 0.00152301206253469, -0.07872162759304047, -0.03527883440256119, -0.06221243366599083, -0.009975764900445938, 0.043808307498693466, 0.0030492793302983046, 0.042119260877370834, 0.02085261419415474, 0.01799827814102173, -0.0035352108534425497, 0.01569221168756485, -0.00524444505572319, 0.03262456879019737, -0.047334495931863785, -0.03501657396554947, -0.013121037743985653, 0.023127106949687004, 0.06414257735013962, 0.00860633235424757, 0.03267080709338188, -0.012177649885416031, 0.02858506143093109, -0.012335649691522121, 0.0409042052924633, -0.03224172443151474, 0.0034933241549879313, -0.058638717979192734, -0.00711285974830389, -0.025321325287222862, -0.01588616706430912, -0.02441372349858284, 0.04329059645533562, -0.032482534646987915, -0.00874157901853323, -0.029288528487086296, -0.012671273201704025, -0.013969650492072105, -0.0014649982331320643, 0.02931165136396885, 0.069358229637146, -0.004814013373106718, 0.009666015394032001, -0.02268947660923004, 0.0019207242876291275, 0.03077102079987526, -0.016209585592150688, 0.021159162744879723, -0.04359392076730728, 0.0033294109161943197, 0.0010009069228544831, -0.0025194480549544096, -0.0012626148527488112, -0.04482074826955795, 0.0062028816901147366, -0.002865127520635724, -0.03638399764895439, -0.019338486716151237, 0.0121320690959692, 0.018857773393392563, 0.0339805968105793, 0.032809287309646606, -0.021129611879587173, -0.005635582376271486, -0.006785613019019365, 0.016611728817224503, -0.054469186812639236, 0.02954803965985775, -0.03669502213597298, 0.0169733464717865, 0.006962273735553026, 0.027647707611322403, 0.025923147797584534, 0.01701860874891281, -0.037622831761837006, 0.019673924893140793, 0.007934561930596828, -0.053564589470624924, -0.035912130028009415, -0.02336079254746437, 0.0659237653017044, -0.021923018619418144, -0.06914778053760529, 0.016592368483543396, -0.02651181071996689, 0.001067837467417121, -0.005797095596790314, -0.022280097007751465, 0.009276227094233036, -0.013376896269619465, -0.032449763268232346, -0.020734835416078568, 0.03432660922408104, 0.0020504118874669075, 0.008484489284455776, -0.014470339752733707, 0.026063421741127968 ]
Fine-Tune ViT for Image Classification with 🤗 Transformers
nateraw
February 11, 2022
fine-tune-vit
guide, cv
https://huggingface.co/blog/fine-tune-vit
Load a dataset Let's start by loading a small image classification dataset and taking a look at its structure. We'll use the beans dataset, which is a collection of pictures of healthy and unhealthy bean leaves. 🍃 python from datasets import load_dataset ds = load_dataset('beans') ds Let's take a look at the 400th example from the 'train' split from the beans dataset. You'll notice each example from the dataset has 3 features: 1. image: A PIL Image 1. image_file_path: The str path to the image file that was loaded as image 1. labels: A datasets.ClassLabel feature, which is an integer representation of the label. (Later you'll see how to get the string class names, don't worry!) python ex = ds['train'][400] ex { 'image': , 'image_file_path': '/root/.cache/.../bean_rust_train.4.jpg', 'labels': 1 } Let's take a look at the image 👀 python image = ex['image'] image That's definitely a leaf! But what kind? 😅 Since the 'labels' feature of this dataset is a datasets.features.ClassLabel, we can use it to look up the corresponding name for this example's label ID. First, let's access the feature definition for the 'labels'. python labels = ds['train'].features['labels'] labels ClassLabel(num_classes=3, names=['angular_leaf_spot', 'bean_rust', 'healthy'], names_file=None, id=None) Now, let's print out the class label for our example. You can do that by using the int2str function of ClassLabel, which, as the name implies, allows to pass the integer representation of the class to look up the string label. python labels.int2str(ex['labels']) 'bean_rust' Turns out the leaf shown above is infected with Bean Rust, a serious disease in bean plants. 😢 Let's write a function that'll display a grid of examples from each class to get a better idea of what you're working with. python import random from PIL import ImageDraw, ImageFont, Image def show_examples(ds, seed: int = 1234, examples_per_class: int = 3, size=(350, 350)): w, h = size labels = ds['train'].features['labels'].names grid = Image.new('RGB', size=(examples_per_class * w, len(labels) * h)) draw = ImageDraw.Draw(grid) font = ImageFont.truetype("/usr/share/fonts/truetype/liberation/LiberationMono-Bold.ttf", 24) for label_id, label in enumerate(labels): # Filter the dataset by a single label, shuffle it, and grab a few samples ds_slice = ds['train'].filter(lambda ex: ex['labels'] == label_id).shuffle(seed).select(range(examples_per_class)) # Plot this label's examples along a row for i, example in enumerate(ds_slice): image = example['image'] idx = examples_per_class * label_id + i box = (idx % examples_per_class * w, idx // examples_per_class * h) grid.paste(image.resize(size), box=box) draw.text(box, label, (255, 255, 255), font=font) return grid show_examples(ds, seed=random.randint(0, 1337), examples_per_class=3) A grid of a few examples from each class in the dataset From what I'm seeing, - Angular Leaf Spot: Has irregular brown patches - Bean Rust: Has circular brown spots surrounded with a white-ish yellow ring - Healthy: ...looks healthy. 🤷‍♂️
[ 0.037896931171417236, -0.051015403121709824, -0.10068104416131973, 0.012810450978577137, 0.07294155657291412, 0.08941641449928284, 0.02318587526679039, 0.05768047645688057, -0.05558124557137489, -0.03079346753656864, -0.05664343759417534, 0.03312116861343384, -0.08699065446853638, 0.044712960720062256, 0.02848343551158905, -0.017473768442869186, 0.050769492983818054, -0.01150748785585165, -0.009352047927677631, 0.10717261582612991, -0.02697904035449028, -0.07178881019353867, 0.015521157532930374, 0.0010261854622513056, 0.0015406967140734196, 0.03394652158021927, -0.005881010554730892, 0.024744752794504166, -0.03723739832639694, 0.009463291615247726, -0.13383270800113678, 0.004044865258038044, -0.007605281192809343, -0.01912466250360012, -0.03116604872047901, 0.02161060832440853, -0.04717334359884262, 0.03786098584532738, 0.060261890292167664, -0.10857638716697693, -0.014553544111549854, -0.000046233213652158156, -0.013237941078841686, 0.052217997610569, 0.006281040143221617, -0.04295358806848526, -0.13448530435562134, 0.09139259904623032, 0.031099271029233932, -0.01944144256412983, -0.049674537032842636, 0.03445721045136452, -0.011799771338701248, -0.038823798298835754, 0.0003541451587807387, -0.010784181766211987, 0.023380128666758537, -0.05031634494662285, 0.036637116223573685, 0.034394729882478714, 0.01876412145793438, 0.07417278736829758, 0.011765175499022007, 0.031023411080241203, 0.05792376771569252, 0.021995514631271362, -0.04313116893172264, 0.07228704541921616, -0.03476684167981148, -0.08577307313680649, 0.024558281525969505, -0.017881382256746292, -0.039615944027900696, -0.06142526865005493, 0.026461360976099968, -0.06123259291052818, -0.029269298538565636, 0.003201662329956889, 0.01926412805914879, 0.04274330660700798, 0.009144934825599194, 0.02771449275314808, 0.05429357290267944, -0.02811085805296898, 0.07845058292150497, -0.03956656530499458, -0.005133581813424826, -0.05379683896899223, -0.03949371725320816, 0.023197175934910774, 0.022082418203353882, -0.05770035833120346, -0.02632095292210579, -0.011672413907945156, 0.04434965178370476, -0.09150353074073792, 0.006428925786167383, 0.03731114789843559, 0.0846308022737503, 0.013157249428331852, -0.018257757648825645, -0.047213971614837646, 0.07971088588237762, -0.03870800510048866, -0.07609595358371735, 0.0677294060587883, -0.053503312170505524, -0.07611032575368881, -0.05574284493923187, -0.027970202267169952, -0.03367852419614792, 0.02402433753013611, -0.04680662974715233, 0.09844601154327393, -0.013897103257477283, -0.027684219181537628, 0.005456412676721811, 0.02334291860461235, -0.0061326418071985245, 0.030494768172502518, -0.05184061825275421, 0.047392576932907104, 0.03952910006046295, 0.016909494996070862, -0.0071119945496320724, 0.05254824459552765, -0.006677685305476189, 0.04431120678782463, 0.03465881571173668, 0.032689694315195084, 0.044604528695344925, 0.020791947841644287, 0.06521796435117722, 0.02449820190668106, 0.007168138865381479, -0.04161714389920235, -0.08067135512828827, 0.019591988995671272, 0.025385575369000435, 0.05586550384759903, -0.016172081232070923, 0.03441356495022774, 0.028742695227265358, 0.0354144424200058, 0.04699506610631943, 0.01043215487152338, 0.002533361781388521, -0.0009192134020850062, 0.050168056041002274, -0.007032081950455904, -0.07917231321334839, 0.061175327748060226, 0.05583616718649864, -0.07142070680856705, -0.03136036545038223, 0.0574561282992363, -0.015411353670060635, 0.0064286841079592705, -0.05132818594574928, 0.009030766785144806, 0.023432932794094086, -0.007630682550370693, -0.03638505935668945, 0.02236071228981018, 0.05428920313715935, -0.02347882278263569, 0.023592032492160797, -0.00960418488830328, 0.06064208969473839, -0.09287194162607193, -0.04909893870353699, -0.08936528116464615, -0.006929505616426468, 0.060517121106386185, 0.01687547005712986, -0.030787015333771706, 0.004376621916890144, -0.030377309769392014, 0.0004643939028028399, -0.0527348518371582, -0.04789172485470772, -0.016450120136141777, 0.0016817370196804404, -0.02130519598722458, 0.03793329373002052, -0.005678615532815456, 0.03125210106372833, -0.055651720613241196, 0.05374036356806755, 0.05222078785300255, -0.07098691165447235, -0.02256918139755726, 0.022737417370080948, -0.07950963824987411, 0.05018489435315132, -0.056247830390930176, -0.03227728232741356, 0.07024164497852325, -0.035167157649993896, 0.00034945557126775384, 0.009179181419312954, -0.04328041151165962, 0.009290879592299461, -0.05393679067492485, 0.07629816234111786, -0.015437353402376175, -0.01652783900499344, -0.06354082375764847, 0.0675656870007515, 0.0034769948106259108, -0.014672999270260334, -0.10907318443059921, 0.06258882582187653, -0.039202719926834106, 0.012518088333308697, 0.04538174718618393, 0.01864997111260891, 0.005249274428933859, 0.0333949513733387, -0.013608171604573727, 0.13258884847164154, 0.004946824628859758, 0.03243962675333023, -0.003934326581656933, -0.022169677540659904, 0.03219297155737877, 0.09832750260829926, 0.0581883043050766, 0.08139867335557938, -0.1660972237586975, -0.04571612924337387, -0.025966959074139595, -0.010347248055040836, 0.0317278616130352, -0.05393426492810249, 0.03876977786421776, 0.04078507795929909, 0.05442668870091438, 0.03755670413374901, 0.0130868935957551, 0.0055203731171786785, -0.04387578368186951, -0.06283781677484512, -0.003761440748348832, -0.029573693871498108, -0.0661626085639, 0.06120629608631134, -0.02529161423444748, -0.05168182775378227, -0.044212955981492996, 0.017194248735904694, -0.007945595309138298, -0.024549953639507294, -0.02919846959412098, -0.009102726355195045, 0.007801609579473734, -0.01534905657172203, -0.049193039536476135, 0.03331609070301056, 0.05941038578748703, -0.011565247550606728, -0.027871128171682358, -0.05801529437303543, -0.04041698947548866, -0.021227240562438965, -0.014424322172999382, 0.003833313938230276, 0.027217304334044456, 0.07284325361251831, 0.006616758648306131, -0.0034034145064651966, 0.0009833782678470016, 0.03601540997624397, 0.008283725008368492, 0.029659200459718704, 0.020687371492385864, -0.0024479259736835957, -0.0007008684333413839, 0.004575998988002539, -0.0045425258576869965, -0.023618927225470543, -0.03788434714078903, 0.0441519133746624, 0.014257384464144707, 0.01829717308282852, -0.06333202123641968, 0.008354120887815952, -0.03185851126909256, 0.01042985264211893, 0.038753293454647064, 0.016668444499373436, 0.046946171671152115, -0.024837860837578773, -0.023423194885253906, 0.04446594789624214, -0.0008225056808441877, -0.01249819528311491, 0.002694251947104931, 0.026852184906601906, 0.008414584212005138, 0.011833061464130878, -0.00492026237770915, -0.007314818445593119, -0.0072166044265031815, -0.008570179343223572, 0.05003295838832855, 0.02444942109286785, 0.02014533430337906, -0.09124164283275604, 0.008350910618901253, 0.0240298043936491, -0.046868305653333664, 0.0029880949296057224, -0.00434227054938674, 0.0901060625910759, 0.004640325903892517, 0.0067727998830378056, 0.05463380739092827, -0.0023505601566284895, 0.014383077621459961, 0.016305360943078995, 0.009494384750723839, 0.028659384697675705, 0.020149506628513336, 0.0140695096924901, 0.019792282953858376, 0.00437468197196722, -0.021581046283245087, -0.052440937608480453, 0.026841364800930023, -0.004407638218253851, 0.040756337344646454, -0.026637280359864235, 0.024628896266222, 0.023985696956515312, 0.025102268904447556, 0.003951646853238344, -0.015078132040798664, -0.007988040335476398, -0.009449063800275326, -0.033499009907245636, -0.019881192594766617, -0.012234335765242577, -0.040788907557725906, -0.025020845234394073, -0.01031807716935873, -0.014735495671629906, -0.026639284566044807, -0.0502958670258522, 0.04354388266801834, 0.019518567249178886, -0.0056016226299107075, 0.014960006810724735, -0.026304373517632484, -0.02726135402917862, -0.04064934328198433, -0.026841748505830765, -0.04319091513752937, -0.030917374417185783, -0.0007198615348897874, 0.01972644403576851, 0.05501954257488251, -0.06227555498480797, -0.011943623423576355, 0.01033989991992712, 0.0074714007787406445, -0.012927309609949589, -0.02206479199230671, -0.029865145683288574, 0.03648785501718521, 0.032232511788606644, -0.03127051889896393, -0.0037858854047954082, 0.016265427693724632, 0.004910717718303204, 0.043400444090366364, 0.005344940349459648, 0.029924925416707993, -0.03684299811720848, -0.009050118736922741, 0.027568573132157326, 0.00599244236946106, 0.0074722906574606895, -0.004117670934647322, -0.04525934159755707, -0.03802613541483879, 0.04013592749834061, 0.06445780396461487, -0.009132287465035915, -0.04401377588510513, 0.0034069844987243414, -0.009444384835660458, -0.0015670000575482845, 0.008547046221792698, 0.000051231276302132756, -0.0677880197763443, 0.055944643914699554, 0.007079334929585457, -0.0025911100674420595, -0.026158619672060013, 0.009514931589365005, 0.01049374882131815, -0.011640532873570919, -0.0019509629346430302, 0.038194939494132996, -0.0018944236217066646, -0.014881507493555546, -0.03244073688983917, 0.01845967210829258, 0.008345992304384708, -0.0044118743389844894, 0.021922040730714798, 0.0003292751789558679, -0.018672745674848557, -0.012172002345323563, -0.011215678416192532, 0.025563647970557213, -0.028788698837161064, 0.01137961819767952, -0.020601632073521614, -0.003210013499483466, -0.012784289196133614, -0.00786433182656765, 0.03253473341464996, 0.0028899223543703556, -0.0386127233505249, 0.024152573198080063, 0.01974773034453392, -0.02553505264222622, 0.00963226892054081, -0.021705428138375282, -0.018071606755256653, -0.012659489177167416, -0.047295331954956055, 0.04614236578345299, -0.03177769109606743, -0.00821958389133215, -0.05568620562553406, -0.00706077553331852, -0.02787589840590954, -0.02222231589257717, 0.0010062417713925242, 0.0038524100091308355, -0.03256184607744217, -0.012471911497414112, 0.030893130227923393, 0.015781616792082787, -0.019110171124339104, -0.0304938443005085, -0.02913769707083702, 0.013196871615946293, -0.015492725186049938, 0.005617831833660603, 0.016751604154706, -0.04010139778256416, 0.015652969479560852, 0.011012067086994648, -0.011426555924117565, 0.0366995669901371, 0.026129139587283134, -0.03109722025692463, 0.02496630884706974, 0.05319291353225708, 0.005263707134872675, 0.04212252050638199, -0.02003985270857811, -0.004713012836873531, 0.016852112486958504, 0.004736003000289202, -0.016698110848665237, -0.018326537683606148, -0.01587078534066677, -0.02020607516169548, 0.034651510417461395, 0.04488009959459305, -0.04037143290042877, 0.01659059338271618, 0.011452056467533112, -0.0360872708261013, 0.0035825453232973814, 0.01889491267502308, -0.05062892287969589, 0.0016097543993964791, 0.015521932393312454, 0.009667357429862022, 0.03020629659295082, -0.022370342165231705, -0.010962394997477531, -0.031983938068151474, -0.014616202563047409, 0.04705872759222984, 0.03035484440624714, 0.008052627556025982, 0.007160915993154049, 0.006515964865684509, 0.04156505689024925, 0.0019602866377681494, 0.004285478964447975, 0.001764160580933094, -0.014571021310985088, 0.030782653018832207, -0.028727056458592415, -0.0037178576458245516, -0.002282150322571397, -0.00031266192672774196, -0.006585060153156519, 0.014688502065837383, -0.05889520049095154, 0.004919803701341152, 0.06500528007745743, 0.0071438634768128395, -0.034363143146038055, -0.007519595790654421, -0.0035008324775844812, -0.010404985398054123, -0.004555053543299437, 0.008365093730390072, -0.05627882480621338, 0.032480619847774506, -0.059236399829387665, -0.023734040558338165, -0.002536923158913851, 0.01402989961206913, 0.013035442680120468, -0.005076167173683643, -0.0024034783709794283, -0.012788284569978714, -0.0074880970641970634, -0.00466769328340888, -0.012124588713049889, 0.0278785303235054, 0.018167993053793907, 0.006153018679469824, -0.03817969560623169, 0.0011124375741928816, 0.019322438165545464, 0.031019404530525208, 0.06017937883734703, 0.03587190434336662, -0.011523295193910599, 0.018541639670729637, 0.04482218623161316, -0.010209755040705204, -0.032824136316776276, -0.007011338137090206, 0.061358191072940826, 0.060063961893320084, -0.03693153336644173, -0.02504594996571541, 0.02762170135974884, 0.006036166567355394, 0.029478834941983223, 0.016302738338708878, -0.007549515925347805, 0.08048788458108902, -0.016560513526201248, 0.033758264034986496, -0.024864835664629936, 0.015147073194384575, 0.0064416141249239445, 0.01657458208501339, -0.0011005762498825788, 0.017862804234027863, 0.011257420293986797, 0.036677516996860504, -0.019281813874840736, 0.007292202208191156, 0.038090772926807404, -0.0036412146873772144, -0.040380604565143585, 0.028961826115846634, 0.016442906111478806, -0.00295747141353786, -0.015787597745656967, 0.02582651376724243, -0.06780556589365005, 0.016247913241386414, 0.005883215926587582, 0.04009852558374405, 0.049628984183073044, -0.0191897414624691, 0.03026391752064228, 0.016654115170240402, 0.006722923833876848, -0.02744426392018795, 0.06771139055490494, -0.042923953384160995, 0.034296054393053055, 0.01449284702539444, -0.007982891984283924, 0.024114632979035378, -0.005274655297398567, 0.025666970759630203, -0.024120507761836052, 0.03642663732171059, -0.00717849750071764, 0.007909078150987625, 0.01529060211032629, 0.026524361222982407, -0.015309702605009079, -0.040506064891815186, -0.001316022127866745, -0.0059374128468334675, 0.049321066588163376, 0.027696684002876282, -0.00019284557492937893, 0.011961261741816998, -0.0497988760471344, 0.02975616231560707, 0.04004989564418793, 0.04067070782184601, 0.005150836426764727, -0.020830947905778885, 0.035899970680475235, 0.03021053411066532, -0.016891280189156532, 0.027959946542978287, 0.00883276853710413, -0.028050918132066727, 0.06039441376924515, 0.012546272948384285, -0.025989875197410583, 0.07660871744155884, 0.024730989709496498, 0.015264218673110008, -0.02811705507338047, -0.040549058467149734, 0.04904436692595482, -0.013552025891840458, -0.041845399886369705, -0.010173636488616467, -0.030986793339252472, -0.03436184674501419, 0.013576949015259743, -0.04825711250305176, -0.0400257408618927, -0.032045118510723114, -0.02903576008975506, 0.004726250655949116, 0.014366470277309418, 0.004898484796285629, 0.0023783231154084206, -0.013737034983932972, 0.053237851709127426, 0.02882429026067257, 0.04332120716571808, 0.017395518720149994, -0.019056977704167366, -0.03573322668671608, -0.001277825445868075, 0.0292739886790514, 0.02724950574338436, -0.006759021896868944, -0.010009839199483395, -0.026071174070239067, -0.014399836771190166, 0.010208218358457088, 0.041080549359321594, -0.0028122738003730774, 0.04667969420552254, 0.017362821847200394, 0.03234080597758293, -0.03424995392560959, -0.02890710160136223, -0.010152623057365417, -0.033465415239334106, 0.025104032829403877, -0.01715858280658722, 0.03546252101659775, -0.006059472449123859, -0.0026748566888272762, 0.022212183102965355, -0.05508945882320404, 0.015655340626835823, -0.009858919307589531, -0.04894590750336647, 0.040102582424879074, -0.016292471438646317, 0.006254064850509167, 0.0303912702947855, 0.01950010657310486, -0.000018101449313689955, -0.0063461135141551495, -0.018562352284789085, 0.030936503782868385, -0.021301474422216415, -0.008433566428720951, 0.02607888914644718, 0.044997308403253555, -0.004418388940393925, 0.019112413749098778, -0.0092710480093956, 0.04292770102620125, -0.04815293475985527, 0.013170897960662842, 0.06550143659114838, 0.006335169076919556, 0.030421357601881027, -0.026282567530870438, -0.048516418784856796, -0.05816198140382767, -0.028470508754253387, -0.034519046545028687, 0.02304448001086712, -0.051873259246349335, 0.0073151299729943275, -0.007778235245496035, 0.012246678583323956, -0.024206992238759995, -0.02878054790198803, 0.03558981791138649, 0.030929138883948326, 0.015234352089464664, 0.0526428259909153, -0.04992111399769783, 0.03241081163287163, -0.02317935973405838, 0.061793118715286255, 0.04990043863654137, -0.0012882075970992446, -0.019651249051094055, -0.02924213744699955, 0.01068273838609457, -0.025696519762277603, -0.028058640658855438, 0.024433162063360214, 0.02464916557073593, 0.010552153922617435, -0.04372580721974373, -0.0022700438275933266, 0.04457052797079086, 0.013456152752041817, -0.010170693509280682, -0.04147036746144295, -0.007792091462761164, 0.008017690852284431, 0.010551846586167812, -0.05222737416625023, 0.0361688956618309, -0.027179988101124763, -0.010871286503970623, -0.014153135009109974, -0.016887258738279343, 0.024294551461935043, 0.01666274294257164, -0.01151252817362547, 0.02090458944439888, 0.027348536998033524, -0.010292754508554935, -0.02729099988937378, -0.019201789051294327, 0.03741984814405441, -0.02598499320447445, 0.027419548481702805, 0.009977003559470177, 0.01488075964152813, -0.0045566074550151825, 0.029953330755233765, 0.004555195569992065, 0.014145693741738796, -0.00981863308697939, 0.017935406416654587, -0.003992356825619936, 0.06988010555505753, 0.00812256895005703, -0.013209402561187744, -0.024911699816584587, 0.04024456813931465 ]
Fine-Tune ViT for Image Classification with 🤗 Transformers
nateraw
February 11, 2022
fine-tune-vit
guide, cv
https://huggingface.co/blog/fine-tune-vit
Train 🚀 python train_results = trainer.train() trainer.save_model() trainer.log_metrics("train", train_results.metrics) trainer.save_metrics("train", train_results.metrics) trainer.save_state()
[ 0.013735661283135414, -0.005115268286317587, 0.021868839859962463, -0.04982494190335274, 0.05430617555975914, 0.03233760595321655, 0.062234848737716675, -0.03107115998864174, -0.07340707629919052, -0.015817999839782715, -0.04120367020368576, 0.050723519176244736, -0.01698492094874382, 0.035167135298252106, -0.010090113617479801, -0.0231291726231575, 0.029250070452690125, -0.016757821664214134, 0.030599448829889297, 0.04294683039188385, -0.03657906875014305, -0.030467703938484192, 0.006636312231421471, -0.03697703778743744, 0.04159260541200638, -0.007240242790430784, 0.007678614463657141, 0.045517709106206894, -0.08013520389795303, 0.04777582362294197, -0.052435584366321564, 0.00578391132876277, -0.024464838206768036, 0.005651458166539669, 0.014552246779203415, 0.02780264802277088, -0.08023879677057266, 0.029287252575159073, 0.02893310971558094, -0.0749090239405632, -0.035941071808338165, -0.003185498993843794, -0.07604984194040298, 0.026688454672694206, 0.01651586964726448, -0.030066411942243576, -0.21100378036499023, 0.003944826778024435, 0.0877336785197258, -0.056255634874105453, -0.09640741348266602, 0.061388447880744934, 0.03182287886738777, 0.033358681946992874, -0.06870751082897186, -0.0013494747690856457, 0.014068739488720894, -0.03132710978388786, -0.033373694866895676, 0.023528864607214928, 0.011090939864516258, 0.04387570172548294, 0.020642729476094246, 0.05764321982860565, 0.05135831609368324, 0.031405411660671234, 0.05476813390851021, 0.010031940415501595, -0.014855585992336273, -0.05093349516391754, -0.03004201501607895, -0.04727185517549515, -0.019972465932369232, -0.01650301180779934, -0.0010029739933088422, -0.05358339846134186, -0.008431078866124153, -0.0071228016167879105, 0.06485030800104141, 0.03793096914887428, 0.029896223917603493, -0.01737704686820507, 0.0036914648953825235, 0.008561813272535801, 0.047891099005937576, -0.022846989333629608, 0.030306506901979446, -0.08169995993375778, -0.010863658040761948, 0.06522665172815323, -0.0463678352534771, -0.07067598402500153, 0.006146796979010105, 0.011463978327810764, 0.031327564269304276, -0.05277770385146141, -0.007835039868950844, 0.0041604493744671345, 0.005629265680909157, 0.0035501744132488966, -0.008472458459436893, -0.07258399575948715, -0.01229787990450859, -0.011562484316527843, -0.002085240790620446, -0.041219312697649, -0.049544088542461395, -0.10146229714155197, -0.026790805160999298, 0.00593190873041749, -0.0571068599820137, 0.020870879292488098, -0.020047465339303017, 0.08095536381006241, -0.026917025446891785, 0.024934429675340652, -0.022574646398425102, 0.014703252352774143, -0.005140806548297405, 0.0025360966101288795, 0.008829575963318348, 0.08349741250276566, 0.10288713872432709, 0.02102048695087433, 0.042999912053346634, 0.05488522723317146, -0.006479889154434204, -0.0019367849454283714, 0.054354507476091385, 0.014970284886658192, -0.028629163280129433, 0.051916588097810745, 0.06888343393802643, 0.04648172855377197, -0.01097102090716362, -0.04748373106122017, -0.005710314493626356, -0.013263021595776081, -0.00949158612638712, 0.020183779299259186, -0.06655506044626236, 0.07189178466796875, -0.033963605761528015, 0.06561491638422012, 0.04992971196770668, 0.022293198853731155, -0.04468372091650963, 0.045693617314100266, 0.03817225247621536, 0.006208856590092182, -0.07500365376472473, 0.05505622923374176, -0.059986717998981476, -0.08069733530282974, -0.054199714213609695, 0.04251474142074585, 0.005536109209060669, 0.016407271847128868, -0.012080959975719452, 0.04165276512503624, 0.024505052715539932, 0.044287245720624924, -0.08685960620641708, 0.0050702812150120735, 0.08968095481395721, -0.04859070107340813, -0.002229307545349002, 0.033338405191898346, 0.01115658599883318, -0.06443806737661362, -0.011413800530135632, -0.06478260457515717, 0.07743526250123978, 0.03066571243107319, -0.047442082315683365, 0.046674396842718124, 0.01134917326271534, -0.007318856194615364, 0.026018060743808746, -0.013939707539975643, -0.01035077590495348, 0.053966641426086426, -0.06088002026081085, -0.014385531656444073, 0.07829860597848892, 0.0015519446460530162, 0.03401946276426315, -0.08331303298473358, 0.017050310969352722, 0.018265070393681526, -0.04958702623844147, -0.063499316573143, 0.04112296923995018, -0.033884983509778976, 0.044226400554180145, -0.10282738506793976, 0.011801298707723618, 0.07874390482902527, 0.0388847291469574, 0.02298142947256565, 0.00800052098929882, -0.009162302128970623, 0.022105049341917038, -0.013279380276799202, 0.033069103956222534, 0.07046067714691162, 0.005670257844030857, -0.0848986878991127, 0.014208382926881313, -0.030874105170369148, -0.04942876100540161, -0.04327515885233879, 0.08705640584230423, -0.13763365149497986, 0.022724391892552376, -0.011047088541090488, 0.004523002542555332, -0.00003048550024686847, 0.021661672741174698, -0.041459981352090836, 0.17173834145069122, -0.025846239179372787, 0.027738936245441437, 0.028111886233091354, -0.01037360355257988, 0.0797901302576065, 0.06923715770244598, 0.06544427573680878, 0.050846412777900696, -0.16270464658737183, -0.05635933205485344, -0.04183033108711243, -0.03810802102088928, 0.06855536252260208, 0.05821181833744049, -0.011166439391672611, 0.027047187089920044, -0.0029326064977794886, 0.01103026233613491, -0.03967680037021637, 0.004442134406417608, 0.024334220215678215, -0.019631575793027878, 0.030681198462843895, 0.01444706879556179, 0.007418031804263592, 0.05431303754448891, 0.024310041218996048, -0.09377867728471756, 0.0050839027389883995, -0.01891074888408184, -0.00427153380587697, 0.023304970934987068, -0.016816647723317146, 0.017635749652981758, -0.004240883514285088, -0.05079473927617073, -0.013970809988677502, -0.008763566613197327, 0.06628883630037308, 0.008724621497094631, -0.012577902525663376, 0.001670561614446342, -0.043508391827344894, 0.018769506365060806, -0.0029005343094468117, -0.017318561673164368, 0.007312997244298458, 0.024645432829856873, -0.017018629238009453, 0.0019030155381187797, -0.023709921166300774, 0.02674485184252262, 0.019188033416867256, 0.03427032381296158, 0.005815884098410606, 0.03692494332790375, -0.040446870028972626, 0.005833433009684086, 0.0046953922137618065, -0.00421912083402276, -0.05092768371105194, 0.012803587131202221, 0.02195143885910511, 0.02384675294160843, -0.017313063144683838, 0.01277359202504158, 0.011711910367012024, 0.004217670299112797, 0.03421758487820625, 0.012893126346170902, 0.03877830132842064, 0.020140953361988068, -0.028203092515468597, 0.0004014014557469636, 0.03338779881596565, 0.00001198462450702209, 0.017059551551938057, 0.058760132640600204, 0.006535368971526623, -0.018798908218741417, -0.001191863208077848, -0.004359348211437464, -0.006200213450938463, -0.02889750339090824, 0.012394336983561516, 0.007020254153758287, -0.029029548168182373, -0.1160418912768364, -0.008779030293226242, 0.020122582092881203, 0.027009209617972374, 0.01455334760248661, -0.007390480022877455, 0.04347756505012512, -0.013259903527796268, -0.029585663229227066, 0.03152456879615784, 0.013506787829101086, 0.004655446391552687, 0.023041151463985443, 0.012546459212899208, -0.007804877124726772, -0.026363814249634743, -0.03087797202169895, 0.007881135679781437, 0.03202898055315018, 0.05857786908745766, -0.02306259237229824, 0.047340039163827896, -0.0196883212774992, -0.011829284951090813, -0.028999298810958862, 0.014056713320314884, -0.005410941317677498, 0.04174249246716499, -0.010254661552608013, -0.03582299128174782, -0.011516368947923183, -0.029310809448361397, -0.07203484326601028, -0.015529220923781395, -0.00609401473775506, 0.017008433118462563, -0.02155878208577633, 0.020336924120783806, 0.044781219214200974, -0.011635501869022846, -0.038581136614084244, 0.03233668580651283, 0.027308311313390732, -0.0302960816770792, -0.04572232812643051, 0.023892058059573174, 0.01486856397241354, -0.005386680830270052, 0.026212390512228012, -0.035995230078697205, 0.015378352254629135, -0.020883549004793167, 0.008299961686134338, 0.07512427121400833, -0.027308890596032143, -0.012948685325682163, 0.019484786316752434, 0.010433505289256573, 0.00377625017426908, 0.005916513502597809, -0.04000921547412872, 0.0025479148607701063, 0.006163264159113169, -0.041594021022319794, -0.034222569316625595, 0.034100744873285294, 0.002540378598496318, 0.03155287355184555, -0.0061842272989451885, 0.07414187490940094, -0.06332609802484512, 0.007958578877151012, 0.00259741535410285, 0.026817001402378082, -0.03301924094557762, 0.015918979421257973, -0.011546778492629528, -0.02707575634121895, 0.08234751969575882, 0.02844833768904209, -0.027512220665812492, -0.046789538115262985, -0.0211323369294405, 0.0055690668523311615, -0.004521437920629978, 0.012392432428896427, -0.016229011118412018, -0.007977877743542194, 0.032496098428964615, 0.03432072326540947, 0.021548423916101456, -0.02058265544474125, 0.009479829110205173, -0.0003961100592277944, -0.029019761830568314, 0.03119170293211937, 0.03469221666455269, -0.023302584886550903, -0.01366423349827528, -0.009950440376996994, 0.020714838057756424, -0.02995767816901207, -0.013032169081270695, 0.04787469655275345, 0.04514700919389725, 0.02339331991970539, -0.0168120339512825, -0.02911362610757351, 0.02078142948448658, -0.021413223817944527, -0.011844445951282978, -0.046020109206438065, 0.003553148591890931, -0.025205811485648155, 0.013720419257879257, 0.03738956153392792, -0.029448945075273514, -0.0038862554356455803, 0.008171643130481243, 0.04458284750580788, -0.07715324312448502, 0.03581342473626137, 0.0031840200535953045, -0.029796306043863297, -0.02156861126422882, -0.028340214863419533, 0.050808489322662354, -0.03151924908161163, 0.02153346687555313, -0.001343011623248458, -0.06613597273826599, -0.012631800957024097, 0.022959303110837936, -0.00892794132232666, 0.024896318092942238, -0.03559204563498497, 0.020140187814831734, 0.022139249369502068, 0.022668492048978806, -0.035253848880529404, -0.004692336544394493, 0.005430800374597311, 0.04276445508003235, -0.06467197090387344, 0.005821630358695984, 0.017302479594945908, -0.056872133165597916, 0.015647491440176964, 0.010956061072647572, -0.003098921850323677, 0.02889854833483696, -0.03215060010552406, -0.051868170499801636, -0.024434445425868034, 0.02665676921606064, -0.012484010308980942, -0.029046205803751945, -0.0069825975224375725, -0.006131219677627087, 0.047562528401613235, -0.03595751151442528, -0.0730016827583313, 0.0011413657339289784, 0.01705090142786503, 0.014227940700948238, -0.025414763018488884, 0.016064267605543137, -0.02692337892949581, 0.036410585045814514, -0.007086769212037325, 0.013553216122090816, -0.028829073533415794, 0.01992250792682171, -0.02144578844308853, 0.019525378942489624, 0.03895794227719307, 0.03427110239863396, 0.03165249153971672, -0.03031071648001671, 0.01541356835514307, -0.01114874891936779, 0.01850285567343235, 0.027899783104658127, -0.007973314262926579, -0.02623067796230316, 0.01390653382986784, 0.04286463186144829, 0.0236318688839674, 0.007297184783965349, 0.05450112000107765, -0.02435777708888054, 0.0063753919675946236, 0.01937861181795597, -0.03307060897350311, -0.009046885184943676, 0.0014668995281681418, -0.007919793017208576, -0.005397598724812269, -0.026662128046154976, -0.051919545978307724, 0.02788340114057064, 0.05805053934454918, 0.035130105912685394, -0.022743113338947296, 0.008255548775196075, 0.012707192450761795, 0.014931468293070793, -0.015376148745417595, 0.03104165755212307, -0.02652747556567192, -0.004326243884861469, -0.056073885411024094, -0.01890062913298607, 0.012994909659028053, 0.011328954249620438, -0.017863040789961815, -0.023207778111100197, 0.02456391043961048, -0.017427392303943634, -0.00018602605268824846, 0.0008263876079581678, 0.004302219487726688, -0.02047933265566826, 0.0035968879237771034, 0.07269177585840225, -0.019140643998980522, 0.01979702152311802, 0.06849686801433563, 0.03277860954403877, 0.05316351354122162, 0.04230756312608719, -0.009227505885064602, 0.0063855405896902084, 0.0156504288315773, -0.004553551319986582, -0.0039768763817846775, -0.03545840084552765, 0.0713595598936081, 0.044638507068157196, -0.015470786020159721, -0.03601369634270668, 0.0425608791410923, -0.040266867727041245, 0.030954891815781593, 0.004930800758302212, 0.0215742364525795, 0.061959389597177505, -0.013991269282996655, 0.023395011201500893, -0.011915670707821846, 0.0011119586415588856, 0.025324003770947456, 0.024708403274416924, 0.032636113464832306, 0.02666969783604145, -0.003192043397575617, 0.016899095848202705, -0.01461880374699831, 0.00825943611562252, -0.005596202332526445, 0.029151126742362976, -0.008367751725018024, -0.0015569808892905712, -0.01380077749490738, 0.02907227911055088, 0.02493526227772236, -0.010978144593536854, -0.01802062802016735, 0.015221267007291317, 0.013706504367291927, 0.034253690391778946, 0.04861154034733772, 0.02060423046350479, 0.01704823225736618, 0.03313543274998665, 0.002717437921091914, -0.012813178822398186, 0.024148939177393913, -0.06310185045003891, 0.04720820486545563, 0.023820213973522186, 0.02187996730208397, 0.023830436170101166, 0.014315523207187653, -0.00041490240255370736, 0.0033646284136921167, 0.042908377945423126, 0.0006525297067128122, 0.024613335728645325, 0.03181522712111473, -0.014593127183616161, -0.004800575785338879, -0.021542217582464218, 0.02987569570541382, 0.0038860072381794453, 0.03818567097187042, 0.027037281543016434, 0.005770842079073191, 0.029114441946148872, -0.0317799374461174, 0.036482375115156174, 0.03241861239075661, -0.01600961573421955, -0.019432080909609795, -0.0041632275097072124, 0.07882945984601974, 0.014224773272871971, 0.015093068592250347, 0.032832901924848557, -0.0008850102894939482, -0.020993158221244812, 0.02724345587193966, 0.016858473420143127, -0.0024001612327992916, 0.027591537684202194, -0.007005617488175631, 0.01527077704668045, -0.03477637097239494, -0.018166638910770416, 0.023478448390960693, 0.004412793088704348, -0.026105055585503578, -0.014837781898677349, -0.007457508705556393, -0.051793213933706284, -0.028913872316479683, -0.01002862211316824, 0.02106960117816925, -0.01578005962073803, -0.009091833606362343, -0.010283009149134159, 0.031262002885341644, 0.023077767342329025, -0.02194858528673649, -0.018003180623054504, 0.030925847589969635, 0.029611777514219284, 0.07026047259569168, 0.011543610133230686, 0.0032596432138234377, -0.018458658829331398, -0.003885152516886592, -0.007055747322738171, 0.05617295578122139, -0.022435232996940613, 0.0004122577956877649, 0.009572903625667095, -0.0029733008705079556, -0.00620557414367795, 0.027383310720324516, -0.004947796929627657, 0.06992895156145096, -0.026741616427898407, -0.04206501320004463, -0.05207895487546921, -0.005430974066257477, 0.0395447239279747, 0.00031450027017854154, 0.002148620318621397, -0.001883268472738564, -0.00737551087513566, 0.01767853833734989, -0.020235532894730568, 0.019916852936148643, -0.023496519774198532, -0.020463917404413223, -0.0158386267721653, -0.004240216687321663, 0.008393656462430954, -0.0026439358480274677, -0.031008580699563026, 0.008009628392755985, 0.018555162474513054, -0.006194579880684614, -0.03297864645719528, -0.021127939224243164, 0.025107569992542267, -0.02097362093627453, 0.02412315458059311, 0.003363619092851877, 0.06884187459945679, 0.009687932208180428, -0.007152684964239597, -0.0003199832863174379, -0.0242912620306015, 0.003373152343556285, -0.03333534672856331, 0.017395561560988426, -0.004303320311009884, 0.00024170785036403686, 0.01330095436424017, -0.03718388453125954, -0.03709469363093376, -0.01686251536011696, -0.041552141308784485, -0.02320055104792118, -0.049825269728899, -0.017682120203971863, 0.025661664083600044, 0.018581917509436607, -0.026453595608472824, 0.032422371208667755, 0.03701107203960419, 0.04080218821763992, 0.005724110174924135, 0.018922578543424606, -0.042641546577215195, -0.01510636042803526, 0.02357255108654499, -0.004306981340050697, 0.023641588166356087, -0.0031332687940448523, -0.015202502720057964, -0.03155992925167084, 0.03222702071070671, -0.030671721324324608, -0.05343332886695862, -0.001978393876925111, -0.025917716324329376, -0.011367139406502247, -0.07562795281410217, -0.011970684863626957, 0.004761253017932177, 0.019047632813453674, 0.035329580307006836, -0.008947446942329407, -0.03790382668375969, -0.014862902462482452, 0.029425254091620445, -0.04098743200302124, -0.001244894228875637, -0.030552254989743233, -0.020860087126493454, 0.024654701352119446, 0.017322298139333725, -0.0062049804255366325, -0.005130815785378218, -0.0319783054292202, 0.00316267809830606, 0.003753812052309513, -0.01971256732940674, -0.05083461105823517, 0.011041776277124882, 0.022105740383267403, -0.028563203290104866, -0.03640341758728027, 0.01796090230345726, -0.005144862923771143, -0.06552234292030334, -0.03297843039035797, 0.016819585114717484, 0.05188137665390968, 0.017670273780822754, 0.007121193688362837, 0.022487400099635124, 0.02545209787786007, 0.0275418758392334, -0.043892793357372284, -0.00014183793973643333, 0.019063686951994896 ]
Fine-Tune ViT for Image Classification with 🤗 Transformers
nateraw
February 11, 2022
fine-tune-vit
guide, cv
https://huggingface.co/blog/fine-tune-vit
Define an evaluation metric The accuracy metric from datasets can easily be used to compare the predictions with the labels. Below, you can see how to use it within a compute_metrics function that will be used by the Trainer. python import numpy as np from datasets import load_metric metric = load_metric("accuracy") def compute_metrics(p): return metric.compute(predictions=np.argmax(p.predictions, axis=1), references=p.label_ids) Let's load the pretrained model. We'll add num_labels on init so the model creates a classification head with the right number of units. We'll also include the id2label and label2id mappings to have human-readable labels in the Hub widget (if you choose to push_to_hub). python from transformers import ViTForImageClassification labels = ds['train'].features['labels'].names model = ViTForImageClassification.from_pretrained( model_name_or_path, num_labels=len(labels), id2label={str(i): c for i, c in enumerate(labels)}, label2id={c: str(i) for i, c in enumerate(labels)} ) Almost ready to train! The last thing needed before that is to set up the training configuration by defining TrainingArguments. Most of these are pretty self-explanatory, but one that is quite important here is remove_unused_columns=False. This one will drop any features not used by the model's call function. By default it's True because usually it's ideal to drop unused feature columns, making it easier to unpack inputs into the model's call function. But, in our case, we need the unused features ('image' in particular) in order to create 'pixel_values'. What I'm trying to say is that you'll have a bad time if you forget to set remove_unused_columns=False. python from transformers import TrainingArguments training_args = TrainingArguments( output_dir="./vit-base-beans", per_device_train_batch_size=16, evaluation_strategy="steps", num_train_epochs=4, fp16=True, save_steps=100, eval_steps=100, logging_steps=10, learning_rate=2e-4, save_total_limit=2, remove_unused_columns=False, push_to_hub=False, report_to='tensorboard', load_best_model_at_end=True, ) Now, all instances can be passed to Trainer and we are ready to start training! python from transformers import Trainer trainer = Trainer( model=model, args=training_args, data_collator=collate_fn, compute_metrics=compute_metrics, train_dataset=prepared_ds["train"], eval_dataset=prepared_ds["validation"], tokenizer=processor, )
[ 0.03796905279159546, -0.03079015016555786, 0.012919032946228981, 0.014017867855727673, 0.013409899547696114, 0.11055642366409302, 0.02676531858742237, 0.02607053332030773, -0.06283711642026901, -0.0286079254001379, -0.05242080241441727, 0.0976170003414154, -0.02239840477705002, 0.07991599291563034, 0.07136213034391403, -0.002757991198450327, 0.07149963825941086, -0.0124563779681921, -0.011836953461170197, 0.04951704293489456, -0.021157080307602882, -0.06260697543621063, 0.04006679728627205, -0.02959628775715828, 0.002999749267473817, -0.03318876773118973, 0.05537451431155205, -0.02080373652279377, -0.07301104068756104, 0.017589407041668892, -0.10979818552732468, 0.02780100703239441, 0.002038076287135482, -0.005939795169979334, -0.0495837964117527, 0.03143339231610298, 0.00027580049936659634, 0.03677183762192726, 0.055894166231155396, -0.03309356048703194, -0.009921247139573097, -0.005255678202956915, -0.0011996951652690768, 0.03202696889638901, -0.011577010154724121, -0.06909086555242538, -0.14445261657238007, 0.018659455701708794, 0.05465739220380783, -0.021659759804606438, -0.026737460866570473, 0.06846900284290314, 0.0008665173663757741, 0.01031354907900095, 0.03134592995047569, -0.030279774218797684, -0.0008434772025793791, -0.08557798713445663, 0.003933522384613752, 0.03875771537423134, -0.0235589612275362, 0.039500489830970764, -0.026151185855269432, 0.03180423006415367, 0.04722311720252037, -0.009166251868009567, 0.05416710302233696, 0.09085208922624588, -0.01638965494930744, -0.03179417550563812, -0.06209470331668854, -0.07165011763572693, 0.010729966685175896, -0.032780181616544724, -0.006493097171187401, -0.02908177860081196, -0.0536276251077652, -0.0350768119096756, 0.014509971253573895, 0.012039870955049992, -0.020185314118862152, 0.011038294993340969, -0.0025693029165267944, -0.010861151851713657, -0.01767774112522602, 0.059829384088516235, 0.01903744414448738, -0.07737432420253754, -0.09569016844034195, 0.06438928842544556, -0.010593794286251068, -0.06950605660676956, -0.0022327611222863197, -0.03290305286645889, -0.013479345478117466, -0.07024824619293213, 0.030735502019524574, -0.024957014247775078, -0.05871814116835594, -0.032629575580358505, 0.016405057162046432, -0.03620661422610283, 0.021177690476179123, -0.039260562509298325, -0.03489983454346657, -0.014148730784654617, 0.003996363375335932, -0.09620939195156097, -0.07879003137350082, 0.052484121173620224, -0.04148399457335472, -0.011391186155378819, -0.028771089389920235, 0.09892989695072174, -0.03325662761926651, -0.014177966862916946, 0.035871319472789764, 0.02230014093220234, -0.02665243297815323, 0.014021608978509903, 0.017949288710951805, 0.08041088283061981, 0.048630692064762115, -0.01450308132916689, -0.04635775834321976, 0.03938193991780281, 0.0383327417075634, 0.07182110100984573, 0.026369282975792885, 0.04858564957976341, -0.01471021305769682, -0.03756294772028923, 0.0657515898346901, -0.019428381696343422, -0.005729878321290016, -0.07676418870687485, 0.013528493233025074, -0.046046122908592224, -0.007706215605139732, 0.0036790722515434027, -0.04692291468381882, 0.04783163592219353, -0.03433820232748985, 0.032799385488033295, 0.036209989339113235, -0.007203218527138233, 0.009768066927790642, 0.042669281363487244, 0.05080009624361992, 0.03716180473566055, -0.09395039081573486, 0.079684317111969, -0.028816625475883484, -0.0396600142121315, -0.031346842646598816, 0.0953712910413742, -0.02370752952992916, 0.002600692445412278, -0.09654601663351059, 0.030363699421286583, -0.021667860448360443, 0.04105094447731972, -0.05404963344335556, -0.016650566831231117, 0.017659641802310944, 0.022064095363020897, 0.03495349735021591, -0.012535935267806053, 0.07314617931842804, 0.053461335599422455, 0.061876241117715836, -0.08575989305973053, -0.007767254952341318, 0.015226121991872787, -0.003623353550210595, 0.03280637040734291, 0.04118983820080757, 0.035003162920475006, -0.028209827840328217, -0.055919747799634933, -0.039018310606479645, 0.0890728235244751, -0.008763153105974197, 0.03557415306568146, 0.06476049870252609, -0.07682206481695175, -0.00007689648191444576, -0.09193767607212067, 0.025968149304389954, 0.04440638795495033, -0.052130937576293945, -0.0059981392696499825, 0.07659776508808136, -0.022155091166496277, 0.03335169330239296, -0.06973587721586227, 0.0022787940688431263, 0.08612078428268433, -0.012576596811413765, -0.0030812574550509453, -0.0033271468710154295, 0.0041725547052919865, 0.027919108048081398, -0.02173023484647274, 0.008660692721605301, -0.026639331132173538, -0.007975065149366856, -0.052636560052633286, 0.04374643787741661, 0.04771285504102707, 0.007764092180877924, -0.09418294578790665, 0.04836060851812363, -0.07452965527772903, 0.010366348549723625, 0.039161261171102524, -0.03363998606801033, 0.014984111301600933, 0.005877080839127302, -0.054581038653850555, 0.12118896842002869, -0.009373042732477188, -0.01996901072561741, -0.007880138233304024, -0.016943825408816338, -0.019543122500181198, 0.04774777591228485, 0.08698861300945282, 0.02044735476374626, -0.1242581382393837, -0.06934434920549393, -0.06503953784704208, -0.01037111971527338, 0.047602660953998566, -0.07977361977100372, -0.0326094813644886, 0.03424934670329094, 0.02271992154419422, 0.05609933286905289, -0.04289410635828972, -0.04649805277585983, -0.017243118956685066, -0.03649582713842392, 0.07996056228876114, -0.023064080625772476, -0.038603752851486206, 0.09796420484781265, 0.03919440880417824, -0.054389942437410355, -0.027695175260305405, 0.0014866471756249666, 0.04088898375630379, 0.036733902990818024, -0.022010449320077896, 0.021528827026486397, 0.014208213426172733, -0.00015255497419275343, 0.0067055802792310715, -0.012233439832925797, 0.041786279529333115, -0.014703328721225262, -0.025382649153470993, -0.03566654026508331, -0.027188824489712715, 0.019636042416095734, -0.0228667464107275, 0.01712210290133953, 0.017749400809407234, -0.0011203833855688572, -0.016589870676398277, -0.01826348714530468, 0.000402342266170308, 0.04375135898590088, -0.01820913329720497, 0.033538807183504105, 0.01284434087574482, 0.0017180140130221844, 0.01723945513367653, 0.012790550477802753, -0.005170546472072601, -0.007209261879324913, -0.016136452555656433, 0.03157581016421318, 0.008530382066965103, 0.016320284456014633, -0.03107437863945961, -0.0040775262750685215, -0.012639877386391163, 0.015579049475491047, 0.0144179193302989, 0.00246519036591053, 0.07784880697727203, -0.0004569617158267647, -0.030976606532931328, -0.02487202174961567, 0.03335271775722504, -0.0008000268717296422, -0.01131522748619318, 0.033546607941389084, 0.003085532458499074, -0.045516371726989746, 0.016592716798186302, 0.010085821151733398, -0.0008043183479458094, -0.05032075569033623, 0.034591466188430786, -0.016612742096185684, 0.029994720593094826, -0.08971374481916428, 0.019039811566472054, 0.06984827667474747, -0.017872218042612076, -0.03167195990681648, -0.024773666635155678, 0.04651883244514465, 0.022656632587313652, -0.02662910893559456, 0.027232281863689423, 0.016360806301236153, 0.01570896804332733, 0.015672067180275917, 0.016601793467998505, -0.0044400556944310665, 0.014453760348260403, -0.004033898003399372, -0.04491199553012848, 0.01871872879564762, 0.024072246626019478, -0.058194972574710846, 0.048229362815618515, -0.007355823181569576, 0.016935355961322784, -0.03864657133817673, 0.020937098190188408, 0.019232740625739098, 0.024308744817972183, 0.03922688215970993, -0.04612351581454277, 0.0038200777489691973, -0.02972942218184471, -0.0760965570807457, 0.01047244481742382, 0.00926892552524805, -0.006283878348767757, -0.017489761114120483, 0.013176966458559036, 0.005759216845035553, 0.003143211593851447, -0.01884356327354908, 0.05932873487472534, 0.007726603653281927, -0.025826627388596535, 0.03459998220205307, -0.003004811005666852, -0.0052620540373027325, -0.02153523452579975, 0.0046857865527272224, -0.04739650711417198, -0.045165203511714935, 0.008037250488996506, 0.0011960141127929091, 0.036636654287576675, -0.00005368347046896815, 0.011508531868457794, -0.001132733072154224, 0.04425370320677757, 0.012475322000682354, 0.009922565892338753, -0.030087215825915337, 0.023012669757008553, -0.0035424737725406885, -0.002964412560686469, 0.008278228342533112, 0.012492428533732891, -0.020908623933792114, 0.03967219218611717, -0.016559429466724396, 0.02553682029247284, -0.015253392979502678, 0.059776805341243744, -0.004870997741818428, 0.009982312098145485, -0.03159826621413231, -0.011879507452249527, 0.0052268183790147305, 0.006033199839293957, 0.030082445591688156, 0.01837543211877346, -0.004036895930767059, -0.04944293573498726, -0.020686235278844833, -0.01996556855738163, -0.007782754488289356, 0.02998531609773636, 0.043571408838033676, -0.03762850537896156, 0.04054960235953331, 0.02988281473517418, 0.0378846749663353, -0.024002932012081146, -0.0336989127099514, 0.021046005189418793, 0.0026117058005183935, -0.005499540828168392, 0.030282847583293915, -0.0013218920212239027, -0.0406586192548275, 0.011795314960181713, -0.005125101190060377, -0.042350780218839645, 0.0272560715675354, 0.0037655315827578306, -0.02530529908835888, 0.03757333382964134, -0.048896946012973785, -0.0491798110306263, 0.024101054295897484, -0.06389599293470383, 0.028226759284734726, -0.015706300735473633, 0.005690759979188442, -0.001973733538761735, 0.03261842206120491, 0.045330293476581573, -0.006954844109714031, -0.01839309185743332, -0.00727601395919919, 0.08352102339267731, -0.028875863179564476, -0.0021296374034136534, -0.028797687962651253, -0.02631925605237484, 0.012075027450919151, 0.01537697296589613, 0.014148806221783161, 0.013904450461268425, -0.0057267677038908005, -0.020113956183195114, 0.0007010622066445649, 0.022172892466187477, 0.03569396212697029, -0.0387994758784771, 0.010141238570213318, 0.029758863151073456, -0.02885700948536396, -0.01661200262606144, -0.00331102404743433, 0.00009476386912865564, -0.008045339025557041, -0.024233318865299225, -0.00010652665514498949, 0.009971587918698788, 0.025248458608984947, -0.031737301498651505, -0.05570057034492493, 0.00805786531418562, -0.04076269268989563, 0.01193022821098566, 0.03198914974927902, 0.03466390445828438, -0.03789369761943817, 0.00255136308260262, 0.04587932676076889, -0.03121229074895382, -0.020882917568087578, -0.01417800597846508, -0.01012534461915493, 0.014867803081870079, -0.003367404919117689, 0.020252371206879616, 0.008250043727457523, -0.030680937692523003, 0.026837734505534172, 0.03096845932304859, 0.0492902435362339, -0.045469339936971664, 0.006471224594861269, -0.015617070719599724, 0.0033724207896739244, 0.03161556273698807, 0.016904449090361595, 0.004352264571934938, -0.03246121481060982, 0.028385426849126816, -0.019022587686777115, 0.01001809909939766, 0.007539785001426935, 0.004913408774882555, 0.005119755398482084, -0.025998326018452644, 0.0322052426636219, 0.01074992399662733, -0.004578564316034317, 0.040697209537029266, -0.0038303059991449118, 0.03675273433327675, 0.005456560757011175, 0.039391279220581055, 0.004791381303220987, -0.0056437659077346325, 0.04363309219479561, -0.019606029614806175, 0.022862905636429787, -0.02744610421359539, 0.016374683007597923, 0.007996064610779285, -0.05937625840306282, -0.046171896159648895, 0.008681952953338623, 0.010649423114955425, -0.034813590347766876, 0.00006427835614886135, 0.05036381259560585, 0.04868349805474281, -0.014913219958543777, -0.044478099793195724, -0.013169336132705212, -0.018714960664510727, 0.027574513107538223, -0.03074028342962265, -0.04346843436360359, 0.020541371777653694, -0.010738387703895569, -0.021433591842651367, -0.03260018303990364, 0.02931969240307808, 0.028449647128582, -0.012123591266572475, -0.005594756454229355, -0.00022006190556567162, -0.011675834655761719, -0.03279471397399902, 0.05555107444524765, -0.08046972006559372, -0.018051877617836, -0.015986351296305656, 0.00526849552989006, 0.053465887904167175, -0.00041207156027667224, -0.035202693194150925, 0.0014669462107121944, 0.027558790519833565, 0.00492224982008338, -0.018720440566539764, -0.05169732868671417, 0.042339831590652466, 0.04110303893685341, -0.04412680119276047, -0.03172735124826431, 0.026422105729579926, -0.03541482985019684, 0.030468616634607315, -0.02248207852244377, 0.02303764969110489, 0.04625080153346062, -0.031964436173439026, 0.020582005381584167, -0.010450232774019241, -0.0013038733741268516, 0.047478087246418, 0.0063630035147070885, -0.005197923164814711, 0.003254744689911604, 0.007697334513068199, -0.036531608551740646, 0.0031357244588434696, -0.012365715578198433, 0.0365719199180603, 0.016024351119995117, -0.03225129097700119, 0.015295236371457577, 0.05912404507398605, -0.021137220785021782, 0.027158431708812714, -0.00180414121132344, -0.05393744632601738, 0.007904627360403538, 0.019831346347928047, 0.024481918662786484, 0.04089740291237831, 0.01999632641673088, 0.021694304421544075, 0.03738802671432495, -0.0366024412214756, -0.030725039541721344, 0.04690742865204811, -0.04986479505896568, 0.026818422600626945, 0.04076988995075226, 0.024800874292850494, 0.03507472574710846, -0.002428123028948903, 0.02078714780509472, -0.05021187663078308, 0.07217647135257721, 0.036157168447971344, 0.01042846031486988, 0.03336736187338829, 0.0477752760052681, -0.00200297636911273, -0.039198607206344604, -0.01494646817445755, -0.038650888949632645, 0.0049124290235340595, 0.042130015790462494, 0.020776860415935516, 0.010798975825309753, 0.008116037584841251, 0.06861088424921036, 0.053964074701070786, 0.03968431055545807, -0.008803389966487885, 0.045431286096572876, 0.06660521030426025, 0.023565182462334633, -0.01772758737206459, -0.00997062399983406, -0.002305185655131936, -0.03981725871562958, 0.04869990050792694, 0.010155648924410343, -0.027741333469748497, 0.02817905694246292, 0.00659196637570858, 0.030475059524178505, -0.0047997538931667805, -0.03652947023510933, 0.03519842401146889, -0.006721482612192631, 0.016316711902618408, -0.008835173211991787, 0.02001671865582466, -0.043136827647686005, -0.004228826146572828, -0.039037685841321945, 0.0036963243037462234, -0.025647444650530815, 0.00033528346102684736, -0.04216630011796951, 0.05439041182398796, 0.002093713264912367, -0.02979109063744545, -0.029049642384052277, -0.01182982325553894, 0.023539185523986816, 0.04111461341381073, 0.0076840282417833805, -0.04339190945029259, -0.02728552743792534, -0.00864053051918745, 0.01129018235951662, 0.02319951541721821, -0.026221023872494698, 0.026763007044792175, -0.013849305920302868, -0.020000949501991272, -0.020030388608574867, 0.027755888178944588, -0.0046321796253323555, 0.0071380301378667355, -0.014754101634025574, 0.03712872043251991, -0.01950625702738762, -0.051392167806625366, 0.0457254983484745, -0.05510067939758301, 0.007272579241544008, 0.0017849486321210861, -0.013205268420279026, 0.010689720511436462, 0.009219769388437271, -0.022397596389055252, -0.04127155616879463, 0.013431801460683346, 0.011125816032290459, 0.003137553809210658, 0.04784451052546501, 0.0022977525368332863, 0.018739396706223488, 0.011019251309335232, -0.016449060291051865, -0.007910954765975475, -0.005628509446978569, 0.0130344582721591, 0.02521970495581627, -0.06148267909884453, -0.0012171489652246237, 0.007858267053961754, 0.021477218717336655, 0.04970409348607063, 0.01137308869510889, 0.02355022355914116, 0.006983781233429909, 0.03987182304263115, -0.023883258923888206, 0.02923966571688652, -0.014592843130230904, -0.0005424151313491166, -0.04602401331067085, -0.02266114391386509, -0.0038306824862957, 0.010220064781606197, -0.05097389966249466, 0.04741557687520981, -0.06556811183691025, 0.014877433888614178, -0.028510335832834244, 0.019394487142562866, -0.026974910870194435, 0.01125296764075756, 0.059052474796772, 0.04824884608387947, 0.05609431862831116, 0.01353010255843401, -0.05715257674455643, 0.031896695494651794, -0.007221407722681761, 0.017480287700891495, 0.022525545209646225, -0.0005369574064388871, 0.015513035468757153, -0.0016246020095422864, 0.029428334906697273, 0.009823700413107872, -0.0423603318631649, -0.0017535975202918053, 0.021599072962999344, -0.022508962079882622, -0.02335379831492901, 0.007204989902675152, 0.03843006491661072, -0.026705266907811165, 0.028687888756394386, -0.01385442353785038, -0.01912391372025013, 0.006725407671183348, 0.011123456060886383, -0.06659304350614548, 0.010559123009443283, -0.052643321454524994, -0.010481175035238266, -0.020622774958610535, 0.0046536060981452465, 0.03607245162129402, 0.03737734258174896, -0.027363229542970657, -0.018862774595618248, -0.007998783141374588, 0.002360526705160737, -0.07382699102163315, 0.05027751252055168, 0.03558697924017906, -0.009747392497956753, -0.031644947826862335, 0.034346967935562134, 0.011214681901037693, 0.008738056756556034, -0.01734466664493084, -0.03831220790743828, 0.03201457858085632, 0.011490674689412117, -0.007559540681540966, 0.017557580024003983, 0.044349800795316696, 0.035811010748147964, -0.005334523040801287, -0.03108210489153862, 0.020660433918237686 ]
Fine-Tune ViT for Image Classification with 🤗 Transformers
nateraw
February 11, 2022
fine-tune-vit
guide, cv
https://huggingface.co/blog/fine-tune-vit
Define our data collator Batches are coming in as lists of dicts, so you can just unpack + stack those into batch tensors. Since the collate_fn will return a batch dict, you can **unpack the inputs to the model later. ✨ python import torch def collate_fn(batch): return { 'pixel_values': torch.stack([x['pixel_values'] for x in batch]), 'labels': torch.tensor([x['labels'] for x in batch]) }
[ -0.0054008616134524345, 0.03409143537282944, -0.0307956300675869, -0.01918214187026024, -0.013213865458965302, 0.07059638947248459, -0.06338255107402802, 0.01722440868616104, -0.01440394390374422, 0.03170863166451454, -0.08060950040817261, 0.01792389340698719, 0.01832466386258602, 0.0648469626903534, -0.029404211789369583, -0.026936735957860947, 0.022406581789255142, 0.02208983525633812, 0.019632328301668167, 0.06838665157556534, -0.0014538683462888002, -0.04260683432221413, 0.0424949936568737, 0.015491221100091934, -0.027929414063692093, -0.05203264206647873, -0.04517446458339691, 0.03549155965447426, -0.029673593118786812, 0.03728513792157173, -0.0864870473742485, 0.04140467569231987, 0.008309757336974144, -0.035057298839092255, -0.025400612503290176, 0.0443921722471714, -0.05276218056678772, 0.11436787992715836, 0.00863511674106121, -0.09765662252902985, -0.0024500074796378613, 0.014228553511202335, -0.07303516566753387, 0.07561762630939484, 0.0232615377753973, 0.011877384968101978, -0.15084239840507507, 0.057602934539318085, 0.01585334911942482, -0.05157201737165451, -0.04219558835029602, 0.04928500950336456, -0.049093592911958694, 0.04108163341879845, -0.022262606769800186, -0.0035803047940135, -0.029900215566158295, -0.05680839717388153, -0.004126645624637604, -0.010587514378130436, -0.016165589913725853, 0.061334799975156784, 0.003383154049515724, -0.003766734851524234, 0.010422212071716785, 0.029230231419205666, 0.01254645362496376, -0.016004201024770737, -0.0891835018992424, -0.012557481415569782, -0.00850481353700161, -0.011154567822813988, -0.032945793122053146, -0.04593699052929878, 0.0011728073004633188, -0.047850724309682846, -0.03796025738120079, -0.042946528643369675, 0.038799747824668884, 0.04115007445216179, -0.040290795266628265, 0.01448621042072773, 0.04501205310225487, 0.04665541276335716, 0.021708467975258827, 0.046328455209732056, -0.0013181142276152968, -0.06879178434610367, -0.03489439934492111, 0.044565387070178986, -0.030140789225697517, -0.087996706366539, -0.007859866134822369, 0.022864703088998795, 0.06308509409427643, -0.09402362257242203, -0.02342396229505539, -0.025847550481557846, -0.014018848538398743, 0.019167378544807434, 0.061614684760570526, -0.08789720386266708, 0.01513860747218132, -0.019521256908774376, -0.08381006121635437, 0.02418048307299614, -0.06641969084739685, -0.09462351351976395, 0.0048895650543272495, -0.04754618927836418, 0.00592035660520196, 0.03422849252820015, -0.04465417563915253, 0.06633215397596359, -0.03268544003367424, -0.0899365171790123, 0.021568521857261658, 0.06773904711008072, -0.06522773951292038, 0.0027553632389754057, 0.009805552661418915, 0.05260138586163521, 0.10014936327934265, 0.04134315624833107, -0.0024292957969009876, 0.0258906539529562, 0.027555987238883972, 0.005100178066641092, 0.027070526033639908, 0.027161765843629837, -0.04478539526462555, 0.039912305772304535, 0.0659475326538086, 0.014094337821006775, 0.03030947968363762, -0.13424068689346313, -0.03400277718901634, -0.0017206913325935602, -0.03793424367904663, 0.0012031791266053915, 0.012193400412797928, 0.06338883936405182, -0.0500306636095047, 0.03821806609630585, 0.04621599614620209, 0.023351548239588737, -0.05485008656978607, 0.02982260100543499, 0.005312812514603138, 0.04739515855908394, -0.0877678394317627, 0.055176980793476105, -0.0063727558590471745, -0.013035568408668041, -0.006665364373475313, 0.03882898762822151, 0.006698036566376686, -0.051500484347343445, -0.0625607818365097, 0.035576231777668, 0.015080512501299381, -0.008109202608466148, -0.025422321632504463, 0.001825069892220199, -0.012011722661554813, 0.00823206827044487, 0.06234331056475639, 0.02988479658961296, 0.03915490582585335, 0.024781275540590286, 0.0164033230394125, 0.011574067175388336, 0.004453897941857576, 0.06195050850510597, -0.005877212155610323, 0.011635242030024529, 0.05078796669840813, 0.05844524875283241, -0.041753076016902924, -0.015341023914515972, -0.009909488260746002, 0.008981642313301563, -0.07255067676305771, -0.02988976612687111, -0.008685863576829433, -0.030212366953492165, 0.025069398805499077, -0.09577269107103348, -0.015239929780364037, 0.11725977808237076, -0.0389125719666481, 0.0018132086843252182, 0.003285280428826809, -0.07541929930448532, 0.0510772280395031, -0.06711646914482117, -0.05349213257431984, 0.09772571921348572, -0.0034390490036457777, 0.03619275987148285, 0.05506641045212746, 0.009223377332091331, -0.007312006317079067, 0.009232493117451668, 0.059768930077552795, 0.015863239765167236, -0.0035347461234778166, -0.04123348370194435, 0.03787737339735031, 0.006113511510193348, -0.02768726460635662, -0.10490743070840836, 0.0590486153960228, -0.098282590508461, 0.039264898747205734, 0.02198144979774952, -0.01580117642879486, 0.014752141200006008, 0.006689117290079594, -0.013102990575134754, 0.17971646785736084, -0.0584772489964962, 0.020693300291895866, -0.018414057791233063, -0.01975291781127453, 0.03687150403857231, 0.024191342294216156, 0.04487760365009308, 0.08526652306318283, -0.09531659632921219, -0.07661231607198715, -0.08029589802026749, -0.04249389097094536, 0.06043095141649246, -0.055880382657051086, -0.07188516855239868, 0.01374834030866623, 0.05029279738664627, -0.007514237426221371, -0.04764016717672348, 0.016341403126716614, 0.0384945422410965, 0.030717892572283745, -0.0045042624697089195, -0.02599932812154293, 0.07833442836999893, 0.07742272317409515, -0.022527538239955902, 0.011045629158616066, -0.003837371012195945, 0.04310564324259758, 0.030895955860614777, -0.022061310708522797, -0.023305032402276993, 0.07936787605285645, 0.012070891447365284, -0.00641239620745182, -0.0540955550968647, 0.024691535159945488, 0.0519929975271225, 0.01715206541121006, 0.012240872718393803, -0.03156454116106033, -0.03376556560397148, 0.00158348074182868, -0.04796864464879036, 0.014884908683598042, -0.0032892783638089895, -0.0016514846356585622, 0.009388701058924198, 0.00030251810676418245, -0.021619118750095367, 0.032730720937252045, 0.003749237395823002, 0.04199323430657387, 0.030801689252257347, 0.015369225293397903, -0.011784481815993786, -0.022045722231268883, -0.04097688943147659, 0.0015591293340548873, -0.02665494941174984, 0.03823382407426834, 0.03159613534808159, -0.004828271456062794, 0.010310688987374306, 0.0070283361710608006, -0.02921612747013569, -0.010866126976907253, 0.03465138375759125, 0.025266915559768677, 0.0390489399433136, 0.009615007787942886, -0.021121596917510033, -0.008548629470169544, 0.020015230402350426, 0.005754099693149328, -0.003983245696872473, -0.012600453570485115, 0.02819810062646866, -0.05431622266769409, -0.004034997429698706, 0.004628485534340143, -0.0015189339173957705, -0.03668459877371788, -0.008661777712404728, -0.00012134055577917024, 0.03600379079580307, -0.09024470299482346, -0.004851264879107475, -0.007668447680771351, 0.009015225805342197, 0.016894130036234856, -0.01755073480308056, 0.003705080598592758, 0.0021922877058386803, -0.019960403442382812, 0.009205584414303303, -0.005701720714569092, 0.014830522239208221, -0.012655045837163925, -0.026950964704155922, -0.00944681465625763, 0.0051474012434482574, -0.010319491848349571, 0.004083813168108463, 0.027813874185085297, 0.06821881979703903, -0.00638500414788723, 0.021295879036188126, -0.007481587119400501, 0.028993409126996994, -0.04728950560092926, -0.0017707502702251077, 0.04616218060255051, -0.00022715594968758523, -0.012168643064796925, 0.01004789024591446, -0.00181887811049819, -0.00575067987665534, -0.022577062249183655, -0.05150875821709633, -0.0102012287825346, -0.014074449427425861, 0.006158157717436552, 0.013399523682892323, 0.009745490737259388, -0.03766639158129692, -0.012984402477741241, 0.03431811183691025, -0.032707568258047104, -0.052686337381601334, 0.01446952298283577, -0.004841136280447245, -0.011839826591312885, 0.028045643121004105, 0.023826749995350838, -0.03897175192832947, -0.0086499759927392, -0.02065986394882202, 0.016570020467042923, 0.03337293863296509, 0.012565948069095612, -0.030988246202468872, 0.005505821667611599, 0.03568388521671295, 0.031204983592033386, 0.013615758158266544, -0.03762998804450035, -0.022469589486718178, -0.005668345373123884, 0.014623073861002922, -0.02644801139831543, 0.036763012409210205, 0.020276149734854698, 0.02314070612192154, 0.01812218688428402, 0.06190858036279678, 0.02899784967303276, 0.0026618901174515486, -0.04138035699725151, 0.013894865289330482, -0.05241397023200989, 0.035058800131082535, -0.02471909485757351, -0.0002959164557978511, 0.04681171104311943, 0.018548842519521713, -0.019302496686577797, -0.04046545550227165, 0.004714579787105322, -0.02987043187022209, 0.01234753243625164, 0.022455783560872078, 0.024194248020648956, -0.009714042767882347, 0.014238727279007435, 0.021865010261535645, 0.02026338502764702, -0.0284113772213459, 0.03678208217024803, 0.044370681047439575, -0.01629568450152874, -0.00265096896328032, 0.02440105751156807, 0.029239710420370102, 0.010815237648785114, -0.00861640926450491, -0.009448576718568802, -0.10800737887620926, -0.013634280301630497, -0.026505667716264725, 0.045549482107162476, 0.0033192061819136143, -0.03290218487381935, -0.028736025094985962, 0.006590392906218767, -0.024452926591038704, 0.011470519937574863, -0.00032698197173886, -0.004837723448872566, 0.0176379531621933, 0.01725456677377224, 0.028087284415960312, -0.015543198212981224, -0.0654945969581604, -0.02643178589642048, 0.04377421364188194, -0.043255507946014404, 0.017597652971744537, 0.009870321489870548, -0.03083472140133381, 0.019431186839938164, -0.020695462822914124, 0.0022492927964776754, -0.015280152671039104, -0.005487946327775717, -0.0293426513671875, -0.03367238491773605, 0.004916803445667028, -0.010643110610544682, 0.01633942499756813, -0.0012777595547959208, 0.013367938809096813, -0.005385408643633127, 0.010696614161133766, -0.013151693157851696, -0.050266511738300323, -0.04654080048203468, -0.019701547920703888, -0.005670177284628153, -0.04117613285779953, 0.02296420931816101, 0.011171176098287106, -0.05255195498466492, -0.006604756694287062, -0.014327038079500198, 0.03700773045420647, 0.014246468432247639, 0.003974525723606348, -0.04576130956411362, 0.014321250841021538, 0.0509798601269722, 0.04253607988357544, 0.03279882296919823, 0.03908010572195053, 0.013810662552714348, 0.03410809114575386, 0.021570349112153053, -0.009641537442803383, -0.016603343188762665, 0.015092523768544197, 0.03233178332448006, -0.05458671972155571, -0.0027785394340753555, -0.03383815288543701, 0.019371137022972107, -0.005131866317242384, -0.011562087573111057, 0.035745054483413696, -0.015723222866654396, -0.048866115510463715, 0.02582848258316517, 0.04299531131982803, 0.028593089431524277, 0.05261603742837906, 0.013364932499825954, -0.0048204148188233376, -0.0032339130993932486, -0.01569693721830845, 0.005652894265949726, 0.015474229119718075, -0.02333224005997181, 0.0003268019063398242, 0.0014255053829401731, 0.044517774134874344, 0.008955665864050388, 0.01121273823082447, 0.0031396171543747187, 0.012328769080340862, 0.020198436453938484, -0.015548775903880596, 0.01092165894806385, 0.006563901901245117, -0.039160244166851044, -0.0017128465697169304, -0.0366181805729866, 0.0035057812929153442, 0.0071690925396978855, 0.037615079432725906, -0.010028094984591007, -0.02636381983757019, 0.02111716940999031, -0.01650763675570488, -0.036256108433008194, -0.02004551887512207, 0.01631111651659012, -0.02494044229388237, -0.0011141039431095123, -0.014776811935007572, -0.014657027088105679, 0.0402018167078495, 0.03730344772338867, -0.036290839314460754, -0.014572197571396828, -0.014864812605082989, 0.01969466730952263, 0.026826161891222, 0.005400685127824545, -0.03497055172920227, 0.014662321656942368, 0.042562805116176605, 0.03167576342821121, -0.026740556582808495, 0.01907580904662609, 0.048751458525657654, 0.010058030486106873, 0.08649292588233948, 0.051429443061351776, -0.02353064715862274, -0.015638720244169235, 0.04426255822181702, 0.012135133147239685, 0.022926077246665955, -0.026235615834593773, 0.043838128447532654, 0.038000307977199554, -0.03909418359398842, -0.00035912246676161885, 0.024975648149847984, -0.021158013492822647, 0.040916211903095245, -0.020302053540945053, -0.005391460377722979, 0.05328766629099846, -0.02256437949836254, 0.02615555189549923, -0.00704557728022337, 0.05517923831939697, -0.017713025212287903, 0.007865003310143948, -0.03319385647773743, 0.01644037291407585, 0.0006713664624840021, 0.019938025623559952, -0.0006605714443139732, 0.021818162873387337, 0.014633012004196644, 0.06648366153240204, -0.058279480785131454, 0.007884595543146133, -0.016826188191771507, 0.02938253991305828, 0.03203541040420532, 0.008782605640590191, -0.041213586926460266, -0.030940813943743706, 0.036900587379932404, 0.03207367658615112, 0.06576456129550934, -0.023944320157170296, 0.03683970496058464, 0.02155221626162529, -0.030647149309515953, -0.006839355919510126, 0.005818274803459644, -0.02717522159218788, 0.029916422441601753, -0.0059136683121323586, 0.016150038689374924, 0.038017354905605316, 0.05848275497555733, 0.03400304540991783, -0.011071940883994102, 0.04524870961904526, -0.011402006261050701, 0.015217574313282967, 0.033275000751018524, 0.025284791365265846, 0.010067807510495186, -0.01802818663418293, -0.007530811242759228, 0.01311703771352768, -0.0060888915322721004, 0.019067326560616493, -0.025825342163443565, -0.0022985434625297785, 0.003541977144777775, 0.02384558506309986, 0.0738920345902443, 0.03375054523348808, -0.031249243766069412, -0.005082354880869389, 0.04809050261974335, 0.03900108113884926, 0.01188934687525034, 0.04239177331328392, 0.012303861789405346, -0.04017253965139389, 0.015124266967177391, -0.01325222384184599, -0.013317284174263477, 0.039940159767866135, -0.010963575914502144, 0.05351056158542633, -0.0643993690609932, -0.0024431475903838873, 0.04297966510057449, -0.01532053668051958, -0.03281441703438759, 0.005406924989074469, 0.012799901887774467, -0.03863651677966118, 0.03851917386054993, -0.011577394790947437, -0.007287670858204365, -0.02594170533120632, -0.0163293294608593, -0.013593176379799843, 0.06629468500614166, 0.01323417667299509, -0.04286433011293411, 0.0213086549192667, -0.027561182156205177, 0.026326915249228477, 0.051776379346847534, -0.006337420549243689, 0.030462414026260376, -0.04176044836640358, 0.04507443681359291, -0.004136531613767147, 0.0019117668271064758, -0.033991146832704544, 0.023851267993450165, 0.043136488646268845, -0.031960438936948776, -0.021306784823536873, 0.005568654276430607, -0.007126855198293924, 0.03394007682800293, -0.00014908466255292296, 0.03744124621152878, -0.007402152754366398, -0.006434601731598377, 0.00666583189740777, -0.0119129978120327, 0.007704220246523619, 0.031454697251319885, -0.005852710921317339, 0.011608540080487728, 0.01795201376080513, 0.018787845969200134, -0.06585987657308578, 0.0024074360262602568, -0.018263721838593483, -0.010080492123961449, 0.003997622523456812, -0.003009939333423972, -0.03275153040885925, 0.004209381993860006, 0.018991058692336082, -0.029537802562117577, -0.033680982887744904, -0.017312103882431984, 0.015588066540658474, -0.03218770772218704, 0.012331911362707615, -0.018158700317144394, 0.017486033961176872, -0.0076527646742761135, -0.06094439700245857, 0.00650035310536623, 0.0001828966778703034, -0.0036080623976886272, -0.00911943893879652, 0.052114564925432205, -0.026587314903736115, 0.010164650157094002, -0.04128444939851761, -0.03733246028423309, -0.03919051215052605, 0.012883219867944717, -0.007093834690749645, 0.022342508658766747, -0.028903013095259666, 0.007259822450578213, -0.004754884168505669, -0.04242083802819252, -0.02258949540555477, -0.021735940128564835, 0.08771771937608719, 0.0557430125772953, -0.00613770168274641, -0.01068884413689375, -0.03562942519783974, 0.031496256589889526, 0.01234448328614235, 0.007089321967214346, 0.008140675723552704, -0.03108382225036621, -0.01761993020772934, -0.005759291350841522, 0.024163376539945602, -0.003562443656846881, -0.028930846601724625, 0.01221687626093626, 0.007792946416884661, 0.0008271690458059311, -0.029795389622449875, 0.015612584538757801, 0.0644996389746666, 0.004077045246958733, 0.03130204230546951, -0.020941374823451042, -0.015645280480384827, -0.004402376711368561, 0.024106942117214203, -0.09525572508573532, -0.02924489602446556, -0.020872199907898903, -0.04134088382124901, 0.008024739101529121, -0.0030658235773444176, 0.06392133980989456, -0.032457027584314346, 0.0017689227825030684, -0.04497124254703522, -0.013069812208414078, 0.008117172867059708, -0.03790571540594101, -0.027593331411480904, 0.03720370680093765, 0.004580614157021046, 0.010919071733951569, -0.00043697672663256526, 0.01793353259563446, -0.005565247032791376, 0.0506102629005909, 0.00987335853278637, 0.014044803567230701, 0.018430620431900024, -0.047122735530138016, 0.025248248130083084, 0.03862910345196724, 0.026232875883579254, -0.02222467213869095, -0.011483460664749146, 0.03674827516078949 ]
Fine-Tune ViT for Image Classification with 🤗 Transformers
nateraw
February 11, 2022
fine-tune-vit
guide, cv
https://huggingface.co/blog/fine-tune-vit
Processing the Dataset Now that you know how to read images and transform them into inputs, let's write a function that will put those two things together to process a single example from the dataset. python def process_example(example): inputs = processor(example['image'], return_tensors='pt') inputs['labels'] = example['labels'] return inputs python process_example(ds['train'][0]) { 'pixel_values': tensor([[[[-0.6157, -0.6000, -0.6078, ..., ]]]]), 'labels': 0 } While you could call ds.map and apply this to every example at once, this can be very slow, especially if you use a larger dataset. Instead, you can apply a transform to the dataset. Transforms are only applied to examples as you index them. First, though, you'll need to update the last function to accept a batch of data, as that's what ds.with_transform expects. python ds = load_dataset('beans') def transform(example_batch): # Take a list of PIL images and turn them to pixel values inputs = processor([x for x in example_batch['image']], return_tensors='pt') # Don't forget to include the labels! inputs['labels'] = example_batch['labels'] return inputs You can directly apply this to the dataset using ds.with_transform(transform). python prepared_ds = ds.with_transform(transform) Now, whenever you get an example from the dataset, the transform will be applied in real time (on both samples and slices, as shown below) python prepared_ds['train'][0:2] This time, the resulting pixel_values tensor will have shape (2, 3, 224, 224). { 'pixel_values': tensor([[[[-0.6157, -0.6000, -0.6078, ..., ]]]]), 'labels': [0, 0] } # Training and Evaluation The data is processed and you are ready to start setting up the training pipeline. This blog post uses 🤗's Trainer, but that'll require us to do a few things first: - Define a collate function. - Define an evaluation metric. During training, the model should be evaluated on its prediction accuracy. You should define a compute_metrics function accordingly. - Load a pretrained checkpoint. You need to load a pretrained checkpoint and configure it correctly for training. - Define the training configuration. After fine-tuning the model, you will correctly evaluate it on the evaluation data and verify that it has indeed learned to correctly classify the images.
[ 0.02419273927807808, -0.042949069291353226, -0.011345431208610535, 0.01501451712101698, 0.0131029998883605, 0.09376347810029984, -0.04384838417172432, 0.015175916254520416, -0.029873523861169815, -0.0004910437855869532, -0.060359302908182144, 0.05227582901716232, -0.04349096864461899, 0.046133264899253845, 0.03612925857305527, -0.031080089509487152, 0.0928012952208519, -0.04126054048538208, 0.031388625502586365, 0.07308430969715118, 0.015207367949187756, -0.07460064440965652, -0.013021739199757576, 0.016423113644123077, -0.026066051796078682, -0.02190101146697998, 0.034405119717121124, 0.0496700257062912, -0.026737257838249207, 0.039377275854349136, -0.16374367475509644, 0.03488907217979431, -0.05183015763759613, -0.0191962867975235, -0.011131307110190392, 0.01659335196018219, -0.07488424330949783, 0.0302018653601408, 0.06027066707611084, -0.07336237281560898, -0.0012270164443179965, 0.06220124661922455, -0.08568388223648071, 0.043146103620529175, 0.0022198064252734184, -0.06686725467443466, -0.1377309262752533, 0.0842060074210167, 0.041546471416950226, -0.035210054367780685, -0.031923409551382065, 0.08665792644023895, 0.060009974986314774, 0.012136185541749, -0.03377619385719299, 0.04813313111662865, -0.02956715226173401, -0.009971502237021923, -0.0007972823223099113, 0.060622185468673706, 0.036498550325632095, 0.028605442494153976, 0.016600480303168297, 0.032871123403310776, 0.0006104408530518413, -0.01370021142065525, -0.009191048331558704, 0.03916731849312782, -0.04531710967421532, -0.05283341184258461, 0.02778991311788559, -0.07040038704872131, 0.009258709847927094, -0.019300704821944237, 0.025909481570124626, -0.0629206970334053, -0.025742830708622932, -0.0043923696503043175, 0.03552455082535744, 0.06068851798772812, 0.01027086190879345, -0.029704652726650238, 0.05444040521979332, 0.01674806885421276, 0.0702662393450737, 0.013990547508001328, 0.035216424614191055, -0.010112345218658447, -0.013433725573122501, 0.06525234878063202, 0.017294786870479584, -0.06441549211740494, 0.0386793315410614, -0.02394765429198742, 0.03518170118331909, -0.04649096354842186, 0.0028888294473290443, 0.019081169739365578, 0.01183717604726553, -0.050196707248687744, -0.01882343366742134, -0.04938596859574318, 0.06388796120882034, -0.002635384676977992, -0.048769913613796234, 0.06914827972650528, -0.01696583814918995, -0.09675778448581696, -0.037371791899204254, 0.001219782279804349, -0.030828209593892097, 0.053228024393320084, -0.035392388701438904, 0.07465530931949615, -0.031588904559612274, -0.035687122493982315, 0.00034394816611893475, 0.023448185995221138, -0.09809409826993942, 0.018009327352046967, 0.03908948227763176, 0.05693431571125984, 0.05663619935512543, -0.021411454305052757, -0.01462775282561779, -0.006601208820939064, 0.04956027492880821, 0.0919475108385086, 0.032055992633104324, -0.012500767596065998, -0.018414171412587166, -0.007356240414083004, 0.07491647452116013, 0.007802360225468874, 0.007199582643806934, -0.07814852893352509, -0.008028779178857803, -0.02372715435922146, -0.005958054680377245, -0.019122188910841942, 0.036168619990348816, 0.051111169159412384, -0.022131266072392464, 0.0616411492228508, 0.037082552909851074, -0.032288745045661926, -0.043796930462121964, 0.015280383639037609, 0.049875494092702866, 0.0180320143699646, -0.0972951203584671, 0.02761267125606537, -0.0039682998321950436, -0.047472450882196426, -0.010245246812701225, 0.033483296632766724, 0.01934119313955307, -0.08091674000024796, -0.10102880001068115, -0.029027484357357025, 0.005649543832987547, -0.0016428993549197912, -0.0014069557655602694, 0.034319546073675156, 0.046952344477176666, -0.03098992072045803, 0.03715556859970093, -0.04619251936674118, 0.04511813819408417, 0.030647141858935356, -0.049966663122177124, -0.03417271003127098, -0.02638552524149418, 0.05228845030069351, 0.012330420315265656, -0.03879861906170845, 0.034378647804260254, 0.04173610731959343, 0.0038667351473122835, -0.059371933341026306, -0.007981223054230213, 0.01914362423121929, -0.03782932460308075, 0.026969850063323975, 0.032067637890577316, -0.06111902371048927, 0.017657607793807983, -0.0556480772793293, 0.06482145190238953, 0.09706533700227737, -0.09217579662799835, -0.005672878120094538, 0.05275435373187065, -0.09403079748153687, 0.02043643780052662, -0.07704158872365952, -0.07499688863754272, 0.10041462630033493, -0.01277904398739338, 0.05251362547278404, 0.0014802092919126153, -0.04087136685848236, -0.005358636844903231, -0.01606435328722, 0.04393625631928444, -0.017823489382863045, 0.02024739235639572, -0.057425037026405334, 0.0800383910536766, 0.00970305223017931, -0.04373636841773987, -0.06761711090803146, 0.05394921451807022, -0.028849275782704353, 0.005607833154499531, 0.030248543247580528, -0.013956255279481411, 0.020961064845323563, 0.045859672129154205, -0.023944169282913208, 0.13654565811157227, -0.02419355884194374, 0.026176126673817635, -0.03220392018556595, 0.006186659447848797, 0.024064889177680016, 0.06745945662260056, 0.06398680061101913, 0.040034614503383636, -0.11447921395301819, -0.08960460126399994, -0.06576575338840485, -0.03865029662847519, 0.026607148349285126, -0.020730357617139816, -0.032961197197437286, 0.02433948963880539, 0.049832962453365326, 0.05623908340930939, -0.02821596898138523, 0.03355586156249046, -0.00085876090452075, -0.04900180175900459, -0.03335617482662201, -0.020156530663371086, 0.002813945058733225, 0.08949444442987442, 0.008665725588798523, -0.05611174553632736, -0.049792736768722534, 0.008096114732325077, 0.03168226405978203, -0.030986446887254715, -0.06373462080955505, -0.016971642151474953, 0.04314719885587692, -0.007955350913107395, -0.0222160667181015, 0.023755939677357674, 0.04800715297460556, 0.015161444433033466, -0.017632020637392998, -0.04522232711315155, -0.044174786657094955, -0.015273836441338062, -0.02299407497048378, 0.005708134267479181, -0.012306301854550838, 0.03162883222103119, -0.025671379640698433, 0.018710235133767128, -0.025188349187374115, 0.022233257070183754, 0.012087821029126644, 0.04015982523560524, 0.0046523758210241795, 0.01700023002922535, 0.01974729634821415, 0.005581310018897057, -0.024774156510829926, 0.01107063889503479, -0.03021838888525963, 0.0508970208466053, 0.0712776631116867, -0.008262930437922478, -0.014235160313546658, 0.026717007160186768, 0.021652380004525185, -0.0018134332494810224, 0.020564036443829536, 0.07027655839920044, 0.05727431923151016, 0.004074904602020979, -0.046571776270866394, 0.0026116485241800547, 0.03696845844388008, -0.02240351401269436, -0.016783874481916428, 0.021027138456702232, 0.0063366941176354885, -0.011505686677992344, -0.03074295073747635, 0.007878323085606098, -0.0023874789476394653, -0.046467434614896774, 0.010120798833668232, 0.0060630543157458305, 0.014513702131807804, -0.09230127930641174, -0.015427472069859505, -0.008996442891657352, -0.015435993671417236, -0.018605226650834084, -0.04561933875083923, 0.06265996396541595, 0.007410988211631775, -0.011359254829585552, 0.011747371405363083, 0.005406789947301149, -0.006008354015648365, -0.04030716046690941, 0.013737288303673267, 0.00874977745115757, 0.023594491183757782, 0.014736752957105637, 0.019479498267173767, 0.018009591847658157, 0.024481788277626038, -0.029815342277288437, 0.0628826841711998, 0.009415850974619389, 0.05684294179081917, -0.029759952798485756, 0.04269552603363991, 0.055465031415224075, 0.010176558047533035, 0.01229135598987341, -0.032092317938804626, -0.01937037706375122, -0.04199182987213135, -0.027299832552671432, 0.02597520872950554, -0.002580843633040786, 0.008585586212575436, 0.003935432992875576, 0.00748282577842474, -0.015988055616617203, -0.013803204521536827, -0.050839561969041824, 0.05631339177489281, 0.0074276248924434185, -0.03310243412852287, 0.03891821950674057, -0.02242533303797245, -0.013455012813210487, -0.02965439483523369, 0.02390367165207863, -0.03315889090299606, -0.0089602405205369, 0.004089221358299255, 0.02279164455831051, 0.02416989766061306, -0.012970729731023312, 0.0065383510664105415, -0.0029496336355805397, 0.04136348143219948, 0.03205063194036484, -0.007375932298600674, -0.033332709223032, 0.023192374035716057, 0.016419248655438423, 0.012461663223803043, 0.0010979360667988658, 0.04463084414601326, -0.009830531664192677, 0.010370630770921707, 0.0005620837910100818, 0.025283731520175934, -0.026601143181324005, -0.03336327522993088, -0.014745960012078285, 0.004250273574143648, -0.016067132353782654, 0.020032422617077827, -0.009714646264910698, 0.0014546540332958102, 0.05298123508691788, 0.033153876662254333, -0.010245306417346, -0.04586624726653099, 0.00895552895963192, -0.039500415325164795, 0.020174531266093254, 0.001251181005500257, -0.009985901415348053, -0.025219567120075226, 0.023191746324300766, -0.00463826023042202, 0.010705417022109032, -0.03486720845103264, -0.02227604016661644, -0.00390479969792068, -0.030487550422549248, -0.007229560520499945, 0.05875520780682564, -0.002341851592063904, 0.02781282179057598, -0.0010819671442732215, 0.013322191312909126, -0.08531000465154648, -0.01633067987859249, -0.004901857580989599, 0.008039556443691254, -0.018527528271079063, -0.03364331275224686, -0.009936559945344925, 0.03052591346204281, -0.0163539070636034, 0.058311570435762405, -0.024045513942837715, 0.006213589105755091, 0.0027131298556923866, 0.05678614601492882, 0.03472457453608513, -0.04898906871676445, -0.05199630558490753, -0.0035087710712105036, 0.03677167743444443, 0.009595309384167194, -0.0003384418960195035, -0.03225460648536682, -0.040896281599998474, -0.003933001775294542, -0.012933331541717052, 0.050675634294748306, 0.021914631128311157, 0.03209926560521126, -0.0041638873517513275, 0.017462212592363358, -0.004537155851721764, -0.04245557636022568, 0.010185258463025093, 0.02583722397685051, -0.016278564929962158, -0.0011399673530831933, -0.002127224812284112, -0.012393045239150524, -0.016210028901696205, -0.015821553766727448, -0.0014108582399785519, 0.05517973378300667, -0.00901266373693943, 0.0396905355155468, 0.04598755016922951, -0.06868128478527069, -0.021359145641326904, -0.02721506729722023, 0.014283173717558384, -0.0017050872556865215, 0.011848737485706806, -0.052511993795633316, 0.022270189598202705, 0.025693688541650772, 0.0040300809778273106, 0.02297603338956833, -0.008211389183998108, 0.021079812198877335, 0.032693639397621155, -0.007565815933048725, -0.02436181902885437, -0.024002786725759506, -0.020369892939925194, 0.0014728823443874717, -0.017877180129289627, -0.008030553348362446, -0.03764346241950989, 0.025603143498301506, -0.0013914358569309115, 0.007417268119752407, 0.015203995630145073, 0.004539970774203539, -0.05251187086105347, 0.002290647244080901, 0.028179777786135674, 0.00002507222961867228, 0.04472838714718819, -0.028952350839972496, -0.015105903148651123, -0.008062605746090412, -0.021757839247584343, 0.026980632916092873, 0.025418102741241455, -0.022473568096756935, 0.02211829088628292, 0.015707070007920265, 0.007082746829837561, 0.003268517553806305, 0.016514640301465988, 0.008195050060749054, -0.016614383086562157, -0.02108077146112919, 0.007781133987009525, -0.016624491661787033, 0.0016526097897440195, -0.011399026960134506, -0.010962862521409988, -0.044555675238370895, -0.017419898882508278, -0.008383847773075104, 0.026031197980046272, 0.01698686182498932, -0.032021038234233856, 0.002182271098718047, -0.0005756723112426698, -0.022760123014450073, -0.0014077824307605624, -0.00694362074136734, -0.0575525276362896, 0.028157468885183334, -0.05127628147602081, -0.03023959882557392, 0.007292683236300945, 0.005669457372277975, 0.007660465314984322, -0.0001259660057257861, -0.02735825441777706, 0.001363118994049728, -0.01628880575299263, -0.0031602694652974606, -0.029890380799770355, -0.025240210816264153, 0.018489092588424683, 0.02095363661646843, -0.04090205579996109, -0.019852571189403534, 0.016876108944416046, -0.006444511469453573, 0.0681728795170784, 0.004611954092979431, 0.004103124141693115, -0.019648149609565735, 0.03238347917795181, 0.0035592501517385244, -0.027241140604019165, -0.023682843893766403, 0.054774317890405655, 0.04769959673285484, -0.03103933297097683, -0.06514786928892136, -0.013544287532567978, 0.006406808737665415, 0.05508682504296303, 0.019359175115823746, 0.004602718632668257, 0.06252706795930862, 0.001234716852195561, 0.009211882948875427, 0.014609132893383503, 0.013618986122310162, 0.03411870077252388, 0.03601950779557228, -0.01965392380952835, 0.05775204673409462, 0.008284319192171097, 0.01932482235133648, -0.02895122766494751, 0.02975635789334774, 0.04103032872080803, 0.016565732657909393, -0.031213868409395218, 0.04115910828113556, -0.02293967455625534, 0.01780204102396965, 0.015107196755707264, 0.0242758896201849, -0.013392920605838299, -0.016891872510313988, 0.04619685187935829, 0.05755120888352394, 0.05223371461033821, -0.0033165740314871073, 0.02001027762889862, -0.011411911807954311, -0.012599669396877289, -0.03949948027729988, 0.03575687110424042, -0.02225765399634838, 0.04688265174627304, -0.014020474627614021, 0.06966167688369751, 0.009829767048358917, 0.010235586203634739, 0.03743354231119156, 0.01165023073554039, 0.07270753383636475, 0.0025153891183435917, -0.022431600838899612, 0.030648617073893547, 0.0394769124686718, -0.02115463837981224, -0.04729040339589119, -0.045879267156124115, -0.011111096478998661, -0.009879382327198982, 0.038217708468437195, -0.028766021132469177, -0.015693318098783493, -0.04729181155562401, 0.022254355251789093, 0.07273468375205994, 0.020404960960149765, 0.005374999716877937, 0.01915428787469864, 0.08990488201379776, 0.020120766013860703, 0.00232687103562057, -0.016765812411904335, 0.0013897583121433854, -0.00905484426766634, 0.0271308533847332, 0.01071165967732668, 0.011672308668494225, 0.03404264897108078, -0.018208162859082222, 0.02964109182357788, -0.009701987728476524, -0.04596339911222458, 0.03638119995594025, 0.012499167583882809, -0.030222497880458832, 0.022004999220371246, 0.006736377254128456, -0.09651494026184082, 0.008853575214743614, -0.016772065311670303, -0.03142382577061653, -0.026356050744652748, -0.032700907438993454, -0.04788685590028763, 0.06278987228870392, -0.029484862461686134, -0.0017459681257605553, -0.0021037375554442406, 0.01821427419781685, 0.029402468353509903, 0.022756418213248253, 0.0015648797852918506, 0.0028790144715458155, -0.019165467470884323, -0.012561465613543987, 0.011536823585629463, 0.0004899181076325476, -0.01452817115932703, 0.007551904767751694, 0.002599075436592102, -0.02009280025959015, -0.03281426057219505, 0.0146834347397089, 0.012681991793215275, 0.07788483798503876, -0.029719844460487366, 0.03614224120974541, 0.008086047135293484, -0.0031888249795883894, 0.015306266956031322, -0.03516726568341255, 0.004600043408572674, -0.013474264182150364, 0.01911565288901329, -0.012422354891896248, 0.026955902576446533, 0.023474114015698433, -0.05097000673413277, -0.013958190567791462, -0.02351210080087185, -0.03380145505070686, -0.016413532197475433, 0.016006236895918846, 0.007929438725113869, 0.04844645410776138, 0.015685008838772774, 0.004914272576570511, 0.018273519352078438, -0.0024600860197097063, 0.01488913781940937, -0.03366260603070259, -0.023681966587901115, 0.011006752960383892, 0.03741960600018501, 0.022153085097670555, -0.009270168840885162, 0.012007532641291618, -0.006782124750316143, -0.008231478743255138, -0.010765950195491314, 0.009918667376041412, -0.006553103681653738, 0.014546295627951622, -0.032738398760557175, -0.004513544961810112, -0.042442161589860916, 0.003952052444219589, -0.028469998389482498, 0.024930179119110107, -0.04268011823296547, -0.005188989918678999, -0.00800505094230175, 0.0038774574641138315, -0.02628730796277523, -0.03412773460149765, 0.03418388590216637, 0.05822062864899635, 0.02969842404127121, 0.024386033415794373, -0.035903263837099075, -0.006906719878315926, -0.03202640637755394, 0.03568442165851593, -0.008249873295426369, 0.0013895491138100624, -0.01973307505249977, 0.010152841918170452, 0.01906474307179451, 0.00028666044818237424, -0.006491454783827066, -0.0018098545260727406, 0.024732189252972603, 0.006004428490996361, -0.034632034599781036, -0.014882687479257584, 0.06353126466274261, -0.001051484257914126, -0.004200680647045374, -0.03209644928574562, 0.0012451832881197333, 0.022952282801270485, 0.027814866974949837, -0.09108544886112213, 0.023842232301831245, -0.02708980068564415, -0.016393544152379036, -0.006758075673133135, 0.005945040378719568, 0.014321369118988514, -0.025820260867476463, 0.026860827580094337, -0.01851591281592846, -0.02080787904560566, -0.028268467634916306, -0.03873974457383156, -0.004055121447890997, 0.04448714479804039, -0.009612458758056164, -0.04799758642911911, 0.008752609603106976, 0.017593810334801674, -0.00023825147945899516, 0.0024130926467478275, 0.02308996394276619, 0.028942808508872986, 0.006668147165328264, -0.015403889119625092, -0.01896577514708042, 0.08885875344276428, 0.0336814746260643, -0.039230167865753174, -0.01165563054382801, 0.026724757626652718 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
4.2 SWAG [SWAG](https://huggingface.co/datasets/swag) (Situations With Adversarial Generations) is an interesting evaluation in that it detects a model’s ability to infer commonsense! It does this through a large-scale dataset of 113k multiple choice questions about common sense situations. These questions are transcribed from a video scene/situation and SWAG provides the model with four possible outcomes in the next scene. The model then does its’ best at predicting the correct answer. BERT out outperformed top previous top models including human-level performance:
[ 0.0189827848225832, -0.04724640026688576, -0.0026267615612596273, 0.014197638258337975, 0.02328207530081272, 0.04974019527435303, 0.031866468489170074, 0.04109424725174904, -0.014127444475889206, -0.0765657126903534, -0.07054056227207184, 0.055668868124485016, -0.037957411259412766, 0.055777691304683685, 0.02277158759534359, 0.003980289213359356, -0.00002157647213607561, 0.03324243053793907, 0.037266310304403305, -0.008812708780169487, -0.0037594304885715246, -0.056499313563108444, 0.03231249749660492, -0.02837110310792923, 0.07734081149101257, -0.018560776486992836, 0.036547139286994934, -0.034656450152397156, 0.01714984141290188, -0.008253351785242558, -0.1263485699892044, -0.04348649084568024, 0.029461810365319252, -0.035337820649147034, 0.008245903067290783, -0.025570722296833992, -0.06689821928739548, 0.03399311751127243, -0.07214845716953278, 0.01807575672864914, 0.03329171985387802, -0.04061177000403404, -0.04172821342945099, 0.02279827371239662, 0.03219342231750488, -0.04026434198021889, -0.07436003535985947, 0.039432406425476074, -0.06566758453845978, -0.05292844399809837, -0.09361252933740616, 0.08826213330030441, -0.042018596082925797, -0.01719573326408863, 0.04910321906208992, -0.045126963406801224, -0.005876924376934767, -0.08494476228952408, 0.025392718613147736, -0.02752392552793026, 0.0016704617301002145, -0.08458317816257477, -0.0012803517747670412, 0.006781371776014566, 0.008901281282305717, -0.01731501705944538, 0.010422984138131142, 0.011508002877235413, -0.05750875547528267, -0.04560994356870651, -0.0004344090702943504, -0.020268231630325317, -0.016588730737566948, -0.0035272787790745497, -0.02928747422993183, -0.024530764669179916, -0.007459583226591349, 0.00726334098726511, -0.06303851306438446, -0.08440271019935608, -0.06025296822190285, -0.04163983464241028, 0.04531688243150711, 0.08371573686599731, 0.035969749093055725, 0.036652736365795135, 0.05633336678147316, -0.10175411403179169, -0.0498368963599205, 0.04665378853678703, -0.02947739139199257, -0.07894649356603622, 0.019113410264253616, -0.03311781585216522, 0.07036245614290237, 0.0071173463948071, -0.04094315320253372, -0.01756131649017334, 0.04572649672627449, -0.07006528228521347, -0.000009917495845002122, -0.047960083931684494, 0.05223914608359337, -0.07160239666700363, -0.11092188954353333, 0.011139650829136372, -0.022385980933904648, -0.06337065249681473, -0.06499232351779938, 0.099491648375988, 0.01772136799991131, -0.048745956271886826, -0.02762722410261631, 0.03775627538561821, -0.042972177267074585, 0.08859281986951828, 0.007033188361674547, 0.004833531565964222, 0.07148371636867523, -0.0009967661462724209, -0.027530943974852562, 0.02950892224907875, -0.056162893772125244, -0.02483031526207924, 0.0685291513800621, 0.01101814303547144, 0.009645344689488411, 0.05793963745236397, -0.006346764974296093, 0.00412067910656333, 0.010865197516977787, -0.023552799597382545, 0.024107594043016434, 0.04909589886665344, -0.0076307072304189205, -0.01669989340007305, -0.019817590713500977, -0.04521896690130234, 0.003467810805886984, 0.026321198791265488, -0.0062866355292499065, 0.01657131314277649, -0.04557543992996216, -0.014057867228984833, 0.06604015827178955, -0.00980323925614357, -0.07519848644733429, 0.01967770792543888, -0.007876135408878326, 0.06525508314371109, -0.06380344182252884, 0.01384818460792303, -0.04225180670619011, -0.0684337317943573, -0.01893441006541252, 0.03537008538842201, -0.037214890122413635, -0.0281887948513031, -0.03664378821849823, -0.011772161349654198, 0.05328354239463806, -0.018949467688798904, -0.06343095004558563, 0.03413267806172371, 0.05568486079573631, -0.004116659052670002, -0.02825825847685337, 0.03264255076646805, -0.1098962277173996, 0.05854608491063118, 0.016680683940649033, -0.008489374071359634, 0.020382963120937347, 0.0071241906844079494, -0.01221808884292841, 0.058067843317985535, 0.037146177142858505, 0.03395530581474304, 0.059136468917131424, 0.03259553015232086, -0.05566675215959549, 0.010988886468112469, 0.003419894725084305, 0.03055073507130146, 0.09986858814954758, -0.03262237086892128, 0.04346540570259094, -0.021623151376843452, 0.005659084301441908, -0.010276252403855324, -0.0452067106962204, 0.05910264700651169, 0.030735019594430923, -0.03928893059492111, -0.03071214072406292, -0.03470069542527199, -0.030027922242879868, 0.1045139729976654, 0.03159254789352417, -0.03413914516568184, 0.045957211405038834, 0.02250504679977894, 0.031286224722862244, -0.049934882670640945, 0.00988565944135189, 0.01938018575310707, -0.04533315822482109, 0.04592340812087059, -0.010528763756155968, 0.03325250744819641, 0.08088026940822601, -0.08359015733003616, 0.017471428960561752, -0.030061472207307816, -0.0008499255054630339, -0.026090798899531364, 0.015405950136482716, 0.021746650338172913, 0.0057206363417208195, -0.028685422614216805, 0.10528053343296051, -0.09736446291208267, 0.004733237437903881, -0.05319729819893837, 0.03314903378486633, 0.05079779028892517, 0.03605654463171959, 0.09546615183353424, 0.06577426940202713, -0.07106661796569824, 0.026932556182146072, -0.009762563742697239, 0.008719153702259064, -0.032495856285095215, 0.010894308798015118, -0.03701508790254593, 0.07843238115310669, 0.04203523322939873, 0.000436824542703107, -0.048369504511356354, -0.05716993659734726, 0.10522354394197464, -0.0011372278677299619, 0.08045706897974014, -0.003618825925514102, -0.09161865711212158, 0.027323588728904724, 0.022741267457604408, -0.06683739274740219, -0.016575802117586136, -0.10144456475973129, 0.038579486310482025, -0.024020740762352943, -0.005491751246154308, -0.029500411823391914, 0.011765268631279469, 0.005396920256316662, 0.027137093245983124, -0.02124391309916973, 0.06258188933134079, 0.00001796705328160897, -0.037822067737579346, -0.010147741064429283, -0.014739581383764744, 0.028032176196575165, -0.03345559164881706, -0.01850505731999874, 0.043873462826013565, 0.013765069656074047, -0.033375345170497894, -0.027039526030421257, -0.014033902436494827, 0.020043600350618362, 0.014267181977629662, 0.021112103015184402, 0.050257183611392975, 0.03227332979440689, 0.0033761148806661367, -0.002371896291151643, -0.017727455124258995, -0.029189305379986763, 0.004762011580169201, 0.06211084499955177, 0.0024130200035870075, 0.058303091675043106, 0.00861299131065607, -0.008488938212394714, 0.03708220645785332, -0.04901859164237976, 0.017859501764178276, 0.020660221576690674, 0.04282842203974724, -0.015975726768374443, -0.04747070372104645, -0.00002498208050383255, -0.003189703216776252, 0.0029068212024867535, -0.0016873357817530632, 0.0029246483463793993, 0.03828928619623184, -0.007892828434705734, 0.042276449501514435, -0.06440341472625732, 0.012848260812461376, 0.033818673342466354, 0.015035046264529228, 0.009305312298238277, -0.002467420417815447, -0.06961832195520401, 0.019317518919706345, 0.038709573447704315, -0.054819364100694656, -0.03527389466762543, -0.009502943605184555, 0.042675670236349106, -0.003196046222001314, -0.02667420543730259, 0.04277990385890007, 0.010636109858751297, -0.0019224666757509112, 0.022516705095767975, -0.029108170419931412, -0.027056235820055008, 0.011584104970097542, -0.0641784593462944, -0.06825820356607437, 0.031069422140717506, -0.0003753017517738044, 0.011652683839201927, 0.026883849874138832, -0.07359090447425842, 0.01964237354695797, -0.011991770006716251, 0.0014062987174838781, 0.014550824649631977, -0.01072821207344532, 0.03965122625231743, -0.017275286838412285, -0.007346153724938631, 0.034103792160749435, -0.0032017321791499853, -0.00590022886171937, -0.034537576138973236, -0.008847469463944435, 0.018992319703102112, 0.04603555053472519, 0.036462780088186264, 0.04234451428055763, 0.04360213503241539, 0.03348647803068161, -0.021989261731505394, 0.022231927141547203, 0.03335777670145035, -0.01667264848947525, -0.03713315352797508, 0.00493346294388175, 0.03861256316304207, -0.03527120500802994, -0.03495648130774498, -0.02238820306956768, -0.0261719711124897, 0.047362785786390305, -0.0028545106761157513, 0.032259803265333176, 0.05529763922095299, -0.0027347998693585396, -0.018703198060393333, -0.012686633504927158, 0.0005292044370435178, 0.02916187234222889, -0.036946896463632584, -0.045372117310762405, -0.013808457180857658, 0.03927475959062576, 0.029328742995858192, -0.036140359938144684, -0.03507154807448387, 0.026860913261771202, 0.022713422775268555, 0.0689503476023674, 0.00585908954963088, -0.005137626081705093, -0.001405392657034099, 0.010226280428469181, -0.02272436022758484, -0.04835487902164459, 0.04756762087345123, -0.002595598576590419, -0.0288299098610878, -0.01214623637497425, -0.0515812449157238, 0.025051599368453026, 0.0005300536286085844, -0.000319213344482705, 0.04348687082529068, -0.02887548692524433, 0.010280872695147991, 0.03478093817830086, -0.024481642991304398, 0.030001124367117882, -0.0440702848136425, -0.01654684729874134, 0.009400696493685246, 0.007638121023774147, -0.028781913220882416, -0.006821507588028908, 0.009093803353607655, 0.00013745122123509645, 0.00919915921986103, -0.013584165833890438, -0.03599860146641731, 0.001546206884086132, -0.04166765883564949, 0.0558050163090229, 0.018191855400800705, -0.005816596560180187, 0.00032200515852309763, -0.0158478282392025, -0.0016905819065868855, 0.03385090082883835, 0.004421434365212917, 0.0007924620294943452, 0.08431702107191086, -0.021393997594714165, -0.00664245942607522, 0.046543266624212265, -0.026747912168502808, -0.0008588347118347883, 0.0017507944721728563, 0.03123251348733902, 0.004124184604734182, 0.00640097027644515, -0.006036476697772741, -0.006286865100264549, -0.02047180011868477, 0.06969656050205231, -0.0008320728084072471, -0.006781326606869698, 0.0022054133005440235, -0.03117852658033371, 0.05228941887617111, 0.0007349675870500505, 0.029218435287475586, 0.011016571894288063, -0.010018445551395416, 0.030733095481991768, -0.034964803606271744, -0.02648239955306053, 0.02380947209894657, -0.0019372703973203897, 0.03494514524936676, -0.014268971979618073, 0.045584145933389664, -0.022271085530519485, 0.023485204204916954, 0.011569671332836151, -0.02369016595184803, -0.0045441617257893085, 0.017016233876347542, 0.012617251835763454, -0.03601088374853134, -0.020177725702524185, 0.07338560372591019, -0.03484610095620155, -0.018352778628468513, 0.014990764670073986, 0.008624403737485409, 0.020847413688898087, -0.02672993391752243, -0.014518722891807556, -0.031916577368974686, -0.009999604895710945, 0.014350149780511856, 0.035305291414260864, -0.00014654875849373639, -0.004171618726104498, 0.0027807368896901608, -0.02493809163570404, -0.0031384597532451153, -0.013084457255899906, 0.026294009760022163, -0.016668496653437614, 0.0022501207422465086, 0.0459153950214386, -0.015450051054358482, -0.0016225047875195742, -0.00003122961788903922, 0.017698094248771667, -0.0012654843740165234, -0.02231115661561489, 0.02633940614759922, -0.041182223707437515, 0.07950339466333389, 0.02178257517516613, 0.041422039270401, 0.08403529226779938, 0.007257453165948391, 0.0006729193264618516, -0.001120955217629671, -0.017275486141443253, 0.003342780051752925, -0.05008065700531006, 0.02080831117928028, -0.010899078100919724, -0.01256099808961153, 0.04500899463891983, -0.02607050910592079, -0.013682398945093155, 0.023624831810593605, 0.023849958553910255, -0.05315388739109039, -0.03741169348359108, -0.024482037872076035, -0.01940271258354187, -0.031416863203048706, 0.0015466249315068126, 0.024371815845370293, -0.031497661024332047, 0.0013247285969555378, -0.045284684747457504, 0.002997432602569461, -0.003084658645093441, -0.008891557343304157, -0.06115129217505455, -0.03903286159038544, 0.01898322068154812, 0.05005698278546333, 0.051611218601465225, 0.0021211146377027035, 0.00520141189917922, -0.013997357338666916, -0.02410239353775978, -0.013302563689649105, -0.03488073870539665, 0.0013026349479332566, -0.0337253101170063, 0.0036124405451118946, 0.023494891822338104, -0.0073266359977424145, -0.0162447988986969, -0.0003109219833277166, 0.027847956866025925, -0.024990173056721687, -0.013036069460213184, -0.02738489769399166, 0.03353140130639076, 0.05898686498403549, -0.04412027820944786, -0.0026270183734595776, 0.03083077259361744, -0.0015096573624759912, -0.01484768558293581, -0.000039533100789412856, 0.04771729186177254, 0.0023494199849665165, 0.008741166442632675, 0.01643170602619648, -0.055190201848745346, -0.008131355978548527, 0.049569327384233475, -0.02282378450036049, 0.01008816622197628, 0.025946523994207382, 0.03818202391266823, 0.031781330704689026, 0.020989274606108665, 0.034704871475696564, 0.009520751424133778, -0.01935671456158161, -0.054742537438869476, -0.015397499315440655, 0.050069659948349, -0.03738519921898842, 0.011156557127833366, 0.014502787962555885, -0.015630830079317093, 0.05037117749452591, 0.03227606043219566, -0.011905897408723831, -0.008877123706042767, 0.050691064447164536, -0.03622123599052429, -0.015711424872279167, -0.03289569541811943, -0.023456664755940437, 0.060783836990594864, 0.011773274280130863, -0.021042058244347572, 0.012979387305676937, 0.0620715357363224, 0.06593791395425797, 0.013122741132974625, 0.04843368008732796, 0.0016501989448443055, 0.09217537939548492, 0.008671499788761139, 0.03568241745233536, 0.03936873376369476, -0.04125020280480385, 0.027147140353918076, -0.01920943148434162, -0.03779802843928337, -0.01485918927937746, -0.02781270444393158, 0.05431971326470375, 0.008941907435655594, -0.011965962126851082, -0.056927986443042755, 0.02149455063045025, 0.03886715695261955, 0.03050658293068409, 0.011337668634951115, 0.03793514519929886, -0.03414800763130188, -0.0010294625535607338, -0.0008271021069958806, -0.027140306308865547, 0.04528931900858879, -0.0522008053958416, -0.037354327738285065, 0.04864109307527542, -0.0006974850548431277, 0.034863706678152084, 0.03738662227988243, -0.012525354512035847, -0.03210318088531494, 0.0210166834294796, -0.02745731733739376, -0.03395630046725273, 0.01609295792877674, 0.005323857069015503, -0.002919207327067852, -0.0017986774910241365, 0.02885013073682785, 0.019026348367333412, 0.00436899671331048, -0.0014737376477569342, -0.009679420851171017, -0.0041862609796226025, 0.07032333314418793, 0.038534898310899734, -0.01662280783057213, 0.031185932457447052, -0.02438361942768097, -0.0032884618267416954, 0.04730506241321564, -0.038329534232616425, -0.029145346954464912, -0.04451265558600426, 0.02354845404624939, 0.04172414168715477, 0.027366379275918007, 0.0007141283131204545, -0.004669724963605404, 0.016551850363612175, 0.026429804041981697, -0.011937826871871948, -0.025805646553635597, -0.009731556288897991, 0.010491632856428623, -0.01820027083158493, 0.006849311757832766, 0.010347734205424786, -0.046407300978899, -0.011261170729994774, -0.03266523405909538, -0.02966134622693062, -0.011146237142384052, 0.05638376250863075, 0.01994938962161541, 0.06500841677188873, -0.023037943989038467, 0.011444922536611557, -0.02590344473719597, 0.004762721247971058, -0.006337916012853384, 0.031333498656749725, 0.009134254418313503, -0.012856421992182732, -0.012728165835142136, -0.005713932681828737, -0.024304650723934174, -0.017206568270921707, 0.03498087450861931, 0.051662471145391464, -0.029016580432653427, -0.007827268913388252, 0.0521480068564415, 0.026305239647626877, -0.001979527994990349, 0.03593522310256958, 0.01915711537003517, 0.018982425332069397, -0.02338118851184845, -0.02569175511598587, 0.03574342653155327, -0.013389998115599155, 0.0026435372419655323, -0.06363643705844879, -0.02399175427854061, -0.06315365433692932, 0.01873014308512211, 0.018720585852861404, 0.0013012603158131242, -0.016352958977222443, 0.022250007838010788, 0.0007114942418411374, -0.029634691774845123, -0.01588016375899315, 0.022177396342158318, 0.03151773288846016, 0.0023243532050400972, 0.033437732607126236, -0.021631412208080292, -0.0036999518051743507, -0.011494020000100136, -0.00911628920584917, -0.024749403819441795, 0.06320710480213165, -0.00037785398308187723, 0.003460640087723732, -0.027287239208817482, -0.019050942733883858, 0.0020397042389959097, 0.0038421095814555883, -0.002636404475197196, 0.04721822589635849, -0.011688445694744587, -0.008820065297186375, -0.027366045862436295, 0.02553035132586956, -0.034353531897068024, 0.02045249752700329, 0.004569058306515217, 0.022671444341540337, -0.0035511613823473454, -0.007959460839629173, -0.022992447018623352, 0.018809311091899872, -0.0011590077774599195, 0.012538140639662743, 0.05856303870677948, -0.0008182579767890275, -0.000032878273486858234, -0.005881633143872023, -0.00017736201698426157, 0.005253375507891178, -0.013556193560361862, -0.03517749533057213, -0.03636620193719864, 0.06513004004955292, 0.03741993382573128, 0.008152859285473824, -0.020180102437734604, 0.015822190791368484, -0.01609974354505539, -0.00334398471750319, -0.04525435343384743, -0.024991007521748543, 0.022142695263028145, -0.008132265880703926, 0.0036940237041562796, -0.01750830002129078, 0.06503608822822571, 0.034034691751003265, 0.012257535010576248, -0.00746534438803792, -0.0053153554908931255 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
2. How does BERT Work? BERT works by leveraging the following:
[ 0.044781096279621124, 0.028624527156352997, 0.09326160699129105, -0.01644909381866455, 0.10460266470909119, 0.05681801587343216, 0.001076701795682311, 0.06680575013160706, 0.0007832423434592783, -0.06964371353387833, -0.10558250546455383, 0.08212069422006607, 0.002748817205429077, 0.0642719492316246, -0.0324799008667469, 0.0329839326441288, 0.05166688188910484, -0.07609838247299194, 0.005006551742553711, 0.007247958332300186, -0.0377439446747303, -0.05745011568069458, 0.10317901521921158, -0.00395956402644515, 0.06434713304042816, 0.017684824764728546, -0.02444552630186081, -0.012943089939653873, -0.0972244068980217, 0.0705774575471878, -0.05211963877081871, -0.002222602255642414, 0.05266541615128517, 0.007863903418183327, -0.03200158476829529, -0.014364983886480331, -0.10709215700626373, 0.04243513569235802, 0.007083888165652752, -0.048992857336997986, -0.06090568006038666, -0.010079421103000641, -0.03249052166938782, 0.043813593685626984, -0.05657171085476875, -0.024809876456856728, -0.2761531472206116, 0.10755130648612976, -0.0032858652994036674, -0.024624960497021675, -0.09037768840789795, 0.06976885348558426, -0.02716539427638054, 0.04881278797984123, -0.024674545973539352, 0.018748370930552483, 0.0026055239140987396, -0.030884934589266777, 0.034227557480335236, -0.06062464788556099, 0.045625973492860794, -0.018542489036917686, 0.01231773104518652, -0.012712723575532436, 0.05042760446667671, 0.08101612329483032, 0.0014324260409921408, -0.009232370182871819, -0.052370939403772354, 0.024573110044002533, 0.00033692503347992897, -0.04050977900624275, -0.05097265541553497, 0.016489487141370773, 0.013397258706390858, -0.03277241066098213, -0.008174469694495201, 0.022474590688943863, 0.031036999076604843, 0.054029323160648346, 0.006991609465330839, -0.008607485331594944, 0.015949852764606476, 0.07081145793199539, 0.018227359279990196, -0.029461810365319252, 0.09402823448181152, -0.02421749196946621, -0.03329163044691086, 0.01445420365780592, -0.046888016164302826, -0.15264488756656647, -0.04546715319156647, 0.009903022088110447, 0.04089570418000221, -0.03369956463575363, 0.005648335441946983, 0.025636188685894012, 0.012468772009015083, -0.004885570146143436, 0.0019791561644524336, -0.04473097249865532, 0.06684436649084091, -0.00610822718590498, -0.08295951038599014, 0.018788153305649757, 0.023676734417676926, -0.10038039833307266, -0.039034418761730194, 0.01626691222190857, -0.02594645693898201, -0.03374827280640602, 0.03371153399348259, 0.027488848194479942, -0.04209929332137108, 0.011156388558447361, -0.0007737150881439447, 0.00483371876180172, 0.019367225468158722, 0.031078115105628967, -0.030066147446632385, 0.07920949161052704, 0.05180909112095833, 0.01782495155930519, 0.0007889897096902132, -0.018471406772732735, 0.003416291903704405, -0.016222015023231506, -0.012021496891975403, -0.025014225393533707, 0.059524718672037125, -0.004114591516554356, 0.06802713871002197, 0.02935282699763775, -0.019253728911280632, -0.007842620834708214, -0.03307691588997841, -0.02568727545440197, -0.012078044936060905, -0.016434617340564728, -0.025868168100714684, 0.06741289794445038, -0.02748221904039383, 0.0501055046916008, 0.0205366350710392, -0.0033966884948313236, -0.08909659087657928, 0.07827417552471161, -0.04593607783317566, 0.02191513031721115, -0.05274543538689613, 0.02754341810941696, -0.006614252459257841, -0.06600130349397659, 0.005512241739779711, 0.06033596023917198, 0.041589077562093735, 0.007062731776386499, -0.055639222264289856, -0.024040406569838524, 0.05922333523631096, 0.024843862280249596, -0.02603471279144287, 0.0019581166561692953, 0.014241544529795647, -0.038511015474796295, 0.007847994565963745, 0.04292330890893936, -0.009243108332157135, -0.01700296811759472, -0.038259584456682205, 0.012278968468308449, 0.0938885435461998, -0.022806955501437187, -0.041328076273202896, 0.032269105315208435, 0.07849439978599548, 0.02179170586168766, -0.007999630644917488, -0.011231396347284317, -0.03703780472278595, 0.0430394783616066, -0.012403827160596848, 0.018176062032580376, 0.014756912365555763, -0.009296602569520473, 0.01781776174902916, -0.029610101133584976, 0.0067878607660532, 0.021352825686335564, -0.04696834087371826, -0.033471617847681046, 0.0824265405535698, -0.015497932210564613, 0.0021335415076464415, -0.05563617870211601, -0.06432844698429108, 0.11270784586668015, 0.031067220494151115, 0.02286280132830143, 0.05834440514445305, -0.021612301468849182, 0.023862037807703018, -0.018833257257938385, -0.006451329216361046, 0.01855151169002056, 0.09754310548305511, -0.021668830886483192, 0.015630478039383888, -0.0014115333324298263, 0.013695424422621727, -0.0841958224773407, 0.028019806370139122, -0.1235259473323822, -0.03345201537013054, -0.057839285582304, 0.013448750600218773, -0.005405670031905174, 0.018077924847602844, 0.008294626139104366, 0.09864850342273712, -0.04823235794901848, -0.009172258898615837, 0.012484364211559296, -0.014628900215029716, 0.05933823809027672, 0.05379153788089752, 0.01414150558412075, 0.1067008525133133, -0.05803355574607849, -0.03438558056950569, -0.046816401183605194, 0.02819002978503704, 0.05690184235572815, -0.0314674936234951, 0.009888246655464172, 0.010368099436163902, -0.0014069745084270835, 0.045053042471408844, -0.02666229009628296, -0.0037700538523495197, 0.03144080936908722, -0.004754927009344101, 0.061528246849775314, -0.041566476225852966, -0.006416582502424717, 0.05199792981147766, 0.034336354583501816, -0.046395279467105865, 0.008151411078870296, -0.0714559406042099, 0.00775073142722249, 0.00029149296460673213, -0.04678387939929962, 0.05333097279071808, 0.028717029839754105, 0.011460205540060997, -0.0265575610101223, 0.0036444005090743303, 0.01809283345937729, -0.013079844415187836, -0.0703209936618805, -0.01717611774802208, -0.06342457979917526, -0.013565237633883953, -0.0381249338388443, 0.012840243987739086, 0.02484029531478882, -0.011618515476584435, 0.04825485497713089, -0.0020876836497336626, -0.024880388751626015, 0.04285459965467453, -0.002289994852617383, 0.005264952778816223, 0.01299707219004631, 0.037239477038383484, -0.017425602301955223, -0.0303027480840683, -0.01972760446369648, -0.022578218951821327, -0.02496377006173134, 0.044503699988126755, 0.013449462130665779, 0.02911735139787197, -0.027714673429727554, -0.015190502628684044, -0.024151526391506195, 0.01927162893116474, 0.021719902753829956, -0.03416762128472328, 0.03730406239628792, -0.014292375184595585, -0.016353128477931023, 0.050727300345897675, 0.019724734127521515, 0.010034188628196716, 0.01996636763215065, -0.011338816955685616, 0.0004145127022638917, 0.03254067525267601, 0.02464449405670166, -0.030796922743320465, -0.0191459059715271, -0.05107014626264572, 0.03971506282687187, 0.011926592327654362, 0.055261172354221344, -0.13222631812095642, -0.03708082437515259, 0.027177507057785988, 0.0013304823078215122, 0.031942881643772125, -0.005866135470569134, 0.05474753677845001, -0.046449098736047745, -0.048568420112133026, -0.006028514821082354, 0.01962902583181858, 0.031173158437013626, 0.011132797226309776, -0.00033967007766477764, -0.018012862652540207, -0.01208365336060524, -0.03297583386301994, 0.018318984657526016, 0.0014681244501844049, 0.0030836991500109434, -0.016123434528708458, 0.02868751809000969, -0.007493605371564627, -0.019200392067432404, -0.02518344856798649, 0.02670568786561489, -0.006136423442512751, 0.023005258291959763, 0.038433320820331573, -0.006768772844225168, -0.0288859736174345, 0.02368435449898243, -0.005139632150530815, 0.025896413251757622, -0.004446174018085003, -0.008554622530937195, 0.01001493539661169, 0.005983663257211447, 0.03285447880625725, 0.03335219994187355, 0.013348964042961597, 0.023770269006490707, 0.013865000568330288, -0.0004179028619546443, -0.016317911446094513, 0.0019529401324689388, -0.012616939842700958, -0.014063914306461811, 0.050193436443805695, -0.007671326864510775, -0.017601436004042625, -0.016403116285800934, -0.02756110578775406, 0.020256372168660164, -0.00877181626856327, -0.011891438625752926, -0.023414721712470055, -0.01895654946565628, 0.03413306176662445, 0.004225920885801315, -0.006898374762386084, 0.004369435366243124, -0.0011504755821079016, -0.01859644055366516, -0.025964416563510895, 0.04802444577217102, -0.0054855551570653915, 0.042466532438993454, 0.012132273055613041, 0.013438545167446136, -0.005086548160761595, 0.005418736021965742, 0.006216389127075672, 0.019749196246266365, 0.008295348845422268, 0.02502748928964138, -0.013071535155177116, -0.011229264549911022, 0.07803305238485336, -0.01976758800446987, -0.01870810240507126, -0.0032514124177396297, -0.001622912590391934, -0.023703545331954956, 0.009673389606177807, 0.002515577943995595, -0.010183071717619896, -0.0008090477203950286, 0.015789706259965897, 0.01464804820716381, 0.02708093822002411, -0.01570209488272667, 0.0005021232063882053, 0.026827892288565636, -0.01892600767314434, 0.01882762275636196, 0.022555295377969742, 0.0011784739326685667, -0.00031812183442525566, 0.02024245448410511, 0.015216642990708351, -0.03279273211956024, -0.047893885523080826, -0.0008981116116046906, 0.02494436502456665, 0.047094035893678665, -0.024412408471107483, -0.029200468212366104, 0.02011393941938877, 0.011922077275812626, -0.008918702602386475, 0.011215770617127419, 0.010986775159835815, -0.008632542565464973, 0.018906697630882263, 0.016412273049354553, -0.006592790130525827, -0.06701981276273727, -0.04525631293654442, 0.002323425142094493, -0.026235133409500122, 0.04936932027339935, 0.0030104569159448147, -0.001576430513523519, -0.002563646761700511, -0.01416250690817833, 0.027850555256009102, 0.03651691600680351, 0.003995413426309824, -0.020106850191950798, -0.02875712141394615, -0.02194967307150364, 0.028786644339561462, -0.007413111161440611, 0.025789355859160423, 0.008897836320102215, 0.014810843393206596, 0.0291795302182436, 0.013643896207213402, -0.0810135155916214, -0.02156769298017025, 0.004447577055543661, 0.020557139068841934, -0.046493712812662125, 0.04716524854302406, -0.024815522134304047, -0.02379869669675827, -0.022272557020187378, -0.009664448909461498, 0.009519497863948345, 0.04491071030497551, -0.03568193316459656, -0.04746098443865776, -0.02613246813416481, 0.018363840878009796, -0.014338846318423748, 0.004130571149289608, 0.026783401146531105, -0.000510477228090167, 0.07831768691539764, -0.0071631381288170815, -0.020684607326984406, -0.05218029022216797, 0.015186277218163013, 0.0019754895474761724, -0.011439810506999493, 0.011828773654997349, -0.0398893840610981, 0.015169818885624409, 0.02151547372341156, -0.014155594632029533, -0.011339136399328709, 0.008667806163430214, -0.04252462089061737, 0.0019104197854176164, 0.05218245089054108, 0.013695222325623035, 0.013831128366291523, 0.015695499256253242, -0.004226938355714083, 0.013635373674333096, 0.013335789553821087, -0.02585754357278347, -0.0027355130296200514, -0.01979406364262104, -0.00869661569595337, 0.03568688780069351, 0.024594997987151146, -0.030223051086068153, 0.05576507747173309, 0.0020455331541597843, -0.001081613590940833, -0.0017793719889596105, -0.022182175889611244, -0.005298158619552851, -0.011602121405303478, -0.0017801834037527442, -0.0077334800735116005, -0.01585586741566658, 0.027617212384939194, 0.01804742030799389, 0.02192210964858532, -0.024164658039808273, -0.013995497487485409, -0.002275099279358983, 0.001137926010414958, 0.001579473726451397, -0.029769478365778923, 0.01811816543340683, -0.010846806690096855, -0.026718366891145706, -0.0038746148347854614, -0.008390335366129875, 0.0050532459281384945, -0.009591671638190746, -0.050679195672273636, -0.02592979557812214, 0.023100469261407852, 0.0009260380757041276, 0.03577840328216553, 0.018425095826387405, 0.007219038438051939, -0.04000179469585419, 0.05804585665464401, 0.024065427482128143, -0.0434948094189167, 0.010472291149199009, 0.018240872770547867, 0.028730910271406174, 0.02625308744609356, 0.06821103394031525, -0.006745545193552971, -0.020201079547405243, 0.03679613769054413, -0.0033251314889639616, -0.014042382128536701, -0.047552693635225296, 0.035323869436979294, 0.0004127397551201284, -0.014389246702194214, 0.03032577410340309, -0.03288529813289642, -0.05344376340508461, 0.019429342821240425, -0.003173213452100754, 0.0017351497663185, 0.07593783736228943, 0.0030654140282422304, 0.02901742234826088, -0.009940720163285732, 0.00675496319308877, -0.006535332649946213, 0.00479528633877635, 0.011689362116158009, 0.01859986037015915, 0.03259311988949776, 0.015106466598808765, 0.008389504626393318, 0.011279727332293987, -0.0008751879795454443, 0.01991419307887554, -0.02633609250187874, 0.010103798471391201, 0.03015497885644436, -0.02114376239478588, 0.0310563575476408, -0.003233988070860505, -0.0038385186344385147, 0.03397436812520027, 0.022856274619698524, -0.005606109742075205, 0.03282484412193298, 0.008421014994382858, -0.0026648445054888725, 0.014405816793441772, -0.018963322043418884, 0.006186782382428646, 0.07783784717321396, -0.020967913791537285, 0.058323606848716736, 0.031947582960128784, 0.028402868658304214, 0.020904695615172386, -0.01965678296983242, -0.02227819710969925, 0.046846676617860794, 0.04284602403640747, 0.0015847735339775681, 0.04044235125184059, 0.02169770747423172, -0.028671838343143463, 0.009049688465893269, -0.02006860449910164, 0.012740363366901875, -0.04506538063287735, -0.01402965746819973, 0.036550138145685196, -0.022598665207624435, 0.028257593512535095, -0.034999579191207886, 0.020451026037335396, 0.01925930567085743, 0.04212217777967453, -0.016931144520640373, -0.0007703342125751078, -0.0026693427935242653, 0.014998246915638447, 0.002989172702655196, 0.009087548591196537, -0.01849096640944481, 0.006490292958915234, 0.07944721728563309, 0.022424504160881042, 0.012651571072638035, 0.005471506621688604, -0.05883526802062988, 0.05280381068587303, -0.03187773749232292, -0.016084743663668633, 0.020297763869166374, 0.049080219119787216, -0.039504844695329666, -0.017716770991683006, 0.013670623302459717, -0.04839739203453064, 0.0007135704508982599, 0.0034700094256550074, -0.007588659413158894, 0.009455470368266106, -0.027031296864151955, 0.004585894290357828, 0.04756537079811096, 0.021116698160767555, -0.03285602107644081, 0.006149757653474808, 0.033813294023275375, -0.011016353033483028, 0.04664895310997963, -0.009483372792601585, -0.042100585997104645, -0.04380223527550697, -0.0148781668394804, -0.027867188677191734, -0.027155892923474312, 0.019193708896636963, 0.007615178823471069, -0.006755044683814049, 0.033879462629556656, -0.025005871430039406, 0.03772865980863571, 0.0278779286891222, 0.005528148729354143, -0.030579127371311188, 0.009584549814462662, -0.016976892948150635, -0.00497159780934453, -0.011907373555004597, -0.03095434419810772, 0.007627876941114664, 0.00827319547533989, 0.02245268225669861, 0.015584701672196388, 0.04985184594988823, -0.018681367859244347, -0.027345294132828712, -0.0013556423364207149, -0.015936853364109993, -0.04774980619549751, 0.058413125574588776, 0.0673019215464592, -0.017570875585079193, 0.010244744829833508, 0.00901169702410698, -0.00799467507749796, -0.019619105383753777, 0.021651240065693855, 0.003104233182966709, -0.013791747391223907, -0.03552556782960892, -0.011789193376898766, 0.04953189939260483, -0.003848037915304303, 0.016554394736886024, 0.05090835690498352, 0.008175176568329334, 0.006464452017098665, -0.04363258183002472, 0.031909652054309845, -0.012724536471068859, 0.004990564659237862, -0.029797101393342018, -0.04594584181904793, 0.00394662469625473, -0.02455938421189785, 0.015177409164607525, 0.0018514069961383939, -0.04929327219724655, -0.01113827619701624, 0.005677823442965746, 0.011356071569025517, -0.03560056537389755, 0.04930415377020836, 0.05746261775493622, 0.010101205669343472, 0.038934338837862015, 0.001044933102093637, -0.01020242553204298, -0.05890750139951706, -0.004270656034350395, 0.004268159624189138, 0.031263407319784164, 0.0362873449921608, -0.021230222657322884, -0.020397625863552094, -0.005375661887228489, -0.022679360583424568, -0.06238994374871254, 0.015500722452998161, 0.017915911972522736, -0.012770256027579308, -0.007105262950062752, -0.0012514172121882439, 0.01729613170027733, -0.01948733627796173, 0.043748050928115845, 0.003689415054395795, -0.03836662694811821, -0.0337115041911602, -0.006025295704603195, -0.05529149994254112, -0.042674850672483444, 0.012893334962427616, -0.01670423150062561, 0.053417086601257324, 0.038547154515981674, -0.000880594365298748, -0.014800417236983776, -0.02349834516644478, 0.041730787605047226, -0.010134070180356503, -0.025755494832992554, -0.02450473979115486, -0.01258891262114048, -0.03155308961868286, -0.046862415969371796, -0.05756494030356407, 0.03463189676403999, 0.01925836317241192, -0.007865597493946552, -0.014316926710307598, -0.013847032561898232, -0.015008671209216118, -0.020136190578341484, 0.02918792888522148, -0.010127721354365349, 0.07852121442556381, 0.01833072118461132, -0.003341357223689556, 0.030872883275151253, 0.014313029125332832 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
4.3 GLUE Benchmark [GLUE](https://huggingface.co/datasets/glue) (General Language Understanding Evaluation) benchmark is a group of resources for training, measuring, and analyzing language models comparatively to one another. These resources consist of nine “difficult” tasks designed to test an NLP model’s understanding. Here’s a summary of each of those tasks: While some of these tasks may seem irrelevant and banal, it’s important to note that these evaluation methods are _incredibly_ powerful in indicating which models are best suited for your next NLP application. Attaining performance of this caliber isn’t without consequences. Next up, let’s learn about Machine Learning's impact on the environment.
[ -0.00642689922824502, 0.038815416395664215, -0.046483155339956284, -0.01852346770465374, 0.010700535960495472, 0.04804594814777374, 0.036413922905921936, 0.018244203180074692, -0.07864978164434433, -0.017515884712338448, 0.0032877756748348475, 0.08868391811847687, -0.05861934646964073, 0.05829254165291786, 0.009176259860396385, 0.03964456543326378, -0.0016637345543131232, 0.020772110670804977, -0.009223570115864277, 0.007917660288512707, -0.02989770844578743, -0.008008374832570553, 0.04776740446686745, 0.012268618680536747, 0.023829655721783638, -0.03537105768918991, 0.013149824924767017, -0.02501983754336834, -0.012836592271924019, -0.017762459814548492, -0.13376553356647491, -0.013877516612410545, -0.0468658022582531, -0.03992573544383049, 0.04222077876329422, 0.036822039633989334, -0.0827571302652359, 0.05864114686846733, -0.005051503889262676, -0.057607825845479965, 0.04343819618225098, -0.007339994423091412, -0.00017452547035645694, 0.010514592751860619, 0.02964641898870468, 0.04152105003595352, -0.12047459930181503, 0.04776686429977417, -0.0324711874127388, 0.024531779810786247, -0.12943758070468903, 0.07544589787721634, 0.030356429517269135, -0.04515034705400467, 0.007094674278050661, -0.034955091774463654, 0.05406391993165016, -0.06520112603902817, 0.06161804869771004, -0.01625725068151951, 0.05783624202013016, -0.04084286466240883, 0.05231355503201485, 0.029272807762026787, 0.028840404003858566, -0.01690143346786499, 0.001047459663823247, 0.03906089812517166, -0.07185634970664978, -0.03629481792449951, 0.0048881592229008675, -0.03625188022851944, -0.013180240988731384, 0.019448375329375267, 0.0021250254940241575, -0.019821200519800186, 0.018875133246183395, -0.007521993014961481, -0.0030246712267398834, 0.020619241520762444, -0.0366084910929203, 0.01502008456736803, 0.03112117201089859, 0.039375629276037216, -0.0024607686791568995, 0.027433030307292938, 0.026461228728294373, -0.06726732105016708, -0.14244040846824646, 0.09216729551553726, 0.020494237542152405, -0.06133601814508438, -0.01570035144686699, -0.022690141573548317, 0.04354969784617424, -0.07115883380174637, -0.010097391903400421, 0.07458074390888214, -0.04981928691267967, -0.017209067940711975, 0.03001166135072708, -0.030746327713131905, 0.04884084314107895, 0.004618201404809952, -0.012154882773756981, 0.0008700312464497983, -0.075460284948349, -0.05177157744765282, -0.039524756371974945, 0.0167763140052557, 0.026705609634518623, -0.05105610936880112, -0.03663744404911995, 0.08066403865814209, -0.06694977730512619, 0.04101751372218132, -0.06124107912182808, 0.05955611169338226, -0.015443366020917892, 0.020693153142929077, 0.0027552226092666388, 0.04789178818464279, 0.017475096508860588, -0.04700259491801262, -0.0062348260544240475, 0.0661056786775589, 0.04404705762863159, -0.025671185925602913, 0.037788670510053635, -0.041576411575078964, 0.03618043288588524, -0.10784982144832611, 0.030177665874361992, 0.05185991898179054, 0.004346837755292654, -0.03995826467871666, -0.017308639362454414, -0.034072715789079666, 0.004863016773015261, 0.05309726670384407, 0.036904312670230865, 0.0055228970013558865, -0.044627852737903595, 0.005826442968100309, 0.009493564255535603, -0.010844353586435318, -0.05768725275993347, -0.02745847962796688, -0.01526600681245327, 0.003882872173562646, -0.09888783097267151, 0.07598479092121124, -0.025153174996376038, 0.02046510949730873, 0.06378436088562012, 0.07774855196475983, 0.001766353496350348, -0.06861938536167145, -0.05000036954879761, 0.01826859824359417, -0.040815792977809906, -0.06794670969247818, -0.08930367976427078, -0.007359912618994713, 0.010562615469098091, 0.0048423344269394875, -0.06279934197664261, 0.037221409380435944, -0.05640792101621628, 0.015614955686032772, 0.020927246659994125, -0.030403440818190575, 0.06813033670186996, -0.03633344545960426, -0.024394091218709946, -0.017740527167916298, 0.01039805542677641, 0.032525233924388885, 0.045084401965141296, 0.024474868550896645, -0.030008288100361824, 0.07719118893146515, 0.034846026450395584, 0.057321224361658096, 0.0774555578827858, -0.05689167231321335, 0.02981514111161232, -0.011460770852863789, 0.008232539519667625, -0.023469436913728714, -0.06603125482797623, -0.019692357629537582, 0.11470644921064377, -0.05305903032422066, -0.011246955953538418, -0.06782488524913788, 0.013459449633955956, 0.11072511970996857, 0.06850770115852356, -0.013150129467248917, 0.04426105320453644, -0.005045582074671984, 0.03578492999076843, -0.0591137669980526, 0.009230108000338078, -0.017624974250793457, -0.03514263033866882, -0.03658387064933777, -0.05087324231863022, 0.00958964228630066, 0.06158928573131561, -0.06347806006669998, 0.05003130063414574, 0.010855340398848057, -0.03973395377397537, -0.03574223816394806, -0.022976884618401527, 0.0412658266723156, 0.027387823909521103, -0.01885032467544079, 0.1618136614561081, -0.06499193608760834, 0.025685377418994904, -0.012278731912374496, -0.05674796178936958, 0.030348189175128937, 0.033322159200906754, 0.10289916396141052, 0.037353336811065674, -0.01474189106374979, 0.03239202871918678, -0.08473112434148788, -0.018807001411914825, 0.020514441654086113, -0.03443028777837753, -0.10461563616991043, 0.05232057347893715, 0.06730141490697861, 0.03992442786693573, -0.036039870232343674, -0.058321114629507065, 0.044463831931352615, 0.08940326422452927, 0.06563764065504074, 0.029506400227546692, 0.0015635122545063496, 0.01578785851597786, -0.06415149569511414, -0.06319757550954819, 0.00036805259878747165, -0.02219241112470627, 0.0022906484082341194, -0.02541094645857811, 0.015066280961036682, -0.03621891513466835, -0.02576546184718609, 0.03144852817058563, 0.0015631831483915448, -0.017785927280783653, 0.04246019944548607, -0.00183815136551857, 0.036843910813331604, -0.0680418312549591, -0.023685073480010033, 0.035212479531764984, -0.06470060348510742, 0.006649792660027742, -0.007024901453405619, 0.019931213930249214, 0.02054589055478573, -0.011419887654483318, 0.0037407909985631704, 0.027346787974238396, -0.03653497248888016, -0.03148280084133148, 0.02567250095307827, 0.009417100809514523, -0.02532980963587761, -0.029695864766836166, -0.013445050455629826, -0.0175759457051754, 0.005253949202597141, 0.03660263866186142, 0.008123420178890228, 0.009533165954053402, 0.0028904657810926437, 0.0035642015282064676, -0.011624885722994804, -0.046486061066389084, -0.001097824890166521, 0.005093216896057129, 0.0016795446863397956, -0.019291382282972336, -0.05877339839935303, 0.017577867954969406, -0.04125269502401352, 0.02420205995440483, -0.025379810482263565, -0.013987523503601551, 0.03087797574698925, -0.009085135534405708, 0.04258478432893753, -0.08459599316120148, -0.013830911368131638, -0.010570690035820007, 0.06526479870080948, 0.038874171674251556, 0.004593428689986467, -0.07338422536849976, 0.0015458818525075912, -0.0024982267059385777, 0.013761736452579498, -0.010438652709126472, -0.0453491173684597, 0.04357701912522316, 0.028886355459690094, 0.016206879168748856, 0.030022652819752693, -0.00209787511266768, -0.03750504180788994, 0.07566279172897339, 0.029055103659629822, -0.015437883324921131, -0.0021103050094097853, -0.019120821729302406, -0.06250116974115372, 0.028416264802217484, 0.009910077787935734, -0.0001307250204263255, 0.002977650845423341, 0.009875773452222347, -0.023846667259931564, -0.03713523969054222, 0.04678916186094284, 0.031781744211912155, -0.020958121865987778, 0.02263610251247883, -0.00506302434951067, 0.006497132126241922, -0.017014911398291588, -0.01876847632229328, 0.013094493187963963, -0.018831241875886917, -0.021321281790733337, -0.02133672684431076, 0.024193866178393364, 0.05437783524394035, 0.0031452190596610308, 0.03034941479563713, 0.03280527889728546, 0.034041550010442734, -0.019117506220936775, 0.005429917015135288, 0.002762129995971918, -0.026801085099577904, 0.0005756768514402211, -0.023706266656517982, -0.013776673004031181, -0.01781490072607994, -0.009250822477042675, -0.006400654092431068, 0.03603317588567734, 0.007474005222320557, 0.0150145897641778, 0.010355989448726177, -0.03193221241235733, 0.01987980492413044, -0.014300968497991562, -0.025868020951747894, -0.01168366614729166, -0.01271521020680666, -0.052939191460609436, -0.04962548613548279, -0.02133970335125923, -0.0011537300888448954, -0.02274002693593502, -0.02348988875746727, 0.04392419382929802, 0.012323309667408466, 0.03625445440411568, -0.02313290163874626, -0.0021559474989771843, -0.06055750697851181, -0.01706666871905327, -0.011702139861881733, -0.02998354099690914, 0.06341920047998428, 0.03899964317679405, -0.08497215807437897, -0.03632514551281929, -0.061137136071920395, 0.0031080571934580803, 0.04639868810772896, -0.002848253585398197, 0.015515054576098919, -0.028273550793528557, 0.03256869688630104, 0.03763079270720482, 0.005116667132824659, -0.004393499810248613, -0.023357121273875237, -0.008753797970712185, -0.028298519551753998, -0.047076545655727386, 0.02766445465385914, 0.019557638093829155, -0.003769563278183341, -0.019797777757048607, 0.007174911443144083, -0.047189824283123016, 0.010494517162442207, 0.01691846363246441, 0.025372717529535294, 0.04775116220116615, -0.03191588819026947, -0.008869788609445095, -0.004314659163355827, 0.006266302894800901, -0.00038719098665751517, 0.003158980282023549, -0.016228515654802322, -0.025986967608332634, 0.027597930282354355, 0.04297513887286186, 0.0035935058258473873, 0.029015913605690002, -0.02499745972454548, 0.005529141053557396, 0.001412722165696323, 0.015809277072548866, 0.019154362380504608, 0.012065853923559189, 0.013143504969775677, 0.01575271598994732, -0.0072534880600869656, 0.02406271919608116, -0.0019439366878941655, -0.040701668709516525, -0.01872856356203556, 0.006928242277354002, 0.02508525364100933, 0.0060004182159900665, -0.0016638245433568954, 0.00914907455444336, -0.023351401090621948, 0.03611661493778229, -0.0078018177300691605, 0.0002502197748981416, 0.039915118366479874, 0.015829669311642647, 0.047442808747291565, 0.02940363623201847, -0.013786637224256992, 0.03857226297259331, 0.0020391950383782387, -0.00883196946233511, -0.03462180495262146, 0.0523141585290432, 0.03323208540678024, -0.004994888789951801, -0.04234486445784569, 0.032411396503448486, 0.04594429209828377, -0.017248235642910004, -0.013778923079371452, 0.0052467524074018, -0.018810831010341644, 0.04658661037683487, -0.011639822274446487, -0.02423744834959507, -0.01648622751235962, -0.00008544672891730443, -0.0103245684877038, -0.006116400472819805, -0.028483670204877853, -0.023827701807022095, 0.011976920999586582, -0.01770547777414322, 0.02970297262072563, -0.01854468695819378, -0.011088178493082523, 0.0016117324121296406, 0.011669720523059368, 0.0342555046081543, 0.01352692861109972, 0.020747993141412735, -0.005130907986313105, 0.01908503845334053, -0.032628897577524185, -0.04073125496506691, 0.027650058269500732, 0.00021815847139805555, 0.025226842612028122, 0.054660502821207047, 0.04415958374738693, 0.06522004306316376, 0.00047782028559595346, 0.0022963285446166992, 0.0011657052673399448, -0.011206313967704773, 0.062224309891462326, -0.009480091743171215, 0.017362939193844795, -0.018598642200231552, 0.034144870936870575, -0.011907822452485561, -0.015812568366527557, -0.02462669275701046, 0.034844737499952316, 0.027413761243224144, -0.03924325108528137, -0.04713765159249306, 0.020562849938869476, 0.004658529534935951, -0.053006112575531006, -0.04391008988022804, 0.04891534149646759, -0.05349364131689072, -0.02721618302166462, -0.026837460696697235, -0.06685902923345566, -0.0089474618434906, 0.01443429384380579, -0.03924396634101868, 0.025742359459400177, -0.002403810154646635, 0.026780271902680397, 0.02219218946993351, -0.026538612321019173, -0.01443680003285408, -0.006394634488970041, -0.030261144042015076, 0.02153921313583851, -0.05480138212442398, -0.001088902004994452, -0.03560885414481163, 0.006309399381279945, -0.02165406383574009, 0.00048133640666492283, 0.00116466183681041, 0.01951606757938862, 0.018742749467492104, 0.008304359391331673, 0.0394207201898098, -0.006937377154827118, 0.009598109871149063, 0.06510389596223831, -0.02274933271110058, -0.04634566605091095, 0.04655461013317108, -0.03785674646496773, 0.0016674073413014412, -0.046320609748363495, 0.025066908448934555, 0.06497027724981308, 0.014075489714741707, 0.02902889996767044, -0.016149304807186127, 0.01332911942154169, 0.04112179949879646, -0.021925166249275208, 0.012210709974169731, 0.030117643997073174, 0.020430583506822586, -0.012977213598787785, 0.04557669907808304, 0.0040079024620354176, 0.012172706425189972, 0.02717912755906582, -0.023648159578442574, 0.01517544873058796, 0.04964904859662056, -0.03717151656746864, 0.03237453103065491, -0.007351446431130171, -0.04893072694540024, 0.01500118151307106, 0.014335369691252708, -0.013439839705824852, 0.01824835315346718, 0.039560310542583466, 0.004485071636736393, 0.04179584980010986, -0.014069975353777409, -0.009437383152544498, 0.07204408198595047, 0.02579226717352867, 0.00669363746419549, 0.02053971402347088, 0.0297540370374918, 0.03583343327045441, 0.029948247596621513, 0.022409901022911072, 0.0070843505673110485, 0.06597782671451569, 0.029045943170785904, 0.0415131151676178, 0.010430704802274704, -0.022999243810772896, -0.03094647079706192, -0.021897051483392715, -0.0596376433968544, -0.040499791502952576, 0.008253981359302998, 0.0588504895567894, 0.006746042985469103, 0.010175763629376888, -0.016344275325536728, 0.0022874732967466116, 0.017649397253990173, 0.00704526249319315, -0.03296570107340813, -0.0009098037262447178, -0.007406936958432198, 0.00025011965772137046, 0.004708827938884497, 0.0400007925927639, 0.035400524735450745, -0.027623577043414116, 0.027283895760774612, 0.031310439109802246, 0.004363628104329109, 0.030280880630016327, -0.0001868064427981153, -0.009385674260556698, -0.04264422506093979, 0.017954785376787186, 0.001950003206729889, -0.007633517496287823, -0.004057000856846571, -0.0026360154151916504, -0.017064949497580528, 0.010871401987969875, 0.01768263429403305, -0.02484316937625408, -0.004287790972739458, -0.0190352201461792, -0.015449797734618187, -0.012322705239057541, 0.029842957854270935, -0.011308071203529835, -0.0492088608443737, -0.002396156545728445, -0.03173121064901352, -0.004624023102223873, 0.016963379457592964, -0.0570753775537014, -0.035609420388936996, -0.026255296543240547, 0.032753534615039825, -0.007179343141615391, -0.0010070831049233675, 0.03169547766447067, -0.038290999829769135, 0.04061025753617287, 0.025947164744138718, -0.02191058360040188, 0.009191694669425488, 0.031011207029223442, 0.04578038677573204, -0.04158566892147064, 0.036754921078681946, 0.019697852432727814, -0.01708844304084778, 0.05537167191505432, 0.0003945947391912341, -0.026762939989566803, -0.003965168725699186, 0.020943330600857735, -0.0071595050394535065, 0.06552338600158691, 0.006758898496627808, 0.011667772196233273, -0.026606695726513863, -0.014194442890584469, -0.03048914112150669, 0.04153837263584137, -0.006666100583970547, -0.03764345496892929, -0.014453736133873463, -0.03332802653312683, 0.029958399012684822, -0.007063787896186113, 0.00903209950774908, 0.06534705311059952, -0.00681988475844264, -0.005119478330016136, -0.018092596903443336, -0.000521548034157604, 0.023718563839793205, 0.0442882664501667, 0.004586008843034506, 0.007412583101540804, 0.024197954684495926, -0.021174106746912003, 0.08396885544061661, -0.0055856844410300255, -0.00962607841938734, -0.03242093324661255, 0.0035600231494754553, -0.03350766375660896, 0.02735564298927784, -0.00845204759389162, 0.03002481907606125, -0.023233851417899132, -0.0222964845597744, -0.014427212998270988, -0.0009705700213089585, 0.0037372643128037453, 0.02331516146659851, 0.0306442528963089, 0.019982971251010895, 0.0081116808578372, 0.018724307417869568, -0.046157702803611755, 0.05045044794678688, -0.016136448830366135, 0.002417753916233778, 0.07211808860301971, 0.0070143574848771095, -0.017568165436387062, -0.00512373261153698, -0.006696140393614769, 0.015456939116120338, -0.03210137411952019, 0.028876321390271187, 0.05346033722162247, 0.02982708252966404, -0.005729141179472208, 0.028962193056941032, 0.00007287524204002693, 0.002122346544638276, 0.038013409823179245, 0.02184991165995598, 0.006267636548727751, -0.014995484612882137, -0.02049243450164795, -0.057579588145017624, -0.019995450973510742, 0.0005881014512851834, 0.006093272473663092, 0.016816172748804092, 0.0015412484062835574, 0.034967344254255295, -0.021432261914014816, -0.04105361923575401, -0.022532805800437927, -0.005357474088668823, -0.03819798678159714, 0.003269971115514636, -0.01402193307876587, 0.0460532009601593, -0.018061785027384758, -0.007496895734220743, 0.0352637805044651, -0.02662440948188305, 0.025941992178559303, -0.045878760516643524, -0.006929547525942326, -0.01007277611643076, -0.014527532272040844, -0.0053803338669240475, -0.02772730030119419, 0.017475632950663567, 0.034203942865133286, 0.003101104637607932, -0.01689673401415348, 0.03910713642835617 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
7. How to get started using BERT We've [created this notebook](https://colab.research.google.com/drive/1YtTqwkwaqV2n56NC8xerflt95Cjyd4NE?usp=sharing) so you can try BERT through this easy tutorial in Google Colab. Open the notebook or add the following code to your own. Pro Tip: Use (Shift + Click) to run a code cell. Note: Hugging Face's [pipeline class](https://huggingface.co/docs/transformers/main_classes/pipelines) makes it incredibly easy to pull in open source ML models like transformers with just a single line of code.
[ 0.02734440192580223, -0.0148202208802104, 0.022801917046308517, -0.0038222698494791985, 0.06355056911706924, 0.07135642319917679, 0.021900387480854988, 0.05239848047494888, 0.02816305123269558, -0.05008876696228981, -0.082482248544693, 0.07967665046453476, -0.015484211035072803, 0.07313571125268936, 0.049724120646715164, -0.03730086237192154, 0.04113708436489105, -0.01805933006107807, 0.010012946091592312, -0.0018421630375087261, -0.008183998987078667, -0.03627887740731239, 0.04482899606227875, 0.007893060334026814, 0.03320777043700218, -0.060445260256528854, 0.04475027322769165, 0.044432077556848526, -0.04319768399000168, 0.05829574167728424, -0.07857317477464676, 0.03270197659730911, 0.03742193430662155, -0.016411952674388885, -0.00733842421323061, 0.025883860886096954, -0.07361500710248947, 0.05969759449362755, 0.04327117279171944, -0.006958452519029379, -0.031039288267493248, -0.020000815391540527, -0.0157028641551733, 0.053818028420209885, -0.0631815642118454, -0.008782151155173779, -0.21375742554664612, 0.06809363514184952, -0.022615622729063034, -0.01953977160155773, -0.04058040305972099, 0.10156404972076416, 0.004880760796368122, -0.023495910689234734, -0.02834995649755001, 0.022644922137260437, 0.026944441720843315, -0.04722306504845619, -0.0019207570003345609, -0.021120315417647362, 0.07087431848049164, -0.01107783429324627, 0.001757809892296791, 0.027639122679829597, 0.016216134652495384, 0.03054736740887165, -0.037813231348991394, -0.00956230890005827, -0.09443105757236481, 0.016023866832256317, 0.029862217605113983, -0.06610813736915588, -0.06087411567568779, -0.024380339309573174, 0.01577840745449066, -0.048025693744421005, 0.032986532896757126, 0.02905239909887314, 0.03969927132129669, 0.05701020359992981, 0.0201032105833292, 0.005849333480000496, 0.0022563801612704992, 0.04696999117732048, 0.06828347593545914, 0.054504282772541046, 0.016978509724140167, -0.01520450133830309, -0.05212529003620148, 0.07788564264774323, -0.018208066001534462, -0.16234458982944489, -0.03453011065721512, -0.009374255314469337, 0.060374077409505844, -0.06342955678701401, -0.023151444271206856, 0.025246093049645424, -0.015259815379977226, -0.03954329714179039, -0.0058428761549293995, -0.06483281403779984, 0.05534738674759865, -0.0028225239366292953, -0.06516353040933609, 0.013607669621706009, 0.01009818073362112, -0.07890130579471588, 0.009428068064153194, -0.02016151323914528, 0.0012192717986181378, -0.06890532374382019, -0.020647048950195312, 0.0758533701300621, -0.08481469005346298, 0.047034744173288345, 0.04115121811628342, -0.011259161867201328, -0.0041381968185305595, 0.024803102016448975, -0.03625398874282837, 0.05289662256836891, 0.024424215778708458, -0.022169459611177444, 0.0046526724472641945, 0.06539981067180634, -0.032278142869472504, 0.013769173063337803, 0.01958741992712021, -0.010141209699213505, 0.08120546489953995, -0.03667619824409485, 0.0873611718416214, -0.0323709137737751, 0.03553670644760132, -0.023240037262439728, 0.026605455204844475, -0.06106742098927498, -0.00670589180663228, 0.003874352667480707, -0.0011924420250579715, 0.08492903411388397, -0.01053908746689558, 0.047391436994075775, 0.09895674139261246, 0.007989192381501198, -0.12382415682077408, 0.0626460611820221, -0.057991694658994675, 0.05035140737891197, -0.09193740785121918, 0.021135956048965454, -0.014062300324440002, -0.031889840960502625, 0.0033889415208250284, 0.07100998610258102, 0.0037782297004014254, -0.01420607790350914, -0.010573117062449455, -0.012470151297748089, 0.037027474492788315, 0.02011430822312832, -0.06002931296825409, 0.01739564538002014, -0.01114202756434679, -0.06458423286676407, 0.014108500443398952, -0.014242524281144142, 0.029491452500224113, 0.020127413794398308, 0.0011473518097773194, -0.02966516651213169, 0.0635606050491333, -0.013378121890127659, -0.0030772846657782793, 0.029611272737383842, 0.08847802132368088, 0.03382183238863945, 0.020485997200012207, -0.02067536488175392, -0.04500787705183029, 0.054095927625894547, 0.016905153170228004, 0.010842475108802319, 0.038020193576812744, -0.07030629366636276, 0.027446044608950615, -0.021571671590209007, -0.015535489656031132, -0.020992938429117203, 0.008838905021548271, -0.03025432489812374, 0.09822225570678711, -0.005367165431380272, 0.028347278013825417, -0.034412968903779984, -0.0366256982088089, 0.08716422319412231, 0.007158302702009678, 0.03168898820877075, 0.05498119443655014, -0.03265676647424698, 0.022914445027709007, -0.031150469556450844, -0.018760379403829575, -0.015187878161668777, 0.07213816046714783, -0.0405656062066555, 0.04365896061062813, -0.011952642351388931, 0.008466786704957485, -0.09645724296569824, 0.06751658022403717, -0.09433404356241226, 0.020462192595005035, -0.08777020871639252, -0.01889239065349102, 0.04566958546638489, 0.05946728214621544, 0.031487852334976196, 0.1659252643585205, -0.06556586176156998, -0.01375285629183054, -0.004158103372901678, -0.035791054368019104, 0.029664328321814537, 0.09682537615299225, 0.0655732974410057, 0.11530091613531113, -0.06420627981424332, -0.0637582391500473, -0.03508363291621208, 0.02900591865181923, 0.05102359503507614, -0.04725257307291031, -0.008045019581913948, 0.004339155275374651, -0.03226834163069725, -0.0014507533051073551, -0.016180358827114105, 0.024679996073246002, -0.014456333592534065, 0.0017612603260204196, 0.014296883717179298, -0.031239986419677734, -0.01391866896301508, 0.048636678606271744, 0.043555352836847305, 0.018744071945548058, -0.005192620679736137, -0.053744666278362274, -0.0128360316157341, -0.01345962006598711, -0.03864879906177521, -0.0006371532799676061, 0.057408932596445084, -0.0008527682512067258, 0.0010103697422891855, -0.023931188508868217, 0.026365796104073524, 0.004164903424680233, -0.032622821629047394, -0.046440351754426956, -0.04460866004228592, -0.03556734323501587, -0.025315914303064346, -0.04550831764936447, 0.0328349843621254, -0.0020043300464749336, 0.025386832654476166, 0.023734474554657936, -0.03386807069182396, 0.049911729991436005, 0.022006968036293983, 0.02031608670949936, 0.014719177968800068, 0.03555390238761902, -0.012788529507815838, -0.028504738584160805, -0.01430794969201088, -0.009110074490308762, -0.028788821771740913, 0.03245885670185089, 0.022478805854916573, 0.03857136517763138, -0.010140979662537575, -0.009525065310299397, -0.03765137866139412, 0.021693965420126915, 0.003972696140408516, -0.021787745878100395, 0.036143384873867035, -0.011397577822208405, -0.030700935050845146, 0.013506963849067688, 0.0035015325993299484, 0.04410160705447197, -0.011666878126561642, -0.022443896159529686, 0.01667374186217785, -0.0053998506627976894, -0.006082297768443823, -0.0035515371710062027, -0.026285996660590172, -0.026790998876094818, 0.011398657225072384, 0.04980147257447243, -0.0002839861554093659, -0.11124664545059204, -0.02545437589287758, -0.00707389647141099, -0.0026007257401943207, 0.031946830451488495, -0.03179939091205597, 0.04342549294233322, -0.013066439889371395, -0.04678461328148842, -0.010983980260789394, -0.038488615304231644, 0.0019114649621769786, -0.0059568858705461025, 0.005218678619712591, -0.010609530843794346, -0.012240002863109112, -0.04563135281205177, 0.022959671914577484, 0.03036499209702015, 0.045131076127290726, -0.04485810175538063, 0.06222014129161835, -0.011589670553803444, 0.00005342622534953989, 0.033483151346445084, -0.008111324161291122, 0.006566115655004978, 0.040462248027324677, 0.039260320365428925, -0.015135501511394978, 0.00764806242659688, -0.007016846910119057, -0.025573870167136192, 0.022806089371442795, -0.014746038243174553, 0.006750321481376886, 0.015558394603431225, 0.036672741174697876, 0.026979263871908188, 0.020055444911122322, 0.011918330565094948, -0.013617471791803837, -0.017581308260560036, -0.02291031926870346, 0.010030613280832767, -0.019846299663186073, -0.01668260060250759, 0.02411351352930069, 0.007678442168980837, -0.03770594671368599, -0.02099223993718624, 0.00122316915076226, 0.00025168780121020973, 0.006893135607242584, 0.009265779517591, -0.00951392576098442, 0.0052967369556427, 0.015398377552628517, 0.01900518499314785, 0.012274709530174732, -0.05264187976717949, 0.01154820155352354, -0.023900913074612617, -0.02882390469312668, -0.013170394115149975, 0.03967367485165596, 0.04574909433722496, 0.02466924674808979, -0.003697160864248872, 0.03304367884993553, 0.0006168965483084321, 0.02020109072327614, 0.036952242255210876, 0.006972489878535271, -0.017889132723212242, 0.02950950525701046, -0.022150663658976555, -0.030025649815797806, 0.07357259839773178, 0.012310216203331947, -0.030915450304746628, -0.032019276171922684, -0.01847222074866295, -0.02468540333211422, -0.0050460644997656345, -0.0197603702545166, 0.022145694121718407, -0.037983428686857224, 0.02344081923365593, 0.045269694179296494, -0.009390481747686863, -0.037714436650276184, 0.013313086703419685, 0.007073931396007538, 0.015027615241706371, -0.007907753810286522, -0.003976762294769287, 0.001510192989371717, 0.009854409843683243, -0.0030932812951505184, 0.011421633884310722, -0.01846819929778576, -0.01796441711485386, 0.019171953201293945, 0.031592436134815216, 0.059723418205976486, -0.034849077463150024, -0.035334743559360504, 0.020337237045168877, -0.02558259852230549, 0.0024125557392835617, -0.008337415754795074, -0.011108708567917347, 0.002245221985504031, 0.012210041284561157, 0.028232373297214508, 0.00850121583789587, -0.05544412136077881, -0.04973168671131134, 0.0022722675930708647, -0.024038664996623993, 0.00021092448150739074, -0.014490180648863316, -0.00022503217041958123, 0.0066605135798454285, -0.009098897688090801, 0.05127156525850296, 0.04137207940220833, -0.008587946183979511, 0.007791801821440458, -0.04104839265346527, -0.04970288649201393, 0.015556828118860722, -0.010577796958386898, -0.005547766108065844, 0.01534272264689207, -0.013994786888360977, 0.009378654882311821, -0.016067931428551674, -0.028529223054647446, -0.012574379332363605, -0.003587177721783519, 0.053650859743356705, -0.05577951669692993, 0.03978634998202324, 0.01333338301628828, -0.05918930470943451, -0.012595160864293575, -0.012526500038802624, 0.002185054123401642, 0.024379903450608253, -0.010929368436336517, -0.057390980422496796, 0.026283858343958855, 0.02666581980884075, -0.03181168809533119, 0.0022193794138729572, 0.052839312702417374, 0.006219003815203905, 0.050447605550289154, -0.02314465120434761, -0.01435618195682764, -0.034956734627485275, 0.04552353918552399, 0.005134581122547388, -0.008235673420131207, 0.024445220828056335, -0.04013723134994507, 0.017982326447963715, 0.009411843493580818, -0.028309574350714684, -0.013464512303471565, 0.027155829593539238, -0.03728581592440605, -0.018446531146764755, 0.06656384468078613, 0.03812548890709877, 0.015775609761476517, -0.00035554799251258373, 0.003952639177441597, -0.018829135224223137, -0.01681695319712162, -0.018146401271224022, 0.002012586919590831, -0.00973756518214941, 0.0028035358991473913, 0.045873817056417465, 0.04031694680452347, 0.006405291613191366, 0.004232201259583235, -0.011029340326786041, -0.013330388814210892, 0.02091430313885212, -0.010558297857642174, 0.007579045835882425, -0.026629172265529633, -0.008456330746412277, 0.0012483971659094095, -0.007893725298345089, -0.006058913189917803, 0.009607389569282532, 0.038792356848716736, -0.0620228610932827, -0.021572304889559746, 0.0487629733979702, -0.0057777538895606995, -0.015529334545135498, -0.053550951182842255, 0.028154535219073296, -0.026331208646297455, 0.005496721249073744, -0.0009034001850523055, 0.004415222909301519, -0.007903018034994602, 0.008219631388783455, -0.01946214586496353, -0.008521080948412418, 0.014786423183977604, 0.027048932388424873, 0.05429922789335251, -0.011693017557263374, -0.00027849944308400154, -0.038276977837085724, 0.009822509251534939, 0.01917518861591816, -0.01986978016793728, -0.01200511958450079, 0.03350423276424408, 0.01166111882776022, 0.008071514777839184, 0.04649088904261589, 0.013907388783991337, -0.009292032569646835, 0.06878431886434555, -0.013815874233841896, -0.025692632421851158, -0.03553175553679466, 0.026099730283021927, 0.011739851906895638, -0.013680764473974705, -0.008159590885043144, -0.03136550262570381, -0.02926861308515072, -0.0031521704513579607, -0.03190199285745621, 0.0129171684384346, 0.09467051923274994, 0.004017679486423731, 0.01122730877250433, 0.02479071542620659, 0.020101778209209442, 0.012647726573050022, -0.005637870170176029, -0.0130296116694808, 0.04191945120692253, 0.032178837805986404, 0.03244484215974808, 0.02584480680525303, 0.014544655568897724, 0.027368765324354172, 0.00029772394918836653, -0.05770370364189148, 0.04152378812432289, 0.027320897206664085, -0.02647347003221512, 0.0003400961577426642, -0.018352817744016647, -0.013158878311514854, 0.0019839005544781685, 0.014181295409798622, 0.036374639719724655, 0.04100363329052925, -0.005438936874270439, -0.009546068497002125, -0.0018948339857161045, -0.021551575511693954, 0.02807985246181488, 0.07022152841091156, -0.04028687626123428, 0.062244169414043427, 0.03036600723862648, 0.017949488013982773, 0.023637931793928146, 0.003268338041380048, -0.005493233446031809, 0.019846849143505096, 0.05953102558851242, 0.031144434586167336, 0.017164668068289757, 0.049643632024526596, -0.015894662588834763, -0.0647464394569397, -0.055447764694690704, -0.014814475551247597, -0.03294157236814499, -0.012745514512062073, 0.030581122264266014, -0.041272010654211044, 0.0008829821599647403, -0.0038896703626960516, 0.028004348278045654, 0.04913653805851936, 0.04051120951771736, -0.007238804362714291, 0.04909161478281021, 0.042934417724609375, -0.004241469781845808, -0.004642738029360771, 0.017228465527296066, 0.008989137597382069, -0.007432851940393448, 0.05021880194544792, 0.017056996002793312, 0.05037844926118851, 0.01288808137178421, -0.03792722150683403, 0.02859661541879177, 0.016701972112059593, -0.03091065026819706, -0.0029749965760856867, -0.005114685278385878, -0.03396319970488548, -0.023886583745479584, 0.020911263301968575, -0.0671297013759613, 0.010328750126063824, 0.0037077846936881542, -0.007816164754331112, 0.009779763408005238, -0.02545805089175701, 0.013775710947811604, 0.018871398642659187, 0.016676293686032295, -0.01287982240319252, 0.002697755815461278, 0.025238366797566414, 0.009069569408893585, -0.0021896082907915115, -0.024636192247271538, -0.05242501571774483, -0.0400717668235302, -0.033557869493961334, -0.046235620975494385, -0.0056398408487439156, -0.009083534590899944, -0.03739197924733162, 0.008761249482631683, 0.0402059368789196, -0.024605799466371536, 0.03766525536775589, 0.009264416992664337, -0.005807545501738787, -0.03625587746500969, 0.01713615097105503, -0.01658421941101551, -0.019536025822162628, 0.009861879050731659, -0.06317725777626038, 0.003306268248707056, -0.0021077569108456373, 0.008351628668606281, 0.029135266318917274, 0.04155978187918663, -0.03100907802581787, -0.05829540267586708, 0.028335848823189735, 0.00498689990490675, -0.05576792731881142, 0.042117100208997726, 0.03838250786066055, 0.0122087886556983, 0.025012383237481117, -0.01023243647068739, 0.011260565370321274, -0.006730697117745876, 0.033120885491371155, 0.014705643989145756, 0.009711939841508865, -0.03715561702847481, -0.008934020064771175, 0.007023094221949577, -0.013695361092686653, 0.0023427351843565702, 0.037829771637916565, -0.008023018948733807, 0.009892275556921959, -0.05076630041003227, 0.024335717782378197, -0.034017302095890045, -0.003161785891279578, -0.06397342681884766, -0.05656513571739197, -0.016064725816249847, -0.013360289856791496, 0.004662228282541037, 0.0179176926612854, -0.0474785640835762, 0.0004900928470306098, -0.02031857520341873, -0.018581224605441093, -0.017831951379776, 0.0040556397289037704, 0.04980606213212013, 0.009786294773221016, 0.009320497512817383, 0.008994567207992077, 0.0011488297022879124, 0.016672413796186447, -0.03281507268548012, 0.005310662090778351, 0.038110677152872086, 0.022593628615140915, -0.03007463924586773, -0.005477267317473888, -0.012506390921771526, 0.008425596170127392, -0.048211146146059036, 0.018371285870671272, 0.027388419955968857, -0.0028069117106497288, -0.022412221878767014, -0.002150279004126787, 0.01740718074142933, -0.024184685200452805, 0.025035427883267403, -0.006446378771215677, -0.04423733428120613, -0.0021917654667049646, 0.0027166891377419233, -0.03774108737707138, -0.021769754588603973, 0.009901901707053185, -0.03754398971796036, 0.03365712985396385, 0.0353933647274971, 0.00682317977771163, -0.013239026069641113, -0.03537445887923241, -0.012955916114151478, 0.02090250328183174, -0.033460114151239395, -0.030028780922293663, -0.009816179983317852, 0.03931054100394249, -0.04748447611927986, -0.030676694586873055, 0.047906629741191864, 0.008365440182387829, -0.012999358586966991, -0.003274163929745555, 0.04723813012242317, 0.012752952985465527, -0.029498007148504257, -0.0031649547163397074, -0.013648517429828644, 0.05198818817734718, 0.0049164993688464165, -0.006405058316886425, 0.0025565268006175756, 0.016435571014881134 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
6. The open source power of BERT Unlike other large learning models like GPT-3, BERT’s source code is publicly accessible ([view BERT’s code on Github](https://github.com/google-research/bert)) allowing BERT to be more widely used all around the world. This is a game-changer! Developers are now able to get a state-of-the-art model like BERT up and running quickly without spending large amounts of time and money. 🤯 Developers can instead focus their efforts on fine-tuning BERT to customize the model’s performance to their unique tasks. It’s important to note that [thousands](https://huggingface.co/models?sort=downloads&search=bert) of open-source and free, pre-trained BERT models are currently available for specific use cases if you don’t want to fine-tune BERT. BERT models pre-trained for specific tasks: - [Twitter sentiment analysis](https://huggingface.co/finiteautomata/bertweet-base-sentiment-analysis) - [Analysis of Japanese text](https://huggingface.co/cl-tohoku/bert-base-japanese-char) - [Emotion categorizer (English - anger, fear, joy, etc.)](https://huggingface.co/j-hartmann/emotion-english-distilroberta-base) - [Clinical Notes analysis](https://huggingface.co/emilyalsentzer/Bio_ClinicalBERT) - [Speech to text translation](https://huggingface.co/facebook/hubert-large-ls960-ft) - [Toxic comment detection](https://huggingface.co/unitary/toxic-bert?) You can also find [hundreds of pre-trained, open-source Transformer models](https://huggingface.co/models?library=transformers&sort=downloads) available on the Hugging Face Hub.
[ 0.022987626492977142, -0.018288906663656235, 0.028179628774523735, -0.006453483831137419, -0.0012694132747128606, 0.0643651932477951, 0.03665725141763687, 0.0951247438788414, -0.00109350704587996, -0.052924200892448425, -0.09659653156995773, 0.06366578489542007, -0.016344545409083366, 0.05274958908557892, 0.009263594634830952, -0.03443560749292374, 0.030397778376936913, -0.012846922501921654, 0.004534212406724691, -0.034923698753118515, -0.004942981526255608, -0.030795322731137276, 0.060244396328926086, -0.014437837526202202, 0.03604483976960182, -0.01973056048154831, 0.045374199748039246, 0.020434211939573288, -0.07641611248254776, 0.0035875989124178886, -0.10675417631864548, 0.038261301815509796, 0.011493219062685966, -0.01920960284769535, -0.03420925885438919, 0.031231127679347992, -0.10545287281274796, 0.08392982184886932, 0.015050438232719898, -0.0000425793623435311, -0.016777146607637405, -0.020887086167931557, -0.030486833304166794, 0.0966949462890625, -0.03283174708485603, 0.004259816370904446, -0.20132626593112946, 0.09253832697868347, -0.014594326727092266, 0.011569775640964508, -0.07989457249641418, 0.07119204849004745, -0.023595483973622322, 0.006512909196317196, -0.017683815211057663, -0.00917501375079155, 0.04133318364620209, 0.0013306980254128575, 0.0063108960166573524, -0.0684993639588356, 0.03916125372052193, -0.034825775772333145, 0.0358029343187809, 0.008976375684142113, 0.0917336717247963, 0.01699415221810341, -0.04261181131005287, -0.02792225033044815, -0.06025795266032219, 0.002494038315489888, 0.01765814796090126, -0.04260873794555664, -0.08636720478534698, -0.0467398539185524, -0.018892280757427216, -0.013379101641476154, 0.017183616757392883, 0.020661821588873863, 0.039997491985559464, 0.010999131016433239, 0.0640902891755104, 0.04355045035481453, -0.0029878115747123957, 0.015144957229495049, 0.037955645471811295, 0.04344591125845909, 0.08493870496749878, -0.028510529547929764, -0.060233257710933685, 0.0237368606030941, -0.015262875705957413, -0.1457591950893402, -0.02244703099131584, -0.04404143616557121, 0.050927869975566864, -0.02408692054450512, -0.012846279889345169, 0.0026306884828954935, -0.021642055362462997, 0.001511765643954277, 0.012199053540825844, -0.052877239882946014, 0.022291991859674454, -0.03746011108160019, -0.07274562865495682, 0.03532717004418373, 0.05495137721300125, -0.10858283191919327, 0.01731160283088684, 0.011536085978150368, 0.02611706592142582, -0.06565319001674652, -0.00365344132296741, 0.03336873650550842, -0.09264614433050156, 0.05270005762577057, 0.015053550712764263, -0.032334137707948685, 0.02442336268723011, 0.01033093873411417, -0.03234127163887024, 0.04131903871893883, -0.004439022392034531, 0.005943468306213617, 0.020127685740590096, 0.05604491010308266, -0.0038415470626205206, 0.01309402845799923, 0.021933773532509804, -0.016728533431887627, 0.0654829740524292, 0.01832152158021927, 0.07434714585542679, -0.049609772861003876, 0.01611034944653511, -0.0220391396433115, 0.012455453164875507, -0.050117213279008865, -0.011710117571055889, -0.031897466629743576, -0.03514791652560234, 0.03299764543771744, -0.05026867613196373, 0.03837064281105995, 0.04420740529894829, 0.0075167217291891575, -0.12887892127037048, 0.073358915746212, -0.0015159244649112225, 0.01609540916979313, -0.08443868905305862, 0.029409989714622498, -0.001340561080724001, -0.04043615609407425, 0.02005399763584137, 0.0799839049577713, 0.017005890607833862, -0.08192579448223114, -0.00862087868154049, -0.011297723278403282, -0.023510171100497246, 0.027297692373394966, -0.03232719376683235, -0.030841894447803497, 0.005563969723880291, -0.0657932385802269, 0.004119497258216143, 0.030160091817378998, -0.0046118018217384815, 0.04832910746335983, -0.00972765777260065, -0.02091621793806553, 0.10970423370599747, -0.04646647721529007, 0.003925046417862177, 0.029659032821655273, 0.07031647861003876, 0.0336458757519722, -0.0013165391283109784, 0.007135653868317604, -0.053718917071819305, 0.06761739403009415, 0.038537029176950455, 0.007025821600109339, 0.04334496334195137, -0.0864359512925148, 0.026245981454849243, -0.05725950002670288, 0.00273921899497509, -0.022643866017460823, -0.021940389648079872, -0.009858781471848488, 0.08241406083106995, 0.007412394974380732, 0.024281492456793785, -0.007710904348641634, -0.020932583138346672, 0.11475205421447754, 0.048336129635572433, 0.05363255366683006, 0.08276378363370895, -0.06418885290622711, 0.0074042463675141335, -0.012844042852520943, -0.054902151226997375, -0.020807217806577682, 0.06965648382902145, -0.00769719248637557, 0.020104873925447464, -0.02373601868748665, 0.03539515286684036, -0.12983621656894684, 0.02133806049823761, -0.07602468132972717, 0.004976397380232811, -0.07760369032621384, -0.03978770598769188, 0.04461756348609924, 0.04963908717036247, 0.00652672816067934, 0.15443722903728485, -0.06803257018327713, -0.019048456102609634, 0.0162595734000206, -0.026900745928287506, 0.0539417639374733, 0.06980342417955399, 0.051170818507671356, 0.09299536049365997, -0.021178850904107094, -0.0625099390745163, -0.03600555658340454, 0.010283729992806911, -0.012601621448993683, 0.0003072901163250208, -0.015577866695821285, -0.008964045904576778, -0.019536718726158142, 0.003812253475189209, -0.011758336797356606, -0.013732211664319038, 0.012433409690856934, 0.0254678875207901, 0.06518785655498505, -0.01971544697880745, -0.042070288211107254, 0.027997465804219246, 0.05415430665016174, -0.039240241050720215, 0.0073022013530135155, -0.06475033611059189, 0.02096940018236637, -0.009278472512960434, -0.027334637939929962, 0.02293488383293152, 0.027108434587717056, -0.00783862266689539, -0.003578863339498639, -0.020938631147146225, 0.042602118104696274, 0.044738974422216415, -0.044905807822942734, -0.03718627616763115, -0.036435697227716446, -0.03310186788439751, -0.021937163546681404, -0.047388024628162384, 0.020344479009509087, 0.006994161754846573, 0.028907835483551025, 0.03983771428465843, -0.03718220442533493, 0.011224551126360893, 0.0071857888251543045, 0.017480578273534775, 0.0390140563249588, 0.03213661164045334, 0.01582876779139042, -0.0227352362126112, 0.0004725212638732046, -0.018221452832221985, -0.010980823077261448, 0.02916124276816845, 0.006736657116562128, 0.02618543617427349, 0.012707825750112534, -0.018091795966029167, -0.02037408947944641, 0.014631078578531742, 0.016164500266313553, 0.006847899407148361, 0.020568223670125008, -0.01224183663725853, -0.014230933971703053, 0.005710056517273188, 0.002231331542134285, 0.03784565255045891, 0.0051713199354708195, -0.026018228381872177, 0.0023172611836344004, -0.0035726565402001143, -0.02812786214053631, -0.005579108372330666, -0.029807567596435547, -0.02617170661687851, 0.031236182898283005, 0.023427478969097137, 0.012431968934834003, -0.11141452938318253, 0.01781431771814823, -0.016906598582863808, 0.002534292871132493, 0.007174148224294186, -0.011564436368644238, 0.03935035318136215, -0.011251255869865417, -0.026932433247566223, 0.022274408489465714, -0.019725387915968895, 0.013222216628491879, 0.02184304967522621, 0.02281237579882145, -0.050861041992902756, 0.013990184292197227, -0.022466229274868965, 0.022091103717684746, 0.04114887863397598, 0.038844309747219086, -0.022017773240804672, 0.03560866415500641, -0.0224237609654665, -0.005485887639224529, -0.028337258845567703, -0.022152625024318695, 0.01667371578514576, 0.01646164432168007, 0.049193769693374634, -0.009335802868008614, 0.003775157732889056, -0.015132473781704903, 0.00786385778337717, 0.022018281742930412, 0.009414260275661945, 0.005151366349309683, 0.009266630746424198, 0.04156685620546341, 0.027443265542387962, 0.03821563720703125, 0.01370171643793583, -0.01905258744955063, -0.014903496950864792, -0.004336438607424498, 0.0009422266739420593, -0.007632964290678501, 0.003420397872105241, 0.011142945848405361, 0.014507662504911423, -0.011050034314393997, -0.01104571484029293, -0.03866960480809212, 0.0006112682749517262, 0.03268768638372421, -0.007956894114613533, -0.016383642330765724, 0.002771726343780756, -0.00817664060741663, -0.006257069297134876, 0.0038643733132630587, -0.059623442590236664, 0.048513736575841904, -0.012370738200843334, -0.014204486273229122, -0.017425071448087692, 0.040416866540908813, 0.04195190221071243, -0.015516835264861584, -0.03382766991853714, 0.03303353860974312, 0.00024946994381025434, 0.031898919492959976, -0.006505423225462437, 0.006338195875287056, -0.03687240928411484, 0.04099211469292641, -0.0265025831758976, -0.037650320678949356, 0.04610529541969299, 0.025389691814780235, -0.04097425192594528, -0.036078762263059616, -0.03286133334040642, -0.013318381272256374, 0.020462406799197197, -0.01531920488923788, 0.02128666825592518, 0.006959162186831236, 0.03200547397136688, 0.06395499408245087, -0.01633216254413128, -0.017376236617565155, 0.004947383422404528, 0.022844232618808746, 0.022022223100066185, 0.000003763702352443943, 0.009789952076971531, 0.014561139978468418, -0.003689575009047985, -0.006079021375626326, 0.03888823837041855, -0.026668846607208252, -0.03069501742720604, 0.010045008733868599, 0.02086380124092102, 0.048686105757951736, -0.06981440633535385, -0.03680303320288658, 0.04569700360298157, -0.030554892495274544, -0.000535577826667577, -0.001957843080163002, 0.0009880478028208017, 0.005195979028940201, 0.04141388088464737, 0.026652997359633446, -0.007845819927752018, -0.01626184768974781, -0.045301105827093124, 0.0032263626344501972, -0.011124096810817719, 0.013568690977990627, 0.0114779407158494, 0.01861575059592724, 0.03596881031990051, 0.004064230248332024, 0.03425617516040802, 0.04677548259496689, -0.016603292897343636, 0.0018644019728526473, -0.0072297086007893085, -0.04584571719169617, 0.02336074598133564, 0.020995724946260452, -0.0050749396905303, 0.023402385413646698, 0.019387302920222282, -0.0046806856989860535, -0.019791750237345695, -0.04426710307598114, -0.00047693614033050835, 0.011034427210688591, 0.00341617688536644, -0.05694287642836571, 0.03747410327196121, -0.015687381848692894, -0.04628084972500801, -0.024559838697314262, 0.007177428808063269, -0.002134906128048897, 0.06335979700088501, -0.002136599738150835, -0.04274057596921921, 0.02773171477019787, 0.03442484140396118, -0.029485374689102173, -0.022397881373763084, 0.05596942454576492, 0.0035330019891262054, 0.04973875731229782, -0.005633501801639795, 0.0006541215116158128, -0.05885506048798561, 0.007518799044191837, 0.011346311308443546, -0.006818543188273907, 0.04962493106722832, -0.02109416387975216, -0.008585949428379536, -0.003543374128639698, 0.003984779119491577, 0.03223010525107384, 0.009448724798858166, -0.024646669626235962, -0.016716862097382545, 0.0422515943646431, 0.009430540725588799, 0.02328294701874256, 0.008380885235965252, 0.00978828500956297, -0.0036856119986623526, 0.005184222012758255, -0.03880554065108299, 0.02499663643538952, -0.0036470331251621246, 0.03023061715066433, 0.043389540165662766, 0.06527795642614365, 0.0136047238484025, 0.007428634911775589, -0.013207587413489819, 0.02880510687828064, 0.031878985464572906, -0.00874932762235403, -0.00168911786749959, -0.0368177555501461, 0.010564513504505157, 0.0012455163523554802, -0.005845861043781042, -0.00020565906015690416, 0.008134475909173489, 0.06183536350727081, -0.05350150167942047, -0.02125447243452072, 0.04408133029937744, -0.0395088717341423, -0.0011809960706159472, -0.0810009092092514, 0.01037557888776064, -0.01680436171591282, -0.01254614070057869, 0.014361177571117878, -0.010364368557929993, 0.004804398864507675, 0.014951884746551514, -0.03776877745985985, -0.02474033646285534, 0.007195678539574146, 0.0017077079974114895, 0.011903045699000359, 0.020024731755256653, -0.027059568092226982, -0.0834391713142395, 0.013959324918687344, 0.011637171730399132, -0.044226378202438354, 0.006904417648911476, 0.027747519314289093, 0.028263727203011513, 0.0007485583191737533, 0.052020106464624405, 0.015458635985851288, 0.018257513642311096, 0.0786883533000946, -0.005894899368286133, -0.02392820082604885, -0.020073063671588898, 0.021689802408218384, 0.01649777963757515, -0.017723843455314636, 0.0011170112993568182, -0.010847206227481365, -0.018832998350262642, -0.006456092465668917, -0.04721386730670929, 0.010221813805401325, 0.07040686160326004, -0.013288505375385284, 0.0021499439608305693, 0.004090931732207537, 0.006474525202065706, 0.036538589745759964, -0.004949372261762619, -0.011244320310652256, 0.035710033029317856, 0.01984250545501709, 0.011698166839778423, 0.012337855994701385, 0.02960745058953762, -0.007843061350286007, 0.008806217461824417, -0.06822599470615387, 0.0019183735130354762, 0.032496336847543716, -0.0041241832077503204, -0.003236578544601798, -0.00042044869042001665, -0.030537717044353485, 0.019229138270020485, 0.03321678936481476, 0.005838416516780853, 0.05582352727651596, 0.006119119934737682, -0.029091419652104378, -0.014026493765413761, -0.022038569673895836, 0.023402409628033638, 0.06704378873109818, -0.016074057668447495, 0.0549062043428421, 0.0264522023499012, 0.03071260266005993, 0.06061621010303497, -0.03808097168803215, -0.014844649471342564, 0.01159672997891903, 0.03500691056251526, 0.0240140650421381, 0.0312764048576355, 0.03152923285961151, -0.04793113097548485, -0.059890225529670715, -0.03843269869685173, 0.005996822379529476, -0.06282766163349152, -0.018577612936496735, 0.005997267551720142, -0.054674550890922546, 0.01232373621314764, -0.01954294554889202, 0.028707554563879967, 0.047666411846876144, 0.06639625877141953, 0.024751883000135422, 0.024302959442138672, 0.015165581367909908, 0.02255130745470524, -0.007923341356217861, 0.013792706653475761, 0.010947185568511486, -0.006604328285902739, 0.01902969740331173, 0.02671786956489086, 0.03633791208267212, -0.003010499058291316, -0.04093821346759796, 0.029607893899083138, 0.004798587877303362, 0.0018010998610407114, 0.013256329111754894, -0.002310642274096608, -0.015241676941514015, -0.014928753487765789, 0.03449026495218277, -0.019763845950365067, 0.007925190962851048, 0.043730903416872025, -0.016785630956292152, 0.020571261644363403, -0.003093806793913245, 0.016222259029746056, 0.05375542864203453, 0.016709545627236366, -0.020481089130043983, -0.01324129942804575, 0.0008924142457544804, 0.016307130455970764, 0.030695177614688873, -0.013470698148012161, -0.03151349350810051, -0.026406854391098022, -0.04237775132060051, -0.040661975741386414, 0.0032065780833363533, 0.005684856791049242, -0.011566496454179287, 0.030341824516654015, 0.022048112004995346, -0.014276403933763504, 0.04743596538901329, 0.017021335661411285, -0.01606786623597145, -0.05491206794977188, 0.01048162579536438, -0.010863362811505795, -0.03065401129424572, -0.014862820506095886, -0.0636085718870163, 0.023032469674944878, -0.02047445997595787, 0.03101608157157898, 0.022095000371336937, 0.06000668555498123, -0.06280036270618439, -0.03195873275399208, 0.0321100577712059, 0.003192684380337596, -0.046978846192359924, 0.011916841380298138, 0.05356454476714134, 0.00891627836972475, -0.00890938751399517, -0.015033300034701824, -0.010371600277721882, -0.011038461700081825, 0.00023563003924209625, 0.04084382578730583, -0.017444608733057976, -0.04002895951271057, 0.007915320806205273, 0.03450506925582886, 0.025335321202874184, 0.011075079441070557, 0.050290483981370926, -0.02571248449385166, 0.017856376245617867, -0.048286113888025284, 0.016803761944174767, -0.020555369555950165, 0.010270888917148113, -0.0516868494451046, -0.06631013751029968, -0.004205282777547836, 0.015769505873322487, 0.010273580439388752, -0.0029637303669005632, -0.04379408061504364, -0.017610562965273857, -0.04343944042921066, -0.013487068936228752, -0.00945284403860569, 0.023533539846539497, 0.046359673142433167, -0.001967780292034149, -0.001659149071201682, 0.0153358718380332, -0.004656537901610136, 0.003206898458302021, -0.0373900942504406, -0.005854835733771324, 0.030669720843434334, 0.024523617699742317, -0.024524029344320297, -0.007234773598611355, -0.007329687476158142, -0.013421215116977692, -0.021350795403122902, 0.023276032879948616, 0.018625162541866302, -0.00819059181958437, -0.011355738155543804, 0.014286304824054241, 0.0001707607152638957, -0.043148305267095566, 0.03866636008024216, -0.00904565118253231, -0.01727752946317196, -0.01817719079554081, 0.007457276806235313, -0.04261142015457153, -0.007219096180051565, -0.003378241788595915, -0.017036419361829758, 0.056827232241630554, 0.0344407893717289, -0.0007214556098915637, -0.006550236139446497, -0.02666430175304413, -0.012495174072682858, 0.030906420201063156, -0.04139895364642143, -0.03779986873269081, -0.0055477372370660305, 0.03061414510011673, -0.04078835994005203, -0.036872975528240204, 0.03083295375108719, -0.02361881732940674, -0.021621262654662132, 0.017489604651927948, 0.031165575608611107, 0.015596180222928524, -0.027130765840411186, 0.0012698594946414232, -0.009229090064764023, 0.03514661639928818, 0.018176371231675148, 0.006590589880943298, 0.015149545855820179, 0.003579400945454836 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
1. What is BERT used for? BERT can be used on a wide variety of language tasks: - Can determine how positive or negative a movie’s reviews are. [(Sentiment Analysis)](https://huggingface.co/blog/sentiment-analysis-python) - Helps chatbots answer your questions. [(Question answering)](https://huggingface.co/tasks/question-answering) - Predicts your text when writing an email (Gmail). [(Text prediction)](https://huggingface.co/tasks/fill-mask) - Can write an article about any topic with just a few sentence inputs. [(Text generation)](https://huggingface.co/tasks/text-generation) - Can quickly summarize long legal contracts. [(Summarization)](https://huggingface.co/tasks/summarization) - Can differentiate words that have multiple meanings (like ‘bank’) based on the surrounding text. (Polysemy resolution) **There are many more language/NLP tasks + more detail behind each of these.** ***Fun Fact:*** You interact with NLP (and likely BERT) almost every single day! NLP is behind Google Translate, voice assistants (Alexa, Siri, etc.), chatbots, Google searches, voice-operated GPS, and more. ---
[ 0.01736864075064659, -0.0004618204548023641, 0.05665379390120506, -0.03795194998383522, 0.08061116188764572, 0.08081559091806412, 0.05271308124065399, 0.0895920842885971, -0.02881654165685177, -0.042213089764118195, -0.08763198554515839, 0.08848565816879272, 0.015501386485993862, 0.04707205668091774, -0.03497175872325897, -0.012973853386938572, 0.07415179163217545, 0.00873398594558239, 0.00591572280973196, -0.0008463811245746911, -0.02840052731335163, -0.02761751040816307, 0.06966635584831238, -0.005519786849617958, 0.03843679279088974, -0.06673730164766312, -0.016763780266046524, 0.02214745245873928, -0.09984857589006424, 0.023548729717731476, -0.10386142134666443, 0.000456510839285329, -0.018999475985765457, -0.008150140754878521, -0.024875691160559654, -0.01828685961663723, -0.09189413487911224, 0.06355892866849899, -0.039937201887369156, -0.010781815275549889, -0.048140402883291245, -0.049577176570892334, -0.051878102123737335, 0.02932726964354515, -0.04645440727472305, -0.02080293744802475, -0.21048924326896667, 0.11160466820001602, -0.03640376403927803, -0.02224370278418064, -0.08806319534778595, 0.08938266336917877, -0.02638721652328968, -0.003242690581828356, -0.009409405291080475, 0.04074405878782272, -0.0016026502707973123, -0.10113099962472916, -0.0026838218327611685, -0.02243848331272602, 0.030299711972475052, -0.04264099895954132, 0.0336577482521534, 0.005755143240094185, 0.019465221092104912, 0.03711942583322525, -0.025322653353214264, -0.021262386813759804, -0.08631804585456848, -0.010841673240065575, -0.01314869150519371, -0.05725669488310814, -0.07291900366544724, 0.026976564899086952, -0.020704181864857674, -0.011599927209317684, 0.0032382227946072817, 0.017596663907170296, -0.023644668981432915, 0.024077368900179863, 0.01614336483180523, -0.008618025109171867, 0.037816718220710754, 0.02582547441124916, 0.040119070559740067, 0.024470176547765732, 0.052597083151340485, -0.007400211412459612, -0.06667079776525497, 0.043865952640771866, 0.0034862887114286423, -0.1810019463300705, -0.006820998154580593, -0.028261175379157066, 0.03690091893076897, -0.07020874321460724, -0.040193721652030945, 0.002852058969438076, -0.03838915377855301, 0.011465945281088352, 0.020022306591272354, -0.07043716311454773, 0.05375131964683533, 0.015369569882750511, -0.04222414270043373, 0.03828815370798111, 0.019429229199886322, -0.09883756935596466, -0.0025990051217377186, 0.018794909119606018, 0.024735398590564728, -0.03141644224524498, 0.00483789062127471, 0.052300434559583664, -0.03367996588349342, 0.0790969580411911, 0.027475962415337563, 0.013723989017307758, 0.00292092259041965, 0.051257453858852386, 0.02378137595951557, 0.03202224150300026, 0.005291921552270651, 0.04199930652976036, -0.014730306342244148, 0.028640523552894592, 0.012777161784470081, -0.026979761198163033, -0.014201004058122635, -0.024576693773269653, 0.05656643956899643, -0.009409496560692787, 0.06327971071004868, -0.004333768505603075, -0.016411317512392998, -0.0002921830746345222, -0.0315970741212368, -0.08127889782190323, 0.016965534538030624, -0.015274529345333576, -0.006217718590050936, 0.08231661468744278, -0.01877906732261181, 0.028177328407764435, 0.05190663039684296, -0.02388976514339447, -0.09311943501234055, 0.06359745562076569, -0.020102348178625107, 0.02051391266286373, -0.08390602469444275, 0.009095832705497742, -0.022822760045528412, -0.041881363838911057, 0.011564061976969242, 0.07988466322422028, 0.010916372761130333, -0.044766683131456375, -0.021840227767825127, -0.030234739184379578, 0.014654932543635368, 0.024586142972111702, -0.05638779699802399, 0.005987883545458317, -0.008345977403223515, -0.04048421233892441, 0.010845594108104706, 0.0017640396254137158, -0.01127803884446621, 0.04985370859503746, -0.014095945283770561, -0.011051773093640804, 0.081304170191288, -0.04555581137537956, -0.009190350770950317, 0.05695654824376106, 0.06574363261461258, 0.009183394722640514, -0.0007706635515205562, 0.009838436730206013, -0.0381431058049202, 0.07643591612577438, 0.03859715163707733, 0.038480356335639954, 0.0450417660176754, -0.03869495540857315, 0.03140841796994209, -0.059778910130262375, -0.0046036443673074245, 0.025304574519395828, -0.017633801326155663, -0.0455092154443264, 0.062153998762369156, 0.008754192851483822, 0.03173370286822319, -0.05951078236103058, -0.020576288923621178, 0.16111300885677338, 0.038653794676065445, 0.0262778177857399, 0.04621215909719467, -0.03143616020679474, 0.026915282011032104, -0.01861809566617012, -0.05684049800038338, 0.03213072940707207, 0.07910648733377457, -0.0036450191400945187, -0.03648855537176132, 0.022595100104808807, 0.026927974075078964, -0.13315925002098083, 0.01795230433344841, -0.07342316955327988, -0.01162038091570139, -0.07057563215494156, -0.02458357997238636, 0.011844178661704063, 0.05006030946969986, 0.0013893155846744776, 0.1119316816329956, -0.06570160388946533, -0.03212205693125725, -0.0063620214350521564, -0.01706826686859131, 0.03330816328525543, 0.05174654349684715, 0.07448399811983109, 0.07832091301679611, -0.030883843079209328, -0.06399401277303696, -0.036959581077098846, 0.006753986235707998, -0.004807942546904087, -0.044517289847135544, 0.014742960222065449, 0.00813327543437481, -0.010930170305073261, 0.016925618052482605, 0.045052506029605865, -0.040200769901275635, 0.03374752774834633, 0.03985408693552017, 0.06888072192668915, -0.04403781145811081, -0.009957320056855679, 0.052492111921310425, 0.012253896333277225, -0.04438413307070732, 0.010505705140531063, -0.07911603897809982, 0.0036521553993225098, -0.006422619801014662, -0.01923629455268383, 0.054843951016664505, 0.038240622729063034, 0.022274857386946678, 0.010783521458506584, -0.003374711610376835, 0.03835359960794449, -0.0003355680382810533, -0.06611157953739166, 0.01713654026389122, -0.06410713493824005, -0.013826441019773483, -0.024792980402708054, -0.006967456080019474, -0.0023267818614840508, -0.02007974311709404, 0.08244260400533676, 0.031002715229988098, -0.006622374523431063, 0.06487435847520828, 0.025188792496919632, 0.025114232674241066, 0.02191881090402603, 0.03216557577252388, 0.027060724794864655, -0.01386195607483387, -0.017704717814922333, -0.0262377317994833, -0.02460268884897232, 0.030953044071793556, 0.024114634841680527, 0.025885768234729767, -0.030543940141797066, -0.013965634629130363, -0.02715296670794487, -0.014969926327466965, 0.0011452981270849705, 0.0318634957075119, 0.019098250195384026, -0.024658693000674248, 0.003587971441447735, 0.016872191801667213, 0.004965735599398613, 0.03352673724293709, 0.0013436806621029973, -0.030232910066843033, 0.03283845633268356, 0.028294553980231285, -0.0025301948189735413, -0.04027631878852844, -0.03660421073436737, -0.02997617796063423, 0.03808218240737915, 0.01047261618077755, 0.011190730147063732, -0.1223323866724968, -0.042150888592004776, 0.021435119211673737, 0.007846304215490818, -0.0012998874299228191, -0.020400552079081535, 0.07631094008684158, 0.006661710795015097, -0.021656256169080734, 0.008529451675713062, -0.0012276839697733521, 0.0007108224672265351, 0.04662800952792168, -0.013894285075366497, -0.022029535844922066, -0.0040962365455925465, -0.02046460658311844, -0.025593744590878487, 0.030419304966926575, 0.010247648693621159, -0.034856878221035004, 0.03798955678939819, 0.021501924842596054, -0.017039161175489426, -0.03592531755566597, -0.016499735414981842, -0.00023594066442456096, 0.019269216805696487, 0.03755572810769081, -0.023571403697133064, 0.03165426105260849, -0.0022724412847310305, 0.009081345982849598, 0.013030019588768482, -0.024714037775993347, 0.012820538133382797, 0.00951794721186161, 0.07124093919992447, 0.021677572280168533, 0.04810609668493271, 0.02901618368923664, -0.00434860261157155, 0.005937563255429268, 0.00956199411302805, -0.005644621793180704, -0.021710067987442017, 0.006497201509773731, -0.02831728383898735, 0.014573302119970322, 0.008695079013705254, -0.02620539255440235, -0.04059213772416115, -0.028384163975715637, 0.039191652089357376, 0.01871623657643795, -0.03670860454440117, -0.002536180429160595, -0.008536241948604584, 0.0145017821341753, 0.02144947461783886, -0.029777109622955322, 0.019833166152238846, -0.012884365394711494, -0.03375569358468056, -0.015620476566255093, 0.04883357882499695, 0.014363070018589497, -0.0024531777016818523, 0.00811739545315504, 0.044343654066324234, 0.015579866245388985, 0.03278712183237076, 0.013469606637954712, 0.011592715047299862, -0.02024669386446476, 0.026473000645637512, -0.024172035977244377, 0.004294530488550663, 0.059199243783950806, 0.021703116595745087, -0.022428223863244057, -0.032117173075675964, -0.024153858423233032, -0.04269218444824219, 0.03654569759964943, -0.015970813110470772, 0.04183107614517212, -0.009920457378029823, 0.005938322748988867, 0.05212017148733139, 0.02780427597463131, -0.03539377823472023, 0.03772466257214546, 0.002589201321825385, -0.014662489295005798, 0.001093253493309021, 0.0037235042545944452, -0.030979881063103676, 0.006300222594290972, -0.020267052575945854, 0.03398476913571358, -0.025528712198138237, -0.023299958556890488, -0.00025152615853585303, 0.030778419226408005, 0.051043927669525146, -0.012408086098730564, -0.03547094017267227, -0.005069229751825333, -0.01121505256742239, -0.0027850097976624966, 0.014734466560184956, -0.007956410758197308, 0.0023720453027635813, 0.047763392329216, 0.020502246916294098, 0.013403128832578659, -0.03563053160905838, -0.03723300248384476, 0.002718679141253233, -0.022854672744870186, 0.011367004364728928, -0.014446977525949478, 0.007282307371497154, 0.020762108266353607, 0.0023236339911818504, 0.03694061189889908, 0.019779197871685028, -0.01380365900695324, 0.016560329124331474, -0.03237752988934517, -0.005714749917387962, 0.01546931080520153, 0.014756442047655582, 0.018563013523817062, 0.006375981494784355, 0.003771716495975852, 0.014097423292696476, -0.024114659056067467, -0.05496054142713547, -0.004010255914181471, -0.0131846247240901, 0.04993400722742081, -0.03758997097611427, 0.019054848700761795, 0.002702759811654687, -0.0487380176782608, -0.007995061576366425, -0.00959336943924427, 0.02850392460823059, 0.02008371241390705, -0.02724691666662693, -0.06319763511419296, -0.0070298416540026665, 0.021929290145635605, -0.05604350194334984, -0.011181041598320007, 0.057630520313978195, 0.02061159722507, 0.07613041996955872, 0.025940414518117905, -0.00801920611411333, -0.026145167648792267, 0.024494003504514694, 0.019514137879014015, -0.0033332500606775284, 0.010152656584978104, -0.040892209857702255, 0.003023399505764246, 0.023434173315763474, 0.006337490398436785, 0.0068712919019162655, -0.005199381150305271, -0.021738426759839058, -0.011117780581116676, 0.04299706220626831, 0.011015861295163631, -0.002732226625084877, 0.0043892208486795425, 0.004478424321860075, 0.0012514080153778195, 0.02459542267024517, -0.011954671703279018, 0.01361083798110485, -0.007348646409809589, 0.0013109426945447922, 0.0711653009057045, 0.054558515548706055, 0.006604182533919811, 0.025090042501688004, -0.0046890550293028355, 0.0009395268862135708, 0.012065905146300793, -0.05063539743423462, 0.006679388228803873, -0.014134840108454227, -0.0067881192080676556, 0.03301026299595833, -0.01249795500189066, 0.00867137685418129, -0.0011768800904974341, 0.02105816639959812, -0.03612920269370079, 0.0039024637080729008, 0.018029730767011642, -0.0027793762274086475, -0.01116218138486147, -0.06759286671876907, -0.0026430077850818634, -0.03137850761413574, -0.00862294901162386, 0.02708153985440731, 0.02017775923013687, -0.0017277126898989081, -0.005573316942900419, -0.02276523970067501, -0.027413053438067436, 0.03549271449446678, 0.02781786024570465, 0.03452391177415848, -0.008258474990725517, -0.008499008603394032, -0.03271268680691719, 0.038740236312150955, 0.03421240299940109, -0.04870889335870743, 0.020082952454686165, 0.010667489841580391, 0.015861093997955322, 0.007820961065590382, 0.043264493346214294, 0.0076561979949474335, -0.020222686231136322, 0.04748377203941345, 0.005970256868749857, 0.008286151103675365, -0.015062031336128712, 0.042248617857694626, -0.00012206999963382259, -0.030498448759317398, 0.010562816634774208, -0.00684893736615777, -0.022841744124889374, 0.0077978502959012985, -0.03346007317304611, 0.03087465837597847, 0.07437615841627121, 0.0055890935473144054, 0.0018520032754167914, 0.008091265335679054, -0.0005793888121843338, 0.03520268574357033, -0.019128544256091118, -0.009275910444557667, 0.021082649007439613, 0.04019616171717644, 0.011158579029142857, 0.027370523661375046, 0.02240000292658806, 0.04202916845679283, -0.009863064624369144, -0.051240239292383194, 0.0056778620928525925, 0.019805675372481346, -0.05510566011071205, 0.03182915598154068, 0.007454477716237307, -0.023417292162775993, -0.001132891047745943, 0.032282304018735886, -0.007365148048847914, 0.0414084754884243, 0.017474135383963585, 0.0055304295383393764, 0.0031783010344952345, -0.03229851648211479, 0.006033880170434713, 0.058545514941215515, -0.025529269129037857, 0.054022375494241714, 0.04223969206213951, 0.03988088667392731, 0.03876851126551628, -0.02876943163573742, 0.004561483860015869, 0.006418255623430014, 0.06900694221258163, 0.02224000170826912, 0.03539074584841728, 0.005086914636194706, -0.04256635159254074, -0.028003884479403496, -0.035494059324264526, 0.0008672583498992026, -0.04975549131631851, -0.016995802521705627, 0.022886667400598526, -0.023953037336468697, 0.02486284449696541, -0.026836492121219635, -0.007074157707393169, 0.011285778135061264, 0.05765720456838608, 0.006695703603327274, 0.000254426384344697, 0.027341444045305252, 0.02262946590781212, 0.00020449477597139776, 0.03678252920508385, 0.00850276742130518, 0.009446253068745136, 0.0416211262345314, 0.021815404295921326, 0.04807637631893158, 0.020504459738731384, -0.040808845311403275, 0.0075712380930781364, -0.030732063576579094, -0.006460423115640879, 0.014564084820449352, -0.004579903557896614, -0.04199417307972908, -0.027083072811365128, 0.04017602652311325, -0.0184139683842659, 0.02809557132422924, 0.014800826087594032, 0.011482350528240204, 0.03340602666139603, -0.015629500150680542, 0.003375197295099497, 0.04909086972475052, 0.012308693490922451, -0.032673440873622894, -0.005890976171940565, -0.0001331301173195243, 0.0005616585840471089, 0.013368896208703518, -0.039180949330329895, -0.024618662893772125, -0.03262308984994888, -0.025324247777462006, -0.037123892456293106, -0.009851456619799137, 0.0005975129315629601, -0.002897172002121806, 0.005077935755252838, 0.009394481778144836, -0.010982406325638294, 0.02788109891116619, -0.0043554892763495445, 0.025574374943971634, -0.025765063241124153, 0.00451357988640666, -0.034776899963617325, -0.014009171165525913, -0.008800186216831207, -0.0444917269051075, -0.0034542391076684, -0.042843375355005264, 0.029884476214647293, -0.011454369872808456, 0.061670295894145966, -0.01359513308852911, -0.020704617723822594, 0.021350642666220665, 0.004839474800974131, -0.036083340644836426, 0.027091091498732567, 0.04281006008386612, 0.0013363846810534596, 0.045599594712257385, -0.024962229654192924, -0.0427229218184948, -0.01568659581243992, -0.001095653511583805, 0.042649172246456146, 0.002150732558220625, -0.013037050142884254, -0.008590648882091045, 0.02807539701461792, 0.017321612685918808, 0.008714830502867699, 0.033648356795310974, -0.025293603539466858, 0.0225483737885952, -0.03920072317123413, 0.04031780734658241, -0.04317355528473854, -0.02075463905930519, -0.03361130878329277, -0.04892240837216377, -0.014958775602281094, 0.004833587910979986, -0.017906272783875465, 0.014539961703121662, -0.03435477241873741, -0.002961767604574561, -0.028947459533810616, -0.0036872103810310364, -0.014922413043677807, 0.01108240894973278, 0.05746981501579285, 0.014106547459959984, 0.008121930062770844, -0.023785963654518127, -0.005364215467125177, -0.02805103175342083, -0.017532289028167725, 0.004680586978793144, 0.047129418700933456, 0.03242895379662514, -0.032442040741443634, -0.019684961065649986, 0.011393104679882526, -0.01467369869351387, -0.02701744996011257, 0.007435130886733532, 0.03951065242290497, -0.006573589518666267, 0.003909226041287184, -0.009035054594278336, 0.019679725170135498, -0.03181057050824165, 0.042558930814266205, -0.014185300096869469, -0.0041915071196854115, -0.021507002413272858, -0.007532590068876743, -0.06151528283953667, -0.035232048481702805, 0.018722422420978546, 0.006028653588145971, 0.07686437666416168, 0.023940391838550568, 0.02397458255290985, -0.03352786973118782, -0.029907552525401115, 0.030832065269351006, -0.013251213356852531, -0.033929333090782166, -0.03392237797379494, 0.00666844705119729, 0.014956782571971416, -0.03341606259346008, -0.03202499449253082, 0.045508552342653275, 0.0022383786272257566, -0.014629518613219261, -0.019909709692001343, 0.0021209800615906715, -0.017834488302469254, -0.019405722618103027, 0.018982116132974625, -0.006566941272467375, 0.07482852786779404, 0.030416693538427353, 0.0035104569979012012, 0.0031353060621768236, 0.003308054292574525 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
2.3 What is Next Sentence Prediction? NSP (Next Sentence Prediction) is used to help BERT learn about relationships between sentences by predicting if a given sentence follows the previous sentence or not. **Next Sentence Prediction Example:** 1. Paul went shopping. He bought a new shirt. (correct sentence pair) 2. Ramona made coffee. Vanilla ice cream cones for sale. (incorrect sentence pair) In training, 50% correct sentence pairs are mixed in with 50% random sentence pairs to help BERT increase next sentence prediction accuracy. **Fun Fact:** BERT is trained on both MLM (50%) and NSP (50%) at the same time.
[ 0.03749881312251091, -0.013882389292120934, 0.027748024091124535, -0.057181697338819504, 0.081419937312603, 0.03216325119137764, 0.05621311813592911, 0.09927156567573547, -0.15362167358398438, -0.009566844440996647, -0.09094517678022385, 0.01863796077668667, -0.002944018691778183, 0.007355941459536552, 0.012302872724831104, 0.005988225340843201, 0.04440832883119583, 0.006887510418891907, -0.031620923429727554, -0.04441643878817558, -0.040990181267261505, -0.01271967962384224, 0.0431659035384655, -0.051155366003513336, 0.11109737306833267, 0.005286398809403181, -0.05902266874909401, -0.04710923507809639, -0.07977273315191269, 0.01630183309316635, -0.0871947780251503, -0.005969029385596514, 0.038757991045713425, -0.046574559062719345, 0.027125531807541847, -0.008270783349871635, -0.04336881265044212, 0.05833762511610985, -0.02622777596116066, -0.03486024960875511, -0.1222631186246872, -0.009500899352133274, -0.04342414811253548, -0.03227991983294487, 0.03785896673798561, -0.0821148082613945, -0.07717955857515335, 0.03789612650871277, -0.031072013080120087, -0.06783252954483032, -0.06838525831699371, 0.08846628665924072, -0.07695213705301285, 0.005193939432501793, -0.04998492822051048, 0.019126811996102333, -0.04080258309841156, -0.07509902119636536, 0.0297803096473217, -0.00327570759691298, 0.06358005106449127, -0.0301703829318285, -0.002480912720784545, 0.04496682062745094, -0.00101225555408746, -0.030239436775445938, 0.011594951152801514, 0.010874366387724876, -0.10055959969758987, 0.010350141674280167, -0.01593800075352192, -0.08695035427808762, -0.07063550502061844, 0.079788938164711, 0.07594370096921921, -0.016343433409929276, -0.012303462252020836, 0.02758016809821129, -0.08179061859846115, 0.04448985680937767, 0.000356117234332487, -0.037274930626153946, 0.0068374075926840305, 0.02061782032251358, 0.033756326884031296, 0.06487774103879929, 0.06675136089324951, -0.04064192622900009, -0.05690547078847885, 0.03726113587617874, 0.004269713070243597, -0.09240802377462387, -0.02502283826470375, -0.032650236040353775, 0.0268692784011364, -0.025787953287363052, 0.004252824001014233, 0.022697340697050095, -0.03512071818113327, -0.055942654609680176, 0.03945755586028099, -0.07536923140287399, 0.0108376769348979, 0.05588870123028755, -0.05789966881275177, 0.01656910590827465, 0.02252936363220215, -0.09549378603696823, -0.028777480125427246, 0.02189355343580246, 0.0476951003074646, -0.011374901980161667, -0.00423211557790637, 0.06219441443681717, -0.05403141304850578, 0.009350063279271126, -0.0006970327231101692, 0.019584577530622482, 0.021684322506189346, -0.012897763401269913, -0.07703700661659241, -0.06645611673593521, -0.011385408230125904, 0.03461558371782303, -0.02525765262544155, 0.05379902943968773, -0.06839467585086823, 0.028387093916535378, 0.02530161663889885, 0.020116209983825684, 0.0507076233625412, -0.016613150015473366, 0.02792402356863022, 0.03026157058775425, 0.061724163591861725, 0.02167562209069729, -0.032478976994752884, -0.03925338760018349, 0.0345064178109169, -0.016345936805009842, 0.0022683311253786087, 0.07424484193325043, 0.0008153287344612181, 0.040806591510772705, 0.03077182173728943, -0.05012614279985428, -0.07187874615192413, 0.034371744841337204, -0.0021068567875772715, 0.06381694227457047, -0.025626784190535545, 0.026183342561125755, -0.02760416828095913, -0.09832125902175903, 0.06786850094795227, 0.056114353239536285, 0.045130468904972076, -0.020310409367084503, -0.04726986587047577, -0.06715168803930283, 0.00023798522306606174, 0.03314995393157005, -0.06171701103448868, 0.012443835847079754, 0.001060512731783092, -0.026382146403193474, -0.029721012338995934, 0.06269712001085281, 0.039416734129190445, 0.0762869268655777, 0.080291748046875, -0.038622546941041946, 0.00671538757160306, -0.06779900938272476, 0.037820782512426376, 0.008725252002477646, 0.02387709729373455, 0.06114631146192551, -0.025454485788941383, -0.05548236891627312, -0.006582073401659727, 0.031724847853183746, 0.02642808109521866, -0.002273425692692399, 0.0017303094500675797, 0.008408388122916222, 0.0056593879126012325, 0.009693149477243423, -0.022764377295970917, 0.06635504215955734, -0.009364044293761253, -0.0025887039955705404, 0.05818638950586319, -0.019618961960077286, 0.02092154696583748, -0.025080984458327293, -0.017290320247411728, 0.03406289219856262, 0.006088398862630129, 0.004350265488028526, 0.05302644893527031, -0.02991783246397972, 0.06329269707202911, 0.024908147752285004, 0.00983815174549818, 0.0017404623795300722, -0.007940998300909996, 0.006086778827011585, 0.043610528111457825, -0.019944647327065468, -0.018956191837787628, -0.0853474885225296, -0.022613605484366417, -0.06087383255362511, -0.022628912702202797, -0.01177211757749319, 0.026990918442606926, 0.024331461638212204, -0.008777344599366188, -0.013502128422260284, 0.07609797269105911, -0.01022103987634182, -0.030384181067347527, -0.028525860980153084, -0.01645377278327942, 0.056580133736133575, 0.036334846168756485, 0.06373818963766098, 0.043906260281801224, -0.048413779586553574, -0.026443809270858765, -0.04942025616765022, 0.09669800847768784, 0.004624573513865471, 0.0063435849733650684, 0.04876150190830231, -0.01585179567337036, 0.06918112933635712, -0.010081670247018337, -0.06452567875385284, -0.05745626240968704, 0.06533496826887131, 0.026101216673851013, 0.13183128833770752, -0.026472507044672966, 0.048172805458307266, 0.060838814824819565, -0.05171307176351547, -0.04478029906749725, 0.009733378887176514, -0.060797180980443954, 0.04209908843040466, 0.01652407832443714, -0.007848754525184631, -0.04482534900307655, 0.12182467430830002, -0.007442747242748737, -0.01084420457482338, 0.02557002753019333, 0.03667651116847992, -0.0012788339518010616, -0.03810151293873787, -0.0018373894272372127, -0.0027264035306870937, -0.0056503526866436005, -0.03378720581531525, 0.008600505068898201, 0.006557687185704708, -0.003964234609156847, 0.009027207270264626, 0.013290242291986942, -0.012224455364048481, 0.05392296612262726, 0.02142859250307083, 0.0407063364982605, 0.019193585962057114, 0.06564397364854813, 0.013300886377692223, -0.0033510031644254923, -0.011421664617955685, -0.06504422426223755, -0.03338160365819931, 0.049999576061964035, 0.0029829402919858694, 0.00010580387606751174, -0.02069953642785549, -0.0070794434286653996, -0.02590864524245262, 0.017370592802762985, -0.047552887350320816, 0.0010593278566375375, 0.03214164078235626, -0.04244283586740494, 0.007210396230220795, -0.011989696882665157, 0.05144136771559715, 0.0007508636335842311, 0.007994789630174637, 0.008595237508416176, -0.027525797486305237, 0.018021009862422943, 0.0256342850625515, -0.07670865207910538, -0.053373467177152634, -0.016155313700437546, 0.027845414355397224, 0.033479683101177216, 0.015464508906006813, -0.06914038211107254, -0.00023923942353576422, 0.050316184759140015, -0.001817152602598071, 0.004719200078397989, -0.014832093380391598, 0.09516830742359161, -0.0309662576764822, -0.02832949161529541, 0.022549502551555634, -0.030584992840886116, 0.024316532537341118, 0.017291763797402382, -0.018385732546448708, -0.008409729227423668, 0.005904192104935646, -0.004090925678610802, -0.033173251897096634, -0.01757560856640339, 0.003103931900113821, 0.009597500786185265, 0.007802098523825407, 0.017746521160006523, -0.028075598180294037, -0.034647904336452484, 0.032167088240385056, 0.010483814403414726, 0.000137934839585796, 0.01628539338707924, -0.03844262287020683, 0.004906367044895887, -0.013086455874145031, -0.003923434764146805, 0.02560875192284584, -0.04049738496541977, 0.0039498466067016125, 0.013762049376964569, 0.058094996958971024, 0.013241056352853775, 0.032677218317985535, -0.012516451068222523, -0.010856345295906067, -0.044776514172554016, 0.028669603168964386, -0.010145078413188457, -0.0033927063923329115, -0.0029406340327113867, -0.014298658818006516, -0.011243687011301517, -0.03235194459557533, -0.004405161365866661, -0.015084450133144855, -0.030609799548983574, 0.005929963197559118, 0.03275148198008537, -0.03355209156870842, 0.006002660840749741, -0.00871568638831377, -0.011197161860764027, -0.04113313555717468, 0.005950210615992546, 0.048277005553245544, -0.011039364151656628, -0.049306634813547134, -0.03677097707986832, 0.04875217378139496, 0.04383191093802452, 0.04690013825893402, 0.009129352867603302, -0.012616987340152264, 0.03492104634642601, 0.01818058080971241, 0.013043161481618881, 0.001304685603827238, -0.017268413677811623, 0.023519359529018402, -0.033157579600811005, -0.00426436448469758, 0.06160377711057663, -0.016502849757671356, -0.026207206770777702, 0.043153416365385056, -0.0648241937160492, -0.02158888429403305, 0.031039876863360405, 0.007401282899081707, 0.00800167303532362, -0.015103143639862537, -0.0037353995721787214, 0.01811380498111248, 0.00454871729016304, 0.0033563016913831234, 0.02895687147974968, 0.024750350043177605, -0.019309336319565773, 0.04997912794351578, -0.016717050224542618, 0.006187453866004944, -0.019194599241018295, -0.05570405349135399, 0.012544204480946064, -0.05503712594509125, 0.0026500187814235687, -0.041533637791872025, -0.028033239766955376, 0.03275831788778305, 0.008470934815704823, 0.017196746543049812, 0.004429156892001629, -0.024675900116562843, -0.025204742327332497, 0.0066236830316483974, 0.008293346501886845, 0.0069442265667021275, 0.03340578079223633, 0.006880396977066994, -0.041938286274671555, -0.0039777616038918495, -0.044784218072891235, -0.013161363080143929, -0.006444758269935846, -0.022891171276569366, -0.0209994837641716, 0.0025507938116788864, 0.010988185182213783, -0.014812391251325607, 0.013739966787397861, 0.05050670728087425, -0.01431510504335165, -0.000938835961278528, -0.02396130934357643, 0.00988488644361496, 0.00695093022659421, -0.020103774964809418, -0.010614038445055485, 0.005854934919625521, -0.021220389753580093, -0.0031607833225280046, -0.007305113133043051, -0.06591340899467468, -0.0013291815994307399, 0.029104551300406456, 0.04599733650684357, -0.045360006392002106, 0.05880845710635185, 0.005742307286709547, -0.01695706509053707, -0.024873314425349236, -0.01346301008015871, 0.02047789841890335, 0.034541379660367966, 0.015238954685628414, -0.04725324362516403, -0.010145023465156555, -0.009476046077907085, -0.045169562101364136, -0.008929037488996983, 0.02814951352775097, 0.02195974625647068, 0.03674301877617836, 0.011678868904709816, -0.03538116067647934, -0.03523239865899086, -0.02279040403664112, 0.023876028135418892, -0.008263126015663147, -0.011900227516889572, -0.029881319031119347, -0.006127975881099701, -0.012393211014568806, 0.011138633824884892, -0.011972669512033463, -0.018830787390470505, 0.011125508695840836, -0.015017327852547169, 0.03192725405097008, -0.014237750321626663, 0.014693115837872028, 0.01744885928928852, 0.004891673102974892, 0.004791987128555775, -0.007399925496429205, -0.017107853665947914, 0.07352112978696823, -0.0330161452293396, 0.05307193100452423, 0.009852349758148193, 0.024469561874866486, -0.021740594878792763, -0.011032219044864178, 0.024045297876000404, -0.024260109290480614, 0.015005513094365597, -0.02419882081449032, 0.028565237298607826, -0.04576006159186363, -0.04581044241786003, 0.03888000547885895, -0.009822203777730465, -0.004291171673685312, 0.010480480268597603, 0.017761370167136192, -0.008518224582076073, -0.016103031113743782, -0.001084734220057726, -0.007873916067183018, -0.01274572592228651, 0.007735539227724075, 0.008805574849247932, 0.01177134457975626, -0.01045648381114006, 0.00044515402987599373, 0.01230759546160698, 0.009707151912152767, -0.028534861281514168, -0.02365698851644993, 0.00007975933112902567, -0.005968378856778145, 0.023677265271544456, 0.052098896354436874, 0.052235957235097885, -0.007831906899809837, -0.016914593055844307, -0.016043707728385925, 0.028532687574625015, -0.01689901202917099, 0.04401019588112831, -0.005974026396870613, 0.007997803390026093, -0.0028603419195860624, 0.04726715385913849, -0.0135977603495121, 0.017634332180023193, -0.013165054842829704, -0.003565660212188959, -0.043900441378355026, -0.0171495471149683, 0.07917702943086624, 0.02856830693781376, -0.023750292137265205, -0.008638817816972733, 0.03232165798544884, -0.03924160450696945, -0.026738809421658516, -0.015090886503458023, -0.04662201181054115, 0.058617740869522095, -0.006725532468408346, 0.0277615487575531, 0.010887162759900093, 0.017721369862556458, -0.026357470080256462, -0.039760343730449677, 0.015408409759402275, 0.007795423269271851, 0.03509338200092316, -0.019045770168304443, 0.03230391815304756, 0.011122135445475578, 0.03844686225056648, 0.04329904541373253, -0.04616304114460945, 0.0008403612300753593, 0.03111419454216957, -0.021676020696759224, 0.01394924521446228, 0.013601204380393028, 0.00933777168393135, 0.01196391973644495, 0.04487122967839241, 0.03584958240389824, 0.02627752348780632, -0.007826660759747028, 0.02307802066206932, 0.014395722188055515, -0.014716647565364838, -0.07042688876390457, 0.06167859956622124, -0.04055972769856453, 0.01744135469198227, 0.03217892348766327, -0.01775122620165348, -0.020942656323313713, 0.03137873485684395, -0.00441640242934227, 0.016693491488695145, 0.027772311121225357, -0.009107216261327267, 0.0010303165763616562, 0.013522622175514698, -0.01861646957695484, -0.01972935162484646, -0.0036014881916344166, -0.0535086952149868, -0.02170935831964016, -0.007041167933493853, 0.05266350880265236, -0.024221887812018394, 0.01007762923836708, -0.010801929980516434, 0.01026294007897377, 0.01671537384390831, 0.018733607605099678, -0.03946250304579735, -0.01834898442029953, 0.019076334312558174, 0.02113274298608303, 0.04619249701499939, 0.02134723961353302, 0.015639984980225563, -0.022071924060583115, 0.023453950881958008, 0.0027245436795055866, 0.0405433364212513, 0.06727785617113113, 0.027414891868829727, 0.011663711629807949, -0.004537169821560383, -0.0259934701025486, 0.0019166582496836782, 0.00992363877594471, -0.002512422390282154, -0.032631345093250275, 0.011704235337674618, -0.00421140668913722, 0.009439022280275822, 0.004492557141929865, 0.003079944523051381, -0.017985548824071884, 0.014280719682574272, -0.018209043890237808, 0.0777205303311348, -0.002569065196439624, -0.018669918179512024, -0.06026580184698105, -0.048202622681856155, 0.0004633793723769486, -0.0225809495896101, -0.05984245985746384, -0.03204156085848808, -0.033019158989191055, 0.010485555045306683, -0.040925282984972, 0.0034848074428737164, 0.002477728994563222, -0.026375873014330864, 0.018596243113279343, 0.017679335549473763, -0.006262506358325481, 0.01813025027513504, 0.00938507355749607, 0.033781424164772034, -0.043006476014852524, -0.005068190395832062, -0.004609298426657915, -0.026974724605679512, -0.0024528938811272383, -0.022426694631576538, -0.010657292790710926, 0.004730481654405594, -0.01092327106744051, 0.04064532741904259, 0.10060855001211166, 0.006918824277818203, 0.04861387982964516, -0.004300472792237997, -0.015516001731157303, 0.007858755998313427, 0.035832714289426804, 0.06376958638429642, -0.00992199219763279, 0.001476447330787778, -0.023223062977194786, -0.046641647815704346, -0.02992159314453602, 0.01883891224861145, 0.004340229090303183, 0.051341429352760315, -0.030174989253282547, 0.026422057300806046, -0.0020798782352358103, -0.01920679211616516, -0.004651632159948349, 0.048444151878356934, -0.026330480352044106, 0.02364008128643036, -0.04396886005997658, 0.014426900073885918, -0.04558943212032318, -0.007483791559934616, -0.02030777372419834, -0.04803713038563728, -0.011094910092651844, 0.060929037630558014, -0.031124021857976913, 0.04324024170637131, 0.026516837999224663, 0.03937798738479614, 0.012686234898865223, 0.021083299070596695, -0.003950514364987612, 0.014246206730604172, 0.06932897865772247, -0.011408260092139244, 0.0610945038497448, -0.00011727028322638944, 0.05639403685927391, -0.028351977467536926, -0.01147022470831871, 0.02990216761827469, 0.023255111649632454, 0.03999919816851616, 0.013501458801329136, -0.03395269811153412, -0.015289770439267159, -0.02732926420867443, -0.05333605036139488, 0.00036969227949157357, -0.00008835082553559914, 0.000004353949861979345, 0.03316996991634369, 0.0002549536875449121, 0.03213068097829819, -0.05599207431077957, 0.029404185712337494, 0.004426808096468449, 0.013993469998240471, -0.00906887836754322, 0.03419411927461624, -0.02827785164117813, 0.00008272604463854805, 0.021932775154709816, -0.05018101632595062, 0.0547393374145031, 0.027547236531972885, 0.01390489749610424, 0.003576563438400626, 0.0171718318015337, 0.04039764776825905, -0.016959644854068756, -0.024044541642069817, -0.07149594277143478, 0.03386827930808067, 0.04426170140504837, -0.015470507554709911, 0.010400185361504555, 0.03062293492257595, 0.0012560697505250573, -0.014217237941920757, 0.013781336136162281, 0.03034087084233761, -0.029285643249750137, -0.031085047870874405, 0.02646704763174057, 0.03464225307106972, 0.04761210456490517, 0.026938024908304214, 0.025625629350543022, -0.0354224294424057, 0.001793473493307829 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
# BERT 101 🤗 State Of The Art NLP Model Explained
[ 0.04321334511041641, -0.014626871794462204, 0.06323208659887314, -0.037857092916965485, 0.05691755935549736, 0.04081776365637779, 0.00619508046656847, 0.06046883761882782, -0.028180161491036415, -0.012621917761862278, -0.07445815950632095, 0.0756714716553688, -0.02950824797153473, 0.058684613555669785, 0.01930791325867176, 0.05343536287546158, 0.031466200947761536, -0.03401391580700874, 0.018943428993225098, -0.017697226256132126, -0.054484445601701736, -0.07045044004917145, 0.06416230648756027, -0.04521482437849045, 0.059033237397670746, -0.01773267425596714, -0.005746612790971994, -0.006281021051108837, -0.06447751820087433, 0.041056614369153976, -0.10903391987085342, 0.00042889590258710086, 0.025171447545289993, -0.004510148894041777, -0.023835772648453712, -0.009225863963365555, -0.09834501892328262, 0.03926849365234375, -0.0407528430223465, -0.05015518143773079, -0.07091055810451508, -0.0615677572786808, -0.029854489490389824, 0.018208704888820648, -0.048701170831918716, -0.04341606795787811, -0.24683348834514618, 0.10976235568523407, 0.0046107531525194645, -0.03391492739319801, -0.06918516010046005, 0.05483018234372139, -0.0879969522356987, 0.052931226789951324, -0.07060521841049194, -0.002495379885658622, 0.00649283779785037, -0.06386225670576096, -0.03440015763044357, -0.04763796553015709, 0.06698424369096756, -0.011187616735696793, -0.00039134969119913876, 0.020731903612613678, 0.036430373787879944, -0.010873676277697086, 0.0025476468726992607, 0.014665883965790272, -0.07566745579242706, 0.05552015081048012, 0.0008541165152564645, -0.016148749738931656, -0.021826110780239105, -0.011471540667116642, 0.0012633366277441382, -0.06448562443256378, 0.03554731234908104, 0.01578385755419731, 0.026022523641586304, 0.037670768797397614, 0.012968619354069233, 0.0006676308112218976, 0.05700788274407387, 0.05268288031220436, 0.022548111155629158, 0.016233060508966446, 0.0896676704287529, -0.05162172019481659, -0.06087809428572655, 0.038638174533843994, -0.011459038592875004, -0.14964784681797028, -0.04797946289181709, -0.03341834247112274, 0.05359647423028946, -0.025793401524424553, 0.004235448781400919, 0.006447985768318176, -0.014514392241835594, -0.02832946926355362, 0.016547581180930138, -0.009632684290409088, 0.05883820727467537, -0.029015637934207916, -0.09866037964820862, 0.04788288101553917, 0.027266956865787506, -0.08019635081291199, -0.05484310910105705, 0.019546395167708397, -0.031695786863565445, -0.026542378589510918, 0.015674008056521416, 0.044469915330410004, -0.04697428271174431, 0.03732914477586746, -0.009502715431153774, -0.007901959121227264, -0.005162007175385952, 0.06454619765281677, -0.018329277634620667, 0.015711642801761627, 0.062155500054359436, -0.009785269387066364, 0.04579395428299904, 0.026037011295557022, 0.0010045048547908664, 0.04280548542737961, -0.03270076587796211, -0.011967010796070099, 0.05214757099747658, -0.02879408374428749, 0.06789927929639816, 0.0030618964228779078, -0.00008858502405928448, 0.024228140711784363, -0.0010252901120111346, -0.05415831133723259, 0.011357961222529411, -0.0031751622445881367, -0.0200972743332386, 0.04423997923731804, 0.010175633244216442, 0.06372996419668198, 0.0368124283850193, -0.036190010607242584, -0.07247162610292435, 0.041325196623802185, -0.036594290286302567, -0.0037277371156960726, -0.0619308203458786, -0.0025252329651266336, -0.029253341257572174, -0.07287151366472244, 0.01180794183164835, 0.08334765583276749, 0.003217849414795637, -0.0005631488165818155, -0.011762638576328754, -0.0460561104118824, 0.04792322963476181, 0.015777649357914925, 0.004924048203974962, -0.029741661623120308, 0.025458812713623047, -0.07766672223806381, -0.016697337850928307, 0.05550624057650566, -0.017233289778232574, -0.009404980577528477, -0.019816303625702858, 0.009629377163946629, 0.07000645250082016, -0.008291700854897499, -0.05300922319293022, -0.011978539638221264, 0.06582280993461609, 0.016093844547867775, -0.03277905285358429, 0.03207772597670555, -0.018040839582681656, 0.03254419192671776, -0.020657740533351898, 0.04399260878562927, 0.045302797108888626, -0.03926217183470726, 0.00021816401567775756, 0.0036514331586658955, 0.022432416677474976, 0.03164998069405556, -0.015083764679729939, -0.05168861523270607, 0.0789022296667099, -0.03467145189642906, 0.06224220618605614, -0.02951372228562832, -0.05415540188550949, 0.11320526152849197, 0.055580150336027145, 0.0334467887878418, 0.0894325003027916, -0.03783980384469032, -0.008438347838819027, -0.029694965109229088, -0.017494168132543564, -0.013750544749200344, 0.032943304628133774, 0.009478297084569931, 0.042306188493967056, 0.016107449308037758, 0.029508279636502266, -0.10627710074186325, 0.017782239243388176, -0.08254535496234894, -0.04359007626771927, -0.06996612995862961, -0.003377084620296955, 0.02118857018649578, 0.018970735371112823, 0.0014708783710375428, 0.15361624956130981, -0.051062632352113724, -0.005755252670496702, 0.02952161245048046, -0.02439725585281849, 0.07386206090450287, 0.07885875552892685, 0.010253176093101501, 0.10084393620491028, -0.05692174285650253, -0.04055913910269737, -0.03658607229590416, 0.040662143379449844, 0.0031363926827907562, 0.007250122260302305, 0.019295481964945793, 0.011532314121723175, 0.041096657514572144, 0.02521258033812046, -0.06227784603834152, -0.00007728285709163174, 0.032749664038419724, 0.03292498737573624, 0.06085547059774399, -0.02327074110507965, 0.0019003720954060555, 0.053287964314222336, 0.031017709523439407, -0.02734193578362465, 0.060369912534952164, -0.0444500707089901, 0.0392686165869236, -0.02945035696029663, 0.0043100821785628796, 0.025699414312839508, 0.028867609798908234, 0.004466374404728413, -0.024830888956785202, -0.011036055162549019, 0.018344948068261147, 0.014726554043591022, -0.042609959840774536, -0.011181767098605633, -0.037579067051410675, -0.008402496576309204, -0.054680775851011276, -0.00305638718418777, -0.0006854680832475424, -0.002981338417157531, 0.03942103683948517, 0.00849573127925396, -0.026212411001324654, 0.056976109743118286, 0.010547141544520855, 0.011032785288989544, 0.006564303766936064, 0.046953391283750534, -0.014823924750089645, -0.013836607336997986, -0.024383462965488434, -0.030088014900684357, -0.016690170392394066, 0.04761291295289993, -0.009565962478518486, 0.028249623253941536, -0.021169759333133698, 0.022263599559664726, 0.00197885581292212, 0.012392166070640087, 0.010365995578467846, -0.003874635323882103, 0.04196515306830406, -0.04951964318752289, 0.0006869741482660174, 0.02975219301879406, 0.015632668510079384, 0.016217084601521492, -0.02747906744480133, -0.009644806385040283, -0.002428750041872263, 0.02876933105289936, 0.056957703083753586, -0.018240313977003098, -0.010132999159395695, -0.03910888731479645, 0.045356374233961105, 0.03556622937321663, 0.009673291817307472, -0.1270241141319275, -0.0441354438662529, 0.038179103285074234, -0.011251181364059448, 0.028330514207482338, -0.02446497417986393, 0.028752395883202553, -0.007109096273779869, -0.005013065878301859, -0.018404336646199226, 0.012691762298345566, 0.014513242058455944, 0.020164592191576958, 0.03779975324869156, -0.007090711034834385, 0.01375499740242958, -0.060679662972688675, 0.013076533563435078, -0.002751500578597188, 0.024855472147464752, -0.023503609001636505, 0.05802470073103905, -0.008595140650868416, -0.005503669381141663, -0.0012740968959406018, 0.026827344670891762, 0.018043817952275276, 0.031179258599877357, 0.029410872608423233, 0.0005266250227577984, -0.02291373908519745, 0.020796533674001694, -0.03202064335346222, 0.04104474186897278, -0.006647291127592325, -0.0001901731448015198, 0.015985602512955666, 0.025302842259407043, 0.03447100892663002, 0.0190291628241539, 0.0024523648899048567, -0.007899141870439053, -0.012790578417479992, -0.024828778579831123, -0.021795589476823807, -0.004524066112935543, -0.033618342131376266, -0.011669700033962727, 0.02064865082502365, -0.025000931695103645, -0.03067176416516304, -0.03071332536637783, -0.024561598896980286, -0.0011272503761574626, 0.008974870666861534, -0.026544496417045593, -0.01770707219839096, -0.011691795662045479, 0.03169124200940132, -0.026312431320548058, -0.021071624010801315, 0.04096590727567673, -0.014096883125603199, -0.04176876321434975, -0.05097787082195282, 0.06378205120563507, 0.00905082281678915, -0.0029571454506367445, 0.01848212070763111, 0.038692597299814224, 0.027414726093411446, -0.00019199724192731082, -0.01955900713801384, 0.01522574108093977, -0.034939780831336975, 0.06570176780223846, 0.01656930148601532, -0.0035160037223249674, 0.0895991325378418, -0.0056083668023347855, -0.05089716985821724, -0.02075505070388317, -0.027496296912431717, -0.007459450978785753, 0.02741953916847706, -0.0083126500248909, -0.00039513848605565727, -0.0032533269841223955, 0.022778892889618874, 0.04010818526148796, -0.007034790702164173, 0.0036808873992413282, -0.007938670925796032, 0.016294468194246292, 0.010814612731337547, 0.009885808452963829, 0.007965939119458199, -0.021620579063892365, 0.0044541507959365845, 0.009452163241803646, 0.013161148875951767, -0.04793781414628029, -0.02714359201490879, 0.020142121240496635, -0.023692842572927475, 0.04981698468327522, -0.013977184891700745, -0.040868181735277176, 0.012070690281689167, 0.011645299382507801, -0.034716229885816574, 0.004364930558949709, 0.008894694037735462, 0.0029357157181948423, 0.043381113559007645, 0.012766972184181213, -0.03819067031145096, -0.03444894403219223, -0.03914247825741768, 0.006235226523131132, -0.002148180268704891, 0.029131054878234863, 0.0007536928169429302, 0.004740024451166391, -0.024362215772271156, -0.028613606467843056, 0.022838255390524864, 0.02401878498494625, -0.01996460184454918, -0.028732597827911377, -0.001946895383298397, -0.028588218614459038, 0.043292880058288574, -0.03283335268497467, 0.00558113306760788, 0.04155915230512619, 0.0135365454480052, 0.027828309684991837, 0.01788516901433468, -0.08438576012849808, -0.020725013688206673, 0.025300156325101852, 0.019241156056523323, -0.029935680329799652, 0.05409589782357216, -0.02929750084877014, -0.036207180470228195, -0.003584520425647497, 0.011219910345971584, 0.00979130994528532, 0.04385938122868538, -0.01265622302889824, -0.019030852243304253, -0.019061045721173286, 0.03165901452302933, 0.002635559067130089, 0.0007723570452071726, 0.03132862225174904, 0.01344982348382473, 0.04739660397171974, 0.029678532853722572, -0.025045549497008324, -0.04765724763274193, 0.007620398886501789, 0.024392807856202126, -0.03948775678873062, 0.004268939141184092, -0.01798393204808235, 0.03937533497810364, 0.016955778002738953, 0.013189740478992462, -0.00495380163192749, 0.028616031631827354, -0.017072906717658043, -0.0299057774245739, 0.030807863920927048, 0.01587412692606449, 0.03137357532978058, -0.030936522409319878, 0.009372184053063393, -0.012034386396408081, 0.027993904426693916, -0.0056367842480540276, 0.002193818334490061, 0.00743201794102788, 0.03377539664506912, 0.03011108748614788, 0.022149650380015373, 0.007472595199942589, 0.05044599995017052, -0.006584618240594864, 0.013287213630974293, 0.0011085806181654334, -0.015607965178787708, -0.01607956551015377, -0.024419277906417847, 0.011719887144863605, -0.019248558208346367, -0.012187391519546509, 0.02824568748474121, -0.005940025206655264, 0.030285485088825226, -0.009782681241631508, -0.019319409504532814, 0.021999944001436234, -0.04067324101924896, 0.010675405152142048, -0.05445298179984093, 0.014755011536180973, 0.026211701333522797, -0.006714460905641317, 0.010905715636909008, -0.01128708478063345, -0.01671343483030796, 0.03426538035273552, -0.028300944715738297, 0.000783552008215338, 0.006430509500205517, -0.0061601013876497746, 0.056535977870225906, 0.014214826747775078, -0.024764932692050934, -0.04347241297364235, 0.018519673496484756, 0.04137144237756729, -0.05264689773321152, 0.0029221384320408106, 0.0040984973311424255, -0.0022093283478170633, 0.03073064610362053, 0.025820408016443253, -0.018713412806391716, 0.006697770673781633, 0.018150096759200096, -0.017131227999925613, -0.019908519461750984, -0.06075045466423035, 0.06590881943702698, 0.01595968008041382, -0.011034009046852589, -0.00462340796366334, 0.0005443335394375026, -0.030992582440376282, -0.005713569466024637, -0.02937367931008339, -0.02778076007962227, 0.0808098316192627, -0.007517232559621334, 0.026688555255532265, 0.009063583798706532, -0.00012062225141562521, -0.0003568452666513622, -0.01927264779806137, 0.014415922574698925, 0.036357585340738297, 0.06675258278846741, 0.02689419686794281, -0.015314116142690182, -0.007061694283038378, 0.00303622055798769, 0.034803032875061035, -0.04881376028060913, 0.007579161785542965, 0.008985084481537342, -0.006591221317648888, 0.01649501733481884, 0.013589141890406609, -0.033054426312446594, 0.031041597947478294, 0.06377826631069183, 0.009850909933447838, 0.04300137236714363, -0.010916688479483128, -0.019204162061214447, 0.006878230720758438, -0.05472274124622345, 0.042263906449079514, 0.09030888229608536, -0.01170151773840189, 0.06773240119218826, 0.0388999804854393, 0.002201876835897565, 0.022047823294997215, -0.014959828928112984, -0.033437397330999374, 0.043748658150434494, 0.059538934379816055, -0.023528214544057846, 0.03372219204902649, 0.02948347106575966, -0.021796848624944687, -0.005142688751220703, -0.016254588961601257, -0.012990661896765232, -0.03320656716823578, 0.0012134442804381251, 0.049655981361866, -0.028264859691262245, 0.0071570235304534435, -0.034654032438993454, 0.03975259140133858, 0.02256430685520172, 0.03135928511619568, -0.022147854790091515, 0.005324276629835367, -0.023386936634778976, -0.0027015821542590857, -0.013094286434352398, 0.010943089611828327, 0.0004190985346212983, -0.004027644172310829, 0.06878714263439178, 0.016586029902100563, 0.01715540513396263, -0.020723208785057068, -0.06779172271490097, 0.05165621638298035, -0.028437800705432892, -0.0013036957243457437, -0.021727250888943672, 0.03088984824717045, -0.02680335007607937, -0.026242921128869057, 0.015310462564229965, -0.004963502753525972, -0.004929160233587027, -0.00012190947745693848, 0.02054443769156933, 0.019952116534113884, -0.020470183342695236, -0.014997086487710476, 0.04699702560901642, -0.005465117748826742, 0.0028317742981016636, 0.017150191590189934, 0.008996080607175827, 0.019582312554121017, 0.036177948117256165, 0.015449066646397114, -0.03186777979135513, -0.00246841530315578, 0.002321913605555892, -0.06227551028132439, -0.008337401784956455, -0.00922533217817545, 0.0010081999935209751, -0.01492481678724289, 0.015112562105059624, -0.04688724875450134, 0.043508030474185944, 0.04354630783200264, 0.0036273282021284103, -0.02518145926296711, 0.013847608119249344, -0.046670615673065186, 0.00012187646643724293, -0.037957631051540375, -0.060683250427246094, 0.0006506411009468138, 0.006796244997531176, 0.022101018577814102, 0.028541453182697296, 0.0550321489572525, -0.02409932389855385, -0.026595106348395348, 0.0025342211592942476, -0.0283647570759058, -0.05299244448542595, 0.031641844660043716, 0.03403470665216446, 0.003104702103883028, 0.013013406656682491, 0.003314487636089325, 0.0023481911048293114, -0.04442291706800461, 0.015719182789325714, 0.011247258633375168, -0.015030181035399437, -0.01016089878976345, -0.008387754671275616, 0.03039023093879223, 0.005601167678833008, 0.02654433250427246, 0.032347433269023895, 0.00992833636701107, -0.0012185352388769388, -0.05409649759531021, 0.01911281794309616, -0.02110671065747738, 0.004099076613783836, -0.022283997386693954, -0.02236630767583847, -0.02414875291287899, 0.019722603261470795, 0.02171165868639946, 0.0081967543810606, -0.04887337237596512, -0.0036570820957422256, -0.024113139137625694, -0.024105066433548927, -0.023154359310865402, 0.05963526666164398, 0.04651845991611481, 0.010920579545199871, 0.02799993008375168, 0.0008428070577792823, 0.00006401514110621065, -0.025223953649401665, -0.015691757202148438, 0.028094090521335602, 0.021546371281147003, 0.023881038650870323, -0.0034330077469348907, 0.0038432609289884567, -0.015162704512476921, -0.028563037514686584, -0.03744921460747719, -0.0005348758422769606, 0.04131641611456871, -0.03362368047237396, -0.019127344712615013, -0.009134187363088131, 0.007197681348770857, -0.04727160185575485, 0.021346980705857277, 0.014261519536376, -0.026733344420790672, -0.01967236027121544, 0.015564215369522572, -0.03833077475428581, -0.006748048588633537, 0.030810853466391563, -0.020180124789476395, 0.05808217450976372, 0.04801885038614273, 0.011197546496987343, 0.012595649808645248, -0.024956919252872467, 0.009341273456811905, 0.013395476154983044, -0.03156588226556778, -0.036455169320106506, 0.023354385048151016, 0.024094775319099426, -0.05200280249118805, -0.026962339878082275, 0.03233920410275459, -0.005791029427200556, 0.005184249021112919, -0.001959466841071844, -0.0006657167105004191, -0.014846328645944595, -0.022968173027038574, 0.015051398426294327, 0.012002539820969105, 0.07154946029186249, 0.021745966747403145, 0.007956179790198803, 0.02160538360476494, 0.0055097187869250774 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
4. BERT's performance on common language tasks BERT has successfully achieved state-of-the-art accuracy on 11 common NLP tasks, outperforming previous top NLP models, and is the first to outperform humans! But, how are these achievements measured?
[ 0.028095444664359093, -0.008741098456084728, 0.009353544563055038, -0.027716014534235, 0.027107685804367065, 0.05432255193591118, 0.022413568571209908, 0.05001570284366608, -0.0472380593419075, -0.039030805230140686, -0.06599153578281403, 0.07558131217956543, 0.004306890070438385, 0.0507526621222496, 0.019654175266623497, 0.020726477727293968, 0.029998816549777985, -0.004622041247785091, 0.01304424088448286, -0.059375371783971786, -0.027803977951407433, -0.07268724590539932, 0.09306899458169937, -0.03831196948885918, 0.04036390036344528, -0.0024367922451347113, -0.013569861650466919, -0.045026618987321854, -0.056153032928705215, 0.02857247367501259, -0.12541452050209045, -0.007297790143638849, 0.028069039806723595, 0.020978476852178574, -0.0542910136282444, -0.00674226600676775, -0.04736236855387688, 0.06752224266529083, -0.053109943866729736, -0.06204228475689888, -0.04618089646100998, -0.030345413833856583, -0.023928115144371986, 0.044095415621995926, -0.0590992197394371, -0.027767695486545563, -0.14855210483074188, 0.06263086199760437, 0.006135204341262579, -0.012122764252126217, -0.07456553727388382, 0.10308729857206345, -0.010699554346501827, 0.01140722818672657, -0.08338990062475204, 0.030654707923531532, 0.01908225566148758, -0.07786399126052856, 0.008311565965414047, 0.033542003482580185, 0.014559335075318813, -0.027992110699415207, 0.011602533981204033, -0.035962723195552826, 0.02256815694272518, 0.006978810299187899, 0.02660575695335865, 0.01330655999481678, -0.08956188708543777, 0.08139006048440933, -0.004448009189218283, -0.07909956574440002, -0.02649945393204689, 0.0243198461830616, -0.02343975380063057, -0.05361782759428024, 0.0391383096575737, -0.022070761770009995, -0.010935565456748009, -0.019138438627123833, 0.009840202517807484, 0.0003982091147918254, 0.04472269490361214, 0.034523166716098785, 0.027426209300756454, 0.06504710763692856, 0.08567795157432556, -0.05666963383555412, -0.07990355044603348, 0.043380338698625565, 0.05005248636007309, -0.14614538848400116, -0.04457911103963852, -0.0027688543777912855, 0.03631088137626648, -0.028702132403850555, -0.0462825708091259, 0.03079424798488617, -0.07046441733837128, -0.06603432446718216, 0.013989315368235111, -0.05869542062282562, 0.06747502833604813, -0.0022069101687520742, -0.09866439551115036, 0.026107272133231163, 0.005436919163912535, -0.11340318620204926, -0.035526830703020096, 0.0531868040561676, 0.01918574795126915, -0.05585193261504173, 0.004174182657152414, 0.06802226603031158, -0.04566545411944389, 0.040600743144750595, 0.01856834627687931, 0.031877387315034866, 0.0284817423671484, 0.031271398067474365, 0.005666447337716818, 0.046803537756204605, 0.023584362119436264, -0.026775935664772987, 0.007409391459077597, -0.0021281158551573753, 0.014131234027445316, -0.003491688519716263, 0.0005691247060894966, -0.01970594748854637, 0.049046870321035385, 0.009698745794594288, 0.05241944268345833, 0.032641276717185974, -0.0021541998721659184, 0.0013060474302619696, 0.012817115522921085, -0.04418284446001053, -0.02406322956085205, 0.017796646803617477, -0.08277463167905807, 0.0225242767482996, -0.024421589449048042, 0.041182927787303925, 0.045603927224874496, -0.003992886282503605, -0.06200027093291283, 0.047780025750398636, -0.029152870178222656, -0.0031098523177206516, -0.09544017910957336, 0.011070415377616882, -0.05025245249271393, -0.04894992709159851, 0.052811380475759506, 0.07557302713394165, 0.0037005431950092316, -0.027298729866743088, 0.0006394410156644881, -0.011488370597362518, -0.03302842751145363, 0.011776426807045937, -0.016976427286863327, -0.053136881440877914, -0.027259619906544685, -0.08439809828996658, -0.02827714942395687, 0.035275284200906754, -0.003947071265429258, 0.055566709488630295, 0.016698593273758888, 0.03933725878596306, 0.07070181518793106, -0.0055051823146641254, -0.08582751452922821, 0.03100573644042015, 0.03170982748270035, 0.05230376124382019, 0.0035724055487662554, 0.03474889695644379, -0.003456678707152605, 0.06461503356695175, 0.0019589427392929792, 0.08355100452899933, 0.03056844137609005, -0.057058095932006836, 0.008420843631029129, -0.030671946704387665, 0.07381963729858398, 0.045543693006038666, 0.019099513068795204, -0.04428279772400856, 0.07098778337240219, -0.015180788934230804, -0.003151366487145424, -0.01857338659465313, -0.025955339893698692, 0.11494959145784378, 0.04337881878018379, 0.01352556049823761, 0.06226256117224693, -0.0632331445813179, 0.004760917741805315, 0.0041813417337834835, -0.006747680716216564, 0.010086966678500175, 0.008483636192977428, 0.028435686603188515, -0.04180421680212021, 0.0170262660831213, 0.047194600105285645, -0.11832437664270401, -0.025632429867982864, -0.047790296375751495, -0.0612916499376297, -0.09271357208490372, 0.024819059297442436, 0.06654658168554306, 0.04064961522817612, 0.00972633995115757, 0.1353021264076233, -0.02935676835477352, 0.023135995492339134, 0.02489047683775425, -0.030126268044114113, 0.01936798170208931, 0.048168204724788666, 0.041140682995319366, 0.059714559465646744, -0.019955167546868324, -0.03974205255508423, -0.09995347261428833, 0.054445780813694, 0.021687189117074013, -0.03355957567691803, -0.002946594962850213, 0.012990469112992287, 0.036109860986471176, 0.011369061656296253, 0.007247711531817913, -0.018636176362633705, 0.052418600767850876, 0.010628055781126022, 0.1058109775185585, -0.04737020656466484, -0.0022355352994054556, 0.04284133389592171, 0.010047153569757938, 0.02369212545454502, 0.03845800831913948, -0.12109524011611938, 0.01163890864700079, -0.007582452613860369, 0.014847815968096256, 0.01578413136303425, 0.0322127640247345, 0.01859445497393608, -0.011323290877044201, -0.008168211206793785, 0.013006936758756638, 0.003644943004474044, -0.05562613904476166, -0.027431482449173927, -0.03012733906507492, 0.03146051988005638, -0.051628027111291885, -0.021423304453492165, -0.007578984368592501, -0.005852885544300079, 0.03037167713046074, 0.0011620990699157119, -0.0337052047252655, 0.04781942442059517, 0.010072920471429825, 0.026986846700310707, 0.01655386947095394, 0.048926327377557755, -0.045265212655067444, -0.018718155100941658, 0.005574720446020365, -0.025329535827040672, -0.025669999420642853, 0.06517047435045242, 0.0061127678491175175, -0.01375534012913704, -0.0017215963453054428, 0.008708573877811432, -0.02873518131673336, 0.012459579855203629, -0.0020084886346012354, -0.010413930751383305, 0.014232450164854527, -0.009969780221581459, -0.02085835114121437, 0.000020191126168356277, 0.0057790763676166534, 0.02018263190984726, -0.01185330655425787, 0.004607265815138817, 0.0013305963948369026, -0.0051904101856052876, 0.05446137860417366, -0.034489382058382034, -0.00835516769438982, -0.02248491905629635, 0.018557844683527946, 0.029427679255604744, 0.008541254326701164, -0.100714772939682, -0.049933936446905136, 0.013632276095449924, -0.00266999751329422, 0.008224351331591606, -0.028688613325357437, 0.048858579248189926, -0.03363038972020149, -0.01812358759343624, 0.01709662564098835, -0.007540894206613302, 0.019029613584280014, 0.03268330544233322, 0.024134518578648567, 0.029592618346214294, 0.03371904417872429, -0.04122962802648544, -0.015464965254068375, 0.02783680334687233, 0.05095638334751129, 0.004275477025657892, 0.03756463900208473, -0.004472739994525909, -0.018192043527960777, -0.017987767234444618, 0.01923949085175991, -0.005000429227948189, 0.015222669579088688, 0.054304201155900955, -0.005198223516345024, 0.013381625525653362, 0.0013345798943191767, -0.0036315047182142735, 0.01780019886791706, -0.008315962739288807, -0.008827234618365765, -0.0018397297244518995, 0.07085327059030533, 0.06003681570291519, 0.02359369397163391, 0.02029525674879551, 0.0019202104303985834, 0.010904780589044094, -0.034787122160196304, -0.026275109499692917, -0.019475579261779785, 0.008479604497551918, -0.029261739924550056, 0.013553802855312824, -0.04851352795958519, -0.013154053129255772, -0.008971314877271652, -0.020186513662338257, 0.009273618459701538, 0.0006050205556675792, -0.022562863305211067, 0.009356566704809666, -0.01155111938714981, -0.008210440166294575, 0.008482575416564941, 0.006861851550638676, 0.04683491960167885, -0.00008750049892114475, -0.021170752122998238, -0.052791815251111984, 0.03939170390367508, 0.02038680389523506, -0.01818760298192501, 0.02724382095038891, -0.01217743568122387, 0.019008783623576164, 0.033381592482328415, -0.024093395099043846, 0.015230664052069187, -0.024916457012295723, 0.023521341383457184, -0.014265693724155426, 0.022030800580978394, 0.06244434043765068, -0.0003722008259501308, -0.06335422396659851, -0.006333062890917063, -0.03544969484210014, -0.016204411163926125, 0.006550922989845276, -0.018350830301642418, -0.011077634990215302, -0.012087412178516388, 0.021389147266745567, 0.0008941747946664691, 0.012165408581495285, -0.01981569454073906, -0.021381806582212448, 0.044840604066848755, 0.021501842886209488, -0.007501963991671801, 0.001388063537888229, -0.0036999222356826067, -0.0445266030728817, -0.017232190817594528, 0.03109097108244896, -0.02334127202630043, -0.008357018232345581, 0.0015956369461491704, 0.007260221056640148, 0.04401349276304245, -0.003942712210118771, -0.03464354947209358, 0.0060328166000545025, -0.005676630884408951, -0.05413086339831352, 0.021017063409090042, 0.03657423332333565, 0.018982617184519768, 0.06462237983942032, 0.0406641848385334, 0.021961914375424385, -0.00027337728533893824, -0.03856232017278671, 0.03739286959171295, -0.010015156120061874, 0.0157610010355711, 0.0012559134047478437, 0.031299855560064316, 0.02701565995812416, 0.0018204232910647988, 0.035769570618867874, 0.037556398659944534, -0.024776432663202286, -0.01880408264696598, -0.009106099605560303, -0.005181995686143637, 0.043759338557720184, 0.007419155910611153, 0.018220150843262672, 0.016237415373325348, 0.0058628045953810215, 0.015046646818518639, -0.008390231989324093, -0.0452561117708683, -0.0022801642771810293, 0.020019320771098137, 0.010881302878260612, -0.03352313116192818, 0.04113509878516197, -0.036435648798942566, -0.04400552064180374, -0.015643442049622536, -0.04442032054066658, 0.02332243323326111, 0.04777955636382103, -0.006216058041900396, -0.033157527446746826, -0.020742250606417656, 0.01140274852514267, -0.03121613711118698, -0.00007070143328746781, 0.048748791217803955, 0.0029603720176965, 0.06305313110351562, 0.02174907550215721, -0.025866754353046417, -0.005716584622859955, 0.0028444810304790735, 0.0138925826177001, -0.01785925403237343, 0.037025436758995056, -0.02407693862915039, 0.03355065733194351, 0.00005330226122168824, 0.032132942229509354, -0.02885952778160572, 0.008716636337339878, -0.03615893796086311, 0.0017385557293891907, 0.01544681191444397, 0.012282656505703926, -0.010829268954694271, 0.013050630688667297, 0.01120596844702959, 0.03373793140053749, 0.00940118357539177, -0.026618964970111847, -0.007499513681977987, 0.024630818516016006, -0.0220556128770113, 0.05161972716450691, 0.05518932640552521, -0.014748785644769669, -0.007714290637522936, 0.052768904715776443, -0.0010591407772153616, 0.009788352996110916, -0.05524693801999092, 0.013475065119564533, -0.024209903553128242, 0.013380743563175201, -0.005285509862005711, -0.04056939110159874, -0.0024032630026340485, -0.029572289437055588, -0.0053517757914960384, 0.00035397158353589475, -0.03127603977918625, 0.009882849641144276, 0.004368981346487999, -0.015804408118128777, -0.05438018590211868, 0.023057570680975914, -0.03242063894867897, -0.022763019427657127, 0.0004963649553246796, -0.0018317311769351363, -0.014542330987751484, 0.01935150846838951, -0.05869033560156822, -0.003430310869589448, 0.03239826112985611, 0.02655053324997425, 0.023566460236907005, 0.016832534223794937, -0.021685218438506126, -0.0521731823682785, -0.00036720861680805683, 0.03119644522666931, -0.024205273017287254, -0.011745109222829342, 0.008860536850988865, 0.01483133900910616, 0.035585250705480576, 0.008950955234467983, -0.02706937864422798, 0.02051272802054882, 0.04525388032197952, -0.007639110088348389, -0.011752071790397167, -0.014548263512551785, 0.046697136014699936, 0.01941869407892227, -0.04299166798591614, 0.007805163972079754, -0.008905557915568352, -0.016358492895960808, -0.0033206380903720856, -0.00830761343240738, 0.00540229631587863, 0.0729244127869606, 0.02993718720972538, 0.006798019167035818, 0.015953024849295616, -0.0271286740899086, 0.00516930315643549, -0.020264562219381332, 0.01308814063668251, 0.016090992838144302, 0.050577498972415924, 0.04109889268875122, -0.027885276824235916, -0.0029196646064519882, -0.005472193472087383, 0.029009006917476654, -0.04401629790663719, -0.010151397436857224, 0.040962398052215576, -0.04763215035200119, 0.023583875969052315, 0.039970513433218, -0.045410528779029846, -0.015501816757023335, 0.04106465354561806, -0.00024273316375911236, 0.013094202615320683, -0.01643729768693447, -0.0017908558947965503, -0.007611621171236038, -0.017168855294585228, 0.03352788835763931, 0.057420242577791214, 0.024540815502405167, 0.06596870720386505, 0.026407558470964432, 0.014161664061248302, 0.04458453506231308, -0.0012657634215429425, 0.010366395115852356, 0.00042474133078940213, 0.01785535179078579, -0.007375791203230619, 0.017227184027433395, 0.03404419869184494, -0.034485090523958206, -0.023443467915058136, -0.026004977524280548, -0.004115604795515537, -0.05856466665863991, 0.004436430986970663, 0.04696914181113243, -0.03269460052251816, -0.012339992448687553, -0.04026831313967705, 0.014462543651461601, 0.042810361832380295, 0.07546846568584442, 0.0028506426606327295, 0.022765623405575752, 0.018983684480190277, 0.016452455893158913, -0.008560849353671074, 0.012417702004313469, 0.011700012721121311, 0.001211476163007319, 0.017942532896995544, 0.050786178559064865, 0.006327021401375532, 0.007425696589052677, -0.06352679431438446, 0.023357030004262924, -0.037791650742292404, 0.012995351105928421, 0.027946598827838898, 0.02375117689371109, -0.008761443197727203, -0.04767070710659027, 0.04600653797388077, -0.04696362465620041, 0.04426408186554909, -0.0031123156659305096, -0.00143215071875602, 0.015702122822403908, -0.039823926985263824, -0.014044615440070629, 0.07143007218837738, 0.008988648653030396, -0.055058278143405914, 0.008707823231816292, -0.013498639687895775, 0.0054613095708191395, 0.02136491797864437, -0.027664443477988243, -0.024585682898759842, 0.01569434627890587, 0.02149982750415802, -0.052326757460832596, -0.007028885651379824, 0.021023551002144814, -0.019362932071089745, -0.01627982035279274, 0.012070415541529655, -0.055749040096998215, 0.018000461161136627, 0.027539966627955437, -0.0269037876278162, -0.021557355299592018, -0.006132038775831461, -0.03330754116177559, -0.01974070444703102, 0.03866558149456978, -0.01927955634891987, -0.016907457262277603, -0.013898089528083801, 0.005331524182111025, 0.028833534568548203, 0.06009965017437935, -0.008209217339754105, 0.01823785901069641, 0.01081116497516632, -0.015422570519149303, -0.059584956616163254, 0.022524788975715637, 0.05966290459036827, -0.00555835198611021, 0.01332523301243782, 0.0172662865370512, -0.01488149631768465, -0.02167544513940811, -0.013346023857593536, 0.039325419813394547, -0.002044383902102709, -0.03893345966935158, -0.04265642911195755, 0.023783817887306213, 0.0007498738705180585, -0.007912302389740944, 0.034837525337934494, -0.03906684368848801, 0.024454744532704353, -0.041911184787750244, 0.026783956214785576, -0.014145748689770699, -0.012494410388171673, -0.045120518654584885, -0.060923509299755096, -0.03629368171095848, 0.011433419771492481, -0.003903159638866782, 0.015626080334186554, -0.04796828329563141, 0.038993217051029205, -0.005976251792162657, -0.02287355624139309, -0.01534030120819807, 0.019773930311203003, 0.05164242535829544, 0.01864519715309143, 0.024012496694922447, -0.027035383507609367, 0.0031719959806650877, -0.02188700996339321, -0.007027744315564632, -0.002976522780954838, 0.012524736113846302, 0.01875251904129982, -0.014736221171915531, 0.008567651733756065, -0.0006542865303345025, -0.028114834800362587, -0.023377111181616783, 0.022736938670277596, 0.02776535227894783, -0.01188910286873579, 0.008422880433499813, -0.019661154597997665, 0.003965382929891348, -0.10375355929136276, 0.03879135847091675, 0.022780660539865494, -0.008985704742372036, -0.02777397446334362, 0.009138984605669975, -0.03043324500322342, -0.021506352350115776, 0.005715238396078348, -0.005870548076927662, 0.05225178226828575, 0.03518136590719223, 0.02802378684282303, 0.0026584831066429615, -0.02055772952735424, 0.033559706062078476, -0.009906128980219364, -0.04971020296216011, -0.044409774243831635, 0.05348984897136688, 0.03509892523288727, -0.01993732713162899, -0.029380517080426216, 0.05565902590751648, -0.0035843094810843468, -0.0006228380952961743, -0.02794015407562256, 0.031188102439045906, -0.03130507841706276, -0.012844960205256939, 0.01927771046757698, -0.0021833847276866436, 0.07501240819692612, 0.03417995944619179, 0.004351201932877302, 0.021571099758148193, 0.00481344573199749 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
2.4 Transformers The Transformer architecture makes it possible to parallelize ML training extremely efficiently. Massive parallelization thus makes it feasible to train BERT on large amounts of data in a relatively short period of time. Transformers use an attention mechanism to observe relationships between words. A concept originally proposed in the popular [2017 Attention Is All You Need](https://proceedings.neurips.cc/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf) paper sparked the use of Transformers in NLP models all around the world. >Since their introduction in 2017, Transformers have rapidly become the state-of-the-art approach to tackle tasks in many domains such as natural language processing, speech recognition, and computer vision. In short, if you’re doing deep learning, then you need Transformers! Lewis Tunstall, Hugging Face ML Engineer & Author of Natural Language Processing with Transformers Timeline of popular Transformer model releases: Source
[ -0.0023513396736234426, -0.009848231449723244, 0.03410748392343521, -0.016022847965359688, -0.034312911331653595, 0.017614200711250305, 0.024922382086515427, 0.10655545443296432, -0.006665242835879326, 0.009554203599691391, -0.04219970107078552, 0.09493432939052582, -0.03622676432132721, 0.10608796775341034, -0.003427356481552124, -0.03728613257408142, -0.0007156429928727448, -0.01057015173137188, -0.014029908925294876, 0.07002944499254227, 0.015417778864502907, -0.09665056318044662, 0.10824330151081085, 0.001988696400076151, 0.00543854059651494, -0.029418595135211945, 0.006719815079122782, -0.057362399995326996, -0.006897983606904745, 0.049631793051958084, -0.13690833747386932, -0.0040776594541966915, 0.011543935164809227, -0.020955491811037064, -0.05519891157746315, -0.03882957994937897, -0.09214576333761215, 0.017793389037251472, 0.028634008020162582, -0.05885859206318855, -0.00840796809643507, 0.03430982306599617, -0.10869234800338745, 0.007322912570089102, -0.020907003432512283, 0.009118009358644485, -0.12846733629703522, 0.08332232385873795, -0.026463093236088753, -0.053403567522764206, -0.10578000545501709, 0.09637036919593811, -0.0204501673579216, 0.055185701698064804, 0.050073571503162384, 0.03306867927312851, -0.011149223893880844, -0.024410931393504143, -0.010810810141265392, -0.007415189873427153, 0.009379725903272629, -0.004842879716306925, 0.043714892119169235, 0.029198985546827316, 0.0036960644647479057, -0.04573770985007286, 0.013880543410778046, -0.03605450689792633, -0.07482533901929855, -0.038704968988895416, 0.0000025903973437380046, -0.037366095930337906, -0.04185584560036659, 0.019928637892007828, -0.059741634875535965, -0.0030147661454975605, 0.025004491209983826, 0.024708688259124756, 0.035661730915308, 0.04379797354340553, 0.010953393764793873, 0.02795470878481865, 0.0021277093328535557, 0.06090060621500015, 0.03904376178979874, 0.05395347625017166, 0.06377726048231125, -0.03738173469901085, -0.09503132104873657, 0.04662567377090454, 0.019566422328352928, -0.13972386717796326, -0.04132161661982536, -0.015064040198922157, 0.039733294397592545, 0.022452017292380333, -0.014144905842840672, 0.01169283501803875, -0.029930587857961655, -0.012653558515012264, 0.012889686971902847, -0.04621727764606476, 0.035990096628665924, -0.021174345165491104, -0.03664976358413696, 0.00988371018320322, 0.019314363598823547, -0.10892776399850845, -0.03661516308784485, 0.011529297567903996, -0.002912993310019374, -0.061331648379564285, -0.0228850319981575, 0.04364927485585213, -0.06113560497760773, 0.017780857160687447, 0.038713179528713226, 0.01195844542235136, 0.01521254051476717, -0.0023342850618064404, 0.0022438184823840857, 0.04903976619243622, 0.052771057933568954, -0.008506973274052143, -0.006439520511776209, 0.028009649366140366, -0.003037005662918091, -0.04604561626911163, 0.013597979210317135, -0.046603232622146606, 0.059048764407634735, -0.05651790648698807, 0.03758951649069786, 0.03709539771080017, 0.01905134506523609, -0.020969951525330544, 0.013641702011227608, -0.06760045886039734, -0.014227425679564476, 0.007256514858454466, -0.0028950704727321863, 0.05376182124018669, 0.030462738126516342, -0.047302521765232086, 0.04107029363512993, -0.010638684034347534, -0.126693457365036, 0.057072851806879044, 0.006559893488883972, -0.02114374004304409, -0.09387816488742828, 0.06315165758132935, -0.04796615615487099, -0.0622183158993721, 0.06485655158758163, 0.0646529421210289, 0.027355985715985298, -0.02398211508989334, -0.041694603860378265, -0.04093753173947334, -0.04718105122447014, -0.012703143991529942, -0.015311865136027336, 0.03927777335047722, 0.007565777283161879, -0.08113075792789459, 0.01662389375269413, 0.00766512006521225, 0.023852046579122543, 0.05720057338476181, -0.0015780371613800526, 0.036858540028333664, -0.0011436260538175702, -0.004398141987621784, -0.02378787100315094, 0.04043489694595337, 0.01130601391196251, 0.06396987289190292, 0.005237162578850985, -0.03349205106496811, -0.03233081474900246, 0.03971334919333458, 0.01484379917383194, 0.04162866249680519, 0.07294955849647522, -0.0350351557135582, 0.0385059118270874, -0.034833330661058426, -0.06468077003955841, 0.031604692339897156, 0.0018792417831718922, -0.027049031108617783, 0.060571108013391495, -0.01104474626481533, 0.041079744696617126, -0.001667961128987372, -0.08026126027107239, 0.09853935986757278, 0.021712446585297585, 0.032682210206985474, 0.06934431195259094, -0.06837278604507446, -0.00453561544418335, -0.021921467036008835, 0.009030475281178951, -0.008534498512744904, 0.011350882239639759, -0.032494500279426575, 0.06345322728157043, -0.03602304309606552, -0.006918073631823063, -0.1186756044626236, -0.010900074616074562, -0.03494644910097122, -0.011752346530556679, -0.09326228499412537, 0.0017055459320545197, 0.044467587023973465, 0.0455668643116951, -0.032757773995399475, 0.14790284633636475, -0.08653464168310165, -0.0323791541159153, 0.00833195075392723, 0.01941177435219288, 0.031266774982213974, 0.0894617810845375, 0.039107490330934525, 0.0805487185716629, -0.029970066621899605, -0.02081315405666828, -0.05306785926222801, -0.02694753371179104, -0.019338523969054222, -0.028143558651208878, -0.03415852040052414, -0.00839137937873602, 0.06410952657461166, -0.0016951450379565358, -0.014405307359993458, -0.0628850907087326, -0.001414117170497775, 0.04656069725751877, 0.05048843100667, 0.009179451502859592, 0.0035505874548107386, 0.035256464034318924, 0.013683469966053963, 0.013466290198266506, 0.004650474525988102, -0.09966598451137543, 0.03070930950343609, -0.032073620706796646, -0.07728390395641327, 0.023546794429421425, 0.03244591876864433, 0.004306527320295572, -0.015468585304915905, 0.011042618192732334, 0.030078083276748657, -0.024810167029500008, -0.009356620721518993, -0.05025286227464676, -0.06473476439714432, -0.033814579248428345, -0.06350638717412949, -0.026143737137317657, 0.022701991721987724, 0.03684287890791893, 0.03453390672802925, -0.004444369114935398, -0.048057377338409424, 0.03664294257760048, -0.014751387760043144, 0.01015452854335308, -0.005397850181907415, 0.02718927338719368, 0.015184106305241585, -0.0011349396081641316, -0.04997069016098976, -0.020280757918953896, -0.021490179002285004, 0.03855272755026817, 0.0248363446444273, 0.009878210723400116, -0.004494250752031803, 0.020000288262963295, -0.03244602680206299, -0.009614887647330761, -0.017905693501234055, 0.03321429714560509, 0.018667463213205338, -0.033192768692970276, -0.03536468371748924, -0.007037465926259756, 0.02451782114803791, -0.023589525371789932, -0.022778289392590523, 0.004381182137876749, 0.013816031627357006, 0.00709077762439847, 0.020938441157341003, 0.02537473663687706, -0.025544455274939537, -0.01932268775999546, 0.009935583919286728, 0.03799303248524666, 0.023764461278915405, -0.08609692007303238, -0.048572927713394165, -0.027727453038096428, -0.018714098259806633, 0.02832823619246483, -0.052453406155109406, 0.03499194234609604, 0.022196633741259575, -0.009906562976539135, -0.00019229469762649387, 0.017899075523018837, -0.0062781572341918945, -0.021250542253255844, -0.0031727293971925974, -0.05049367621541023, -0.0160403773188591, -0.010192963294684887, -0.03104441799223423, 0.03936318680644035, 0.015173051506280899, -0.009828820824623108, 0.017211465165019035, 0.008541356772184372, -0.001047179102897644, -0.01025222335010767, -0.00132785236928612, 0.02697261981666088, 0.02484881691634655, 0.029106225818395615, 0.007560598663985729, -0.021148690953850746, 0.0008168529602698982, -0.02249956503510475, 0.04005296900868416, -0.0018026491161435843, -0.010467146523296833, 0.0250842347741127, 0.041076455265283585, 0.059911977499723434, 0.018609100952744484, 0.029784707352519035, -0.009886432439088821, 0.002187951933592558, -0.030819933861494064, 0.060739725828170776, -0.021914049983024597, -0.02371019311249256, -0.009663674049079418, 0.011737991124391556, -0.011268120259046555, -0.02398260496556759, -0.024667315185070038, -0.03287370130419731, -0.010995861142873764, 0.03594284504652023, -0.008737055584788322, 0.00792928971350193, -0.007536817342042923, 0.009159451350569725, 0.005862231366336346, -0.024633899331092834, 0.03463081270456314, -0.024421339854598045, -0.01340694259852171, -0.026599613949656487, 0.04429464787244797, 0.03399210795760155, 0.014528068713843822, 0.004494223278015852, 0.01926693320274353, -0.012849862687289715, 0.030366500839591026, 0.007663861382752657, -0.002746560610830784, -0.041883595287799835, 0.03393983095884323, 0.013665026985108852, -0.003039792412891984, 0.058162935078144073, 0.020323840901255608, -0.056639038026332855, -0.03737063705921173, -0.049582190811634064, 0.010913286358118057, 0.028423765674233437, 0.021770304068922997, 0.04398350790143013, -0.014441458508372307, 0.024634527042508125, 0.028579257428646088, 0.004869421944022179, -0.01737748645246029, 0.01002238504588604, -0.041543424129486084, 0.001960929250344634, 0.004948164336383343, 0.001710674143396318, 0.012088782154023647, -0.008099664933979511, -0.030490294098854065, 0.02773919329047203, -0.04723973199725151, -0.013777604326605797, -0.01622013747692108, -0.01515189092606306, 0.026902485638856888, -0.021840861067175865, -0.016461363062262535, 0.04717877507209778, 0.004450199659913778, 0.014571364969015121, 0.00425864988937974, -0.04432561248540878, 0.023015683516860008, 0.039017658680677414, 0.013416319154202938, -0.015286200679838657, 0.015344209969043732, -0.05160178989171982, 0.03092866949737072, -0.0251429695636034, 0.0404130257666111, -0.01422033179551363, -0.00009116002183873206, 0.020566944032907486, 0.013670163229107857, 0.037270478904247284, 0.02168940007686615, -0.015283705666661263, -0.008265672251582146, -0.024808041751384735, -0.014967579394578934, 0.02949642576277256, 0.03862224146723747, 0.001965205417945981, 0.03120759315788746, -0.0016412849072366953, 0.021651769056916237, -0.03225234895944595, -0.0050393398851156235, -0.02017584815621376, 0.02569078654050827, 0.03936758264899254, -0.027794791385531425, -0.008013833314180374, -0.0027699582278728485, -0.04342027008533478, -0.00825774297118187, -0.0492585264146328, 0.016085023060441017, 0.03795737400650978, -0.01407379750162363, -0.01982743665575981, 0.04342685267329216, 0.05446378514170647, -0.004118665121495724, 0.003388463519513607, 0.045440979301929474, 0.00913905818015337, 0.037894610315561295, -0.006681432481855154, 0.02888224832713604, -0.059295397251844406, -0.011347814463078976, 0.03941924124956131, 0.0017774207517504692, -0.020318714901804924, -0.05338708311319351, -0.005147208459675312, 0.0009940162999555469, 0.0162137933075428, -0.020400341600179672, -0.006692961789667606, -0.002752846572548151, -0.013923161663115025, 0.04180596023797989, 0.03178472816944122, 0.03486800938844681, -0.003526205662637949, -0.0013109036954119802, -0.014408108778297901, -0.008323312737047672, -0.024195482954382896, 0.0186315905302763, 0.02045687660574913, 0.042378172278404236, 0.044234197586774826, 0.0932895690202713, -0.031942520290613174, 0.014425678178668022, 0.02243119478225708, -0.015835998579859734, -0.002073076320812106, -0.025407802313566208, -0.005507566500455141, -0.02731512114405632, 0.00012911579688079655, 0.008678553625941277, -0.017072664573788643, 0.04799892008304596, -0.014072451740503311, 0.038177359849214554, -0.024982038885354996, -0.0037384070456027985, 0.04398300126194954, 0.006094480399042368, -0.021595273166894913, -0.01926266960799694, 0.02724398486316204, 0.001336599001660943, 0.008339514024555683, -0.004874129313975573, -0.030738074332475662, 0.015919744968414307, -0.0006480845622718334, -0.037474483251571655, -0.028890937566757202, 0.04414047673344612, 0.019083771854639053, 0.04970400407910347, -0.047143831849098206, -0.01966315507888794, -0.01787102408707142, -0.0022461714688688517, 0.0013615149073302746, -0.07573157548904419, 0.009626634418964386, 0.018385283648967743, 0.005850103218108416, -0.0029373476281762123, 0.038190655410289764, 0.0027316028717905283, -0.020737700164318085, 0.04863831028342247, 0.008745383471250534, -0.021488137543201447, -0.03237207233905792, 0.06661463528871536, 0.030890610069036484, -0.00907379575073719, 0.0008472725166939199, -0.014078977517783642, -0.05389958992600441, 0.05479079857468605, -0.030045771971344948, 0.004631474148482084, 0.0528193898499012, 0.009354048408567905, -0.01623961515724659, -0.019115343689918518, 0.02927013300359249, 0.002207576995715499, -0.005049808416515589, 0.006136894691735506, -0.011695632711052895, 0.0260243508964777, -0.004134409129619598, 0.026051990687847137, 0.04819781333208084, 0.011188012547791004, 0.02107800915837288, -0.025754958391189575, 0.0052754636853933334, 0.01715204305946827, -0.00910668633878231, 0.007492171600461006, 0.010317401960492134, -0.022225303575396538, 0.013246290385723114, 0.014492539688944817, -0.011548646725714207, -0.0012926519848406315, -0.012929767370223999, -0.000684090075083077, 0.0050362939946353436, -0.014915293082594872, 0.0067268190905451775, 0.06052612513303757, 0.015878714621067047, 0.06952732801437378, 0.022533301264047623, 0.021056732162833214, 0.0737551599740982, -0.04173263534903526, 0.005794122815132141, 0.018677640706300735, 0.032858483493328094, -0.026380132883787155, 0.029127497225999832, 0.02748490683734417, -0.042287830263376236, -0.05627578869462013, 0.014381139539182186, 0.0005602984456345439, -0.0473596565425396, -0.03831769898533821, 0.003628508886322379, 0.0075332652777433395, 0.005398693960160017, -0.028405534103512764, 0.039581336081027985, 0.04818037152290344, 0.043821439146995544, -0.019224373623728752, 0.0268343947827816, 0.015171506442129612, 0.03838415816426277, 0.02895662561058998, 0.034045394510030746, 0.023976927623152733, 0.00079244194785133, 0.024824662134051323, 0.036918383091688156, 0.06467686593532562, -0.01066079456359148, -0.05274742469191551, 0.027384232729673386, -0.04000674560666084, -0.03387106582522392, 0.020682238042354584, -0.04203610122203827, -0.01574348285794258, 0.014318656176328659, 0.005992033518850803, -0.028424089774489403, 0.07264060527086258, -0.004192660562694073, -0.022374726831912994, -0.03572402149438858, -0.0411670096218586, 0.001892539788968861, 0.04639581963419914, 0.025056613609194756, -0.029979651793837547, -0.00007951103907544166, -0.03984401375055313, 0.024571983143687248, 0.0366949662566185, -0.02254290133714676, -0.026022344827651978, -0.024404803290963173, -0.005415753461420536, 0.010565746575593948, 0.05876259133219719, -0.017238477244973183, 0.02261919528245926, 0.05433339625597, 0.023389257490634918, -0.018525047227740288, 0.0453948900103569, -0.002024108776822686, -0.014430834911763668, -0.043760284781455994, 0.03484271466732025, 0.0032978462986648083, -0.02565382607281208, 0.01504594087600708, -0.018375331535935402, 0.03474141284823418, -0.0166091900318861, 0.013711820356547832, 0.048383697867393494, 0.0727919265627861, -0.02224818989634514, -0.018943727016448975, 0.00786087941378355, -0.00594693748280406, -0.031768664717674255, 0.03856877610087395, 0.03253193572163582, -0.026800507679581642, 0.01913357526063919, -0.03294427692890167, -0.012121557258069515, -0.01944669708609581, 0.01007803250104189, 0.05962187796831131, 0.004491197876632214, 0.005218196660280228, -0.021882735192775726, 0.037843264639377594, 0.032236482948064804, -0.0004641033592633903, 0.02507379651069641, -0.006529004313051701, 0.017118901014328003, -0.04142390564084053, 0.019948894158005714, -0.016078434884548187, -0.004908286966383457, -0.013179044239223003, -0.010036048479378223, -0.0001468652335461229, 0.03082931973040104, -0.012362354435026646, 0.04713132232427597, -0.006081690080463886, 0.005995333660393953, -0.03562479093670845, 0.0008920833934098482, 0.011664800345897675, 0.022173581644892693, 0.07746750116348267, 0.026768937706947327, 0.02023480460047722, -0.02081686072051525, -0.04233575239777565, -0.03673485293984413, 0.002114692935720086, 0.02270546555519104, 0.06361819803714752, -0.035139985382556915, 0.008851626887917519, -0.02650945819914341, -0.05782475695014, 0.009894355200231075, -0.05237334594130516, 0.011190145276486874, 0.009479674510657787, -0.0008208937360905111, -0.0007867030217312276, 0.004444282967597246, 0.0263461172580719, -0.061567023396492004, 0.040783368051052094, -0.038052208721637726, -0.002784962300211191, -0.022513272240757942, -0.025252168998122215, -0.03022407740354538, -0.012061744928359985, -0.002951555186882615, -0.016174765303730965, 0.041584309190511703, 0.0447583943605423, -0.0011537439422681928, -0.018084581941366196, 0.012067856267094612, 0.023277822881937027, -0.008736677467823029, -0.05558295547962189, -0.04874053969979286, 0.00438418984413147, 0.004540658555924892, 0.009650246240198612, -0.03124680370092392, 0.0447111539542675, 0.014108802191913128, 0.020305199548602104, -0.02041386254131794, -0.015012072399258614, -0.0026066654827445745, -0.0010604939889162779, 0.001248507876880467, 0.0060571832582354546, 0.04008590430021286, 0.03405696153640747, 0.013819750398397446, -0.009210762567818165, -0.049051422625780106 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
7.3 Be aware of model bias Let's see what jobs BERT suggests for a "man": ```python unmasker("The man worked as a [MASK].") ``` When you run the above code you should see an output that looks something like: ```python [{'score': 0.09747546911239624, 'sequence': 'the man worked as a carpenter.', 'token': 10533, 'token_str': 'carpenter'}, {'score': 0.052383411675691605, 'sequence': 'the man worked as a waiter.', 'token': 15610, 'token_str': 'waiter'}, {'score': 0.04962698742747307, 'sequence': 'the man worked as a barber.', 'token': 13362, 'token_str': 'barber'}, {'score': 0.037886083126068115, 'sequence': 'the man worked as a mechanic.', 'token': 15893, 'token_str': 'mechanic'}, {'score': 0.037680838257074356, 'sequence': 'the man worked as a salesman.', 'token': 18968, 'token_str': 'salesman'}] ``` BERT predicted the man's job to be a Carpenter, Waiter, Barber, Mechanic, or Salesman Now let's see what jobs BERT suggesst for "woman" ```python unmasker("The woman worked as a [MASK].") ``` You should see an output that looks something like: ```python [{'score': 0.21981535851955414, 'sequence': 'the woman worked as a nurse.', 'token': 6821, 'token_str': 'nurse'}, {'score': 0.1597413569688797, 'sequence': 'the woman worked as a waitress.', 'token': 13877, 'token_str': 'waitress'}, {'score': 0.11547300964593887, 'sequence': 'the woman worked as a maid.', 'token': 10850, 'token_str': 'maid'}, {'score': 0.03796879202127457, 'sequence': 'the woman worked as a prostitute.', 'token': 19215, 'token_str': 'prostitute'}, {'score': 0.030423851683735847, 'sequence': 'the woman worked as a cook.', 'token': 5660, 'token_str': 'cook'}] ``` BERT predicted the woman's job to be a Nurse, Waitress, Maid, Prostitute, or Cook displaying a clear gender bias in professional roles.
[ -0.0736994594335556, 0.006180330645292997, 0.03932134807109833, -0.0144455935806036, 0.05038299039006233, 0.05062919110059738, 0.044862087815999985, 0.042738668620586395, -0.0588577501475811, -0.035893362015485764, -0.10026170313358307, 0.06339623779058456, -0.04721394553780556, 0.0898490771651268, -0.04516451433300972, -0.003406913485378027, 0.0025988223496824503, -0.025952596217393875, 0.01764332503080368, 0.0007479581399820745, -0.007932474836707115, -0.03827354684472084, 0.11064177751541138, -0.036343734711408615, 0.08562793582677841, -0.06270858645439148, -0.0024349249433726072, -0.019068952649831772, -0.12355751544237137, 0.07398585230112076, -0.10639217495918274, 0.024084215983748436, 0.03289748355746269, 0.0049570598639547825, -0.07961216568946838, -0.007248817477375269, -0.07036017626523972, 0.046055302023887634, 0.028135476633906364, -0.0344514325261116, -0.027686679735779762, -0.05161755532026291, -0.033523574471473694, 0.047487251460552216, 0.00320417364127934, -0.046967681497335434, -0.15684324502944946, 0.06452135741710663, -0.004367671441286802, -0.023645734414458275, -0.052177928388118744, 0.04742002859711647, -0.0022601247765123844, 0.012411714531481266, 0.039499156177043915, -0.06379060447216034, 0.010943005792796612, -0.03840363025665283, 0.01775558479130268, -0.01546409446746111, 0.037831295281648636, -0.023085303604602814, -0.0018167910166084766, -0.021509448066353798, 0.05633026361465454, 0.029814977198839188, -0.00610757851973176, 0.009735594503581524, -0.06682128459215164, 0.02754431590437889, -0.02601073496043682, -0.05154234170913696, -0.04564834013581276, -0.012839674949645996, 0.05267738923430443, -0.11130838841199875, -0.013256787322461605, -0.008286265656352043, -0.02950597181916237, -0.014205178245902061, -0.006921364460140467, 0.026528339833021164, 0.009606439620256424, 0.09838350862264633, 0.03832520544528961, -0.009973532520234585, 0.05247509852051735, -0.041565388441085815, -0.05750056728720665, 0.09022034704685211, -0.043615538626909256, -0.11246153712272644, -0.04843100532889366, -0.014102140441536903, 0.0029605766758322716, -0.018124202266335487, 0.017158735543489456, 0.0092155234888196, -0.015093098394572735, 0.015167482197284698, -0.013285288587212563, -0.008873253129422665, 0.045053400099277496, 0.012200595811009407, -0.051630955189466476, 0.040858764201402664, 0.007374250795692205, -0.055013179779052734, -0.065541572868824, -0.017181357368826866, -0.009796379134058952, -0.011734499596059322, -0.00385274994187057, 0.062204889953136444, -0.014793382957577705, 0.013899627141654491, 0.010824107564985752, 0.009575428441166878, 0.053832150995731354, 0.010707416571676731, -0.02946334145963192, 0.08042388409376144, 0.05258738622069359, -0.00037167122354730964, -0.0018908759811893106, -0.002141882898285985, 0.010687838308513165, 0.017096197232604027, 0.033040568232536316, -0.015803538262844086, 0.07949540764093399, 0.06953275948762894, 0.0351555310189724, 0.030829956755042076, 0.01882433332502842, -0.02465522475540638, -0.04151260852813721, -0.058898162096738815, 0.02916058525443077, -0.046138692647218704, -0.06833494454622269, 0.06511620432138443, -0.013186088763177395, 0.07352431118488312, 0.02484145388007164, 0.0027411836199462414, -0.0638405904173851, 0.07849688827991486, 0.008365478366613388, 0.06031111627817154, -0.059957921504974365, 0.07569048553705215, -0.013099201954901218, -0.07462719082832336, 0.10363531857728958, 0.04592442512512207, -0.009801076725125313, -0.0258302241563797, -0.017505018040537834, -0.031891752034425735, -0.00040573891601525247, 0.029789689928293228, -0.06373810768127441, -0.005125742405653, 0.019279509782791138, -0.029377926141023636, -0.003998571541160345, 0.002292606746777892, 0.0055669331923127174, 0.0742991641163826, -0.001762570347636938, 0.012545987032353878, 0.0879737138748169, 0.0320097990334034, -0.039007194340229034, 0.07507286965847015, -0.021363355219364166, -0.00045290045090951025, 0.011408836580812931, -0.027753276750445366, -0.023959720507264137, 0.08009421825408936, -0.020741406828165054, 0.013316781260073185, 0.018868785351514816, -0.06741179525852203, 0.0018500967416912317, -0.04706907644867897, -0.006718962918967009, 0.04299383610486984, -0.05618305131793022, -0.04029158130288124, 0.07484737783670425, -0.01789969578385353, 0.004351227544248104, -0.06963500380516052, -0.06378726661205292, 0.045069579035043716, 0.05982860177755356, -0.0337664894759655, 0.0186604131013155, -0.04886460304260254, -0.0032246781047433615, -0.02565508335828781, 0.002385502215474844, 0.030273480340838432, 0.03305872902274132, -0.08098394423723221, 0.07041963934898376, -0.0037667315918952227, 0.037360597401857376, -0.03362095355987549, 0.0035846149548888206, -0.09961910545825958, -0.056045833975076675, -0.03645457327365875, 0.03279322758316994, 0.008776716887950897, 0.018774328753352165, 0.0003637733170762658, 0.14490702748298645, 0.006872421596199274, 0.03581012412905693, -0.07764283567667007, -0.00413166731595993, 0.02645028941333294, 0.061169929802417755, 0.03749361261725426, 0.08109959959983826, -0.059347379952669144, -0.05340016260743141, -0.005177978426218033, 0.03260452672839165, 0.04111740365624428, -0.07069024443626404, 0.010710621252655983, 0.008290762081742287, 0.039054132997989655, -0.01748240366578102, -0.042744025588035583, 0.00661144545301795, 0.05404860898852348, -0.002576486673206091, 0.09338874369859695, -0.05046231672167778, 0.018996383994817734, 0.049637485295534134, -0.008466902188956738, -0.0380011722445488, 0.02781796269118786, -0.06576387584209442, 0.05328846722841263, 0.015289862640202045, 0.0020600107964128256, 0.026529652997851372, 0.05332145467400551, -0.004276573657989502, 0.007458794396370649, -0.03645925596356392, 0.011720978654921055, -0.035302743315696716, -0.018253836780786514, -0.026481015607714653, -0.04074873402714729, -0.025493299588561058, 0.0027897353284060955, -0.012014931999146938, 0.02799190580844879, -0.01286569144576788, 0.04728052392601967, -0.014900465495884418, -0.04873063787817955, 0.023787707090377808, 0.02753477171063423, 0.029552066698670387, 0.029639067128300667, 0.038079988211393356, -0.024843018501996994, -0.00932315830141306, -0.01376419048756361, -0.01338208094239235, -0.03487173095345497, 0.02927708812057972, 0.010619012638926506, -0.004028366878628731, -0.027107497677206993, 0.0002986990148201585, -0.049048878252506256, 0.00806623324751854, -0.004683807957917452, 0.013316337019205093, 0.0623122975230217, 0.00294501893222332, -0.013490481302142143, 0.0019656545482575893, 0.009446285665035248, 0.0026862341910600662, 0.009186459705233574, -0.0014146520989015698, -0.004928960930556059, -0.02693198435008526, 0.07475169003009796, 0.003836393356323242, -0.009586161933839321, -0.027493923902511597, 0.05382319912314415, 0.02225685864686966, 0.009132147766649723, -0.10010440647602081, 0.000742367294151336, 0.03177545592188835, -0.004241700284183025, 0.0035901740193367004, -0.014979241415858269, 0.09884193539619446, -0.017584696412086487, -0.030358832329511642, 0.01563524827361107, 0.01247603353112936, 0.0018213383154943585, 0.004624720197170973, 0.03175671771168709, 0.005803910084068775, -0.006820996757596731, -0.033614154905080795, -0.0038787778466939926, 0.02981659770011902, 0.00009458522981731221, -0.02224769815802574, 0.014035153202712536, -0.010782058350741863, -0.05017343908548355, -0.025146013125777245, 0.003751515643671155, 0.03702567517757416, 0.03200070932507515, 0.022702807560563087, -0.030550867319107056, -0.033923398703336716, 0.021242620423436165, 0.02044212631881237, -0.019092610105872154, -0.018715862184762955, -0.008436962962150574, 0.00716039864346385, 0.03582438454031944, 0.029838193207979202, 0.03958847373723984, -0.022825468331575394, -0.0002624809567350894, -0.007031093817204237, 0.025604834780097008, 0.0041435882449150085, -0.01849139854311943, -0.024658240377902985, -0.03450725972652435, 0.01725403219461441, -0.025355210527777672, -0.01902800053358078, -0.03373674675822258, -0.01099326927214861, 0.036419495940208435, 0.016922004520893097, -0.004748016595840454, 0.006987621076405048, 0.0257909893989563, 0.03287806361913681, -0.01957150176167488, 0.012792992405593395, 0.04248764365911484, -0.017815181985497475, 0.006087459623813629, -0.03556511923670769, 0.032817985862493515, 0.049802977591753006, 0.04795944318175316, -0.009977984242141247, 0.004918323364108801, 0.0005172155215404928, 0.027099769562482834, 0.0295481625944376, 0.007166584953665733, -0.016605297103524208, -0.019161760807037354, -0.011556793004274368, -0.008766005747020245, 0.03911016508936882, -0.014813770540058613, -0.021151196211576462, -0.02613077126443386, -0.05592266842722893, -0.033543456345796585, 0.0038337085861712694, -0.007179266307502985, 0.0067279343493282795, -0.024313226342201233, -0.015063987113535404, 0.003978668712079525, -0.011746122501790524, -0.014218208380043507, 0.001955899642780423, 0.023192696273326874, -0.04606401175260544, 0.0346292145550251, -0.0064210738055408, -0.022888315841555595, -0.029614290222525597, 0.005916079506278038, 0.030924789607524872, -0.021379511803388596, -0.023395083844661713, 0.0034551697317510843, 0.01949312910437584, 0.06403419375419617, -0.017361434176564217, -0.0201040580868721, 0.0058838683180511, -0.010682147927582264, 0.017042411491274834, 0.0022909941617399454, 0.02694529853761196, -0.028120923787355423, 0.006789766252040863, 0.01754290796816349, -0.001976524479687214, -0.020373914390802383, -0.011843227781355381, 0.033881302922964096, -0.022180629894137383, 0.014214971102774143, 0.010387110523879528, -0.042821433395147324, -0.007072347216308117, -0.02123268134891987, 0.028841502964496613, 0.046046480536460876, 0.0138151366263628, -0.013354684226214886, -0.027651537209749222, 0.011947228573262691, 0.036283109337091446, -0.028939148411154747, 0.0006556387525051832, 0.030917154625058174, 0.0113274697214365, 0.03102944791316986, -0.018675779923796654, -0.056939151138067245, -0.015882445499300957, -0.002096571959555149, 0.000054526626627193764, -0.04662889614701271, -0.020546872168779373, -0.01198117621243, -0.016090935096144676, -0.056385986506938934, -0.008576640859246254, 0.029938284307718277, 0.02965044230222702, 0.021898990496993065, -0.01852971687912941, 0.003986310679465532, 0.019700894132256508, -0.030921651050448418, -0.020369917154312134, 0.07563020288944244, 0.0018687511328607798, 0.05532658472657204, 0.00931142084300518, -0.045407358556985855, -0.04984327778220177, 0.028161143884062767, 0.0009423486771993339, -0.0005421337555162609, 0.007260112091898918, -0.057425227016210556, 0.01989256776869297, 0.03200962394475937, -0.0361626073718071, -0.03921583667397499, -0.008384954184293747, -0.048859838396310806, 0.0527777224779129, 0.020097989588975906, -0.015597349032759666, 0.00008299978799186647, 0.0032707008067518473, 0.02171071618795395, 0.003984066192060709, 0.03301755338907242, -0.017249787226319313, 0.019312452524900436, -0.006110243033617735, 0.0388171449303627, 0.03691339120268822, 0.05400299280881882, 0.012418855912983418, 0.010229152627289295, 0.04165041446685791, -0.0359649620950222, 0.00011478548549348488, -0.03932010382413864, 0.013239671476185322, 0.0002950473572127521, -0.005016517359763384, 0.018443705514073372, -0.032864220440387726, 0.009644906036555767, 0.04693930596113205, 0.04977784678339958, 0.03219369053840637, -0.02108321711421013, 0.04896126687526703, -0.0399671234190464, -0.01344817690551281, -0.041919462382793427, -0.004478259943425655, -0.051753804087638855, 0.025117499753832817, -0.034094151109457016, -0.017682770267128944, 0.012183338403701782, 0.016688819974660873, -0.04221102595329285, -0.0007146699354052544, 0.018611092120409012, 0.02227998524904251, 0.07800257951021194, 0.024452585726976395, -0.0009854774689301848, -0.02516481652855873, 0.01153796911239624, 0.04336875304579735, -0.081088587641716, -0.0019461095798760653, 0.007277997210621834, 0.03511200472712517, 0.023577159270644188, 0.09147658944129944, 0.02258352003991604, -0.0004020005580969155, 0.06876543164253235, 0.004360702820122242, -0.022945504635572433, 0.0008414786425419152, 0.04472332447767258, 0.029506316408514977, -0.057609111070632935, 0.005166430026292801, -0.0022742291912436485, -0.03541291132569313, 0.046801816672086716, -0.01462938915938139, -0.01407745573669672, 0.05655538663268089, 0.005415151361376047, -0.025921618565917015, 0.01914175972342491, 0.03062744252383709, 0.03776472434401512, 0.03267420828342438, 0.050226643681526184, 0.030887428671121597, 0.05010514333844185, 0.02081529051065445, -0.002995782997459173, 0.021556133404374123, 0.029340608045458794, 0.02067803218960762, -0.036699485033750534, 0.011298083700239658, 0.05526391416788101, -0.029739711433649063, 0.04669692739844322, 0.010545876808464527, -0.01902121677994728, 0.019808543846011162, -0.0236931424587965, 0.01561976782977581, 0.0049381316639482975, 0.00911322608590126, -0.044041991233825684, 0.029696637764573097, 0.014775118790566921, 0.022685742005705833, 0.06202656775712967, -0.003335716435685754, -0.002137732459232211, 0.005462585482746363, 0.030980773270130157, 0.0380866676568985, 0.009324967861175537, -0.015979362651705742, -0.002876746468245983, 0.0589834488928318, 0.0035176908131688833, 0.003061203984543681, -0.010591031052172184, -0.013887363485991955, 0.0032685864716768265, -0.03228995203971863, 0.003765626111999154, -0.007737776264548302, 0.019148409366607666, 0.010502568446099758, -0.0547625906765461, 0.014082669280469418, -0.01581617072224617, 0.011555980890989304, 0.028060847893357277, 0.039530396461486816, -0.02140325866639614, 0.021724779158830643, -0.0022637122310698032, 0.007579671684652567, 0.014288489706814289, 0.03271426260471344, 0.01052170991897583, -0.041796278208494186, 0.07867694646120071, 0.02374940924346447, 0.04899008199572563, 0.032159045338630676, -0.03811151906847954, 0.0026832513976842165, -0.06581474095582962, 0.0017578424885869026, 0.03454015403985977, -0.0041067879647016525, 0.014192218892276287, 0.0017544651636853814, 0.01462304312735796, -0.0377684012055397, -0.02328268438577652, 0.022129131481051445, -0.015288211405277252, 0.006102897692471743, 0.009143277071416378, -0.00931826326996088, 0.051508497446775436, 0.018337231129407883, -0.0468214713037014, -0.00904254149645567, -0.02482021041214466, 0.02265550196170807, 0.03614772483706474, -0.01972784288227558, -0.025698844343423843, -0.0563943088054657, -0.04199547693133354, -0.040384162217378616, 0.03130379691720009, -0.0037964191287755966, -0.011620301753282547, 0.047390930354595184, 0.00815053004771471, -0.03729268163442612, 0.004785999655723572, 0.009184660390019417, 0.013819013722240925, -0.0073407841846346855, -0.0024072451051324606, -0.011030307970941067, -0.02336600422859192, 0.018982384353876114, -0.06967616081237793, 0.014645766466856003, -0.00537666492164135, 0.0035244955215603113, 0.02299920842051506, 0.04750976711511612, -0.015414167195558548, -0.0020075112115591764, -0.03410382941365242, -0.03252727910876274, -0.029223471879959106, 0.0015281356172636151, 0.0684376209974289, 0.003601920325309038, -0.002420842880383134, -0.0051788040436804295, 0.0028706470038741827, -0.02168521285057068, -0.0015655278693884611, 0.03555643931031227, -0.022176245227456093, -0.01509539969265461, -0.007076179143041372, 0.0019430587999522686, -0.008816973306238651, 0.025524728000164032, 0.02645217441022396, -0.046083640307188034, 0.02326703816652298, -0.00019885429355781525, 0.02376849763095379, -0.049836255609989166, -0.0005793011514469981, -0.02208027057349682, -0.005757556762546301, -0.04515929892659187, -0.009968566708266735, -0.04502212256193161, 0.009579330682754517, -0.06936923414468765, 0.047525182366371155, 0.020378941670060158, 0.005229278467595577, -0.0356474295258522, 0.017083153128623962, 0.06610898673534393, 0.01421476062387228, 0.011571305803954601, 0.01408140454441309, -0.04122770577669144, -0.04033740982413292, 0.0001174389326479286, -0.030107490718364716, 0.02291812188923359, 0.005101761315017939, -0.02104204148054123, -0.014822087250649929, 0.0058324565179646015, -0.004290938843041658, -0.056805841624736786, -0.030470997095108032, 0.03784753382205963, -0.02513512410223484, -0.025244833901524544, 0.004866939503699541, 0.01950182393193245, -0.021445708349347115, -0.0009514551493339241, 0.022046614438295364, -0.030143095180392265, -0.030715709552168846, 0.010424826294183731, -0.06835708767175674, -0.012354811653494835, -0.024080894887447357, -0.028626369312405586, 0.049281831830739975, 0.04243636503815651, 0.011895278468728065, -0.0007396533619612455, -0.009663472883403301, -0.03936015069484711, 0.025490576401352882, -0.021316686645150185, -0.042734526097774506, -0.00992734543979168, 0.026004064828157425, -0.024274758994579315, -0.019951507449150085, 0.02777872607111931, -0.004434475675225258, -0.0061228214763104916, -0.0015305590350180864, 0.012587565928697586, 0.02128777839243412, -0.022677691653370857, -0.012264029122889042, 0.0009314659982919693, 0.030158771201968193, 0.037107061594724655, 0.029837077483534813, 0.025707516819238663, 0.02334427461028099 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
5. Environmental impact of deep learning Large Machine Learning models require massive amounts of data which is expensive in both time and compute resources. These models also have an environmental impact: Source Machine Learning’s environmental impact is one of the many reasons we believe in democratizing the world of Machine Learning through open source! Sharing large pre-trained language models is essential in reducing the overall compute cost and carbon footprint of our community-driven efforts.
[ 0.03599702939391136, -0.04822537675499916, 0.0011580513091757894, 0.06612727046012878, 0.0279773510992527, 0.030644193291664124, -0.03518088907003403, 0.037220533937215805, -0.02400420419871807, -0.03553816303610802, -0.07815319299697876, 0.005778320133686066, -0.08223052322864532, 0.02924972027540207, 0.021451584994792938, -0.06852918118238449, 0.014341882430016994, -0.0317206047475338, -0.004892339464277029, 0.034985870122909546, 0.015517092309892178, -0.003773832693696022, 0.0638616755604744, 0.052567314356565475, -0.03000999428331852, -0.022597840055823326, 0.020313287153840065, -0.011301853694021702, -0.0289977565407753, -0.02735108882188797, -0.09035070985555649, 0.03686266392469406, -0.03846767172217369, 0.021820856258273125, -0.0038543655537068844, -0.007497203070670366, -0.098905548453331, 0.0892251506447792, 0.027011651545763016, -0.007838250137865543, 0.008666163310408592, 0.05053066089749336, -0.05750312656164169, 0.0233109500259161, -0.02287314087152481, -0.02079165354371071, -0.059779539704322815, 0.052182868123054504, 0.025882018730044365, 0.02275211177766323, -0.12158095836639404, 0.029955711215734482, -0.07602488994598389, 0.017876509577035904, -0.003609814215451479, 0.025186417624354362, 0.06075474992394447, 0.017150482162833214, 0.0029423541855067015, -0.020107055082917213, 0.06540858745574951, -0.07422690838575363, 0.009769587777554989, 0.028068188577890396, 0.035736486315727234, -0.007970096543431282, 0.010610298253595829, -0.07709238678216934, -0.1127040907740593, -0.030702130869030952, -0.018534932285547256, 0.016305789351463318, -0.042989082634449005, -0.01258439477533102, -0.09435776621103287, 0.014678891748189926, 0.036024440079927444, 0.014872554689645767, -0.01651734672486782, 0.01108802855014801, 0.05648915469646454, 0.07605499029159546, 0.05944885313510895, 0.010565686039626598, 0.03399287909269333, 0.010434583760797977, 0.007444700691848993, -0.004631648305803537, -0.058620892465114594, 0.07040989398956299, 0.07215515524148941, -0.06917795538902283, 0.032807230949401855, 0.023957418277859688, 0.08304125815629959, -0.0026532786432653666, 0.0301511213183403, -0.031374361366033554, -0.08148510009050369, -0.007569386623799801, -0.054785724729299545, -0.022909075021743774, -0.002523513277992606, -0.0026802928186953068, -0.10356854647397995, 0.038667984306812286, -0.022480854764580727, -0.0817793756723404, 0.01124997716397047, 0.043447382748126984, -0.006149556953459978, 0.0685916393995285, -0.086333267390728, -0.0003909737861249596, -0.019037166610360146, 0.04951758310198784, 0.01210484653711319, -0.08383288234472275, 0.0424952507019043, 0.0943763479590416, -0.0040527284145355225, 0.013921204023063183, 0.05415666848421097, 0.017712684348225594, -0.02030455693602562, 0.06505459547042847, 0.03085281513631344, 0.02600470371544361, 0.03134169802069664, -0.041887879371643066, 0.039425015449523926, 0.03457164019346237, 0.052419062703847885, -0.042501870542764664, 0.0348408967256546, -0.0938880667090416, -0.0028536447789520025, -0.02901385724544525, 0.035509541630744934, -0.0012824416626244783, -0.1058698296546936, 0.004134479444473982, 0.016020918264985085, -0.012416325509548187, 0.07754812389612198, 0.03241575136780739, -0.07889537513256073, 0.030069928616285324, 0.0258481465280056, 0.041398510336875916, -0.06892178952693939, 0.07177573442459106, -0.05111481621861458, -0.06155923381447792, -0.04207811877131462, 0.10899398475885391, -0.054617926478385925, -0.03335192799568176, -0.04050065577030182, 0.062151748687028885, -0.043120820075273514, -0.01702546514570713, 0.023150451481342316, 0.011928102001547813, 0.0702163353562355, -0.07307585328817368, -0.056340623646974564, 0.052479442209005356, -0.017462536692619324, 0.11249218881130219, -0.035586871206760406, -0.10820069909095764, 0.026252901181578636, -0.07793963700532913, 0.03846462815999985, 0.013330992311239243, -0.017681684345006943, 0.015629375353455544, 0.020227063447237015, 0.004177158232778311, -0.0377391017973423, 0.0014679210726171732, -0.030207624658942223, -0.012519234791398048, 0.06713636964559555, -0.0946100503206253, 0.013260381296277046, -0.08086369186639786, 0.01713242009282112, -0.0026605124585330486, -0.034929338842630386, -0.04847097769379616, 0.07709821313619614, -0.011509300209581852, 0.007312894333153963, -0.015753475949168205, -0.029086971655488014, 0.11422444134950638, 0.03877444192767143, 0.09261653572320938, -0.015084896236658096, -0.031490258872509, -0.008047305978834629, -0.02424462139606476, -0.020726950839161873, 0.009473752230405807, 0.026841076090931892, -0.05133812129497528, 0.03024466522037983, -0.00940428301692009, -0.024632057175040245, -0.08261406421661377, 0.004418352153152227, 0.012083997018635273, 0.005473192781209946, -0.011893055401742458, -0.04657399281859398, 0.05984685942530632, 0.009034806862473488, 0.007995747961103916, 0.12942203879356384, -0.0310388021171093, 0.04940922185778618, 0.019274955615401268, -0.03803630545735359, 0.00329958344809711, 0.05440245941281319, -0.02680310234427452, 0.1111886128783226, -0.049889422953128815, -0.0464341826736927, -0.045504093170166016, -0.020243575796484947, -0.03812620788812637, 0.007729116827249527, 0.0250596534460783, -0.017155826091766357, 0.02112562209367752, 0.011292089708149433, 0.020865490660071373, -0.020027536898851395, -0.023719752207398415, -0.011773867532610893, 0.04457844793796539, -0.009916111826896667, -0.10306783765554428, 0.07487723231315613, -0.043068286031484604, -0.043623704463243484, -0.0018663116497918963, -0.007548858877271414, -0.008879536762833595, -0.0039003118872642517, 0.015953201800584793, -0.0289775300770998, 0.009189166128635406, -0.007364654913544655, -0.04904976487159729, 0.002775614382699132, 0.04345124214887619, 0.03410707414150238, 0.010011169128119946, -0.02306888811290264, -0.03439861536026001, -0.014885279349982738, -0.012205841019749641, -0.015170414000749588, -0.029865171760320663, 0.0038372292183339596, 0.024703942239284515, 0.027666674926877022, 0.0016042388742789626, 0.0032306474167853594, 0.0061582354828715324, -0.012060091830790043, 0.022086726501584053, 0.03306053206324577, 0.027381446212530136, -0.02488507330417633, -0.01954481191933155, -0.03307577967643738, -0.010719897225499153, 0.0478053018450737, 0.04337103292346001, 0.004463947378098965, 0.02933703176677227, 0.02654357999563217, -0.002935173688456416, -0.00980481319129467, 0.02576112002134323, 0.006604719907045364, -0.020856987684965134, -0.0199134424328804, -0.010645420290529728, 0.012860056012868881, 0.007857594639062881, 0.012830785475671291, -0.04459099471569061, -0.012433511205017567, 0.019861683249473572, -0.010184191167354584, -0.0029943641275167465, 0.027171311900019646, -0.011746974661946297, -0.02382681332528591, 0.05340718477964401, 0.004589431453496218, 0.026189450174570084, -0.08376066386699677, 0.03703344985842705, 0.02437162958085537, 0.03435239940881729, -0.021713299676775932, 0.010821557603776455, 0.020397786051034927, 0.032212033867836, -0.009106003679335117, 0.009492163546383381, 0.018262594938278198, -0.005087087396532297, 0.00368973589502275, 0.07387924194335938, 0.025225695222616196, 0.02036205120384693, 0.015884453430771828, -0.02302614226937294, 0.01242586225271225, 0.03931088000535965, -0.03571711853146553, 0.04188627377152443, -0.05794548988342285, 0.026804981753230095, -0.009791607037186623, 0.02426830492913723, 0.00776596600189805, 0.027322465553879738, 0.027116762474179268, -0.012690750882029533, -0.051009368151426315, -0.03514410927891731, -0.006768898572772741, -0.013726613484323025, 0.012037805281579494, 0.05716720223426819, 0.013113634660840034, 0.04801459610462189, 0.026927078142762184, 0.04215359687805176, 0.03801970183849335, -0.003980051260441542, 0.0275149866938591, -0.028752319514751434, 0.00881885550916195, -0.0077314297668635845, -0.026113497093319893, -0.033018652349710464, -0.010958186350762844, 0.012330379337072372, -0.034186527132987976, -0.03650880232453346, 0.06753773242235184, 0.02963847853243351, 0.025315601378679276, 0.011983830481767654, -0.006091882474720478, 0.017300955951213837, -0.006147383246570826, -0.030733073130249977, -0.019158106297254562, 0.022540736943483353, 0.041716136038303375, -0.010881895199418068, -0.039796311408281326, 0.004887949209660292, -0.002695350907742977, -0.03187745064496994, 0.0022532870061695576, 0.02423930913209915, -0.010930614545941353, 0.006978269666433334, 0.0021634353324770927, 0.010079651139676571, -0.03715785965323448, 0.04553424194455147, -0.01386864110827446, -0.06418287009000778, 0.09764585644006729, 0.055346790701150894, -0.015798594802618027, -0.04251186177134514, -0.014698044396936893, 0.0057417768985033035, -0.025674108415842056, -0.04624094441533089, 0.004149791784584522, 0.015308341011404991, 0.019552255049347878, 0.0257097277790308, -0.02761571668088436, -0.05540188401937485, 0.017862938344478607, -0.007917799986898899, 0.032352227717638016, -0.005432393867522478, 0.005992311984300613, 0.016744419932365417, -0.004330769646912813, -0.013084604404866695, -0.000013973880413686857, -0.020451432093977928, -0.01974732056260109, 0.004299487452954054, 0.005586065351963043, -0.010663812048733234, 0.01139382366091013, 0.023862870410084724, 0.04172051325440407, -0.03227892890572548, 0.024429192766547203, -0.006279395893216133, -0.00514262868091464, -0.019626464694738388, 0.0318760871887207, 0.010858171619474888, -0.015583953820168972, 0.01438157632946968, 0.014221305027604103, 0.03790200129151344, -0.0031518079340457916, 0.019464973360300064, -0.006032147910445929, 0.006819258909672499, 0.04733572527766228, 0.009768945164978504, -0.0010562465758994222, -0.017328942194581032, -0.015705538913607597, -0.019109075888991356, -0.00561059033498168, 0.0036486233584582806, 0.0041322968900203705, 0.0017762157367542386, -0.020180843770503998, -0.01237862091511488, -0.025059204548597336, -0.005448990501463413, 0.02037637308239937, 0.009354221634566784, 0.03784073144197464, 0.014118875376880169, 0.01146250031888485, -0.03417416661977768, 0.05692354962229729, 0.020235616713762283, -0.06631934642791748, -0.021200694143772125, 0.0025093236472457647, -0.03367884084582329, 0.03625500574707985, 0.04668516293168068, -0.034912869334220886, 0.016257982701063156, 0.01645944081246853, -0.06182931363582611, -0.0028983333613723516, 0.025254694744944572, -0.02376151643693447, 0.006942928768694401, -0.005657470319420099, 0.013949788175523281, -0.036186374723911285, -0.004719778895378113, 0.013583206571638584, 0.011260936968028545, 0.047403085976839066, -0.02500605396926403, -0.026120569556951523, 0.02730996534228325, 0.00002718320320127532, 0.054817624390125275, -0.003487820504233241, -0.013740996830165386, 0.019417494535446167, 0.00931489560753107, 0.03946547582745552, 0.01482910756021738, -0.018365351483225822, 0.01035301573574543, -0.027788206934928894, 0.02840159647166729, 0.019700465723872185, 0.03004147857427597, 0.029712839052081108, 0.0126267708837986, 0.035527825355529785, 0.06613204628229141, -0.007998456247150898, 0.003403261536732316, -0.013642819598317146, 0.010280728340148926, 0.03932153806090355, -0.011856723576784134, 0.014365088194608688, 0.02673058584332466, 0.03635714203119278, -0.006509969010949135, -0.01841527782380581, -0.023173946887254715, 0.03394770994782448, 0.03499365597963333, -0.013015593402087688, 0.008358311839401722, 0.00997838843613863, -0.02619769796729088, -0.01588940992951393, -0.010116079822182655, 0.05237584561109543, -0.03285340964794159, -0.003158798674121499, -0.015641313046216965, -0.012140480801463127, -0.035165656358003616, -0.00988489668816328, -0.020833125337958336, -0.04360242187976837, 0.027180500328540802, -0.004938979633152485, 0.021066932007670403, 0.00601101852953434, -0.012533454224467278, -0.016990572214126587, -0.03211594000458717, 0.0037143949884921312, -0.02368510514497757, -0.008316274732351303, 0.07004039734601974, 0.0013311862712725997, -0.005552543792873621, 0.0007566175190731883, -0.0036730619613081217, 0.044737737625837326, 0.04906327649950981, 0.020265989005565643, 0.019536593928933144, -0.03411788493394852, 0.07587569206953049, 0.005274342838674784, -0.040631722658872604, -0.03626242280006409, -0.04228033870458603, -0.050220049917697906, 0.014794684015214443, -0.041711483150720596, 0.009897984564304352, 0.022945092990994453, -0.0131502915173769, -0.0014107362367212772, 0.008343922905623913, 0.02239355631172657, 0.01444251649081707, 0.024235356599092484, -0.016002768650650978, 0.03397239372134209, -0.0031859101727604866, 0.03930340334773064, -0.036803338676691055, 0.009059100411832333, -0.04981830343604088, -0.026668919250369072, -0.04892224818468094, 0.003729710355401039, 0.01687893457710743, 0.010927765630185604, 0.013741427101194859, 0.004702978301793337, -0.04079926759004593, 0.005340580362826586, -0.012766136787831783, 0.057829875499010086, 0.013291869312524796, 0.0021684172097593546, 0.035912033170461655, -0.016254445537924767, 0.012854985892772675, -0.006608698051422834, 0.04469484090805054, -0.009196266531944275, 0.07489161938428879, -0.03780591860413551, 0.030392907559871674, 0.045851416885852814, -0.028916306793689728, -0.004548906348645687, 0.0010671978816390038, 0.021630682051181793, 0.032396577298641205, -0.011457603424787521, 0.03560266271233559, -0.030346399173140526, -0.04866643622517586, -0.011834505014121532, -0.02180241420865059, -0.03001614846289158, 0.018532464280724525, -0.014389391988515854, -0.024395015090703964, -0.02096935175359249, -0.045150332152843475, -0.011102686636149883, 0.04107905551791191, 0.005511701572686434, 0.085604727268219, 0.034897614270448685, 0.0031531495042145252, 0.03468664735555649, 0.013380307704210281, -0.004920320585370064, 0.009202751331031322, -0.018091492354869843, 0.02464374341070652, 0.05458850413560867, 0.05069665610790253, 0.004479601047933102, 0.015384916216135025, -0.011059644632041454, 0.01117519848048687, 0.04227597266435623, 0.0035273944959044456, 0.004999706055969, -0.04201565682888031, -0.0037839964497834444, 0.02984428033232689, -0.02251662127673626, 0.04291344806551933, -0.02650326117873192, -0.026503929868340492, 0.02371986396610737, -0.04247216507792473, -0.027052700519561768, 0.006885715760290623, -0.0035623207222670317, -0.0020974481012672186, -0.009750643745064735, -0.009748648852109909, 0.030196666717529297, -0.031941596418619156, -0.052901141345500946, -0.04590662196278572, -0.011175006628036499, 0.045941490679979324, 0.0012348128948360682, -0.011291460134088993, -0.0022528045810759068, -0.010287625715136528, 0.036487776786088943, 0.0002078676043311134, -0.021759111434221268, 0.008227446116507053, -0.006968293804675341, 0.0009582717902958393, -0.03493658825755119, -0.003001375123858452, -0.029883671551942825, 0.002100893761962652, 0.013148017227649689, 0.0037713765632361174, -0.02594897523522377, -0.017125889658927917, 0.05684475973248482, 0.05809220299124718, 0.01770382933318615, 0.030587760731577873, 0.003937487490475178, -0.006390202324837446, -0.0018898819107562304, -0.046681150794029236, 0.03415258601307869, 0.0349450446665287, -0.01639604941010475, 0.016825957223773003, -0.02597431093454361, 0.0017818621126934886, -0.01915128529071808, -0.03593207895755768, 0.06015345826745033, -0.02128288894891739, -0.010762527585029602, 0.01825789548456669, 0.03922251611948013, 0.0028321517165750265, 0.010167601518332958, 0.009424380026757717, 0.009472334757447243, -0.023351965472102165, -0.08440703898668289, 0.03164226934313774, -0.003822767175734043, 0.07134276628494263, -0.03414781391620636, -0.022104647010564804, -0.0069242194294929504, 0.017611239105463028, -0.0020723033230751753, -0.0009841789724305272, -0.03337562084197998, 0.006119532510638237, -0.020931873470544815, 0.019492264837026596, -0.011950399726629257, -0.033491119742393494, 0.030578797683119774, 0.010664367116987705, -0.005353767890483141, -0.009097298607230186, -0.04920484125614166, -0.011033149436116219, 0.024622049182653427, 0.07593502104282379, -0.017864307388663292, -0.018461327999830246, -0.003339349292218685, 0.021832475438714027, 0.0010016144951805472, -0.05209316313266754, -0.031486332416534424, 0.016370518133044243, -0.032828446477651596, 0.03842521458864212, -0.04110635817050934, 0.005623453762382269, 0.001468975911848247, -0.04484973102807999, 0.06674592196941376, -0.01706269383430481, -0.06714704632759094, 0.011367863044142723, -0.024182775989174843, -0.03710509091615677, -0.006068392191082239, 0.016210129484534264, -0.04837441071867943, 0.052672430872917175, 0.039354708045721054, 0.012087613344192505, -0.025082552805542946, -0.03593180701136589, -0.012617371045053005, -0.03242877870798111, -0.044708579778671265, -0.041814543306827545, -0.0035315873101353645, 0.015439243987202644, -0.0017169751226902008, -0.032714273780584335, -0.0017742107156664133, -0.03889855369925499, -0.006303864065557718, 0.023903943598270416, 0.03673061355948448, 0.030118968337774277, 0.021634118631482124, 0.010466949082911015, -0.03800223395228386, 0.030372379347682, 0.06699524074792862, 0.007744248956441879, -0.011469239369034767, 0.032641611993312836 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
NLP Evaluation Methods:
[ 0.05259077250957489, -0.005755994934588671, 0.05687153711915016, -0.02048332430422306, 0.08284834027290344, 0.06859776377677917, 0.044499896466732025, 0.0672735869884491, -0.04312260448932648, -0.035603344440460205, -0.02973395213484764, 0.10917229950428009, -0.01823323592543602, -0.006033821497112513, 0.006276966538280249, 0.021882325410842896, 0.03663361445069313, -0.017063390463590622, 0.0515616200864315, -0.021082445979118347, -0.04784335941076279, -0.05063430219888687, 0.06415984779596329, -0.027372872456908226, 0.0331648588180542, -0.026465585455298424, 0.02836398221552372, -0.016136160120368004, -0.06949356943368912, 0.006278805900365114, -0.13456930220127106, -0.01353028416633606, -0.0067305960692465305, 0.00625671586021781, -0.014958924613893032, 0.016883427277207375, -0.11674632132053375, 0.03613476827740669, 0.012551999650895596, -0.03009393811225891, -0.04667113348841667, -0.0668136402964592, -0.05405579134821892, 0.008979207836091518, -0.051242098212242126, -0.04438335821032524, -0.25215423107147217, 0.04762683063745499, -0.000803296163212508, -0.0005097028333693743, -0.06833480298519135, 0.06533896923065186, -0.06322886049747467, -0.01314142718911171, -0.015008576214313507, -0.007292042952030897, 0.014570081606507301, -0.07979227602481842, 0.04803922772407532, 0.0044138189405202866, 0.06088124215602875, -0.03607248514890671, -0.0008335596648976207, 0.04900578409433365, 0.06365051120519638, 0.012886428274214268, 0.016846822574734688, 0.060322511941194534, -0.09019720554351807, 0.01563357003033161, -0.006142688449472189, -0.02501627802848816, -0.017764275893568993, 0.027346588671207428, 0.019730838015675545, -0.06087309122085571, -0.022124284878373146, 0.02781686559319496, 0.0041030696593225, 0.1006111353635788, -0.009607251733541489, 0.006150755565613508, 0.06560979038476944, 0.028350669890642166, 0.0287689920514822, 0.03355937451124191, 0.08414915204048157, -0.0365569069981575, -0.029187148436903954, 0.047105226665735245, 0.039596814662218094, -0.08726973831653595, -0.004357711412012577, 0.019004300236701965, 0.02199135534465313, -0.0628613531589508, 0.05257142707705498, 0.050953786820173264, -0.044438835233449936, -0.017256269231438637, 0.014737484976649284, 0.0013873031130060554, 0.023980576545000076, -0.033417098224163055, -0.05916598439216614, 0.00034143406082876027, -0.00044541616807691753, -0.068851999938488, -0.06843923777341843, 0.02371840924024582, -0.04891477897763252, 0.019438235089182854, 0.023005411028862, 0.05613937973976135, -0.066434845328331, 0.047466814517974854, -0.008848626166582108, 0.056434694677591324, -0.004516619723290205, 0.04439118131995201, 0.029690412804484367, 0.0482901856303215, 0.06485658138990402, 0.014021291397511959, 0.026600800454616547, 0.03137820586562157, 0.05336262658238411, 0.04593366011977196, -0.06747643649578094, -0.012785777449607849, 0.009166358970105648, -0.04052509739995003, 0.03221165016293526, 0.03395317867398262, -0.03357644006609917, -0.04855824634432793, -0.04180791601538658, -0.05669679120182991, 0.018177304416894913, 0.0029410002753138542, -0.051100458949804306, 0.04821232706308365, -0.018734246492385864, 0.06010602414608002, 0.053321510553359985, 0.0033369825687259436, -0.04431280493736267, 0.017223326489329338, -0.005563833750784397, 0.009411739185452461, -0.056980572640895844, 0.06917060166597366, -0.022029927000403404, -0.04780057817697525, 0.03642535209655762, 0.09622756391763687, -0.0360589437186718, -0.008699559606611729, -0.08357928693294525, -0.016259601339697838, -0.0028583346866071224, 0.015424764715135098, -0.04652296006679535, -0.007334727793931961, 0.04460958391427994, -0.004682027734816074, 0.016708217561244965, 0.031944211572408676, -0.020978495478630066, -0.004938680212944746, 0.023602675646543503, -0.04678229242563248, 0.05388149991631508, -0.006103538908064365, -0.035294465720653534, -0.018336618319153786, 0.04802120476961136, 0.04457191005349159, -0.008186829276382923, 0.022500788792967796, -0.036282192915678024, 0.040378935635089874, -0.056971363723278046, 0.041826654225587845, 0.018189799040555954, -0.06533005833625793, -0.00023011154553387314, -0.012282892130315304, 0.059541959315538406, 0.018799420446157455, -0.10859746485948563, -0.0823841467499733, 0.0992451012134552, 0.007834941148757935, 0.041334886103868484, -0.07390375435352325, -0.04372786730527878, 0.15163671970367432, 0.020236054435372353, 0.04736971855163574, 0.03006206639111042, -0.018055535852909088, 0.06922329217195511, -0.048431724309921265, -0.014818592928349972, -0.002814740175381303, 0.015033502131700516, -0.015994757413864136, 0.01388033851981163, 0.037627946585416794, -0.001810290152207017, -0.08354370296001434, 0.033492717891931534, -0.0909891426563263, -0.032366711646318436, 0.005873845424503088, 0.010660072788596153, 0.04950515553355217, 0.02510402351617813, -0.02938286028802395, 0.15357980132102966, -0.030830884352326393, 0.01743299700319767, 0.0030121796298772097, -0.05556375905871391, 0.07301720976829529, 0.05469534173607826, 0.06657732278108597, 0.0863080620765686, -0.04902677237987518, -0.03480091691017151, -0.0359949953854084, 0.027179403230547905, 0.07204568386077881, -0.007285731378942728, 0.0035893376916646957, 0.03233244642615318, 0.004903418943285942, 0.06710720807313919, -0.035699378699064255, -0.006937139667570591, -0.00013270656927488744, -0.0013206658186390996, 0.08862154930830002, -0.015623783692717552, -0.017114724963903427, 0.03544272854924202, 0.020802754908800125, -0.030650045722723007, 0.023475443944334984, -0.028963742777705193, 0.057467635720968246, 0.03534926474094391, -0.03616238385438919, 0.012008854188024998, -0.0006502038449980319, -0.005650292616337538, -0.01663830876350403, -0.01845715567469597, 0.020338034257292747, 0.010445444844663143, -0.017996424809098244, -0.013225925154983997, -0.05383158102631569, 0.001935455366037786, -0.04530802369117737, 0.011910280212759972, -0.007067426107823849, -0.012607377022504807, 0.044252704828977585, -0.004720000084489584, -0.007304776459932327, 0.04782848432660103, -0.003900583367794752, -0.006319373846054077, -0.007388044614344835, 0.05545078590512276, -0.023708343505859375, -0.03023078851401806, -0.011554768308997154, -0.013729633763432503, -0.044256120920181274, 0.02989516407251358, 0.01117070484906435, 0.03512716293334961, -0.035567089915275574, 0.00738784484565258, 0.00692920433357358, -0.008007152937352657, 0.0339411161839962, -0.02578095719218254, 0.036722101271152496, -0.03458673506975174, -0.009009918197989464, 0.03181647136807442, -0.0024669691920280457, -0.007263978477567434, 0.023393623530864716, -0.00961022637784481, 0.011451760306954384, 0.017274675890803337, 0.041487738490104675, -0.03317178785800934, -0.00239642639644444, -0.06478254497051239, 0.05119745805859566, 0.009161793626844883, 0.028471844270825386, -0.14032532274723053, -0.04113617539405823, 0.027332117781043053, 0.0029017131309956312, 0.004676504991948605, -0.01007072813808918, 0.04617802053689957, -0.024130970239639282, -0.01617065630853176, -0.004103349521756172, 0.02937832660973072, 0.005665893666446209, 0.026860995218157768, 0.02549050934612751, -0.003773589851334691, 0.004466013051569462, -0.0059174178168177605, 0.01478591375052929, 0.02107778750360012, 0.013044448569417, -0.018525222316384315, 0.0645948052406311, -0.03688574582338333, 0.00044995982898399234, -0.00900233257561922, 0.07492269575595856, 0.0453176349401474, 0.030075006186962128, 0.03445983678102493, -0.03829597681760788, -0.01450126152485609, 0.023330843076109886, -0.046124208718538284, 0.0112260477617383, -0.027471788227558136, 0.00261318008415401, 0.007837573997676373, 0.004220565315335989, 0.020606927573680878, 0.03391697630286217, 0.012258201837539673, 0.022817477583885193, 0.02789939194917679, -0.01286875270307064, -0.0177985318005085, 0.007221318315714598, 0.00260567688383162, -0.019115358591079712, 0.03103768453001976, -0.038577716797590256, -0.047711752355098724, -0.014785172417759895, -0.010206305421888828, 0.06363221257925034, 0.012825791724026203, 0.00926776323467493, -0.018357543274760246, -0.000436779810115695, 0.039843540638685226, -0.0016288658371195197, -0.023738721385598183, 0.006897177547216415, 0.011186857707798481, -0.04870899021625519, -0.06827310472726822, 0.029337482526898384, -0.022898642346262932, 0.035435017198324203, -0.0034132376313209534, 0.04351557418704033, 0.03453550487756729, 0.03454342111945152, -0.0049250004813075066, 0.02746954746544361, -0.02114148624241352, -0.005859456490725279, -0.021910525858402252, 0.0003051071835216135, 0.08250957727432251, -0.010856675915420055, -0.05313959717750549, 0.009094682522118092, -0.02787991799414158, -0.01824945956468582, -0.0044164638966321945, 0.019530516117811203, 0.025989096611738205, 0.00825396366417408, 0.027419866994023323, 0.03163234144449234, 0.023925626650452614, -0.025413326919078827, 0.0019536151085048914, 0.016079921275377274, -0.014251196756958961, -0.01750461384654045, 0.050570715218782425, -0.021773947402834892, -0.022180015221238136, -0.0031139894854277372, 0.0103793079033494, -0.028274567797780037, -0.004149473737925291, 0.0142896119505167, -0.00680124294012785, 0.02633233740925789, -0.0233719814568758, -0.041519645601511, 0.018748663365840912, -0.02181984670460224, -0.0018159470055252314, -0.027932217344641685, -0.004928696900606155, -0.00803301203995943, 0.042208727449178696, 0.007014422211796045, -0.00974641926586628, -0.016651982441544533, -0.030648816376924515, 0.026449210941791534, -0.038545161485672, 0.01785632036626339, -0.03210834413766861, -0.019725346937775612, 0.007360572926700115, -0.01848406158387661, 0.024819204583764076, 0.008839008398354053, -0.020125996321439743, -0.0011147622717544436, 0.004197641741484404, 0.0029527428559958935, 0.02067475952208042, -0.007777051534503698, 0.00789723452180624, 0.007174598053097725, -0.01514943316578865, 0.015292533673346043, 0.008632918819785118, -0.036529187113046646, 0.002513049403205514, 0.023389335721731186, 0.0020573853980749846, -0.007220807485282421, 0.03347928076982498, -0.015676986426115036, -0.05547795817255974, -0.032172784209251404, -0.017192518338561058, 0.025709321722388268, 0.028643615543842316, -0.02269362285733223, -0.02035289816558361, -0.01020785141736269, 0.030922213569283485, -0.021259645000100136, -0.00011549452028702945, 0.0022545268293470144, -0.01762246899306774, 0.045096464455127716, 0.010964474640786648, -0.029614334926009178, -0.026638396084308624, 0.011307154782116413, -0.005139269400388002, -0.029312698170542717, -0.016134100034832954, -0.028695769608020782, 0.005610371474176645, 0.012985005974769592, 0.006631689611822367, -0.0039947135373950005, 0.007674563210457563, -0.0063590905629098415, 0.000475716486107558, 0.02519233524799347, 0.021267307922244072, 0.02767328731715679, 0.0009072221000678837, 0.01811921037733555, -0.025325987488031387, -0.009986608289182186, 0.025420479476451874, -0.007579219061881304, 0.00701587600633502, 0.0318940170109272, 0.057638220489025116, 0.03744291886687279, -0.011322329752147198, 0.04458087682723999, -0.02238871343433857, -0.006898043677210808, 0.009901008568704128, -0.05837602913379669, 0.010577647015452385, 0.0036173081025481224, 0.034858450293540955, -0.01379384845495224, -0.018398446962237358, -0.014073718339204788, 0.02501414529979229, 0.027302049100399017, 0.005253036506474018, -0.028153477236628532, 0.009992951527237892, 0.015016265213489532, -0.008009872399270535, -0.04184207320213318, 0.011230327188968658, -0.010076659731566906, -0.023773591965436935, -0.02210131287574768, -0.04551447927951813, -0.029670728370547295, 0.011982515454292297, -0.02094103954732418, -0.006951045244932175, 0.006679054815322161, -0.038422513753175735, 0.036976106464862823, 0.0013961457880213857, -0.012543188408017159, -0.048041801899671555, 0.008589002303779125, 0.05505537986755371, -0.023507744073867798, -0.003691106801852584, -0.008310758508741856, 0.025119386613368988, 0.05786703899502754, 0.01165566872805357, -0.032589707523584366, 0.004039191175252199, 0.016232788562774658, 0.02790672332048416, -0.01195448450744152, -0.061799224466085434, 0.04502080753445625, 0.014720531180500984, 0.00007499065395677462, -0.013975662179291248, 0.001709495554678142, -0.035668399184942245, -0.026787202805280685, -0.024536248296499252, 0.029026217758655548, 0.06137927994132042, 0.00033741365768946707, 0.02597871795296669, 0.005480020307004452, -0.01233334094285965, 0.013943617232143879, -0.0014012395404279232, -0.0009664776152931154, 0.03974517434835434, 0.054159339517354965, -0.017926804721355438, 0.00004155446731601842, -0.00599320326000452, 0.002910526003688574, 0.04646855965256691, -0.029875215142965317, 0.004189108964055777, 0.05570187419652939, -0.04908427596092224, 0.006521701812744141, -0.007675246335566044, -0.04277627170085907, 0.014649507589638233, 0.029030242934823036, 0.01074289996176958, 0.016246680170297623, 0.0132386963814497, 0.026400607079267502, 0.008510177955031395, -0.046160392463207245, -0.0004256567044649273, 0.06775769591331482, -0.025853564962744713, 0.04411425441503525, 0.024301761761307716, 0.02758357673883438, 0.0019432734698057175, 0.004754447843879461, -0.02430594153702259, 0.028384286910295486, 0.05660921707749367, -0.0078816469758749, 0.03530123084783554, 0.016705315560102463, 0.004261128604412079, 0.003350988496094942, -0.03769185394048691, -0.029148878529667854, -0.04777642339468002, 0.023021938279271126, 0.03701106458902359, -0.024130139499902725, -0.003336568595841527, -0.044183969497680664, 0.02512184903025627, 0.005180562846362591, 0.02829616889357567, 0.004036662168800831, -0.018544701859354973, 0.02568765915930271, 0.00566747784614563, -0.011689729057252407, 0.018670663237571716, -0.03631225973367691, 0.012541004456579685, 0.07710306346416473, 0.013469254598021507, 0.0046394276432693005, 0.005766420625150204, -0.03482040762901306, 0.047302715480327606, -0.014054112136363983, 0.000027311654775985517, 0.0054976907558739185, 0.05343340337276459, -0.030979983508586884, -0.010045366361737251, -0.004800585098564625, -0.017902608960866928, -0.0198226235806942, -0.03379511460661888, 0.011589712463319302, 0.014746060594916344, -0.04004945605993271, -0.024212593212723732, 0.05561186000704765, -0.0011825273977592587, -0.007326463237404823, -0.009450394660234451, 0.023735573515295982, 0.02790123224258423, 0.03730376064777374, -0.052175123244524, -0.02943223901093006, -0.000710453256033361, 0.021619167178869247, -0.02647954784333706, 0.004847133532166481, -0.0029172643553465605, 0.009176259860396385, -0.005690725054591894, -0.008171255700290203, -0.02968570776283741, 0.014063767157495022, 0.04344170168042183, 0.016353394836187363, -0.01778292842209339, 0.03024829737842083, -0.01737368293106556, -0.00022946846729610115, -0.020745398476719856, -0.03728124126791954, -0.004098804667592049, -0.008066141977906227, 0.013831053860485554, 0.028953351080417633, 0.029016733169555664, -0.024071913212537766, -0.014325443655252457, -0.006048774346709251, -0.039016079157590866, -0.037093523889780045, -0.0030110229272395372, 0.04083109647035599, 0.004870185162872076, 0.00019210732716601342, -0.01161419227719307, -0.03908034786581993, -0.017503267154097557, 0.021427273750305176, -0.005843055434525013, -0.01530678104609251, -0.03374604135751724, -0.021227603778243065, 0.029166625812649727, 0.0008850875892676413, 0.016883790493011475, 0.04000459983944893, 0.03567094728350639, 0.013267556205391884, -0.056835249066352844, 0.03480108454823494, -0.015959754586219788, -0.0022064917720854282, -0.02876771241426468, -0.02531546540558338, -0.024846162647008896, 0.020490219816565514, -0.00674426881596446, 0.027301611378788948, -0.06106110289692879, -0.007228493690490723, -0.018233148381114006, 0.0006861889269202948, -0.04857894778251648, 0.006359260994940996, 0.06397049129009247, 0.03408840671181679, 0.038266777992248535, 0.0014042541151866317, -0.0009092959808185697, 0.024099763482809067, -0.0025420438032597303, -0.00487727764993906, 0.014851391315460205, 0.05221499130129814, 0.0015198595356196165, -0.03593754395842552, 0.029539713636040688, -0.039731744676828384, -0.01521342433989048, 0.022214699536561966, 0.0028083359356969595, -0.011751200072467327, -0.00010861188638955355, -0.007561700884252787, 0.00949239544570446, 0.008365935645997524, 0.05635596066713333, 0.0036436915397644043, 0.015351218171417713, -0.02694825455546379, -0.0041289785876870155, -0.06791313737630844, -0.005017041228711605, 0.02361210249364376, -0.005953378044068813, 0.0346871055662632, 0.030671248212456703, 0.03172965720295906, 0.007641292177140713, -0.03354239836335182, -0.006328473333269358, 0.005783631931990385, -0.024159828200936317, -0.04466651380062103, -0.00027552517713047564, 0.010237665846943855, -0.0306775514036417, -0.0620761513710022, 0.038717664778232574, -0.015735851600766182, -0.018665065988898277, -0.048607274889945984, 0.003075576853007078, 0.013577251695096493, -0.00578672531992197, 0.031808361411094666, -0.018409181386232376, 0.07406087219715118, 0.02900581993162632, -0.00041708804201334715, 0.00653520692139864, 0.015299289487302303 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
7.2 Try out BERT Feel free to swap out the sentence below for one of your own. However, leave [MASK] in somewhere to allow BERT to predict the missing word ```python from transformers import pipeline unmasker = pipeline('fill-mask', model='bert-base-uncased') unmasker("Artificial Intelligence [MASK] take over the world.") ``` When you run the above code you should see an output like this: ``` [{'score': 0.3182411789894104, 'sequence': 'artificial intelligence can take over the world.', 'token': 2064, 'token_str': 'can'}, {'score': 0.18299679458141327, 'sequence': 'artificial intelligence will take over the world.', 'token': 2097, 'token_str': 'will'}, {'score': 0.05600147321820259, 'sequence': 'artificial intelligence to take over the world.', 'token': 2000, 'token_str': 'to'}, {'score': 0.04519503191113472, 'sequence': 'artificial intelligences take over the world.', 'token': 2015, 'token_str': '##s'}, {'score': 0.045153118669986725, 'sequence': 'artificial intelligence would take over the world.', 'token': 2052, 'token_str': 'would'}] ``` Kind of frightening right? 🙃
[ -0.06554947793483734, -0.0075546083971858025, 0.054971884936094284, -0.013257559388875961, 0.05432036519050598, 0.0576758049428463, 0.10584325343370438, 0.01056086178869009, -0.024287227541208267, 0.003888950450345874, -0.08887876570224762, 0.025466930121183395, -0.023068659007549286, 0.08394813537597656, 0.021104944869875908, 0.02681082673370838, 0.06938189268112183, 0.004956722725182772, -0.029737545177340508, -0.02620008774101734, 0.0047670030035078526, -0.025789737701416016, 0.12068995088338852, -0.046396367251873016, 0.05226954445242882, -0.06046941503882408, 0.00019738325499929488, 0.016537819057703018, -0.09982141852378845, 0.07688646018505096, -0.057272378355264664, 0.0009102989570237696, 0.04055968299508095, -0.03778354078531265, -0.0007473620353266597, 0.01954934187233448, -0.051741987466812134, 0.07067028433084488, -0.014577141031622887, 0.006516906898468733, -0.04214470833539963, 0.006375259254127741, -0.008025162853300571, 0.02087763324379921, -0.045408472418785095, -0.04362769424915314, -0.16011634469032288, 0.08012636005878448, -0.029398050159215927, -0.03911566734313965, -0.059633444994688034, 0.03439633548259735, -0.02166532538831234, -0.036342035979032516, -0.025915365666151047, -0.06268295645713806, -0.020450687035918236, -0.10092827677726746, 0.041731420904397964, 0.016751646995544434, 0.05033911019563675, -0.01345005165785551, -0.025185856968164444, 0.003734048455953598, 0.03307509049773216, 0.026643814519047737, -0.036579638719558716, -0.03132736682891846, -0.026308488100767136, -0.012046949937939644, 0.0009544487111270428, -0.06042720377445221, -0.05523994192481041, -0.014675851911306381, 0.029283937066793442, -0.07353916019201279, -0.013590008951723576, 0.0431649386882782, -0.02056129276752472, 0.00813509151339531, -0.015586670488119125, -0.01718352921307087, 0.003220141865313053, 0.06985855847597122, 0.06177220121026039, -0.03707623854279518, 0.06923671066761017, -0.01508222334086895, -0.06728274375200272, 0.03594483062624931, -0.006641071755439043, -0.126792773604393, -0.07237683981657028, 0.011981908231973648, 0.005669970065355301, -0.03430943936109543, 0.015506322495639324, -0.029956277459859848, -0.056159887462854385, -0.011375105008482933, -0.02825903706252575, -0.10598926246166229, 0.04309922456741333, 0.0019826863426715136, -0.09602236747741699, -0.016878921538591385, 0.006760977208614349, -0.07457365840673447, -0.007337518967688084, -0.03251254931092262, 0.05535854026675224, -0.015038515441119671, 0.0050599342212080956, 0.08889158815145493, -0.004472699947655201, -0.002089996822178364, -0.009155887179076672, 0.04225499555468559, 0.06524176150560379, -0.005611869506537914, 0.010320346802473068, 0.036822982132434845, 0.08252198994159698, 0.009774047881364822, 0.012968095019459724, -0.00432245759293437, -0.06724677234888077, 0.047005731612443924, 0.040227245539426804, 0.029782544821500778, 0.03742511197924614, 0.038430795073509216, 0.03790413215756416, 0.017124956473708153, 0.01338502112776041, -0.04820486158132553, -0.0023272489197552204, -0.059836145490407944, -0.004425311926752329, -0.004953998140990734, -0.007775641046464443, 0.06119327247142792, -0.013323877938091755, 0.062249474227428436, 0.010269862599670887, -0.023040955886244774, -0.08567267656326294, 0.01912631280720234, -0.00950244627892971, 0.07914209365844727, -0.0212691742926836, 0.009906248189508915, -0.021289076656103134, -0.012423262931406498, 0.05032195523381233, 0.07969930768013, -0.006991742644459009, -0.0507337860763073, -0.027910837903618813, -0.0006732477340847254, -0.012770270928740501, 0.07086307555437088, -0.05477515608072281, -0.042750053107738495, 0.013046304695308208, -0.08961594849824905, 0.032113444060087204, 0.007455767598003149, 0.04172427952289581, 0.05815840885043144, 0.012206480838358402, 0.022600082680583, 0.05722319334745407, -0.021946510300040245, 0.0203527994453907, 0.07445961982011795, -0.013129455037415028, 0.02905622497200966, -0.021394627168774605, 0.02744593285024166, 0.0007432808051817119, 0.030489541590213776, 0.01631065458059311, 0.00639547361060977, 0.013698097318410873, -0.005180817563086748, 0.01723908819258213, -0.03316636011004448, 0.054226215928792953, 0.05039538815617561, -0.027689771726727486, -0.03288758918642998, 0.018415944650769234, -0.0038223767187446356, 0.01364864781498909, -0.049602244049310684, -0.08388499170541763, 0.06675443053245544, 0.047250401228666306, 0.04332868754863739, 0.02182932198047638, -0.028956158086657524, -0.003982319962233305, -0.06413796544075012, 0.011953432112932205, 0.017119891941547394, 0.008548181504011154, -0.08620522916316986, -0.007360147777944803, 0.01708369515836239, 0.07425232231616974, -0.05340394005179405, 0.010140372440218925, -0.13873036205768585, -0.05761897563934326, -0.0777120292186737, -0.03940301388502121, -0.0025328125339001417, -0.012125015258789062, 0.028759587556123734, 0.10409296303987503, -0.021741079166531563, -0.0009812508942559361, -0.07915785163640976, -0.011559567414224148, 0.03608601540327072, 0.050914499908685684, 0.04565810039639473, 0.03929664567112923, -0.07606996595859528, -0.10541465133428574, -0.02195802703499794, 0.05230330675840378, 0.023537298664450645, -0.06547385454177856, -0.03022700920701027, 0.008717839606106281, 0.01752777211368084, -0.01595447026193142, 0.003204625565558672, 0.03533705696463585, -0.03352179005742073, 0.017214711755514145, 0.054030563682317734, -0.016795624047517776, -0.011794216930866241, 0.0724807158112526, -0.06435646116733551, -0.0031004250049591064, 0.03911956027150154, -0.030476098880171776, 0.03774508088827133, 0.014315729960799217, -0.02212013117969036, 0.041914623230695724, 0.06270914524793625, -0.0227667186409235, 0.0224780086427927, -0.0233803391456604, 0.05218485742807388, -0.003889750922098756, -0.019624192267656326, 0.01343460287898779, -0.02761807106435299, -0.008092326112091541, -0.009448397904634476, -0.010294973850250244, 0.008044042624533176, -0.020526917651295662, 0.05230419710278511, -0.0017045526765286922, -0.027575954794883728, 0.014076988212764263, -0.008655300363898277, 0.04445304721593857, 0.037060581147670746, 0.02581462264060974, 0.027483219280838966, -0.012151616625487804, -0.017144573852419853, -0.020212391391396523, -0.03524305298924446, 0.03748321160674095, 0.011136810295283794, -0.020559249445796013, -0.01091854739934206, -0.023708006367087364, -0.019864244386553764, 0.028920860961079597, -0.017252184450626373, 0.02640010602772236, 0.049425914883613586, 0.03075302764773369, -0.023799914866685867, -0.03381435200572014, 0.04094313085079193, -0.02538784220814705, 0.0006795352674089372, -0.019271671772003174, 0.0074360002763569355, -0.00869294535368681, 0.04393626004457474, -0.0234869122505188, -0.03678486496210098, -0.010066168382763863, 0.040003616362810135, 0.019562164321541786, 0.00300691113807261, -0.0904545933008194, -0.004094862844794989, 0.02674819715321064, -0.023709526285529137, 0.0009123946074396372, -0.012580177746713161, 0.07317287474870682, 0.02890695445239544, -0.0636720359325409, 0.017937466502189636, 0.007257960736751556, 0.0034659842494875193, 0.011819201521575451, 0.00994420237839222, 0.013822983019053936, -0.04800420626997948, -0.01973278820514679, -0.010502382181584835, -0.018228044733405113, -0.014263373799622059, 0.02353891171514988, 0.044615164399147034, 0.04127909243106842, -0.021889492869377136, -0.010135496035218239, -0.013380158692598343, 0.022086545825004578, 0.03127453848719597, 0.028859222307801247, -0.03544597700238228, -0.004506812430918217, -0.016585176810622215, -0.004570062272250652, 0.01777377538383007, -0.06995382905006409, 0.0374428853392601, -0.028369806706905365, 0.00432025920599699, 0.04435700550675392, 0.027072953060269356, -0.02510811947286129, -0.01438457053154707, -0.0037703737616539, -0.008964941836893559, 0.02998151257634163, -0.048486530780792236, -0.04402638599276543, -0.03759479150176048, -0.005452816840261221, -0.027087712660431862, -0.008267605677247047, -0.030708318576216698, -0.004356709774583578, 0.012310456484556198, 0.018045485019683838, 0.00023847096599638462, 0.002851588884368539, 0.00847125705331564, 0.02884904481470585, -0.0023562044370919466, -0.006982047110795975, 0.006406657863408327, -0.034629400819540024, -0.018372930586338043, 0.010343081317842007, 0.02048184722661972, 0.031009675934910774, 0.04205314815044403, 0.03470494598150253, 0.020030679181218147, 0.01717265695333481, 0.018309365957975388, 0.028209680691361427, 0.0052211289294064045, 0.0060225361958146095, -0.005544799380004406, -0.01386010367423296, -0.009489823132753372, 0.03999733924865723, -0.01571163721382618, -0.033539626747369766, 0.022643599659204483, -0.057913754135370255, 0.0010366018395870924, 0.0014553243527188897, -0.013147338293492794, 0.01762927882373333, -0.02701118029654026, 0.02806757390499115, 0.00945047102868557, 0.010780459269881248, -0.01635350100696087, 0.009090203791856766, -0.009864688850939274, -0.026728084310889244, 0.02503892593085766, 0.01579534076154232, -0.019616173580288887, -0.059894487261772156, -0.012271683663129807, 0.015732713043689728, -0.016811057925224304, -0.012567196041345596, -0.0021054260432720184, 0.004059320315718651, 0.056587252765893936, -0.047862064093351364, -0.036629270762205124, -0.012935478240251541, -0.018950706347823143, 0.009557046927511692, -0.014863461256027222, -0.0050983428955078125, -0.010641434229910374, 0.012674004770815372, 0.015337641350924969, 0.02005685865879059, -0.025084076449275017, -0.0186951644718647, 0.021562334150075912, -0.0022135665640234947, 0.057773295789957047, 0.0009138718596659601, 0.006263009272515774, 0.0021284674294292927, -0.036404017359018326, 0.0716695562005043, 0.05831094831228256, 0.02850111946463585, -0.026698924601078033, -0.02639894187450409, -0.017154129222035408, 0.035784460604190826, -0.019576644524931908, 0.006225462071597576, 0.030167222023010254, -0.0020127128809690475, 0.011563424952328205, -0.030300404876470566, -0.03361278399825096, -0.040380578488111496, -0.020543204620480537, 0.033032387495040894, -0.08316385746002197, 0.06440629065036774, -0.0019375919364392757, -0.01912480965256691, -0.012632552534341812, 0.00010684216977097094, 0.03367352485656738, 0.05185733363032341, 0.01628784090280533, -0.012065126560628414, -0.02040271833539009, 0.02976287715137005, -0.054480865597724915, -0.016105657443404198, 0.0274452306330204, 0.0218114722520113, 0.03188331797719002, -0.0022596947383135557, 0.00549317104741931, -0.043921999633312225, 0.03790472820401192, 0.007851418107748032, -0.030833708122372627, 0.00022984175302553922, -0.0627874881029129, 0.026039158925414085, 0.054553594440221786, 0.017048075795173645, 0.01535424217581749, 0.022617237642407417, -0.033757783472537994, -0.0059159304946660995, 0.04347105696797371, -0.012807684950530529, 0.026164783164858818, -0.02529485709965229, 0.01862836815416813, -0.008006695657968521, -0.0022821598686277866, -0.010266230441629887, 0.045732226222753525, -0.006035024765878916, 0.016783803701400757, 0.01611322909593582, 0.01221797801554203, -0.02544647455215454, 0.022426972165703773, 0.04795107990503311, -0.013040084391832352, -0.04010610654950142, -0.022184597328305244, 0.03757304325699806, -0.008573063649237156, -0.017764225602149963, -0.00006598331674467772, -0.041233811527490616, 0.026984520256519318, 0.050077229738235474, 0.02288767136633396, 0.02496655099093914, -0.01835283637046814, 0.017324719578027725, -0.04285033419728279, 0.005877688992768526, -0.03130469098687172, -0.018598152324557304, -0.042565882205963135, 0.015743212774395943, -0.019575439393520355, -0.007173693273216486, 0.02214161865413189, 0.00622590072453022, 0.02484646439552307, 0.029166050255298615, 0.027658237144351006, 0.01530634704977274, 0.09255056083202362, 0.031717266887426376, -0.0016118581406772137, -0.021023135632276535, 0.03954431042075157, 0.01646364852786064, -0.04444863274693489, -0.006022213492542505, 0.0370083823800087, 0.02553662657737732, 0.03029634617269039, 0.016154266893863678, 0.04223138093948364, 0.010023807175457478, 0.07664742320775986, -0.007985842414200306, 0.020140351727604866, -0.014922409318387508, -0.018278203904628754, 0.024262260645627975, -0.02401409111917019, 0.02037939988076687, 0.0011341884965077043, -0.030437365174293518, 0.013560359366238117, -0.00755096273496747, 0.01280051190406084, 0.06711094081401825, 0.03137177601456642, -0.008093874901533127, 0.00286080245859921, 0.014569585211575031, 0.028554679825901985, -0.0035678818821907043, 0.023211833089590073, 0.03308479115366936, 0.043125931173563004, 0.03435536473989487, 0.03169266879558563, 0.015341201797127724, -0.0014880094677209854, 0.029065784066915512, -0.07001831382513046, -0.00043463558540679514, 0.04902919754385948, -0.0012290457962080836, 0.044081300497055054, -0.0005113257793709636, -0.05915353447198868, -0.02326829731464386, 0.025396475568413734, 0.016676586121320724, 0.033268798142671585, -0.016774192452430725, -0.0077628144063055515, 0.06386799365282059, -0.017775805667042732, 0.0019584253896027803, 0.031231442466378212, -0.028348408639431, 0.04651230201125145, 0.01398291066288948, 0.033674515783786774, 0.011026626452803612, -0.001255007809959352, -0.0257022213190794, -0.02365812100470066, 0.0563206747174263, 0.019068069756031036, 0.027559500187635422, 0.041031062602996826, -0.0023342466447502375, -0.007657554931938648, -0.00241951085627079, -0.02179061621427536, -0.005351559724658728, -0.023344861343503, 0.06308148801326752, -0.030022837221622467, 0.019150659441947937, -0.005887050647288561, 0.02463855780661106, 0.03587760403752327, 0.03685164079070091, -0.05424182862043381, 0.04165486991405487, 0.015439564362168312, 0.0015356027288362384, 0.02317424863576889, 0.06357089430093765, -0.016933655366301537, -0.04362649843096733, 0.08202069997787476, 0.004885305650532246, 0.0056241899728775024, 0.018598057329654694, -0.0006383141153492033, 0.004398683086037636, -0.07428230345249176, -0.02114216238260269, 0.02603902667760849, 0.0022633830085396767, -0.013545459136366844, -0.04147948697209358, 0.030819693580269814, -0.036922529339790344, 0.006550008896738291, -0.021721001714468002, -0.010421177372336388, -0.03241334855556488, -0.008162038400769234, 0.024085840210318565, 0.026733573526144028, -0.010365144349634647, -0.02793843485414982, -0.017531154677271843, -0.00823743361979723, 0.03977213054895401, 0.003945036791265011, -0.05573777109384537, -0.023823248222470284, -0.028076836839318275, -0.04101049527525902, -0.035311538726091385, 0.01840348169207573, -0.02486916072666645, -0.019566871225833893, 0.017726918682456017, 0.024884004145860672, -0.0019641867838799953, 0.021065663546323776, -0.003537116339430213, 0.023911869153380394, -0.00838511809706688, -0.006810242775827646, -0.029823655262589455, -0.0040650819428265095, 0.05087638273835182, -0.052446261048316956, 0.010626673698425293, 0.004664377309381962, 0.0003623502270784229, 0.03566928952932358, 0.03470325469970703, -0.0294643547385931, 0.00367676536552608, 0.009676124900579453, -0.0049322014674544334, -0.060784339904785156, -0.013502566143870354, 0.029703348875045776, 0.0024882827419787645, 0.0020073000341653824, 0.015064796432852745, 0.004132697358727455, -0.04225482419133186, -0.025121508166193962, 0.010351378470659256, -0.002532380633056164, -0.026952341198921204, 0.0008804401732049882, -0.02172214165329933, 0.01863083243370056, 0.025266507640480995, 0.05030622333288193, -0.03780815377831459, 0.06140502169728279, -0.02889116294682026, 0.04950737953186035, -0.06527946144342422, 0.013176106847822666, -0.07021935284137726, -0.03224867582321167, -0.02114703878760338, -0.026629839092493057, -0.011958343908190727, 0.02500794269144535, -0.04838760197162628, 0.05756780505180359, 0.008002379909157753, 0.02899164892733097, -0.009041686542332172, 0.03214278817176819, 0.09025091677904129, 0.027236662805080414, 0.030992817133665085, 0.013101741671562195, -0.007149263750761747, -0.029637696221470833, -0.014282221905887127, -0.02262575551867485, 0.011251505464315414, 0.02348870225250721, -0.010939251631498337, -0.01760454848408699, -0.020020952448248863, -0.024574149399995804, -0.06936223804950714, -0.0375441238284111, 0.053226932883262634, -0.020831309258937836, -0.010760573670268059, 0.005390168633311987, 0.038202643394470215, -0.01305394247174263, 0.00016019726172089577, 0.0274906475096941, -0.026283590123057365, -0.006732197478413582, 0.032751526683568954, -0.060629308223724365, -0.026297302916646004, -0.008849862962961197, 0.02704467996954918, 0.035105008631944656, 0.05341688171029091, -0.02242967300117016, -0.004872517194598913, 0.010388270020484924, -0.04030374065041542, -0.02330896072089672, -0.04597824439406395, -0.03428215906023979, 0.0012758333468809724, 0.03975379839539528, -0.03301269933581352, 0.02003445290029049, 0.003078720299527049, 0.015886520966887474, -0.024035343900322914, 0.024469487369060516, 0.04725006967782974, -0.024289436638355255, -0.03226861357688904, -0.007164766546338797, -0.003238161327317357, 0.03493610396981239, 0.018765972927212715, 0.031100470572710037, 0.012401769869029522, 0.026589078828692436 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
2.2 What is a Masked Language Model? MLM enables/enforces bidirectional learning from text by masking (hiding) a word in a sentence and forcing BERT to bidirectionally use the words on either side of the covered word to predict the masked word. This had never been done before! **Fun Fact:** We naturally do this as humans! **Masked Language Model Example:** Imagine your friend calls you while camping in Glacier National Park and their service begins to cut out. The last thing you hear before the call drops is: Friend: “Dang! I’m out fishing and a huge trout just [blank] my line!” Can you guess what your friend said?? You’re naturally able to predict the missing word by considering the words bidirectionally before and after the missing word as context clues (in addition to your historical knowledge of how fishing works). Did you guess that your friend said, ‘broke’? That’s what we predicted as well but even we humans are error-prone to some of these methods. **Note:** This is why you’ll often see a “Human Performance” comparison to a language model’s performance scores. And yes, newer models like BERT can be more accurate than humans! 🤯 The bidirectional methodology you did to fill in the [blank] word above is similar to how BERT attains state-of-the-art accuracy. A random 15% of tokenized words are hidden during training and BERT’s job is to correctly predict the hidden words. Thus, directly teaching the model about the English language (and the words we use). Isn’t that neat? Play around with BERT’s masking predictions: Hosted inference API Fill-Mask Examples Mask token: [MASK] Compute This model can be loaded on the Inference API on-demand. JSON Output Maximize **Fun Fact:** Masking has been around a long time - [1953 Paper on Cloze procedure (or ‘Masking’)](https://psycnet.apa.org/record/1955-00850-001).
[ -0.004255678039044142, -0.04624856263399124, 0.01909690909087658, -0.013301319442689419, 0.0976162925362587, 0.023930974304676056, 0.04006088152527809, 0.07036462426185608, -0.07077362388372421, 0.01499518658965826, -0.08985698968172073, 0.06388305872678757, 0.0013408479280769825, 0.015012265183031559, -0.08074534684419632, 0.013422515243291855, 0.011688279919326305, -0.0030761444941163063, -0.0003669996513053775, -0.03387327119708061, -0.031170858070254326, -0.03889663144946098, 0.09506597369909286, -0.07567238062620163, 0.0706963837146759, -0.009287165477871895, 0.015902210026979446, -0.0635932981967926, -0.022328177466988564, 0.035931482911109924, -0.05425022542476654, 0.030637335032224655, 0.02262955717742443, 0.02629603073000908, -0.018405750393867493, -0.004460114985704422, -0.11302492022514343, 0.017919816076755524, -0.030828308314085007, 0.020940491929650307, -0.0593593455851078, 0.02415238320827484, -0.054425470530986786, 0.017572730779647827, -0.05380115658044815, -0.044573720544576645, -0.14842373132705688, 0.0755566731095314, -0.039881836622953415, -0.04508097842335701, -0.119102843105793, -0.002325496869161725, -0.07010699063539505, 0.006820072885602713, -0.007723458576947451, -0.009422835893929005, -0.04331254959106445, -0.08429396152496338, -0.018755875527858734, -0.038739077746868134, 0.02712671272456646, -0.04672744497656822, -0.010771163739264011, -0.02527247928082943, 0.033952828496694565, 0.028977682814002037, -0.037115368992090225, -0.008390774950385094, -0.052340004593133926, -0.010294684208929539, -0.031520724296569824, -0.040092833340168, -0.10172653943300247, -0.00903295073658228, 0.01668652892112732, -0.06839160621166229, -0.03311678394675255, 0.0030109642539173365, -0.04982484132051468, -0.0413982979953289, -0.05845172703266144, 0.021507252007722855, 0.04693739116191864, 0.04528473690152168, 0.027033163234591484, -0.00849378202110529, 0.05978419631719589, 0.018658636137843132, -0.002585816662758589, 0.05752091109752655, -0.008738675154745579, -0.09641816467046738, -0.04855460673570633, -0.01582188718020916, -0.020032305270433426, -0.022784052416682243, 0.017614662647247314, 0.04525041952729225, -0.07682496309280396, -0.060934290289878845, -0.03233646601438522, -0.11107499897480011, 0.04239383712410927, 0.053572431206703186, -0.08584999293088913, 0.03898781165480614, 0.012235243804752827, -0.018511110916733742, -0.03450366109609604, 0.002490610582754016, 0.01731807366013527, -0.013808231800794601, 0.036574285477399826, 0.033233288675546646, -0.06275644898414612, -0.016509581357240677, 0.007788058836013079, 0.006061933934688568, 0.02462657354772091, 0.008734764531254768, -0.04835120216012001, 0.0761740580201149, 0.07269518822431564, 0.02363954484462738, 0.0008105666493065655, 0.014441544190049171, -0.030019894242286682, 0.04895823821425438, 0.04068971052765846, 0.01827329769730568, 0.06516312807798386, 0.01378773432224989, 0.05008304864168167, 0.04621362313628197, 0.021313302218914032, -0.0021477900445461273, -0.011507336050271988, -0.07141991704702377, 0.030626796185970306, -0.0699203684926033, -0.07348040491342545, 0.025906067341566086, -0.033416446298360825, -0.006262619514018297, 0.050317879766225815, -0.04425971582531929, -0.010982183739542961, 0.023071574047207832, -0.011992384679615498, 0.03298216685652733, -0.060499731451272964, 0.03337126970291138, 0.001847529667429626, -0.07305102050304413, -0.0016236862866207957, 0.03548937290906906, -0.00814678706228733, -0.00998302735388279, -0.0331287644803524, -0.026126038283109665, 0.03387218713760376, 0.0771402046084404, -0.018300427123904228, 0.022059757262468338, 0.027956396341323853, 0.02650783769786358, 0.0012542590266093612, 0.053102683275938034, -0.03095400147140026, 0.05507354065775871, -0.010965309105813503, -0.024950988590717316, 0.08316905051469803, -0.04177797958254814, 0.022694142535328865, 0.029562436044216156, 0.04918071627616882, 0.07401403039693832, 0.01894342713057995, 0.029607851058244705, -0.03291325643658638, 0.057385411113500595, 0.010198238305747509, 0.027552789077162743, 0.026570435613393784, -0.05968508496880531, -0.00872309785336256, -0.05364386737346649, 0.000841147149913013, 0.10536041855812073, -0.08401980251073837, -0.0008209390798583627, 0.06085643544793129, -0.06442411243915558, 0.0043840669095516205, -0.05354081466794014, -0.044225241988897324, 0.1056346744298935, 0.022023195400834084, 0.010131738148629665, 0.08623678982257843, -0.025027941912412643, -0.04941139742732048, -0.015510802157223225, -0.030763855203986168, -0.0002443268313072622, 0.046727504581213, -0.036786600947380066, -0.011437825858592987, -0.018795283511281013, 0.026630913838744164, -0.08133286982774734, 0.002218967769294977, -0.0829031765460968, -0.007414208725094795, -0.052743081003427505, 0.0005329908453859389, 0.06372210383415222, -0.010933086276054382, 0.022492680698633194, 0.11940846592187881, -0.07453769445419312, -0.007239087484776974, -0.05231263116002083, -0.026331614702939987, 0.02426438219845295, 0.017838623374700546, 0.0077423513866961, 0.1060858741402626, -0.0572960302233696, -0.05778299272060394, -0.04377720132470131, 0.10352589935064316, -0.01939241588115692, -0.03234248235821724, -0.011096298694610596, -0.00007008926331764087, -0.005606522783637047, -0.02714177779853344, -0.040182482451200485, 0.015140946954488754, -0.036107420921325684, -0.034122634679079056, 0.07599351555109024, -0.04119323566555977, 0.0009225926478393376, 0.02927897684276104, -0.0372237004339695, -0.03538888692855835, 0.0773392915725708, -0.03766550123691559, 0.014984318986535072, -0.009221392683684826, -0.03037920407950878, 0.056197378784418106, 0.058698687702417374, 0.003919632639735937, -0.003108284203335643, 0.021154826506972313, 0.008075662888586521, -0.00248064030893147, -0.03982614353299141, -0.0204615518450737, -0.03408254683017731, -0.03360079228878021, -0.022439824417233467, 0.015183420851826668, 0.07188989967107773, 0.0024065400939434767, 0.04583055153489113, 0.042594414204359055, -0.04028550907969475, 0.01385729480534792, -0.0038747212383896112, 0.04977716505527496, 0.030127394944429398, 0.027407106012105942, -0.012387221679091454, -0.031405240297317505, -0.024852674454450607, -0.0044580004177987576, -0.012510465458035469, 0.030483227223157883, 0.04763353615999222, 0.0024561116006225348, -0.026382537558674812, -0.022314338013529778, -0.016569124534726143, 0.0023463659454137087, 0.002548073185607791, -0.008729398250579834, 0.05733582377433777, -0.003856335999444127, 0.011156736873090267, 0.012575567699968815, 0.021454893052577972, -0.027418656274676323, 0.011425268836319447, -0.019439540803432465, -0.005900773219764233, -0.01869942620396614, 0.02454965189099312, -0.03425382077693939, -0.0004637068195734173, 0.0355420783162117, 0.042683497071266174, 0.033791378140449524, 0.022987771779298782, -0.08682403713464737, 0.0087293591350317, 0.04538862407207489, -0.04857674241065979, -0.007380672264844179, 0.017034685239195824, 0.06293827295303345, 0.013447982259094715, -0.011325584724545479, 0.033749084919691086, 0.03306018188595772, 0.011543243192136288, 0.011126358062028885, -0.004523277748376131, 0.004957061260938644, -0.007302908226847649, -0.005538050550967455, 0.012583130970597267, 0.0060782176442444324, -0.026600705459713936, -0.0006779473042115569, 0.048200253397226334, 0.019037267193198204, 0.006582177244126797, -0.01623542793095112, 0.039623573422431946, -0.017554594203829765, 0.02155139110982418, 0.04393523558974266, -0.02982204034924507, -0.01916426606476307, -0.014597700908780098, -0.003531071823090315, 0.0015306671848520637, -0.019615385681390762, 0.010288686491549015, 0.011417048051953316, 0.04955901950597763, 0.009459733963012695, 0.044013816863298416, -0.015992701053619385, 0.0008386779809370637, 0.00940535869449377, 0.005382727365940809, -0.014760448597371578, -0.012059248052537441, -0.053492117673158646, -0.05549172684550285, 0.016734654083848, -0.027163080871105194, -0.01894550584256649, -0.04439306631684303, -0.03782422095537186, 0.0334230437874794, 0.007109836209565401, -0.013406883925199509, -0.022310389205813408, -0.00835585780441761, 0.020631959661841393, 0.007317450363188982, -0.009995776228606701, 0.06736472994089127, -0.022925440222024918, -0.03391118347644806, -0.030926324427127838, 0.021218974143266678, 0.04948568716645241, 0.03784573823213577, 0.027802953496575356, 0.01936250738799572, 0.025832293555140495, 0.0017926604487001896, 0.004565381444990635, 0.00415729358792305, -0.006865428760647774, 0.002853738609701395, -0.010234321467578411, 0.007679359056055546, 0.07395467907190323, -0.010103070177137852, -0.03679252043366432, 0.03099406138062477, -0.003049127059057355, 0.005871220491826534, 0.0066592455841600895, -0.026737432926893234, 0.005705144722014666, -0.033518221229314804, -0.01467737928032875, 0.04117068275809288, 0.0003794795193243772, 0.011384177021682262, 0.024973174557089806, 0.011681733652949333, -0.010119610466063023, 0.032726164907217026, 0.006709223613142967, -0.010442067869007587, -0.023356826975941658, -0.00025410123635083437, 0.005771388299763203, -0.0003775556106120348, -0.01117208506911993, -0.023346703499555588, 0.007281459867954254, 0.08310330659151077, -0.035764340311288834, 0.015386171638965607, 0.024111973121762276, -0.0335620641708374, -0.029452169314026833, 0.03890419006347656, -0.0003350749029777944, 0.03651990741491318, 0.014212721958756447, 0.025556957349181175, -0.0356258787214756, -0.0027427570894360542, -0.0011745982337743044, 0.004760949872434139, 0.021874288097023964, 0.01650938019156456, 0.04420918971300125, 0.014987972564995289, 0.045630697160959244, -0.013844228349626064, 0.03618481382727623, 0.028758564963936806, 0.03139208257198334, -0.013062460348010063, -0.025979869067668915, 0.006421459838747978, 0.044848497956991196, -0.01991192251443863, -0.007173824589699507, 0.02493196912109852, -0.017125574871897697, 0.004147807601839304, -0.016317011788487434, -0.05151772126555443, 0.00446609640493989, -0.010478767566382885, 0.010513044893741608, -0.020295768976211548, 0.07913829386234283, -0.010427209548652172, -0.022044511511921883, -0.03264822065830231, -0.006260094232857227, -0.019977113232016563, 0.016136541962623596, 0.010480303317308426, -0.02723327837884426, -0.060749687254428864, 0.01125984825193882, -0.03254106640815735, 0.00883858185261488, 0.04291551560163498, 0.01721872016787529, 0.06210515648126602, 0.05042889714241028, 0.0037521454505622387, -0.03703434392809868, 0.019667787477374077, 0.03204287216067314, -0.014256363734602928, -0.020416567102074623, -0.019442670047283173, -0.008385012857615948, 0.030218560248613358, 0.028486890718340874, -0.025993812829256058, 0.00785246305167675, 0.03199215978384018, 0.006083807907998562, -0.005561338271945715, 0.009290579706430435, -0.027204129844903946, -0.037118930369615555, -0.004841766320168972, 0.005951515398919582, 0.0013420478207990527, -0.015262582339346409, 0.03960459306836128, 0.03594920039176941, 0.03757613152265549, 0.04992238059639931, 0.033488452434539795, 0.0044040014035999775, 0.04159839451313019, 0.01771017536520958, 0.004317756276577711, 0.05266636237502098, -0.034539975225925446, 0.055250950157642365, -0.01322973519563675, -0.03169891983270645, 0.021163009107112885, -0.017176667228341103, 0.044454656541347504, 0.05399806424975395, 0.006769825238734484, -0.03286144509911537, -0.024264270439743996, -0.018305419012904167, -0.01839800551533699, -0.029824791476130486, -0.0321333073079586, -0.03290561959147453, -0.028844499960541725, 0.01615816354751587, 0.016996117308735847, 0.010286912322044373, 0.0404081791639328, -0.016370683908462524, -0.017694225534796715, -0.027674458920955658, 0.03452662006020546, 0.015150795690715313, 0.0817977711558342, 0.048568934202194214, -0.020466111600399017, -0.04269702732563019, 0.019436262547969818, 0.00591698382049799, -0.08300328254699707, 0.0049129631370306015, 0.006050569005310535, 0.005215093493461609, 0.0134766586124897, 0.014038359746336937, 0.02410588413476944, 0.010782957077026367, 0.05232226103544235, -0.041758179664611816, 0.017166852951049805, -0.015330295078456402, -0.004625946749001741, 0.015802985057234764, -0.0167612936347723, -0.0038212421350181103, 0.0009609053959138691, -0.06725997477769852, 0.0004744748002849519, -0.03727361932396889, -0.018953289836645126, 0.052201561629772186, 0.004013788886368275, 0.02213667705655098, 0.0042914231307804585, 0.020985350012779236, -0.0042359190993011, 0.015683438628911972, 0.024879353120923042, 0.010564706288278103, 0.028980083763599396, 0.01444706879556179, 0.049823760986328125, -0.014503508806228638, -0.006726108957082033, 0.02798936516046524, -0.054975301027297974, 0.006031235214322805, 0.029920591041445732, -0.02411511540412903, 0.03620320186018944, 0.0319141261279583, -0.045132871717214584, -0.03251522406935692, 0.028195124119520187, 0.041092511266469955, 0.005207584239542484, -0.02952607534825802, -0.017126377671957016, 0.018975956365466118, -0.006931450217962265, 0.002849986543878913, 0.0671151876449585, -0.03579504042863846, 0.037726420909166336, 0.009285935200750828, 0.005837476346641779, 0.017519615590572357, -0.008432810194790363, -0.004014458507299423, 0.02232886664569378, 0.052712250500917435, -0.02380596101284027, 0.030918050557374954, -0.008019285276532173, -0.025290142744779587, -0.005410445388406515, 0.0025848739314824343, -0.018324676901102066, -0.06449811905622482, 0.01161440834403038, 0.027551257982850075, -0.029359083622694016, 0.003535618307068944, -0.016428567469120026, 0.022369924932718277, 0.010684349574148655, 0.013400734402239323, -0.008737744763493538, 0.050165582448244095, 0.00409550778567791, 0.023607894778251648, 0.010490303859114647, 0.06753122061491013, 0.02340547926723957, -0.002448047511279583, 0.04522154480218887, 0.02856345660984516, 0.010936830192804337, -0.007007872220128775, -0.0026758620515465736, 0.0639948919415474, -0.03889421001076698, 0.0032979913521558046, -0.014158330857753754, 0.032777950167655945, 0.02346673607826233, -0.032895248383283615, 0.031472861766815186, -0.01381278783082962, -0.01819881610572338, 0.012858814559876919, 0.020717822015285492, 0.0024130602832883596, -0.019071223214268684, 0.0022367967758327723, 0.03125618025660515, 0.023919695988297462, -0.05944541469216347, -0.0503583624958992, -0.01990211196243763, -0.0043188100680708885, -0.022418590262532234, -0.055739790201187134, -0.027264419943094254, -0.010755551047623158, -0.022194551303982735, -0.04025590792298317, -0.03021967224776745, 0.023602195084095, -0.018414171412587166, -0.009566227905452251, 0.04575314000248909, -0.02158447541296482, 0.01952500268816948, 0.03416465222835541, -0.017948701977729797, -0.007568350527435541, -0.031601034104824066, -0.013599940575659275, -0.018565412610769272, -0.023869238793849945, -0.024422457441687584, -0.04929808899760246, 0.004421358462423086, 0.04582308977842331, 0.020625630393624306, 0.07564615458250046, 0.005120443180203438, -0.0014611646765843034, -0.017321856692433357, 0.020841557532548904, -0.019727079197764397, 0.007861973717808723, 0.09869247674942017, 0.008216165006160736, -0.014566387049853802, -0.01210684236139059, -0.031352873891592026, -0.0007599461823701859, 0.028664587065577507, 0.008611376397311687, 0.020415760576725006, -0.04192930832505226, -0.025159073993563652, 0.015868742018938065, 0.008977577090263367, 0.044223956763744354, 0.050796203315258026, -0.024540772661566734, 0.035516537725925446, -0.044556472450494766, 0.04087431728839874, -0.046337395906448364, -0.013934780843555927, 0.0022117127664387226, -0.04317361116409302, -0.06597618758678436, 0.013066018931567669, 0.019315537065267563, 0.021647531539201736, -0.024498488754034042, -0.011625056155025959, -0.01848459802567959, -0.01930110715329647, -0.0027184037026017904, -0.013536249287426472, 0.08647140860557556, -0.0054016439244151115, 0.026040323078632355, -0.003223980776965618, 0.00509705999866128, -0.01498366892337799, -0.012273374944925308, 0.05431004986166954, 0.0354260616004467, 0.00008677168807480484, 0.04090604931116104, -0.005525866989046335, 0.013822881504893303, 0.00010367128561483696, -0.037347495555877686, -0.03556457906961441, 0.014138487167656422, -0.0033736207988113165, -0.003857493167743087, 0.03380390256643295, 0.03805215284228325, -0.0022509517148137093, 0.0010712234070524573, -0.000655696727335453, 0.009047172032296658, -0.026354406028985977, 0.0267912857234478, -0.068698950111866, -0.029546502977609634, -0.004070350434631109, -0.003216886194422841, 0.061430394649505615, 0.02378643862903118, 0.025803470984101295, -0.008195149712264538, -0.0028166992124170065, 0.007695240434259176, -0.018989194184541702, -0.00670310202986002, -0.05217059329152107, -0.02131083235144615, 0.008546927943825722, -0.025578662753105164, 0.04172549024224281, 0.0362047404050827, 0.03689415380358696, 0.011769364587962627, -0.014581730589270592, 0.031916555017232895, 0.010929835960268974, 0.0011250972747802734, 0.050226468592882156, -0.01663556508719921, 0.06036676838994026, 0.04499619081616402, 0.0312650203704834, 0.003785194829106331, -0.014024639502167702 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
7.4 Some other BERT Notebooks you might enjoy: [A Visual Notebook to BERT for the First Time](https://colab.research.google.com/github/jalammar/jalammar.github.io/blob/master/notebooks/bert/A_Visual_Notebook_to_Using_BERT_for_the_First_Time.ipynb) [Train your tokenizer](https://colab.research.google.com/github/huggingface/notebooks/blob/master/examples/tokenizer_training.ipynb) +Don't forget to checkout the [Hugging Face Transformers Course](https://huggingface.co/course/chapter1/1) to learn more 🎉
[ 0.004791446030139923, -0.02958822250366211, 0.030937666073441505, -0.02055223472416401, 0.08347320556640625, 0.02720141038298607, 0.010036450810730457, 0.08039061725139618, -0.00549403065815568, -0.06737067550420761, -0.05412263795733452, 0.0445956215262413, -0.00007465202361345291, 0.07120242714881897, 0.04843118041753769, -0.003954118117690086, 0.037544552236795425, -0.020143447443842888, 0.022028746083378792, 0.010731076821684837, -0.023487810045480728, -0.05385332182049751, 0.06727452576160431, -0.002471833722665906, 0.04339851438999176, -0.05987674742937088, 0.03132200986146927, 0.05583121255040169, -0.065407894551754, 0.03535761311650276, -0.08701324462890625, 0.006581468973308802, 0.06303716450929642, -0.011875299736857414, -0.004009653814136982, 0.004280948080122471, -0.08331695944070816, 0.05251091346144676, 0.022121349349617958, 0.010704116895794868, -0.03881668671965599, -0.02596704289317131, -0.007086665835231543, 0.02402254194021225, -0.027775578200817108, -0.005703161936253309, -0.21556244790554047, 0.08779902011156082, -0.0025083045475184917, -0.046201441437006, -0.07451978325843811, 0.12440641224384308, 0.02220880798995495, -0.005476388148963451, -0.016122983768582344, 0.01581611856818199, 0.015511898323893547, -0.049336012452840805, 0.026745622977614403, -0.016892120242118835, 0.06973002851009369, -0.003666279138997197, 0.02808236889541149, 0.050026457756757736, 0.03898085281252861, 0.02163725532591343, -0.03804725781083107, -0.01274581253528595, -0.07473602145910263, -0.005589877255260944, 0.034989409148693085, -0.04795016720890999, -0.05310148373246193, -0.03402833268046379, 0.008781593292951584, -0.04308761656284332, 0.022858625277876854, -0.024219002574682236, -0.008465905673801899, 0.06939136981964111, 0.037129517644643784, -0.009264444001019001, 0.02843516319990158, 0.06874678283929825, 0.02377363108098507, 0.03957463800907135, 0.0241994671523571, -0.01911313459277153, -0.07345031946897507, 0.0650937408208847, -0.04803040251135826, -0.16723577678203583, -0.04322575777769089, -0.012316095642745495, 0.03650100156664848, -0.04440862312912941, -0.007033819332718849, 0.0481564961373806, 0.009012595750391483, -0.032826654613018036, 0.013615780510008335, -0.07049807906150818, 0.021842338144779205, -0.02697645127773285, -0.0691964253783226, 0.01725773699581623, -0.02229706384241581, -0.09824766218662262, 0.00654334481805563, 0.010771650820970535, 0.018995190039277077, -0.05453602597117424, 0.0063323830254375935, 0.11033347249031067, -0.06938056647777557, 0.05356593057513237, 0.028364432975649834, 0.026880448684096336, -0.006701174657791853, 0.015539800748229027, -0.020365968346595764, 0.09217006713151932, 0.08170882612466812, -0.02937064878642559, -0.004279181361198425, 0.04515330493450165, -0.04212944209575653, 0.016937149688601494, -0.019827233627438545, -0.017398184165358543, 0.05199263244867325, -0.033419713377952576, 0.06841502338647842, -0.036270514130592346, 0.014940226450562477, -0.0223075058311224, -0.011031655594706535, -0.11452852189540863, 0.002371078124269843, 0.013669710606336594, -0.024516548961400986, 0.07578031718730927, -0.021990736946463585, 0.06279709190130234, 0.04569823667407036, -0.005114859435707331, -0.10876787453889847, 0.06774447113275528, -0.05250862240791321, 0.010201600380241871, -0.09744088351726532, 0.014972656033933163, -0.021830610930919647, -0.00759948929771781, -0.007845002226531506, 0.04538504779338837, 0.004503373522311449, -0.027242030948400497, -0.05654006078839302, -0.00643420172855258, 0.021656082943081856, 0.046920619904994965, -0.07360276579856873, 0.04737093299627304, -0.024255016818642616, -0.047041043639183044, 0.017899679020047188, 0.017192402854561806, 0.037828728556632996, -0.004413580987602472, 0.056994594633579254, -0.03603877127170563, 0.04220815747976303, 0.00290512852370739, -0.0091270562261343, 0.040268007665872574, 0.06630449742078781, 0.026198619976639748, -0.007635081186890602, -0.0025278343819081783, -0.03577665984630585, 0.04984971508383751, 0.032830119132995605, -0.007582755759358406, 0.017505131661891937, -0.05746548995375633, -0.007081008516252041, 0.005139131564646959, 0.012306655757129192, 0.001802421291358769, -0.03952516242861748, -0.030619777739048004, 0.06838898360729218, -0.012985014356672764, 0.0346757173538208, -0.03352220356464386, -0.019125618040561676, 0.09685954451560974, 0.007804707158356905, 0.026406049728393555, 0.03551197424530983, 0.022014901041984558, -0.0021504671312868595, 0.008109685964882374, -0.015829581767320633, 0.006878720596432686, 0.06701383739709854, -0.07257715612649918, 0.06623023003339767, -0.011402654461562634, 0.009294940158724785, -0.09250851720571518, 0.06827747821807861, -0.06558860093355179, 0.026506494730710983, -0.06484643369913101, -0.024977637454867363, 0.04259713366627693, 0.02329462207853794, -0.011480963788926601, 0.1859155148267746, -0.05504480376839638, 0.03259923309087753, -0.002472315449267626, -0.0074378205463290215, 0.04635560140013695, 0.07203756272792816, 0.0337398536503315, 0.10541462153196335, -0.0670989528298378, -0.06469841301441193, -0.027569757774472237, 0.013594490475952625, 0.05844130739569664, -0.05422244593501091, -0.01975191943347454, 0.010744123719632626, -0.04806823655962944, 0.022858669981360435, -0.03504830226302147, 0.0051228380762040615, -0.018221989274024963, 0.01763692870736122, 0.013959603384137154, -0.029321862384676933, 0.006310943979769945, 0.05949055030941963, 0.05905888229608536, 0.007372199557721615, -0.013500194065272808, -0.07353304326534271, 0.03146679326891899, -0.05816132202744484, -0.02834138460457325, 0.018244681879878044, 0.06544939428567886, -0.009317670948803425, -0.029115362092852592, -0.011403960175812244, 0.05137496441602707, -0.014288798905909061, -0.0239457655698061, -0.0450117327272892, -0.037310048937797546, -0.03276520594954491, -0.021645113825798035, -0.028032205998897552, 0.018899250775575638, 0.015933610498905182, 0.03755723312497139, 0.02570907212793827, -0.012162010185420513, 0.03006286732852459, 0.02204287424683571, 0.01856730878353119, 0.02380436658859253, 0.03997949883341789, 0.0006317489314824343, -0.02567538246512413, -0.017520073801279068, 0.005557982716709375, -0.05982331559062004, 0.058981265872716904, 0.02767237462103367, 0.035400211811065674, -0.009927219711244106, -0.016490058973431587, -0.046484507620334625, -0.014465375803411007, 0.0038362513296306133, -0.015372791327536106, 0.04345651715993881, -0.0018629663391038775, 0.0086686871945858, 0.017541998997330666, 0.011336983181536198, 0.041318606585264206, -0.008406152948737144, -0.008067178539931774, 0.03398782014846802, -0.003517793957144022, 0.022318225353956223, -0.006369670387357473, -0.024834703654050827, -0.02555179037153721, 0.025196656584739685, 0.04190346226096153, -0.005525683984160423, -0.11105760186910629, -0.02743544988334179, 0.01699366234242916, 0.023575324565172195, -0.010351207107305527, -0.03921956568956375, 0.028482364490628242, -0.021762918680906296, -0.033035170286893845, -0.017816727980971336, -0.004849936347454786, -0.008307870477437973, -0.004150225780904293, 0.000502769195009023, -0.011723935604095459, -0.015273516066372395, -0.031359679996967316, 0.01837591640651226, 0.019104955717921257, 0.02799692004919052, -0.053531747311353683, 0.038552138954401016, -0.016414588317275047, -0.015642352402210236, 0.0018347185105085373, -0.03251328319311142, 0.01728602685034275, 0.03776582330465317, 0.05066550523042679, 0.007321569137275219, 0.02380458451807499, -0.011193773709237576, -0.015502777881920338, 0.018962446600198746, -0.03243197128176689, 0.014106673188507557, -0.009548796340823174, -0.0013079880736768246, 0.0035418285988271236, 0.014961784705519676, 0.016658088192343712, 0.005462538916617632, 0.00909570511430502, -0.010150901973247528, 0.01087632030248642, -0.012833215296268463, -0.018273159861564636, 0.01340857706964016, 0.032529622316360474, -0.027774283662438393, -0.010817442089319229, -0.00851861946284771, 0.001857557101175189, 0.022882014513015747, 0.006334730423986912, -0.023779837414622307, -0.0018487625056877732, 0.012491051107645035, 0.027793413028120995, -0.03157360851764679, -0.03934203088283539, 0.008788855746388435, -0.035539690405130386, -0.023679131641983986, -0.0321282297372818, 0.04574756324291229, 0.03806215152144432, 0.04338091239333153, -0.002019742736592889, 0.018475836142897606, -0.004847495350986719, 0.032553594559431076, 0.004412531387060881, 0.0065802475437521935, 0.0014068755554035306, 0.010957157239317894, -0.01680872030556202, -0.018589038401842117, 0.07828003168106079, 0.023530207574367523, -0.032454684376716614, -0.022813385352492332, -0.03967990353703499, -0.014673310332000256, 0.007225649897009134, 0.00015299978258553892, 0.012525569647550583, -0.023169325664639473, 0.015377056784927845, 0.03163456916809082, 0.019018804654479027, -0.010616513900458813, 0.01826830767095089, 0.004390866030007601, 0.0023279639426618814, 0.0016786610940471292, -0.0028084239456802607, -0.01646021567285061, -0.0024728672578930855, 0.03166951984167099, 0.038726549595594406, -0.035338591784238815, -0.03596779704093933, 0.006314670667052269, 0.03236737847328186, 0.047283463180065155, -0.04303579032421112, -0.02472330816090107, 0.019020693376660347, -0.005182069260627031, 0.023969603702425957, -0.007451317273080349, 0.008166234940290451, 0.0033760450314730406, 0.010607189498841763, 0.042050786316394806, 0.008481216616928577, -0.02599562518298626, -0.0526045523583889, 0.011858743615448475, -0.031570639461278915, 0.009657245129346848, -0.010794230736792088, -0.007019663229584694, -0.010644986294209957, 0.002481337171047926, 0.028002802282571793, 0.041890181601047516, -0.0012761842226609588, -0.005771953612565994, -0.027628937736153603, -0.053044311702251434, -0.00405597360804677, 0.020286697894334793, 0.03322596475481987, 0.015260827727615833, -0.034298259764909744, 0.009670756757259369, 0.000637490360531956, -0.04985210672020912, -0.026631610468029976, -0.004791408311575651, 0.0657128170132637, -0.05308299884200096, 0.02158370055258274, 0.016596108675003052, -0.05965311452746391, -0.011322986334562302, -0.020168550312519073, 0.03123454563319683, 0.03795082867145538, -0.02264203317463398, -0.03949245810508728, 0.024644197896122932, 0.03228716179728508, -0.02026447094976902, -0.012529964558780193, 0.027651866897940636, 0.025220045819878578, 0.05650312080979347, -0.010684316046535969, 0.014579486101865768, -0.03625388443470001, 0.01222284696996212, -0.00932337436825037, -0.006470208056271076, 0.005362718366086483, -0.05352634936571121, 0.027901610359549522, -0.0035118036903440952, 0.011968281120061874, -0.011527126654982567, 0.0218025054782629, -0.015326788648962975, 0.005467019975185394, 0.07390575110912323, 0.04088848829269409, 0.020297570154070854, 0.006890750024467707, -0.0003882247838191688, -0.03606388345360756, -0.013771750032901764, 0.01666334457695484, -0.014697066508233547, -0.0026604023296386003, 0.024135684594511986, 0.044307924807071686, 0.03782877326011658, -0.006745817605406046, 0.028910920023918152, -0.03586211055517197, -0.03686242923140526, 0.006168556399643421, -0.0286552794277668, -0.022118939086794853, -0.021750297397375107, -0.028995929285883904, 0.008511848747730255, -0.012460717000067234, -0.004872343968600035, 0.004034646321088076, 0.022367820143699646, -0.03603930398821831, -0.005174904130399227, 0.033538706600666046, 0.02040397934615612, -0.0009212748846039176, -0.055700477212667465, 0.018728259950876236, -0.04841315373778343, 0.00347679085098207, -0.012807806953787804, 0.00004810748578165658, -0.020137665793299675, 0.015477930195629597, -0.0169240552932024, -0.008459213189780712, 0.001277684117667377, 0.04475831240415573, 0.053408507257699966, -0.0011886638822034001, 0.021666983142495155, -0.03383081778883934, -0.0007641849806532264, 0.011783216148614883, -0.01288263313472271, -0.005215219222009182, 0.02520449459552765, -0.007285992614924908, 0.036991849541664124, 0.047936778515577316, 0.011066991835832596, -0.0012627745745703578, 0.06367220729589462, -0.013810588978230953, -0.004234251566231251, -0.042395323514938354, 0.02578004077076912, 0.015585114248096943, -0.01736825332045555, 0.011363150551915169, -0.03676965460181236, -0.04834283888339996, 0.013832238502800465, -0.03870838135480881, 0.0017789026023820043, 0.08647096902132034, 0.007281570695340633, 0.03487486019730568, 0.038440462201833725, 0.033648379147052765, -0.0007605219725519419, -0.03604438900947571, -0.006642208434641361, 0.043682582676410675, 0.03244389593601227, 0.017361633479595184, 0.021951178088784218, 0.00008531865751137957, 0.033546123653650284, 0.017025165259838104, -0.06220388412475586, 0.038501203060150146, 0.006187631748616695, -0.04123501479625702, 0.01288125291466713, -0.021291280165314674, -0.026949578896164894, -0.0201615821570158, 0.034104157239198685, 0.03649124503135681, 0.03562340885400772, -0.025868933647871017, -0.009600748308002949, -0.002160049509257078, -0.025688640773296356, 0.03082532063126564, 0.06527066975831985, -0.025572137907147408, 0.06324432045221329, 0.02681894600391388, 0.02063922956585884, 0.004682112485170364, 0.021306106820702553, 0.016604946926236153, 0.013955262489616871, 0.030581273138523102, 0.00207035755738616, 0.03345074504613876, 0.010162513703107834, -0.010613266378641129, -0.03422268107533455, -0.03643154725432396, -0.02142106369137764, -0.01577344909310341, 0.005094226915389299, 0.03218076378107071, -0.01686338521540165, -0.0057017384096980095, -0.018899861723184586, 0.04741038754582405, 0.06108519807457924, 0.04070311039686203, -0.0389038510620594, 0.0251533854752779, 0.04316823557019234, 0.012602602131664753, -0.013907723128795624, 0.029856383800506592, 0.029891399666666985, 0.006058625876903534, 0.06448943167924881, 0.039024993777275085, 0.0196430254727602, 0.028776509687304497, -0.03297646716237068, 0.03730354830622673, -0.004874076694250107, -0.019961802288889885, -0.010334065183997154, 0.006888772826641798, -0.04914461821317673, -0.013847623020410538, 0.00013054738519713283, -0.063695527613163, 0.001532575930468738, 0.02119476906955242, -0.00988590344786644, 0.004665639717131853, -0.007006858009845018, -0.006558771710842848, 0.047851916402578354, 0.01708412542939186, -0.01394797582179308, -0.002014514757320285, 0.03234976902604103, -0.02561045065522194, -0.0233006589114666, -0.022076847031712532, -0.022054582834243774, -0.021321143954992294, -0.01516185887157917, -0.04904720559716225, -0.004063691943883896, 0.00007165285205701366, -0.022207900881767273, 0.0026938063092529774, 0.04678168520331383, -0.030243197456002235, 0.01231439970433712, -0.0030832819174975157, 0.011198928579688072, -0.02082456648349762, 0.022393111139535904, 0.013557099737226963, -0.011017389595508575, 0.020920898765325546, -0.08639680594205856, 0.03507128730416298, -0.0005320784403011203, -0.0014787178952246904, 0.03604522719979286, 0.04575875774025917, -0.01951581798493862, -0.0564391165971756, -0.000031465318897971883, 0.0061725471168756485, -0.04975297674536705, 0.015310109592974186, 0.033402591943740845, -0.01852058619260788, -0.0004181327822152525, -0.01494379248470068, 0.0011519994586706161, -0.01873723603785038, 0.015237517654895782, 0.02504797838628292, 0.009494205005466938, -0.03940955922007561, -0.024964503943920135, 0.0282369963824749, 0.02717065066099167, 0.0023609488271176815, 0.0543564036488533, -0.0175511185079813, 0.007887609302997589, -0.049366697669029236, 0.008000357076525688, -0.014315555803477764, -0.021002627909183502, -0.06525859981775284, -0.03882762789726257, -0.020592443645000458, -0.026504652574658394, -0.00831704679876566, 0.02195541188120842, -0.04049663618206978, 0.013572314754128456, -0.015240953303873539, -0.012857066467404366, -0.019882038235664368, -0.000833026017062366, 0.055098049342632294, 0.007760289590805769, 0.018426816910505295, 0.0022135532926768064, -0.019940344616770744, 0.007793105207383633, -0.009529354982078075, 0.001545368111692369, 0.04340577498078346, 0.0488564595580101, -0.010001654736697674, -0.013857209123671055, -0.01602848619222641, 0.0020671342499554157, -0.03621582314372063, 0.020778430625796318, -0.005576143506914377, -0.009012621827423573, -0.010210626758635044, -0.005826262291520834, 0.03329046443104744, -0.004086375702172518, 0.03473837673664093, 0.011167500168085098, -0.04101448133587837, -0.0076354388147592545, 0.027189550921320915, -0.053152307868003845, -0.03486313670873642, -0.008181850425899029, -0.039894938468933105, 0.01169259287416935, 0.011426189914345741, -0.0017401622608304024, -0.02213986963033676, -0.05027206987142563, -0.020118340849876404, -0.004721970297396183, -0.04790619760751724, -0.004655338358134031, 0.014423667453229427, 0.0033159442245960236, -0.04389642924070358, -0.04407208785414696, 0.03230363130569458, 0.01864253729581833, -0.0195330698043108, -0.01754959113895893, 0.030872799456119537, 0.016150929033756256, -0.02479463443160057, 0.02606489323079586, 0.003928489051759243, 0.04861334338784218, 0.01515965536236763, 0.007094104308634996, 0.004458481911569834, 0.009985138662159443 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
2.1 Large amounts of training data A massive dataset of 3.3 Billion words has contributed to BERT’s continued success. BERT was specifically trained on Wikipedia (\~2.5B words) and Google’s BooksCorpus (\~800M words). These large informational datasets contributed to BERT’s deep knowledge not only of the English language but also of our world! 🚀 Training on a dataset this large takes a long time. BERT’s training was made possible thanks to the novel Transformer architecture and sped up by using TPUs (Tensor Processing Units - Google’s custom circuit built specifically for large ML models). —64 TPUs trained BERT over the course of 4 days. **Note:** Demand for smaller BERT models is increasing in order to use BERT within smaller computational environments (like cell phones and personal computers). [23 smaller BERT models were released in March 2020](https://github.com/google-research/bert). [DistilBERT](https://huggingface.co/docs/transformers/model_doc/distilbert) offers a lighter version of BERT; runs 60% faster while maintaining over 95% of BERT’s performance.
[ -0.023633453994989395, -0.00939214788377285, 0.01848665066063404, -0.029667029157280922, 0.016148507595062256, 0.039289411157369614, 0.035914164036512375, 0.10525520145893097, -0.0014655768172815442, -0.01772342622280121, -0.0848558098077774, 0.0491696335375309, -0.00582768302410841, 0.05995086580514908, 0.014070196077227592, -0.03779913857579231, 0.02406073734164238, -0.013545415364205837, -0.030965786427259445, 0.006830725818872452, -0.022232744842767715, -0.04997222125530243, 0.08556612581014633, -0.019368812441825867, 0.03559979423880577, 0.01182463951408863, -0.015107588842511177, -0.04281173273921013, 0.014676414430141449, -0.029076920822262764, -0.1154380515217781, -0.015994276851415634, -0.015470067039132118, -0.000034223052352899686, -0.06596467643976212, 0.02475585788488388, -0.09147786349058151, 0.10450439900159836, 0.04628146439790726, -0.047313202172517776, -0.008648325689136982, 0.015718726441264153, -0.09664411842823029, 0.07100606709718704, -0.004071991425007582, 0.006827444303780794, -0.11934199184179306, 0.05875854939222336, 0.003525691805407405, -0.02718563750386238, -0.12498430907726288, 0.04775906726717949, -0.005936428904533386, 0.060967087745666504, 0.01564580388367176, 0.025458719581365585, 0.03539291396737099, -0.03092317283153534, 0.01037027407437563, -0.03042599931359291, 0.012261155061423779, -0.010408501140773296, 0.05421506613492966, -0.003311523934826255, 0.040653061121702194, -0.014759130775928497, -0.03732052817940712, 0.018022511154413223, -0.0825166404247284, 0.02296018972992897, 0.04230769723653793, -0.05786632373929024, -0.0711175799369812, 0.0035298916045576334, -0.08773200958967209, -0.006631259806454182, 0.04797450453042984, 0.005007810425013304, 0.02907676436007023, -0.012290668673813343, -0.04283957928419113, 0.02923511527478695, -0.007210623938590288, -0.00009365188452647999, 0.02211555279791355, 0.014033585786819458, 0.0881669670343399, -0.030278082937002182, -0.10002759099006653, 0.03560040146112442, 0.0013485719682648778, -0.15726691484451294, -0.00840035267174244, -0.022212158888578415, 0.04376206174492836, -0.04132155701518059, -0.012367496266961098, 0.0005050014588050544, -0.018755266442894936, -0.013184227049350739, -0.008284799754619598, -0.06261958926916122, 0.031738732010126114, -0.019296744838356972, -0.09915854036808014, 0.01687462627887726, -0.0024287549313157797, -0.10005486011505127, 0.009517690166831017, 0.01404690369963646, 0.013358311727643013, -0.03910226747393608, -0.05495968833565712, 0.024634849280118942, -0.07311856001615524, 0.036712780594825745, -0.006726786028593779, 0.014813779853284359, 0.017333250492811203, 0.036138229072093964, -0.05322371423244476, 0.044854093343019485, 0.020419664680957794, -0.0052500138990581036, 0.0014447566354647279, 0.023932479321956635, -0.03282845765352249, 0.005493144504725933, 0.028706789016723633, -0.031160706654191017, 0.06942576915025711, -0.0010949517600238323, 0.07559631019830704, -0.0035311803221702576, 0.004935822915285826, 0.03497437760233879, -0.031844362616539, -0.0026888081338256598, -0.03378407657146454, 0.019954925402998924, -0.011773754842579365, 0.09043130278587341, -0.04463157430291176, -0.0009388934704475105, 0.06581252068281174, 0.00570168811827898, -0.09396445006132126, 0.05200231820344925, -0.03884432464838028, -0.018636004999279976, -0.10515962541103363, 0.031236397102475166, -0.040205296128988266, -0.05135396867990494, 0.12268216162919998, 0.05610262602567673, 0.0014188807690516114, -0.054713405668735504, -0.03669360280036926, -0.0020251264795660973, -0.03371759504079819, 0.03317105397582054, -0.02404927648603916, -0.016150379553437233, 0.02640959434211254, -0.10229987651109695, 0.01255993265658617, 0.07149002701044083, -0.0032682656310498714, 0.0009492926765233278, -0.010622416622936726, -0.018477806821465492, 0.0672181248664856, 0.012595930136740208, -0.026681281626224518, 0.04580997675657272, 0.037774816155433655, 0.02250448614358902, -0.0046848636120557785, -0.013479937799274921, -0.04601242393255234, 0.031174886971712112, 0.007863471284508705, 0.036662496626377106, 0.04354696720838547, -0.045252636075019836, 0.06575668603181839, -0.0405200719833374, 0.007776375859975815, 0.020861001685261726, 0.019256457686424255, -0.04044465348124504, 0.05789636820554733, -0.013040846213698387, 0.01733570359647274, -0.02569832094013691, 0.0038621388375759125, 0.06947382539510727, 0.03621520847082138, 0.047421928495168686, 0.013814905658364296, -0.03769000619649887, 0.026300890371203423, -0.0045761242508888245, 0.0004008668183814734, -0.013406231068074703, 0.044370394200086594, -0.0188856553286314, 0.018314402550458908, -0.046689968556165695, 0.04622317850589752, -0.1300332397222519, 0.015447748824954033, -0.08308959007263184, -0.0365084707736969, -0.132097065448761, 0.06640110164880753, 0.01781403087079525, 0.044556159526109695, -0.025835730135440826, 0.14939026534557343, -0.048412736505270004, -0.009650252759456635, 0.025590354576706886, -0.005778233055025339, -0.01870761625468731, 0.03330576419830322, 0.0014885833952575922, 0.10093329101800919, -0.08026137202978134, -0.055934321135282516, -0.1046205535531044, 0.05291645601391792, -0.008562132716178894, 0.008112861774861813, -0.08999215066432953, -0.013473113998770714, -0.007678092923015356, -0.0017233858816325665, -0.022095130756497383, -0.025684239342808723, 0.006398817989975214, 0.03200284019112587, 0.06857488304376602, -0.02465023659169674, -0.04011550173163414, 0.031127095222473145, 0.04398369416594505, -0.005995993036776781, -0.03214128315448761, -0.05391265079379082, 0.03714202716946602, -0.03457047790288925, 0.016981421038508415, 0.00952586717903614, 0.027880731970071793, 0.010931228287518024, -0.028660308569669724, -0.015919968485832214, 0.06001763045787811, -0.01906018890440464, -0.0034673786722123623, -0.03774561360478401, -0.0036433248315006495, 0.0068405731581151485, -0.044240765273571014, -0.05172739923000336, -0.015349073335528374, 0.0036315140314400196, -0.004489402752369642, -0.00003833134542219341, -0.045324087142944336, 0.003732031676918268, 0.01365038100630045, 0.03977981209754944, 0.038815610110759735, 0.02308627963066101, -0.006184067577123642, -0.03523194044828415, -0.05046841502189636, -0.012203602120280266, -0.013483822345733643, 0.03051314875483513, -0.0007924235542304814, -0.005083337891846895, 0.006541561800986528, 0.015443088486790657, -0.06763015687465668, -0.04002336412668228, 0.017120100557804108, -0.011921570636332035, 0.0195224117487669, -0.0062299869023263454, -0.0496608130633831, 0.035685740411281586, 0.010361135937273502, -0.0027493159286677837, -0.009313174523413181, -0.004125396721065044, 0.03370087966322899, -0.010057187639176846, 0.00624622218310833, -0.003094496438279748, -0.024234017357230186, 0.012006785720586777, 0.0130797503516078, 0.0069139264523983, 0.057037483900785446, -0.08703871071338654, 0.01250127051025629, 0.021602988243103027, -0.02176007069647312, 0.0003705834096763283, -0.015767527744174004, 0.05382425710558891, -0.0003306975995656103, -0.016811028122901917, 0.013600441627204418, 0.00016094441525638103, 0.028357720002532005, 0.0021864434238523245, 0.010489569045603275, -0.014766222797334194, 0.038713499903678894, -0.02875402942299843, 0.00543071236461401, 0.0072443196550011635, 0.012019340880215168, -0.023593731224536896, 0.011518298648297787, -0.008386673405766487, 0.01766030490398407, -0.013720610179007053, 0.0093980822712183, -0.024340840056538582, 0.018855148926377296, 0.04864772409200668, -0.005672812927514315, 0.01300829742103815, -0.03699391335248947, -0.016067272052168846, 0.010517572984099388, -0.024849485605955124, -0.007022111676633358, -0.0008413410396315157, 0.0627468079328537, 0.012181108817458153, 0.0380374938249588, 0.002110583707690239, -0.024229757487773895, -0.0016701126005500555, 0.0019454486900940537, 0.02983914688229561, 0.00565396947786212, -0.0134741785004735, -0.026613490656018257, 0.002125069033354521, 0.007243386469781399, -0.008852830156683922, 0.001130743301473558, -0.03771451488137245, 0.03350349888205528, 0.010365866124629974, 0.001370729529298842, 0.028435204178094864, -0.02312372997403145, -0.006895552389323711, -0.026039298623800278, 0.03258087858557701, 0.0586557500064373, -0.034992728382349014, -0.01178926881402731, -0.0012578339083120227, 0.02001991681754589, 0.03663596138358116, 0.009083842858672142, -0.024360958486795425, 0.03898125886917114, -0.01669473759829998, 0.031280938535928726, -0.0004232450155541301, 0.0005573222297243774, -0.0249776691198349, 0.021732810884714127, 0.007848655804991722, -0.0035715943668037653, 0.07994303852319717, 0.04399753734469414, -0.06416159868240356, 0.0031940422486513853, -0.04898769035935402, -0.00853784941136837, 0.023408474400639534, 0.020362865179777145, 0.013753640465438366, -0.043689265847206116, 0.031039884313941002, 0.0380181148648262, -0.007248940411955118, -0.024286245927214622, -0.025813061743974686, 0.04776137322187424, 0.002247184980660677, -0.001737623824737966, 0.01870584674179554, 0.035283926874399185, -0.016504233703017235, 0.0014321340713649988, 0.043868210166692734, -0.03682572394609451, -0.010854260995984077, -0.015065794810652733, 0.008632740005850792, 0.021905124187469482, -0.03664793074131012, -0.016495315358042717, 0.034909527748823166, 0.008686605840921402, -0.006230827420949936, 0.021882174536585808, -0.030491041019558907, -0.0026309520471841097, 0.025323456153273582, 0.041974589228630066, -0.01504690945148468, 0.0002766342367976904, -0.04236544296145439, 0.0237882100045681, -0.011170606128871441, 0.05520159378647804, -0.009930144995450974, 0.01408638060092926, 0.021303115412592888, 0.021220840513706207, 0.015108820982277393, 0.018406806513667107, 0.009471183642745018, -0.027367003262043, -0.028375308960676193, -0.03171316161751747, 0.025847960263490677, 0.030733823776245117, -0.022880293428897858, 0.01022348552942276, 0.012151787057518959, -0.014944110997021198, -0.02280532754957676, -0.0418531596660614, -0.007478442508727312, 0.02469984069466591, 0.014815566129982471, -0.04582172632217407, 0.018889816477894783, -0.021767131984233856, -0.015903856605291367, -0.028935059905052185, -0.035580020397901535, 0.0047690910287201405, 0.024793516844511032, 0.00012621427595149726, -0.04488575458526611, 0.02798788622021675, 0.024406032636761665, -0.020147457718849182, -0.004801503382623196, 0.08024366199970245, -0.0043790824711322784, 0.05188542604446411, -0.041020847856998444, -0.0074775200337171555, -0.03204658627510071, 0.012173541821539402, 0.03225567936897278, 0.006297669373452663, 0.036109864711761475, -0.02462564967572689, 0.005945660639554262, 0.009172528982162476, 0.008098931051790714, 0.033497925847768784, -0.039799559861421585, -0.032538458704948425, 0.007648711558431387, 0.02513500675559044, -0.01955953799188137, 0.024439457803964615, -0.006341729313135147, 0.01935494691133499, -0.028392760083079338, 0.01170740183442831, -0.04312394931912422, 0.023594101890921593, 0.03042615018785, 0.03170537203550339, 0.052828215062618256, 0.09094095230102539, -0.013942409306764603, 0.030890824273228645, 0.007358144037425518, -0.011883184313774109, -0.02103675715625286, -0.0025778983253985643, -0.02848186157643795, -0.02944892831146717, 0.006366944871842861, 0.005548274144530296, 0.0023694869596511126, 0.00416933000087738, 0.019083650782704353, 0.04274759069085121, -0.014535970985889435, 0.006692690309137106, 0.04071502760052681, 0.008697890676558018, -0.014874955639243126, -0.048283208161592484, 0.03401928395032883, -0.029258081689476967, -0.01898854970932007, 0.00871060136705637, 0.014686085283756256, 0.03797711059451103, -0.015549731440842152, -0.032060328871011734, -0.022155415266752243, 0.05479482561349869, 0.020163699984550476, 0.013574554584920406, -0.013338680379092693, 0.013513718731701374, -0.009182560257613659, 0.0012251944281160831, 0.01865190640091896, -0.05095721408724785, 0.02928108163177967, -0.006897776387631893, 0.024092474952340126, -0.000882430118508637, 0.04502006620168686, -0.022580737248063087, 0.021073825657367706, 0.06653649359941483, 0.011082067154347897, -0.006047523580491543, -0.010459640994668007, 0.03204125538468361, 0.03814569488167763, 0.020902592688798904, 0.010038296692073345, -0.0015214089071378112, -0.05355764925479889, 0.02370479144155979, -0.04660571739077568, -0.02006307989358902, 0.06878641247749329, 0.01573292352259159, 0.01751882955431938, -0.016241060569882393, -0.009442931972444057, 0.028435174375772476, -0.024425383657217026, 0.02020801417529583, 0.027118848636746407, 0.046876177191734314, 0.03577688708901405, 0.013132591731846333, 0.02959538996219635, 0.01899665594100952, 0.0033721444196999073, -0.027407241985201836, 0.049212221056222916, 0.03455805405974388, -0.025508590042591095, -0.006577369756996632, -0.0040631103329360485, -0.03850272670388222, -0.0014502605190500617, 0.056100524961948395, 0.0038150723557919264, 0.032197073101997375, -0.01456014160066843, -0.035447683185338974, -0.020297283306717873, -0.0343521349132061, -0.013904997147619724, 0.051820166409015656, -0.0009978804737329483, 0.04714271053671837, 0.028965052217245102, 0.016319090500473976, 0.09575872123241425, -0.017993411049246788, -0.038596346974372864, 0.04055936262011528, 0.046758756041526794, 0.010095746256411076, 0.0228749867528677, 0.018887687474489212, -0.027372274547815323, -0.05068132281303406, -0.0465221144258976, 0.0291889775544405, -0.029185451567173004, -0.018410295248031616, 0.03961571678519249, -0.03206911310553551, 0.003931745421141386, 0.010187698528170586, 0.04383769631385803, 0.0401688776910305, 0.04518590494990349, 0.005154917947947979, 0.047589559108018875, 0.02024802193045616, 0.015060456469655037, 0.012376359663903713, 0.02856723964214325, -0.010656428523361683, 0.02402728796005249, 0.019322412088513374, 0.05369315296411514, 0.05386035144329071, 0.00833902321755886, -0.049126479774713516, -0.011783046647906303, -0.02318873256444931, 0.013732153922319412, 0.02435782551765442, 0.01101215835660696, -0.006486489903181791, 0.004504101816564798, 0.012940892018377781, -0.0525340810418129, 0.061840448528528214, -0.013402081094682217, -0.00594272930175066, -0.01983579248189926, -0.04654380679130554, -0.018372224643826485, 0.044403109699487686, -0.004330330528318882, -0.04773855209350586, -0.033891331404447556, -0.04479959234595299, 0.012848170474171638, 0.03901887312531471, -0.01360681839287281, -0.02229291759431362, -0.016430208459496498, -0.03329366073012352, 0.011159173212945461, 0.01750040054321289, -0.019028333947062492, -0.0004109672154299915, 0.017838232219219208, -0.00037348936893977225, 0.0042184749618172646, 0.0250043086707592, 0.006575381383299828, 0.0015948459040373564, -0.04219018295407295, 0.03243624418973923, 0.010342997498810291, -0.030433693900704384, 0.021750736981630325, -0.04140191897749901, -0.013203377835452557, -0.020578645169734955, 0.008115243166685104, 0.05602702870965004, 0.07263541221618652, 0.005959070287644863, -0.015060042962431908, -0.01004980131983757, -0.032349810004234314, -0.058742959052324295, 0.05046353489160538, 0.058789096772670746, -0.01737300120294094, 0.0008512777858413756, -0.0041723777540028095, -0.03004135936498642, -0.04383951425552368, 0.005630522035062313, 0.04556119069457054, -0.04253612086176872, -0.00643808301538229, -0.022872718051075935, -0.00046880877926014364, 0.0006475747795775533, -0.0004252200305927545, 0.047295019030570984, 0.005023861303925514, 0.010581238195300102, -0.03813425824046135, 0.05114453658461571, -0.00390448747202754, -0.01609112322330475, -0.01659850776195526, -0.06987956166267395, -0.03198598697781563, -0.004388465546071529, -0.011072427034378052, -0.0001624286378500983, -0.03576607257127762, 0.001878672163002193, -0.031182680279016495, 0.01800510287284851, -0.0011833530152216554, 0.03714340925216675, 0.050111062824726105, 0.021399646997451782, 0.033742811530828476, 0.023324577137827873, -0.01168222725391388, -0.013660668395459652, 0.0006381617859005928, -0.012832253240048885, 0.03548296540975571, 0.025196414440870285, -0.026880919933319092, -0.016761068254709244, -0.05264166742563248, 0.005674208980053663, -0.045385271310806274, 0.030337078496813774, 0.023444540798664093, 0.00939640961587429, -0.015419933013617992, 0.027079349383711815, 0.03192182257771492, -0.0017208688659593463, 0.05412289872765541, -0.029128888621926308, -0.03134030103683472, 0.012304502539336681, -0.0012154290452599525, -0.05095786601305008, -0.02521534077823162, 0.005980904214084148, 0.008638741448521614, 0.07408389449119568, 0.032387200742959976, 0.01467725820839405, 0.007604079786688089, -0.010045990347862244, 0.008788657374680042, 0.015003453008830547, -0.050188664346933365, -0.013717439956963062, -0.008577704429626465, 0.013489519245922565, -0.02939963899552822, 0.014145661145448685, 0.04839610680937767, 0.003457899671047926, 0.007221894804388285, 0.004401571117341518, 0.006609219592064619, 0.009119093418121338, -0.026706576347351074, 0.015377399511635303, -0.021189486607909203, 0.016567664220929146, 0.048867709934711456, -0.0011062637204304338, -0.00027524898177944124, -0.002053829375654459 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
7.1 Install Transformers First, let's install Transformers via the following code: ```python !pip install transformers ```
[ 0.014156880788505077, 0.02675124630331993, 0.10495251417160034, 0.03750491887331009, 0.05341062322258949, 0.03357479348778725, 0.026844890788197517, 0.06030742824077606, 0.006231988780200481, -0.024830589070916176, -0.044952698051929474, 0.10149383544921875, -0.022927556186914444, 0.07446308434009552, 0.034735746681690216, -0.0064780316315591335, 0.0330267995595932, 0.01593053713440895, -0.055022500455379486, 0.020526617765426636, 0.015267843380570412, -0.04121321067214012, 0.05445962771773338, 0.002697013085708022, 0.008117685094475746, -0.07757506519556046, 0.006396496668457985, 0.03030182048678398, -0.08528626710176468, 0.03956278786063194, -0.09213422238826752, -0.0136308828368783, 0.024580087512731552, -0.02948739193379879, -0.06195276230573654, 0.022099342197179794, -0.09569615870714188, 0.0028791390359401703, 0.05895805358886719, -0.04088938236236572, 0.03129228949546814, -0.02938881330192089, -0.057170189917087555, -0.01004341896623373, -0.01109585352241993, 0.0025623468682169914, -0.21524745225906372, 0.09994222968816757, -0.031969550997018814, -0.014640916138887405, -0.04653150215744972, 0.05382896959781647, 0.007758917286992073, -0.06103576719760895, 0.024307958781719208, 0.01825861446559429, -0.04078599810600281, -0.0187233854085207, -0.00742572033777833, 0.052977077662944794, 0.06361027806997299, 0.039042241871356964, -0.010692737996578217, 0.0506768636405468, 0.00902250874787569, 0.020974628627300262, -0.02444605715572834, 0.043963342905044556, -0.054831840097904205, -0.06955372542142868, 0.014543536119163036, -0.061068616807460785, -0.04234592244029045, -0.03690359741449356, 0.016019349917769432, -0.043662361800670624, 0.0017233826220035553, 0.048857104033231735, 0.055574461817741394, 0.09052223712205887, 0.04253731667995453, 0.03187086060643196, 0.05713165923953056, 0.0787266194820404, 0.04029623791575432, 0.002688200445845723, 0.06111729145050049, -0.007607817184180021, -0.040879279375076294, 0.08411680161952972, -0.010087503120303154, -0.09340272843837738, -0.0704461932182312, -0.029902921989560127, 0.0205420833081007, -0.021689273416996002, -0.010469048283994198, 0.013015974313020706, -0.04350821673870087, 0.022606708109378815, -0.030247511342167854, -0.009785373695194721, 0.05222829058766365, -0.046676140278577805, 0.012156033888459206, -0.019167374819517136, -0.009241563268005848, -0.052625201642513275, 0.0009409316699020565, -0.010475150309503078, 0.008836568333208561, -0.055646251887083054, 0.05124271288514137, 0.050291892141103745, -0.0009710976737551391, 0.0930122509598732, 0.005940825212746859, -0.03158790245652199, 0.02281940169632435, 0.018017014488577843, 0.0036831980105489492, 0.07628799229860306, 0.040413543581962585, 0.014036416076123714, 0.041652873158454895, 0.08333729207515717, -0.008374660275876522, 0.027903888374567032, -0.03430039435625076, -0.038321323692798615, 0.034906789660453796, 0.0042845094576478004, 0.03752005472779274, -0.02553694322705269, -0.018918154761195183, -0.078278087079525, 0.04664256051182747, 0.012229697778820992, 0.004953373223543167, -0.038602106273174286, -0.006984651554375887, 0.07099878787994385, -0.01050988957285881, 0.10295432060956955, -0.019065089523792267, -0.018798446282744408, -0.11424674093723297, 0.05692749097943306, -0.011128164827823639, 0.04411717504262924, -0.004483278840780258, 0.05976438522338867, -0.049541767686605453, -0.03191334381699562, 0.01461512316018343, 0.05362251028418541, 0.016159523278474808, 0.013845030218362808, -0.10569950938224792, -0.08286181092262268, 0.008656785823404789, -0.01375283021479845, -0.039497289806604385, -0.01567382737994194, 0.0420670285820961, -0.10624610632658005, 0.007982831448316574, 0.00963376834988594, 0.06627754867076874, 0.02083338424563408, -0.011841784231364727, -0.06672353297472, 0.043219152837991714, 0.012889347039163113, -0.022576939314603806, 0.008304436691105366, 0.04108162969350815, 0.041952334344387054, -0.00042493187356740236, -0.03421221673488617, 0.034476425498723984, 0.06639186292886734, -0.0733165442943573, 0.0488036647439003, 0.03246770799160004, -0.009721015579998493, 0.009492943063378334, -0.01329118199646473, 0.06633502244949341, 0.016856757923960686, -0.05577978119254112, -0.09349481016397476, 0.054024938493967056, 0.014396026730537415, 0.07045617699623108, -0.001132022705860436, -0.04265657812356949, 0.07131694257259369, 0.058011315762996674, 0.07381463795900345, -0.011063193902373314, -0.0220591239631176, 0.02940547838807106, 0.00138613220769912, -0.005769765470176935, 0.07620688527822495, 0.008185653947293758, -0.0856182724237442, 0.03962644189596176, 0.030375922098755836, 0.022114917635917664, -0.06930898129940033, 0.04694812372326851, -0.0754234716296196, -0.016462821513414383, -0.057735998183488846, -0.03603334352374077, 0.01034404244273901, 0.03693392500281334, 0.021416496485471725, 0.0797329843044281, 0.00961053092032671, 0.024737339466810226, -0.06169690564274788, -0.033819299191236496, 0.0631721243262291, 0.11273705214262009, -0.0017470578895881772, 0.07447795569896698, -0.08728139847517014, -0.010929123498499393, -0.028704028576612473, -0.027699945494532585, 0.07810171693563461, -0.001753778662532568, -0.011306686326861382, -0.020932136103510857, -0.02380683831870556, 0.020664667710661888, -0.03403465449810028, 0.013293863274157047, -0.013791896402835846, -0.030565230175852776, 0.0280106570571661, 0.02210070751607418, 0.012783175334334373, -0.011176925152540207, 0.01207620371133089, 0.026439132168889046, -0.0008623665198683739, -0.039383579045534134, -0.026239408180117607, 0.04621632397174835, -0.01987583003938198, 0.04804389178752899, 0.10394306480884552, -0.029470860958099365, -0.015853336080908775, -0.008219967596232891, 0.04025154188275337, -0.017175426706671715, 0.007232001516968012, -0.03348346799612045, -0.061191923916339874, -0.01752796396613121, -0.012630455195903778, -0.006230883300304413, 0.03135569021105766, -0.018505513668060303, -0.01786811649799347, 0.005402151960879564, -0.039254315197467804, 0.01917888969182968, 0.016121476888656616, -0.00047246224130503833, 0.009250879287719727, 0.06550572067499161, 0.01219942606985569, 0.003933741245418787, -0.014974613673985004, -0.0019952133297920227, -0.02491113543510437, 0.017542850226163864, 0.025526689365506172, -0.01362138893455267, 0.006585963070392609, 0.015019003301858902, -0.02912796661257744, 0.004115073010325432, -0.01822216995060444, -0.020351586863398552, 0.0257565900683403, 0.00994426105171442, -0.025618504732847214, -0.009450060315430164, -0.003010817803442478, 0.012220844626426697, 0.013512087054550648, 0.022731473669409752, 0.03640162944793701, 0.02266262285411358, 0.0059687974862754345, 0.019649909809231758, -0.009554604068398476, -0.05000483617186546, 0.009326605126261711, 0.005183226894587278, -0.019836917519569397, -0.11718486994504929, -0.06257205456495285, -0.014296567998826504, 0.015293116681277752, -0.008148731663823128, -0.023685889318585396, 0.05597132444381714, -0.02562485821545124, 0.006137046962976456, -0.006167637184262276, 0.012581540271639824, 0.0027584766503423452, 0.0016796146519482136, 0.04263632372021675, 0.007590239867568016, -0.03845283389091492, -0.008532480336725712, 0.025526849552989006, 0.03125738352537155, 0.013162401504814625, -0.016367632895708084, 0.049478452652692795, -0.004156396258622408, -0.002519716741517186, -0.026167383417487144, 0.02280142344534397, 0.05439009144902229, 0.06089397892355919, -0.006087237503379583, -0.05504271015524864, -0.021363576874136925, 0.015148807317018509, -0.017469137907028198, -0.002786981174722314, -0.04616836458444595, -0.014136983081698418, 0.019382087513804436, 0.0011599380522966385, 0.0024787625297904015, 0.018161090090870857, -0.005705272313207388, -0.04043900966644287, 0.013277851976454258, -0.006751764100044966, -0.02046063356101513, -0.03265015780925751, -0.030625872313976288, 0.0004020804481115192, 0.002069257665425539, -0.025104019790887833, -0.03595169261097908, -0.013577007688581944, 0.0024576226714998484, 0.01531722117215395, 0.03837088495492935, 0.011823409236967564, -0.0016162189422175288, 0.024822421371936798, 0.03973808512091637, -0.0033683704677969217, -0.0531286783516407, 0.010819428600370884, -0.005645780358463526, -0.015281189233064651, -0.04451815038919449, 0.03948958218097687, -0.008020401000976562, 0.032590944319963455, 0.02531188167631626, 0.0202287919819355, -0.01723887398838997, 0.014295453205704689, 0.02349385991692543, 0.022343246266245842, -0.0410575270652771, 0.029534215107560158, -0.06406513601541519, -0.013123206794261932, 0.04187162593007088, -0.031995151191949844, -0.01484429370611906, -0.06035493686795235, -0.029401136562228203, 0.022990824654698372, -0.03920845314860344, 0.020912209525704384, -0.00012647443509195, -0.039827413856983185, 0.025138335302472115, 0.02294526807963848, 0.011327516287565231, -0.018921537324786186, 0.01107553020119667, -0.03265679255127907, -0.027928369119763374, 0.004264753311872482, 0.019348902627825737, -0.030929548665881157, -0.03029024787247181, 0.004058953374624252, 0.02690405771136284, -0.05561978742480278, -0.017185140401124954, 0.04018031805753708, 0.008079294115304947, 0.003769173286855221, -0.023674461990594864, -0.036995191127061844, -0.02615363709628582, 0.007440951187163591, 0.032593611627817154, -0.0369071364402771, 0.0018700623186305165, -0.053645677864551544, -0.013346037827432156, 0.035034965723752975, 0.02426719479262829, -0.03330201283097267, -0.047263506799936295, 0.042414844036102295, -0.029549891129136086, 0.030930716544389725, -0.012876232154667377, -0.017889119684696198, -0.031065864488482475, -0.005012101028114557, 0.07223194092512131, 0.05958348140120506, -0.013018499128520489, 0.02710765227675438, -0.03003789857029915, -0.026295939460396767, 0.02353687956929207, -0.018259111791849136, 0.009300017729401588, 0.021467845886945724, 0.000708152714651078, 0.02356179989874363, 0.014030267484486103, -0.03843604028224945, -0.010945495218038559, -0.0225082915276289, 0.0816897451877594, -0.037274379283189774, 0.025066114962100983, -0.013469569385051727, -0.035347286611795425, 0.01908143237233162, -0.02616507187485695, 0.006516766734421253, 0.0594613291323185, -0.011716483160853386, 0.008535770699381828, 0.02658016048371792, -0.006979155354201794, 0.013128222897648811, -0.03322312608361244, 0.027873730286955833, -0.0032842541113495827, 0.0729583129286766, -0.037780310958623886, -0.02869906648993492, -0.01978820003569126, 0.021928926929831505, -0.008894163183867931, -0.006371197756379843, 0.025063257664442062, -0.08446424454450607, 0.007384995464235544, 0.009856424294412136, -0.009213391691446304, 0.01620863936841488, -0.00008321898349095136, -0.03423019126057625, 0.0025688486639410257, 0.029544474557042122, 0.0336063988506794, -0.0038901218213140965, 0.024115044623613358, -0.017117340117692947, 0.0154881551861763, -0.02545185200870037, -0.00413953373208642, 0.0013491259887814522, -0.05501999706029892, 0.033526912331581116, 0.05320166423916817, 0.03481755778193474, -0.01658713072538376, 0.010990031063556671, -0.004427123814821243, -0.05436960235238075, 0.0101692546159029, -0.04277908429503441, 0.0021647398825734854, -0.026018712669610977, 0.0020160560961812735, -0.01461116038262844, -0.020576030015945435, 0.015010283328592777, 0.022698648273944855, 0.05229386314749718, 0.013503778725862503, -0.07313533872365952, 0.0501536950469017, 0.023412227630615234, -0.00005434574995888397, -0.0174101572483778, 0.012068495154380798, -0.02715841680765152, 0.053522370755672455, -0.006279987283051014, -0.015384925529360771, -0.005658713635057211, -0.04532317444682121, -0.044065702706575394, -0.012680542655289173, 0.00645575113594532, -0.018850130960345268, -0.0008075130172073841, -0.03138871118426323, 0.01623080112040043, 0.024887260049581528, 0.012050826102495193, 0.05155736953020096, -0.01905348338186741, -0.004742707125842571, 0.02124490775167942, 0.014718460850417614, 0.02629500813782215, 0.014447535388171673, 0.01311752013862133, 0.012877030298113823, 0.03312654420733452, 0.030052460730075836, 0.006481315474957228, -0.0462658628821373, 0.030185185372829437, -0.0014776169555261731, -0.00792677327990532, -0.0164549071341753, -0.015362895093858242, -0.04463295266032219, -0.0033155984710901976, 0.002365420339629054, -0.008783668279647827, 0.06443338841199875, 0.009621895849704742, 0.0024013565853238106, -0.0069352444261312485, 0.02160486951470375, 0.025838011875748634, -0.020661868155002594, 0.00468811159953475, 0.01950770616531372, 0.019685322418808937, 0.00012916770356241614, 0.003826711792498827, -0.00419660983607173, -0.00807605218142271, 0.024202143773436546, -0.009811565279960632, 0.026806121692061424, -0.00687710614874959, -0.02965359389781952, 0.01997337117791176, 0.017475420609116554, -0.02057529427111149, -0.0046851313672959805, 0.022975564002990723, -0.00590244447812438, 0.054740797728300095, 0.03546047583222389, 0.0035199420526623726, -0.019992709159851074, -0.04845865070819855, 0.038346435874700546, 0.009784516878426075, -0.012420939281582832, 0.05027535930275917, 0.010252594947814941, 0.04708273708820343, 0.020925141870975494, -0.01856343261897564, -0.0073994230479002, 0.022958895191550255, 0.04570712894201279, -0.0027356899809092283, 0.02501020021736622, 0.05503077059984207, -0.014186838641762733, -0.006099454127252102, -0.03012845665216446, 0.0007100755465216935, -0.052193231880664825, 0.009521505795419216, -0.005457974970340729, 0.01627439819276333, 0.005199713166803122, -0.033935368061065674, 0.037936072796583176, 0.04064592346549034, 0.06833408027887344, -0.005098163150250912, 0.007686224300414324, 0.025048915296792984, 0.013770684599876404, 0.02132970467209816, 0.014959516935050488, 0.021779052913188934, 0.019682900980114937, 0.07854022830724716, -0.0035993109922856092, 0.03903352841734886, 0.0009399338159710169, -0.00891913939267397, 0.012317894026637077, -0.03338797017931938, -0.04368932917714119, -0.018396280705928802, 0.01484959851950407, -0.06162182241678238, -0.02454870194196701, 0.02702374942600727, -0.034781619906425476, -0.02603657729923725, -0.016030659899115562, 0.020420383661985397, -0.017281774431467056, -0.04900669679045677, -0.029806526377797127, 0.03183707594871521, 0.027419060468673706, -0.00311870314180851, -0.013659772463142872, 0.03292379900813103, 0.02909727208316326, 0.006414360366761684, -0.01568477787077427, -0.00335263111628592, -0.04726986959576607, 0.020404821261763573, -0.03226066008210182, 0.02748679742217064, -0.011967292055487633, -0.0027038080152124166, 0.012774255126714706, 0.002164567355066538, -0.015813259407877922, 0.022569242864847183, 0.026835337281227112, 0.030914204195141792, -0.07849359512329102, 0.011696826666593552, -0.02099309302866459, -0.0011962837306782603, -0.003207072149962187, -0.0005350398714654148, 0.00005622084063361399, -0.03232571855187416, 0.026240188628435135, 0.04844047874212265, -0.00663621723651886, -0.02058262936770916, -0.04415317252278328, 0.033901676535606384, -0.015811825171113014, -0.03882840648293495, 0.015173960477113724, -0.0026561140548437834, 0.007583005353808403, 0.0015706435078755021, -0.0019303348381072283, 0.025375111028552055, -0.007510756608098745, 0.018013019114732742, 0.021915948018431664, 0.00949372909963131, -0.01119153294712305, -0.009465604089200497, 0.03618781268596649, 0.010016346350312233, 0.016093509271740913, 0.010640834458172321, 0.0310895387083292, -0.0054589444771409035, 0.0037314833607524633, 0.0037974428851157427, -0.030074352398514748, -0.010569699108600616, -0.06793887168169022, -0.0243831817060709, -0.004476168192923069, -0.02358485758304596, 0.013766658492386341, 0.007974546402692795, -0.042476218193769455, 0.01906602457165718, -0.027659261599183083, -0.017479293048381805, 0.011604652740061283, 0.009122084826231003, 0.032200172543525696, 0.04836777597665787, 0.043195102363824844, -0.010728176683187485, -0.0034518842585384846, -0.011117875576019287, 0.030033182352781296, 0.00840446725487709, 0.00794589426368475, 0.011786029674112797, -0.020795563235878944, -0.05182776600122452, 0.007493259385228157, -0.03967765346169472, -0.054028552025556564, 0.0022171789314597845, -0.017708973959088326, -0.03244040161371231, 0.0032274029217660427, -0.0037271787878125906, 0.01822293922305107, 0.0017725907964631915, 0.03664547577500343, -0.01343421172350645, -0.03287865221500397, 0.02432858943939209, 0.013351482339203358, -0.021346891298890114, 0.007962999865412712, 0.007510945666581392, -0.005514943972229958, 0.0062870848923921585, 0.02321520633995533, -0.0021258145570755005, -0.003463216358795762, -0.03293764218688011, -0.022077230736613274, 0.040165845304727554, -0.06994018703699112, -0.06850073486566544, -0.01905735582113266, 0.05545008182525635, -0.047243062406778336, -0.08109673857688904, 0.02605622634291649, 0.0105332275852561, -0.03357933089137077, 0.007968800142407417, 0.012541767209768295, -0.007404042407870293, -0.04816223308444023, 0.03989700973033905, -0.002513349521905184, 0.02189190872013569, 0.02861005626618862, -0.010533710941672325, 0.008077496662735939, 0.016650665551424026 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
2.4.1 How do Transformers work? Transformers work by leveraging attention, a powerful deep-learning algorithm, first seen in computer vision models. —Not all that different from how we humans process information through attention. We are incredibly good at forgetting/ignoring mundane daily inputs that don’t pose a threat or require a response from us. For example, can you remember everything you saw and heard coming home last Tuesday? Of course not! Our brain’s memory is limited and valuable. Our recall is aided by our ability to forget trivial inputs. Similarly, Machine Learning models need to learn how to pay attention only to the things that matter and not waste computational resources processing irrelevant information. Transformers create differential weights signaling which words in a sentence are the most critical to further process. A transformer does this by successively processing an input through a stack of transformer layers, usually called the encoder. If necessary, another stack of transformer layers - the decoder - can be used to predict a target output. —BERT however, doesn’t use a decoder. Transformers are uniquely suited for unsupervised learning because they can efficiently process millions of data points. Fun Fact: Google has been using your reCAPTCHA selections to label training data since 2011. The entire Google Books archive and 13 million articles from the New York Times catalog have been transcribed/digitized via people entering reCAPTCHA text. Now, reCAPTCHA is asking us to label Google Street View images, vehicles, stoplights, airplanes, etc. Would be neat if Google made us aware of our participation in this effort (as the training data likely has future commercial intent) but I digress.. To learn more about Transformers check out our Hugging Face Transformers Course.
[ 0.04563452675938606, 0.0027877152897417545, 0.04841705411672592, -0.009058435447514057, 0.028921004384756088, 0.04715530574321747, 0.007517216261476278, 0.06591136008501053, 0.00639837933704257, 0.006583648268133402, -0.08043530583381653, 0.12882791459560394, -0.0871097594499588, 0.06539305299520493, -0.033282652497291565, -0.016451893374323845, 0.0731276273727417, -0.032276701182127, -0.029360370710492134, 0.05991275981068611, -0.040091272443532944, -0.08557584136724472, 0.04735224321484566, -0.03278147429227829, 0.04029053822159767, 0.008953516371548176, -0.005270323250442743, -0.0495520681142807, -0.049146611243486404, 0.0610521137714386, -0.14683586359024048, 0.014749428257346153, 0.010193455964326859, -0.004663574043661356, -0.06840725988149643, -0.0220348984003067, -0.11586833745241165, 0.010953766293823719, 0.012036933563649654, -0.0595526322722435, -0.05333130434155464, 0.02719658799469471, -0.15106572210788727, 0.013500512577593327, -0.04251004755496979, -0.011697735637426376, -0.19793818891048431, 0.07072949409484863, -0.047395434230566025, -0.05361129716038704, -0.06825719028711319, 0.09099946916103363, 0.0004213143838569522, 0.06480462104082108, -0.03477327153086662, 0.06003189831972122, -0.009567098692059517, -0.024033335968852043, 0.02192661538720131, -0.01808745600283146, 0.01814723201096058, 0.03319575637578964, 0.031168440356850624, 0.03584542125463486, 0.025690918788313866, -0.002502509392797947, 0.056055013090372086, 0.010769308544695377, -0.041877631098032, -0.05998099967837334, -0.011477011255919933, -0.055591341108083725, -0.015942588448524475, 0.017279699444770813, -0.09366200119256973, 0.001771222217939794, 0.026716481894254684, 0.039416901767253876, -0.0063514262437820435, 0.0061959815211594105, 0.014553704299032688, 0.016822896897792816, 0.01880597323179245, 0.02536938339471817, 0.04357275366783142, -0.017317786812782288, 0.034211430698633194, -0.00742060923948884, -0.07678395509719849, 0.06004448980093002, -0.017108390107750893, -0.14672359824180603, -0.00970566738396883, 0.010821478441357613, 0.03320563957095146, -0.028923723846673965, -0.00338832032866776, -0.021745838224887848, -0.04244086891412735, -0.05789217725396156, -0.033441729843616486, -0.06059129536151886, 0.09213758260011673, -0.006940872874110937, -0.019169805571436882, -0.0006132175331003964, 0.004605129361152649, -0.08846674859523773, 0.03409387171268463, 0.0061217849142849445, -0.040555164217948914, -0.03304126858711243, 0.018976423889398575, 0.04991775006055832, -0.05197257548570633, 0.031591691076755524, 0.04657299444079399, -0.017997415736317635, -0.00937300082296133, 0.036016933619976044, -0.012293101288378239, 0.05129988491535187, 0.004754191264510155, 0.013032155111432076, -0.01852726936340332, 0.012396369129419327, -0.03257618844509125, -0.00018505174375604838, 0.016438964754343033, 0.01464866753667593, 0.06236238777637482, -0.019092531874775887, 0.06675349920988083, 0.022391732782125473, 0.008945421315729618, -0.02710796147584915, -0.005944173317402601, -0.009598749689757824, -0.02071959152817726, -0.0231033843010664, -0.0192289836704731, 0.03969602659344673, 0.024182651191949844, -0.08730001747608185, 0.0574306920170784, -0.04294748231768608, -0.09968589246273041, 0.07526575773954391, 0.05083909630775452, 0.054290708154439926, -0.057931218296289444, 0.02663416601717472, -0.030295202508568764, -0.08364936709403992, 0.039329636842012405, 0.030971042811870575, 0.022224459797143936, -0.01338593102991581, -0.035774216055870056, -0.022190019488334656, -0.03287060558795929, 0.022301621735095978, -0.0138003034517169, 0.06917368620634079, -0.0049895127303898335, -0.029496295377612114, 0.03287693113088608, 0.01648215390741825, 0.00421354454010725, 0.07090926170349121, -0.02907613292336464, 0.01604621671140194, 0.03526553511619568, -0.05908314883708954, -0.02881639450788498, 0.02793080545961857, 0.014143159613013268, 0.024726994335651398, 0.024561898782849312, -0.030326582491397858, -0.049665722995996475, -0.0049252077005803585, 0.003875861642882228, 0.06373125314712524, 0.05486184358596802, -0.058688946068286896, 0.0018021294381469488, -0.023718085139989853, -0.029053296893835068, 0.020175185054540634, -0.03404194861650467, 0.019211675971746445, 0.0339319072663784, -0.00920153222978115, 0.0544431172311306, -0.040490422397851944, -0.0818973109126091, 0.11626957356929779, -0.0016131659504026175, 0.047915805131196976, 0.017616000026464462, -0.0721067562699318, -0.007522257976233959, -0.03003503568470478, -0.006541356910020113, -0.0023339809849858284, 0.031496819108724594, -0.02699527144432068, 0.010135218501091003, -0.01841224730014801, -0.03280040621757507, -0.1028742864727974, -0.038679663091897964, -0.04119871184229851, -0.010914391838014126, -0.07943009585142136, 0.028953352943062782, 0.010997166857123375, 0.0018863104050979018, 0.005974351894110441, 0.08867720514535904, -0.008832177147269249, -0.025924092158675194, 0.017046445980668068, -0.013321527279913425, 0.008824478834867477, 0.061277925968170166, 0.000030994517146609724, 0.06914179027080536, -0.03143196180462837, -0.007018302101641893, -0.023466866463422775, -0.012486269697546959, -0.06032548099756241, -0.06348246335983276, -0.0732724666595459, 0.02771584875881672, 0.08323077857494354, 0.008731694892048836, 0.013171762228012085, -0.01856076903641224, -0.028422590345144272, -0.0007789533701725304, 0.059824664145708084, -0.030220922082662582, 0.007288380526006222, 0.06861991435289383, 0.026331091299653053, -0.03168304264545441, -0.0033205910585820675, -0.11247403174638748, 0.03843270242214203, -0.024620093405246735, -0.04883628338575363, 0.03536227345466614, 0.02400638721883297, 0.025754854083061218, -0.008309903554618359, -0.006287724711000919, -0.0043883249163627625, -0.013059070333838463, -0.037722148001194, -0.029136231169104576, -0.03293285891413689, -0.03626410290598869, -0.052414990961551666, -0.0012814555084332824, 0.016226155683398247, 0.03358476608991623, 0.03341851010918617, 0.009240565821528435, 0.01309442613273859, 0.03533346951007843, -0.0008022193796932697, 0.03220677003264427, 0.03105505369603634, 0.04590607061982155, -0.019498225301504135, -0.0017176956171169877, -0.029666269198060036, -0.009783435612916946, -0.01044281292706728, 0.0767660140991211, 0.042101290076971054, 0.029757332056760788, 0.007416085805743933, 0.0003437949635554105, -0.00542638823390007, -0.0128850182518363, 0.030342722311615944, 0.013823804445564747, 0.006351620424538851, -0.012729737907648087, -0.01287118811160326, -0.02009880729019642, 0.01792367734014988, -0.01273411512374878, -0.025030467659235, -0.013333163224160671, 0.018384454771876335, 0.009227574802935123, 0.013949057087302208, 0.0237802155315876, -0.01937882788479328, -0.01666167937219143, 0.014902964234352112, 0.013914949260652065, 0.044648610055446625, -0.09575599431991577, -0.062199000269174576, -0.005035667214542627, -0.007088558282703161, 0.013414306566119194, -0.04449702426791191, 0.04311423748731613, 0.06741129606962204, -0.02336486056447029, 0.0026695842389017344, -0.031041927635669708, -0.014099767431616783, -0.03531547263264656, 0.026933874934911728, -0.020749101415276527, 0.01825742796063423, 0.012279197573661804, 0.00018710702715907246, 0.03503260016441345, 0.007918566465377808, -0.01936517469584942, 0.023948879912495613, 0.0010632224148139358, 0.0007833351264707744, -0.027041373774409294, 0.015910975635051727, 0.0131564661860466, 0.013036767020821571, 0.04010750353336334, 0.0027609309181571007, 0.010322947055101395, -0.015627484768629074, 0.02553364634513855, 0.05046236142516136, -0.0037888740189373493, 0.01251518726348877, 0.04588991776108742, -0.010146749205887318, 0.028808509930968285, 0.03454795479774475, -0.002334813354536891, -0.014322979375720024, -0.01488853432238102, 0.012948288582265377, 0.06459376215934753, -0.022586647421121597, -0.011724209412932396, -0.058806076645851135, -0.007754303980618715, -0.03815934807062149, -0.03705180808901787, -0.003252980764955282, -0.02443724125623703, -0.00025993541930802166, -0.01007163617759943, -0.028481027111411095, 0.027442842721939087, -0.016354182735085487, 0.010123541578650475, 0.02109401673078537, -0.01191623229533434, 0.06602358818054199, -0.011123153381049633, -0.0023044408299028873, -0.03811151161789894, 0.02520792745053768, 0.012520229443907738, 0.004427982959896326, 0.02242741547524929, 0.023261766880750656, -0.019025443121790886, 0.032413989305496216, 0.024641167372465134, -0.00013296797988004982, 0.011037861928343773, 0.022855941206216812, -0.0040216040797531605, 0.014681797474622726, 0.09263405203819275, -0.001585648162290454, -0.033428359776735306, -0.03188907727599144, -0.030072607100009918, -0.00786114577203989, 0.03523044288158417, -0.013901120983064175, 0.027054952457547188, -0.005945957265794277, 0.004475567489862442, -0.018390515819191933, 0.02157130278646946, -0.04394035413861275, 0.008969857357442379, -0.02690599486231804, 0.011390934698283672, 0.01581943966448307, -0.005524192936718464, -0.005938221234828234, 0.006507630925625563, -0.01969938725233078, 0.014323645271360874, -0.047505833208560944, -0.014237257651984692, 0.010739490389823914, -0.01573934219777584, -0.023105110973119736, -0.024612363427877426, 0.001942336093634367, 0.01774674840271473, 0.017061682417988777, 0.026788176968693733, 0.025394299998879433, -0.018574342131614685, 0.021895119920372963, 0.02647676318883896, 0.034447912126779556, 0.0023921013344079256, -0.02541189081966877, 0.011327449232339859, -0.005851173773407936, -0.025644877925515175, 0.042726192623376846, -0.018937230110168457, 0.004250386729836464, 0.0076565369963645935, 0.017364531755447388, 0.03989674523472786, 0.040991898626089096, -0.012074162252247334, 0.00016972450248431414, -0.03634684160351753, 0.005660514812916517, 0.028862183913588524, 0.010608136653900146, -0.0007209930918179452, 0.004628696478903294, -0.010731733404099941, 0.016998814418911934, -0.016137899830937386, -0.004468810278922319, -0.017940128222107887, -0.015696147456765175, 0.05117512494325638, -0.056493427604436874, -0.000910004717297852, -0.032211363315582275, -0.039473794400691986, 0.007661525625735521, -0.030193863436579704, -0.023437034338712692, 0.05202455818653107, -0.03302706405520439, -0.04529154673218727, 0.023069094866514206, 0.025094827637076378, -0.03678552433848381, 0.02285647764801979, 0.04899170622229576, 0.005981012713164091, 0.03843026980757713, 0.006918041035532951, 0.04336436092853546, -0.04259064421057701, 0.00422455882653594, 0.02937968447804451, 0.003598700510337949, -0.020442424342036247, -0.06498167663812637, 0.011913503520190716, 0.030496980994939804, 0.015165320597589016, -0.02890050783753395, 0.008285220712423325, 0.0028310255147516727, -0.008352157659828663, 0.027882559224963188, -0.009818344376981258, 0.031583573669195175, -0.01882059872150421, 0.013193385675549507, 0.007492023520171642, 0.032200779765844345, -0.02082279697060585, -0.00004867531970376149, 0.020924309268593788, 0.006412521004676819, 0.02792484499514103, 0.05748594179749489, -0.042495712637901306, 0.014315908774733543, 0.04685932397842407, -0.015371846035122871, 0.013874118216335773, -0.016183175146579742, 0.037813469767570496, -0.013083791360259056, 0.03514562547206879, 0.031129788607358932, -0.05222268030047417, 0.07697850465774536, 0.024574805051088333, 0.022593125700950623, -0.03851747140288353, -0.014510962180793285, 0.014082538895308971, -0.004546854179352522, -0.02092118188738823, 0.00632065162062645, 0.006676479242742062, -0.024875832721590996, 0.00816830899566412, -0.00030389882158488035, -0.0008013067999854684, -0.006239373702555895, -0.02106623351573944, -0.038302648812532425, -0.016459915786981583, 0.03749501332640648, 0.025366518646478653, 0.05635896325111389, -0.014842563308775425, 0.01168676558881998, -0.01604519970715046, 0.038073889911174774, 0.037725843489170074, -0.05394947901368141, 0.00931981299072504, -0.0031378003768622875, 0.03282838687300682, -0.012631803750991821, 0.040055520832538605, 0.04295950010418892, -0.010261260904371738, 0.02057865634560585, -0.029190588742494583, -0.03577328100800514, -0.03633753955364227, 0.04640619456768036, 0.03393123671412468, -0.027251623570919037, -0.008159373886883259, -0.002674632240086794, -0.07450050115585327, 0.048885636031627655, 0.011766903102397919, 0.05319070443511009, 0.05417958274483681, -0.0014881968963891268, 0.02360842376947403, -0.0013671512715518475, 0.02301602065563202, 0.0023791512940078974, -0.02266712114214897, 0.02882895991206169, -0.009036975912749767, 0.015150103718042374, -0.01957530528306961, 0.009192271158099174, 0.021498428657650948, 0.025134077295660973, 0.02061856910586357, -0.02037431113421917, 0.014382248744368553, 0.023404108360409737, -0.007756630890071392, 0.021157987415790558, 0.0013587092980742455, -0.013338851742446423, 0.03165552020072937, 0.01088947243988514, 0.017916902899742126, 0.048919741064310074, 0.01162602100521326, -0.0029166440945118666, -0.02607891708612442, -0.01691717468202114, 0.011089419946074486, 0.07758211344480515, -0.0372285395860672, 0.06594295799732208, 0.0436922162771225, 0.0322309285402298, 0.05751877278089523, -0.014761202968657017, 0.013406036421656609, -0.02317839115858078, 0.03655849024653435, 0.007853977382183075, 0.02266336977481842, -0.011809548363089561, -0.03566684201359749, -0.0238783098757267, 0.011919851414859295, 0.006820125505328178, -0.04404541105031967, 0.014621231704950333, 0.02773088403046131, 0.013135639019310474, 0.033176273107528687, -0.009314030408859253, 0.020818211138248444, 0.04757171869277954, 0.06444073468446732, 0.018932940438389778, 0.04010676220059395, 0.0321977324783802, -0.005260097328573465, 0.04296823963522911, 0.025387458503246307, 0.011915079317986965, -0.008126105181872845, 0.02852260321378708, 0.03174460679292679, 0.04781993106007576, 0.0031903176568448544, -0.043503034859895706, 0.035413309931755066, -0.02754443697631359, -0.06278526037931442, 0.042061395943164825, -0.003052679356187582, -0.023068152368068695, 0.006503451149910688, 0.019542593508958817, -0.032983627170324326, 0.03883892670273781, 0.01891019195318222, -0.003148312447592616, -0.03250309079885483, -0.03357487544417381, -0.019441360607743263, 0.051763489842414856, 0.013726402074098587, -0.042718157172203064, -0.000560257991310209, -0.01624499075114727, -0.0051691243425011635, 0.005970760248601437, -0.016135359182953835, -0.05185379087924957, -0.048891112208366394, -0.004336241632699966, 0.01214258186519146, 0.013841977342963219, -0.0311827901750803, -0.01203699130564928, 0.02476579137146473, 0.015002566389739513, -0.031037993729114532, 0.024972455576062202, -0.020811034366488457, 0.0025658190716058016, -0.025674672797322273, 0.020261099562048912, -0.044996678829193115, -0.03482567518949509, 0.017675720155239105, -0.022540628910064697, -0.006197588983923197, -0.023492660373449326, 0.0253343153744936, 0.021251102909445763, 0.04542681574821472, -0.0006300312816165388, 0.010987008921802044, 0.02172495238482952, -0.0062051755376160145, -0.011919327080249786, 0.04435316100716591, 0.033678553998470306, -0.03845025971531868, 0.051414888352155685, 0.02073477767407894, -0.012241272255778313, -0.009163872338831425, 0.045160923153162, 0.03656735271215439, -0.003651368198916316, -0.03509761393070221, 0.01390148140490055, 0.046725474298000336, 0.0007524759275838733, 0.01946750096976757, 0.0388321653008461, 0.009540229104459286, 0.005344531033188105, -0.05320010334253311, 0.022358950227499008, -0.028988145291805267, -0.010284784249961376, 0.001454432145692408, -0.045453134924173355, 0.014117365702986717, 0.0200265534222126, 0.020954081788659096, 0.020246241241693497, -0.04974837228655815, 0.007942636497318745, -0.03398262709379196, 0.02233537659049034, 0.008311614394187927, 0.007834561169147491, 0.039317209273576736, 0.02002681978046894, 0.033957939594984055, -0.012056749314069748, -0.0234427060931921, -0.05382588878273964, -0.021599022671580315, 0.02887764386832714, 0.043495919555425644, -0.01481787022203207, 0.0047549293376505375, -0.039786700159311295, -0.058372851461172104, -0.008392758667469025, -0.033875662833452225, 0.022948112338781357, 0.01626615971326828, -0.0038870940916240215, 0.010396884754300117, -0.01079515740275383, -0.003305406542494893, -0.02229674533009529, 0.02503270097076893, -0.05062296614050865, -0.03098437190055847, 0.002324433531612158, 0.0062322295270860195, -0.05817340314388275, -0.011095171794295311, 0.0012053134851157665, 0.016191711649298668, 0.05410333722829819, 0.0791497454047203, -0.003310722066089511, -0.0207511056214571, 0.027988679707050323, 0.04623216763138771, -0.021765204146504402, -0.007488476578146219, -0.08530411124229431, -0.0015846267342567444, 0.001332098850980401, -0.010964257642626762, -0.03706347197294235, 0.025679057464003563, -0.008111757226288319, 0.021698100492358208, 0.01105942577123642, -0.004194643814116716, -0.007966099306941032, -0.021427016705274582, 0.029689807444810867, -0.03611854463815689, 0.06087935343384743, 0.014453191310167313, -0.01162603311240673, 0.016882287338376045, -0.030047791078686714 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
What is BERT? BERT, short for Bidirectional Encoder Representations from Transformers, is a Machine Learning (ML) model for natural language processing. It was developed in 2018 by researchers at Google AI Language and serves as a swiss army knife solution to 11+ of the most common language tasks, such as sentiment analysis and named entity recognition. Language has historically been difficult for computers to ‘understand’. Sure, computers can collect, store, and read text inputs but they lack basic language _context_. So, along came Natural Language Processing (NLP): the field of artificial intelligence aiming for computers to read, analyze, interpret and derive meaning from text and spoken words. This practice combines linguistics, statistics, and Machine Learning to assist computers in ‘understanding’ human language. Individual NLP tasks have traditionally been solved by individual models created for each specific task. That is, until— BERT! BERT revolutionized the NLP space by solving for 11+ of the most common NLP tasks (and better than previous models) making it the jack of all NLP trades. In this guide, you'll learn what BERT is, why it’s different, and how to get started using BERT: 1. [What is BERT used for?](#1-what-is-bert-used-for) 2. [How does BERT work?](#2-how-does-bert-work) 3. [BERT model size & architecture](#3-bert-model-size--architecture) 4. [BERT’s performance on common language tasks](#4-berts-performance-on-common-language-tasks) 5. [Environmental impact of deep learning](#5-enviornmental-impact-of-deep-learning) 6. [The open source power of BERT](#6-the-open-source-power-of-bert) 7. [How to get started using BERT](#7-how-to-get-started-using-bert) 8. [BERT FAQs](#8-bert-faqs) 9. [Conclusion](#9-conclusion) Let's get started! 🚀
[ -0.03227407857775688, -0.01774890534579754, 0.060921162366867065, -0.0530347041785717, 0.05031026527285576, 0.07374988496303558, 0.010514049790799618, 0.07913146167993546, -0.023793691769242287, -0.018106551840901375, -0.10706797242164612, 0.06364353746175766, -0.014977364800870419, 0.043574150651693344, -0.0017566781025379896, -0.00577223626896739, 0.060702480375766754, -0.01591355912387371, 0.008846447803080082, -0.00922168418765068, -0.010838543996214867, -0.0682109147310257, 0.10150204598903656, -0.03154702112078667, 0.07320237904787064, -0.04605058208107948, -0.0023616980761289597, 0.0007399779860861599, -0.092518649995327, 0.032298315316438675, -0.12653203308582306, -0.0017807753756642342, 0.017826663330197334, -0.010574758984148502, -0.05622567608952522, 0.008286500349640846, -0.11404876410961151, 0.04163702577352524, -0.022633705288171768, -0.038640957325696945, -0.039825718849897385, -0.022055145353078842, -0.06273965537548065, 0.046193890273571014, -0.03149408474564552, 0.0048958067782223225, -0.1917797029018402, 0.06984267383813858, 0.002201237715780735, -0.0221661739051342, -0.09822729974985123, 0.05615432187914848, -0.056590914726257324, 0.044793084263801575, -0.05057526379823685, 0.03703837841749191, 0.021317806094884872, -0.06264209002256393, 0.01714668609201908, -0.023030651733279228, 0.0471816286444664, -0.013075933791697025, -0.010512428358197212, -0.005018146242946386, 0.03125161677598953, 0.004536373540759087, -0.03266967460513115, -0.014829020015895367, -0.07332953810691833, -0.015050804242491722, -0.04200594872236252, -0.040750838816165924, -0.08846402913331985, 0.036711230874061584, -0.04310855641961098, -0.044078804552555084, 0.02934509702026844, 0.0343000590801239, 0.015661781653761864, 0.013498901389539242, 0.010976174846291542, 0.0337119922041893, 0.007369306869804859, 0.04034765437245369, 0.03965894505381584, 0.02057361975312233, 0.06301368772983551, -0.007611291948705912, -0.06449373066425323, 0.08285680413246155, -0.0307918693870306, -0.18111087381839752, -0.04181644320487976, -0.03636039420962334, 0.010464286431670189, -0.07753152400255203, -0.017749415710568428, 0.004929511342197657, -0.020808082073926926, -0.008783061057329178, 0.029399201273918152, -0.03248460590839386, 0.06549816578626633, -0.0028917593881487846, -0.038834523409605026, 0.029702629894018173, 0.011051165871322155, -0.09371328353881836, 0.00013167172437533736, -0.008506746031343937, 0.026381975039839745, -0.044316209852695465, -0.0033076961990445852, 0.07402221858501434, -0.06179357320070267, 0.03845006227493286, 0.028934849426150322, -0.0016408046940341592, 0.025011183694005013, 0.04357949644327164, -0.0033238898031413555, 0.03608205169439316, 0.0031717035453766584, -0.005262595601379871, -0.0012045061448588967, 0.021694840863347054, 0.011905688792467117, 0.0034876710269600153, 0.012662387453019619, -0.03584175556898117, 0.07535288482904434, -0.008454532362520695, 0.08288358151912689, -0.011205418035387993, -0.03578606992959976, -0.003797507146373391, -0.008036577142775059, -0.08755497634410858, 0.015411141328513622, -0.004556358326226473, -0.019993586465716362, 0.05592773109674454, -0.012264445424079895, -0.007142243906855583, 0.08285827189683914, 0.006436528638005257, -0.0818382278084755, 0.02651578187942505, 0.003954374231398106, 0.00732550909742713, -0.11648409068584442, 0.009177420288324356, -0.013355784118175507, -0.07365594804286957, 0.021260274574160576, 0.05916385352611542, -0.0012065619230270386, -0.04110289365053177, -0.01871532015502453, -0.009321000427007675, -0.005089269019663334, 0.006353660486638546, -0.04349628463387489, 0.022799357771873474, -0.016982657834887505, -0.07083045691251755, 0.014589738100767136, 0.02944583259522915, -0.014088524505496025, 0.04807491973042488, -0.02184452675282955, 0.004178555682301521, 0.10872109234333038, -0.016995174810290337, -0.008602351881563663, 0.01801873929798603, 0.049889978021383286, 0.018896549940109253, 0.03799041360616684, 0.00007787163485772908, -0.029226426035165787, 0.06534258276224136, 0.016523217782378197, 0.025623468682169914, 0.05995689332485199, -0.03297434002161026, 0.026005426421761513, -0.062341637909412384, 0.005620182491838932, 0.027288222685456276, -0.013662785291671753, -0.04473596066236496, 0.07883137464523315, -0.005587172694504261, 0.03251050040125847, -0.059086211025714874, -0.047630783170461655, 0.12843821942806244, 0.004115913528949022, 0.012193798087537289, 0.09849320352077484, -0.056957028806209564, 0.029549233615398407, -0.01130696851760149, -0.02280379645526409, 0.012063078582286835, 0.0739288181066513, 0.009295758791267872, 0.024499181658029556, -0.010448064655065536, 0.02396094985306263, -0.09191542118787766, 0.0070654950104653835, -0.07347801327705383, 0.002525989431887865, -0.09364242851734161, -0.010085157118737698, 0.0349874347448349, 0.06729935854673386, 0.009480400010943413, 0.11635877937078476, -0.0937599316239357, -0.02784135937690735, -0.011398653499782085, -0.0204983688890934, 0.04087955877184868, 0.07504582405090332, 0.018833773210644722, 0.12266802042722702, -0.0299566350877285, -0.042296942323446274, -0.025400741025805473, 0.02931375801563263, -0.0155226681381464, -0.01247740164399147, -0.005672008264809847, 0.0050577339716255665, 0.014402857050299644, 0.0020604999735951424, 0.003889186307787895, -0.04445324093103409, 0.021861521527171135, 0.03304307535290718, 0.05256347358226776, -0.036596134305000305, -0.021235009655356407, 0.07184058427810669, 0.006305675487965345, 0.0013329414650797844, 0.01884438283741474, -0.06413006782531738, 0.0025517570320516825, 0.01031308714300394, -0.0236799418926239, 0.015711771324276924, 0.05395602807402611, -0.005679867696017027, -0.0018873625667765737, 0.013485378585755825, 0.029031280428171158, -0.024142466485500336, -0.058312684297561646, -0.011005583219230175, -0.05605940520763397, -0.010643979534506798, -0.03997492790222168, -0.03645128011703491, 0.03787611797451973, 0.004853160586208105, 0.04682278260588646, 0.013381258584558964, -0.02027437649667263, 0.05638429522514343, 0.014863837510347366, 0.033865656703710556, 0.03800952062010765, 0.03316916897892952, 0.01456014346331358, -0.017513003200292587, -0.04436182603240013, -0.02108600176870823, -0.012714702636003494, 0.03580193966627121, 0.023426707834005356, 0.030231861397624016, -0.013546301051974297, -0.00955637451261282, -0.03958592563867569, -0.002569902455434203, 0.0019093408482149243, 0.021109772846102715, 0.03506290167570114, -0.03735683485865593, -0.01942393369972706, -0.0014679074520245194, 0.014580282382667065, 0.019029388204216957, -0.0029878851491957903, -0.039434030652046204, 0.03125212714076042, -0.005489913281053305, 0.003590548876672983, -0.014821729622781277, -0.0038709649816155434, -0.02431163191795349, 0.02740526758134365, 0.024786321446299553, 0.022742625325918198, -0.11424683779478073, -0.020300477743148804, 0.015492630191147327, -0.019961250945925713, 0.02249484695494175, 0.004842500668019056, 0.06149968504905701, 0.012414845637977123, -0.044362399727106094, 0.024196995422244072, 0.00895236898213625, 0.002449996303766966, 0.01937813311815262, 0.01413330901414156, -0.006990646477788687, 0.016254449263215065, -0.028780749067664146, -0.0010328610660508275, 0.015169485472142696, -0.005650017410516739, -0.01645311526954174, 0.03314564749598503, 0.012133097276091576, 0.004279064480215311, -0.017791125923395157, -0.001184270135127008, -0.014448271133005619, -0.0004062360094394535, 0.02392112836241722, -0.021854529157280922, 0.006095441058278084, 0.01451394334435463, -0.02748808078467846, 0.025300119072198868, -0.022956538945436478, -0.0037055108696222305, 0.027727598324418068, 0.04737427830696106, 0.031532399356365204, 0.045210469514131546, 0.0062288325279951096, -0.0061012147925794125, 0.007997123524546623, 0.004572139121592045, 0.008515706285834312, -0.02062980830669403, -0.010586193762719631, -0.026002543047070503, 0.007659066468477249, -0.00924932211637497, -0.03153780847787857, -0.03895902261137962, -0.03549906611442566, 0.015217496082186699, 0.005688224453479052, -0.011635799892246723, -0.009024592116475105, -0.03097546100616455, -0.004874976351857185, 0.006914074532687664, -0.01895766891539097, 0.05213935300707817, -0.023612260818481445, -0.030313512310385704, -0.03264060989022255, 0.03976653516292572, 0.03564348816871643, 0.03589019924402237, 0.017258336767554283, 0.0369640477001667, -0.009925260208547115, 0.019257811829447746, 0.007821758277714252, 0.008652469143271446, -0.019403846934437752, 0.042808111757040024, -0.009905272163450718, -0.007316357456147671, 0.0900053158402443, 0.020206166431307793, -0.04619841277599335, -0.017027180641889572, -0.0295142512768507, -0.01376761682331562, 0.04864535480737686, -0.006121170707046986, 0.01961064338684082, -0.005332940258085728, 0.029888851568102837, 0.03464525565505028, 0.01204573456197977, -0.017630750313401222, 0.009379585273563862, 0.01845996454358101, 0.008324713446199894, 0.003076759399846196, -0.001811370486393571, -0.03340680152177811, -0.008158265613019466, 0.00910639762878418, 0.02809830754995346, -0.06056137755513191, -0.03315076231956482, 0.01062233466655016, 0.03412248194217682, 0.04133496433496475, -0.011362852528691292, -0.005261073354631662, 0.0271134115755558, -0.023790324106812477, -0.02167575992643833, 0.009935799054801464, -0.0044733379036188126, 0.01176394335925579, 0.03903786465525627, 0.040150005370378494, -0.02303391881287098, -0.03518111631274223, -0.028143415227532387, 0.005942151881754398, 0.01215329859405756, 0.004045154899358749, 0.0022847645450383425, 0.011955498717725277, 0.04436634108424187, 0.005777899641543627, 0.026907552033662796, 0.02621403895318508, -0.02690926007926464, -0.020996810868382454, -0.02833002246916294, -0.008756468072533607, 0.029103845357894897, -0.022876830771565437, 0.0018474815879017115, 0.0021690938156098127, 0.017712820321321487, 0.014875895343720913, 0.0031707033049315214, -0.03149446099996567, -0.00426814379170537, -0.0038167585153132677, 0.03634725883603096, -0.057071272283792496, 0.032111287117004395, -0.011917640455067158, -0.047008153051137924, -0.02580162137746811, 0.0031100378837436438, 0.0015681413933634758, 0.036342553794384, 0.005954742431640625, -0.041799478232860565, 0.007209313567727804, 0.004802190698683262, -0.0582529678940773, -0.004948065150529146, 0.06310737878084183, -0.0027701666112989187, 0.05466992408037186, -0.0047861491329967976, -0.007752353325486183, -0.03961733356118202, 0.0017620834987610579, 0.015870243310928345, 0.016475694254040718, 0.012782998383045197, -0.027935141697525978, 0.015768537297844887, 0.03477604314684868, 0.019007451832294464, -0.006638598628342152, 0.029226232320070267, -0.023300448432564735, -0.0017897561192512512, 0.035487979650497437, 0.010446758009493351, 0.018567297607660294, 0.007525434717535973, 0.036072246730327606, -0.008574476465582848, 0.005245408974587917, -0.03692564368247986, 0.007868689484894276, -0.006653137970715761, -0.00442843372002244, 0.06060414016246796, 0.05461542308330536, 0.00024711532751098275, 0.033244743943214417, 0.015588841401040554, -0.017637042328715324, 0.036623407155275345, -0.031489454209804535, -0.010077403858304024, -0.02230551466345787, -0.004093953873962164, 0.007809794507920742, -0.014488852582871914, 0.025378473103046417, -0.00948237907141447, 0.03679920732975006, -0.028920676559209824, 0.0026235857512801886, 0.03815329447388649, -0.016803421080112457, -0.0134217394515872, -0.0722946897149086, -0.01705794595181942, -0.019042089581489563, -0.008169649168848991, -0.002315959194675088, 0.003235976677387953, 0.01873810589313507, -0.006668630056083202, -0.029959585517644882, -0.0077320062555372715, 0.027579009532928467, 0.026247354224324226, 0.03073769249022007, -0.010857081972062588, -0.0007179313688538969, -0.03863007202744484, 0.015962278470396996, -0.001999014988541603, -0.0736093521118164, 0.013856714591383934, 0.034199003130197525, 0.03504526987671852, 0.019067611545324326, 0.054036203771829605, 0.009904433973133564, -0.018092622980475426, 0.04321695864200592, -0.009369609877467155, -0.010324978269636631, -0.014475056901574135, 0.023469917476177216, 0.0264297928661108, -0.00867724884301424, 0.0018251682631671429, -0.012255514040589333, -0.01651034690439701, 0.023865489289164543, -0.05367128923535347, 0.00017446510901208967, 0.05834688991308212, -0.029916847124695778, -0.0074134753085672855, 0.02445286326110363, 0.008525729179382324, 0.012506821192800999, -0.01643816940486431, 0.002049517584964633, 0.033497948199510574, 0.047646474093198776, 0.02705572359263897, 0.025380713865160942, 0.021631615236401558, 0.025075403973460197, 0.02728540450334549, -0.04475826770067215, 0.016007672995328903, 0.01659473218023777, -0.016881845891475677, 0.028608329594135284, 0.02183552086353302, -0.0268727857619524, 0.014125563204288483, 0.03781622275710106, 0.008471542969346046, 0.03525171056389809, 0.014973527751863003, 0.022688983008265495, 0.008528029546141624, -0.030790023505687714, 0.02233280800282955, 0.0918450728058815, -0.04778515547513962, 0.07493578642606735, 0.03756072372198105, 0.06216762587428093, 0.05047941580414772, -0.03824938088655472, 0.0027634871657937765, 0.02849125862121582, 0.07236196100711823, -0.012967447750270367, 0.021209243685007095, 0.011956818401813507, -0.041628140956163406, -0.025467656552791595, 0.00696726655587554, -0.01077314093708992, -0.04398786276578903, -0.016424208879470825, 0.027202341705560684, -0.018880855292081833, 0.026030996814370155, -0.008666587062180042, 0.005823148414492607, 0.034981440752744675, 0.033671386539936066, 0.0037978736218065023, 0.03161347284913063, 0.05415983125567436, 0.013457666151225567, 0.003047875827178359, 0.021563420072197914, 0.006672578398138285, 0.010926303453743458, 0.05756275728344917, 0.026090577244758606, 0.04242753982543945, 0.012716934084892273, -0.05198388174176216, 0.024399280548095703, -0.023904675617814064, -0.015424352139234543, 0.011931498534977436, -0.02873249165713787, -0.0025332882069051266, -0.02330312877893448, 0.014708738774061203, -0.030983515083789825, 0.027331022545695305, 0.022595830261707306, 0.014493952505290508, 0.02215529792010784, -0.03409317508339882, 0.011707562021911144, 0.030960842967033386, 0.020237743854522705, -0.030845262110233307, -0.02478315494954586, -0.0002575993712525815, -0.004626822657883167, 0.025394441559910774, -0.013833210803568363, -0.029851431027054787, -0.020262183621525764, -0.004043363034725189, -0.049450527876615524, 0.010185587219893932, -0.007093509193509817, -0.013704066164791584, 0.020650524646043777, 0.004318541847169399, -0.03424448147416115, 0.03492800518870354, 0.0032937335781753063, -0.007067257072776556, -0.0454646535217762, -0.0022171572782099247, -0.03539496660232544, -0.0006774940993636847, -0.014554587192833424, -0.060651183128356934, -0.00007837540761101991, -0.031970616430044174, 0.033414918929338455, 0.02813897654414177, 0.08807077258825302, -0.03204171732068062, -0.002065527020022273, 0.007887681014835835, -0.018703117966651917, -0.03641626611351967, 0.004982902202755213, 0.05655309185385704, -0.0028590408619493246, 0.02930770255625248, -0.04049127176403999, -0.024062538519501686, -0.015209218487143517, 0.010660236701369286, 0.035824209451675415, -0.00934511050581932, -0.023788081482052803, -0.02834363840520382, 0.0219996590167284, 0.008937307633459568, 0.018730763345956802, 0.04136010631918907, -0.03161439299583435, 0.022824248299002647, -0.04421187564730644, 0.012544470839202404, -0.02711861953139305, -0.027592001482844353, -0.02812300994992256, -0.05312536284327507, -0.014272509142756462, 0.025271806865930557, 0.01843307726085186, 0.01543470099568367, -0.03397492691874504, -0.002086457796394825, -0.026076873764395714, 0.002017499413341284, -0.015657659620046616, 0.00396121246740222, 0.05467497557401657, 0.014374409802258015, 0.0024907654151320457, -0.03563379496335983, -0.026600342243909836, -0.04483899846673012, 0.000015716112102381885, 0.010460535064339638, 0.058827098459005356, 0.011414478532969952, -0.0021366197615861893, -0.0049600317142903805, -0.018299808725714684, -0.01313940342515707, -0.03482968360185623, -0.0010294315870851278, 0.01943371631205082, -0.005528782028704882, -0.016243258491158485, 0.016606604680418968, 0.0011026697466149926, -0.04614905267953873, 0.010153690353035927, -0.021620651707053185, -0.0031576778274029493, -0.031071648001670837, -0.006555324885994196, -0.07368552684783936, -0.048265643417835236, 0.010011072270572186, -0.012238952331244946, 0.07143355160951614, 0.04968298226594925, 0.019195029512047768, -0.013246987015008926, -0.013392399065196514, 0.0005820673541165888, -0.0016321907751262188, -0.036058444529771805, -0.032093390822410583, -0.0022195547353476286, 0.029109038412570953, -0.02766256406903267, -0.030848843976855278, 0.05217885971069336, 0.01449190080165863, -0.0008573394152335823, 0.00953771360218525, 0.020234033465385437, -0.010667966678738594, -0.008304079994559288, 0.04247792810201645, -0.010547907091677189, 0.05855083838105202, 0.031527671962976456, 0.027781208977103233, 0.039962686598300934, 0.007080733776092529 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
3. BERT model size & architecture Let’s break down the architecture for the two original BERT models: ML Architecture Glossary: | ML Architecture Parts | Definition | |-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Parameters: | Number of learnable variables/values available for the model. | | Transformer Layers: | Number of Transformer blocks. A transformer block transforms a sequence of word representations to a sequence of contextualized words (numbered representations). | | Hidden Size: | Layers of mathematical functions, located between the input and output, that assign weights (to words) to produce a desired result. | | Attention Heads: | The size of a Transformer block. | | Processing: | Type of processing unit used to train the model. | | Length of Training: | Time it took to train the model. Here’s how many of the above ML architecture parts BERTbase and BERTlarge has: | | Transformer Layers | Hidden Size | Attention Heads | Parameters | Processing | Length of Training | |-----------|--------------------|-------------|-----------------|------------|------------|--------------------| | BERTbase | 12 | 768 | 12 | 110M | 4 TPUs | 4 days | | BERTlarge | 24 | 1024 | 16 | 340M | 16 TPUs | 4 days | Let’s take a look at how BERTlarge’s additional layers, attention heads, and parameters have increased its performance across NLP tasks.
[ -0.003191212425008416, 0.012968813069164753, 0.05188194289803505, -0.027392981573939323, 0.022317005321383476, 0.0908113569021225, 0.0246156994253397, 0.05312579125165939, -0.04506785795092583, -0.002749375067651272, -0.07732722163200378, 0.038522083312273026, -0.0038786171935498714, 0.037468187510967255, -0.005063066259026527, -0.008936960250139236, 0.08950790017843246, -0.027452247217297554, -0.004194427747279406, -0.021296821534633636, 0.000052441049774643034, -0.09140747785568237, 0.0908127874135971, -0.007876993156969547, 0.035186219960451126, 0.0035962937399744987, -0.009592407383024693, -0.038317907601594925, 0.0020135855302214622, 0.06681255996227264, -0.13897928595542908, -0.00645021116361022, -0.00939503125846386, -0.0411091148853302, -0.04942915588617325, -0.02176738530397415, -0.09327476471662521, 0.06459330767393112, 0.008884253911674023, -0.05092594027519226, -0.018413398414850235, 0.0219966322183609, -0.06870228052139282, 0.035419970750808716, -0.0063967895694077015, -0.0007916671456769109, -0.1208530142903328, 0.05059942975640297, -0.03298183158040047, -0.002398231066763401, -0.0729551911354065, 0.04443530738353729, -0.043610818684101105, 0.06184353306889534, -0.007383285090327263, -0.011740755289793015, 0.021065043285489082, -0.0023270538076758385, 0.05305943638086319, -0.02223365381360054, 0.05669359117746353, 0.0037970594130456448, 0.02597784623503685, 0.061926424503326416, 0.010619054548442364, -0.0025786857586354017, -0.011427350342273712, -0.00974227488040924, -0.015484306961297989, 0.02425098605453968, -0.01730404980480671, -0.025678474456071854, -0.03364742547273636, -0.021633444353938103, -0.06370119750499725, -0.04201572760939598, 0.03506822511553764, 0.009207583032548428, 0.02732626534998417, 0.014927972108125687, 0.0031088506802916527, 0.028653454035520554, -0.009262416511774063, 0.03167007863521576, 0.0014599498827010393, -0.00681334501132369, 0.043921876698732376, -0.03711541369557381, -0.054663173854351044, 0.07935091108083725, -0.036532118916511536, -0.20453819632530212, -0.03953886777162552, -0.02484029531478882, 0.014474052004516125, -0.02473820559680462, -0.015342027880251408, -0.001851597218774259, -0.021851250901818275, 0.02159830927848816, 0.009006094187498093, -0.053744662553071976, 0.04999161884188652, 0.011172724887728691, -0.06983375549316406, 0.024699490517377853, 0.025548355653882027, -0.1265752911567688, -0.03181559219956398, -0.025729013606905937, -0.04696408659219742, -0.057000480592250824, 0.0003628490958362818, 0.074124276638031, -0.07412953674793243, 0.014827691949903965, -0.00686042383313179, 0.004478058777749538, 0.017532048746943474, 0.0492025651037693, -0.015845369547605515, 0.08130711317062378, 0.0793200135231018, -0.01898522488772869, 0.021304527297616005, 0.020247768610715866, -0.012895866297185421, 0.023543616756796837, 0.014995870180428028, -0.0433482863008976, 0.0647369921207428, -0.05740319937467575, 0.07020524144172668, -0.013845983892679214, -0.012797924689948559, -0.037742193788290024, -0.028172247111797333, -0.06109912320971489, 0.015751251950860023, -0.031068116426467896, -0.0820237547159195, 0.05247822403907776, -0.012595837004482746, 0.014862429350614548, 0.0577816367149353, -0.06066592037677765, -0.09605921804904938, 0.0073747592978179455, 0.000688309723045677, 0.004992597736418247, -0.09651530534029007, 0.028157224878668785, -0.049039267003536224, -0.03242279216647148, 0.05617673695087433, 0.046985168009996414, 0.0010314490646123886, -0.05968093127012253, -0.06326477974653244, -0.01342940703034401, -0.010928230360150337, 0.02358180657029152, -0.017309842631220818, 0.02762497030198574, 0.06453399360179901, -0.05049731954932213, 0.03464828431606293, 0.048551447689533234, 0.011241255328059196, 0.037734609097242355, -0.0142865851521492, -0.038098741322755814, 0.06799130141735077, 0.025701820850372314, -0.049194131046533585, 0.028873249888420105, 0.04828553646802902, 0.03477565199136734, -0.008518562652170658, -0.024609511718153954, -0.02805378846824169, 0.03796975314617157, -0.004191150423139334, 0.03746872395277023, 0.06242029368877411, -0.06524978578090668, 0.05734025686979294, -0.0674196109175682, -0.054826147854328156, 0.03238506242632866, 0.011964943259954453, -0.06478549540042877, 0.008869294077157974, 0.01799057610332966, 0.03125099092721939, -0.021437669172883034, -0.05412249639630318, 0.101911261677742, 0.031277142465114594, 0.060300856828689575, 0.07901604473590851, 0.02342260256409645, -0.008760574273765087, -0.00010832892439793795, 0.044711872935295105, -0.02544199861586094, 0.007054349407553673, -0.025556258857250214, 0.03524448722600937, -0.02762383408844471, 0.025910306721925735, -0.1035807803273201, 0.009320393204689026, -0.10359236598014832, 0.015472221188247204, -0.08193908631801605, 0.03149108216166496, -0.02480815164744854, 0.07240702211856842, -0.03913668170571327, 0.13370515406131744, -0.06789066642522812, -0.07182056456804276, 0.0014311174163594842, -0.023872654885053635, -0.0029110347386449575, 0.060080040246248245, 0.012043066322803497, 0.07177365571260452, -0.06294536590576172, -0.0435776524245739, -0.04975754767656326, 0.060592737048864365, 0.007399623282253742, -0.005858514923602343, -0.00809857901185751, -0.05611530318856239, 0.05058189481496811, 0.047989360988140106, -0.06099560484290123, -0.05272362753748894, -0.0336703397333622, 0.04181072860956192, 0.042251355946063995, -0.03291242569684982, -0.020409923046827316, 0.031408507376909256, 0.022900575771927834, -0.03377903252840042, 0.03300554305315018, -0.05360236018896103, 0.02829425036907196, 0.016582682728767395, -0.05955798178911209, 0.05669904500246048, 0.07040727883577347, 0.0031287241727113724, -0.04692879319190979, -0.010159782133996487, 0.013042503967881203, -0.032062143087387085, -0.019230995327234268, -0.0158842783421278, -0.036871567368507385, -0.013667933642864227, -0.055156905204057693, -0.0536712184548378, -0.016265306621789932, -0.0038559644017368555, 0.03117992728948593, 0.016313359141349792, -0.005711409728974104, 0.034161221235990524, 0.009719107300043106, 0.03607269376516342, -0.02416829578578472, 0.02297508530318737, -0.02785441279411316, -0.03013821691274643, -0.022852104157209396, -0.00017524993745610118, -0.028579991310834885, 0.0338285006582737, 0.033302102237939835, 0.010274207219481468, 0.0058815437369048595, -0.0024876478128135204, -0.03910422325134277, 0.0038674455136060715, -0.022598836570978165, 0.00926823541522026, 0.03672309219837189, -0.012198911048471928, -0.0357230119407177, 0.006921128369867802, 0.052835606038570404, 0.005823333282023668, -0.0065574743784964085, -0.013651657849550247, 0.013224990107119083, -0.00011641718447208405, 0.05526407063007355, -0.004307885654270649, -0.010714338161051273, -0.03655477240681648, 0.025902623310685158, 0.03464551270008087, 0.07236636430025101, -0.10027073323726654, -0.014946144074201584, 0.021815156564116478, 0.01741575263440609, 0.0034803515300154686, -0.007720767054706812, 0.02626391313970089, -0.017292940989136696, -0.009432480670511723, 0.007618484552949667, 0.025644812732934952, -0.029300887137651443, 0.017518797889351845, 0.03375055268406868, 0.002386556938290596, 0.008550151251256466, -0.012073691934347153, 0.004942332860082388, 0.036687303334474564, -0.02470627799630165, 0.002142799785360694, 0.014402983710169792, 0.02760201506316662, 0.0004623842833098024, 0.01564681902527809, 0.003988017328083515, 0.005922086536884308, 0.02576466277241707, 0.01858248934149742, 0.002866506576538086, -0.03728494793176651, -0.021125661209225655, -0.025311162695288658, 0.015336890704929829, -0.027233000844717026, 0.023009896278381348, 0.011639603413641453, 0.043384093791246414, 0.020604761317372322, 0.041615623980760574, 0.016476862132549286, -0.0125574404373765, 0.025668255984783173, 0.005298346746712923, 0.023117372766137123, -0.04709487408399582, 0.00022604118566960096, -0.00728073064237833, 0.020661629736423492, -0.007484487723559141, -0.0005151326186023653, -0.0494505874812603, -0.006573389284312725, 0.009116453118622303, 0.011663069948554039, -0.013524136506021023, 0.002441700780764222, -0.00017797846521716565, 0.030260249972343445, -0.008884935639798641, -0.04165882617235184, 0.03310359641909599, -0.02415112406015396, -0.004545903764665127, -0.03199400007724762, 0.028970101848244667, 0.015031163580715656, 0.04456513375043869, -0.00010961841326206923, 0.03476604446768761, -0.03143499419093132, 0.018501626327633858, 0.0049005248583853245, 0.005963447969406843, 0.005080820992588997, 0.015287988819181919, -0.015959979966282845, -0.011608841829001904, 0.07910476624965668, 0.026921534910798073, -0.03315671905875206, 0.013418999500572681, -0.04578729718923569, 0.013395300135016441, 0.018986057490110397, 0.00848415493965149, 0.013479158282279968, -0.007631487213075161, 0.03886857628822327, 0.043881628662347794, -0.008509908802807331, -0.023755505681037903, -0.007985040545463562, -0.01113440003246069, 0.002115710871294141, 0.0050710150972008705, 0.00011657202412607148, -0.04270888864994049, -0.010153680108487606, 0.010977206751704216, 0.036567557603120804, -0.06330954283475876, -0.005887412931770086, -0.017350856214761734, 0.008005541749298573, 0.033198900520801544, -0.05071939155459404, -0.021098747849464417, 0.04062412306666374, -0.006760414689779282, 0.0020861723460257053, 0.01461447961628437, -0.004670622292906046, 0.021152881905436516, 0.028885895386338234, 0.04285218194127083, -0.024858985096216202, -0.045457623898983, -0.0005072730709798634, 0.009283620864152908, -0.006880029104650021, 0.023057937622070312, -0.019068939611315727, 0.008830755949020386, 0.02283474989235401, -0.00796051137149334, 0.05424525588750839, 0.02230352908372879, 0.014605074189603329, -0.023994076997041702, -0.023146050050854683, 0.0161757655441761, 0.051298074424266815, 0.013884009793400764, -0.02109428308904171, 0.042876362800598145, -0.022311247885227203, 0.022694600746035576, 0.0007860809564590454, -0.05467817932367325, -0.007584422826766968, 0.045855361968278885, 0.008394590578973293, -0.029454533010721207, 0.021658021956682205, -0.0031535178422927856, -0.06743822246789932, -0.000739309296477586, -0.0438561737537384, 0.011240015737712383, 0.07250253856182098, -0.033220671117305756, -0.08553241193294525, 0.011072416789829731, 0.0010809096274897456, -0.01369481161236763, 0.0038156781811267138, 0.03897056356072426, -0.009201549924910069, 0.04539889097213745, -0.012667732313275337, 0.012182897888123989, -0.060107290744781494, 0.04051021859049797, 0.01723729632794857, 0.005649442784488201, 0.005140785127878189, -0.053346965461969376, 0.007724568713456392, 0.018498210236430168, 0.007873411290347576, -0.028751825913786888, -0.021013101562857628, -0.028732135891914368, 0.0028625898994505405, 0.050151221454143524, -0.006106544751673937, 0.011699690483510494, 0.009884410537779331, -0.00991304125636816, -0.031633440405130386, -0.003718588501214981, -0.03112388402223587, 0.031829480081796646, 0.006660123355686665, 0.034119125455617905, 0.04365872964262962, 0.08112025260925293, 0.0027719163335859776, 0.05412666127085686, 0.0343388170003891, 0.021250933408737183, 0.028233343735337257, -0.0066742063499987125, -0.020983366295695305, -0.0027074585668742657, -0.005612742155790329, 0.024304956197738647, 0.013333206996321678, 0.00882868841290474, -0.0030134599655866623, 0.03230837360024452, -0.0031530088745057583, 0.03339288383722305, 0.005889188963919878, -0.011632905341684818, 0.034352779388427734, -0.0661347359418869, 0.03471876680850983, -0.0123930424451828, -0.015316134318709373, -0.0008857795619405806, -0.010449585504829884, 0.005585719831287861, -0.007403165567666292, -0.047006215900182724, -0.02378644421696663, 0.030275363475084305, 0.030551264062523842, 0.006826705299317837, -0.0023577879182994366, -0.002214817563071847, -0.027357829734683037, 0.023356759920716286, 0.012104494497179985, -0.06593624502420425, 0.009439099580049515, 0.022699378430843353, -0.011213529855012894, 0.01350471843034029, 0.047591179609298706, -0.019526660442352295, 0.014483317732810974, 0.064827561378479, -0.01425810344517231, -0.042921166867017746, -0.028472356498241425, 0.011121916584670544, 0.038484085351228714, 0.00045420308015309274, -0.015359025448560715, 0.017046412453055382, -0.025142371654510498, 0.04446794092655182, -0.03424229472875595, -0.023472372442483902, 0.06071002036333084, -0.004762479104101658, 0.023227980360388756, 0.017952166497707367, 0.024974096566438675, -0.0007276082178577781, 0.026006733998656273, 0.014637387357652187, 0.0281752310693264, 0.0605110228061676, 0.012057325802743435, 0.014921288006007671, 0.0523877888917923, 0.041299864649772644, 0.02091551013290882, -0.04130788519978523, 0.03927380591630936, -0.013362990692257881, -0.03524294123053551, 0.01751171611249447, -0.009836825542151928, -0.043503087013959885, 0.030205367133021355, 0.05666787549853325, 0.028963780030608177, 0.04224391281604767, -0.03685317188501358, 0.010155896656215191, -0.00036360969534143806, -0.0325925275683403, 0.027767518535256386, 0.06449506431818008, 0.006063137203454971, 0.05141899362206459, 0.026652632281184196, 0.03609609976410866, 0.058427002280950546, -0.012432189658284187, -0.014250155538320541, 0.012254239991307259, 0.06766968965530396, 0.002573076169937849, 0.0028220247477293015, 0.017925554886460304, -0.006506310775876045, -0.01976146548986435, -0.005010790191590786, 0.0017640903824940324, -0.07484201341867447, -0.017797110602259636, 0.01876160316169262, -0.024036971852183342, 0.052057523280382156, -0.010748453438282013, 0.016661645844578743, 0.03226329758763313, 0.023152029141783714, -0.000060146336181787774, 0.02925369329750538, 0.024821683764457703, -0.0018982882611453533, 0.003985142335295677, 0.02389797568321228, -0.01175687089562416, 0.008402783423662186, 0.05049624294042587, 0.028466111049056053, 0.02096608094871044, 0.01672631874680519, -0.05752658098936081, 0.0031511380802839994, -0.04686679318547249, -0.021376503631472588, 0.011942327953875065, -0.009526637382805347, -0.029721442610025406, 0.0016171552706509829, 0.012859891168773174, -0.05548940226435661, 0.030980009585618973, -0.011946438811719418, -0.010602854192256927, 0.015669822692871094, -0.027015969157218933, 0.01702791638672352, 0.02232273295521736, -0.008602499961853027, -0.03874530270695686, -0.024419458582997322, -0.035773634910583496, -0.013620821759104729, 0.0021191644482314587, 0.0023725125938653946, -0.0058863782323896885, -0.009011325426399708, 0.002285535680130124, -0.03991534188389778, 0.034589752554893494, -0.000615969649516046, 0.024709533900022507, 0.053752876818180084, 0.02193274535238743, -0.008006834425032139, 0.032511141151189804, -0.005062897223979235, -0.017290178686380386, -0.048633720725774765, 0.000266495393589139, -0.01914999447762966, -0.010903687216341496, 0.00003972148988395929, -0.015051255002617836, -0.020040418952703476, -0.02211768738925457, 0.04232075437903404, 0.033691395074129105, 0.06667158007621765, -0.03201622888445854, 0.003149760654196143, 0.007617283146828413, -0.029954444617033005, -0.025491658598184586, -0.006468223873525858, 0.03994366154074669, 0.007620837539434433, 0.033590905368328094, -0.03321457654237747, -0.04664354771375656, -0.046299226582050323, 0.030802059918642044, 0.020536595955491066, -0.010514810681343079, 0.0025166317354887724, -0.03717619553208351, 0.02703911066055298, 0.04365063086152077, 0.017316963523626328, 0.06875607371330261, 0.01719363033771515, -0.007972738705575466, -0.045956145972013474, 0.007983923889696598, -0.01397265400737524, -0.00760934641584754, -0.04620499163866043, -0.03815449774265289, -0.01837201789021492, 0.030329156666994095, 0.013603691011667252, 0.02591005153954029, -0.034920673817396164, 0.0024163653142750263, -0.028091520071029663, -0.0030260600615292788, -0.02315543219447136, 0.01345718652009964, 0.026309896260499954, 0.0346413217484951, 0.0343589261174202, 0.004019488114863634, -0.018068065866827965, -0.017752692103385925, -0.0238251443952322, -0.013202588073909283, 0.02551940083503723, -0.016694599762558937, -0.0034710285253822803, -0.0020239122677594423, -0.02594275400042534, -0.0012174046132713556, -0.05475696921348572, -0.00029329617973417044, 0.010486540384590626, -0.004809207282960415, 0.01006767712533474, 0.011454532854259014, -0.004036193713545799, 0.005311061628162861, 0.0590955950319767, -0.01890198327600956, -0.019926344975829124, -0.015586724504828453, 0.004350109025835991, -0.06850899010896683, -0.03092697262763977, 0.02266710251569748, -0.025107670575380325, 0.06955806165933609, 0.01103447750210762, 0.010802268981933594, 0.014814007095992565, -0.007244134321808815, 0.04282531142234802, -0.006005147472023964, -0.05106807500123978, -0.02800392545759678, 0.00146095035597682, 0.0494123175740242, -0.03893672674894333, -0.009747980162501335, 0.02449086681008339, 0.04130680486559868, 0.008389391005039215, 0.014982245862483978, 0.0010880316840484738, -0.0005166148184798658, 0.0007318831630982459, 0.05038628354668617, -0.016648931428790092, 0.03542756661772728, 0.013304024934768677, 0.05569171532988548, 0.020232781767845154, 0.011739029549062252 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
8. BERT FAQs Can BERT be used with PyTorch? Yes! Our experts at Hugging Face have open-sourced the PyTorch transformers repository on GitHub. Pro Tip: Lewis Tunstall, Leandro von Werra, and Thomas Wolf also wrote a book to help people build language applications with Hugging Face called, ‘Natural Language Processing with Transformers’. Can BERT be used with Tensorflow? Yes! You can use Tensorflow as the backend of Transformers. How long does it take to pre-train BERT? The 2 original BERT models were trained on 4(BERTbase) and 16(BERTlarge) Cloud TPUs for 4 days. How long does it take to fine-tune BERT? For common NLP tasks discussed above, BERT takes between 1-25mins on a single Cloud TPU or between 1-130mins on a single GPU. What makes BERT different? BERT was one of the first models in NLP that was trained in a two-step way: BERT was trained on massive amounts of unlabeled data (no human annotation) in an unsupervised fashion. BERT was then trained on small amounts of human-annotated data starting from the previous pre-trained model resulting in state-of-the-art performance.
[ 0.009348593652248383, -0.007950927130877972, 0.023617587983608246, 0.011749756522476673, -0.00042255010339431465, 0.06374840438365936, 0.0374116376042366, 0.10978208482265472, 0.006765556987375021, -0.016818493604660034, -0.09302923828363419, 0.10187128931283951, -0.010903418995440006, 0.020296068862080574, -0.005074494052678347, -0.05921115726232529, 0.03817175328731537, -0.020336704328656197, -0.023813718929886818, -0.003698576707392931, 0.009606395848095417, -0.07814738154411316, 0.05660480633378029, 0.007809581235051155, 0.006614549085497856, -0.046037811785936356, -0.006631042342633009, 0.011305442079901695, -0.011776981875300407, 0.00615120492875576, -0.1277058720588684, -0.003987197298556566, 0.012379727326333523, -0.02765665389597416, -0.015737198293209076, -0.002798118395730853, -0.061725202947854996, 0.09138773381710052, 0.05572856217622757, -0.021018894389271736, -0.04432472586631775, 0.016344429925084114, -0.07582850754261017, 0.06345373392105103, -0.012000824324786663, -0.0037354480009526014, -0.12134319543838501, 0.0947578176856041, -0.0002196259592892602, -0.04064943268895149, -0.08192659169435501, 0.08406523615121841, -0.015168173238635063, 0.018003227189183235, -0.008165081031620502, 0.05519300699234009, -0.041412368416786194, -0.02084745280444622, -0.023188810795545578, 0.007054908201098442, 0.03568205237388611, -0.019918592646718025, -0.0002086806925944984, 0.010811161249876022, 0.022287648171186447, 0.006063646171241999, -0.033017244189977646, -0.01662668213248253, -0.05538477376103401, 0.015035673975944519, 0.03616113215684891, -0.04203321039676666, -0.037558212876319885, -0.0022974638268351555, -0.040373995900154114, -0.014371318742632866, 0.01928427629172802, 0.021478859707713127, 0.02779805101454258, 0.03591624274849892, -0.0007894232403486967, 0.014411243610084057, -0.004145740997046232, 0.01765279285609722, 0.035589322447776794, 0.024073027074337006, 0.03885190188884735, -0.019735829904675484, -0.06028585135936737, 0.05720321461558342, -0.020814619958400726, -0.1574580818414688, -0.01771130971610546, -0.037041570991277695, 0.01026486698538065, -0.023334750905632973, -0.05194488912820816, 0.029298342764377594, -0.05252411216497421, -0.03695593774318695, 0.03333277627825737, -0.09080440551042557, 0.018412364646792412, -0.015178954228758812, -0.07084806263446808, 0.029449664056301117, -0.009208706207573414, -0.1300126165151596, -0.007686334662139416, -0.013013379648327827, -0.008630991913378239, -0.03747756779193878, 0.0121384896337986, 0.08994457125663757, -0.08461382240056992, 0.02312202751636505, 0.03807637840509415, -0.002418115735054016, -0.009276799857616425, 0.0066851540468633175, 0.002476900815963745, 0.04917218163609505, 0.012846390716731548, -0.012606896460056305, 0.010645955801010132, 0.08808952569961548, 0.005035882815718651, 0.005107934586703777, 0.01815325953066349, -0.016042223200201988, 0.06627608090639114, -0.0602448508143425, 0.09225118905305862, -0.04035148769617081, 0.014007211662828922, 0.014338136650621891, 0.00445567537099123, -0.06386525928974152, 0.0234743133187294, -0.0164671428501606, -0.03570495918393135, 0.09573585540056229, -0.023294687271118164, 0.01996867172420025, 0.06032276153564453, -0.015759607776999474, -0.09850408881902695, 0.08389688283205032, -0.021971656009554863, 0.034287624061107635, -0.15815888345241547, 0.056061774492263794, -0.006724642124027014, -0.040172457695007324, 0.024858439341187477, 0.08128821104764938, -0.010080008767545223, -0.042002636939287186, -0.04883771762251854, -0.057965174317359924, -0.002887151436880231, 0.03719469904899597, -0.06056603416800499, -0.01208341121673584, 0.025839252397418022, -0.07178851962089539, 0.007203825283795595, 0.005023658741265535, -0.00767106469720602, 0.040374916046857834, 0.014510960318148136, 0.01015824731439352, 0.10065022110939026, -0.027469728142023087, 0.0024972092360258102, 0.02878846973180771, 0.04933105409145355, 0.047661397606134415, 0.006776323541998863, -0.04770791158080101, -0.017442474141716957, 0.05704120174050331, 0.03811229392886162, 0.035609737038612366, 0.028882451355457306, -0.050534315407276154, 0.023304328322410583, -0.06996836513280869, 0.0070672971196472645, 0.04049306362867355, 0.032771430909633636, -0.021615587174892426, 0.058133624494075775, -0.03795449063181877, 0.027306759729981422, -0.049730680882930756, -0.044285714626312256, 0.11577904224395752, -0.007495207246392965, 0.047044169157743454, 0.0720837190747261, -0.04325708746910095, 0.02143373154103756, -0.009450385347008705, -0.030881034210324287, 0.022708728909492493, 0.06721071153879166, -0.02986888214945793, 0.01200022641569376, -0.021969882771372795, 0.050954654812812805, -0.14487236738204956, -0.019230518490076065, -0.06125606596469879, 0.006167121697217226, -0.0787758156657219, -0.0009028808563016355, 0.0002195030974689871, 0.06998459994792938, -0.014422373846173286, 0.17573386430740356, -0.029544545337557793, -0.012239032424986362, -0.017028262838721275, -0.03607941418886185, -0.03439461439847946, 0.027691444382071495, 0.0507587306201458, 0.08881225436925888, -0.06322115659713745, -0.06322845816612244, -0.09667777270078659, -0.018238604068756104, 0.00530054559931159, -0.04500662162899971, -0.03999825567007065, -0.020949818193912506, -0.013808772899210453, 0.009097299538552761, -0.016538962721824646, -0.02008136920630932, -0.008668039925396442, 0.023912236094474792, 0.05025620386004448, -0.030454719439148903, 0.01591525971889496, 0.045739494264125824, 0.040226906538009644, -0.017933353781700134, 0.034080762416124344, -0.09914736449718475, -0.0002587019116617739, -0.004887427669018507, -0.02519013173878193, 0.06173524260520935, 0.07468504458665848, -0.008032799698412418, -0.02119842916727066, -0.011533033102750778, 0.04699739068746567, 0.015187163837254047, -0.025490790605545044, -0.028747204691171646, -0.011059101670980453, -0.01964535191655159, -0.0538371279835701, -0.02546939067542553, 0.0015926397172734141, 0.011537251994013786, 0.01518260594457388, 0.032676246017217636, -0.04390696436166763, 0.02762446738779545, 0.023279057815670967, 0.03791080415248871, 0.03838202729821205, 0.05117020756006241, -0.017371738329529762, -0.05062677711248398, -0.031194237992167473, 0.01209397055208683, -0.03901756554841995, 0.041084207594394684, 0.017884058877825737, 0.0069386460818350315, -0.007136181462556124, -0.002473061438649893, -0.046063248068094254, -0.030970374122262, 0.0005678014713339508, 0.023658381775021553, 0.02671978250145912, -0.014834362082183361, -0.022624125704169273, -0.008495427668094635, 0.03141948953270912, 0.0078971479088068, -0.013009641319513321, 0.0062764231115579605, 0.03519747406244278, -0.004617608617991209, -0.010158984921872616, -0.016762277111411095, -0.02723400667309761, -0.0179574154317379, 0.0006902377353981137, 0.03178840130567551, 0.008602495305240154, -0.09717060625553131, -0.018472064286470413, -0.020750926807522774, 0.01005829218775034, 0.008192277513444424, -0.010975608602166176, 0.02286318689584732, 0.0023935195058584213, -0.008454134687781334, 0.02509669028222561, -0.005584585014730692, 0.0007507851696573198, 0.02239733189344406, 0.03289305791258812, 0.007335369475185871, -0.004240632522851229, -0.007092666812241077, -0.001576801878400147, 0.005959693342447281, 0.01898208260536194, -0.06420691311359406, 0.03120502457022667, -0.005405718460679054, 0.039736341685056686, -0.0223548524081707, -0.004917670041322708, 0.0033234849106520414, 0.00549864349886775, 0.04135280102491379, -0.02678018808364868, -0.002007480710744858, -0.0462547205388546, -0.013480030000209808, 0.03179144114255905, -0.013517696410417557, -0.030203435570001602, -0.011761436238884926, 0.05749378725886345, 0.05579955503344536, 0.027145536616444588, -0.004142319783568382, 0.015621224418282509, -0.014547400176525116, -0.008181091398000717, 0.025893453508615494, -0.019094519317150116, -0.016545943915843964, -0.024318711832165718, 0.011580958031117916, -0.007570822257548571, -0.0038476597983390093, -0.030794864520430565, -0.007642420940101147, 0.019933750852942467, 0.020454948768019676, -0.01168216671794653, 0.0017874168697744608, 0.01880253665149212, 0.01293486263602972, -0.014819856733083725, -0.0308807585388422, 0.036991361528635025, -0.016818491742014885, -0.021235132589936256, -0.016261044889688492, 0.027187325060367584, 0.03009326569736004, 0.01952175982296467, 0.01117176003754139, 0.008523240685462952, -0.004041073378175497, 0.029657505452632904, 0.001465424313209951, 0.006110864691436291, 0.00021557888248935342, 0.0152860376983881, -0.028013912960886955, -0.00882878340780735, 0.07239682227373123, 0.044178105890750885, -0.03658367320895195, -0.02429305389523506, -0.025985050946474075, -0.027307895943522453, 0.019969100132584572, -0.007858538068830967, 0.03074653446674347, -0.03107256256043911, 0.028176425024867058, 0.026234300807118416, 0.005109020974487066, -0.02914956398308277, 0.006889234762638807, 0.006325921043753624, -0.0007471693097613752, -0.02426539734005928, 0.01433178223669529, 0.018675411120057106, -0.005744142457842827, -0.0041093165054917336, 0.02497674524784088, -0.04633360728621483, -0.011753277853131294, -0.009821469895541668, 0.009071565233170986, 0.03320988640189171, -0.015126395039260387, -0.023180346935987473, 0.029682224616408348, 0.000008487168088322505, 0.0035231562796980143, 0.010255806148052216, 0.012474039569497108, 0.0010933498851954937, 0.03472524136304855, 0.060273319482803345, -0.004454244393855333, -0.05435676500201225, -0.04927464947104454, 0.04165196046233177, -0.01221185177564621, 0.039804473519325256, -0.007278078701347113, -0.004474235698580742, 0.02664205990731716, 0.011726978234946728, 0.03131486102938652, 0.038840796798467636, 0.008206376805901527, -0.019713712856173515, -0.03419561684131622, -0.010847821831703186, 0.022693391889333725, 0.03284674882888794, -0.02964416705071926, 0.005723616108298302, 0.01603517308831215, -0.019383221864700317, -0.010704671032726765, -0.028403189033269882, -0.03132376819849014, 0.019223704934120178, 0.031011473387479782, -0.02000933140516281, 0.03398919105529785, 0.014383440837264061, -0.04564080014824867, -0.00752688106149435, -0.027532437816262245, 0.026629354804754257, 0.05797535553574562, -0.02663598023355007, -0.0507163479924202, -0.009727013297379017, 0.024997789412736893, -0.03572475165128708, 0.004724596161395311, 0.05099638178944588, 0.037176333367824554, 0.05740341544151306, -0.010173280723392963, 0.007438128814101219, -0.027471544221043587, 0.007263039238750935, 0.0440497100353241, 0.006722149904817343, 0.007629774510860443, -0.03950265422463417, -0.0019688482861965895, -0.004599426407366991, -0.0021173162385821342, -0.011678260751068592, 0.0038125193677842617, -0.04446767643094063, -0.005030048545449972, 0.06149004027247429, 0.012608945369720459, -0.0012375136138871312, 0.0023409384302794933, 0.01846078783273697, -0.012963486835360527, 0.015066343359649181, -0.013397765345871449, -0.00805782899260521, -0.0003650207072496414, 0.039435598999261856, 0.0461297333240509, 0.07522846758365631, 0.009190807119011879, 0.023230373859405518, -0.01240049209445715, -0.017428487539291382, 0.0028153378516435623, -0.021292870864272118, 0.0033380549866706133, -0.032336603850126266, -0.013470432721078396, 0.034311406314373016, -0.007879619486629963, -0.015535560436546803, -0.004906569607555866, 0.04940420016646385, -0.02496621012687683, 0.007956402376294136, 0.06003555655479431, -0.00768968416377902, -0.014022821560502052, -0.04104233160614967, -0.004384506959468126, -0.05109141021966934, -0.0012958452571183443, 0.012092427350580692, 0.03864001855254173, 0.054590366780757904, 0.008935154415667057, -0.019347332417964935, -0.02771955169737339, 0.03368416801095009, 0.047586943954229355, 0.03142603114247322, -0.0038472565356642008, -0.005966177210211754, -0.03266433998942375, 0.02044268324971199, 0.036739666014909744, -0.052485834807157516, 0.021111687645316124, 0.010384411551058292, 0.0016539323842152953, 0.004241103306412697, 0.029175227507948875, -0.009633101522922516, -0.024746689945459366, 0.06297802925109863, 0.00035132485209032893, -0.010226699523627758, -0.019494177773594856, 0.013991927728056908, 0.02708877995610237, -0.004110765643417835, -0.02036151848733425, -0.026766551658511162, -0.0367068313062191, 0.010557125322520733, -0.045195069164037704, 0.004025198053568602, 0.08377241343259811, -0.02597680315375328, 0.0068084984086453915, -0.004455956630408764, 0.01948845013976097, 0.013041608035564423, -0.023124778643250465, -0.0143185555934906, 0.04078618809580803, 0.028686868026852608, 0.029053011909127235, 0.016602950170636177, 0.027810901403427124, 0.016759058460593224, 0.030340492725372314, -0.05296129360795021, 0.036579687148332596, 0.00321448827162385, -0.012204115279018879, 0.0084811020642519, 0.009127713739871979, -0.018775567412376404, 0.006521835923194885, 0.024169154465198517, -0.004108397755771875, 0.015636149793863297, -0.00903460942208767, 0.0025878853630274534, -0.014830167405307293, -0.02837328426539898, -0.001115119899623096, 0.0759618803858757, -0.020977720618247986, 0.06866265833377838, 0.04607018455862999, 0.05055767670273781, 0.04833244904875755, -0.01318430621176958, -0.015333551913499832, 0.012273556552827358, 0.042061761021614075, 0.03000037372112274, 0.03429582715034485, 0.0342438630759716, -0.02577357180416584, -0.024720484390854836, -0.03113427571952343, -0.007004966028034687, -0.05845349654555321, -0.022691868245601654, 0.04821479320526123, -0.019105348736047745, 0.008381498046219349, -0.006631309166550636, 0.02581108920276165, 0.03554161638021469, 0.06652804464101791, -0.03203330561518669, 0.050586093217134476, 0.02602411061525345, 0.01916409470140934, 0.012248835526406765, 0.01179997157305479, 0.006515224929898977, 0.006797722540795803, 0.034293077886104584, 0.05682677775621414, 0.045685697346925735, -0.009624117985367775, -0.02268206514418125, 0.02743893302977085, 0.015302383340895176, -0.040792737156152725, 0.02022711932659149, 0.007718749810010195, 0.008863705210387707, -0.02879442647099495, 0.05728693678975105, -0.03989981859922409, 0.054683417081832886, 0.00195406936109066, -0.02139594778418541, 0.0011602824088186026, -0.03069986216723919, -0.015583956614136696, 0.05498581379652023, 0.01342130359262228, -0.04570748284459114, 0.0017366738757118583, -0.005613160785287619, -0.0016022194176912308, 0.021369192749261856, -0.03085184656083584, -0.02325691469013691, -0.014947762712836266, -0.013570079579949379, -0.02343732863664627, 0.02222294546663761, -0.012304376810789108, 0.01218605786561966, 0.03236192464828491, 0.01890510879456997, -0.017284562811255455, 0.025150315836071968, 0.021334316581487656, -0.011143616400659084, -0.04771300405263901, 0.0024003360886126757, 0.0017044275300577283, -0.022505713626742363, 0.028531789779663086, -0.0356634221971035, 0.009467003867030144, -0.031290892511606216, 0.03061709739267826, 0.03343954309821129, 0.06556182354688644, -0.02325042337179184, -0.06027482450008392, 0.0041882689110934734, 0.019059844315052032, -0.044764891266822815, 0.033274244517087936, 0.05150144174695015, -0.007542073726654053, 0.02907492220401764, -0.005764213856309652, -0.010835600085556507, -0.03340698778629303, -0.012265719473361969, 0.037429049611091614, -0.011910646222531796, -0.041279081255197525, -0.005079967435449362, 0.01754775084555149, 0.005664017051458359, -0.0027873676735907793, 0.035492658615112305, -0.04051953926682472, 0.005684132222086191, -0.04582595080137253, -0.0036978796124458313, -0.02218642458319664, 0.006038475316017866, -0.026924341917037964, -0.04454754665493965, -0.013949159532785416, 0.014429912902414799, 0.007239207159727812, -0.012480094097554684, -0.03677373006939888, 0.0027405410073697567, -0.03087250329554081, 0.0038450779393315315, 0.010365085676312447, -0.0014820134965702891, 0.06611251831054688, 0.016777636483311653, 0.022701680660247803, -0.002110384637489915, 0.003962664399296045, -0.00875028595328331, -0.03667667880654335, 0.00929698720574379, 0.025965798646211624, 0.02403990551829338, -0.020492997020483017, -0.010024053044617176, -0.0321563221514225, -0.003164303954690695, -0.03734248876571655, 0.009284302592277527, 0.008912866935133934, 0.0045160031877458096, 0.0000619698766968213, -0.005931748542934656, 0.022778332233428955, -0.03145723417401314, 0.049405261874198914, -0.009687398560345173, -0.008351936005055904, -0.005452402867376804, -0.005197073798626661, -0.05443970486521721, -0.009095943532884121, 0.014391947537660599, -0.03634067624807358, 0.05437951162457466, 0.019723189994692802, 0.0215196181088686, 0.0031113396398723125, 0.010699229314923286, 0.008037353865802288, -0.003965903539210558, -0.05205933749675751, -0.03641105443239212, -0.022056275978684425, 0.06018650159239769, -0.01857447624206543, -0.03405139595270157, 0.04485691711306572, -0.010217906907200813, -0.017035983502864838, -0.01955523155629635, 0.01180566381663084, -0.026824263855814934, -0.023142201825976372, 0.005800798535346985, -0.013286643661558628, 0.05049731582403183, 0.0024506773333996534, 0.0041344668716192245, 0.00020867164130322635, -0.0008053666097112 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
1.1 Example of BERT BERT helps Google better surface (English) results for nearly all searches since November of 2020. Here’s an example of how BERT helps Google better understand specific searches like: Source Pre-BERT Google surfaced information about getting a prescription filled. Post-BERT Google understands that “for someone” relates to picking up a prescription for someone else and the search results now help to answer that. ---
[ 0.035106148570775986, -0.029199892655014992, 0.06322256475687027, -0.05092445760965347, 0.05858445540070534, 0.08556414395570755, 0.014457172714173794, 0.08279608190059662, -0.015126763842999935, -0.013702690601348877, -0.05936916172504425, -0.0005822794628329575, -0.007196543272584677, 0.04138084128499031, -0.0007465339731425047, 0.009007018990814686, 0.032346561551094055, -0.008585592731833458, 0.003638619789853692, 0.018817903473973274, -0.005984634160995483, 0.010732775554060936, 0.11212803423404694, -0.04182751104235649, 0.10034682601690292, -0.03975226357579231, -0.022335657849907875, -0.003154186299070716, -0.09454569220542908, 0.05582912266254425, -0.05917603522539139, -0.02888089045882225, -0.006544991862028837, -0.00913017988204956, -0.09132454544305801, 0.029084760695695877, -0.008797185495495796, 0.0400882214307785, -0.07286600768566132, -0.030729059129953384, -0.045198503881692886, -0.05759240686893463, -0.051010943949222565, 0.022443050518631935, -0.029706140980124474, -0.0032418270129710436, -0.22850297391414642, 0.07137364149093628, 0.018252361565828323, -0.024144334718585014, -0.10852690786123276, 0.07541288435459137, -0.01697787083685398, -0.0004521161026787013, -0.004080379381775856, 0.048979680985212326, 0.043067317456007004, -0.08145929127931595, 0.043337997049093246, 0.013231662102043629, 0.04196387156844139, 0.01815512590110302, 0.029143095016479492, 0.0003172731667291373, -0.019574202597141266, 0.017417486757040024, -0.078035369515419, -0.051069147884845734, -0.06779772788286209, 0.02763543464243412, 0.011656297370791435, -0.05995500832796097, -0.0625116154551506, 0.05889246612787247, -0.02360970340669155, 0.03389260545372963, -0.011053146794438362, -0.03318812698125839, -0.039821725338697433, -0.02353064715862274, -0.01648283563554287, -0.02647837996482849, 0.03208402544260025, 0.013999837450683117, 0.031737275421619415, 0.008578763343393803, 0.07121721655130386, -0.02975110337138176, -0.062287963926792145, 0.030007733032107353, 0.008601624518632889, -0.1365347057580948, -0.010081646032631397, -0.05139348283410072, 0.06367180496454239, -0.05848243460059166, 0.011423919349908829, -0.03125154227018356, -0.00435636006295681, -0.04938231781125069, -0.022271445021033287, -0.07637935131788254, 0.07457208633422852, 0.012229346670210361, -0.10396329313516617, 0.00006860751454951242, 0.010313035920262337, -0.08327463269233704, -0.011432738043367863, 0.04623555764555931, 0.02361978217959404, -0.01081196591258049, -0.015192550607025623, 0.06935156881809235, -0.025263503193855286, 0.056745171546936035, 0.05015331134200096, 0.013095700182020664, 0.007631220854818821, 0.03180598095059395, -0.03898264840245247, 0.025954261422157288, 0.0354539193212986, -0.0016345845069736242, 0.05112138018012047, 0.038868024945259094, 0.007933596149086952, 0.0035776407457888126, -0.0044366298243403435, 0.007029477506875992, 0.06375762075185776, 0.016000907868146896, 0.07618335634469986, -0.04299158230423927, 0.0011215516133233905, 0.03328273817896843, 0.010541565716266632, -0.10809428989887238, -0.01268863957375288, -0.019258463755249977, -0.016741057857871056, 0.001989644020795822, -0.013561836443841457, 0.003360952716320753, 0.065489761531353, -0.003272606525570154, -0.053174495697021484, 0.06135464087128639, -0.07975570857524872, 0.05384683236479759, -0.0862683579325676, 0.0032701606396585703, 0.0056963153183460236, -0.0834614560008049, 0.06390964239835739, 0.04065478593111038, 0.002197262831032276, -0.04498562961816788, 0.008882441557943821, -0.020159374922513962, -0.007752569857984781, 0.046005070209503174, -0.0017793489387258887, 0.03900252655148506, -0.021136965602636337, -0.06925642490386963, -0.010356900282204151, 0.016421154141426086, -0.0006198363262228668, 0.061766982078552246, -0.0038610734045505524, -0.010542875155806541, 0.07436046749353409, -0.04421062767505646, 0.005491842050105333, 0.05334185063838959, 0.07348094135522842, 0.03006461262702942, 0.04929789900779724, -0.005652419291436672, -0.009606375358998775, 0.05829664692282677, 0.00970767717808485, -0.007093075197190046, -0.005864053498953581, -0.005586978513747454, 0.02568107284605503, 0.007863109931349754, 0.04743247479200363, -0.000987292849458754, -0.01588333584368229, -0.0735892727971077, 0.06022266671061516, -0.020474907010793686, 0.011472539976239204, 0.00676611578091979, -0.033219434320926666, 0.0901922956109047, 0.026884587481617928, 0.0032013310119509697, 0.04034563526511192, -0.06140316277742386, 0.013157689943909645, -0.002807167824357748, -0.018512150272727013, 0.03648173436522484, 0.13651274144649506, -0.049057621508836746, -0.0219996590167284, 0.024175187572836876, 0.0846002921462059, -0.10501927882432938, 0.01455130334943533, -0.10308799147605896, 0.013787709176540375, -0.0812668725848198, 0.04721703380346298, 0.05521100386977196, -0.037847522646188736, -0.015852371230721474, 0.0772320032119751, 0.0016159493243321776, 0.025119775906205177, 0.04117506742477417, -0.02287123166024685, 0.07197786122560501, 0.07074064016342163, 0.01202207338064909, 0.05871974304318428, -0.0279516763985157, -0.0738912969827652, 0.008320407941937447, 0.06123809143900871, -0.007896563969552517, -0.015617973171174526, 0.016666676849126816, 0.01797253079712391, -0.009932219982147217, -0.006207754369825125, 0.03164958953857422, -0.023605456575751305, 0.01786845736205578, 0.06358589977025986, 0.07503954321146011, -0.060046009719371796, -0.035352203994989395, 0.059053611010313034, -0.034022007137537, 0.004382610786706209, -0.020844778046011925, -0.0511331707239151, -0.020467715337872505, -0.04147842526435852, -0.0713820680975914, 0.023330576717853546, 0.04376426339149475, 0.022807016968727112, -0.03586205840110779, 0.015620044432580471, 0.05341319739818573, -0.014240913093090057, -0.029210256412625313, 0.0018102170433849096, -0.03529224172234535, -0.004556823521852493, -0.03177845478057861, -0.02107713185250759, 0.009357226081192493, -0.025040889158844948, 0.048831693828105927, 0.004822668619453907, -0.037987712770700455, 0.01936989650130272, 0.019097240641713142, 0.051690440624952316, 0.03525811806321144, 0.04048828408122063, 0.07419271767139435, -0.010038462467491627, -0.026321833953261375, -0.02677915245294571, 0.007494740653783083, 0.07280730456113815, 0.025669004768133163, 0.015032521449029446, -0.029170949012041092, -0.009516426362097263, -0.012679636478424072, -0.022345539182424545, -0.0042325397953391075, -0.024826815351843834, 0.017178261652588844, -0.024184666574001312, 0.007537028286606073, 0.021014288067817688, 0.010393032804131508, 0.050261709839105606, -0.018338317051529884, -0.010346125811338425, 0.0513540543615818, 0.029403582215309143, 0.001125842216424644, -0.03173251822590828, -0.01337336003780365, -0.00898946262896061, 0.052417006343603134, 0.016721753403544426, 0.01628829352557659, -0.1006108820438385, -0.0016430551186203957, 0.05375666916370392, 0.002330404706299305, 0.0031563236843794584, 0.00014962076966185123, 0.046850237995386124, -0.03357531502842903, -0.01620883122086525, -0.01782316341996193, 0.01972706988453865, -0.0077327098697423935, 0.009772175922989845, -0.00008110564522212371, -0.02301027625799179, 0.020514169707894325, -0.027892136946320534, 0.03092198260128498, 0.001355365151539445, -0.008789069019258022, -0.008205162361264229, 0.04547273367643356, -0.013020106591284275, -0.016011761501431465, -0.03215525299310684, 0.026354705914855003, -0.04131782427430153, -0.0015069134533405304, 0.040554940700531006, -0.016484159976243973, 0.05994792282581329, 0.027376094833016396, -0.03665987402200699, 0.018328942358493805, -0.006034339778125286, 0.03249173238873482, -0.015477301552891731, 0.013373489491641521, 0.05014491453766823, 0.037736304104328156, 0.004063668195158243, -0.0005321644130162895, -0.01941847987473011, 0.02592392824590206, -0.05347390100359917, -0.029920537024736404, -0.021366329863667488, 0.004582833498716354, 0.009145948104560375, -0.028610914945602417, -0.04774996638298035, -0.03174334764480591, -0.06246091425418854, 0.025073502212762833, -0.010810998268425465, -0.06983845680952072, 0.036210477352142334, -0.01576758734881878, 0.006978041026741266, 0.02549068257212639, 0.002721701981499791, 0.03370277211070061, -0.004764069337397814, -0.01944691874086857, -0.03096053935587406, 0.0359870120882988, 0.02826075814664364, 0.026464451104402542, -0.010278113186359406, 0.017694547772407532, 0.023892423138022423, 0.006462329067289829, 0.020794440060853958, 0.010580847971141338, -0.002322538523003459, 0.04393379017710686, 0.01706039346754551, 0.022777974605560303, 0.10069333016872406, 0.02162150852382183, -0.022760719060897827, -0.004667468834668398, -0.051619093865156174, -0.0023278365842998028, -0.006291084922850132, -0.013040883466601372, 0.005430712830275297, -0.015866829082369804, -0.0010804238263517618, -0.00008359150524483994, -0.015466329641640186, -0.04660612344741821, 0.038432810455560684, 0.04996178671717644, -0.026454482227563858, 0.012801618315279484, -0.02176806330680847, 0.013222390785813332, 0.004676321055740118, -0.0033763283863663673, 0.012724995613098145, -0.015703072771430016, -0.023367876186966896, 0.02997995913028717, 0.011823151260614395, 0.01979781873524189, -0.017429277300834656, -0.01286349818110466, 0.007680712733417749, -0.008701042272150517, -0.02897520735859871, 0.004906821064651012, -0.018900206312537193, -0.004938518162816763, 0.0245248693972826, 0.012278560549020767, 0.010323658585548401, -0.01123241800814867, -0.02824859321117401, -0.011530241928994656, -0.009533671662211418, 0.029527615755796432, 0.00869415607303381, 0.015523220412433147, 0.02522214874625206, 0.028285173699259758, 0.022945556789636612, 0.028986576944589615, -0.013268332928419113, 0.036361996084451675, 0.0056317453272640705, -0.0013660283293575048, 0.016004357486963272, -0.010440332815051079, 0.015835322439670563, 0.0016767812194302678, 0.01713167503476143, 0.05373850837349892, -0.021652651950716972, -0.040263187140226364, -0.05078468099236488, -0.022057658061385155, 0.03830141946673393, -0.05355267971754074, 0.04671592265367508, -0.013626017607748508, -0.045716870576143265, -0.022430019453167915, -0.008026077412068844, 0.028686432167887688, 0.02582819201052189, -0.009021131321787834, -0.07059915363788605, 0.018824994564056396, 0.05436013638973236, -0.03856399282813072, 0.010196083225309849, 0.057271622121334076, -0.009665978141129017, 0.049597229808568954, -0.0031824319157749414, -0.0033232001587748528, -0.03670148923993111, 0.029158461838960648, 0.013962074182927608, -0.003228017594665289, -0.0010614533675834537, -0.03827730566263199, 0.020642507821321487, 0.0303787998855114, 0.035367999225854874, -0.006753418128937483, -0.005188618786633015, -0.0121101513504982, 0.0018594036810100079, 0.041811369359493256, 0.0022063131909817457, 0.015976468101143837, 0.010382257401943207, 0.024549631401896477, 0.004638245794922113, -0.011957090348005295, -0.04729067161679268, -0.008228282444179058, 0.0019123482052236795, -0.0009198655607178807, 0.06083160638809204, 0.01834026351571083, -0.013422058895230293, 0.010060262866318226, -0.006509102415293455, -0.021427584812045097, 0.006555731408298016, 0.0014488964807242155, -0.0025167616549879313, -0.03564318269491196, -0.008317709900438786, 0.009394355118274689, -0.031206123530864716, 0.0190292876213789, -0.002075432799756527, 0.0117068225517869, -0.0659601241350174, -0.004263457376509905, 0.010159355588257313, -0.013993336819112301, 0.008333303965628147, -0.03643264248967171, -0.041507408022880554, -0.03229322284460068, -0.02109939604997635, 0.010360282845795155, 0.03813701122999191, 0.015758903697133064, -0.005112517159432173, -0.05327330529689789, 0.002528388751670718, 0.005685266572982073, 0.015746261924505234, 0.01381800789386034, 0.045753393322229385, -0.02528984472155571, -0.02101418934762478, 0.0022751546930521727, 0.005293741822242737, -0.028093425557017326, 0.010948394425213337, 0.02447337843477726, 0.021267427131533623, 0.026225881651043892, 0.034608758985996246, 0.0177021287381649, -0.0034369644708931446, 0.05769067630171776, -0.018239444121718407, -0.023084288462996483, -0.030284134671092033, 0.04095519706606865, 0.02636052668094635, -0.03031122125685215, 0.027079099789261818, -0.026297856122255325, -0.050326038151979446, -0.007182504050433636, -0.01918545737862587, 0.0073598274029791355, 0.04815828800201416, 0.017538953572511673, 0.03580286353826523, 0.03413847088813782, 0.007119194604456425, -0.009362639859318733, -0.03650813177227974, 0.026008442044258118, 0.01278113853186369, 0.031037867069244385, 0.026685502380132675, 0.032324209809303284, -0.013343381695449352, 0.045007165521383286, 0.025532107800245285, -0.033735573291778564, -0.004131705965846777, 0.00791493896394968, -0.020551638677716255, 0.01991601660847664, 0.01928853616118431, 0.006347050424665213, -0.012065109796822071, 0.028772834688425064, -0.023954397067427635, 0.03856809064745903, -0.00595748471096158, -0.02794514037668705, 0.003066812641918659, -0.023668522015213966, 0.016345832496881485, 0.06209126487374306, -0.020387278869748116, 0.04674836993217468, 0.035243310034275055, 0.03292291983962059, 0.013601845130324364, -0.01850326731801033, -0.01572626642882824, 0.0328521765768528, 0.05281224846839905, 0.004555859137326479, 0.03943011537194252, -0.012998245656490326, -0.029478847980499268, -0.027556614950299263, -0.03443838655948639, -0.025822581723332405, -0.014658112078905106, -0.011385787278413773, 0.039874814450740814, -0.004207778722047806, -0.0005932031781412661, -0.021086718887090683, 0.02001076377928257, 0.01621917076408863, 0.053926512598991394, 0.008569221943616867, 0.014913231134414673, 0.010315301828086376, 0.012135712429881096, 0.020824801176786423, 0.02534288726747036, -0.007818907499313354, 0.011869235895574093, 0.023230701684951782, 0.036568257957696915, 0.04544173926115036, 0.020513387396931648, -0.0016994139878079295, 0.014523773454129696, -0.017234288156032562, -0.024788808077573776, 0.020782001316547394, -0.008797606453299522, -0.0060589550994336605, -0.030498946085572243, 0.038680300116539, -0.0398668609559536, 0.00023018357751425356, 0.01897078938782215, 0.005476613994687796, -0.0006964245112612844, -0.004849603865295649, 0.00847114808857441, 0.007161087356507778, 0.00012104060442652553, -0.03377597779035568, 0.019467195495963097, -0.030360590666532516, 0.010858438909053802, 0.011999019421637058, -0.05018191039562225, -0.013423862867057323, -0.057959552854299545, -0.01348713506013155, -0.040309078991413116, -0.027294375002384186, 0.016163796186447144, -0.014574922621250153, -0.014493909664452076, 0.007664314471185207, -0.009640607051551342, -0.002440505661070347, -0.008319716900587082, 0.006616057362407446, -0.022043928503990173, 0.03040764480829239, -0.047028496861457825, -0.03873942419886589, -0.028171299025416374, -0.05724816769361496, -0.018927404657006264, -0.0049902754835784435, 0.007839635014533997, 0.010423542000353336, 0.055671531707048416, -0.00011838511272799224, -0.009024790488183498, 0.022211644798517227, -0.03939710557460785, -0.04208016395568848, -0.005548371002078056, 0.0490831658244133, 0.010900765657424927, 0.028577549383044243, -0.007274318486452103, -0.03382289409637451, -0.04619169607758522, -0.006117066368460655, 0.05816575884819031, -0.01002523209899664, -0.021662456914782524, -0.0366964116692543, 0.002928095869719982, -0.03581852838397026, -0.003122991416603327, 0.002512166043743491, -0.037060171365737915, 0.008563700132071972, -0.04531584680080414, 0.05789889395236969, -0.03568165749311447, 0.003604260040447116, -0.03901302441954613, -0.03465985879302025, -0.007778613828122616, 0.011104251258075237, -0.02028709091246128, 0.0316588394343853, -0.01769411191344261, 0.03236192464828491, -0.00313172466121614, -0.011347012594342232, -0.028456449508666992, 0.00593250198289752, 0.05503633990883827, -0.0017432342283427715, 0.012800130993127823, -0.009089145809412003, 0.01677294261753559, -0.04257946461439133, -0.01016279961913824, 0.008872573263943195, 0.011422824114561081, 0.037287697196006775, -0.04159973934292793, -0.004920304752886295, 0.006325552240014076, -0.06199115514755249, -0.044409047812223434, 0.023464728146791458, 0.023673661053180695, 0.010332559235394001, -0.0004275648680049926, 0.003154492937028408, 0.008373561315238476, -0.050814688205718994, 0.026335224509239197, 0.008631200529634953, -0.004910940770059824, -0.00685132946819067, 0.0046480209566652775, -0.018371326848864555, -0.040773648768663406, -0.0004961893428117037, -0.030554592609405518, 0.05289764702320099, 0.047346487641334534, 0.014542119577527046, -0.027006205171346664, -0.013794929720461369, 0.01726658083498478, -0.010918229818344116, -0.06991799920797348, -0.04009707644581795, 0.0007849246612749994, 0.02258840762078762, -0.05231765657663345, -0.029395580291748047, 0.06522952020168304, 0.0051698461174964905, -0.023716621100902557, 0.010347404517233372, 0.014411148615181446, -0.013158433139324188, -0.016397010535001755, 0.028315342962741852, 0.030809510499238968, 0.031981464475393295, 0.0027055495884269476, 0.03137921541929245, 0.039091806858778, 0.001696864259429276 ]
BERT 101 🤗 State Of The Art NLP Model Explained
britneymuller
March 2, 2022
bert-101
guide, nlp
https://huggingface.co/blog/bert-101
4.1 SQuAD v1.1 & v2.0 [SQuAD](https://huggingface.co/datasets/squad) (Stanford Question Answering Dataset) is a reading comprehension dataset of around 108k questions that can be answered via a corresponding paragraph of Wikipedia text. BERT’s performance on this evaluation method was a big achievement beating previous state-of-the-art models and human-level performance:
[ 0.012542019598186016, -0.028473125770688057, -0.00037790118949487805, 0.016975052654743195, -0.04879596456885338, 0.05606752261519432, 0.026245955377817154, 0.01236645132303238, -0.01474125124514103, -0.04272844269871712, -0.10639257729053497, 0.05261338874697685, -0.063890241086483, -0.024983936920762062, 0.015099295414984226, 0.03944883123040199, 0.03673030436038971, -0.007765725255012512, -0.020365314558148384, 0.0022458466701209545, 0.0048918165266513824, -0.049323294311761856, 0.040242720395326614, -0.04140021651983261, -0.0008765781531110406, -0.011638649739325047, 0.01379383448511362, -0.007126707583665848, 0.02843562513589859, 0.032228849828243256, -0.08571899682283401, -0.0216516125947237, 0.03634720295667648, -0.046177104115486145, -0.018405018374323845, 0.006505102850496769, -0.07397107779979706, 0.08699076622724533, -0.0016014751745387912, -0.046630002558231354, -0.0023503119591623545, -0.07287895679473877, -0.03274054825305939, 0.04614441841840744, -0.03213047236204147, 0.02514789067208767, -0.03735747188329697, 0.010800451040267944, -0.0572182759642601, -0.06732998788356781, -0.11670726537704468, 0.02262016013264656, -0.05035115405917168, 0.015254813246428967, 0.02850297838449478, -0.03394788131117821, 0.03684544563293457, -0.09847910702228546, 0.02215031534433365, -0.021251201629638672, 0.03629837557673454, -0.019302010536193848, 0.0904582142829895, 0.004845049697905779, -0.017676252871751785, 0.041822031140327454, 0.03230620548129082, 0.02430238574743271, -0.0627148300409317, 0.032094214111566544, -0.012429723516106606, -0.04843796789646149, -0.034695256501436234, -0.03498999774456024, -0.048750121146440506, -0.04302164167165756, -0.002176279667764902, -0.016056684777140617, -0.026197772473096848, -0.07322154194116592, -0.03687957674264908, 0.011069904081523418, 0.017075898125767708, 0.020151175558567047, -0.001161359017714858, 0.05704793334007263, 0.10408833622932434, -0.07949460297822952, -0.11735214293003082, 0.04097640514373779, 0.014873968437314034, -0.09636583179235458, -0.0076009961776435375, -0.06366823613643646, 0.054375000298023224, -0.06404414772987366, -0.025547636672854424, 0.053879864513874054, -0.02723315730690956, -0.04884713515639305, 0.023800060153007507, -0.030596615746617317, 0.03149018809199333, -0.0001420099870301783, -0.12097428739070892, 0.030916383489966393, -0.007636006455868483, -0.10064422339200974, 0.002898777835071087, 0.011791788972914219, 0.03998952358961105, -0.024582305923104286, -0.02797195129096508, 0.04534842446446419, -0.09476689994335175, 0.04845046624541283, 0.004070656839758158, 0.056765392422676086, 0.014310931786894798, 0.043712008744478226, -0.05620862543582916, 0.019353626295924187, 0.01699581928551197, 0.004224160220474005, 0.019799459725618362, 0.023124348372220993, -0.01681234873831272, 0.027850328013300896, 0.041970059275627136, 0.016046814620494843, 0.030572926625609398, -0.055104658007621765, 0.0661226436495781, 0.08620235323905945, 0.001935082720592618, -0.008773939684033394, -0.051049381494522095, -0.02602110058069229, 0.03086148202419281, 0.021139781922101974, 0.038081083446741104, 0.07235068827867508, 0.0012402402935549617, 0.01464396994560957, 0.08072802424430847, -0.003542449325323105, -0.059148140251636505, 0.04499627649784088, -0.009404359385371208, 0.0011513751232996583, -0.13793209195137024, 0.045971885323524475, -0.0309631135314703, -0.05520665645599365, -0.0009277955396100879, 0.029770050197839737, -0.03805755078792572, -0.07925143837928772, -0.056403160095214844, -0.0184940118342638, -0.045292485505342484, 0.008109315298497677, -0.047006282955408096, 0.02615380473434925, 0.009515082463622093, -0.03362609073519707, -0.026590945199131966, 0.08873216062784195, -0.025803830474615097, -0.04823413863778114, -0.027501925826072693, -0.009811557829380035, 0.044570401310920715, -0.014518040232360363, -0.003992488142102957, 0.06801369041204453, 0.05813106521964073, 0.027726516127586365, 0.011018806137144566, -0.004146510269492865, -0.027420254424214363, -0.0005515952361747622, 0.02490723878145218, 0.04664839059114456, 0.015573169104754925, -0.009191105142235756, 0.06490673124790192, 0.021712688729166985, 0.044792644679546356, 0.029430950060486794, 0.018756816163659096, -0.07548684626817703, 0.10106831043958664, -0.018967248499393463, 0.0808434933423996, -0.1050669252872467, -0.02894533984363079, 0.09611489623785019, 0.0805923193693161, -0.003672812832519412, 0.02057863585650921, 0.03350813686847687, 0.02838115021586418, -0.04068869724869728, 0.028873082250356674, -0.025864357128739357, 0.01842488907277584, -0.019918367266654968, 0.012851035222411156, -0.017814746126532555, 0.05011061951518059, -0.06753318756818771, 0.048383258283138275, -0.04169892519712448, 0.005424064118415117, -0.05751776322722435, -0.022731442004442215, 0.035615645349025726, 0.052460458129644394, -0.020668594166636467, 0.15356914699077606, -0.06927976757287979, 0.03196503967046738, -0.08239535987377167, -0.01805971935391426, 0.06390959769487381, 0.06749772280454636, 0.09538733214139938, 0.040815263986587524, -0.0775502547621727, -0.0022751924116164446, -0.006420972291380167, -0.014541895128786564, 0.01945323497056961, -0.013527309522032738, -0.06516651809215546, 0.04700411483645439, -0.01060669869184494, 0.009077569469809532, -0.010685843415558338, -0.017003288492560387, 0.02940457873046398, 0.06520058959722519, 0.049089059233665466, 0.06484587490558624, -0.0706566572189331, 0.04936765134334564, 0.01949038915336132, -0.05405531823635101, -0.06753310561180115, -0.04796500504016876, 0.026988821104168892, 0.002448126906529069, 0.012246701866388321, -0.016337573528289795, 0.03415299579501152, 0.01426173746585846, -0.01774723082780838, -0.0026095928624272346, 0.04494094103574753, -0.016293562948703766, -0.0184756051748991, -0.023008868098258972, 0.0019176483619958162, 0.00775484461337328, -0.07318970561027527, 0.011351163499057293, 0.009870173409581184, 0.004158150404691696, -0.007350466679781675, 0.04494515806436539, -0.0002153342793462798, 0.03824559226632118, 0.0017431655433028936, 0.03240188956260681, 0.08116435259580612, 0.04465649649500847, 0.002938683610409498, -0.020505135878920555, -0.03547203168272972, 0.022867899388074875, -0.03386663645505905, 0.04618670046329498, -0.014952054247260094, 0.032088398933410645, -0.019579317420721054, 0.03681124374270439, -0.03336526080965996, -0.013171380385756493, 0.02307332307100296, 0.026249807327985764, 0.006468471605330706, -0.01738480105996132, -0.05767068266868591, 0.029036803171038628, -0.009925324469804764, 0.008672119118273258, -0.011073204688727856, -0.010615508072078228, 0.03086054138839245, -0.03011607564985752, 0.048940591514110565, -0.06694520264863968, 0.007578801829367876, 0.026965253055095673, 0.02118927799165249, 0.009888112545013428, 0.01512524951249361, -0.07547479122877121, 0.015235590748488903, 0.01305357739329338, -0.03474295511841774, -0.04215022176504135, -0.013684685342013836, 0.060790207237005234, -0.033488575369119644, -0.01799558848142624, 0.016904128715395927, 0.01799871399998665, 0.0034366275649517775, 0.03337174281477928, 0.013621574267745018, -0.035523977130651474, 0.008239839226007462, -0.008197641000151634, -0.037639159709215164, 0.012454117648303509, -0.007914163172245026, 0.0003076812718063593, 0.01095957588404417, 0.011801276355981827, -0.0043431115336716175, -0.019924575462937355, 0.047316066920757294, 0.00005640776362270117, 0.003006748389452696, 0.037793681025505066, -0.005729402881115675, 0.02668883092701435, -0.027502352371811867, -0.006049811840057373, 0.020476482808589935, -0.03132830560207367, -0.008291388861835003, 0.0010164993582293391, 0.03334840014576912, -0.019221581518650055, 0.020084911957383156, 0.00844036228954792, -0.039820436388254166, 0.021020177751779556, -0.05118117108941078, 0.028802575543522835, 0.02343125268816948, -0.034255847334861755, -0.0045470683835446835, 0.01206680666655302, -0.043272409588098526, -0.02190249226987362, -0.0143441092222929, -0.019431021064519882, 0.06554265320301056, 0.027650507166981697, 0.006616210099309683, 0.08845385164022446, -0.020832324400544167, 0.01224550511687994, -0.013430836610496044, 0.03719085827469826, 0.01900869607925415, -0.021588001400232315, -0.0720018520951271, 0.00820449274033308, -0.0038722052704542875, 0.018063094466924667, -0.005539163015782833, -0.005299117416143417, 0.04794372618198395, 0.03203818202018738, 0.007664632052183151, 0.020184384658932686, -0.006279879715293646, -0.00730531569570303, 0.017830727621912956, -0.004119927529245615, -0.023591484874486923, 0.03385807201266289, 0.036170922219753265, -0.02427142672240734, -0.020848961547017097, -0.05731048434972763, -0.02119411528110504, 0.02473454922437668, -0.02239280939102173, 0.01482151448726654, -0.08330970257520676, 0.03902857005596161, 0.01150235254317522, 0.008659266866743565, -0.03904516249895096, 0.03986194357275963, 0.012255693785846233, -0.026538662612438202, 0.005144563037902117, 0.004701694473624229, 0.0404239222407341, -0.023491445928812027, 0.02970484271645546, 0.019372524693608284, -0.019436407834291458, -0.022450024262070656, 0.009251680225133896, -0.020045865327119827, 0.057923104614019394, -0.029803937301039696, -0.046215251088142395, -0.006571647245436907, -0.005666006356477737, 0.025062285363674164, -0.0033088549971580505, -0.0069114272482693195, 0.009432866238057613, 0.07582717388868332, 0.0055214050225913525, -0.02748938277363777, -0.00924455001950264, -0.016019416972994804, 0.01744583621621132, -0.01580287143588066, 0.030310628935694695, 0.02367585524916649, -0.02291283756494522, 0.02434057742357254, 0.025437841191887856, -0.006545718293637037, 0.002151359571143985, 0.025581074878573418, -0.04682552441954613, -0.02706608921289444, -0.02211061678826809, 0.0006068181828595698, -0.010671008378267288, 0.015310928225517273, -0.008187410421669483, -0.008974120020866394, 0.0029113597702234983, -0.03831212967634201, -0.048107780516147614, 0.020208045840263367, 0.018691135570406914, 0.0294695682823658, -0.005482756067067385, 0.01706082746386528, 0.021505100652575493, 0.016123443841934204, -0.041733596473932266, -0.0559791624546051, 0.020133858546614647, 0.009978456422686577, -0.005457352381199598, -0.05319111421704292, 0.010767340660095215, 0.08554995805025101, -0.002076569478958845, -0.028210844844579697, 0.05181313678622246, -0.019337648525834084, 0.060962967574596405, -0.0066703143529593945, 0.022454867139458656, -0.015035665594041348, -0.04177480936050415, 0.013281413353979588, 0.008655427955091, 0.02043628878891468, -0.01807728223502636, -0.004329309333115816, 0.03188781812787056, -0.03690535947680473, -0.007012256421148777, -0.030269568786025047, -0.009070035070180893, -0.02116924524307251, 0.06489246338605881, 0.0215448010712862, 0.014816434122622013, -0.018143992871046066, -0.0040526604279875755, 0.004924285691231489, 0.028330547735095024, 0.016021031886339188, 0.026211244985461235, 0.026792699471116066, 0.06774716079235077, 0.01962606981396675, 0.08553314208984375, -0.0034172653686255217, 0.01649300940334797, 0.010634521953761578, 0.006557681132107973, 0.026273757219314575, -0.07303234189748764, -0.008367388509213924, -0.03160496801137924, -0.006570982281118631, -0.021839402616024017, -0.024159999564290047, -0.01813412457704544, -0.006765122525393963, 0.03499313443899155, -0.031254492700099945, 0.010261557064950466, 0.01916021667420864, -0.01950244978070259, 0.011907465755939484, -0.02151655964553356, 0.01672113500535488, -0.012422909960150719, 0.0004052129515912384, -0.019060833379626274, -0.01565929502248764, -0.014753871597349644, -0.0008482537232339382, -0.018313158303499222, 0.015730658546090126, 0.0030573990661650896, 0.04468207433819771, 0.0052564251236617565, -0.04523034021258354, -0.016256915405392647, 0.0017049805028364062, -0.0023389982525259256, 0.0043407767079770565, -0.06412994116544724, 0.02325625717639923, 0.000777816865593195, -0.0005963837029412389, 0.016608037054538727, 0.010526689700782299, -0.004435691516846418, -0.02769630216062069, -0.0024523958563804626, -0.007256487384438515, 0.01750044897198677, -0.026401706039905548, 0.014042134396731853, 0.03676898032426834, -0.025821588933467865, 0.0053112199530005455, 0.00792611576616764, -0.013891607522964478, 0.001232487615197897, -0.03159349039196968, 0.0008377020130865276, 0.06655720621347427, 0.023461727425456047, 0.06559550762176514, -0.01676347479224205, 0.004785507917404175, 0.02955656871199608, -0.019795184955000877, 0.02973439358174801, -0.01848854124546051, 0.053272172808647156, 0.034212980419397354, 0.03129645437002182, 0.03209904953837395, 0.03321729972958565, -0.0006365025183185935, -0.0114362807944417, 0.00041661912109702826, 0.039747197180986404, -0.050460219383239746, 0.0030406033620238304, 0.01324534509330988, -0.03998076170682907, -0.01783149130642414, 0.07328243553638458, -0.002356816316023469, 0.04013093188405037, 0.04348501190543175, 0.002677331678569317, 0.004534222185611725, -0.004050991032272577, -0.02027239091694355, 0.029309174045920372, 0.01211021188646555, 0.01260136067867279, 0.0407320037484169, 0.053274333477020264, 0.019272418692708015, 0.005271426867693663, -0.03301047161221504, -0.0171671062707901, 0.042030591517686844, -0.010997476056218147, 0.03077363222837448, 0.06304489076137543, -0.027169860899448395, 0.003429873613640666, -0.01776505634188652, -0.02090536057949066, 0.009172854013741016, -0.02178715355694294, 0.0611732192337513, -0.03426225483417511, 0.018601834774017334, -0.013449852354824543, 0.029685107991099358, 0.04538477212190628, 0.06015605852007866, -0.029700329527258873, 0.009112372063100338, 0.02091902308166027, -0.026421261951327324, -0.0006240124930627644, 0.015016131103038788, 0.0036818482913076878, -0.021643945947289467, 0.026430688798427582, 0.06765972822904587, 0.004698258824646473, 0.03657054156064987, -0.01621324196457863, -0.029579665511846542, -0.012313662096858025, 0.0427493080496788, -0.0015958889853209257, -0.007367141079157591, 0.02847950905561447, -0.03269274905323982, 0.0009636569302529097, -0.028656795620918274, 0.007559808902442455, 0.00026638456620275974, -0.0015955899143591523, 0.002962718717753887, -0.044149093329906464, 0.011248983442783356, 0.035821858793497086, -0.02582879178225994, -0.0053435335867106915, 0.017840636894106865, -0.00001927277844515629, -0.008200347423553467, 0.055363286286592484, -0.03113984502851963, -0.008821651339530945, -0.031670425087213516, -0.0022201095707714558, -0.003427642397582531, 0.012386661022901535, -0.02905200980603695, -0.021177731454372406, -0.0386248379945755, 0.02817864902317524, 0.014201316051185131, 0.0049546947702765465, 0.00861491821706295, 0.02916349470615387, -0.023797739297151566, 0.02605631947517395, 0.00564695056527853, -0.03425988554954529, 0.041122350841760635, -0.04059157520532608, -0.018292782828211784, -0.01676156185567379, 0.03177586570382118, -0.0099208764731884, 0.05843958631157875, -0.02283765934407711, 0.0012037885608151555, -0.024455681443214417, -0.028046222403645515, -0.0546264611184597, 0.026747843250632286, 0.050476543605327606, 0.0033944633323699236, 0.00007349180668825284, -0.029890676960349083, -0.013725089840590954, -0.020218294113874435, 0.0400811992585659, 0.062486302107572556, -0.034747976809740067, -0.03132892772555351, -0.01667364314198494, 0.03359316289424896, 0.019754966720938683, -0.008338406682014465, 0.020888229832053185, 0.013594606891274452, 0.017584532499313354, -0.04868483543395996, 0.049339015036821365, -0.013333662413060665, -0.012306206859648228, -0.01323841791599989, -0.028898945078253746, -0.040476128458976746, 0.0057923803105950356, -0.01541722659021616, 0.03277711570262909, -0.03492077440023422, 0.015066942200064659, 0.023838981986045837, -0.023342233151197433, -0.0417400524020195, 0.010732833296060562, 0.03330503776669502, 0.0029198217671364546, 0.021237673237919807, 0.0003327365848235786, -0.03365706279873848, 0.0014989193296059966, -0.012937233783304691, -0.011562265455722809, 0.028260154649615288, 0.0140857407823205, -0.02064407616853714, -0.04307011142373085, -0.01397049892693758, 0.019845301285386086, -0.0642973855137825, -0.023938167840242386, 0.02695910632610321, 0.011060927994549274, -0.04199469834566116, 0.008005017414689064, 0.014636368490755558, -0.016743389889597893, 0.01664217934012413, 0.010453596711158752, 0.015089216642081738, -0.05223628133535385, -0.0015782872214913368, -0.07196932286024094, -0.008048650808632374, 0.01825469173491001, -0.011097247712314129, 0.05699450522661209, 0.014537684619426727, -0.004365089815109968, 0.039854180067777634, -0.013904960826039314, 0.025299986824393272, -0.009320395067334175, -0.042175646871328354, 0.019860396161675453, 0.02258247882127762, 0.02316729910671711, -0.03167304769158363, 0.013945839367806911, 0.00900231022387743, 0.0002511809580028057, -0.003869288833811879, -0.007690734695643187, -0.006730982568114996, 0.03579728305339813, -0.045761484652757645, -0.014452304691076279, -0.00005785356552223675, 0.04747189208865166, 0.031769171357154846, 0.025948654860258102, -0.0019675299990922213, 0.012050087563693523 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
More About Constraint Classes and Custom Constraints The main takeaway from the explanation can be summarized as the following. At every step, we keep pestering the model to consider the tokens that fulfill our constraints, all the while keeping track of beams that don't, until we end up with reasonably high probability sequences that contain our desired phrases. So a principled way to design this implementation was to represent each constraint as a Constraint object, whose purpose was to keep track of its progress and tell the beam search which tokens to generate next. Although we have provided the keyword argument force_words_ids for model.generate(), the following is what actually happens in the back-end: python from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, PhrasalConstraint tokenizer = AutoTokenizer.from_pretrained("t5-base") model = AutoModelForSeq2SeqLM.from_pretrained("t5-base") encoder_input_str = "translate English to German: How old are you?" constraints = [ PhrasalConstraint( tokenizer("Sie", add_special_tokens=False).input_ids ) ] input_ids = tokenizer(encoder_input_str, return_tensors="pt").input_ids outputs = model.generate( input_ids, constraints=constraints, num_beams=10, num_return_sequences=1, no_repeat_ngram_size=1, remove_invalid_values=True, ) print("Output:\n" + 100 * '-') print(tokenizer.decode(outputs[0], skip_special_tokens=True)) Output: ---------------------------------------------------------------------------------------------------- Wie alt sind Sie? You can define one yourself and input it into the constraints keyword argument to design your unique constraints. You just have to create a sub-class of the Constraint abstract interface class and follow its requirements. You can find more information in the definition of Constraint found here. Some unique ideas (not yet implemented; maybe you can give it a try!) include constraints like OrderedConstraints, TemplateConstraints that may be added further down the line. Currently, the generation is fulfilled by including the sequences, wherever in the output. For example, a previous example had one sequence with scared -> screaming and the other with screamed -> scared. OrderedConstraints could allow the user to specify the order in which these constraints are fulfilled. TemplateConstraints could allow for a more niche use of the feature, where the objective can be something like: python starting_text = "The woman" template = ["the", "", "School of", "", "in"] possible_outputs == [ "The woman attended the Ross School of Business in Michigan.", "The woman was the administrator for the Harvard School of Business in MA." ] or: python starting_text = "The woman" template = ["the", "", "", "University", "", "in"] possible_outputs == [ "The woman attended the Carnegie Mellon University in Pittsburgh.", ] impossible_outputs == [ "The woman attended the Harvard University in MA." ] or if the user does not care about the number of tokens that can go in between two words, then one can just use OrderedConstraint.
[ 0.02610899694263935, 0.008941358886659145, 0.019882867112755775, -0.005899948999285698, 0.011717991903424263, 0.12315402925014496, 0.07057251036167145, -0.02289930172264576, -0.020732006058096886, 0.01082794088870287, -0.04200934246182442, -0.011807415634393692, -0.022032201290130615, 0.06755421310663223, -0.012674284167587757, 0.018035540357232094, 0.03009839355945587, -0.0347624309360981, -0.027457887306809425, 0.0036666798405349255, 0.036146268248558044, 0.017319906502962112, 0.10995405167341232, 0.011794880963861942, 0.057841744273900986, -0.006311061792075634, -0.0047768778167665005, 0.03977656364440918, -0.05461768060922623, 0.0017064264975488186, -0.06650950014591217, 0.00014547765022143722, 0.007746554911136627, -0.037214282900094986, 0.012421579100191593, 0.0023465019185096025, -0.113526850938797, 0.007990839891135693, 0.08159397542476654, 0.0036601736210286617, -0.07701669633388519, 0.02555391751229763, -0.06474485248327255, -0.0038196188397705555, -0.005337978713214397, -0.01943906769156456, -0.1563750058412552, 0.07058253139257431, -0.012282759882509708, -0.031476546078920364, -0.10456687957048416, -0.006799306254833937, -0.043867986649274826, 0.05285783112049103, 0.04944835603237152, 0.01459453348070383, -0.019162829965353012, -0.0873846486210823, 0.048304397612810135, -0.03953738883137703, -0.010036122985184193, 0.056688182055950165, 0.05100429430603981, 0.00724028330296278, 0.030894355848431587, -0.031010476872324944, -0.02330612763762474, 0.07483508437871933, 0.0002803914248943329, -0.036838993430137634, -0.017501628026366234, -0.03456531837582588, -0.053701888769865036, 0.01761789619922638, -0.018462037667632103, -0.08397518843412399, -0.0544179268181324, 0.02426145412027836, -0.041087910532951355, 0.0574847050011158, 0.038581158965826035, 0.0718788430094719, 0.02756875939667225, 0.014656498096883297, 0.05402210354804993, 0.01336212269961834, 0.036487482488155365, -0.060704175382852554, -0.0014088299358263612, 0.03363921865820885, 0.010447913780808449, -0.132544606924057, 0.01799771748483181, -0.00627615861594677, 0.04784361645579338, -0.04615490883588791, 0.020651279017329216, 0.06816314160823822, 0.007091397885233164, 0.03725184127688408, -0.020977547392249107, -0.04758965224027634, 0.02909538336098194, -0.038906123489141464, -0.0188288614153862, 0.02747579663991928, 0.000019099083147011697, -0.03867481276392937, -0.046922434121370316, 0.029745863750576973, -0.023161331191658974, -0.024084890261292458, 0.03011685237288475, 0.08387063443660736, -0.07403505593538284, 0.005473299417644739, 0.03203039988875389, 0.0045625255443155766, -0.01261129043996334, 0.04467954486608505, -0.013155286200344563, 0.04913116246461868, 0.06647228449583054, 0.021793697029352188, 0.016511816531419754, 0.043057043105363846, -0.06448791176080704, -0.0010065174428746104, 0.004510466940701008, -0.09119924157857895, 0.02258482202887535, -0.02335263229906559, 0.059183645993471146, -0.0008852329920046031, 0.034297820180654526, -0.052152182906866074, 0.04415048286318779, -0.09568788856267929, -0.004783373326063156, 0.045158062130212784, 0.0017664782935753465, 0.023854495957493782, -0.029656127095222473, 0.017969883978366852, -0.0010259035043418407, -0.012551946565508842, -0.03107679821550846, 0.06804284453392029, -0.01614817976951599, 0.028224986046552658, -0.03754054009914398, 0.019159048795700073, 0.03126521408557892, -0.047001954168081284, -0.017433444038033485, 0.059899523854255676, -0.04630295932292938, -0.008664468303322792, -0.05708729103207588, 0.017415978014469147, -0.08514974266290665, 0.015038725920021534, -0.015234151855111122, -0.020357370376586914, 0.050925206393003464, -0.04429042339324951, 0.01946283131837845, -0.009118910878896713, 0.001327800564467907, 0.05852067843079567, 0.04530738294124603, -0.0063843089155852795, 0.05171984061598778, -0.034117769449949265, 0.01965424232184887, 0.06437044590711594, -0.02530963160097599, 0.03425956889986992, -0.01863206923007965, -0.03452496603131294, -0.024502355605363846, -0.013406305573880672, -0.009898043237626553, 0.09446902573108673, 0.043125879019498825, -0.04932726174592972, 0.015918314456939697, -0.038284022361040115, -0.03785788267850876, -0.018523775041103363, -0.04081061854958534, -0.030827000737190247, 0.11490242928266525, -0.08465934544801712, 0.017973126843571663, -0.11602278053760529, -0.06833776086568832, 0.09174610674381256, 0.048974063247442245, 0.03381744399666786, 0.07177668809890747, 0.02546224556863308, -0.021974779665470123, -0.034357164055109024, -0.01152002438902855, 0.0127967968583107, -0.039647333323955536, -0.09930115193128586, 0.009890967980027199, -0.0000660124933347106, 0.010381379164755344, -0.07224541902542114, 0.027870917692780495, -0.11454130709171295, -0.04691305756568909, -0.015716493129730225, -0.03702876716852188, -0.03113342449069023, -0.05281268432736397, -0.02830878458917141, 0.15706001222133636, -0.06437498331069946, -0.050263550132513046, -0.021749546751379967, -0.02594979666173458, 0.03451922535896301, 0.007217048667371273, 0.03990864008665085, 0.045647524297237396, -0.07470463961362839, 0.028284989297389984, -0.03965289890766144, 0.03564658388495445, 0.04387654364109039, -0.06669404357671738, 0.0004992159083485603, 0.02062063291668892, 0.03183557838201523, 0.036853622645139694, -0.007901281118392944, -0.03222700208425522, 0.03984075039625168, -0.057932425290346146, 0.05424266308546066, -0.0019978515338152647, 0.04630350321531296, 0.06934024393558502, -0.013248304836452007, -0.022366968914866447, -0.005389729049056768, -0.06163643300533295, 0.041238266974687576, -0.021026939153671265, -0.06195448338985443, 0.04954853281378746, 0.06435178220272064, 0.009338317438960075, -0.03361273184418678, -0.014637968502938747, 0.005561011377722025, -0.020580649375915527, 0.0001977084466489032, -0.04356512799859047, -0.08164502680301666, -0.02281343936920166, -0.06831634044647217, 0.01688695326447487, -0.006123553495854139, 0.0016986160771921277, 0.01221949141472578, -0.0051585035398602486, -0.018038472160696983, 0.01929633505642414, -0.02514314092695713, 0.02803216502070427, 0.02267453446984291, 0.03209586814045906, 0.0031642753165215254, -0.04560067504644394, -0.00251183845102787, -0.05366929620504379, -0.011498936451971531, 0.04114930331707001, 0.015665996819734573, 0.02002798765897751, 0.02321503311395645, 0.03332296386361122, 0.0072838556952774525, -0.0249214805662632, -0.010481790639460087, 0.007659789174795151, 0.04285173863172531, -0.015075292438268661, -0.042181700468063354, 0.020470356568694115, 0.04520067200064659, -0.018296338617801666, -0.03431457281112671, 0.034877512603998184, -0.008878952823579311, 0.007462026085704565, 0.05608348548412323, 0.0015145399374887347, 0.007649767212569714, -0.03480185940861702, 0.026520654559135437, 0.011185170151293278, 0.03151334822177887, -0.09067358076572418, -0.027538996189832687, -0.006691151764243841, 0.006990716326981783, 0.014561204239726067, -0.01406040322035551, 0.045485153794288635, 0.037226688116788864, -0.044771160930395126, 0.01529886107891798, 0.013689564540982246, -0.02696777507662773, 0.021510988473892212, 0.011539127677679062, -0.011841372586786747, 0.0014566597528755665, -0.021252552047371864, 0.007775000762194395, 0.013889881782233715, 0.006199412047863007, -0.0076673091389238834, 0.021359389647841454, -0.051314130425453186, 0.003939425107091665, -0.026324421167373657, -0.020178012549877167, 0.024012338370084763, 0.04438819736242294, -0.010890459641814232, -0.03705854341387749, -0.0336327962577343, -0.00010684357403079048, -0.012795427814126015, -0.02275676093995571, -0.0005888594896532595, 0.004081576131284237, 0.011140089482069016, 0.0018428375478833914, -0.009900754317641258, 0.03419431671500206, 0.004228013567626476, -0.019450776278972626, 0.0015465480973944068, -0.018798165023326874, 0.00008092831558315083, -0.029503624886274338, -0.03861124441027641, -0.027927370741963387, -0.0011401515221223235, -0.06408621370792389, -0.015182636678218842, -0.012019091285765171, 0.00729328952729702, 0.04581931233406067, 0.007575423456728458, -0.03933783620595932, 0.019957290962338448, 0.003386460477486253, 0.05748007073998451, 0.03751058503985405, -0.04401516169309616, 0.019437767565250397, 0.018963953480124474, 0.015403705649077892, -0.028269145637750626, 0.07704919576644897, 0.03166647255420685, 0.04087429866194725, -0.016741307452321053, 0.010277523659169674, -0.023134278133511543, 0.07713630050420761, -0.013413342647254467, 0.003789540845900774, -0.008255324326455593, 0.02321147918701172, 0.01337435469031334, -0.0557180792093277, 0.04358649626374245, 0.020270410925149918, -0.012365898117423058, 0.003789419773966074, -0.07888446748256683, -0.011768415570259094, 0.01655946671962738, -0.020560838282108307, 0.02241200953722, 0.001451807445846498, 0.0038965847343206406, -0.0010840467875823379, 0.0074672093614935875, -0.033709198236465454, -0.004898968618363142, -0.01723526045680046, -0.03374730795621872, 0.04258634150028229, -0.00731635233387351, 0.00043817132245749235, 0.04724251478910446, 0.010469590313732624, 0.031634751707315445, -0.031381864100694656, -0.02057645097374916, 0.017364412546157837, -0.024130195379257202, 0.0008200331940315664, -0.07132834196090698, 0.0003922995529137552, 0.017430661246180534, 0.0041714743711054325, 0.00940170418471098, 0.031823914498090744, 0.001371233374811709, -0.007687275297939777, 0.030260222032666206, 0.010532046668231487, -0.03572387620806694, -0.00803216453641653, -0.017056934535503387, 0.02875537984073162, -0.05731097608804703, -0.022372553125023842, -0.0052014561370015144, -0.031411100178956985, 0.014122849330306053, -0.0005815149052068591, 0.04303321614861488, 0.014773612841963768, 0.002841903828084469, -0.018413737416267395, -0.00866753701120615, -0.007735803257673979, -0.010592732578516006, 0.03390383720397949, -0.020336920395493507, 0.0340573713183403, 0.005018141120672226, -0.008297291584312916, 0.010885761119425297, -0.019866717979311943, -0.027703549712896347, -0.001485054031945765, 0.05213338881731033, -0.010337143205106258, 0.060139432549476624, -0.04412728548049927, -0.018006620928645134, -0.00009611934365238994, 0.020817751064896584, 0.03910550847649574, 0.035164184868335724, 0.0018663927912712097, -0.03374578431248665, -0.01822911761701107, 0.062063656747341156, -0.009978960268199444, -0.013069124892354012, -0.0016164770349860191, 0.01003233715891838, 0.044605862349271774, 0.007542548701167107, -0.019875384867191315, -0.032358214259147644, 0.037731241434812546, 0.011783910915255547, -0.003302713856101036, -0.03411881625652313, -0.0819782093167305, 0.020151635631918907, -0.01151868887245655, -0.010776210576295853, 0.023808524012565613, 0.03479892760515213, -0.011098208837211132, 0.0019197531510144472, 0.04394824802875519, -0.020547835156321526, 0.022493375465273857, -0.06486496329307556, 0.016047844663262367, -0.008875529281795025, -0.013429521583020687, 0.04059889540076256, 0.06268493831157684, -0.008303552865982056, 0.023633206263184547, 0.10064666718244553, 0.02806655317544937, 0.022893963381648064, 0.011333001777529716, -0.014168732799589634, -0.016687637194991112, -0.0033144766930490732, -0.05388888716697693, 0.019135067239403725, -0.02305501140654087, -0.037913694977760315, 0.06930553913116455, -0.0467052236199379, -0.026732927188277245, 0.04670673608779907, 0.01217796839773655, -0.02183944545686245, -0.022229881957173347, 0.015577023848891258, -0.0020158172119408846, -0.015708541497588158, -0.042102646082639694, -0.00394680630415678, -0.038821253925561905, -0.00730937160551548, -0.02551226317882538, -0.023165486752986908, 0.028020242229104042, 0.005218556150794029, 0.014744308777153492, -0.011010169982910156, 0.043738652020692825, 0.061549991369247437, 0.03077150695025921, 0.040816303342580795, -0.009221412241458893, -0.03692327067255974, 0.047175083309412, 0.024089869111776352, -0.027940824627876282, -0.001469088951125741, 0.03519902378320694, 0.02696835808455944, 0.039395421743392944, 0.0311917494982481, -0.03569537028670311, 0.0036376456264406443, -0.0038497070781886578, -0.005000978242605925, -0.0443146713078022, 0.00894993543624878, 0.02464691549539566, 0.06625198572874069, -0.011036362498998642, 0.03179314360022545, 0.013905356638133526, -0.04228503629565239, 0.02291260100901127, -0.010414868593215942, 0.02300013042986393, 0.021054401993751526, -0.01802508346736431, -0.03170865401625633, -0.0016010778490453959, 0.009593538008630276, -0.012014638632535934, -0.010514824651181698, 0.04271285980939865, -0.01247824914753437, 0.06860020011663437, 0.022335579618811607, 0.045947376638650894, 0.00985120702534914, -0.003686504438519478, -0.007638567592948675, -0.042423270642757416, 0.024300741031765938, 0.014821267686784267, -0.03658614680171013, 0.0439210869371891, 0.010938737541437149, -0.0657755509018898, -0.0031007244251668453, -0.03559241071343422, 0.008002198301255703, 0.008097145706415176, -0.004840673413127661, 0.03143608570098877, -0.003824587445706129, 0.009520439431071281, -0.01888766698539257, 0.07864289730787277, 0.003208012320101261, 0.036050669848918915, 0.01703418605029583, 0.028779013082385063, -0.011137944646179676, 0.011419866234064102, -0.014891274273395538, 0.0031884629279375076, 0.044188160449266434, 0.004444553051143885, 0.008390773087739944, -0.0013007050147280097, -0.031583115458488464, 0.01463056169450283, -0.019092734903097153, -0.0004904453526251018, -0.014636905863881111, 0.005526836961507797, 0.01270322222262621, -0.035581160336732864, 0.007889297790825367, 0.023115117102861404, 0.04341340437531471, 0.002791907172650099, 0.029940251260995865, 0.00007707313488936052, -0.012123915366828442, 0.01882018707692623, 0.006592659745365381, 0.04660389944911003, 0.0694776102900505, -0.013007625937461853, -0.007219740655273199, 0.07468581944704056, 0.02972039394080639, 0.040866244584321976, 0.042139917612075806, 0.004902985412627459, 0.03804241865873337, -0.012751160189509392, -0.035852573812007904, 0.03864654526114464, 0.029158812016248703, -0.002226935001090169, -0.022270886227488518, 0.011273177340626717, -0.06153101846575737, 0.02179655060172081, 0.002610213356092572, 0.00562780536711216, -0.02455039694905281, 0.013914893381297588, 0.00008794842142378911, 0.0378522165119648, 0.026427479460835457, -0.04735973849892616, -0.008853311650454998, 0.01940707117319107, -0.0070264036767184734, 0.03441833332180977, 0.0005160656874068081, -0.021737949922680855, -0.07225292176008224, -0.03970102220773697, 0.00027606432558968663, -0.0269969142973423, -0.013700990937650204, -0.013929898850619793, 0.0004430408589541912, 0.04401040077209473, 0.01884394884109497, 0.03982698544859886, 0.02791523188352585, 0.013032454065978527, -0.02723352611064911, -0.06166290491819382, -0.04086274281144142, -0.0027812537737190723, 0.02373531274497509, -0.06547476351261139, 0.00821104645729065, 0.008671640418469906, 0.03415040671825409, -0.011372582986950874, 0.016110144555568695, -0.017570115625858307, -0.04272410273551941, -0.025083748623728752, -0.028311999514698982, 0.011277345009148121, 0.04008829593658447, 0.02885659597814083, 0.004309515468776226, 0.0076214964501559734, -0.04246293008327484, -0.04667705297470093, -0.011532281525433064, -0.018773222342133522, 0.04329084977507591, -0.01876787468791008, -0.026274321600794792, -0.0003751685144379735, 0.04818832501769066, -0.0021439220290631056, 0.01579461060464382, 0.047758281230926514, 0.027500709518790245, 0.015851527452468872, 0.014805978164076805, 0.027018077671527863, -0.05574866011738777, 0.043086882680654526, -0.05075524002313614, -0.03423682600259781, -0.01783638447523117, 0.022363971918821335, -0.029763968661427498, 0.01507315132766962, -0.040044039487838745, 0.036874059587717056, -0.018184999004006386, -0.005450563970953226, 0.003910901956260204, 0.016322970390319824, 0.06011313572525978, 0.0232701376080513, 0.03523051366209984, -0.008694706484675407, -0.02091929502785206, -0.00838345568627119, -0.020952684804797173, 0.003928807098418474, 0.04607000946998596, 0.007155685685575008, 0.0057337479665875435, -0.025849752128124237, 0.002785192569717765, -0.011048020794987679, -0.017039012163877487, 0.0018735909834504128, 0.0042675514705479145, -0.006447144318372011, -0.009014838375151157, 0.01822728104889393, -0.005885951686650515, 0.010743657127022743, 0.015728186815977097, 0.007003564853221178, 0.020919833332300186, 0.030561547726392746, -0.02734181471168995, -0.04248297959566116, -0.02381405420601368, 0.0003042995813302696, -0.018382927402853966, 0.030592480674386024, 0.012606250122189522, -0.005011002067476511, 0.011087615042924881, -0.02178029716014862, 0.017196975648403168, 0.011212103068828583, 0.023470986634492874, -0.017842648550868034, -0.03009920008480549, 0.012553006410598755, 0.005732051096856594, -0.03378482908010483, 0.010936244390904903, 0.01486721821129322, -0.0017492308979853988, 0.010791052132844925, 0.008561239577829838, -0.004846792668104172, -0.0034056410659104586, -0.002399867633357644, 0.0224751103669405, 0.026103371754288673, 0.0491846427321434, 0.0026075539644807577, -0.04102614149451256, 0.0019053847063332796 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
Conclusion Constrained beam search gives us a flexible means to inject external knowledge and requirements into text generation. Previously, there was no easy way to tell the model to 1. include a list of sequences where 2. some of which are optional and some are not, such that 3. they're generated somewhere in the sequence at respective reasonable positions. Now, we can have full control over our generation with a mix of different subclasses of Constraint objects! This new feature is based mainly on the following papers: - Guided Open Vocabulary Image Captioning with Constrained Beam Search - Fast Lexically Constrained Decoding with Dynamic Beam Allocation for Neural Machine Translation - Improved Lexically Constrained Decoding for Translation and Monolingual Rewriting - Guided Generation of Cause and Effect Like the ones above, many new research papers are exploring ways of using external knowledge (e.g., KGs, KBs) to guide the outputs of large deep learning models. Hopefully, this constrained beam search feature becomes another effective way to achieve this purpose. Thanks to everybody that gave guidance for this feature contribution: Patrick von Platen for being involved from the initial issue to the final PR, and Narsil Patry, for providing detailed feedback on the code. Thumbnail of this post uses an icon with the attribution: Shorthand icons created by Freepik - Flaticon
[ 0.028994785621762276, -0.022401491180062294, 0.053426746279001236, -0.015527227893471718, -0.012258438393473625, 0.0730435773730278, 0.0030894880183041096, -0.04659247025847435, -0.03757066652178764, 0.026552021503448486, -0.06701786071062088, -0.05406773462891579, 0.0073511977680027485, -0.00020472865435294807, -0.0009686520788818598, -0.030495787039399147, 0.026419619098305702, 0.0027852163184434175, -0.07648928463459015, 0.04230178892612457, 0.06618214398622513, 0.006334636826068163, 0.07933671772480011, -0.06492748856544495, 0.020481934770941734, -0.049491215497255325, -0.013363663107156754, -0.020264964550733566, -0.03124566376209259, -0.001083205221220851, -0.02413327991962433, 0.009990494698286057, 0.008772115223109722, -0.026069363579154015, -0.0778665766119957, 0.02111668512225151, -0.10312145948410034, 0.03201994299888611, 0.050594836473464966, 0.009997532702982426, -0.06944621354341507, 0.021088095381855965, -0.02013969235122204, -0.004153861198574305, 0.02705451473593712, 0.034786030650138855, -0.10448171198368073, 0.07509299367666245, -0.06656566262245178, -0.006877944804728031, -0.1057930514216423, 0.010903934948146343, -0.0322815366089344, -0.03321397677063942, 0.012474593706429005, 0.054258134216070175, -0.04248892143368721, -0.15005901455879211, 0.05587694048881531, -0.02938191220164299, -0.07020898163318634, 0.0034751039929687977, 0.019907070323824883, 0.04421551153063774, 0.052761007100343704, -0.054346613585948944, -0.043728671967983246, -0.0015437522670254111, -0.048441365361213684, 0.014440101571381092, -0.0044398196041584015, 0.027231156826019287, -0.042781028896570206, -0.05399448424577713, -0.004161468241363764, -0.08423703908920288, -0.035309337079524994, 0.019494283944368362, -0.013444229029119015, -0.013171127997338772, 0.03383497893810272, 0.0804312601685524, 0.017266666516661644, 0.0254417322576046, 0.050092749297618866, 0.04373805597424507, 0.0509515255689621, -0.05365515127778053, -0.021744050085544586, 0.04941066727042198, -0.029016371816396713, -0.10930711030960083, -0.020633025094866753, 0.02620725892484188, 0.026054615154862404, -0.05530412122607231, 0.053162891417741776, -0.0066467998549342155, -0.0019422004697844386, 0.01858288049697876, -0.0165408905595541, -0.0574653185904026, 0.07263271510601044, -0.021933019161224365, -0.06703410297632217, 0.0001456377940485254, -0.0393955260515213, -0.02578810602426529, -0.06989732384681702, 0.06000163406133652, -0.0007878569304011762, 0.0002413777692709118, -0.01686660759150982, 0.05455229803919792, -0.08271307498216629, -0.0325298011302948, 0.03439055010676384, -0.004592555575072765, -0.08327339589595795, 0.04426364228129387, -0.052030500024557114, 0.05944318324327469, 0.042779698967933655, 0.04305635765194893, 0.08032742142677307, 0.04062817618250847, -0.006438801530748606, -0.02431594952940941, -0.0015686008846387267, -0.045668814331293106, 0.008102141320705414, 0.015588358044624329, 0.03719991445541382, 0.010196151211857796, 0.06383634358644485, -0.027731435373425484, 0.012185299769043922, -0.055639684200286865, -0.050148703157901764, -0.0016006159130483866, 0.04846041277050972, -0.022821497172117233, -0.013009676709771156, 0.0096585126593709, 0.05856985226273537, -0.039691437035799026, -0.0015221753856167197, 0.02568904496729374, -0.08541648834943771, 0.058597054332494736, 0.008844745345413685, 0.02806563675403595, 0.029010437428951263, -0.08917006850242615, -0.07192680239677429, 0.03591541573405266, 0.010203717276453972, 0.010818288661539555, -0.00913248397409916, -0.009341091848909855, -0.06319621950387955, -0.000116337338113226, 0.007498724386096001, -0.00770571967586875, 0.0007945370743982494, -0.07639114558696747, 0.019212042912840843, 0.0367390401661396, 0.0035616345703601837, 0.048999473452568054, 0.020944079384207726, 0.016918569803237915, 0.039195239543914795, -0.03915315121412277, 0.05371840298175812, -0.01659255661070347, -0.00704107666388154, 0.030654238536953926, -0.01625664532184601, -0.05467108637094498, -0.05044187977910042, -0.06651989370584488, 0.013270528987050056, 0.02848093956708908, 0.03364906087517738, -0.112101249396801, 0.050142884254455566, -0.020139848813414574, -0.01400842797011137, -0.06925245374441147, -0.05608204007148743, -0.03777014836668968, 0.020549263805150986, -0.03384106233716011, -0.02041010372340679, -0.0884447768330574, -0.060775771737098694, 0.13722985982894897, 0.03537134453654289, 0.08136418461799622, 0.11719875782728195, 0.03301381319761276, 0.004975782707333565, -0.03545669838786125, -0.015550070442259312, -0.0016682286513969302, -0.018364831805229187, -0.06451736390590668, 0.012267017737030983, 0.05331628397107124, 0.0299652311950922, -0.08373183012008667, 0.03136136755347252, -0.06592753529548645, -0.007057603448629379, -0.021080687642097473, -0.042615942656993866, -0.031769804656505585, -0.059589918702840805, 0.015266766771674156, 0.14272481203079224, 0.026757361367344856, -0.0327356718480587, -0.032526686787605286, -0.022573372349143028, 0.049740832298994064, 0.022176750004291534, 0.0008289791294373572, 0.021976254880428314, -0.10816072672605515, 0.04231753200292587, 0.023707590997219086, 0.042462024837732315, 0.03588902950286865, -0.06505439430475235, -0.007651981431990862, -0.03398802503943443, 0.03960702568292618, 0.02562033012509346, 0.0030333432368934155, -0.02390133962035179, 0.024143511429429054, -0.028973139822483063, 0.02658311277627945, 0.023105865344405174, -0.07508856058120728, 0.076229527592659, 0.0018158721504732966, -0.016336940228939056, -0.02467470057308674, -0.03491740673780441, 0.0766066312789917, -0.03473983705043793, -0.09692684561014175, -0.015748584643006325, 0.019200561568140984, -0.012876474298536777, -0.04651399329304695, -0.029213009402155876, 0.027625687420368195, 0.04005375877022743, 0.014501439407467842, -0.007631258573383093, -0.047520361840724945, -0.003711121389642358, -0.011374504305422306, 0.00415360601618886, 0.01420221384614706, -0.0075089107267558575, -0.0163088571280241, -0.004213162697851658, -0.02317681722342968, 0.012479577213525772, 0.005907257553189993, 0.0030985651537775993, -0.005064866971224546, 0.046809758991003036, -0.011977205984294415, -0.07275386899709702, -0.01026779506355524, -0.052756957709789276, 0.013199515640735626, 0.07299312949180603, 0.014065607450902462, 0.027090944349765778, 0.019096098840236664, 0.03340822830796242, -0.01742652617394924, -0.02147345058619976, -0.0204914640635252, -0.021974483504891396, 0.024586495012044907, -0.004974436946213245, -0.00020645899348892272, 0.005757341161370277, 0.017029955983161926, -0.026891151443123817, -0.043197955936193466, -0.006257887929677963, -0.007844889536499977, -0.03243328630924225, 0.0001795444986782968, -0.022431327030062675, -0.0014055160572752357, -0.02586507424712181, 0.06807365268468857, 0.017608603462576866, 0.04136134311556816, -0.07481174916028976, -0.02400278113782406, -0.06332358717918396, 0.030356839299201965, 0.029525943100452423, 0.022341473028063774, 0.012828601524233818, 0.05912881717085838, -0.005659323185682297, 0.018810249865055084, -0.003489983733743429, -0.003876270027831197, 0.016656668856739998, 0.00821414403617382, -0.023579804226756096, 0.020692138001322746, -0.023364616557955742, 0.0037008218932896852, 0.012468120083212852, 0.006594934966415167, -0.009704085066914558, 0.015871474519371986, 0.008813034743070602, 0.027652682736516, -0.023970000445842743, -0.008720187470316887, -0.0011287403758615255, 0.046781204640865326, 0.023792186751961708, -0.008972648531198502, -0.0029533719643950462, -0.023204760625958443, -0.050433315336704254, -0.04206565022468567, -0.05720837786793709, 0.043528586626052856, 0.017858918756246567, 0.03913307562470436, 0.014688110910356045, 0.036878421902656555, 0.01810053549706936, -0.02045818231999874, -0.013104092329740524, 0.00027867971220985055, -0.00638904795050621, -0.004276792053133249, -0.047765836119651794, 0.020940877497196198, 0.03569719195365906, -0.06010017916560173, -0.05050867423415184, 0.009888749569654465, 0.011369746178388596, 0.04681335389614105, 0.037858493626117706, -0.01601891592144966, 0.022891538217663765, -0.019368257373571396, 0.02234427072107792, 0.014639897271990776, -0.05130677670240402, -0.010999783873558044, 0.021889690309762955, 0.014095189049839973, 0.015106678940355778, 0.06495814770460129, 0.02079480141401291, 0.02190897986292839, -0.004464671481400728, 0.030310960486531258, -0.042161840945482254, 0.006563738454133272, 0.012042220681905746, -0.0011083146091550589, -0.021916771307587624, 0.02442343719303608, 0.004316218197345734, -0.05646631494164467, 0.049292370676994324, 0.031596217304468155, 0.015341372229158878, -0.004603620618581772, -0.051547907292842865, 0.0042439657263457775, 0.0626799538731575, -0.04577117785811424, 0.016076616942882538, -0.05039916932582855, 0.0019569641444832087, -0.009629691950976849, -0.013327034190297127, -0.018440797924995422, 0.0019056493183597922, -0.0013886889209970832, 0.00731276161968708, 0.043259959667921066, -0.009406408295035362, 0.03787653148174286, 0.045960232615470886, 0.0035468642599880695, -0.007269988302141428, -0.03984330967068672, -0.009844846092164516, 0.027310751378536224, -0.029781688004732132, 0.017762498930096626, -0.05106966197490692, 0.017597783356904984, -0.02014175057411194, -0.004591090604662895, -0.012505893595516682, -0.036123741418123245, -0.018195325508713722, -0.00023228507780004293, 0.0028760333079844713, -0.002175841247662902, -0.01765972562134266, -0.005490630865097046, -0.010118700563907623, -0.011541186831891537, -0.012361936271190643, 0.003704969771206379, -0.0034720778930932283, -0.012307524681091309, 0.002417811192572117, -0.02888651192188263, -0.010766520164906979, 0.0010554665932431817, 0.009866646490991116, 0.015338245779275894, 0.04805497080087662, 0.014195865020155907, 0.03708650916814804, 0.028850335627794266, 0.03531865030527115, 0.010441424325108528, -0.0041875350289046764, -0.01997368223965168, -0.018372466787695885, -0.024552959948778152, 0.011964593082666397, -0.01935117319226265, 0.022763749584555626, 0.010345433838665485, 0.07688360661268234, -0.004561034496873617, -0.03016209602355957, 0.045340947806835175, -0.008173705078661442, 0.0439794659614563, 0.024372756481170654, 0.04635707288980484, -0.043924443423748016, 0.007336090784519911, 0.03823016956448555, -0.05055346339941025, 0.0015673083253204823, 0.05480995774269104, 0.01708296500146389, 0.019187653437256813, 0.006409708876162767, -0.010413757525384426, -0.0468285046517849, 0.026550546288490295, 0.014689422212541103, 0.01709452085196972, 0.03388303890824318, 0.0008833557367324829, 0.001307591563090682, -0.009226075373589993, 0.024317080155014992, 0.02661694400012493, 0.011861372739076614, -0.028533101081848145, 0.030767619609832764, 0.026371484622359276, 0.03710438311100006, 0.006701123900711536, -0.03327040374279022, 0.011356956325471401, -0.01862005889415741, -0.010727769695222378, 0.04595012590289116, 0.051261719316244125, 0.023983655497431755, 0.03125016763806343, 0.050091467797756195, 0.024768665432929993, 0.04345537722110748, -0.026484517380595207, 0.015217838808894157, 0.027017859742045403, 0.04095443710684776, -0.01643531210720539, 0.01566399447619915, 0.004897421225905418, -0.025348873808979988, 0.014449444599449635, -0.0031728933099657297, 0.027766043320298195, 0.00571038480848074, 0.019936615601181984, -0.015863478183746338, -0.0392182357609272, 0.008784212172031403, -0.023407697677612305, -0.03341437131166458, -0.035220418125391006, 0.015667371451854706, -0.021607521921396255, -0.0030127763748168945, 0.023448698222637177, -0.05529073253273964, 0.00575624406337738, 0.030978547409176826, -0.027838876470923424, -0.023823359981179237, -0.016370706260204315, 0.05613937973976135, 0.037360306829214096, 0.02413918823003769, -0.06444667279720306, -0.03361910209059715, 0.0437481626868248, 0.006296602543443441, 0.0021612890996038914, 0.013707670383155346, 0.05352036654949188, 0.04537031054496765, 0.05987614393234253, 0.0003882891032844782, -0.045826081186532974, 0.018017277121543884, 0.028643347322940826, -0.02166370302438736, -0.018296504393219948, 0.005261288024485111, 0.04433344677090645, 0.004347012843936682, 0.0009857193799689412, 0.10461116582155228, 0.005715970881283283, -0.04227614775300026, 0.03699777275323868, -0.0032069385051727295, 0.02071906439960003, 0.01371753215789795, -0.020071323961019516, -0.03047807887196541, 0.015744779258966446, 0.06163614243268967, -0.031216956675052643, 0.0056654042564332485, 0.026791244745254517, -0.018880570307374, 0.044780343770980835, 0.015051339752972126, 0.005443665198981762, -0.024541929364204407, 0.021030515432357788, 0.01315994281321764, -0.03684602305293083, -0.003307785140350461, -0.004721547476947308, -0.046429961919784546, 0.03407641500234604, -0.020082203671336174, -0.023906461894512177, -0.018618520349264145, 0.008327937684953213, -0.008422655053436756, 0.01707030087709427, -0.03408818691968918, 0.025883009657263756, 0.003618749091401696, -0.01099164504557848, -0.0020891036838293076, 0.04955797269940376, 0.019730208441615105, 0.02618398517370224, -0.021402910351753235, 0.07303270697593689, -0.038681648671627045, -0.030673867091536522, -0.004763709846884012, 0.019599316641688347, 0.06562173366546631, -0.01226614136248827, 0.027187742292881012, 0.02256578952074051, -0.037628691643476486, -0.01536477543413639, 0.005135716870427132, -0.0019858526065945625, -0.010097888298332691, 0.008354870602488518, -0.008322847075760365, 0.023592831566929817, -0.006288900505751371, -0.027446428313851357, 0.04063056409358978, -0.0018824596190825105, -0.003278043819591403, 0.03181803971529007, 0.03297065198421478, 0.04063371941447258, -0.0021933172829449177, 0.02947545237839222, 0.06496375054121017, -0.01918063871562481, -0.03853441774845123, 0.048840902745723724, 0.0334298275411129, 0.024727066978812218, 0.016211451962590218, -0.007962731644511223, 0.015641750767827034, -0.011334220878779888, -0.01968921720981598, 0.05256197229027748, 0.017663288861513138, -0.030637439340353012, -0.01765216700732708, -0.011375770904123783, -0.05298084765672684, 0.023674646392464638, 0.020232949405908585, 0.005018983501940966, -0.047978613525629044, 0.022543448954820633, -0.030895544216036797, 0.024321328848600388, -0.002547648036852479, -0.0044178650714457035, -0.0033297308254987, -0.0070053525269031525, 0.004470743238925934, 0.058716606348752975, 0.0122855668887496, -0.009190876968204975, -0.01713348925113678, 0.010641026310622692, 0.030319007113575935, -0.012846318073570728, -0.009600270539522171, 0.014716770499944687, -0.007510635536164045, 0.0405440554022789, -0.008986297063529491, 0.054428886622190475, 0.02264995127916336, 0.023870952427387238, -0.04059972986578941, -0.01871802844107151, -0.02058536745607853, -0.010077961720526218, 0.00528302788734436, -0.042283620685338974, -0.008008060045540333, -0.046475306153297424, 0.006106773857027292, 0.019218621775507927, -0.008233707398176193, -0.038493312895298004, -0.026403682306408882, -0.031832627952098846, -0.004643681459128857, -0.005502032581716776, 0.03351761773228645, 0.0267347302287817, 0.004901891108602285, 0.004070112947374582, -0.06835273653268814, -0.0011490985052660108, -0.003888617968186736, -0.004512808285653591, 0.05430307984352112, 0.01051911897957325, -0.08027809113264084, -0.006511458661407232, 0.05278876796364784, 0.015747439116239548, 0.018221436068415642, 0.038145631551742554, 0.024563519284129143, 0.067412830889225, 0.03178529068827629, 0.029806822538375854, -0.01627770997583866, 0.04519626125693321, -0.06832563132047653, -0.04774156212806702, -0.02243676409125328, 0.03106548823416233, -0.0025966577231884003, 0.02409129962325096, 0.010590915568172932, 0.04853888601064682, 0.0020873351022601128, -0.010707536712288857, -0.037141572684049606, 0.003530575893819332, 0.03169921413064003, -0.002282282104715705, 0.054957110434770584, -0.02074459195137024, 0.032005175948143005, 0.026716340333223343, -0.015809061005711555, 0.03636549413204193, 0.05334094539284706, -0.02283744141459465, 0.0022141297813504934, -0.05295320600271225, 0.017185427248477936, -0.01914791390299797, -0.04444558545947075, 0.03384697064757347, 0.02587379701435566, -0.002403606427833438, -0.01037706807255745, 0.02505064569413662, 0.04142869636416435, 0.021606961265206337, -0.012850151397287846, 0.018213341012597084, -0.007162648253142834, 0.03465333580970764, 0.007000477518886328, -0.02091008611023426, -0.04787597805261612, -0.003817448392510414, 0.014426722191274166, 0.02659238502383232, -0.04040119796991348, 0.02631523460149765, -0.014892568811774254, 0.01923503540456295, -0.010812267661094666, -0.025135548785328865, -0.010000579990446568, 0.012656721286475658, 0.019272644072771072, -0.024776875972747803, -0.015290845185518265, 0.01978313736617565, -0.006838735658675432, -0.011167998425662518, -0.02039548195898533, 0.03387398272752762, 0.0011090626940131187, 0.01646820642054081, 0.002817051485180855, 0.01843073032796383, -0.008586741052567959, 0.05280039831995964, 0.0341695100069046, 0.03409959003329277, -0.02525375410914421, 0.00005653400148730725 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
Constrained Beam Search Constrained beam search attempts to fulfill the constraints by injecting the desired tokens at every step of the generation. Let's say that we're trying to force the phrase "is fast" in the generated output. In the traditional beam search setting, we find the top k most probable next tokens at each branch and append them for consideration. In the constrained setting, we do the same but also append the tokens that will take us closer to fulfilling our constraints. Here's a demonstration: On top of the usual high-probability next tokens like "dog" and "nice", we force the token "is" in order to get us closer to fulfilling our constraint of "is fast". For the next step, the branched-out candidates below are mostly the same as that of traditional beam search. But like the above example, constrained beam search adds onto the existing candidates by forcing the constraints at each new branch:
[ 0.0447988398373127, 0.030395934358239174, 0.0752190425992012, -0.003731803735718131, 0.026701726019382477, 0.08691669255495071, 0.034552302211523056, 0.0422416515648365, 0.002258846303448081, -0.013442856259644032, -0.07201509922742844, -0.06530199944972992, -0.03403881564736366, 0.0315733477473259, -0.04919106885790825, 0.028181182220578194, 0.07362068444490433, -0.05248945206403732, -0.0046906182542443275, -0.0027089829090982676, 0.04098526015877724, 0.042890582233667374, 0.09063895046710968, -0.022013600915670395, 0.07745593041181564, 0.015166026540100574, -0.04299173504114151, -0.033708054572343826, -0.016420088708400726, 0.03010801412165165, -0.051649775356054306, -0.007207232061773539, 0.047002580016851425, -0.042593102902173996, 0.006693496834486723, 0.019307250156998634, -0.10883284360170364, 0.028473449870944023, 0.069963738322258, -0.008834408596158028, -0.09808050841093063, -0.017811806872487068, -0.0070465682074427605, 0.005876133218407631, -0.010391240008175373, 0.006519523449242115, -0.14975593984127045, 0.10719521343708038, -0.03176824003458023, -0.03946797922253609, -0.11146519333124161, -0.007093934342265129, -0.06556122750043869, -0.010694621130824089, 0.0050716097466647625, 0.015029743313789368, -0.012847415171563625, -0.08230594545602798, 0.07132486253976822, -0.0027003800496459007, 0.010647389106452465, -0.02490137331187725, 0.02779584936797619, 0.03999175503849983, 0.04016926884651184, -0.010503808967769146, 0.024578720331192017, 0.035101402550935745, -0.09143896400928497, 0.003029395127668977, 0.039330918341875076, 0.03566813841462135, -0.06409195065498352, -0.0048115006648004055, 0.04557638615369797, -0.029390903189778328, -0.009421863593161106, 0.07385717332363129, -0.055053092539310455, 0.028951693326234818, 0.03629983216524124, 0.04065818712115288, 0.03870604187250137, 0.0638522058725357, 0.029811356216669083, 0.05542450770735741, 0.033613283187150955, -0.020839281380176544, -0.07132135331630707, 0.06769494712352753, -0.0081589724868536, -0.14116321504116058, -0.06012296304106712, 0.048490963876247406, -0.0012000310234725475, -0.052807047963142395, 0.06849700957536697, 0.034598443657159805, -0.01204188633710146, 0.02377716638147831, -0.024818291887640953, -0.022391345351934433, 0.06781285256147385, 0.04362316429615021, -0.05658579617738724, 0.030690666288137436, -0.03163876757025719, -0.018636373803019524, -0.05414895340800285, 0.03411625325679779, -0.011120229959487915, 0.022196339443325996, 0.07563597708940506, 0.05070279538631439, -0.031666435301303864, 0.02119472064077854, 0.05569810792803764, -0.01604272425174713, -0.04377014562487602, 0.018581461161375046, -0.011503277346491814, 0.08001300692558289, 0.09266021847724915, -0.014661982655525208, 0.0592612586915493, 0.013293614611029625, 0.019858965650200844, 0.01923634111881256, -0.006793169770389795, -0.04284944012761116, -0.0017445137491449714, -0.02671809494495392, -0.0060918303206563, 0.04961647093296051, 0.02157766930758953, -0.0036152717657387257, -0.0047948285937309265, -0.049135468900203705, -0.008927015587687492, 0.017246674746274948, -0.00433197570964694, -0.039183296263217926, 0.008730868808925152, 0.016530189663171768, -0.008779969066381454, -0.05079995468258858, -0.008191295899450779, 0.019763290882110596, -0.09346549212932587, 0.03877883404493332, 0.016147304326295853, 0.03023703768849373, 0.01988132856786251, -0.080316923558712, -0.04810762032866478, 0.04068249091506004, 0.007162849418818951, -0.011535901576280594, -0.06045789644122124, 0.010609561577439308, -0.04472092539072037, -0.020298976451158524, 0.013619833625853062, -0.03200111538171768, 0.06676343083381653, 0.012565401382744312, 0.056791335344314575, 0.042285844683647156, -0.03563706949353218, 0.05266083404421806, 0.009803743101656437, 0.014050432480871677, 0.07874909043312073, -0.05642538517713547, 0.03638983517885208, 0.031810905784368515, 0.03264021873474121, 0.07267845422029495, -0.04389529675245285, -0.03187907487154007, -0.005728406831622124, -0.015622536651790142, 0.03849194198846817, 0.06501201540231705, -0.009207719936966896, -0.08123630285263062, -0.003043871372938156, 0.006824317388236523, 0.03798120468854904, -0.04200885817408562, -0.052411824464797974, -0.03936094418168068, 0.06345995515584946, -0.06932450830936432, -0.032177556306123734, -0.09704601764678955, -0.05806636065244675, 0.060827575623989105, 0.04856216162443161, 0.05119933560490608, 0.09705252200365067, 0.052580296993255615, 0.025671200826764107, -0.024740293622016907, -0.059249620884656906, -0.0022018684539943933, -0.006977530661970377, -0.0771259143948555, 0.00490146316587925, 0.043129969388246536, -0.018451757729053497, -0.07964105159044266, -0.003234412521123886, -0.1275346875190735, -0.07338380068540573, 0.010813990607857704, -0.03472068905830383, -0.022555813193321228, -0.01188721414655447, 0.03481075167655945, 0.16853737831115723, 0.0018147578230127692, -0.0026835044845938683, 0.00006488723738584667, -0.01609194464981556, 0.041214313358068466, 0.05835774168372154, 0.007065124809741974, 0.03198746591806412, -0.059137728065252304, 0.045548222959041595, 0.015314123593270779, 0.09479276835918427, 0.05223716422915459, -0.007715581450611353, -0.007301147561520338, -0.018208548426628113, 0.006185763515532017, 0.04333968833088875, -0.0024375696666538715, -0.0019366657361388206, -0.03455580398440361, -0.030724359676241875, 0.06588644534349442, 0.06959627568721771, -0.023716257885098457, 0.091849185526371, -0.0045727575197815895, -0.015161121264100075, -0.03349214792251587, -0.021792255342006683, 0.008817288093268871, -0.011423060670495033, -0.10250622034072876, 0.042488258332014084, 0.02879340387880802, 0.011270007118582726, -0.04789992794394493, 0.002602888736873865, 0.00018251851724926382, -0.0008126571192406118, -0.029236549511551857, 0.022569185122847557, -0.0427025705575943, 0.003443203866481781, 0.0014064568094909191, 0.017601683735847473, 0.02023692987859249, -0.04688030853867531, 0.00924829300493002, 0.0028976951725780964, -0.012330478057265282, -0.003782765008509159, -0.030017441138625145, 0.011375930160284042, -0.015505132265388966, 0.0106445187702775, -0.05105185881257057, -0.04110555723309517, 0.009329229593276978, -0.03607289120554924, -0.003753294236958027, 0.0344100296497345, 0.018738379701972008, 0.012419057078659534, -0.010882394388318062, 0.032769717276096344, 0.012396303936839104, 0.015726827085018158, -0.019217567518353462, -0.0295189768075943, 0.03105182759463787, -0.017013536766171455, 0.025077054277062416, 0.04145754128694534, -0.011451872065663338, 0.008198754861950874, -0.02481052279472351, -0.040437839925289154, -0.01897013746201992, -0.02319648489356041, 0.014128252863883972, -0.01370423473417759, -0.016009295359253883, -0.04396054521203041, 0.0469156876206398, -0.008259537629783154, 0.08416204154491425, -0.09564927220344543, -0.02493315376341343, 0.018834641203284264, 0.0009109933744184673, 0.01259178202599287, 0.0011404529213905334, 0.026511022821068764, -0.0008065781439654529, -0.002438653027638793, -0.010852128267288208, 0.005006854888051748, 0.015160433016717434, 0.0004790235252585262, 0.008040042594075203, 0.0029093120247125626, -0.01995656080543995, 0.019923726096749306, 0.0021602956112474203, 0.014646708965301514, -0.010855800472199917, -0.0047396887093782425, 0.014046238735318184, 0.0024633605498820543, -0.019065357744693756, -0.01921001449227333, -0.026589272543787956, 0.011557753197848797, 0.02372802421450615, 0.019406966865062714, -0.022870754823088646, -0.030120596289634705, 0.02297380566596985, -0.048004165291786194, -0.01537320576608181, -0.04132206365466118, -0.001036216737702489, 0.0015831117052584887, 0.029823007062077522, 0.02953680418431759, 0.026150649413466454, 0.03808233514428139, -0.03563806414604187, -0.0005576627445407212, -0.042066656053066254, -0.001527334563434124, -0.002365431049838662, -0.04598969966173172, 0.023944348096847534, 0.01976023055613041, -0.07597324997186661, -0.032081976532936096, 0.008445965126156807, -0.004558375105261803, 0.0386790968477726, 0.0004436511662788689, -0.03469080850481987, -0.0032213437370955944, -0.014794138260185719, 0.04164152219891548, 0.02838512882590294, -0.06762389093637466, 0.00579088693484664, 0.017075631767511368, 0.003122312482446432, 0.006503948476165533, 0.039331868290901184, 0.001889960840344429, 0.03454224765300751, -0.003602457232773304, 0.009401146322488785, 0.004258323926478624, 0.010023890063166618, -0.020028699189424515, 0.012909527868032455, -0.0001368762896163389, 0.014166563749313354, -0.021552426740527153, -0.043220121413469315, 0.054781194776296616, 0.03414897248148918, -0.0058189271949231625, 0.004408864304423332, -0.06933824717998505, 0.0023846847470849752, 0.024592135101556778, -0.028451785445213318, -0.00692920945584774, 0.026500288397073746, -0.030461952090263367, -0.005936752073466778, -0.026750357821583748, -0.01973116584122181, -0.010813090018928051, 0.0014659863663837314, -0.004666680470108986, 0.04052439704537392, 0.008273715153336525, -0.012306678108870983, 0.02627161517739296, 0.0002159559226129204, -0.004009097348898649, -0.023523462936282158, -0.008707926608622074, -0.004731921013444662, -0.017059853300452232, 0.031834520399570465, -0.040335748344659805, 0.010116243734955788, -0.004627639893442392, 0.03489941731095314, 0.001764174667187035, -0.014272327534854412, -0.018553227186203003, -0.011282043531537056, 0.007829371839761734, 0.001978679094463587, -0.005600856617093086, -0.0036591514945030212, -0.025751888751983643, 0.010826576501131058, -0.014563553035259247, 0.014760288409888744, -0.007889165543019772, -0.0012068944051861763, 0.0019834693521261215, -0.051407430320978165, 0.019059263169765472, 0.014704149216413498, 0.016233913600444794, -0.019073961302638054, 0.02393222413957119, 0.011290972121059895, 0.041769497096538544, -0.01085614413022995, 0.011982036754488945, -0.0038550763856619596, -0.005368036217987537, -0.015949249267578125, -0.012529426254332066, -0.03700096160173416, 0.02914954349398613, -0.016101345419883728, 0.02838851884007454, -0.0178142711520195, 0.07037593424320221, 0.021180681884288788, -0.049762096256017685, 0.00926364678889513, -0.007463607471436262, 0.0345161072909832, 0.07713579386472702, 0.011118058115243912, -0.042088888585567474, 0.010679024271667004, 0.030945418402552605, -0.05013829469680786, -0.018396291881799698, -0.02880033105611801, 0.01080320030450821, 0.03555755317211151, 0.01553970668464899, -0.038276296108961105, -0.06463392078876495, 0.003677103901281953, -0.0017050725873559713, -0.02445141412317753, -0.025812339037656784, 0.009624648839235306, -0.02178817428648472, -0.014098071493208408, 0.009092850610613823, 0.0033457300160080194, 0.015926819294691086, -0.016181105747818947, 0.018913911655545235, 0.03468123450875282, 0.016203975304961205, 0.004753678105771542, -0.026044685393571854, 0.0019874474965035915, -0.06035537272691727, -0.0042159403674304485, 0.00822334922850132, 0.030090782791376114, 0.009747453033924103, 0.0007273596711456776, 0.07137332111597061, 0.01613912172615528, -0.00798526220023632, 0.013493891805410385, 0.0011732473503798246, -0.01202037837356329, 0.03356494382023811, -0.04173819348216057, 0.025610676035284996, 0.013768128119409084, -0.04822755977511406, 0.03899582475423813, -0.011460844427347183, -0.013992669060826302, 0.01011900044977665, -0.03332994878292084, -0.02566053718328476, -0.00260411505587399, 0.01057174988090992, 0.003160475753247738, -0.002587533090263605, -0.04832713305950165, -0.01639621891081333, -0.005391672719269991, 0.0006361444829963148, -0.005089378450065851, -0.08673130720853806, -0.015326078049838543, 0.020162109285593033, -0.024162428453564644, -0.04859388247132301, -0.0010262905852869153, 0.03538349270820618, 0.05258088558912277, 0.020227588713169098, -0.03855333477258682, -0.028713587671518326, 0.04376666620373726, 0.020590895786881447, 0.0027220260817557573, 0.0026761144399642944, 0.01687554642558098, 0.05267404392361641, 0.05951418727636337, 0.028621627017855644, -0.02878866344690323, 0.009136157110333443, -0.011725392192602158, 0.027831215411424637, -0.008951887488365173, -0.0030202162452042103, 0.06871587038040161, 0.028560500591993332, 0.019031500443816185, 0.04918147996068001, 0.0001886556128738448, -0.03358124569058418, 0.0030191608238965273, -0.026068488135933876, -0.014048616401851177, 0.05943623185157776, -0.015352091751992702, -0.00374074699357152, 0.027979008853435516, 0.02165009081363678, -0.00543444138020277, -0.005311192478984594, 0.031174013391137123, -0.02970038913190365, 0.03839579597115517, 0.040231239050626755, -0.0025631082244217396, -0.014488187618553638, 0.016573626548051834, 0.025972042232751846, -0.06499762088060379, -0.01865236461162567, 0.0070009492337703705, -0.05797669291496277, 0.042350053787231445, -0.031601253896951675, -0.05691322684288025, -0.010266651399433613, 0.004905198235064745, 0.009827665984630585, 0.004032866097986698, -0.022196372970938683, 0.05526398494839668, -0.008848915807902813, 0.02382434904575348, 0.010828394442796707, 0.08635571599006653, -0.007512910757213831, 0.04709126055240631, 0.008403916843235493, 0.05056583508849144, -0.015735290944576263, -0.0124581940472126, -0.010374833829700947, 0.006159996148198843, 0.042620062828063965, -0.022793183103203773, 0.05196419358253479, 0.004761595278978348, -0.029660644009709358, 0.0010127373971045017, 0.009589063934981823, -0.014721674844622612, -0.01138162799179554, 0.009389786049723625, 0.019972095265984535, 0.02303624339401722, 0.02608656696975231, -0.015099587850272655, 0.022218821570277214, -0.020175117999315262, 0.024551844224333763, -0.012673281133174896, 0.013050233945250511, 0.0014790174318477511, 0.016154352575540543, 0.04689500108361244, 0.07464947551488876, -0.03160347416996956, -0.01618771255016327, 0.0896710529923439, 0.007355269975960255, 0.03706064447760582, 0.019540833309292793, 0.031349822878837585, 0.02046680450439453, 0.0005003802361898124, -0.02147023007273674, 0.018178511410951614, 0.05110078677535057, -0.02326466143131256, 0.007371176034212112, 0.007050910033285618, -0.04313073307275772, -0.013199413195252419, 0.015032586641609669, 0.0018941812450066209, -0.012051098980009556, -0.00852940883487463, 0.004513320978730917, 0.02739456668496132, 0.025408726185560226, -0.04805838689208031, -0.048912353813648224, -0.01661258190870285, -0.014505544677376747, 0.029957275837659836, -0.04953955486416817, -0.03372910991311073, -0.027520006522536278, 0.016532961279153824, -0.012270565144717693, 0.0034817291889339685, -0.000631782750133425, 0.03132268041372299, -0.030688967555761337, 0.027189571410417557, -0.04459265246987343, 0.07909204810857773, 0.01898474246263504, 0.006066693924367428, -0.060220710933208466, -0.02919774129986763, -0.0037873198743909597, 0.009097876027226448, -0.02058209292590618, -0.032501738518476486, -0.006774373352527618, -0.04410777613520622, 0.05525975301861763, -0.009178923442959785, -0.0017174049280583858, -0.036441147327423096, -0.01516183465719223, -0.02143155410885811, -0.04547159746289253, -0.005013775080442429, -0.006507830694317818, 0.0206194669008255, -0.004495927598327398, -0.021816115826368332, -0.01655750349164009, -0.020057301968336105, 0.010384186170995235, 0.02989720180630684, 0.04106626287102699, -0.01393196452409029, -0.07772067934274673, -0.017883235588669777, 0.03644103556871414, -0.00581990834325552, 0.003165223402902484, 0.03719324246048927, 0.00499690743163228, 0.01721092499792576, 0.011386607773602009, -0.000764084339607507, -0.02139231562614441, 0.06204689294099808, -0.04391124099493027, -0.038301531225442886, -0.04718121141195297, -0.006349647417664528, 0.008712077513337135, 0.012420113198459148, -0.038699496537446976, 0.042099613696336746, 0.02163201943039894, 0.003515222342684865, -0.01879245601594448, -0.018233582377433777, 0.03914203122258186, -0.022075561806559563, 0.05913328006863594, -0.015330560505390167, 0.01757221482694149, -0.029550667852163315, 0.003568499581888318, 0.026668988168239594, 0.029929105192422867, -0.012627679854631424, 0.00639905221760273, -0.02964377962052822, 0.020374856889247894, -0.06207539886236191, -0.043414369225502014, 0.018923737108707428, 0.005153116770088673, -0.021817557513713837, -0.008586031384766102, 0.03046201355755329, 0.030422255396842957, 0.02441016584634781, 0.009434442035853863, 0.0009995762957260013, -0.002446151105687022, 0.02226942591369152, 0.007295170333236456, -0.030042361468076706, -0.036940984427928925, 0.005525294225662947, 0.02287285216152668, 0.01296472828835249, 0.026023011654615402, -0.02797858789563179, 0.006735679227858782, -0.01108017098158598, 0.0053106918931007385, 0.013480846770107746, -0.02713753841817379, -0.025560038164258003, -0.006898713763803244, -0.007556634023785591, -0.04398588836193085, -0.02530423365533352, 0.020817112177610397, -0.0034148877020925283, -0.048141706734895706, 0.030756385996937752, 0.014685346744954586, 0.0023649551440030336, -0.010569872334599495, 0.05245261639356613, 0.00939941219985485, 0.02286529913544655, 0.03305468708276749, 0.028980864211916924, -0.016927726566791534, -0.010966780595481396 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
Example 1: Forcing a Word Let's say we're trying to translate "How old are you?" to German. "Wie alt bist du?" is what you'd say in an informal setting, and "Wie alt sind Sie?" is what you'd say in a formal setting. And depending on the context, we might want one form of formality over the other, but how do we tell the model that?
[ 0.04413573443889618, 0.013083222322165966, 0.03195600211620331, -0.015515908598899841, 0.06313670426607132, 0.04523817077279091, 0.03292445093393326, 0.03919980674982071, -0.02453949861228466, 0.014112923294305801, -0.041562385857105255, 0.06762649118900299, -0.011166510172188282, -0.011807973496615887, -0.028850775212049484, 0.01658407226204872, 0.07272743433713913, -0.045297201722860336, 0.006172293797135353, -0.053874582052230835, -0.0542047843337059, 0.017825843766331673, -0.005357476882636547, -0.018352460116147995, 0.05523692071437836, -0.029637660831212997, 0.03787974640727043, -0.04139690473675728, -0.03839194029569626, -0.015238200314342976, -0.048079609870910645, -0.02526368759572506, -0.01022209133952856, -0.01972489058971405, -0.03727469965815544, 0.001049403683282435, -0.058334048837423325, 0.021638398990035057, 0.010723867453634739, -0.09106867760419846, -0.03881414234638214, -0.006072753109037876, -0.010485537350177765, -0.024210060015320778, -0.06550613045692444, -0.0055983588099479675, -0.1935916543006897, 0.05097080394625664, -0.033157918602228165, -0.010659863241016865, -0.05613009259104729, 0.05378775671124458, 0.00481031509116292, 0.036132827401161194, 0.0002313362347194925, -0.019747953861951828, -0.05641657114028931, -0.09676715731620789, -0.001839249860495329, -0.04425446689128876, 0.03912133723497391, 0.016756366938352585, 0.018267543986439705, 0.028358830139040947, 0.030830390751361847, 0.02655930444598198, -0.0662989392876625, 0.024406133219599724, -0.10211893916130066, 0.035226866602897644, -0.0588252879679203, -0.014280498027801514, -0.02944255992770195, -0.025264138355851173, 0.017688026651740074, -0.039151180535554886, 0.029764289036393166, 0.0536835640668869, -0.02061823196709156, 0.08409994095563889, -0.018989933654665947, -0.024068286642432213, 0.08011239767074585, 0.0662030503153801, 0.01867884211242199, -0.019532594829797745, 0.045034606009721756, 0.060419872403144836, 0.031026078388094902, 0.009327304549515247, 0.008780281990766525, -0.10429910570383072, -0.039365947246551514, -0.011984553188085556, 0.050011638551950455, -0.006367961410433054, 0.05696819722652435, 0.03330186754465103, 0.02739124745130539, 0.06616780161857605, -0.041905224323272705, -0.015154018998146057, 0.08716670423746109, 0.00728963129222393, -0.04435327649116516, 0.027872176840901375, -0.02728729322552681, -0.019810007885098457, -0.014139415696263313, 0.04325241968035698, 0.014116296544671059, -0.02910929173231125, 0.08797777444124222, 0.008076622150838375, -0.03826213628053665, 0.027446916326880455, 0.07039754092693329, -0.007062616292387247, -0.02210325002670288, 0.040800001472234726, 0.04548792168498039, 0.03418981656432152, 0.11970504373311996, 0.02004128322005272, 0.06545176357030869, -0.008496442809700966, 0.01918637566268444, 0.008598740212619305, -0.04177265614271164, -0.0574844554066658, 0.01712897978723049, 0.035873088985681534, 0.028388332575559616, 0.00763540156185627, 0.022532613947987556, -0.09647290408611298, 0.05861671641469002, -0.07264406234025955, 0.012897529639303684, -0.011825953610241413, 0.007559660822153091, 0.010942003689706326, -0.02951093576848507, 0.10055843740701675, 0.03941333666443825, 0.007642916403710842, -0.01231809426099062, -0.018162071704864502, -0.007967960089445114, 0.01670023798942566, 0.04286441206932068, 0.08474757522344589, -0.01378525048494339, -0.03569672256708145, 0.029310831800103188, 0.040032967925071716, -0.05321583151817322, -0.01016257144510746, 0.01138055045157671, -0.030060283839702606, 0.00267925881780684, 0.023435601964592934, 0.0047205411829054356, -0.014701968058943748, 0.11470233649015427, -0.034815702587366104, -0.0017776080640032887, 0.08911584317684174, 0.0091288136318326, -0.011670743115246296, 0.03303762525320053, -0.029827525839209557, 0.09490980952978134, -0.015508661046624184, -0.03554944694042206, 0.09209045022726059, 0.0012595097068697214, 0.03712591156363487, 0.011666794307529926, 0.053450196981430054, 0.01936723291873932, 0.04718176648020744, -0.03432861343026161, 0.017959877848625183, 0.04490648955106735, -0.01025378704071045, -0.007830565795302391, -0.07546517997980118, 0.019673895090818405, 0.010009052231907845, -0.11936583369970322, -0.023046866059303284, 0.0878937765955925, 0.010658146813511848, -0.029207482933998108, -0.07867015153169632, -0.06077038496732712, 0.10577455163002014, 0.022539028897881508, 0.08326272666454315, 0.07933914661407471, -0.06203553453087807, 0.012686395086348057, -0.054185014218091965, -0.032860320061445236, 0.08168277889490128, 0.038217492401599884, -0.032015226781368256, -0.020942267030477524, 0.045467305928468704, 0.040757399052381516, -0.06604648381471634, 0.05682523176074028, -0.11446225643157959, -0.03730221092700958, -0.06120426580309868, -0.009327996522188187, 0.0027594752609729767, -0.02483050897717476, -0.05627794563770294, 0.13709735870361328, -0.02997325174510479, -0.020666752010583878, -0.014313950203359127, -0.03823758289217949, 0.008850864134728909, 0.07144518196582794, 0.0711536705493927, 0.02405855804681778, -0.08864296972751617, 0.001572839100845158, -0.04286739230155945, 0.061335984617471695, -0.011552467942237854, 0.004890704993158579, -0.03557644411921501, 0.0031939547043293715, 0.004478513728827238, -0.01454024575650692, -0.07933595776557922, 0.03455106168985367, -0.04921818524599075, 0.009294015355408192, 0.0687100812792778, -0.03131357952952385, 0.00625406950712204, 0.05355445295572281, 0.010009123012423515, -0.0003388111072126776, -0.008031797595322132, -0.0828028991818428, -0.0076394714415073395, 0.025735266506671906, -0.018467318266630173, 0.010774212889373302, -0.015812376514077187, 0.0366976298391819, 0.029558926820755005, -0.006839953828603029, 0.013452589511871338, -0.011663178913295269, -0.01029985398054123, 0.03966011479496956, -0.04779874160885811, 0.008554111234843731, -0.0034151310101151466, -0.0043467748910188675, 0.04017609730362892, -0.017910445109009743, 0.034961335361003876, -0.031765468418598175, -0.012502746656537056, -0.00869700312614441, -0.029521074146032333, -0.010650670155882835, 0.03559744730591774, 0.008746868930757046, 0.0031829869840294123, -0.03272193670272827, 0.011012067086994648, -0.022679263725876808, 0.00599907198920846, 0.03688882663846016, 0.020716147497296333, 0.015684474259614944, -0.036357372999191284, 0.02078806795179844, 0.011127295903861523, -0.04982985556125641, 0.00014805543469265103, 0.025510083884000778, 0.0008075001533143222, -0.01633260026574135, 0.021329108625650406, 0.0433618500828743, -0.011685159988701344, -0.009877977892756462, -0.023746320977807045, -0.004225502721965313, -0.025438327342271805, 0.00024993804981932044, 0.04227551445364952, -0.002264326438307762, 0.00375509075820446, -0.03424251452088356, 0.03023664653301239, -0.004518705885857344, -0.006327806040644646, -0.11624766141176224, -0.00470247445628047, 0.015032690018415451, -0.009286344051361084, -0.010602233000099659, -0.03328920155763626, 0.018837854266166687, -0.03194286674261093, -0.03205360099673271, 0.02660585753619671, -0.017519919201731682, 0.0040857307612895966, 0.01842600665986538, 0.047974664717912674, -0.024465782567858696, -0.04590225592255592, -0.012799473479390144, -0.023311572149395943, -0.027679091319441795, -0.014407984912395477, 0.008430594578385353, 0.050020333379507065, 0.02495427057147026, -0.007676402106881142, 0.03214453160762787, 0.017479203641414642, 0.04667586460709572, 0.043867241591215134, 0.033171396702528, -0.04773712158203125, 0.0010335866827517748, 0.022508572787046432, -0.023564713075757027, -0.00911730993539095, -0.023701099678874016, 0.025953713804483414, 0.009683139622211456, 0.03612509369850159, 0.009424041956663132, 0.07603180408477783, 0.00114478322211653, -0.016711074858903885, 0.010041904635727406, 0.02644294686615467, -0.06653106212615967, -0.028237495571374893, -0.047073833644390106, -0.00997227057814598, 0.031233390793204308, -0.052704598754644394, -0.016605209559202194, 0.006886912509799004, 0.00928527396172285, 0.04351331666111946, 0.017371665686368942, 0.02775447443127632, 0.011114521883428097, 0.05816183611750603, 0.06839581578969955, -0.03563045337796211, -0.044731661677360535, 0.020272109657526016, 0.00704990653321147, -0.029554458335042, -0.029346510767936707, 0.04550530016422272, -0.01710527576506138, 0.03987311199307442, 0.031711943447589874, 0.024449240416288376, -0.010141901671886444, 0.011667161248624325, -0.022397762164473534, 0.016979854553937912, -0.02331709675490856, -0.002910581650212407, -0.04179861396551132, -0.02174396812915802, 0.09268203377723694, 0.00671249907463789, -0.03105357103049755, -0.014045941643416882, -0.04757146164774895, -0.023713279515504837, -0.009288338012993336, -0.02017778530716896, 0.03527918830513954, -0.009144975803792477, -0.019201016053557396, 0.05927027761936188, 0.0024784118868410587, 0.0009642706718295813, 0.015155999921262264, 0.03770267963409424, -0.033990345895290375, -0.0073050702922046185, 0.04302914813160896, -0.03742540627717972, 0.03849320858716965, -0.020103666931390762, 0.014724907465279102, -0.051632411777973175, -0.011471203528344631, 0.025482041761279106, 0.0302375927567482, 0.049082595854997635, -0.05884704366326332, -0.014052113518118858, 0.010585818439722061, 0.030592573806643486, -0.008741202764213085, 0.008615449070930481, -0.019975818693637848, -0.03623346611857414, -0.026933208107948303, 0.019727172330021858, -0.009983639232814312, -0.026142820715904236, -0.005571096669882536, -0.01675289496779442, -0.04555295780301094, 0.004002437461167574, 0.02765880711376667, -0.024195540696382523, -0.011846281588077545, -0.015429595485329628, 0.05104066804051399, 0.03312050178647041, 0.031031059101223946, 0.03822469338774681, -0.017898568883538246, -0.031816836446523666, 0.01289444975554943, -0.00621398538351059, 0.017920633777976036, 0.0016172738978639245, 0.01168796606361866, 0.06411813944578171, -0.016550952568650246, -0.05393066257238388, -0.006856110878288746, 0.012202057987451553, 0.014825199730694294, -0.0014095996739342809, 0.0632566586136818, -0.017210828140378, -0.05013929679989815, -0.0208001509308815, 0.03161686658859253, 0.03443562239408493, 0.0570218525826931, -0.012310911901295185, -0.03580870106816292, -0.014930400997400284, -0.006991271395236254, -0.050933536142110825, 0.017595697194337845, -0.031119724735617638, -0.03132199868559837, 0.06485208123922348, -0.017487257719039917, -0.02404225990176201, -0.024093162268400192, 0.0408204160630703, 0.02176351100206375, 0.0074608828872442245, -0.025433504953980446, -0.014335212297737598, -0.0017096869414672256, 0.03226633742451668, 0.020269012078642845, -0.022057242691516876, 0.004156089853495359, -0.03268342837691307, 0.00556174898520112, 0.002367619192227721, 0.014399254694581032, 0.03484208881855011, -0.014212985523045063, -0.0015746594872325659, 0.012398578226566315, -0.027264947071671486, -0.007036833558231592, 0.01551110576838255, -0.007708604447543621, 0.012549598701298237, 0.047044094651937485, 0.03384420648217201, 0.03424828499555588, 0.04553063586354256, 0.010002193972468376, -0.020722322165966034, 0.007951352745294571, -0.057027868926525116, 0.0037937157321721315, 0.004068576730787754, -0.02747403271496296, -0.051735423505306244, -0.028677185997366905, 0.06512223929166794, 0.04857322946190834, 0.007531274110078812, 0.012597202323377132, -0.00409550778567791, 0.004020616412162781, 0.0015765890711918473, -0.0033526059705764055, -0.07875003665685654, 0.008087780326604843, -0.026310734450817108, -0.03467473387718201, -0.04602907970547676, -0.02040664292871952, -0.03472958877682686, -0.010333535261452198, -0.022178199142217636, -0.017083046957850456, 0.0007104490650817752, -0.030615724623203278, 0.040709711611270905, 0.053371235728263855, -0.004056526813656092, -0.0443229079246521, 0.03121666982769966, 0.05615538731217384, 0.012355661951005459, 0.003537962445989251, 0.03618163242936134, 0.06652650237083435, 0.030570488423109055, -0.010593761689960957, -0.009303620085120201, 0.03192908316850662, 0.03283362090587616, -0.026981601491570473, 0.01485777273774147, -0.007516197860240936, 0.03948820009827614, 0.016581108793616295, -0.00969886127859354, 0.0162154920399189, -0.01721920631825924, -0.013928551226854324, -0.011290865950286388, -0.05303746089339256, 0.01858365349471569, 0.04964005947113037, 0.031737737357616425, 0.010511510074138641, 0.012055788189172745, -0.000867385882884264, 0.012318108230829239, 0.03562566265463829, -0.0014662353787571192, -0.005305855069309473, 0.020027952268719673, 0.023251155391335487, 0.01568160206079483, -0.021856235340237617, -0.034221842885017395, 0.08504976332187653, -0.029352743178606033, -0.04671894758939743, -0.009312976151704788, -0.04723887890577316, 0.011624949984252453, 0.028449619188904762, 0.0029976600781083107, -0.00860369112342596, 0.04862971976399422, 0.011348954401910305, 0.010418147780001163, 0.00027077694539912045, 0.0071433549746870995, 0.029032407328486443, -0.001057755551300943, -0.011085336096584797, 0.0454544723033905, -0.0029415565077215433, 0.026745576411485672, 0.010512563399970531, 0.03688778728246689, 0.026937266811728477, -0.0063733747228980064, -0.004377652425318956, 0.027733808383345604, 0.052303213626146317, -0.0007343605975620449, 0.021946096792817116, 0.027343938127160072, -0.0392766147851944, -0.029324481263756752, 0.013201727531850338, 0.019495472311973572, -0.07304602116346359, 0.06250641494989395, -0.010656598955392838, -0.00040534985600970685, -0.00018544771592132747, -0.019344696775078773, 0.036628033965826035, -0.020996039733290672, 0.006379642523825169, -0.028242070227861404, 0.009156831540167332, 0.04223243519663811, 0.05945899710059166, 0.031641505658626556, 0.030892107635736465, -0.04564593359827995, -0.009790527634322643, 0.06568919867277145, 0.016119297593832016, -0.0165434330701828, 0.0006633785087615252, 0.005463688634335995, 0.0052271680906414986, -0.042017076164484024, -0.03747167810797691, -0.00787268579006195, 0.04719313979148865, -0.03916087746620178, -0.03544412925839424, 0.030434945598244667, -0.009818104095757008, -0.02075645513832569, -0.005150025710463524, -0.01658068224787712, -0.0037073292769491673, -0.047299984842538834, 0.011150847189128399, 0.03387056663632393, 0.012695354409515858, -0.04531288146972656, -0.04317808896303177, -0.005583246238529682, 0.023481246083974838, 0.004764547571539879, -0.043311964720487595, 0.006870011333376169, -0.04042861610651016, -0.0414767749607563, -0.018816713243722916, -0.01850440353155136, 0.00846382137387991, 0.004300128202885389, 0.007062608376145363, -0.019429299980401993, -0.014276118017733097, -0.004653803538531065, 0.006485489197075367, 0.02625126950442791, -0.0036240359768271446, -0.008250631392002106, -0.01653296686708927, -0.012249121442437172, 0.015757951885461807, -0.010059917345643044, -0.018177013844251633, -0.006900862790644169, 0.004545240662992001, 0.0036917123943567276, -0.00131377880461514, -0.01835642009973526, -0.022252539172768593, -0.011523258872330189, -0.030730895698070526, 0.01779303327202797, 0.00009502175089437515, 0.03511656075716019, -0.023953843861818314, 0.023334959521889687, -0.028607895597815514, -0.046931780874729156, -0.00008860354864737019, -0.009185166098177433, 0.005841083358973265, -0.011742811650037766, -0.00286358711309731, -0.0681556835770607, 0.004751785658299923, 0.012142748571932316, 0.009044394828379154, 0.03520553559064865, 0.04612809419631958, -0.005937477108091116, -0.022411786019802094, 0.032473791390657425, -0.03517020866274834, 0.025373052805662155, 0.009777473285794258, -0.03805255889892578, -0.0215090811252594, 0.024000149220228195, -0.01358125451952219, -0.015283502638339996, -0.041247427463531494, -0.019430290907621384, -0.02748202160000801, -0.016845162957906723, -0.0037509328685700893, 0.019649751484394073, 0.03393419831991196, 0.002206745557487011, 0.025377759709954262, -0.002738955430686474, 0.038741227239370346, -0.010038269683718681, -0.024902738630771637, -0.015024789609014988, 0.008681186474859715, 0.006607843097299337, -0.016782842576503754, 0.014848367311060429, 0.02006164938211441, -0.04549980163574219, -0.0345098115503788, 0.01745385304093361, 0.026037337258458138, -0.0419699102640152, 0.027423446998000145, 0.009032168425619602, 0.0015556516591459513, -0.0046304683201014996, 0.010220593772828579, 0.027206342667341232, -0.010285565629601479, 0.0007383500342257321, 0.030163772404193878, -0.04389428347349167, -0.022852644324302673, -0.018145430833101273, 0.028281264007091522, 0.01894228905439377, 0.05267518013715744, 0.007635677233338356, 0.020681342110037804, -0.02277389168739319, 0.0028982798103243113, 0.009720120579004288, -0.04101242870092392, -0.03353680297732353, -0.00027473291265778244, 0.004894329234957695, -0.027859801426529884, -0.03564195707440376, 0.031115256249904633, 0.0037736590020358562, -0.021124206483364105, -0.027923330664634705, 0.05798269063234329, -0.025341501459479332, 0.019431568682193756, -0.012605019845068455, -0.015379780903458595, -0.005669821985065937, 0.04204122722148895, -0.007115064188838005, -0.002131005981937051, 0.0046484824270009995 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
Traditional Beam search The following is an example of traditional beam search, taken from a previous blog post: Unlike greedy search, beam search works by keeping a longer list of hypotheses. In the above picture, we have displayed three next possible tokens at each possible step in the generation. Here's another way to look at the first step of the beam search for the above example, in the case of num_beams=3: Instead of only choosing "The dog" like what a greedy search would do, a beam search would allow further consideration of "The nice" and "The car". In the next step, we consider the next possible tokens for each of the three branches we created in the previous step. Though we end up considering significantly more than num_beams outputs, we reduce them down to num_beams at the end of the step. We can't just keep branching out, then the number of beams we'd have to keep track of would be \( \text{beams}^{n} \) for \( n \) steps, which becomes very large very quickly ( \( 10 \) beams after \( 10 \) steps is \( 10,000,000,000 \) beams!). For the rest of the generation, we repeat the above step until the ending criteria has been met, like generating the <eos> token or reaching max_length, for example. Branch out, rank, reduce, and repeat.
[ 0.029993006959557533, 0.019536664709448814, 0.07233747839927673, -0.052766766399145126, 0.07085300981998444, 0.03374901041388512, 0.04008487984538078, 0.04126085340976715, -0.03691411763429642, -0.010078885592520237, -0.07110375910997391, -0.026722904294729233, 0.013074501417577267, 0.038436468690633774, -0.06035288795828819, -0.010883831419050694, 0.04823166877031326, -0.06296251714229584, 0.013780537992715836, 0.006718665361404419, 0.0499129518866539, 0.018947482109069824, 0.11275343596935272, -0.02085185796022415, 0.0691150352358818, 0.004153966438025236, 0.021384740248322487, -0.0036461802665144205, -0.01983310468494892, 0.07641670852899551, -0.0785236805677414, -0.02700904756784439, 0.0421212762594223, -0.046201545745134354, -0.012647881172597408, 0.004943931940943003, -0.08199683576822281, 0.060502130538225174, 0.04448080062866211, -0.06920996308326721, -0.027968261390924454, -0.0467672199010849, -0.007680548820644617, 0.03918909281492233, 0.001226769294589758, 0.02443593367934227, -0.2004787027835846, 0.09076645970344543, -0.08501739054918289, -0.011329091154038906, -0.08679460734128952, 0.029108408838510513, -0.041110195219516754, 0.03343437984585762, -0.024425877258181572, -0.02190464548766613, 0.02140173316001892, -0.023881901055574417, 0.07908152788877487, 0.03134756162762642, -0.007906410843133926, -0.008254995569586754, 0.020928818732500076, 0.06336455792188644, 0.03801974281668663, 0.01326396968215704, -0.013811677694320679, 0.06007940322160721, -0.09190160781145096, 0.06754676252603531, 0.056006889790296555, 0.012680045329034328, -0.04358343407511711, -0.03243454545736313, 0.03334696218371391, -0.025419216603040695, -0.030000217258930206, 0.0427507609128952, -0.02571842260658741, 0.02611379511654377, 0.04036618769168854, 0.05794508010149002, 0.04669215530157089, 0.0594765767455101, 0.02831781469285488, 0.057619210332632065, 0.015182903036475182, 0.011845345608890057, -0.0578683465719223, 0.039201769977808, -0.03721486032009125, -0.15589849650859833, -0.0006307585863396525, 0.07954180985689163, 0.03918226435780525, -0.04738979786634445, 0.06429141759872437, 0.020119192078709602, -0.004312237724661827, 0.02678944170475006, 0.026231354102492332, -0.02272956818342209, 0.06248107925057411, -0.00688056368380785, -0.07892311364412308, 0.0085464371368289, 0.0007464551599696279, -0.04837290197610855, -0.06313375383615494, -0.009299838915467262, -0.002885496709495783, 0.029989073053002357, 0.031174786388874054, 0.07161208242177963, 0.02086588926613331, 0.044517967849969864, 0.0629345178604126, 0.018825337290763855, -0.020587941631674767, -0.005584739148616791, -0.042128317058086395, 0.09445741027593613, 0.14851361513137817, -0.04918106645345688, 0.01593838632106781, 0.003056485438719392, 0.008809379301965237, 0.0319705493748188, -0.09213202446699142, -0.03715594857931137, 0.024498991668224335, 0.02049340307712555, -0.001026015728712082, -0.029668519273400307, -0.028413919731974602, 0.005511768627911806, 0.009017380885779858, -0.002276559127494693, -0.014397435821592808, -0.011725050397217274, -0.028224000707268715, -0.03736964985728264, -0.021231690421700478, 0.05272765830159187, 0.025619162246584892, -0.060221098363399506, 0.009626572020351887, -0.005230506416410208, -0.051373615860939026, 0.04490082710981369, -0.020322265103459358, 0.029966386035084724, 0.0296210628002882, -0.072883740067482, -0.0036245996598154306, 0.049642160534858704, 0.04584548622369766, -0.03052145428955555, -0.04684150964021683, 0.015898456797003746, -0.005818115547299385, -0.00844480749219656, 0.031154416501522064, -0.011511069722473621, 0.04650320112705231, -0.020452024415135384, 0.052282702177762985, 0.07352293282747269, -0.06630691885948181, 0.06283318251371384, -0.00026380326016806066, 0.014905313029885292, 0.07086045295000076, -0.06677638739347458, 0.025369660928845406, 0.0017143174773082137, 0.025321226567029953, 0.009776066057384014, -0.040212202817201614, -0.014116058126091957, -0.008469980210065842, -0.0584409162402153, 0.024059928953647614, 0.030421331524848938, -0.026122167706489563, -0.070347361266613, 0.04543118178844452, 0.017868448048830032, 0.029971878975629807, -0.03402012959122658, -0.03288090229034424, -0.08793194591999054, 0.059960685670375824, -0.0441993810236454, -0.015240231528878212, -0.03155471011996269, 0.0026866246480494738, 0.07664602249860764, 0.031231675297021866, 0.0528663694858551, 0.04258288815617561, 0.08366384357213974, 0.048903949558734894, -0.04674085974693298, -0.02417714335024357, 0.004345487337559462, 0.012808971107006073, -0.0488392598927021, 0.022033043205738068, 0.0153240617364645, -0.01954042725265026, -0.04883958399295807, 0.04647626727819443, -0.11682207882404327, -0.07565024495124817, -0.02094835229218006, 0.014009728096425533, 0.00751257361844182, 0.026074638590216637, 0.010288416408002377, 0.13179732859134674, -0.01778826117515564, -0.06307398527860641, 0.014499983750283718, -0.03243133798241615, 0.03993001952767372, 0.10169173777103424, -0.000964006467256695, 0.016182545572519302, -0.08236716687679291, 0.0010425910586491227, 0.008289264515042305, 0.06793483346700668, 0.029501788318157196, 0.006862966809421778, -0.032052502036094666, -0.022738249972462654, -0.026936020702123642, 0.04387940838932991, -0.0048094335943460464, -0.012331601232290268, -0.05105261132121086, -0.006640469189733267, 0.0923416018486023, 0.009828297421336174, -0.04483075439929962, 0.05651969462633133, 0.022980408743023872, -0.0486268512904644, -0.023635566234588623, -0.01659446582198143, 0.04948386177420616, -0.05748488008975983, -0.06720650941133499, 0.051609594374895096, 0.05639602988958359, -0.009007974527776241, -0.02169855125248432, -0.02171996794641018, 0.004668719135224819, -0.028531823307275772, -0.01056749653071165, 0.013119794428348541, -0.04675426334142685, -0.004491819068789482, 0.012859662063419819, -0.015049152076244354, -0.016363976523280144, -0.009620662778615952, 0.0023268733639270067, -0.023523451760411263, 0.01518873032182455, 0.007467423100024462, 0.01636861264705658, 0.012152253650128841, 0.00435552978888154, 0.005858797580003738, -0.0357903316617012, -0.01791413314640522, 0.0015728495782241225, -0.03883141279220581, -0.0030419006943702698, 0.03322817385196686, 0.01320869754999876, 0.03439455106854439, -0.014952193014323711, 0.023560553789138794, 0.0030590230599045753, 0.004416861105710268, -0.007518914993852377, -0.007779333274811506, 0.020345371216535568, 0.013695497065782547, -0.026795558631420135, 0.016300462186336517, -0.00423512514680624, -0.004005224443972111, -0.0006316166836768389, -0.04880842566490173, 0.0023799811024218798, 0.0073514473624527454, -0.01494155265390873, -0.007520951796323061, -0.043100278824567795, -0.03189251571893692, 0.0594366192817688, 0.05244072154164314, 0.09920921176671982, -0.10455605387687683, -0.03313183784484863, 0.023376064375042915, 0.0029540464747697115, 0.0012508099898695946, 0.009379924274981022, -0.008541123010218143, -0.019995857030153275, 0.0023225140757858753, -0.06252186745405197, -0.0011917941737920046, 0.004034568089991808, 0.02172197587788105, 0.024069931358098984, -0.016284482553601265, 0.012416223995387554, -0.016752105206251144, 0.027453938499093056, 0.029409484937787056, 0.0023748939856886864, -0.0014697532169520855, 0.033404745161533356, -0.0062629240565001965, 0.009094523265957832, -0.027398988604545593, -0.031563226133584976, 0.0434722974896431, 0.003567374311387539, 0.030119605362415314, -0.007438178639858961, -0.019732234999537468, 0.0013379541924223304, -0.04729866236448288, 0.012447189539670944, -0.021917684003710747, -0.013627951964735985, 0.054526615887880325, 0.007435622159391642, -0.0019351192750036716, 0.04309692978858948, 0.019158227369189262, -0.016735129058361053, 0.01707715168595314, -0.01081741414964199, -0.048241592943668365, -0.006490681320428848, -0.02433912828564644, 0.013150877319276333, 0.03831515088677406, -0.06740058958530426, -0.0034944377839565277, -0.018917163833975792, 0.009078324772417545, 0.017496004700660706, -0.017120972275733948, -0.02760334499180317, 0.003608141792938113, -0.012114502489566803, 0.0356573686003685, 0.012803556397557259, -0.058466434478759766, 0.033966243267059326, 0.02216111309826374, -0.000014853475477139, -0.01598399691283703, 0.0278864074498415, -0.014406302012503147, 0.03887011483311653, -0.0073710777796804905, 0.006845077499747276, 0.02151329070329666, -0.0021924006287008524, -0.01730135828256607, 0.0033593832049518824, 0.014504273422062397, 0.017338156700134277, -0.009241732768714428, -0.0498720221221447, 0.07940231263637543, 0.03286295756697655, -0.013176904991269112, 0.014518425799906254, -0.0557560920715332, 0.00889598298817873, 0.0456681102514267, 0.00013645699073094875, -0.018245330080389977, 0.018393220379948616, -0.043036092072725296, 0.00035263592144474387, -0.0014659937005490065, -0.0215341504663229, -0.04908327758312225, 0.017595067620277405, -0.017031725496053696, -0.0039329989813268185, 0.01373816467821598, -0.013597417622804642, 0.014884717762470245, -0.01927710883319378, 0.03317970037460327, -0.016402900218963623, 0.006921857129782438, 0.014642056077718735, -0.00024385344295296818, -0.0068015893921256065, -0.10183060169219971, -0.00011364353849785402, 0.02289806678891182, 0.017837131395936012, 0.0012219940545037389, -0.03753354027867317, -0.005368386395275593, -0.01155743096023798, -0.007676402572542429, 0.026556190103292465, -0.02812696248292923, -0.02340761013329029, -0.05321459472179413, -0.010725805535912514, -0.040844257920980453, 0.04004894196987152, -0.004415002651512623, -0.001893921522423625, -0.0007039358606562018, -0.009379057213664055, 0.020947782322764397, -0.006421167403459549, 0.003851377172395587, -0.03682197257876396, 0.007438952103257179, -0.01629054918885231, 0.05381906032562256, -0.010085515677928925, 0.019510265439748764, 0.039657119661569595, -0.015417763032019138, 0.00011846959387185052, -0.025144407525658607, -0.07517196238040924, -0.037819020450115204, -0.026641737669706345, 0.023876121267676353, -0.0375821627676487, 0.02780258283019066, 0.01658262312412262, -0.03856956958770752, -0.011564493179321289, -0.005405375733971596, 0.04636891186237335, 0.07369620352983475, 0.01719070039689541, -0.020808301866054535, 0.007725174073129892, 0.03379892557859421, -0.03512590005993843, -0.010746408253908157, -0.013739078305661678, 0.0075593991205096245, 0.028039122000336647, -0.010905378498136997, -0.023694010451436043, -0.05738122761249542, 0.008078711107373238, -0.01335429772734642, -0.029663823544979095, -0.02722492441534996, 0.029371419921517372, -0.011694980785250664, -0.03376706317067146, 0.012215469032526016, -0.007796574383974075, -0.0042601460590958595, -0.025487199425697327, -0.0023293253034353256, 0.03359502553939819, -0.00017542162095196545, 0.05483628809452057, -0.011248018592596054, -0.02003553882241249, -0.08398619294166565, 0.007288848515599966, 0.01716957613825798, 0.008135045878589153, 0.01760857179760933, 0.029074614867568016, 0.029806194826960564, 0.008459346368908882, -0.01773613877594471, 0.02887417934834957, 0.022794386371970177, -0.016578784212470055, 0.03875909745693207, -0.015181027352809906, 0.00410301610827446, -0.02199520543217659, -0.01619076356291771, -0.0015336066717281938, 0.0036209130194038153, -0.04031176492571831, 0.011436913162469864, 0.005134813487529755, -0.042216602712869644, -0.03365639969706535, -0.010512816719710827, 0.012122583575546741, 0.001733519253320992, -0.04755576699972153, -0.02308042347431183, -0.03127899393439293, -0.013145353645086288, -0.020931478589773178, -0.06791392713785172, 0.000501922913827002, 0.01389413233846426, -0.044914115220308304, -0.014338318258523941, 0.002072825562208891, 0.020662451162934303, 0.05610659345984459, 0.032390791922807693, -0.02127150446176529, -0.02359176054596901, 0.05037982761859894, 0.04318337142467499, -0.05181584134697914, -0.008616253733634949, 0.028696084395051003, 0.03676307573914528, 0.001236935961060226, 0.05872821807861328, -0.004605152178555727, 0.02425442263484001, 0.0037581471260637045, 0.016629694029688835, -0.023878952488303185, -0.03401491418480873, 0.039187587797641754, 0.030392996966838837, 0.04899148270487785, 0.02139032818377018, -0.010930636897683144, -0.0051749395206570625, 0.012483743950724602, -0.0002911065530497581, -0.0107194809243083, 0.060080159455537796, 0.015174804255366325, -0.0129742082208395, 0.023767082020640373, 0.014491977170109749, -0.013103039935231209, -0.03190579637885094, 0.02934914641082287, 0.005279379431158304, 0.014066183939576149, 0.025478381663560867, -0.01123335026204586, -0.00945526733994484, 0.032345712184906006, 0.005673059727996588, -0.04188501462340355, 0.01499005313962698, 0.021483048796653748, -0.041682496666908264, 0.026713473722338676, -0.01610102318227291, -0.04617105424404144, -0.013538490980863571, -0.005816117860376835, 0.022064680233597755, -0.008791100233793259, -0.036652348935604095, 0.0445382297039032, -0.04531092941761017, 0.0660017728805542, 0.04322981834411621, 0.04589298367500305, 0.003150980221107602, 0.03423334285616875, 0.004962143488228321, 0.037594474852085114, -0.0009668422280810773, -0.00821203924715519, -0.01670493185520172, 0.03854299709200859, 0.058894507586956024, -0.009807034395635128, 0.06185441464185715, -0.013554220087826252, -0.028446272015571594, -0.002074006712064147, -0.04706581309437752, -0.00723265903070569, -0.01716851070523262, -0.006969123613089323, 0.03593671694397926, -0.010234232991933823, 0.0387585312128067, -0.03567873686552048, 0.037182651460170746, 0.002106772270053625, 0.04072529822587967, -0.0178633164614439, 0.0004491117724683136, -0.01873093470931053, 0.03550593927502632, 0.06048555299639702, 0.0467817522585392, -0.01245142612606287, 0.006345927715301514, 0.044986434280872345, 0.005672750994563103, 0.04217507690191269, 0.042823728173971176, -0.00044272231752984226, 0.0021837942767888308, -0.020171476528048515, 0.011457937769591808, 0.02746368572115898, 0.029338162392377853, 0.0017484963173046708, 0.014444091357290745, -0.00155673548579216, -0.027338510379195213, -0.03078649751842022, -0.007673171814531088, -0.005484797991812229, -0.012307519093155861, -0.02824546955525875, -0.00922546535730362, 0.01801653765141964, 0.005883377511054277, -0.03104451484978199, -0.018272731453180313, -0.008193803951144218, 0.0107416408136487, 0.04609086364507675, -0.02990531548857689, -0.004225708544254303, -0.04422237351536751, -0.0020640918519347906, 0.015490880236029625, -0.020273476839065552, 0.0076664206571877, -0.010465691797435284, 0.025664247572422028, 0.023190360516309738, -0.03548024222254753, 0.07253656536340714, -0.0037589888088405132, -0.018506653606891632, -0.012082424014806747, 0.03685552626848221, -0.019275764003396034, 0.00351383863016963, -0.017230359837412834, -0.032741326838731766, -0.03268008306622505, -0.01825784146785736, 0.022188249975442886, 0.017617085948586464, -0.005047657061368227, -0.02194487676024437, -0.021505670621991158, 0.011229553259909153, -0.04545561596751213, -0.007458292879164219, -0.045153502374887466, -0.003814661642536521, 0.0010863210773095489, -0.0565112866461277, -0.008950738236308098, 0.008092796429991722, -0.03133951127529144, 0.01507561095058918, 0.030404554679989815, 0.005149646662175655, -0.032983407378196716, -0.013316422700881958, 0.021631063893437386, -0.005120342597365379, -0.005351101979613304, 0.04171072691679001, 0.014501020312309265, 0.02161335200071335, 0.005097371060401201, 0.04330778867006302, 0.013917122967541218, 0.026463881134986877, -0.06742212176322937, -0.058481257408857346, -0.012978160753846169, -0.01065168809145689, -0.013777774758636951, 0.00150164938531816, -0.04054148122668266, 0.04798460379242897, 0.019544284790754318, -0.035924460738897324, -0.04933974891901016, -0.024354135617613792, 0.034946974366903305, -0.02186044119298458, 0.05853838101029396, -0.0029541931580752134, 0.046322572976350784, -0.006464049685746431, -0.0021402817219495773, 0.01829361543059349, 0.03166600316762924, 0.01981336809694767, -0.00047429947881028056, -0.04029863327741623, 0.01910734921693802, -0.049192704260349274, -0.04343609884381294, 0.0007329504587687552, 0.01525227539241314, -0.005952372681349516, 0.003951351623982191, 0.04058017581701279, 0.013741737231612206, 0.005308793392032385, 0.0007798396400175989, -0.0045035467483103275, -0.03335345536470413, 0.029706189408898354, 0.034262798726558685, -0.03444040194153786, -0.011029237881302834, 0.049265529960393906, 0.00012760555546265095, 0.03430940955877304, 0.011063982732594013, 0.003411683486774564, 0.003924873657524586, -0.039385050535202026, -0.026550356298685074, -0.007488972041755915, -0.017000824213027954, -0.02476833388209343, 0.0028801748994737864, -0.008616660721600056, -0.06217547506093979, -0.021957969292998314, 0.04865271970629692, -0.00597229553386569, -0.01987457275390625, 0.013203789480030537, 0.023394085466861725, 0.046274926513433456, -0.004835712257772684, 0.03789987415075302, -0.00890763197094202, 0.016071230173110962, 0.019647875800728798, 0.0029997590463608503, -0.004958008881658316, 0.022504964843392372 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
Traditional Beam Search Here's how we would do text translation in the traditional beam search setting. !pip install -q git+https://github.com/huggingface/transformers.git python from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("t5-base") model = AutoModelForSeq2SeqLM.from_pretrained("t5-base") encoder_input_str = "translate English to German: How old are you?" input_ids = tokenizer(encoder_input_str, return_tensors="pt").input_ids outputs = model.generate( input_ids, num_beams=10, num_return_sequences=1, no_repeat_ngram_size=1, remove_invalid_values=True, ) print("Output:\n" + 100 * '-') print(tokenizer.decode(outputs[0], skip_special_tokens=True)) Output: ---------------------------------------------------------------------------------------------------- Wie alt bist du?
[ -0.02497042343020439, 0.002071554306894541, 0.025440296158194542, -0.04474164545536041, -0.02625410072505474, 0.06502719968557358, 0.0672837421298027, 0.053022854030132294, -0.010978445410728455, 0.0251119676977396, -0.12090438604354858, 0.011492437683045864, 0.01818077266216278, 0.07771291583776474, -0.002486646641045809, -0.0034008417278528214, 0.0360998660326004, -0.03299181908369064, 0.03438611328601837, 0.04083571955561638, 0.07010995596647263, 0.003400681773200631, 0.09695544093847275, -0.010847977362573147, 0.014547258615493774, -0.05228284001350403, 0.03130567818880081, 0.0356949083507061, -0.049863237887620926, 0.019403627142310143, -0.07288400828838348, -0.007173133082687855, -0.015118785202503204, -0.04855566471815109, -0.04338044300675392, 0.07691282033920288, -0.12883663177490234, 0.03788922354578972, -0.001364792580716312, -0.04281017184257507, -0.09536010771989822, 0.012439738027751446, 0.01056687068194151, 0.05746329575777054, -0.012170711532235146, 0.019380884245038033, -0.15811656415462494, 0.05694710835814476, -0.04181194677948952, -0.005767750553786755, -0.05058819800615311, 0.03281310573220253, -0.012866168282926083, -0.020545106381177902, 0.029203439131379128, 0.047467753291130066, -0.046200815588235855, -0.0741080567240715, 0.018580492585897446, 0.035567108541727066, -0.019712621346116066, 0.02840322256088257, -0.003872953588142991, 0.044195953756570816, 0.045367591083049774, 0.01713050715625286, -0.052806511521339417, 0.020786365494132042, -0.0708065927028656, 0.03040783666074276, -0.02155769057571888, -0.024373918771743774, -0.0288552176207304, -0.05765324458479881, -0.00025282675051130354, -0.07352662831544876, -0.07328860461711884, 0.052008628845214844, 0.015279173851013184, 0.059960659593343735, 0.022456640377640724, 0.0466926172375679, 0.0389738455414772, 0.025372620671987534, 0.07362068444490433, 0.09763544797897339, 0.017201971262693405, -0.033900510519742966, -0.03906997665762901, 0.04246625676751137, -0.0031288540922105312, -0.17110960185527802, -0.02106509543955326, 0.02044169418513775, 0.05684977397322655, -0.005514913238584995, 0.04042169079184532, 0.027942070737481117, -0.03742640092968941, 0.042492400854825974, 0.020333051681518555, -0.06899247318506241, 0.0676422193646431, 0.010411594994366169, -0.024854222312569618, -0.0436786524951458, 0.007924042642116547, -0.07971920818090439, 0.02788441814482212, -0.022387824952602386, 0.034642137587070465, -0.018987808376550674, 0.030978767201304436, 0.07535281032323837, -0.049867335706949234, 0.0352194644510746, 0.04070104658603668, -0.01512975338846445, -0.020378930494189262, 0.06393527239561081, 0.017009519040584564, 0.0688411071896553, 0.04309035465121269, -0.013176876120269299, 0.023013554513454437, 0.02891087904572487, -0.020163644105196, 0.009470629505813122, 0.018664546310901642, -0.003733375808224082, 0.05857333540916443, -0.034906089305877686, 0.07865088433027267, -0.010692639276385307, 0.0027217280585318804, -0.03692366182804108, 0.058514248579740524, -0.06682109832763672, -0.021085862070322037, -0.028415217995643616, 0.012627797201275826, -0.008874927647411823, -0.025694580748677254, 0.03457719460129738, -0.005994740407913923, -0.0026415742468088865, -0.0812801718711853, 0.01777006685733795, -0.023901114240288734, 0.0320887565612793, -0.09403805434703827, 0.04187469556927681, 0.02073107659816742, -0.04106126353144646, -0.009804234839975834, 0.06398966908454895, -0.00008147110202116892, -0.03457370400428772, -0.03473323956131935, 0.031088361516594887, -0.06920251995325089, 0.02500724419951439, -0.0238338615745306, -0.03510225936770439, -0.014275021851062775, -0.027671881020069122, 0.0034220898523926735, 0.052798837423324585, -0.003761792089790106, 0.05380617454648018, 0.0626484602689743, 0.025940898805856705, 0.08533668518066406, -0.04546843469142914, 0.022954585030674934, 0.01744607836008072, 0.013333787210285664, 0.016502011567354202, -0.07176601141691208, -0.07984968274831772, -0.00001271587643714156, 0.033246636390686035, -0.003460665699094534, 0.06930267810821533, -0.02136838622391224, -0.09905766695737839, 0.02085096575319767, 0.00402434216812253, 0.02569212019443512, -0.016503548249602318, -0.0319317951798439, -0.08065836131572723, 0.014226740226149559, -0.025202909484505653, 0.010890714824199677, -0.07514720410108566, 0.03605061396956444, 0.11101404577493668, 0.03840777650475502, 0.08380590379238129, 0.055934350937604904, -0.02973903715610504, -0.00797432940453291, -0.019853588193655014, 0.02563413791358471, 0.029702378436923027, 0.017604593187570572, -0.07817403227090836, 0.013571096584200859, 0.00983780063688755, 0.023620715364813805, -0.09413979947566986, 0.0338248535990715, -0.08147498965263367, -0.0240717064589262, -0.039788175374269485, -0.08237367123365402, 0.0051189204677939415, -0.009899210184812546, 0.028959132730960846, 0.16504468023777008, -0.059598781168460846, -0.018837392330169678, -0.02486296370625496, -0.006525084376335144, 0.04572047293186188, 0.08273115009069443, 0.060548242181539536, 0.00918971374630928, -0.017435038462281227, 0.0007845627842471004, -0.052625514566898346, 0.021100370213389397, 0.034891463816165924, -0.009595567360520363, -0.06322439759969711, 0.0043362840078771114, -0.04056098684668541, 0.014058959670364857, 0.05618526041507721, -0.01244652271270752, -0.02961750328540802, -0.023478105664253235, -0.006424301769584417, 0.021717451512813568, 0.016816386952996254, 0.05656781047582626, -0.0003183992812409997, -0.005094220396131277, -0.023068612441420555, -0.007170230150222778, 0.025238176807761192, -0.01789247989654541, -0.058123115450143814, 0.04411471262574196, 0.05028596147894859, -0.006721280049532652, 0.008339831605553627, -0.03298178315162659, 0.05160592496395111, 0.015442997217178345, 0.021319448947906494, -0.010936658829450607, -0.08394277095794678, -0.025381388142704964, -0.020282192155718803, -0.022740647196769714, 0.021388351917266846, -0.029957352206110954, 0.0037606745027005672, -0.005720676388591528, -0.010578705929219723, 0.026425817981362343, 0.007779934909194708, 0.016803883016109467, 0.007774860132485628, 0.019575368613004684, -0.015098738484084606, -0.03802146762609482, -0.007907017134130001, -0.022192563861608505, -0.015993915498256683, 0.04710903391242027, 0.04476805776357651, -0.01996428333222866, -0.007497444283217192, -0.013078741729259491, -0.02337018772959709, -0.014091229066252708, 0.016060370951890945, 0.04545280337333679, -0.005023445002734661, 0.03310029208660126, -0.02660851553082466, 0.015234951861202717, 0.02645363099873066, -0.006767958402633667, 0.001331669045612216, 0.021688848733901978, 0.026930855587124825, -0.03603023663163185, 0.005973075050860643, 0.010776340961456299, 0.015387998893857002, -0.03743874654173851, 0.03573835268616676, 0.012218816205859184, 0.01037390623241663, -0.08758026361465454, -0.028976235538721085, -0.04905889183282852, 0.005575887393206358, -0.003994652070105076, 0.012727703899145126, -0.01714458130300045, 0.027591371908783913, -0.02664731629192829, -0.003699010005220771, 0.024427659809589386, 0.02465720660984516, 0.05985420569777489, 0.029735207557678223, -0.029675092548131943, 0.008685044012963772, -0.0335892029106617, 0.025593804195523262, 0.02230234257876873, 0.021735550835728645, -0.014019150286912918, 0.014366836287081242, -0.0055948104709386826, 0.010643144138157368, -0.004714976064860821, -0.0529278963804245, 0.025007709860801697, -0.02380501478910446, 0.008119507692754269, -0.0096974428743124, 0.0381719172000885, -0.02558513917028904, -0.021145517006516457, -0.018374348059296608, -0.031258948147296906, 0.01270368043333292, 0.029964953660964966, 0.03435014560818672, 0.021282639354467392, 0.0390569344162941, 0.009464794769883156, -0.007931167259812355, 0.01578277163207531, -0.03878258541226387, -0.0031338417902588844, -0.03182442858815193, -0.02467093989253044, 0.014214848168194294, 0.004746281076222658, -0.05004030466079712, -0.021134983748197556, -0.013509177602827549, 0.0020478556398302317, 0.041946522891521454, 0.039534106850624084, -0.02192683145403862, 0.00408400921151042, 0.020641038194298744, 0.03153104707598686, 0.04122981056571007, -0.06022501736879349, 0.015902161598205566, -0.0155437421053648, -0.022831356152892113, -0.02800433523952961, 0.07586938142776489, -0.005934031214565039, 0.009473105892539024, 0.008641611784696579, 0.017890654504299164, -0.007698329631239176, 0.036353252828121185, 0.01599229872226715, 0.012039483524858952, -0.021904926747083664, -0.0008809335995465517, -0.025881676003336906, -0.06278609484434128, 0.02994084358215332, 0.04684267193078995, -0.04807208850979805, -0.04046585410833359, -0.048964206129312515, 0.01207676250487566, 0.033601369708776474, -0.015465674921870232, 0.007389577571302652, -0.04908636584877968, 0.019750703126192093, -0.019191104918718338, -0.0025555358733981848, -0.06867849081754684, -0.008591028861701488, -0.05960967391729355, -0.02946646511554718, -0.010869784280657768, 0.002630643080919981, -0.016604188829660416, -0.007258540019392967, 0.004545450210571289, 0.03615447133779526, -0.06706804782152176, -0.004935975186526775, 0.005671169143170118, 0.03938070684671402, 0.0177407618612051, -0.05998716130852699, -0.022580275312066078, 0.002946453168988228, 0.03864121064543724, 0.00605756277218461, -0.002230241661891341, -0.028376052156090736, 0.002410403685644269, 0.03154973313212395, 0.04883190244436264, -0.0020100523252040148, -0.055831052362918854, -0.03262212127447128, -0.0001045037861331366, -0.05351201072335243, 0.0010157848009839654, -0.020302506163716316, 0.0062362877652049065, 0.005127378273755312, 0.01471349410712719, 0.038497745990753174, 0.021764500066637993, -0.022236082702875137, -0.061902280896902084, -0.01325594075024128, -0.002158289309591055, 0.050281960517168045, 0.01039867289364338, 0.0165448896586895, 0.01862618699669838, 0.014193380251526833, -0.02230418473482132, -0.022512493655085564, -0.02988838218152523, -0.04131968691945076, -0.01125896442681551, 0.006854264996945858, -0.0442577563226223, 0.038850825279951096, 0.002819986781105399, -0.03912102431058884, -0.01522644143551588, -0.01920950599014759, 0.02376602776348591, 0.0590318888425827, 0.01258001383394003, -0.007607306819409132, 0.028133150190114975, 0.06593046337366104, -0.01949346624314785, 0.009044693782925606, 0.034907855093479156, 0.014586024917662144, 0.021089952439069748, 0.0005994404782541096, -0.012518517673015594, -0.028914675116539, -0.011099008843302727, 0.02230803482234478, -0.00551484152674675, 0.0023278165608644485, -0.012305584736168385, -0.002792478073388338, -0.02274971269071102, 0.0030801722314208746, 0.0241978969424963, 0.011290338821709156, -0.020602218806743622, -0.03252255544066429, 0.048760902136564255, 0.015831200405955315, 0.021474435925483704, -0.016367534175515175, 0.00617016339674592, -0.011773267760872841, 0.004156975541263819, 0.015747305005788803, 0.04078537970781326, -0.0007330922526307404, 0.03276554495096207, 0.022570716217160225, 0.0368640199303627, -0.012131833471357822, -0.01412054430693388, 0.008411250077188015, 0.003646053606644273, 0.03648776933550835, -0.019335201010107994, 0.03885624185204506, -0.05969629064202309, 0.0009057980496436357, -0.008120202459394932, -0.047918710857629776, 0.0003415685205254704, 0.046699583530426025, 0.0439378060400486, -0.029386373236775398, -0.02057311311364174, 0.02199483849108219, -0.000860724423546344, -0.02324642986059189, -0.030447836965322495, -0.03156121447682381, -0.023411959409713745, 0.00000915052805794403, 0.004763362463563681, -0.018661487847566605, 0.007386431097984314, 0.02497321367263794, -0.02296733669936657, 0.021319104358553886, 0.01877870224416256, 0.030526053160429, 0.05201991647481918, 0.030974403023719788, -0.03747199848294258, -0.025290394201874733, 0.02810933068394661, 0.05273221805691719, -0.03428240865468979, 0.03112415038049221, 0.04899470880627632, -0.016223574057221413, 0.01203867793083191, 0.029385697096586227, -0.030107179656624794, -0.004544154740869999, 0.00785075780004263, 0.030185259878635406, -0.051472634077072144, -0.01754671148955822, -0.008410194888710976, 0.06189572811126709, -0.015604549087584019, 0.05776064097881317, -0.028922831639647484, -0.02299276739358902, 0.023318365216255188, -0.007457672618329525, 0.007598440628498793, 0.05747493728995323, 0.02629336342215538, 0.0005069446633569896, 0.01528117898851633, 0.015643810853362083, -0.001310714753344655, -0.005272237118333578, 0.0327550433576107, 0.01189833041280508, 0.01744745299220085, 0.014233420602977276, 0.017568843439221382, -0.01914427988231182, 0.0068868366070091724, 0.018076103180646896, -0.0667341873049736, 0.009835785254836082, 0.020009072497487068, -0.009008619002997875, 0.009166411124169827, -0.011413749307394028, -0.06481534987688065, -0.06334107369184494, 0.012681192718446255, 0.016970040276646614, 0.021427076309919357, -0.0286088977009058, 0.02284139022231102, -0.010879372246563435, 0.010272139683365822, 0.034947991371154785, 0.05843905732035637, -0.019364314153790474, 0.07757410407066345, 0.028054798021912575, 0.03519386425614357, -0.0006310570752248168, 0.005089414771646261, -0.01128648966550827, -0.008478919044137001, 0.07787153869867325, 0.02271897904574871, 0.05311007425189018, 0.023958584293723106, 0.0074470313265919685, -0.03158053383231163, -0.012759285047650337, -0.003033515065908432, -0.030185246840119362, 0.00863848440349102, 0.04468121752142906, 0.0050105140544474125, 0.024474473670125008, 0.012490309774875641, 0.04806479066610336, 0.03769351541996002, 0.06118287518620491, -0.025015225633978844, 0.004269566852599382, 0.024478545412421227, 0.051363710314035416, 0.05853954330086708, 0.06750698387622833, 0.00884266011416912, 0.04502808302640915, 0.03963608294725418, 0.005486635025590658, 0.015929562970995903, -0.010500526987016201, 0.027506288141012192, 0.02101784572005272, -0.0009166864329017699, -0.03332698345184326, 0.04896344617009163, 0.033131182193756104, 0.00994967296719551, -0.03144339844584465, 0.028747854754328728, -0.02337961457669735, -0.006106722634285688, 0.0007401591283269227, -0.009343146346509457, -0.013734321109950542, -0.024243241176009178, -0.043526336550712585, 0.026988090947270393, 0.015063425526022911, -0.033522218465805054, -0.0005257966695353389, 0.006403642240911722, 0.04137173295021057, 0.017733361572027206, -0.013585641048848629, -0.016345925629138947, -0.050633903592824936, -0.031911496073007584, -0.033026695251464844, -0.057403504848480225, 0.01766037940979004, 0.006411183159798384, -0.007707921322435141, 0.018552063032984734, 0.027649497613310814, 0.0009754277998581529, 0.0008340248023159802, 0.009624499827623367, -0.030564621090888977, -0.004443910904228687, -0.013890551403164864, -0.015592007897794247, 0.011236070655286312, -0.057264357805252075, 0.0065413909032940865, -0.014696069061756134, -0.003551040543243289, 0.015731217339634895, 0.025708576664328575, -0.0001389828830724582, -0.060104940086603165, 0.029987841844558716, -0.052185215055942535, -0.023068157956004143, 0.024052444845438004, -0.0013198264641687274, 0.01074390672147274, -0.00233601126819849, -0.02528195083141327, -0.0019322437001392245, -0.005512608680874109, 0.016543997451663017, 0.06010952219367027, -0.01617157831788063, -0.04017062857747078, -0.03379366919398308, 0.030597859993577003, 0.009793596342206001, -0.020910440012812614, 0.03623386099934578, -0.023175545036792755, 0.01958160474896431, 0.0012077782303094864, 0.04715437814593315, -0.07524062693119049, 0.02280353009700775, -0.06264425069093704, -0.06752511858940125, 0.0011260941391810775, -0.026382971554994583, -0.009545954875648022, 0.0026463561225682497, -0.03870668262243271, 0.04633522778749466, -0.005248324945569038, -0.012620771303772926, -0.024871516972780228, 0.0044401572085917, 0.04002499207854271, 0.004208158235996962, 0.027722232043743134, 0.02406989224255085, 0.01768033392727375, -0.0026464301627129316, -0.03506355360150337, -0.006876773666590452, 0.04752455651760101, 0.021053778007626534, -0.025006433948874474, -0.007264379411935806, 0.04539719223976135, -0.005467494484037161, -0.03762037307024002, 0.03558099642395973, -0.002953631803393364, -0.030406169593334198, -0.030884163454174995, 0.0173644982278347, -0.012757538817822933, -0.030735662207007408, 0.026377251371741295, 0.0062609766609966755, -0.02836115099489689, 0.023846564814448357, 0.007046934682875872, -0.06502032279968262, -0.020198553800582886, 0.0023641185835003853, -0.010945922695100307, 0.0047981832176446915, 0.009551728144288063, 0.029428083449602127, -0.0024242564104497433, -0.027497509494423866, -0.014666897244751453, -0.025336194783449173, 0.006731333676725626, -0.04341202229261398, -0.0031907344236969948, 0.013377516530454159, -0.022027522325515747, -0.0117767583578825, 0.05147671699523926, -0.032989226281642914, -0.037751324474811554, 0.0018834471702575684, 0.013524024747312069, -0.027927489951252937, -0.007707514800131321, -0.004068914335221052, 0.007760774809867144, 0.009701941162347794, 0.016068650409579277, 0.0037823552265763283, -0.026966361328959465, 0.008102073334157467 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
Why It's Difficult However, this is actually a very non-trivial problem. This is because the task requires us to force the generation of certain subsequences somewhere in the final output, at some point during the generation. Let's say that we're want to generate a sentence S that has to include the phrase \( p_1={ t_1, t_2 } \) with tokens \( t_1, t_2 \) in order. Let's define the expected sentence \( S \) as: $$ S_{expected} = { s_1, s_2, ..., s_k, t_1, t_2, s_{k+1}, ..., s_n } $$ The problem is that beam search generates the sequence token-by-token. Though not entirely accurate, one can think of beam search as the function \( B(\mathbf{s}{0:i}) = s{i+1} \), where it looks at the currently generated sequence of tokens from \( 0 \) to \( i \) then predicts the next token at \( i+1 \) . But how can this function know, at an arbitrary step \( i < k \) , that the tokens must be generated at some future step \( k \) ? Or when it's at the step \( i=k \) , how can it know for sure that this is the best spot to force the tokens, instead of some future step \( i>k \) ? And what if you have multiple constraints with varying requirements? What if you want to force the phrase \( p_1={t_1, t_2} \) and also the phrase \( p_2={ t_3, t_4, t_5, t_6} \) ? What if you want the model to choose between the two phrases? What if we want to force the phrase \( p_1 \) and force just one phrase among the list of phrases \( {p_{21}, p_{22}, p_{23}} \) ? The above examples are actually very reasonable use-cases, as it will be shown below, and the new constrained beam search feature allows for all of them! This post will quickly go over what the new constrained beam search feature can do for you and then go into deeper details about how it works under the hood.
[ 0.029061999171972275, -0.02266348898410797, 0.062237076461315155, -0.014629924669861794, 0.017207549884915352, 0.032132990658283234, 0.021581558510661125, -0.008369839750230312, -0.057933058589696884, -0.03383396565914154, -0.056582339107990265, -0.04170362651348114, -0.008130759000778198, 0.05835111066699028, -0.04330562800168991, 0.00774760264903307, 0.0642891675233841, -0.04891888052225113, 0.0053347013890743256, -0.052301231771707535, 0.03693513199687004, 0.04704723879694939, 0.11398343741893768, -0.02707321010529995, 0.04877994954586029, -0.023224789649248123, -0.008740440011024475, -0.011956382542848587, -0.01245846413075924, 0.013169780373573303, -0.05838878080248833, -0.05790700390934944, 0.024224478751420975, -0.03344427049160004, 0.01978272572159767, 0.003576289163902402, -0.11057903617620468, -0.0002856212086044252, 0.08358905464410782, -0.01636187732219696, -0.05575387552380562, -0.0074320267885923386, 0.015959300100803375, 0.0009059010772034526, -0.0210142619907856, -0.01403023675084114, -0.1189613789319992, 0.09070278704166412, -0.08262186497449875, -0.06623632460832596, -0.06538289785385132, 0.01716393046081066, -0.034936822950839996, 0.01392454095184803, 0.010999270714819431, -0.02065935544669628, -0.028697490692138672, -0.1048378273844719, 0.019684307277202606, 0.04424135014414787, 0.0009114195127040148, 0.011025425978004932, 0.06130995973944664, 0.050011344254016876, 0.07872669398784637, -0.0066436841152608395, -0.005220185965299606, -0.00008104132575681433, -0.1251046359539032, -0.00028515400481410325, 0.0378250777721405, -0.00957742240279913, 0.009605861268937588, -0.005903709679841995, 0.06152242794632912, -0.03666459769010544, -0.07649143040180206, 0.05218346044421196, -0.04867491498589516, 0.04362015798687935, 0.009696430526673794, 0.03342168778181076, 0.06143462285399437, 0.07689950615167618, -0.004964192397892475, 0.04873845353722572, 0.06254491955041885, -0.04948566481471062, -0.04391278326511383, 0.05691468343138695, -0.02560606598854065, -0.1011236235499382, -0.06787124276161194, 0.06816975772380829, 0.005387681070715189, -0.04541953653097153, 0.03583931922912598, 0.03517453745007515, -0.02541765756905079, 0.020050613209605217, 0.028939468786120415, -0.026543235406279564, 0.05061288923025131, -0.017705751582980156, -0.07139720767736435, 0.05436113476753235, -0.02068822830915451, -0.04270678386092186, -0.07110616564750671, -0.001366080017760396, 0.03160620108246803, -0.015102788805961609, 0.03905365616083145, 0.07493828237056732, -0.013904931023716927, 0.021611288189888, 0.03720363602042198, 0.024501776322722435, -0.05461718142032623, -0.030407598242163658, -0.015278642065823078, 0.046224724501371384, 0.1226859837770462, 0.007619576994329691, -0.006835234817117453, 0.040805209428071976, 0.009816380217671394, -0.019700461998581886, -0.03378906100988388, -0.028591159731149673, -0.05526278167963028, 0.00662569422274828, 0.007821095176041126, 0.009126264601945877, 0.06441688537597656, 0.020390823483467102, 0.01462836004793644, -0.08078400790691376, 0.004662610124796629, 0.02578783594071865, -0.01042093150317669, -0.0198444202542305, 0.010323572903871536, 0.00956599973142147, 0.04199054837226868, -0.017214179039001465, -0.01056652795523405, 0.03043721430003643, -0.07713736593723297, 0.07787644118070602, -0.00544701749458909, -0.0012953922851011157, -0.01330149918794632, -0.08609987050294876, -0.05954442918300629, 0.04190682992339134, -0.04840203374624252, 0.0369565524160862, -0.06413456797599792, -0.006277871783822775, 0.02796320803463459, -0.007084514480084181, -0.037507787346839905, 0.010861415416002274, 0.05234066769480705, -0.03767247870564461, 0.03791023790836334, 0.04664161801338196, -0.020120559260249138, 0.07205633074045181, 0.05298706144094467, 0.03623366355895996, 0.03532835468649864, -0.049218010157346725, 0.05167808383703232, 0.027378525584936142, -0.013428530655801296, 0.04553818330168724, -0.012442629784345627, -0.017728205770254135, -0.024431755766272545, -0.031829945743083954, 0.010851067490875721, 0.021262934431433678, 0.01305066142231226, -0.09360621124505997, 0.016644177958369255, 0.012855992652475834, -0.009491425938904285, -0.008173300884664059, -0.025919808074831963, -0.04884398356080055, 0.07462934404611588, -0.06719954311847687, -0.03335587680339813, -0.08217810839414597, -0.023355824872851372, 0.0712219625711441, 0.055051062256097794, 0.09365542232990265, 0.028226682916283607, 0.05205545574426651, 0.024601923301815987, -0.05577715113759041, 0.017612524330615997, 0.01496630348265171, -0.060725320130586624, -0.08044811338186264, 0.0156711433082819, 0.020955661311745644, -0.005132711958140135, -0.04524139314889908, -0.012949354946613312, -0.15674196183681488, -0.09137488901615143, 0.015088308602571487, -0.0010527994018048048, 0.0038739372976124287, -0.016097448766231537, 0.022290805354714394, 0.1546950489282608, 0.0035735326819121838, -0.05074383690953255, -0.04101631045341492, -0.026402100920677185, 0.046184781938791275, 0.0016103846719488502, -0.009300077334046364, 0.025216128677129745, -0.03544900566339493, -0.004190309904515743, -0.027628572657704353, 0.08025435358285904, 0.020075568929314613, -0.02278911881148815, 0.016986887902021408, -0.02938922494649887, 0.05185766518115997, 0.02963089570403099, -0.04052316024899483, 0.01237169187515974, -0.007390196435153484, -0.0522451177239418, 0.07888410985469818, -0.00047552320756949484, -0.014749077148735523, 0.07702811807394028, -0.021836046129465103, -0.031550001353025436, -0.040698323398828506, -0.03174138814210892, 0.02689739316701889, -0.058028481900691986, -0.0515582337975502, -0.005297299008816481, 0.07998768240213394, 0.018672669306397438, -0.011311878450214863, -0.02120136097073555, 0.016093945130705833, -0.02895471639931202, 0.019352704286575317, 0.026913650333881378, -0.035936370491981506, -0.012226841412484646, 0.003799468046054244, 0.04276302829384804, -0.01611054688692093, -0.030128631740808487, 0.0034697328228503466, -0.01908233016729355, -0.0033570697996765375, 0.010571395978331566, 0.018487462773919106, 0.00009301878162659705, 0.019810261204838753, 0.02321646176278591, -0.033248670399188995, -0.05258888378739357, 0.008753007277846336, -0.008634177967905998, 0.009983949363231659, 0.056670136749744415, 0.03984532505273819, 0.03546537086367607, 0.03345967456698418, 0.033825378865003586, 0.013354366645216942, 0.002640628023073077, -0.014251694083213806, -0.01293958816677332, 0.0418986938893795, 0.026301003992557526, 0.017200235277414322, 0.008938036859035492, 0.012462520971894264, 0.0031611693557351828, -0.0026484010741114616, -0.02562617138028145, 0.010349941439926624, 0.016548946499824524, 0.030727669596672058, -0.02869536355137825, -0.022951237857341766, -0.01738843508064747, 0.04069339111447334, 0.018815256655216217, 0.057910580188035965, -0.08697815239429474, -0.011068202555179596, 0.02048647031188011, 0.024300632998347282, -0.001284450409002602, -0.022572381421923637, 0.021655641496181488, 0.01987902633845806, -0.006163499318063259, -0.02102082595229149, -0.00509703578427434, -0.024635447189211845, 0.01329735852777958, 0.01607295125722885, -0.012449539266526699, -0.015333648771047592, -0.02313445322215557, -0.012601378373801708, 0.03380391374230385, 0.028390759602189064, 0.021271666511893272, 0.015735192224383354, -0.005810930393636227, -0.024977149441838264, -0.012093686498701572, -0.02203107625246048, 0.018816983327269554, 0.030163995921611786, 0.04377947002649307, -0.02851145900785923, -0.026277631521224976, 0.038641225546598434, 0.0048695337027311325, -0.038139909505844116, -0.07527144253253937, -0.03523174300789833, 0.01944573223590851, 0.02346920780837536, 0.0021951873786747456, 0.014878333546221256, 0.018801217898726463, -0.010960864834487438, -0.007763346191495657, -0.021893933415412903, -0.0021461283322423697, -0.01392664946615696, -0.023405790328979492, 0.0027452532667666674, 0.015349638648331165, -0.08538278937339783, -0.01689140871167183, 0.006242508068680763, 0.011467406526207924, 0.0344160720705986, 0.0072534107603132725, 0.010299974121153355, 0.020011113956570625, 0.002523822942748666, 0.010922304354608059, 0.0033461221028119326, -0.03415476530790329, -0.05576939880847931, 0.03259056806564331, 0.0029469942674040794, 0.03375539556145668, 0.07212560623884201, 0.038117144256830215, 0.039212632924318314, -0.00551176629960537, 0.029107004404067993, 0.001144396374002099, 0.02089512161910534, 0.012952418997883797, 0.006889467127621174, -0.00047172338236123323, 0.005489603150635958, -0.018683454021811485, -0.07663729786872864, 0.041694868355989456, 0.030349669978022575, -0.008402349427342415, -0.0009795184014365077, -0.06373663246631622, 0.016896724700927734, 0.041222408413887024, -0.017668239772319794, -0.010912236757576466, -0.01844937726855278, -0.03918507322669029, -0.007739783730357885, -0.012525473721325397, -0.01299442257732153, -0.027565866708755493, -0.0067319064401090145, -0.021381800994277, 0.01986744813621044, 0.0033922723960131407, 0.01101207360625267, 0.05426691472530365, -0.004990666639059782, 0.012067096307873726, -0.036424532532691956, 0.035346869379282, -0.005527241621166468, -0.016534455120563507, -0.0039542922750115395, -0.030047399923205376, -0.008902064524590969, 0.008642995730042458, 0.0064666178077459335, -0.018662104383111, -0.01914053224027157, -0.0046135615557432175, -0.018766654655337334, 0.033003535121679306, -0.0006379171973094344, -0.01922234706580639, -0.00749092735350132, -0.033643100410699844, -0.001687514246441424, -0.04367523267865181, -0.01133973989635706, 0.005472119431942701, -0.0016605454729869962, 0.0023877876810729504, -0.05144037306308746, 0.008771752938628197, 0.03210284933447838, 0.0020718351006507874, 0.016184169799089432, 0.00009228976705344394, -0.0006798682152293622, 0.03391377255320549, -0.01972878910601139, 0.027616512030363083, 0.03298208490014076, -0.02090095914900303, 0.02369774505496025, -0.03618369251489639, -0.07410366833209991, 0.005744255613535643, -0.009597881697118282, 0.023735057562589645, -0.001584018231369555, 0.04865787550806999, 0.030968621373176575, -0.025110704824328423, -0.007165752816945314, 0.01674877293407917, 0.041470810770988464, 0.07109171897172928, 0.03800659254193306, -0.051846083253622055, -0.021151946857571602, 0.03446078673005104, -0.054145101457834244, -0.002428025472909212, -0.005993205588310957, 0.04214535653591156, 0.014021255075931549, 0.017402958124876022, -0.03906741738319397, -0.037851158529520035, 0.03366250544786453, -0.017781918868422508, -0.0029328842647373676, -0.050918564200401306, -0.022191982716321945, -0.015423284843564034, -0.031921736896038055, 0.03317120671272278, -0.029311971738934517, 0.0023207799531519413, -0.01973124034702778, 0.02244761772453785, 0.03246825560927391, 0.0381525382399559, -0.005686192773282528, -0.06463401764631271, -0.01590820588171482, -0.05581902712583542, 0.0016311571234837174, 0.03534262999892235, 0.05623368173837662, 0.01886093243956566, 0.016807246953248978, 0.06116507202386856, 0.04794633761048317, 0.00534053472802043, 0.015231707133352757, 0.033708974719047546, -0.005190253257751465, 0.017729593440890312, -0.062147241085767746, -0.008655726909637451, 0.0009620134369470179, -0.03587387502193451, 0.019432516768574715, -0.0004004506627097726, -0.035175736993551254, 0.024475447833538055, -0.023144133388996124, 0.02058994583785534, -0.035962726920843124, 0.03949068486690521, 0.012322060763835907, -0.011378796771168709, -0.03642731159925461, 0.011810272932052612, -0.004191914573311806, 0.0008130293572321534, -0.021076995879411697, -0.02978670969605446, 0.00009831468196352944, 0.013255341909825802, 0.03755413740873337, 0.007467041257768869, -0.04678250104188919, 0.012464202009141445, 0.09148170799016953, -0.004522829782217741, -0.04453878477215767, -0.007132527884095907, 0.002719894517213106, 0.02992240898311138, 0.015835832804441452, -0.0031083663925528526, 0.03061051294207573, 0.032979827374219894, 0.036567993462085724, 0.04873368889093399, -0.023754294961690903, 0.018784286454319954, 0.005499043967574835, 0.01396210864186287, -0.017416981980204582, -0.01595970243215561, 0.04660164564847946, 0.021662482991814613, -0.005209885537624359, 0.03459366410970688, -0.0020821704529225826, -0.014996691606938839, 0.026481779292225838, -0.015212402679026127, 0.015537767671048641, 0.053083352744579315, 0.008777322247624397, -0.021505599841475487, 0.059490762650966644, 0.02713150531053543, -0.020733406767249107, -0.04088849574327469, 0.05176129937171936, -0.01141022052615881, 0.07336056232452393, 0.053191762417554855, -0.02069721557199955, -0.019474094733595848, 0.023867642506957054, 0.01672775112092495, -0.05585513263940811, 0.002013902412727475, 0.008856371976435184, -0.026087956503033638, 0.03809394687414169, -0.008323527872562408, -0.017781374976038933, 0.000004298765361454571, 0.012062804773449898, 0.03846736624836922, -0.03471449017524719, -0.06744363903999329, 0.05288475751876831, -0.000053632913477486, 0.03622540459036827, -0.0378400944173336, 0.040008287876844406, -0.00995013490319252, 0.03647332638502121, -0.010444758459925652, 0.02567989006638527, -0.04482455551624298, 0.026573235169053078, -0.004517749883234501, 0.030525175854563713, 0.020433517172932625, -0.012265859171748161, 0.01710263453423977, 0.010239239782094955, -0.017991505563259125, 0.009267889894545078, -0.018677381798624992, -0.003519546240568161, -0.04601527750492096, 0.000505576899740845, 0.024946967139840126, 0.005970558151602745, 0.019675975665450096, -0.027199484407901764, 0.05851544439792633, 0.0204110536724329, -0.008551552891731262, -0.0036343822721391916, -0.009910301305353642, 0.0026297494769096375, 0.026727057993412018, 0.01209678128361702, 0.06491971015930176, -0.013109167106449604, -0.03464540094137192, 0.07200902700424194, 0.00905934814363718, 0.037872977554798126, 0.030047526583075523, 0.010602186433970928, 0.03451754152774811, -0.006754770874977112, -0.03573780506849289, 0.052527934312820435, -0.0008423224790021777, -0.018531976267695427, -0.002785799326375127, -0.008457070216536522, -0.0414111465215683, 0.0034748383332043886, 0.0044277929700911045, 0.0006861945730634034, -0.032528188079595566, -0.012630765326321125, -0.02313927933573723, 0.0664956197142601, 0.019133616238832474, -0.021602818742394447, -0.015384242869913578, -0.0366177000105381, -0.0015675155445933342, 0.03639545291662216, -0.046993404626846313, -0.015942221507430077, -0.03384615108370781, 0.004492358770221472, -0.013529499992728233, 0.012210488319396973, -0.005365927703678608, 0.012966095469892025, 0.01881050318479538, 0.06472145766019821, -0.04794211685657501, 0.07406172156333923, 0.01997741125524044, 0.021065732464194298, -0.016934018582105637, -0.01876005344092846, 0.009178641252219677, 0.0004187801678199321, 0.04683328792452812, -0.03244396671652794, -0.015375950373709202, -0.0077047087252140045, 0.04801246523857117, 0.01787170208990574, -0.026265263557434082, -0.02770118974149227, -0.044461265206336975, -0.023187551647424698, -0.02454160898923874, 0.012067856267094612, -0.02203758992254734, 0.01782752387225628, 0.000886971945874393, -0.045156076550483704, -0.030887307599186897, -0.015589741058647633, -0.018228013068437576, -0.004273582715541124, 0.032472480088472366, -0.013629510067403316, -0.06438896805047989, -0.02989332750439644, 0.03245525434613228, -0.010610711760818958, 0.02584001049399376, 0.055369000881910324, -0.006465478800237179, 0.048256274312734604, 0.008259907364845276, 0.03284876048564911, -0.048282649368047714, 0.05680802837014198, -0.058157362043857574, -0.03140353783965111, -0.010528967715799809, 0.005078245420008898, -0.02070598676800728, -0.0027388238813728094, -0.04073189198970795, 0.026114553213119507, -0.0034111866261810064, -0.01751634292304516, -0.022649915888905525, -0.008479617536067963, 0.06276291608810425, -0.00709671201184392, 0.06006203591823578, 0.008473532274365425, -0.017817405983805656, 0.0024968795478343964, 0.025280185043811798, 0.024354759603738785, 0.018788186833262444, -0.010816625319421291, -0.004790856037288904, 0.019026074558496475, 0.018597548827528954, -0.06726492941379547, -0.059917792677879333, 0.029179593548178673, 0.006986105348914862, -0.06607465445995331, 0.015846125781536102, 0.017478808760643005, 0.010162701830267906, 0.016255410388112068, 0.00917936209589243, -0.007023040670901537, -0.018513886258006096, 0.00829368643462658, 0.02845142036676407, -0.012443347834050655, -0.014400877058506012, -0.02357245236635208, 0.025199666619300842, 0.056412920355796814, -0.0033947837073355913, -0.02013792097568512, 0.003148056799545884, -0.025613736361265182, 0.01074592862278223, 0.004879211541265249, -0.013887028209865093, -0.055337365716695786, 0.01249280758202076, 0.019459279254078865, -0.04521682858467102, 0.004385082051157951, 0.016053346917033195, 0.017395436763763428, -0.01869143731892109, 0.009378768503665924, 0.003258218988776207, 0.03969025984406471, -0.02762196585536003, 0.01762337237596512, 0.006060129962861538, 0.0017515459330752492, 0.039171263575553894, 0.04059077426791191, -0.03558553382754326, 0.0056204102002084255 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
Banks Before we talk about the next step, we need to think about the resulting undesirable behavior we can see in the above step. The problem with naively just forcing the desired phrase "is fast" in the output is that, most of the time, you'd end up with nonsensical outputs like "The is fast" above. This is actually what makes this a nontrivial problem to solve. A deeper discussion about the complexities of solving this problem can be found in the original feature request issue that was raised in huggingface/transformers. Banks solve this problem by creating a balance between fulfilling the constraints and creating sensible output. Bank \( n \) refers to the list of beams that have made \( n \) steps progress in fulfilling the constraints. After sorting all the possible beams into their respective banks, we do a round-robin selection. With the above example, we'd select the most probable output from Bank 2, then most probable from Bank 1, one from Bank 0, the second most probable from Bank 2, the second most probable from Bank 1, and so forth. Since we're using num_beams=3, we just do the above process three times to end up with ["The is fast", "The dog is", "The dog and"]. This way, even though we're forcing the model to consider the branch where we've manually appended the desired token, we still keep track of other high-probable sequences that probably make more sense. Even though "The is fast" fulfills our constraint completely, it's not a very sensible phrase. Luckily, we have "The dog is" and "The dog and" to work with in future steps, which hopefully will lead to more sensible outputs later on. This behavior is demonstrated in the third step of the above example: Notice how "The is fast" doesn't require any manual appending of constraint tokens since it's already fulfilled (i.e., already contains the phrase "is fast"). Also, notice how beams like "The dog is slow" or "The dog is mad" are actually in Bank 0, since, although it includes the token "is", it must restart from the beginning to generate "is fast". By appending something like "slow" after "is", it has effectively reset its progress. And finally notice how we ended up at a sensible output that contains our constraint phrase: "The dog is fast"! We were worried initially because blindly appending the desired tokens led to nonsensical phrases like "The is fast". However, using round-robin selection from banks, we implicitly ended up getting rid of nonsensical outputs in preference for the more sensible outputs.
[ 0.009302550926804543, -0.024991236627101898, 0.02825874276459217, -0.02031453512609005, 0.024473102763295174, 0.06825809925794601, 0.06720470637083054, 0.05044152960181236, -0.046407125890254974, -0.06324069201946259, -0.07659696787595749, -0.0057465508580207825, -0.0009486473281867802, 0.06852748245000839, -0.04168519377708435, -0.026427611708641052, 0.0519416518509388, -0.041889697313308716, -0.016341667622327805, -0.02377631515264511, 0.0058602578938007355, 0.03657117858529091, 0.11745622009038925, -0.05955130234360695, 0.0596308596432209, -0.011766950599849224, 0.016421208158135414, 0.015813689678907394, -0.02487281709909439, 0.0482400581240654, -0.08005988597869873, 0.0020573155488818884, 0.050613194704055786, 0.045069266110658646, 0.05435040220618248, -0.02722584269940853, -0.1293984353542328, 0.024984559044241905, 0.03864710405468941, 0.012031139805912971, -0.029428690671920776, -0.007321906741708517, -0.04798377677798271, -0.026870300993323326, 0.04670511186122894, -0.019830776378512383, -0.13454917073249817, 0.03430028259754181, -0.05188409611582756, -0.06770528107881546, -0.08759186416864395, 0.03166550397872925, -0.04754962399601936, 0.010069719515740871, -0.04055594652891159, -0.05146496742963791, -0.06428395956754684, -0.08012345433235168, 0.024970952421426773, 0.006025949493050575, 0.011090350337326527, -0.015288615599274635, 0.019916318356990814, 0.0363951213657856, 0.07138080149888992, 0.0019083546940237284, -0.021967394277453423, 0.041541002690792084, -0.03913802653551102, 0.005666031036525965, 0.012600669637322426, -0.0014619509456679225, -0.023532558232545853, -0.021010877564549446, 0.002938021905720234, -0.04043347388505936, -0.01602163352072239, 0.05714717507362366, -0.042869772762060165, 0.05504162982106209, 0.006741311866790056, 0.02122386358678341, 0.04968541860580444, 0.13347184658050537, 0.05899093672633171, 0.01376623846590519, 0.08490128070116043, -0.07710102945566177, -0.07033585011959076, 0.06090236082673073, -0.00035000662319362164, -0.09579054266214371, -0.05894099175930023, 0.016861364245414734, -0.00756411999464035, -0.022890722379088402, -0.01241379790008068, 0.02291879616677761, -0.0008871565223671496, 0.02141803875565529, 0.023086221888661385, -0.055867861956357956, 0.02587928995490074, -0.023108957335352898, -0.05009374022483826, 0.024059312418103218, -0.09910213202238083, -0.0713818147778511, -0.06509915739297867, -0.02409878559410572, 0.02836412936449051, -0.0033113816753029823, 0.05189404636621475, 0.043331846594810486, -0.020126620307564735, 0.03202427551150322, -0.018037153407931328, -0.024311985820531845, -0.08131483942270279, 0.005521448794752359, 0.04045311361551285, 0.09032730758190155, 0.07571252435445786, 0.011551597155630589, 0.04407669976353645, 0.01874588243663311, -0.030708150938153267, 0.037785839289426804, -0.013860698789358139, -0.034235838800668716, -0.032159291207790375, -0.0002448989253025502, -0.044515132904052734, -0.004900527652353048, 0.006924792192876339, -0.04922398552298546, 0.03217029944062233, -0.10501986742019653, 0.05356629192829132, 0.028879644349217415, 0.028741413727402687, 0.026565296575427055, -0.0280122309923172, -0.012169995345175266, 0.033575963228940964, -0.01340274978429079, -0.07335805147886276, 0.03034312278032303, -0.03553879261016846, 0.0371481329202652, -0.022615067660808563, 0.04454638063907623, -0.024946220219135284, -0.061498139053583145, 0.019200848415493965, 0.07542315870523453, -0.015774639323353767, 0.0005331274005584419, -0.07008693367242813, 0.037298496812582016, 0.0012903870083391666, 0.05236979201436043, -0.04859562963247299, -0.06329069286584854, 0.043804071843624115, -0.03216910362243652, 0.024638747796416283, 0.023128429427742958, -0.029409222304821014, 0.011793524026870728, 0.07046744227409363, -0.04735809192061424, 0.05294562503695488, -0.011777506209909916, -0.01318515557795763, 0.0610906258225441, -0.00581793487071991, -0.016486691311001778, -0.009304498322308064, -0.03146697208285332, -0.049637794494628906, 0.03427867218852043, 0.010303381830453873, 0.06794321537017822, 0.05906839296221733, -0.08329358696937561, 0.002257829997688532, -0.012828245759010315, -0.008658581413328648, -0.008196137845516205, -0.0009432522347196937, 0.008472773246467113, 0.11994608491659164, -0.03996584564447403, -0.02296312525868416, -0.05779023841023445, -0.09664785861968994, 0.05065609887242317, 0.039315178990364075, 0.007350037340074778, 0.06364591419696808, 0.04425090178847313, 0.054998595267534256, -0.0116950124502182, 0.014961209148168564, 0.0090949647128582, -0.033554788678884506, -0.09005815535783768, 0.04048042371869087, 0.027631405740976334, -0.031242482364177704, -0.05362698808312416, 0.07421441376209259, -0.15210255980491638, -0.023152397945523262, -0.0599433034658432, -0.021398870274424553, 0.01491820439696312, -0.012885102070868015, 0.022286485880613327, 0.10353782773017883, -0.008235380053520203, 0.011510784737765789, -0.03019748255610466, 0.0029890816658735275, -0.009163666516542435, 0.05238854140043259, 0.08939781785011292, -0.0018350190948694944, -0.07259295880794525, -0.008350125513970852, -0.018392685800790787, 0.024674858897924423, -0.001422887435182929, -0.040103234350681305, -0.027737880125641823, -0.012083309702575207, -0.002276077400892973, 0.01987856812775135, -0.04907423257827759, 0.0024705915711820126, -0.047874655574560165, 0.00034718133974820375, 0.04103568196296692, 0.022068781778216362, -0.029467763379216194, 0.053657013922929764, -0.013469010591506958, -0.02210836485028267, -0.022211920469999313, -0.09998428076505661, 0.00860987976193428, -0.04275732487440109, -0.06965085119009018, 0.04089347645640373, 0.07475616037845612, 0.01972023770213127, -0.02347050979733467, -0.04233091324567795, 0.03876398876309395, -0.013414368964731693, -0.01251134742051363, -0.017805371433496475, -0.046311069279909134, -0.02886129729449749, -0.01827802136540413, -0.01694880984723568, 0.036584556102752686, -0.0010191521141678095, 0.02418348379433155, -0.01747910864651203, -0.012681178748607635, 0.0342240035533905, 0.002146455692127347, 0.022967996075749397, -0.023200348019599915, 0.04442644864320755, 0.033018577843904495, -0.03900061547756195, -0.0005404800758697093, -0.00623937975615263, -0.031651660799980164, 0.02285612002015114, 0.03859991207718849, 0.023310093209147453, 0.006754449103027582, 0.014325923286378384, -0.01413788739591837, -0.039711348712444305, -0.002937744138762355, 0.028992757201194763, 0.07188255339860916, 0.015015806071460247, -0.05148041993379593, 0.05043021962046623, 0.031732164323329926, 0.009640777483582497, -0.01487402431666851, -0.006130605936050415, -0.0118667371571064, -0.05636869743466377, -0.007709103170782328, -0.003712607780471444, 0.007515020668506622, -0.022121449932456017, 0.019276153296232224, 0.03045721910893917, 0.032206665724515915, -0.08532346785068512, -0.03943957760930061, 0.02734295092523098, 0.008518233895301819, 0.008276257663965225, -0.018992071971297264, 0.01412754412740469, 0.009954849258065224, -0.013828744180500507, 0.02698717825114727, 0.008555395528674126, 0.005500979255884886, -0.001042587449774146, -0.01643289625644684, 0.015139368362724781, -0.047853242605924606, -0.014423544518649578, -0.027532389387488365, -0.01805146224796772, 0.0040991101413965225, -0.010355675593018532, -0.028051989153027534, -0.0429096594452858, -0.02201239950954914, -0.011368582025170326, -0.045336078852415085, 0.06001114472746849, 0.013844874687492847, 0.01851782202720642, -0.06507441401481628, -0.009963632561266422, -0.012265252880752087, 0.028147414326667786, -0.002801187103614211, -0.04345536604523659, -0.015554524026811123, -0.020012937486171722, 0.011673441156744957, -0.005047932267189026, 0.052061308175325394, 0.02677297219634056, 0.012792288325726986, 0.006445247679948807, -0.00793652143329382, 0.02624335139989853, 0.015067199245095253, -0.026077870279550552, -0.03127862885594368, 0.014343899674713612, -0.04890682175755501, -0.006069511640816927, -0.015599226579070091, 0.0004291917139198631, 0.04810040444135666, -0.005399560555815697, 0.044727783650159836, -0.016629749909043312, -0.01262592151761055, 0.03559008985757828, 0.003710131160914898, -0.023840341717004776, 0.011570660397410393, -0.017013609409332275, 0.0012007924960926175, 0.04589376598596573, 0.06135325878858566, 0.0034206551499664783, 0.04352043569087982, -0.009849373251199722, 0.03468954935669899, 0.005524998530745506, -0.01086979079991579, -0.007925198413431644, 0.004235630389302969, 0.011509818024933338, -0.010315057821571827, -0.004611347336322069, -0.008137394674122334, 0.03387898579239845, 0.019190730527043343, -0.027080459520220757, 0.012514028698205948, -0.06532016396522522, 0.03362809121608734, 0.008812866173684597, -0.00956042855978012, 0.009007145650684834, -0.0007081065559759736, -0.006829830352216959, -0.03821733221411705, -0.024279693141579628, -0.009048296138644218, -0.040010128170251846, -0.005326064769178629, -0.0680447518825531, -0.002752769272774458, -0.0032945701386779547, -0.03598584234714508, 0.014699363149702549, 0.03471967950463295, 0.021014971658587456, -0.03981044143438339, 0.01849512569606304, 0.03831642121076584, -0.01160423643887043, 0.014363788068294525, -0.014585266821086407, -0.0027531012892723083, 0.006927140988409519, 0.01675451546907425, -0.014017308130860329, 0.0009437361732125282, -0.014198273420333862, -0.029641220346093178, 0.05750485509634018, 0.027657488361001015, -0.01287827268242836, -0.021865764632821083, -0.05024638772010803, 0.0175896268337965, -0.041210439056158066, 0.00892729964107275, 0.015564889647066593, 0.019075404852628708, 0.016357319429516792, -0.02310788817703724, 0.02326212450861931, 0.03191594034433365, 0.004461389500647783, -0.01162913627922535, 0.02380005270242691, -0.00648035341873765, 0.014775617979466915, -0.014341198839247227, 0.03440852090716362, 0.03037100099027157, -0.00627429923042655, -0.0003887084894813597, -0.04159963130950928, -0.04265066608786583, 0.004981186706572771, -0.005567555781453848, 0.05217069387435913, -0.037179213017225266, 0.029390456154942513, 0.02863844856619835, -0.01602778397500515, -0.012999487109482288, 0.020937321707606316, 0.05448800325393677, 0.07612988352775574, -0.004114246461540461, -0.045451510697603226, -0.0018817984964698553, 0.059057362377643585, -0.026660142466425896, -0.025097308680415154, -0.040445972234010696, 0.020870355889201164, 0.04427065700292587, 0.012977341189980507, -0.009135296568274498, -0.02401440590620041, 0.04080197960138321, 0.02412685565650463, -0.013576475903391838, -0.00827074609696865, -0.029482489451766014, 0.0414450578391552, -0.026488108560442924, 0.012707804329693317, -0.00869329459965229, 0.021501662209630013, -0.029281068593263626, -0.0054535274393856525, 0.02276991493999958, 0.041296545416116714, 0.036038950085639954, -0.006616918370127678, 0.0016497070901095867, -0.057299088686704636, 0.007365108467638493, 0.0015250000869855285, -0.008502564392983913, 0.00558986933901906, 0.04744741693139076, 0.06687812507152557, 0.07869916409254074, 0.00813314225524664, 0.052203621715307236, -0.024609167128801346, -0.010489925742149353, 0.0015265097608789802, -0.05849630385637283, 0.021596424281597137, -0.028433555737137794, -0.03412787616252899, 0.05107632279396057, -0.027129411697387695, -0.027400484308600426, 0.016777852550148964, 0.03951406106352806, -0.0150843420997262, -0.028892304748296738, 0.02337018772959709, 0.01959894225001335, 0.013162861578166485, -0.013871581293642521, 0.02131052315235138, -0.02864951826632023, 0.00026815541787073016, -0.011981316842138767, -0.029213769361376762, 0.0021804834250360727, 0.020425528287887573, -0.01097534317523241, -0.019699644297361374, 0.005575515329837799, -0.00025841404567472637, 0.06851166486740112, -0.006108531262725592, -0.00818950217217207, -0.024957330897450447, -0.001245252788066864, 0.016901757568120956, 0.0076933810487389565, 0.012516282498836517, 0.03416647017002106, 0.039775364100933075, 0.038852509111166, -0.017809385433793068, -0.012925231829285622, 0.029593409970402718, 0.0316564179956913, -0.005699513480067253, -0.007911945693194866, 0.0006849205819889903, 0.018525738269090652, 0.06273756921291351, -0.025994038209319115, 0.03506232425570488, 0.012080141343176365, -0.05888453871011734, 0.001178585342131555, -0.003202226245775819, 0.007639218121767044, 0.07722577452659607, 0.0043671615421772, -0.023591065779328346, 0.03973890468478203, 0.03562810644507408, -0.006876736413687468, -0.01347413845360279, 0.03553355857729912, -0.023690151050686836, 0.029093267396092415, 0.026499642059206963, 0.015220199711620808, -0.016589980572462082, 0.002737724455073476, 0.019686026498675346, -0.07858389616012573, -0.011724011041224003, 0.03611348941922188, -0.051174186170101166, 0.06619120389223099, -0.001584208570420742, -0.0448184497654438, -0.008947204798460007, 0.029206737875938416, 0.033586855977773666, -0.014850369654595852, -0.04031958431005478, 0.03521448373794556, -0.00770938815549016, 0.03306415677070618, -0.005181602668017149, 0.06794654577970505, -0.009500203654170036, -0.00203334609977901, 0.04114688187837601, 0.02792367711663246, -0.008920201100409031, 0.016953038051724434, 0.02386045828461647, 0.017958562821149826, 0.051255617290735245, -0.0018048834754154086, 0.027803469449281693, 0.032025303691625595, -0.029110636562108994, -0.015016484074294567, 0.00926546473056078, -0.007158235646784306, -0.05945882573723793, 0.02296251431107521, 0.03337155655026436, -0.011991331353783607, 0.021980224177241325, -0.040330350399017334, 0.06823926419019699, 0.019772985950112343, 0.0028996244072914124, -0.008629027754068375, -0.030425138771533966, 0.014981645159423351, 0.011395066045224667, 0.035133782774209976, 0.037945475429296494, -0.0025843344628810883, -0.06682619452476501, 0.048021845519542694, 0.03564165160059929, 0.04348252713680267, 0.04560340940952301, 0.019210120663046837, -0.015588106587529182, -0.04131358861923218, 0.020287642255425453, 0.025472508743405342, 0.03290765359997749, 0.008456387557089329, -0.05050983652472496, 0.003917866386473179, 0.0005619926960207522, -0.0009351618937216699, 0.0033872961066663265, -0.0024330085143446922, -0.032128557562828064, 0.020051347091794014, 0.010863376781344414, 0.030659029260277748, 0.021315686404705048, -0.0521395243704319, -0.02136230655014515, 0.008706809021532536, 0.020420603454113007, 0.010434377938508987, -0.022775331512093544, -0.0049404664896428585, -0.03723878785967827, -0.040711909532547, -0.03317449241876602, 0.016665266826748848, -0.011488832533359528, -0.010629961267113686, 0.013243349269032478, 0.042973924428224564, -0.016095036640763283, 0.08552754670381546, -0.003525717416778207, -0.0005350515129975975, -0.025013042613863945, -0.03266708180308342, 0.015164859592914581, 0.014096623286604881, -0.003625679761171341, -0.03888487443327904, -0.00844726525247097, -0.00044084913679398596, -0.0034592493902891874, 0.026413625106215477, 0.01735389046370983, -0.024049313738942146, -0.034807220101356506, -0.01733534410595894, 0.00306146708317101, 0.019566066563129425, 0.014960622414946556, 0.004408213309943676, -0.017303314059972763, -0.019746504724025726, -0.032479427754879, -0.015438046306371689, -0.00873755943030119, 0.0009800768457353115, 0.02730589359998703, -0.010137578472495079, -0.04867653548717499, 0.022732751443982124, 0.009133138693869114, 0.03595682233572006, 0.0034206330310553312, 0.06114084646105766, 0.011677585542201996, 0.0017891977913677692, 0.006024983245879412, 0.01899716630578041, -0.0392223559319973, -0.0008012780454009771, -0.05486040562391281, -0.027443408966064453, -0.0027649577241390944, -0.001210822258144617, -0.004754933994263411, 0.019042469561100006, -0.012522710487246513, 0.04930552840232849, -0.0232477355748415, 0.010244615375995636, 0.010608364827930927, -0.01767173781991005, 0.06716922670602798, 0.03518897294998169, 0.09360157698392868, -0.007082329131662846, -0.0006016954430378973, -0.018748389557003975, -0.0021985506173223257, -0.0047159441746771336, 0.039531998336315155, 0.010624353773891926, 0.017301242798566818, -0.007268002722412348, -0.0010871636914089322, -0.02823677472770214, -0.0345563106238842, 0.000039975457184482366, 0.010272542014718056, -0.02530876360833645, 0.005379505455493927, 0.019258489832282066, -0.001226366381160915, 0.041332196444272995, 0.03999270126223564, -0.021257897838950157, 0.004015413112938404, 0.009154675528407097, 0.030931880697607994, -0.05029306933283806, -0.031200997531414032, 0.00391130056232214, 0.0465305857360363, 0.01647275872528553, -0.00038032091106288135, 0.007733117789030075, 0.027630165219306946, 0.0038157464005053043, 0.01899770088493824, 0.027738342061638832, -0.024644790217280388, -0.043007537722587585, -0.002143105259165168, 0.017510859295725822, -0.055571507662534714, -0.01995457336306572, 0.014878424815833569, 0.0422297865152359, -0.0643458440899849, -0.012051785364747047, 0.032765310257673264, 0.04172249510884285, -0.01276391465216875, 0.025839976966381073, -0.019796110689640045, 0.025069614872336388, 0.03572454676032066, 0.02520628832280636, -0.028935976326465607, -0.00482213543727994 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
# Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
[ 0.000027433434297563508, -0.0015847347676753998, 0.09826171398162842, -0.013456776738166809, 0.011573714204132557, 0.01424617413431406, 0.0036255510058254004, 0.03989940509200096, 0.00811727810651064, -0.04532591998577118, -0.06625311821699142, 0.002900506369769573, -0.018684161826968193, 0.04375239089131355, -0.01493770256638527, 0.027331531047821045, 0.03887927532196045, 0.0108632892370224, -0.004873023368418217, 0.011340543627738953, -0.0008305132505483925, -0.017750071361660957, 0.10079991072416306, -0.022144488990306854, 0.07695219665765762, -0.05142032355070114, 0.007082624360918999, 0.013696259818971157, -0.051168497651815414, 0.03534351661801338, -0.04552440345287323, -0.006233384367078543, 0.018953662365674973, -0.04469822347164154, -0.062044449150562286, 0.049520496279001236, -0.09769755601882935, -0.0018747453577816486, 0.027670182287693024, -0.011125922203063965, -0.08189752697944641, -0.0396067313849926, 0.02905821055173874, -0.021212391555309296, 0.009986919350922108, 0.011734713800251484, -0.22871816158294678, 0.1111859455704689, -0.08129904419183731, 0.0072830854915082455, -0.0921715572476387, 0.04584765434265137, -0.029450299218297005, -0.0056630466133356094, 0.005026630125939846, 0.06331712007522583, -0.013224941678345203, -0.08765813708305359, 0.036064259707927704, -0.007630178239196539, 0.031377509236335754, 0.004022079519927502, 0.02186758816242218, 0.06552840024232864, 0.03229556232690811, 0.005218578036874533, -0.009945863857865334, 0.01051432453095913, -0.09544520080089569, 0.008399441838264465, 0.04742357134819031, 0.03278886899352074, -0.06169534847140312, -0.06456179916858673, -0.021823100745677948, -0.03927040100097656, -0.0188014954328537, 0.07790269702672958, 0.004424313083291054, 0.09628035128116608, -0.0022779323626309633, 0.018791189417243004, 0.052196938544511795, 0.06547994911670685, 0.01689462549984455, 0.04660884663462639, 0.04763221740722656, -0.027366194874048233, -0.04435058683156967, 0.0659516230225563, -0.020352741703391075, -0.1776341050863266, -0.06304573267698288, 0.03711234778165817, 0.035592060536146164, -0.025229373946785927, 0.06679742783308029, 0.005705265793949366, -0.006603439804166555, 0.05466834828257561, -0.017093868926167488, 0.035771578550338745, 0.10880880057811737, -0.005238822661340237, -0.08009599149227142, -0.03779982402920723, -0.0018758043879643083, -0.05967720225453377, -0.020373698323965073, 0.04849623516201973, -0.02480473183095455, 0.008171125315129757, 0.0712643712759018, 0.061439864337444305, -0.015685565769672394, 0.04021820053458214, 0.06771698594093323, -0.019531112164258957, -0.044097185134887695, 0.04353344440460205, 0.007133998908102512, 0.07882477343082428, 0.05808807164430618, 0.03607819601893425, 0.0412319079041481, 0.05502106249332428, -0.0013666334562003613, 0.010267498902976513, -0.034921664744615555, -0.020986931398510933, 0.028983591124415398, -0.033422041684389114, 0.042673833668231964, 0.013036193326115608, -0.0010452460264787078, -0.024138307198882103, 0.04479863494634628, -0.03308670595288277, -0.04344339296221733, 0.007574766408652067, 0.0052041951566934586, -0.004622056148946285, 0.02708943374454975, 0.020410194993019104, -0.021298019215464592, -0.08029399812221527, -0.05596185848116875, 0.04279565066099167, -0.07233189046382904, 0.029169388115406036, 0.007180245127528906, 0.05004255473613739, -0.03273354470729828, -0.07643438875675201, -0.03121650032699108, 0.0449703149497509, 0.02405470795929432, 0.0002544565359130502, -0.06668990105390549, -0.021981634199619293, -0.05361076444387436, -0.0006851903744973242, 0.021757882088422775, -0.014718901365995407, 0.01705501787364483, -0.06157612055540085, 0.007060240488499403, 0.019334303215146065, 0.03617290407419205, 0.0013496722094714642, -0.022135233506560326, -0.025923557579517365, 0.048000775277614594, -0.03614306449890137, -0.007546713575720787, 0.024788353592157364, 0.057189568877220154, 0.05442796275019646, -0.043753769248723984, -0.028369611129164696, -0.04170629754662514, 0.011454345658421516, 0.018035508692264557, 0.07647641003131866, 0.027937885373830795, -0.06414084881544113, 0.03635665029287338, 0.018088703975081444, 0.0029898835346102715, 0.0037948894314467907, -0.09468808025121689, -0.06847259402275085, 0.05322761461138725, -0.0006547412485815585, -0.009380069561302662, -0.0921768769621849, -0.028337916359305382, 0.10982903838157654, 0.06532574445009232, 0.08877870440483093, 0.0647619441151619, 0.018038740381598473, 0.04910141974687576, -0.013201768510043621, -0.03440369665622711, 0.02132718823850155, 0.03209307789802551, -0.008825784549117088, 0.008757702074944973, 0.01357488613575697, 0.017537927255034447, -0.10466007888317108, 0.05343425273895264, -0.08878249675035477, -0.024881532415747643, -0.05306796729564667, -0.03617246821522713, -0.01879888027906418, -0.025939123705029488, 0.01600964367389679, 0.12865690886974335, 0.026459408923983574, -0.05748796835541725, -0.014610644429922104, -0.01345511432737112, 0.05927278473973274, 0.0399269163608551, -0.0030335874762386084, 0.03477954864501953, -0.08505324274301529, 0.027084575966000557, 0.025203637778759003, 0.05635407939553261, 0.0716785117983818, 0.0022921657655388117, -0.03276016190648079, -0.01595122367143631, 0.0013101052027195692, 0.07107169181108475, -0.0069824093952775, -0.02794685959815979, -0.005182463675737381, 0.006634491961449385, 0.053036995232105255, -0.00890844315290451, -0.006788317114114761, 0.04172556847333908, 0.010326243937015533, -0.025592079386115074, 0.0017708850791677833, -0.04390936344861984, 0.056360188871622086, -0.014278650283813477, -0.08499176800251007, 0.08347716182470322, 0.022498512640595436, -0.01646248996257782, -0.050246480852365494, -0.022561272606253624, 0.013354199007153511, 0.002484554424881935, -0.01756211742758751, 0.01733536645770073, -0.055575452744960785, 0.0007605812279507518, -0.01385419350117445, 0.05002102628350258, 0.021309003233909607, -0.031623393297195435, 0.03001401387155056, -0.0032156212255358696, -0.02616971731185913, 0.04164854809641838, -0.013854265213012695, 0.004442333243787289, -0.003718751482665539, 0.04631112515926361, -0.02458709478378296, -0.031894031912088394, 0.012924539856612682, -0.04500344768166542, 0.006257489789277315, 0.03796925023198128, 0.013802681118249893, -0.0050872438587248325, -0.008532467298209667, 0.019909603521227837, 0.0030995081178843975, 0.007220406085252762, -0.03335868567228317, -0.023797260597348213, 0.01865442469716072, -0.01356755755841732, -0.010869774967432022, 0.027499210089445114, 0.0009545947541482747, 0.011330963112413883, -0.00870592426508665, -0.028364980593323708, -0.0009502808679826558, 0.013039585202932358, 0.005344818811863661, -0.002912467811256647, 0.009332919493317604, -0.03927283361554146, 0.03565886244177818, -0.006146120373159647, 0.03615880757570267, -0.11706916242837906, -0.04555186629295349, 0.002955110277980566, 0.012844571843743324, -0.01795157790184021, -0.0029323657508939505, 0.010942746885120869, -0.018749957904219627, 0.006588414777070284, -0.042392391711473465, 0.01561678759753704, 0.006013371050357819, 0.004798044450581074, 0.01566091552376747, -0.01900617964565754, -0.03149564191699028, -0.03343008831143379, 0.02974168211221695, 0.011884750798344612, -0.011291464790701866, -0.011681415140628815, 0.013155658729374409, 0.0002633042458910495, 0.00036639405880123377, 0.011582814157009125, -0.0015383721329271793, -0.0010089358547702432, 0.03019406832754612, -0.0018396831583231688, -0.028370942920446396, -0.009504451416432858, 0.01895449310541153, -0.0532870888710022, 0.02034253440797329, -0.02090018428862095, 0.008190914057195187, 0.03408605977892876, -0.0075470018200576305, 0.027858074754476547, 0.025719741359353065, 0.04105711355805397, -0.005919038318097591, -0.006989774759858847, -0.015192687511444092, -0.026214318349957466, -0.045134395360946655, -0.048440393060445786, 0.020987331867218018, 0.016784682869911194, -0.05075246840715408, -0.04429981857538223, -0.013491137884557247, -0.021642494946718216, 0.02007339708507061, 0.028907133266329765, -0.00651538698002696, -0.00557538541033864, -0.0008318350301124156, 0.050520602613687515, -0.022277342155575752, -0.06059299409389496, -0.008292422629892826, -0.0032788715325295925, 0.014787478372454643, -0.042737819254398346, 0.08858614414930344, -0.006591480225324631, 0.04217057302594185, 0.0019687172025442123, 0.04706098139286041, 0.002813482191413641, 0.00127918750513345, 0.004100925754755735, 0.020815683528780937, -0.04632902145385742, 0.06425369530916214, -0.015352694317698479, -0.05711095780134201, 0.08000538498163223, -0.007009102962911129, -0.015374776907265186, -0.025054629892110825, -0.05633014813065529, 0.01667017489671707, 0.00775437755510211, -0.01511948462575674, 0.02650088630616665, -0.013160024769604206, 0.024575235322117805, 0.011967072263360023, 0.006279232446104288, -0.042712610214948654, -0.0019858828745782375, -0.028209125623106956, -0.006460791919380426, 0.009014745242893696, 0.012030063197016716, -0.0257488451898098, 0.009967940859496593, 0.02652536705136299, 0.02706872671842575, -0.041176680475473404, -0.00837566889822483, 0.012693868950009346, 0.013268852606415749, 0.022831063717603683, -0.048658110201358795, -0.009129866026341915, -0.025527531281113625, 0.029136518016457558, 0.034969836473464966, -0.03931937366724014, -0.029300015419721603, -0.008945445530116558, -0.010650326497852802, 0.014448773115873337, 0.00086686055874452, -0.036117371171712875, -0.04521113261580467, 0.03627133369445801, -0.02655893936753273, 0.02260720729827881, 0.008768599480390549, -0.00003744222340174019, -0.0006160149932838976, -0.012496241368353367, 0.020482463762164116, 0.0471719391644001, -0.01890299655497074, -0.021889623254537582, -0.005397931672632694, -0.021084213629364967, 0.053505703806877136, 0.009521707892417908, 0.0314866341650486, 0.007439629174768925, -0.008900710381567478, -0.003325854195281863, -0.03397926315665245, -0.03901859372854233, -0.0012001068098470569, 0.017113955691456795, 0.005917681846767664, -0.0004259419220034033, 0.04740384966135025, -0.02078397572040558, -0.03775380551815033, 0.019676411524415016, -0.02194046601653099, 0.0426182821393013, 0.0749804750084877, -0.01125316508114338, -0.03523858264088631, 0.021113289520144463, 0.047064390033483505, -0.013916020281612873, 0.002985771279782057, 0.00946167390793562, -0.01264987513422966, 0.0354527048766613, 0.0025481823831796646, -0.01348787359893322, -0.05924099683761597, 0.015309447422623634, 0.008796483278274536, 0.013873929157853127, 0.029447494074702263, -0.02971525490283966, 0.02061932161450386, -0.009341473691165447, 0.02046346105635166, 0.000916393066290766, 0.025788819417357445, -0.007479280699044466, 0.0008643728797324002, 0.04154973104596138, 0.0016339590074494481, 0.010017408058047295, -0.0008949604234658182, -0.0035565157886594534, -0.022343726828694344, 0.0018915674882009625, 0.0227641761302948, 0.04550747573375702, 0.00018551874381955713, -0.013126090168952942, 0.049302469938993454, 0.014574370346963406, 0.009779855608940125, -0.016182638704776764, -0.008346177637577057, -0.03454943746328354, 0.0030234234873205423, -0.028657447546720505, 0.005336109548807144, -0.027852464467287064, 0.009035874158143997, 0.0016235397197306156, 0.0046194749884307384, 0.019301073625683784, 0.05417703837156296, 0.008578794077038765, -0.014503457583487034, 0.0016487784450873733, 0.024451302364468575, -0.012161875143647194, 0.00725427083671093, -0.0235486701130867, -0.013775336556136608, -0.022760754451155663, 0.000777343986555934, 0.02963910810649395, -0.05128331109881401, -0.029771311208605766, 0.008283289149403572, -0.03810584172606468, 0.0035606881137937307, -0.02193174511194229, 0.029706086963415146, 0.052136339247226715, 0.025664906948804855, -0.02084454335272312, 0.02707270346581936, 0.04254468157887459, 0.0243453960865736, -0.016278637573122978, 0.028112787753343582, 0.016379328444600105, 0.016853265464305878, 0.025349825620651245, 0.02017267234623432, 0.00616687536239624, 0.0030036033131182194, 0.014443385414779186, 0.01517611276358366, 0.0002956796088255942, -0.05690278485417366, 0.04690137133002281, 0.03514532372355461, 0.010281124152243137, 0.04763731360435486, -0.024915792047977448, -0.024647342041134834, 0.019706659018993378, -0.014952375553548336, 0.018234891816973686, 0.046415064483881, -0.005128490272909403, -0.020322253927588463, 0.01554397214204073, 0.03736329451203346, -0.03190683200955391, -0.03954256325960159, 0.018005717545747757, 0.010791550390422344, 0.04636920988559723, 0.020760241895914078, -0.004411233589053154, -0.0015766737051308155, 0.004843144211918116, 0.010354090481996536, -0.0471237450838089, 0.005502690561115742, 0.01947537064552307, -0.029717393219470978, 0.03734563663601875, -0.03791690245270729, -0.02598213404417038, -0.013417784124612808, 0.020331088453531265, -0.02573699690401554, 0.02584613487124443, 0.022373704239726067, 0.00491401506587863, 0.011233731172978878, -0.028141498565673828, 0.02169637568295002, 0.06945185363292694, 0.009967442601919174, 0.037108004093170166, 0.024330485612154007, 0.06615424156188965, -0.005744833033531904, -0.005899639334529638, -0.02876472659409046, 0.022901291027665138, 0.05171683803200722, -0.007371185813099146, 0.034486498683691025, 0.0043087606318295, -0.016269100829958916, -0.0164966881275177, 0.002982126548886299, -0.027276573702692986, -0.03941677510738373, 0.031813956797122955, 0.029656430706381798, 0.002020331332460046, 0.03645162656903267, -0.03386286646127701, 0.04730931296944618, 0.006104190368205309, 0.018331728875637054, -0.027871379628777504, 0.021580258384346962, -0.005652116611599922, 0.00005880081153009087, 0.022166788578033447, 0.03298937529325485, 0.008180180564522743, -0.010049477219581604, 0.08054108917713165, -0.01638803258538246, 0.0373377650976181, 0.009141769260168076, -0.028838932514190674, 0.030050119385123253, 0.004861300345510244, -0.012839353643357754, 0.012178568169474602, 0.04992587864398956, -0.0289294570684433, -0.01818677969276905, 0.013086343184113503, -0.02794433757662773, -0.03326461836695671, 0.028820835053920746, 0.020594706758856773, -0.02999204769730568, -0.023094309493899345, -0.024897504597902298, 0.04271068796515465, 0.012369528412818909, -0.00837546493858099, 0.016637137159705162, 0.0018260549986734986, 0.02249949797987938, 0.055144164711236954, -0.014502608217298985, 0.013053014874458313, -0.05330188199877739, -0.00900461245328188, -0.012056459672749043, -0.030933715403079987, 0.0018718464998528361, -0.016998212784528732, -0.014825871214270592, 0.010250868275761604, -0.01589362882077694, 0.06138754263520241, 0.01569356583058834, 0.019024165347218513, -0.038937173783779144, 0.005811700597405434, -0.039458271116018295, 0.018992681056261063, -0.021905500441789627, -0.058935124427080154, -0.003312507411465049, -0.02243805304169655, 0.011418365873396397, 0.025064028799533844, -0.005397452041506767, -0.05977034196257591, -0.03171520307660103, 0.0009870623471215367, -0.04126117751002312, -0.011418337002396584, 0.019581951200962067, 0.017327986657619476, -0.021986477077007294, 0.004953344818204641, -0.016544930636882782, 0.010119081474840641, 0.0012399944243952632, 0.013311058282852173, 0.04828037694096565, -0.02580905146896839, -0.06287159025669098, -0.048198044300079346, 0.06624526530504227, 0.00046602642396464944, 0.015236248262226582, 0.02560291811823845, 0.033440954983234406, 0.009995629079639912, -0.0179684329777956, 0.00047832372365519404, -0.03206207603216171, 0.03807802498340607, -0.04807033762335777, -0.05843828618526459, -0.02320307306945324, -0.02234416827559471, 0.0007854830473661423, 0.02829408273100853, -0.042507484555244446, 0.017970075830817223, -0.006507641635835171, -0.012013250030577183, -0.0437488853931427, 0.01292065903544426, 0.046170298010110855, -0.014518371783196926, 0.04992146044969559, -0.01957034505903721, 0.03607998788356781, -0.004645467270165682, -0.0009688526042737067, 0.0023723437916487455, 0.04593585431575775, 0.015695109963417053, -0.016047269105911255, -0.02246960997581482, 0.015467897057533264, -0.0595926009118557, -0.04854132607579231, 0.016665834933519363, 0.022027362138032913, -0.026193028315901756, -0.035022661089897156, 0.012245452962815762, 0.027633119374513626, 0.01637083850800991, 0.027253836393356323, -0.006127744447439909, -0.03816667199134827, 0.027675675228238106, 0.017354227602481842, -0.051935285329818726, 0.016995538026094437, -0.010039257816970348, 0.003920459188520908, 0.04172274470329285, 0.006459385622292757, 0.004656252916902304, 0.002725971629843116, -0.021675195544958115, -0.010306308977305889, -0.0014714215649291873, -0.026729034259915352, -0.035022251307964325, 0.014568849466741085, -0.013805736787617207, -0.04700981453061104, -0.05096561089158058, 0.030259782448410988, -0.01276037935167551, 0.010445074178278446, 0.021238533779978752, -0.0038799403700977564, -0.019804807379841805, 0.007221379317343235, 0.03467220067977905, 0.01518480759114027, 0.00037071952829137444, 0.028969591483473778, 0.009829466231167316, 0.027518868446350098, -0.021246781572699547 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
Introduction This blog post assumes that the reader is familiar with text generation methods using the different variants of beam search, as explained in the blog post: "How to generate text: using different decoding methods for language generation with Transformers" Unlike ordinary beam search, constrained beam search allows us to exert control over the output of text generation. This is useful because we sometimes know exactly what we want inside the output. For example, in a Neural Machine Translation task, we might know which words must be included in the final translation with a dictionary lookup. Sometimes, generation outputs that are almost equally possible to a language model might not be equally desirable for the end-user due to the particular context. Both of these situations could be solved by allowing the users to tell the model which words must be included in the end output.
[ 0.015611776150763035, -0.020913176238536835, 0.06393565982580185, -0.016354655846953392, 0.02511107176542282, 0.08056657761335373, 0.013773552142083645, 0.003898125607520342, -0.02341686375439167, -0.011033249087631702, -0.08241987973451614, -0.03589493781328201, -0.029916778206825256, 0.04665563255548477, -0.06705865263938904, -0.004099722485989332, 0.0617445670068264, -0.00041945785051211715, -0.010647140443325043, 0.060722291469573975, 0.030881838873028755, -0.0059503368102014065, 0.09282492846250534, -0.023916546255350113, 0.09462665766477585, -0.03972264751791954, 0.01163540594279766, -0.035728178918361664, -0.052835818380117416, 0.03170526400208473, -0.05257689952850342, 0.002900986932218075, 0.009624713100492954, -0.026960112154483795, -0.06843405216932297, 0.05335284769535065, -0.10918807238340378, 0.012932926416397095, -0.004748993553221226, -0.027944333851337433, -0.08807402104139328, -0.008021346293389797, 0.0025864329654723406, 0.00043184831156395376, -0.01692214421927929, 0.03345832973718643, -0.18679016828536987, 0.10206875205039978, -0.06078708544373512, 0.009855196811258793, -0.11625976860523224, 0.05392055585980415, -0.028849612921476364, -0.022898957133293152, -0.0017246127827093005, 0.04823358356952667, -0.028353584930300713, -0.1390242874622345, 0.042530741542577744, -0.015428666956722736, -0.03347032517194748, 0.02474471926689148, 0.04642229899764061, 0.06228771433234215, 0.04656077176332474, -0.038992058485746384, 0.012325337156653404, -0.0038486614357680082, -0.0828617587685585, 0.017315112054347992, -0.030826350674033165, 0.010945744812488556, -0.06890732049942017, -0.050295062363147736, 0.008775409311056137, -0.00993402674794197, 0.0037774257361888885, 0.048578567802906036, -0.037781089544296265, 0.021969852969050407, 0.01950855553150177, 0.06633268296718597, 0.04512353241443634, 0.01653459295630455, 0.043494563549757004, 0.038346149027347565, 0.047843992710113525, -0.024720391258597374, -0.0317167267203331, 0.053969934582710266, -0.00785150844603777, -0.15503224730491638, -0.06711301952600479, 0.0236904826015234, 0.04002860188484192, -0.05165611952543259, 0.06804284453392029, 0.06220390275120735, -0.03490857034921646, 0.05369767174124718, 0.020417258143424988, -0.02377517893910408, 0.07545024156570435, -0.004179046954959631, -0.060718487948179245, -0.02187008410692215, -0.01703561469912529, -0.06314948201179504, -0.029214883223176003, 0.05037739500403404, -0.0007538085919804871, 0.012131956405937672, 0.04365222901105881, 0.05659002438187599, -0.04323624074459076, 0.008061745204031467, 0.07176414877176285, 0.029614239931106567, -0.06484296917915344, 0.0413057804107666, 0.0003408190095797181, 0.05713777616620064, 0.05382252112030983, 0.030206577852368355, 0.032736100256443024, -0.002890851814299822, 0.009063548408448696, -0.005582911428064108, 0.014193597249686718, -0.0027283187955617905, 0.021332550793886185, -0.006682730279862881, 0.07288758456707001, 0.030707689002156258, 0.052978236228227615, -0.0060782600194215775, 0.021078163757920265, -0.06238721311092377, -0.05971315875649452, 0.014981594868004322, 0.013938370160758495, -0.006875874940305948, -0.01658099703490734, 0.014133157208561897, -0.02522401325404644, -0.042434148490428925, -0.02495378442108631, 0.015546029433608055, -0.05887260288000107, 0.03787638619542122, 0.025060666725039482, 0.06208028271794319, -0.02392614632844925, -0.08456915616989136, -0.04276531562209129, 0.03686261177062988, 0.01930192857980728, 0.0061469245702028275, -0.033154647797346115, -0.03332076966762543, -0.052205681800842285, 0.00772918900474906, 0.030410686507821083, -0.0029593612998723984, 0.0188621673732996, -0.035437390208244324, 0.022118007764220238, 0.06537573039531708, 0.00010994186595780775, 0.037719886749982834, 0.0010692430660128593, 0.01498595904558897, 0.08345819264650345, -0.0785287544131279, 0.03163420408964157, 0.010539298877120018, 0.02356051094830036, 0.037623725831508636, -0.010811340995132923, -0.05335165187716484, -0.02453024312853813, -0.005117838270962238, 0.02248421125113964, 0.053102485835552216, 0.016830187290906906, -0.09106896817684174, 0.04085863009095192, -0.042550649493932724, -0.012402364984154701, -0.012583001516759396, -0.06169545650482178, -0.060338787734508514, 0.037967585027217865, -0.03878440335392952, -0.03611735999584198, -0.09743160754442215, -0.04675384983420372, 0.13753826916217804, 0.05783411115407944, 0.07780259847640991, 0.09220776706933975, -0.0013942514779046178, 0.01988077349960804, -0.02232871763408184, -0.02257029339671135, -0.007533020805567503, 0.015109737403690815, -0.02913494221866131, -0.024208517745137215, 0.0271372701972723, 0.011359256692230701, -0.09017838537693024, 0.018906284123659134, -0.10385449975728989, -0.037971772253513336, -0.020744040608406067, -0.021442804485559464, 0.010443339124321938, 0.0006842142902314663, 0.012477604672312737, 0.1480346918106079, 0.013377518393099308, -0.05329281836748123, -0.007305304054170847, 0.017111701890826225, 0.06471547484397888, 0.019597044214606285, 0.04258231446146965, 0.013317674398422241, -0.08463683724403381, 0.02859474904835224, 0.021406076848506927, 0.0696137472987175, 0.0354405902326107, -0.04031304642558098, -0.029658138751983643, -0.026339543983340263, 0.027202218770980835, 0.02998555637896061, 0.04345241189002991, -0.05100472643971443, -0.0008860363159328699, -0.03180260583758354, 0.06902623921632767, -0.028676047921180725, -0.04869372397661209, 0.06188252940773964, 0.01604779064655304, -0.020911812782287598, -0.013094330206513405, -0.03617818281054497, 0.06282159686088562, -0.0018917883280664682, -0.09750796109437943, 0.060639310628175735, 0.01770411990582943, 0.02660563215613365, -0.03989645838737488, -0.005236799828708172, 0.012799018993973732, -0.012825231067836285, -0.028922386467456818, 0.017412083223462105, -0.06591536849737167, 0.007907522842288017, -0.016130726784467697, 0.046388983726501465, 0.018300456926226616, -0.010290474630892277, 0.0073210131376981735, -0.0034777848049998283, -0.03641091659665108, 0.0267576202750206, -0.018605828285217285, 0.028087947517633438, 0.0047548389993608, 0.014312980696558952, -0.02810802310705185, -0.033612463623285294, -0.005920029245316982, -0.060239531099796295, 0.012855571694672108, 0.03830404952168465, 0.02330823801457882, 0.008065707981586456, -0.010114233940839767, 0.007237614598125219, -0.00009596209565643221, 0.011957868002355099, -0.021639466285705566, -0.03553764149546623, 0.012889119796454906, -0.0002658265584614128, 0.014515011571347713, 0.03138148412108421, 0.012078951112926006, 0.011159863322973251, -0.024462737143039703, -0.015604435466229916, 0.010830945335328579, -0.013296088203787804, -0.012311269529163837, -0.006605976261198521, 0.00929675716906786, -0.04272948205471039, 0.03901832178235054, 0.00798965897411108, 0.03926212340593338, -0.09647321701049805, -0.04955115169286728, 0.007008315064013004, 0.007753896526992321, -0.003176379483193159, 0.008194327354431152, 0.02345755510032177, -0.002708231331780553, -0.0015899655409157276, -0.010766282677650452, -0.014121311716735363, -0.011743035167455673, 0.030995702371001244, 0.010783887468278408, -0.013895700685679913, -0.025875980034470558, -0.022554952651262283, 0.015015918761491776, 0.032138410955667496, 0.006781522184610367, -0.01769091747701168, 0.004349142778664827, 0.030973969027400017, 0.008424665778875351, -0.020978553220629692, 0.002524233190342784, -0.0015848579350858927, 0.03545830771327019, 0.014742887578904629, -0.017937421798706055, 0.006941692437976599, 0.010698762722313404, -0.046253710985183716, -0.0024408961180597544, -0.01996767893433571, 0.0018339770613238215, 0.02718651108443737, 0.019700419157743454, 0.027459241449832916, 0.03344997391104698, 0.0351283922791481, -0.032784730195999146, 0.00610765628516674, -0.02251657098531723, -0.040699686855077744, -0.0330282561480999, -0.04013150557875633, -0.0008627313654869795, 0.022817935794591904, -0.05975485220551491, -0.043600548058748245, -0.014079680666327477, -0.00412046117708087, 0.043581489473581314, 0.02669929899275303, -0.03504466637969017, 0.008086370304226875, -0.020698780193924904, 0.03156964108347893, 0.026336967945098877, -0.08175564557313919, 0.0014004261465743184, 0.011271506547927856, -0.004471193067729473, -0.03060675971210003, 0.08337313681840897, 0.009512736462056637, 0.03682750090956688, 0.0006948965019546449, 0.049880608916282654, 0.0023236533161252737, 0.020900538191199303, 0.03251411020755768, 0.009981071576476097, -0.037929680198431015, 0.04635710269212723, -0.01884593814611435, -0.04796607047319412, 0.07727835327386856, 0.01133256871253252, -0.014391280710697174, -0.023663030937314034, -0.06600726395845413, -0.007266979198902845, 0.04140712320804596, -0.02146078087389469, 0.007399474270641804, -0.011321967467665672, -0.014243286103010178, 0.004609032534062862, 0.022313933819532394, -0.040244780480861664, -0.0047440375201404095, -0.011586720123887062, -0.011767065152525902, 0.024191811680793762, -0.006310808006674051, -0.01335838995873928, 0.018769770860671997, -0.014301449991762638, -0.011249303817749023, -0.051771122962236404, -0.018047431483864784, 0.009224438108503819, 0.010258511640131474, 0.01428399607539177, -0.07215823978185654, 0.002438750583678484, -0.014066725969314575, 0.010829833336174488, -0.004259016830474138, -0.013822641223669052, -0.024674369022250175, 0.01863635890185833, -0.003200704697519541, 0.00591249018907547, 0.007598364260047674, -0.054036278277635574, -0.025133393704891205, -0.014620380476117134, -0.06236015260219574, 0.0022496285382658243, -0.0008461227407678962, -0.005991047248244286, 0.00993083044886589, -0.03526746854186058, -0.003709082957357168, 0.023215750232338905, 0.011060944758355618, -0.0014868307625874877, 0.025270400568842888, 0.0261936467140913, 0.06179662048816681, 0.016461487859487534, 0.022563347592949867, 0.00884990394115448, -0.020930755883455276, 0.021667271852493286, -0.05325678735971451, -0.02098744548857212, -0.02870389074087143, -0.004142832476645708, 0.017364978790283203, -0.020820919424295425, 0.06106961891055107, 0.0009331284672953188, -0.04175792261958122, 0.01741657592356205, 0.005740221589803696, 0.014733901247382164, 0.07715724408626556, 0.012824347242712975, -0.07469793409109116, 0.013320470228791237, 0.03246678039431572, -0.03941165283322334, -0.017207928001880646, 0.03196798637509346, -0.007130593992769718, 0.017661498859524727, 0.010215707123279572, -0.02821364626288414, -0.04315182566642761, 0.045309606939554214, 0.012627456337213516, 0.02198193594813347, 0.0020836656913161278, 0.02121889963746071, 0.004553158767521381, 0.009922397322952747, 0.019555455073714256, 0.0009425043244846165, 0.021174393594264984, -0.008967176079750061, 0.0030601094476878643, 0.034303758293390274, 0.007375419605523348, 0.019036203622817993, 0.007794863078743219, 0.013879023492336273, -0.014356309548020363, -0.020319757983088493, 0.03579813241958618, 0.03751271218061447, 0.04441402852535248, -0.004095357842743397, 0.06519711017608643, 0.028086300939321518, 0.028310541063547134, -0.03358650952577591, 0.0007478803163394332, -0.004868612624704838, 0.028226563706994057, -0.030851515009999275, 0.0333666130900383, 0.007549299858510494, -0.02031809091567993, 0.010830030776560307, 0.001736422535032034, 0.03268660977482796, 0.03160278871655464, -0.0003701578825712204, -0.03710845857858658, 0.005971814505755901, 0.0026032926980406046, 0.001850676373578608, -0.006539089139550924, -0.04274124652147293, -0.004670548718422651, -0.01932479254901409, -0.018679723143577576, 0.016138773411512375, -0.064516082406044, 0.0005817172350361943, -0.0038967665750533342, -0.04464872181415558, -0.018363341689109802, 0.002033163560554385, 0.03385351970791817, 0.058268602937459946, 0.03341742232441902, -0.04241342097520828, 0.008628932759165764, 0.042802855372428894, 0.03994502127170563, -0.019350921735167503, 0.01001578290015459, 0.02493080124258995, 0.05464119464159012, 0.03845398873090744, 0.03129163011908531, -0.027131225913763046, 0.00030880095437169075, 0.018524155020713806, -0.0000018072181546813226, -0.01725073717534542, -0.0294365044683218, 0.059503406286239624, 0.027380215004086494, -0.006055496633052826, 0.047481879591941833, -0.015264175832271576, -0.021244246512651443, 0.0256402138620615, -0.006004820112138987, 0.010744547471404076, 0.02499108389019966, -0.006211443804204464, -0.021155862137675285, 0.027286233380436897, 0.008793702349066734, -0.01424221508204937, -0.005836596712470055, 0.03843684867024422, -0.027642060071229935, 0.04607611522078514, 0.026180895045399666, -0.013915171846747398, -0.013314926065504551, 0.011930258944630623, 0.0031348431948572397, -0.0366964153945446, -0.0345626026391983, 0.03021635301411152, -0.049124203622341156, 0.04512515291571617, -0.032578252255916595, -0.05246080830693245, -0.017664359882473946, -0.004928236827254295, 0.019166605547070503, 0.010496069677174091, -0.008869282901287079, 0.01892571896314621, 0.008384241722524166, -0.020040230825543404, 0.011376426555216312, 0.07017802447080612, 0.02186499536037445, 0.05212656408548355, 0.02050221525132656, 0.05019400641322136, -0.021644379943609238, -0.042066559195518494, -0.008114662952721119, -0.002732211258262396, 0.04713808745145798, 0.0031688534654676914, 0.01583593152463436, -0.01958365924656391, -0.041815660893917084, -0.02086581476032734, 0.0028691391926258802, -0.022158244624733925, -0.030123695731163025, 0.014080929569900036, 0.0038310373201966286, 0.019618043676018715, 0.0017343655927106738, -0.047459740191698074, 0.05276575684547424, -0.002662919694557786, 0.024289466440677643, 0.003151461249217391, 0.0354161337018013, 0.018014848232269287, 0.007115668151527643, 0.03961249813437462, 0.07210246473550797, 0.006252571474760771, -0.004378946032375097, 0.06018142029643059, 0.019117465242743492, 0.020964240655303, 0.0018693379824981093, -0.010740827769041061, 0.043741632252931595, -0.008039324544370174, -0.009420648217201233, 0.028669191524386406, 0.030404716730117798, -0.016920305788517, -0.006684733554720879, 0.012491761706769466, -0.020089054480195045, -0.008933966048061848, 0.016748810186982155, -0.006319283042103052, -0.024728944525122643, -0.0122217470780015, -0.016658233478665352, 0.06462264806032181, 0.02879316359758377, -0.04570484161376953, -0.004333124030381441, -0.02068830281496048, 0.013967243954539299, 0.07992462068796158, -0.009898540563881397, -0.006954307667911053, -0.04225067421793938, 0.0011790625285357237, -0.005772477947175503, -0.01447551604360342, -0.0035822708159685135, 0.00784654077142477, -0.04119664430618286, 0.022243794053792953, -0.03728177398443222, 0.056335777044296265, 0.0032257321290671825, 0.02843056060373783, -0.0288107730448246, -0.018632106482982635, -0.034289829432964325, -0.0026691376697272062, 0.006426953244954348, -0.04846455901861191, 0.0007723283488303423, -0.0443374402821064, 0.02227197028696537, -0.0014118773397058249, 0.00436315918341279, -0.025900762528181076, -0.019830502569675446, -0.014993144199252129, -0.005982717964798212, -0.01833225041627884, 0.00879912730306387, 0.031495071947574615, -0.010306121781468391, -0.00015150028048083186, -0.02925686538219452, -0.004625614266842604, 0.015375210903584957, 0.023522205650806427, 0.04991648346185684, -0.02856496162712574, -0.06234404072165489, -0.03164147585630417, 0.05088554695248604, 0.0005600210279226303, -0.00024324754485860467, 0.018958717584609985, 0.015438572503626347, 0.02288268506526947, 0.01053138542920351, 0.020639022812247276, -0.03165898844599724, 0.05142673850059509, -0.026021383702754974, -0.05677419155836105, -0.023238347843289375, 0.02909168042242527, 0.0008294614381156862, 0.017808323726058006, -0.041743990033864975, 0.0362670011818409, -0.017941564321517944, -0.006279554218053818, -0.011878750286996365, 0.000850466953124851, 0.04764184355735779, 0.011221741326153278, 0.04770703241229057, -0.003383108414709568, 0.03724208474159241, -0.007577236276119947, -0.010279571637511253, 0.03941260650753975, 0.05091743543744087, -0.011212735436856747, -0.002799020381644368, -0.03266443312168121, 0.010086484253406525, -0.058377526700496674, -0.037165701389312744, 0.02477312833070755, 0.016653120517730713, -0.04534991458058357, 0.011076021939516068, 0.017933400347828865, 0.0236867293715477, 0.011033854447305202, 0.000525174371432513, -0.0022502467036247253, -0.003085874719545245, 0.01361027080565691, -0.0008605063776485622, -0.04991418123245239, -0.004363226238638163, -0.0013051573187112808, 0.024737942963838577, 0.02828489989042282, 0.014742910861968994, 0.019503138959407806, -0.021896762773394585, -0.01667066290974617, -0.01121677365154028, 0.0028728509787470102, -0.009949523024260998, -0.030107587575912476, 0.0337521992623806, -0.006675481330603361, -0.0326620414853096, -0.03424207866191864, 0.014202343299984932, 0.00931540410965681, -0.0015407642349600792, 0.0245631355792284, -0.01374944020062685, -0.036977335810661316, -0.021166060119867325, 0.026381412521004677, 0.021433360874652863, 0.030361775308847427, 0.0183649193495512, 0.03153727203607559, -0.010966048575937748, -0.017449641600251198 ]
Guiding Text Generation with Constrained Beam Search in 🤗 Transformers
cwkeam
March 11, 2022
constrained-beam-search
guide, nlp
https://huggingface.co/blog/constrained-beam-search
Example 2: Disjunctive Constraints We mentioned above a use-case where we know which words we want to be included in the final output. An example of this might be using a dictionary lookup during neural machine translation. But what if we don't know which word forms to use, where we'd want outputs like ["raining", "rained", "rains", ...] to be equally possible? In a more general sense, there are always cases when we don't want the exact word verbatim, letter by letter, and might be open to other related possibilities too. Constraints that allow for this behavior are Disjunctive Constraints, which allow the user to input a list of words, whose purpose is to guide the generation such that the final output must contain just at least one among the list of words. Here's an example that uses a mix of the above two types of constraints: python from transformers import GPT2LMHeadModel, GPT2Tokenizer model = GPT2LMHeadModel.from_pretrained("gpt2") tokenizer = GPT2Tokenizer.from_pretrained("gpt2") force_word = "scared" force_flexible = ["scream", "screams", "screaming", "screamed"] force_words_ids = [ tokenizer([force_word], add_prefix_space=True, add_special_tokens=False).input_ids, tokenizer(force_flexible, add_prefix_space=True, add_special_tokens=False).input_ids, ] starting_text = ["The soldiers", "The child"] input_ids = tokenizer(starting_text, return_tensors="pt").input_ids outputs = model.generate( input_ids, force_words_ids=force_words_ids, num_beams=10, num_return_sequences=1, no_repeat_ngram_size=1, remove_invalid_values=True, ) print("Output:\n" + 100 * '-') print(tokenizer.decode(outputs[0], skip_special_tokens=True)) print(tokenizer.decode(outputs[1], skip_special_tokens=True)) Setting pad_token_id to eos_token_id:50256 for open-end generation. Output: ---------------------------------------------------------------------------------------------------- The soldiers, who were all scared and screaming at each other as they tried to get out of the The child was taken to a local hospital where she screamed and scared for her life, police said. As you can see, the first output used "screaming", the second output used "screamed", and both used "scared" verbatim. The list to choose from ["screaming", "screamed", ...] doesn't have to be word forms; this can satisfy any use-case where we need just one from a list of words.
[ 0.04102357476949692, -0.02436433918774128, 0.03506217896938324, 0.029732003808021545, 0.04145964980125427, 0.14031760394573212, 0.02934158965945244, 0.018570594489574432, -0.03766308352351189, -0.006237614434212446, -0.05661722272634506, -0.0035400348715484142, -0.05355239659547806, 0.06368103623390198, -0.04227813705801964, 0.02733023464679718, 0.07041299343109131, -0.004944429732859135, 0.02774125151336193, 0.01538015529513359, 0.0436512716114521, -0.004806517157703638, 0.07485265284776688, -0.014669607393443584, 0.09415382891893387, -0.017116805538535118, -0.010240885429084301, -0.02552475407719612, -0.07450943440198898, 0.01910625956952572, -0.07972394675016403, 0.035205185413360596, 0.008459873497486115, 0.00832065474241972, 0.013435288332402706, -0.014861663803458214, -0.0873052254319191, 0.008286925032734871, 0.016204174607992172, -0.007991650141775608, -0.005080155562609434, -0.009057898074388504, -0.09415090829133987, -0.06827566772699356, -0.045251499861478806, -0.011753296479582787, -0.17275072634220123, 0.11656270176172256, -0.05652759596705437, -0.02566460706293583, -0.07422236353158951, 0.014757567085325718, -0.019386904314160347, 0.01865445449948311, -0.006263666786253452, -0.009369085542857647, -0.02804155834019184, -0.13140282034873962, 0.05900461971759796, -0.029927417635917664, 0.010585890151560307, 0.02962370775640011, 0.023418249562382698, 0.016508134081959724, 0.030026955530047417, -0.03778733313083649, -0.0017520454712212086, 0.03005276620388031, -0.04940403625369072, -0.03205154463648796, -0.016250833868980408, -0.02298072725534439, -0.1099318191409111, 0.00806498248130083, 0.014283007942140102, -0.06501054018735886, 0.013735438697040081, -0.002376205287873745, -0.03564084693789482, 0.07563051581382751, 0.02344590611755848, 0.008267984725534916, 0.074546217918396, 0.04814869910478592, 0.075337715446949, -0.053049616515636444, 0.00897501315921545, -0.055006735026836395, -0.02022688277065754, 0.04117758199572563, -0.001766359549947083, -0.11192566901445389, 0.023298198357224464, -0.054516032338142395, 0.044235959649086, -0.062104061245918274, -0.0038571590557694435, 0.03559054434299469, -0.023610232397913933, 0.04399927332997322, -0.010497791692614555, -0.036649398505687714, 0.06718005239963531, -0.013262176886200905, -0.09122815728187561, 0.08799320459365845, -0.03144800662994385, -0.028494004160165787, -0.017268309369683266, 0.05259290337562561, -0.02891155146062374, -0.03559989854693413, 0.05962289124727249, 0.054611507803201675, -0.0635131374001503, 0.014301297254860401, -0.011520221829414368, 0.07841131836175919, -0.043910544365644455, 0.003392916638404131, 0.006644444074481726, 0.03984999656677246, 0.055191922932863235, 0.03219213709235191, 0.014688648283481598, -0.0039741843938827515, -0.02039415016770363, 0.013393806293606758, -0.010607240721583366, -0.031198762357234955, -0.04296346381306648, 0.0037687867879867554, 0.016750266775488853, 0.004071434494107962, 0.019127748906612396, -0.10868272930383682, 0.012648982927203178, -0.018587300553917885, 0.014281283132731915, -0.02560214325785637, -0.0033273259177803993, 0.027223849669098854, -0.02686765231192112, 0.029443880543112755, -0.03163137659430504, 0.017699042335152626, -0.01007024571299553, 0.06797809898853302, -0.017162350937724113, 0.013670044019818306, 0.00877412874251604, 0.07018812000751495, -0.028565706685185432, -0.0649271234869957, -0.04820357635617256, 0.07108327746391296, -0.05003709718585014, -0.003788359696045518, -0.03372117504477501, -0.06680947542190552, -0.04738147184252739, 0.05029144138097763, 0.009707415476441383, -0.003981119487434626, 0.06197512894868851, -0.055715933442115784, 0.01924794539809227, 0.046174343675374985, -0.0038207329344004393, 0.06542843580245972, 0.01288113184273243, 0.0003137643216177821, 0.04249192774295807, -0.029715226963162422, 0.0010779901640489697, 0.02591424435377121, -0.014255167916417122, 0.04782313480973244, 0.01056114211678505, 0.00048232986591756344, 0.005782412830740213, -0.003543292637914419, 0.0049121747724711895, 0.05329510569572449, 0.07546667754650116, -0.05065886303782463, 0.012932725250720978, -0.045301035046577454, 0.02025892212986946, 0.015378306619822979, -0.10600505024194717, -0.02594306692481041, 0.07379598915576935, 0.001502235303632915, 0.0008281765622086823, -0.08082818984985352, -0.12807390093803406, 0.11582370847463608, 0.06067660078406334, 0.007559817284345627, 0.08053705096244812, 0.014155559241771698, -0.038215380162000656, -0.021977083757519722, -0.049248937517404556, 0.00013695101370103657, -0.03218027949333191, -0.09452798962593079, -0.001269444590434432, 0.020221145823597908, 0.001088828663341701, 0.005152789410203695, 0.04800669103860855, -0.12076731026172638, -0.02747585065662861, -0.005895538721233606, 0.0026780266780406237, 0.004957612603902817, 0.012806807644665241, -0.027848079800605774, 0.12686331570148468, -0.05196192115545273, 0.003395316656678915, -0.03479266166687012, 0.014561071060597897, 0.04552524909377098, 0.03640959411859512, 0.050511159002780914, 0.05545094609260559, -0.10683725029230118, -0.005340416915714741, 0.01836988516151905, 0.03582337126135826, 0.031036265194416046, -0.021191315725445747, -0.03456640616059303, 0.041276004165410995, 0.05704460293054581, 0.03747992962598801, -0.01423660758882761, 0.01072159968316555, 0.045205045491456985, -0.0423375703394413, 0.043568890541791916, -0.010353252291679382, -0.029977550730109215, 0.06681397557258606, -0.027205998077988625, -0.011050482280552387, 0.001671195961534977, -0.07176844775676727, 0.033238403499126434, 0.0015012036310508847, -0.04993651807308197, 0.07415545731782913, 0.02531312219798565, 0.012224535457789898, -0.013697568327188492, 0.0401495024561882, -0.011568880639970303, -0.03043360263109207, -0.01841212622821331, 0.01251217257231474, -0.07894255965948105, 0.01265623513609171, -0.06508475542068481, 0.05767745524644852, 0.009509366005659103, 0.027399122714996338, 0.008703132160007954, 0.010931580327451229, -0.023954207077622414, 0.03334047645330429, -0.00890312809497118, 0.013275166042149067, 0.0013732932275161147, 0.028659481555223465, 0.040624476969242096, -0.005541433114558458, -0.012784075923264027, -0.010800318792462349, -0.01621510088443756, 0.03158939257264137, 0.026691609993577003, -0.03116067498922348, 0.022181695327162743, 0.020415011793375015, 0.03256668895483017, 0.0031266952864825726, -0.005233521573245525, -0.014402695931494236, 0.03567848354578018, -0.03477488458156586, -0.0314176045358181, 0.011281341314315796, 0.046319302171468735, -0.01841258630156517, -0.022955164313316345, -0.01729527674615383, -0.022934110835194588, -0.004547337535768747, 0.027906320989131927, -0.025700950995087624, 0.0455811470746994, -0.01869218237698078, 0.010377498343586922, 0.015712562948465347, 0.020312979817390442, -0.10508620738983154, -0.01968088559806347, 0.004909548908472061, 0.0385809950530529, 0.0007404754869639874, -0.025075150653719902, 0.07811668515205383, 0.008354954421520233, -0.03230378031730652, 0.016597677022218704, 0.0015897277044132352, -0.021763121709227562, -0.005183822941035032, -0.006782058626413345, 0.0011673266999423504, -0.02654949016869068, 0.0022846218198537827, 0.004055387806147337, 0.004699287004768848, -0.0020240412559360266, 0.017960064113140106, 0.047092415392398834, -0.01121591404080391, -0.0009202866349369287, -0.045373737812042236, -0.003337468020617962, 0.02449779585003853, 0.04383935406804085, 0.009819329716265202, -0.03208488970994949, -0.02373412624001503, 0.015122450888156891, -0.036486685276031494, -0.0007874555885791779, 0.0034213808830827475, -0.00824944581836462, -0.0023090301547199488, -0.01999814435839653, -0.006499976385384798, 0.054910726845264435, -0.016693461686372757, -0.014500797726213932, 0.007318020332604647, -0.028773492202162743, -0.009757899679243565, -0.020046943798661232, -0.05547802895307541, -0.023077746853232384, 0.03408863767981529, -0.04945477098226547, -0.03571968525648117, -0.03902118653059006, 0.04675011336803436, 0.030234113335609436, 0.042268335819244385, -0.038899824023246765, -0.010134827345609665, 0.029186682775616646, 0.04115275293588638, 0.009845319204032421, -0.03538011759519577, 0.026738611981272697, -0.022241871803998947, 0.005629519931972027, -0.01802833192050457, 0.06372266262769699, 0.016340015456080437, 0.019115164875984192, 0.019423549994826317, 0.04282423481345177, 0.023592613637447357, 0.01542214211076498, -0.009400504641234875, -0.0029802650678902864, 0.005524188280105591, 0.017972933128476143, -0.018871158361434937, -0.004454776644706726, 0.06043200567364693, 0.012859282083809376, -0.03504478931427002, -0.015050169080495834, -0.046334732323884964, -0.007303125690668821, 0.01412903144955635, -0.00048557331319898367, 0.00264567113481462, -0.005868302192538977, -0.037803806364536285, 0.012712615542113781, 0.004668110515922308, -0.023316211998462677, 0.026954924687743187, 0.014899631030857563, -0.036453403532505035, 0.054426196962594986, -0.015454786829650402, -0.027543626725673676, 0.012317660264670849, 0.003358859568834305, 0.005187991075217724, -0.030079085379838943, -0.0323120653629303, 0.0016025002114474773, -0.01087865885347128, 0.0015071338275447488, -0.039119258522987366, -0.006814995314925909, 0.006818529684096575, 0.0007912532892078161, 0.03829372301697731, 0.004060443490743637, -0.004237087443470955, -0.014056652784347534, 0.026136601343750954, 0.021497173234820366, 0.002001503249630332, -0.025858284905552864, 0.022988928481936455, -0.013874534517526627, -0.041673511266708374, 0.012109959498047829, 0.005372487474232912, -0.03448761627078056, 0.017750712111592293, -0.0009066410129889846, 0.04488060995936394, 0.005895086098462343, 0.0068302880972623825, -0.018020814284682274, -0.024907715618610382, -0.008780166506767273, -0.028643405064940453, -0.0045755826868116856, -0.0005455109640024602, 0.013510873541235924, -0.016983451321721077, 0.023833179846405983, -0.030130427330732346, -0.05177164822816849, -0.04623814672231674, -0.003972398582845926, 0.04753589630126953, -0.037434909492731094, 0.03210034593939781, -0.01986231468617916, -0.025135861709713936, 0.017748167738318443, 0.004632741212844849, 0.025924887508153915, 0.0562182255089283, -0.016123460605740547, -0.05844825133681297, 0.013334175571799278, 0.0364900603890419, -0.03834588825702667, -0.026254398748278618, 0.007762338034808636, 0.03176620602607727, 0.06491558253765106, -0.005873509217053652, -0.01188939530402422, -0.017112815752625465, 0.04827577993273735, 0.01760965958237648, -0.01078786887228489, -0.042992003262043, -0.01689280942082405, 0.01530053187161684, 0.03553517907857895, 0.030152516439557076, -0.028652694076299667, 0.03511040285229683, 0.003443934256210923, 0.009767859242856503, -0.01116055529564619, 0.01290678046643734, 0.014639163389801979, -0.04079494997859001, 0.012547029182314873, -0.007750802673399448, -0.026486992835998535, 0.01553227100521326, 0.01621984876692295, 0.01437988318502903, 0.02449408732354641, 0.06052853539586067, 0.04433814436197281, 0.02619275450706482, 0.04087253287434578, -0.04333099350333214, -0.04660945385694504, 0.02213394083082676, -0.08053702861070633, 0.04926064610481262, 0.01054197084158659, -0.05208767205476761, 0.023829597979784012, -0.0015214027371257544, 0.019023850560188293, 0.030942240729928017, 0.0014879172667860985, 0.0006177910254336894, 0.009041867218911648, -0.017494622617959976, -0.019475501030683517, -0.0003413429076317698, -0.03415784239768982, -0.020446181297302246, -0.06292693316936493, 0.013372077606618404, -0.02311139926314354, -0.04537459835410118, -0.0056790318340063095, -0.016465242952108383, 0.006789210718125105, -0.02597169764339924, 0.002849479438737035, 0.0014064747374504805, 0.03607841208577156, 0.02706294134259224, -0.026578813791275024, 0.0004834695137105882, 0.0707094669342041, 0.046225130558013916, -0.0233493410050869, 0.0015336652286350727, 0.03666820377111435, 0.0647411122918129, 0.050576720386743546, 0.007252332288771868, -0.02081911265850067, 0.0059599727392196655, 0.01629730314016342, -0.040586020797491074, -0.04394553601741791, -0.029367083683609962, 0.05037625879049301, 0.023165281862020493, -0.02109415829181671, 0.027080679312348366, 0.03500797227025032, -0.05637674406170845, 0.02431996911764145, -0.0003509127127472311, 0.00924745574593544, 0.014581053517758846, -0.0026853291783481836, -0.05385393276810646, 0.03661210462450981, 0.005125909578055143, -0.003329185303300619, -0.014649610035121441, 0.0183099452406168, -0.0169693510979414, 0.03649378940463066, 0.03795687481760979, -0.0012314807390794158, 0.012012702412903309, -0.003826842876151204, 0.043360237032175064, -0.015881072729825974, 0.00538860447704792, 0.03332182392477989, -0.04611878842115402, 0.02675706334412098, 0.020305074751377106, -0.04823143780231476, -0.021251345053315163, -0.025964979082345963, 0.021906329318881035, 0.053022805601358414, 0.041969768702983856, 0.006486282218247652, 0.004819510504603386, 0.0035996839869767427, -0.02061028592288494, 0.051191966980695724, 0.002389633795246482, 0.033628154546022415, 0.018751798197627068, 0.03659626841545105, 0.006766191218048334, 0.007712030783295631, -0.023663751780986786, -0.005710334051400423, 0.04615118354558945, -0.00943316612392664, 0.019658587872982025, -0.01368416752666235, -0.009270554408431053, -0.008814581669867039, -0.011075478978455067, -0.02618321403861046, -0.005467457231134176, -0.010266974568367004, 0.014591421000659466, -0.01277917716652155, -0.014775070361793041, -0.015732787549495697, 0.06402266025543213, 0.008653560653328896, 0.008135946467518806, 0.03165358304977417, 0.02531776949763298, 0.07048314809799194, 0.011584986001253128, 0.013504552654922009, 0.061899688094854355, -0.015043511986732483, -0.00894963275641203, 0.0754823312163353, 0.002287144074216485, -0.0031321928836405277, 0.04169561341404915, 0.03164391964673996, 0.012228966690599918, -0.06500446796417236, 0.033223219215869904, 0.030700702220201492, 0.005609020125120878, -0.0008017068030312657, -0.02099975384771824, 0.013916080817580223, -0.027637716382741928, 0.011414767242968082, -0.031862929463386536, -0.029049856588244438, 0.006227864418178797, 0.022581681609153748, -0.001299273339100182, 0.04544452205300331, 0.048556648194789886, -0.055427901446819305, -0.023018887266516685, -0.015307091176509857, 0.006328150164335966, 0.022958166897296906, -0.02343261055648327, -0.0004388489469420165, -0.04345352202653885, -0.02030382864177227, -0.011892382055521011, -0.00417467812076211, -0.022050820291042328, -0.007073414046317339, 0.0036303596571087837, 0.029110796749591827, -0.03469008952379227, 0.03335559368133545, 0.02850199118256569, 0.03855947032570839, -0.01296084001660347, -0.014239354990422726, -0.03438858315348625, 0.0003703332331497222, 0.0025033834390342236, -0.06156129390001297, 0.009394782595336437, -0.01270648930221796, 0.031415536999702454, -0.0026003632228821516, 0.0037649425212293863, -0.02917410619556904, -0.03296699747443199, -0.003675017273053527, 0.0028427450451999903, 0.0014488251181319356, -0.03273314982652664, 0.013781358487904072, -0.0071153962053358555, 0.00457603856921196, -0.030613472685217857, -0.023413296788930893, -0.018904179334640503, -0.013321083039045334, 0.008185450918972492, -0.023264210671186447, -0.0246131531894207, 0.00038868296542204916, 0.03651457652449608, 0.022808965295553207, 0.05020381510257721, 0.03928065672516823, 0.07119608670473099, 0.01627149060368538, -0.01413604523986578, 0.0010780213633552194, -0.024149326607584953, 0.052247967571020126, -0.02388940006494522, -0.020671850070357323, -0.02122703194618225, 0.029821723699569702, -0.00060023128753528, 0.009182125329971313, -0.06954985111951828, 0.03253314271569252, -0.014245663769543171, -0.012082704342901707, 0.006555904168635607, -0.008722804486751556, 0.006558596156537533, 0.014355425722897053, 0.07506762444972992, 0.017002172768115997, 0.002336871577426791, -0.028119459748268127, 0.0008927545277401805, -0.023873569443821907, 0.03648898005485535, -0.048316046595573425, -0.004667192697525024, -0.030274851247668266, -0.011483523063361645, -0.04150152951478958, -0.027570750564336777, 0.019031450152397156, 0.03505931422114372, -0.0373464860022068, 0.014574158005416393, 0.019649308174848557, 0.021557213738560677, -0.016274720430374146, -0.003214727621525526, 0.004915689118206501, 0.015452094376087189, 0.02756025828421116, -0.006737899035215378, -0.04382826015353203, -0.006120134610682726, 0.013052305206656456, 0.0316741019487381, 0.031316958367824554, 0.023275548592209816, -0.008058231323957443, 0.006363461259752512, -0.0019069042755290866, -0.031741462647914886, 0.010447629727423191, 0.01913350820541382, -0.037988223135471344, 0.026218384504318237, 0.031535804271698, -0.025261597707867622, -0.019333090633153915, 0.0052748024463653564, 0.04301459342241287, 0.0019520685309544206, 0.025716641917824745, -0.004078044090420008, -0.03961862251162529, -0.002389113185927272, 0.008223691955208778, -0.002048624912276864, 0.06433030962944031, 0.03209352120757103, 0.03568034619092941, -0.023448383435606956, 0.01927386410534382 ]