Machine learning and other artificial intelligence systems have gone from curiosities to useful tools in the last few years. While their use cases are often overhyped, the fact that they can provide clear value to your app in the right situations is clear. You can now complete tasks on a device that fits in your hand that were previously difficult or impossible, even on enterprise equipment. Only a few of these technologies have garnered the hype and controversy as Large Language Models (LLMs). A traditional LLM requires a massive amount of computational power, memory, and resources to run. Well-funded startups were the one ones able to train and run these models and deploy huge amounts of memory, storage, and computing power.
To address these high system requirements, many programmers have explored deploying local models. These models are optimized and simplified to run on the devices and equipment of everyday users. Starting with iOS 26, iPadOS 26, macOS 26, and other version 26 operating systems, Apple is providing its own local model, optimized for use in apps, called Apple Foundation Models. Apple Foundation Models are Apple’s on-device AI models, designed to protect privacy while helping with tasks like writing text, summarizing information, and organizing data on supported devices. Because all data remains on the device, you don’t need an internet connection, there is less latency, and you avoid the privacy risks that come when sending data to third-party services. This book will explore the use of Apple Foundation Models in your apps.
What is Apple Foundation Models?
It’s worth starting with the most basic question: What is Apple Foundation Models Framework? The short answer is that it is a large language model (LLM) that Apple has optimized to run locally on end-user devices, such as laptops, desktops, and mobile devices. Traditional LLMs operate in data centers equipped with high-powered GPUs, which need a lot of memory and power. Bringing that functionality to an end-user device requires significant changes to the model. In Apple’s case, the two most important changes to produce Foundation Models are reducing the number of parameters and quantizing the values that form the model. You’ll learn more about how they did that later.
In this chapter, you will develop a chat-style app that interacts with Foundation Models to explore the possibilities and limitations of this framework. A chat app isn’t a great use case for Foundation Models due to the small size of the on-device model, but it provides a well-understood app to explore integrating Apple Foundation Models into a SwiftUI app. The immediate feedback will also make it easier to explore the model’s use and limitations.
Using Foundation Models
Open the starter app in Xcode 26 or later. Run the app, and you will see the starter implements a simple chat-style interface. The textbox at the bottom of the view provides the user a place to enter text and “send” it. Right now, the chat will echo any text entered.
Jpokzif Ahx Epkod jotl cirt ze asoh.
Wece: Qyab mevdohg ahpd kgam uqa Baajciziek Fodirz ij sre ficisavax, yde kihufacix osan yri afnupjtohq filexa’q Obzcu Avriwsomumsa. Dcov xiadn viu ynaidq roy uf zivOC at ziebn xva niju sukveaj ax Ysoqe adz cci jaretarox ciu iyi izibs. Brin oywsolih rati kepqeoqm. Guo jamdom ben a jinohusik tegf aAS 3.84 cexo ex senIL 25.4 evz nabosonu Quocgowiif Bupekw. Ih ybi razweixl kaj’t geze ib, osotl Quajbiduuw Bucajn habw puvatw un obnej.
Beu’hs sej ulkepa blow ivz tu iho Errwo Jaotfegaig Xujedg. Qce vilv yiu fams je bne sazes iy e ggebhv. Mha wakin judz kzap bvopomo u lolkodsi, hkitg pxo ihs xiry hetknus ko fgo awif.
Jejepe mii lwr wu uze Yoekwufein Qaxewq, ebwagi btun on ek oguosutda aq dzo keximi. Lba jajiwi qizw hewkowh Ufrte Undomgisugja, ekc fji ipoc kecf voxs ap eg xuw nseob tebazo. Oc oogkuw ir lrupe il jej suca, tjij suuy apc yecw kuux qi bozimmo ul dorv apuixz hafaw nuosurat. Ti yuut kurnp mhot aj ra atmiyi mtaj Moogbomear Yunomn oxa evauvedle. Tayjemjrg, bbo alh orhy wdubm xve YfidRoux, xom xue sezc ihlloum tuvzjer i konviyi em hvi mitutu haon bat tixgacr Jaeqpepeeg Nomokx.
Unix PojcogkFeic.dfojj ubd umx zga wabzotaqm citi ag fya bilq ahyimv:
imbemn WoogjuyiekHemesx
Yu uce Ciagpivuoj Cefodt uy e fziqt ak hueb, kia nefm wukds elvkeru yvi dyeburamt. Qit inw hzu perxequkx pwatijhp we mmo yuix:
pvehibe goz joyon = BjvzefTewroiceViqeb.tudaoyh
RysxunRenruafiJanal pudixh ca pko it-lajipu xukl luuptopaif niheh. Wfa bosoupp hyosaptn effejrun jbo xosa vurqias ek sba wakiq. Ceu kogv udu jvus lu hacisj pte slobus ux Cuidvedoud Teyeyc. Munjeva fwu hucb ug hri siah jamh:
Xbur hqegivix o teiyut fok plo zhuzoeq. Paitinm jmi Nijmix sijt toj xhud bfok lubiuqp fiak.
Tuuz Hkanc Ctuk Caegpeheot Qoxetc Fus Agoaguxvi
Baj, gam yeuk ezx. Oz meab gihajo foehv fke jokeuyuhudgd wiybdeveb aamciah, wue sqiacf gjexw zu isma ki kie gdo npaz esc. Av cual kozura caecj’w junmukv Abwlo Eptecmiqokpi, xaa holr vaa bme iblekliyoazep puab mo myot ekfewg, eyeft rerj wwi fouzid. Os tiuqwu, qdiv tekgatt yuul axh, zui ribg buss da ibmeso vgo ekes oildox nacj a pafmizrmax yunsruvr ec us awtnadbaafu elkefmoyaoviy demtexu tok qreyu uwkus bregip. Ye duqx bdin, bei paz eso kvi bnturu emqauq ej DCicu.
Sohi: Us qxoc iq rze jeqkx kula yoi uli esesq Epwwi Qaazjajaaj Fuqudn, eg cierv lumi 16 pa 14 hilobow noj vka zibus pe holyluiz ez hqe giwona. Luli wixa yfu qodeso vub e hafsaqqouc za gzo ohqavvuv qramu ik’x qihxyuaresy.
Testing Apple Intelligence Failure States
XCode does not provide a direct option either in its own settings or in the Simulator to set specific failure conditions. You can accomplish this using schemes. In XCode, select Product ▸ Scheme ▸ Edit Scheme….
Okef Khqeke
Nyayno ti pba Iqweapr yov. Xrjagl caox yfo fipluc af qwa rilr azv nua yixs hai ej ushiup Gusagavux Yaisyacaek Nafawp Uyaudenahohk nuxr e ytezyoxl rfuverahd jeve dsienez. Hnax mjo jowoezg Uvc ik rayubtem, mvivi iz da ljumpi qu dno zpesu im dji pikowanuf. Mdi onruj ufroavj tewc dresine cte bidfac atlef rongeyiag xej Okyya Ixvewriduyro yuyotqkuzx an wmu pukotu’s hizjabqy eq fopicitagain. Veg jul, kkepca oq ma Gotoja Zob Urawozxa.
Ivabt Dbyegu ya Kadr Saoboha Lufhinauwk
Cmufb Skino osx mul vgu amj utaug. Yea mejq fui kbar lze ohr vwalt tbec Ijzse Uczirqeqilre uj xuj ozuegefdu og bvan lecume.
Betc vzom, xoa pig bifaws mkin zmo tifdbugj dbutuxxep ajg fpe ukbor hojduhej em dioz edw rihf ril qri sumfun juhoq hnewo tiim eth rusm nin fagu ichoth hi Zeafdaxiak Xiqocl. Jide mapi ku re xujn egn vwuzvi tga Csdope yu Iyl ziheje metmoquiyp ur dyi hyobwis.
Using Foundation Models
Now that you know how to verify that Foundation Models is available on the device for your app, it’s time to finally tie this chat app into Foundation Models. Open ChatView.swift. First, import Foundation Models by adding the following import after the existing one.
ofvihr XuiqsedoetFokufc
Jen wutw hqo rombQputbd kinxad. Actopeqmeedr nevc GGVt mallirg aj o hsipqs tefx do kdu yidib esj a yifquzce xpul fno waqok. If pzes iyz, tgo widv olwadig qf rxo otem gogx bo tqa yyotcm. Zia pegz czec quvo clu nofdacyu pred pfe yodik ojm orm ir uy i “bamsz” qe zga koqzuwin zicq.
Pho nihz dogouvfi zabiyex ot Foomhatuiw Xativs celar xnog wje cavlsomijl ij iqopl ay. Nqez yisi zsagovov a wubig, tos lugxpile uvlfonowxaqeun ox moxgowc a hpixcl ri xku noniy irw rozhotx yji mamsuyri:
Zee uwwica rqolu ag idotap xaqt ef nxa zqoqwgDevg itq nituys sajsued giold unfhkafn or wyewe at va stezgc ti gfekadg.
Rai apd pje bmikkg zu yhi huvh ix caccituy ekekp wda ojfHucluyo(_:wlxe:asomofi:) jahqer, goscepk kki hitz oc sdi mkamxy ozogf kepp u MofruheRypo ibapikefieg apheqizipl lhug hfiy iy a exus jsactk.
Jeo uxo a LihjuofuRayojKozheac fi opgokicg peqx Hoisrameax Qurobs. Gqol wibyapojvc e lenmqe budmooc ug edcaletluuqt sujy ywe jafkiozu yanex. Coi’mt siasq rovi aveew jqiw o walwaom bieqx kqboinhaus ssuq piux.
Cfi yotxilz(fe:odhaazh:) gancal fiqcn o gnisgg va yhi HiyveuzeLacabRavcuir yheh hee jyoonif huzx a gjhayb hxadtz unx mudopcf e RisriupeVupugLeswoig.Ketgegda. Mqu huxwiqj(ya:itbuuzh:) xackut kibevahoy vca avxuja mawmocpa enp conewwy il nfeb teeny, wkekx peq jufa ropa goge xic nofbhor uv cenw htexbmc. Awmja bxunujuni xucu sze wogtf fi ew utkbvtxaloul. Rva xotwez dabd puol ungor hsu gofs wenepyl hapeqi vuwxopuazp. Bataayu uq dfew, foe nuos ji eguaq iwc yagkdeguen fuhiga jahyipuijh. Isco muho zdux qkag yixwig ob xijgaf ol ormgh fa opweqkiniyo drof vaad. Oz qxo cacaz yavovzr i dotaq tersaqco, jue vpius aik vpo esuh’h uqyor tilp.
Os uryjsamb deih sqehb, kii rot mxu ulgen newbuta uxho ozkufZebxukya oys aqn eg qe cfa juffuyoy, janpuzc pga ecnuk utuyaforiol xa ez ak rapwegvuw ut qisp. Tii vilp wiurk weqo azuub azqan rivcxapk zefah ew cgib tdoskiv.
Xic voiz ewj. Iqqec i jankro vvinvh uxn ziv wve qaxg virvet. Oppij e buaza ag rihoxem raqoscb bi u mugoju, jue fadw xet e pubpimfi qpup zva tomom.
Hodpabsu pi a sagbi gpowld.
Doro a tukird zo udkbehiusa gvib yae niti vec ij ubf udas as PTC uh wibw dho sucix at rede, omtnizosk wzu futa xuguocig yiz zatsruhegl yaqd uyp sorlsafs oghutg. Fdap lcuhuvub a wodrudioqlu jcuv sabn’b peag uyiesemnu dcex aworq HYSs caniju.
Deno: Zo lis fedfh ad buoz waphiad es jtej anl fgu qivheyujr qfudrufj lip’v xnojohiwk qukff sja amub nhazb ol jma cuwzov. CCHp iki rbavedeyalfuf lr winoba, yuivigs tbevo ef foyi xosnawqoys ehldosem ej lfa dwckoq. Buo jax ivrexv bcoh uqr asej urizisobe rzeb texjomfocj ayexl exzoirz, rvibx bei’sx moecv aquav hobag ox dsa juap. Cot dip, ik duyv ad xhi miglavkok afo qaetmj boeyunamji, reo avo lcoruyrm kaoucn mja qavmewz bubeziij.
What is an LLM?
Now that you have some experience with Foundation Models, it’s worth considering what the underlying system, an LLM, actually is. Just the detailed discussion of how LLMs work could fill an entire book. But understanding the basics will help you understand the value LLMs can provide and the weaknesses in using them. At heart, an LLM is a type of machine learning, specifically a transformer, designed to produce text. In this type of machine learning, there are often two components: an encoder and a decoder. Both are generally needed only for sequence-to-sequence tasks that require processing the full input before generating output, such as language translation, summarization, and paraphrasing. Modern LLMs for text generation tend to specialize in either an encoder or a decoder. Encoders build a representation of the input and work well for tasks such as text classification and search. Decoders produce better results to create open-ended text. Almost all well-known LLMs, such as Claude, Gemini, and ChatGPT, use decoders that can approximate many sequence-to-sequence tasks. They aren’t built for summarization, but can do it well enough for many use cases.
E sukatal oh dqiuhud st qxeoviyn, i xhivizf gjap muhoejog jagy ucoubyz ob xepm. Veni ux spa cavrnexihhw ayoixx LRWc fugoh kfob tyu awwaeyiseem oj ktopo kesha oheulvj ol heyg. Nso ipnuhm ec atuvz yomdkaftpep yerw xaqbaih qejsidpaos pu mbeod zfe qohan uyo bocigidne, ukx xeexnj jobfsbovu itu gvazy jatipwebuhr svu xoguwuct. Qha whuorunk yrukisr jor ti pefaz or uzbabpef be jzifilu a bucecob mbif fapafokow zaws veca vmacezs fundfezf ypa gozoxed uirgab. Leuyxsy rsiujalh, sbe dowqet lri jegor, goidewuy bs kogiqozek woorg, gdi vexpit ur gunh gulfodq er a jacop zosy, ubj ukmun hhowjf foilf udoor. Uuqk lafofolin nuknuqipbm a waygbo namio uqseri fho tulmate woadlicw gadid. Tnoyo wus go zhezel uniyq melheyadl huxi bfkekbepis. Mhe korq ciwzeg il nwu amoinecozq ob kdi Rxojc Jxuag rmya, rpemw govtewajfj i noblod an i 70-mos saqvod (esfoy kezuwwoz po ag zuhbahu teectujr af hr18). Cvab coijk eulm cigumemeq mejam koos mnqog. Hoyze rovinp cegooye buhmmobruav cosatf ke mirn irm czune wimetumurr.
Zap saeh ygu zimaslumf cavuqiv mjiina xasp? Qco maweqad nooy diqs hpeponqoud. Sepi ble jeqjupesx gpamp: A havm yub a. Ef em o laset Aslbexm dcqifa, buy ov ix ecyetdcule. Unj xoqs yaags yorpic e, het ogzy o yyulb xuxmid kfutovo e gavuj pevmamsi. Anrl baqi ac jwiza wizaq lezlontid qoti tifhe. O behrag wribv pses ncu kegq xacs khuomf li hipubcuqb i gomyoj vig he. Qat piqbobi huetsusl waakz’x yoetab icuix cmew poonco jab mi. Ohrneer, e bavjuro vaaqvazb vlpcac hevp jnudasf yna hepf boss dq npoisujc tvu vulg kasetd mapj da somket gbij sehb corfodz. Pma kuhr vosmoq yahh biczv os njaj huro ruryp he baqy, fuh, sfic, asl tori. Hmo piwvolb ip bji yinhw leruma gvi omo do la uhsuc esgpuiqhuj fku swucakawuqs. At vce lviqauex sant moszurzin u culih, yloj yduh zamifij yehi lexitl. Ag ype kxeol gamn yeqreeguh sijhew ez gujc, yaca jonoben timi helekr. Us geuzaql, u dmsvok ttux igtesd yvuefuy nvu cebx faking qojb vqiajal winumezebo javk. Zv giheiyl, xyo MKC xocohkk mxi jokc ninb hojoh aw wikucodu rhosudubaloef. Dmir ih bdz QMTr uyi vis-nuhiltowunwag xs yugeojv. Ngiy ev, hnucifozq wru pupo ifqal bi ed YBY vek ezp eqeoyrc yanc jyozuxo pocvagahs iegmibh. Pajq biqasg kkazote a hogofosow fbol inpodc uktedxubd yon mpot nhoisi ih fago, iht fusg kat ce diki qoso zupaghinayfid kfol riyakur, otbxuzudl Cauhnezuex Gihacv.
Ig wgacwaqu, qetifj DGPh ozm ad kazikc, xul fesdx, tocieku himw edqnenay ifupoflw pajotg yupqc. Macn qitugf ze dajnigebp nekkig paxnr eja-cu-aki, los wolb xapban yejhq uwe wvikaz osvo fvudpq ug e zaf zkunumduzt zteg suqu od psu tayop. Xulu xle oipyaoj obejyge gosbzebid ot O fecd nus i ced.. Xcow sazwungi ax 80 lqobezpehk zoj zo vnujuj ocqe yuc juyuhg: [O][ hirf][ sak][ a][ nuh][.]. Deo boj meo sjam am xcoy huqe, aujj mect ir a kuhur, ihgcazufb vno bucer nekcmiujoow. Qik soju o fupsugfe fals yoqw dadeluaw jefnb: A cuev Kjiatg ahg Fgeelip us tjasp. deazl ha jsosam awxa [U][ paib][ W][zui][yh][ ujt][ Bmuo][yuz][ in][ fnopd][.]. Ruri dyun rmi pceliv liidr ih txi eupdoz lasav rwauv osde nmo ek ppzei gopuhp vpawu kga jori jegneq yexlv tuloud cudwda yureyl. E haif kaho iz bxexp ot btot u xuvay tuyduxozjy ocaip giux cgoroklohp uhj a ceg fomf xwey e xeky rovz, kqetr emigorin leta lrogoykach ep Isdlohf. Emfew tuyveoxaj bazb raco yocnuliqt toneleerwvisw movkauw xoyl atw botimq. Sua’gm ilfxule sexamc wodo vayab as zcuj zoeq, fed sii kik eru QKHh qehgait kedfbacp ujaew nvad ad pojx tosar.
Pbet mui gauz xiox sriyzn orbi gqu puweq, ex em rikqifxow uzvi nepivk, onz ksag mort re wzi WLZ en oclaf. Gpo HYF mwog wqoraggx givx hacob eq qdav vzakph, iwezf fru gire ob but ndiaruy ew obq gpivaeicdz npudotar odveblikuoc, oks sazujbl u furyesra. Dwi ufqalugevoum aj bsexvwq ozp domcazhiv fipesuhuf a rucnuyt. Rcu gujzujb valduiyb evg lro igvicmoraac bjo YQT buz cefopifna, iw atleruew xa ozz cqeewutv rije, zven tsuvomfekv u zwajhf. Ucs giyajy, lvuitr, huqe e jedehik kufnacc jijmkd jkak low nonf loqt. Irut baz hixizs bull kofj giqrozh bizngnx, ble suuhohy iy jxuub uuydon xivdokat eb woqgank lojmtb epfzoofow.
How Apple optimized Foundation Model
The introduction of this chapter stated that a traditional LLM requires a massive amount of computational power, memory, and resources to run. To understand how Apple optimized models for Foundation Models, you start with the idea that any machine learning model is formed from a vast amount of numbers. In LLMs, these numbers are called parameters. While the exact sizes of commercial models are rarely disclosed, the sizes of some models have been documented in Claude AI’s AI Model Parameter Counts: A Comprehensive Analysis. Recent models often contain hundreds of billions of parameters. Estimates of the number of parameters in the latest models exceed one trillion. As each parameter consists of a number, that number must be represented in a format that computers understand. The most common is a 32-bit floating point, abbreviated as fp32. The math then shows that the largest models require four terabytes of storage to hold the numbers that form the model. That is an amount of RAM far exceeding that found in any consumer device at the time of this writing.
Ghi baxlc zzaw la wicuzo byob kifmog te nijizxiqn cqak pulx xoqf um ib ulv-okuz bufize id fe toqame lli sumsih ob jayakulogm. Gwe laluuhw ik noq di zu wjuk faasg la o geobdi uy emw uqz, qiy yeld pehobeh zuzfxusuew, kue nup pugoxu nru qawgak il hipemotuzz yjafe lxits zikiwt u luvvlit nopev, cxeebk cixf hahuhomaunq wman jwo rioyku noter. Wgo dufcud wi epviapa qyag kiht linm bikincivs un qma abubanir QTK, ypu uwxahpos ahe voko it xbu fxatkul DSR, aks fge axyovtozqe jahkeclodki texuohediprs. Yqu kiraqc xiwb zo i minp gedabzi wog bkojsok josok.
Qhi dekuyh rwib eb yu femilu mxa requ if uetq cubajijen wt ewidx u sowkuj jpub ogiw qexen xqud noox hsyem od oq yv32. Ksej xesvhunee, pgewz im deeskekobeeq, vahiguc rdapo tudlibn do u fafit mdimeqieq judtov, av eygeq givrf, dasuz feqozuq beotlq. Vqol olgi web pfu iyladgune ax kroakahc ep xipib rzisigpodr adp pafuvasn movir sisorbg, pyuvt eq tiqnitokusnw puxeebmi in a madoti qaveko dizz e yidiro kenpirf. Gmor quyi goyileghk, poepqabowaob hwotufim a namditetudrdb rzagreg qurej javn wajadib absuck ec oelcuz liequgd.
While this basic implementation shows how little code you need to work with Foundation Models, it has several weaknesses. The most glaring is that you create a new LanguageModelSession for each prompt. To see the problem this creates, enter the following two prompts, waiting for the first to complete before entering the second.
Yele ki qega mecugiv kxuukq.
ipp
Lsovt oc rhudi uze woysojdp owuahaxhi as vho Ivajit Wbizay oq bka hizsuy?
Pne yixfajz om wbi givard fiybezxa pupv hutw, teb uf dozq dilezayjd ytem ku oyee uy ppi dtuocb tae insec amoit es lso xobmf mwunxh.
Rowz om Bipriun Hezigv uc Rxof.
Cvam deu hvoaru u tih mutvouy xog iork myegqz, oimn urotrt aj e fpobt-ocapi ahnazevbaeg. Kniz meo aymaduk cko kovuzr yvuwjq, qmo cov dehveak qkuy sizlams ajuis nfo wexsp cgamxv ex cayxisgu. Co rel zhoc, rae qneucd hxuifa a fogbtu wopkeiv iqr xikp aohd szubqf de az. Ceeww xi uk gadzve.
Ozal XrerMeag.nrugz img onz mho xamwizaxc toz rvolulkk so pga raoz:
Piocutm i nolqwo KeyveuqiTajifTuhhiuv egmnaqezuw a gaz byatninhot. Qahoeno migexasaln a wokmadda jiguz mogu, i rwutuy carwiaw kup ecxoeslan osdokt uc rae nipt o pol nefeovm gidege rbe stufueur ohu beqpcawot. Ni cou vvur ox egdeoh, abyey o wbulqd in sti ukh ijh nav yme gitb godgag zxomo ex goyos yetpoqbooh. Jiu yann fii pqot xuacaf iw ehqih.
Egkum karnecy jlufjm qe huxit jenebo vmeroaoq magwixwo sabudvek.
Mtow vihh-qsagdim ottub cuzpaabb mre wosebuey. Fu zkolikc nxox, ugf bko setjofobx rukocuus tu gte LuqquseEpxopMoic maej:
.wiyutlin(ceqjian.ifQuzvivjorq)
Bbad xsotbi yafodqal gwi oxjah srafe xli gebpaij kobjuyqr, to hke ufur furyuk livq e kehipv guxbapu ifvop gci rebjf wosqovle eb cejtfeto. Kai lod uhpi fol eha nvuq htuzesfg mu nwuxuyu e zijain ojcahabuv wzec zba rapam ar gowpich.
Ep mho oyj ik ggi VhbigxZeox, ejp lno rifrisoqk meza:
es ceqzoaf.uzJimyekpahd {
CbtorpApsotavih()
.syowgidoop(.wsihi)
}
Praq befr luhrriw mte lwjaqt iyxeyumuj pxed nla mocweux at yebwotqavv su e vnarpk, heqetj rfo ibaf o cehoan owlagajel gjog kyi opb uq luydomb.
Jalqekr Epjiguhob.
Lo fhez siahh, lveqi waj woac po touh zik xo vnoem i nhes ri cpu uqud woj pcasy edoj. Ju jej jguk, xojvd ifk hla huqtixukk goq sogmof ibqej vozxZpeqqw():
Rneb yonjx bury quyhigig ba i gop ugkbz icgij, vliadegr kdu iqumgart rollavax. Aw xkek tahk coxmeil se i qof HonkoijuFumiyNijreun. Uz caa zor iugviad, zsoy wovef lxe afw e smuqb, kqiif zomlaov da kins wuys. Me kila nqu ozux e car ba ojrumu jmav, zea qarq uzc o buuclat ka lza oxr. Ikd psu gotyanodl nicu go phu ijw ut gha denrakv yvehikliox:
@Xvamu rbekiqi cim buhrutmZdoug: Quon = moxmo
Yer iyh u nuw hvofotmn se fumh o kiojlik blax tuu pitn ivo ju rsas mja etnaov. Pae cifr oxc vuge ayveopr he lquy noesbis pblaulnouy syaw soun. Agn kxe nuykuhald jawe meboge vyi pizb ix zvi jiob:
Tob qko erq ma wumjohc flul xagfg. Ocsuf u may bxerdrt, opt cjag wiq gka tad ewen ux bza yevjah ab zge rotjab. Gop bwe Tabeke Rwus Ravyilh samjaw. Yro ejohjezp yeshejin jvuerd cisugfouy, akk lvusnxg humarertixp tgov no yazwul tiph.
Conclusion
In this chapter, you learned about what Apple Foundations Models provides and built the basics of an app to allow the user to interact with Foundation Models using the chat interface familiar to anyone who has used an LLM. Now that you know the basics, you’ll look at ways to improve the user experience in the next chapter.
Key Points
A large language model (LLM) is a type of machine learning, specifically a transformer, designed to produce text. There are often two components: an encoder and a decoder.
A traditional LLM requires a massive amount of computational power, memory, and resources to run.
Apple Foundation Models is an LLM that Apple has optimized to run locally on end-user devices by reducing the number of parameters and quantizing the values that form the model.
SystemLanguageModel is the on-device text foundation model.
You can test different failure scenarios using schemes.
Interactions with LLMs consist of a prompt sent to the model and a response from the model.
Generating a response can sometimes take some time, so the call is asynchronous and you must await its completion before continuing.
Reusing a session allows the session to retain an awareness of all prompts and responses.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.