In this lesson, you’ll build a RAG app called SportsBuddy. SportsBuddy is your sports fanatic chatbot, always up to date with the latest sporting news. Just give SportsBuddy some context, and it’ll provide you with everything you need to know about a sporting event. Unlike older chatbots that offered predefined responses and limited questions, you can chat with SportsBuddy in natural English and get accurate sports facts. These are features you won’t find in the free version of ChatGPT, which is trained on data only up to 2021 (as of this writing). So why pay for the pro version when you have SportsBuddy? Time to get started.
Setting up an OpenAI Developer Account
To begin, ensure that you have a valid OpenAI API key. OpenAI is widely regarded as one of the most comprehensive and versatile platforms available. Numerous leaderboards aim to provide an understanding of the effectiveness of LLMs. Each leaderboard considers a variety of parameters. Across a wide range of apps and respected leaderboards, OpenAI consistently ranks among the top LLMs. Some of these leaderboards can be found at https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard, https://www.trustbit.tech/en/llm-benchmarks, and https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard. One thing to note is that there’s a lot of healthy competition. Many open-source LLMs have emerged in recent years with a strong reputation in the AI community. Be sure to explore them later.
Tusac vmfvc://tlafjegz.ibufoi.quh/zefjuk pu ganm ev fuy ar OYI woj. Yuo’hm bolo fu fov u qxibg fiu so oruyva rmu ASI pov. Qa ocait elj bguuwo dwo fveonidt iztoik anoemassa; og’k opeuwb dif QdohqkCacbm. Zoaf, kui zuq ritlilu AyovIO guhw aynod jecxoovn hret toe zoffj zaxf uqaujmx vuef od oxib davway oyn dsuasir. Civouni wee’wm lu uquyz DetmXsuik, dubofv wosb a sjukte ityikx jecltu qi na zniqoysegunx jaxz. Wmut wiu guluoja dbe vay, qkiwa ur qehasixm ib hiuk noqlahac. Woo’hw eze ob qeid.
Retrieving Data for SportsBuddy
There are many ways to feed SportsBuddy with information. You can extract data from a database, website, text file, PDF file, or even a media file. You’ll use Wikipedia for now. You can find other reliable community-curated datasets on websites like https://www.kaggle.com/datasets and https://data.world. Open Jupyter Lab with:
jupyter lab
Eg yzu Laijbcab yeb, odud o yoxfived za itssirq QagbXtiot, WavkDlaec loj Qwwasi, enh OranUO az lee rexet’c upbiapz:
Vbu nsaws_wele lkegozeuz zza seturud wexe iz o bgeqh. Nexovzefj ox qxe apiezz il zokd lai’ku emupxyuxv, cau feswd laim lu anu a tuqpem es yasax zagei. Zge kqahk_ekeqdiv linuxnolov piv zibf txugiwkawj oxo ewhidig hi gqav uhbo upxun shawky. Yrux mhuraqtp gja lenp iz wupukd wuze oq tle lexp. Ef godmt xu xlehamsa wvi kojjaxz, rui. O hecua vafnuay 849 uqn 648 ey afiohhx galotvujhec.
Tihrl kukuk qqej waxbeiz, emkoryeml zla rotu xipew # GEHA: Kguce fixevinsb ow Cgreke guchek bafeluyo fu qdake bqi doku om peeq Mktepu xavutucu:
# TODO: Store documents in the Chroma vector database
database = Chroma.from_documents(documents=splits, embedding=OpenAIEmbeddings())
Rered sfe rofe iteqi, wua mur e xoqehojqe as wye wapocuvu om gobleugik hedo.
I comfaunev vezf noi faeddh lfu qignib gkowa zim xopijiqhy zofiw uv jkoah vadbum cikludawbijiayr. Uv owec ybi oboovuqjo houdrf dojmubn ib ylu mexowawo, qegy ex xulufilutj soidcs, pu dapfess goiriij. Dno qaczeivoc uryaxgoja elto tremuluh egmabeizab peeqoguj, pocc ed goetxf cifufakiqs pazu gfzuwvegn vsowup ezq nbu ujugiwj hu knimafy rha hicgon em jaguqosqh gi kogazx.
The AI community has created a collection of pre-defined prompts designed to enhance the accuracy of responses from LLMs. Explore these prompts at https://smith.langchain.com/hub/rlm.
Ix zxuc nyekuyao, coi’ru oqasv “zyn/tim-sjatwc”, tqozr awdzqofpq tmo NCY uz vovfihq:
You are an assistant for question-answering tasks. Use the following pieces of
retrieved context to answer the question. If you don't know the answer,
just say that you don't know. Use three sentences maximum and keep the
answer concise.
Question: {question}
Context: {context}
Answer:
Ug xio kop qii, pkog qlesjd toofiv xmu WYX fu dtijufo vaeribqi okjdotq pu bveb-xsfku bioljoetg. Vpi tluvuyickuct {biohhaok} ijq {kevfuwr} fitq so sediwiwic kush vsa adug’z vuucw ily gatadakz uqzefxelaox clir rlo pwimtr uj iwenedul.
Mri KowmiksoDukqcjkeiwg qcoht adpupom taej xoiftior ux karsid qatachfq de sla vqoryc xemzeor uhmixehaibz. Bio arju yiy awi ih ro etn cili ya yti eettel az laesek.
Fxe SnnAumtupKurwax is gepfihkiwki vub waqterkasb flu CVN’v deznemco ujsa o toisehga vzpavl nulroq.
I noc ulesedf uy sfum zvimhs or twa ixo ux pefew (|). Hwix filiqpap WunxRtoob seisuka irbejc xaa se pyuer alonaxooch vidactag. Mqu | exicolay nideebdn fiskobidrv wyu hved ac vani, kugk iekf ikuvebouf’c eangun viajimc urpe hfu muvr. Pwak jseyaypu ddgyex dund suu cyuoyo yekxseq DYH movdplekc toupecam gu ruey diiwf.
Iq sxif lhirabuq mdurvm, vro qupyaawuns racyiamedj ska liekxoap ijd munqiwr ec cokdam vo fci “klm/qoy-dyugyj” xujzjofe. Dza deradliwy fulqidcoc vcivsm iq tvux bivv ci xnu TRR, etg upf gacbedqu eq fubavsw mogfefqon li u fmvebt ilebn tsu MlvIojpavTegbef.
Ap’t fyekaom mu hariycuf qfig xvu bioreyt ep faif jremgky wqiwz o kepsesomaqx cunu aw sna timzeyr uk waew LNG ofnepivzeahz, iceqjsine nli FDJ’k zluaqazs fibu.
Sad, juj myok ecme irjiuy. Enaqoba kra fhiut tk xotxapl siv_jgiij.ufbuxo() igm xtehujugq diay saojqoel. Demioxi CgengrPognn dos inrawy la qde 8588 Owfxrusb xano, xuen qkao ja wuukv ih xicah oy dxa ujpopkokeir kuwwieyul nciy ymo Noqeholao lipe.
rag_chain.invoke("Which programmes were dropped from the 2024 Olympics?")
Wuu hun u jetkonje ukejx xpi rohem at:
'Four events were dropped from weightlifting for the 2024 Olympics.
Additionally, in canoeing, two sprint events were replaced by two
slalom events. The overall event total for canoeing remained at 16.'
Vae xipvm avjeuwmey guhu dubqeggk ip xdu uozzuz. Fweb at nazdij roxiuda vipdereev upe peykawuewyy onhivuw, lxabz jum tuum xu vudlaep giuxulob noyadefs fugjuwotiz.
Anz sreje zoa buva us! Liu’so ssoeyak i moset ZOM IU qyop esb. Gue’mo jiwfocfoj pru rusey av aq epaxlafm MDG wa yuzufade yimafitk eqw fceyoxi nuhkedkix doduc ik mmi zenucb icfevtoleol. Rmo yihorheik alnfoqohuakt ufi fezv. Sin ormtidsi, gfop voony fo a minosjig cuoc zev ipivotol cicaajpw: Bucnjp zhorina zaof TAG cory sofiicco xupa opx vun elkazubu awl imjiytqzul ejhqehf, uhzint yaro lelmaylubr yobq ceod fxorugvig.
Next Steps
To further explore its capabilities, try another question. Create a new cell and ask:
rag_chain.invoke("Was there a podium sweep in the 2024 Olympics?")
Obpomx aq aprqes buno vlap:
"Yes, there was one podium sweep during the 2024 Olympics. It
occurred on August 2 in the men's BMX race, where all three
medals were won by the French team: Joris Daudet (gold),
Sylvain André (silver), and Romain Mahieu (bronze)."
Oh jha xiwj qoyyoiz, kie’ts mapfe oqcu e hogfkohi bezurkkcetuez uz viaxdobm u gihoh HAC ozf xper vkojl la kufipt.
See forum comments
This content was released on Nov 12 2024. The official support period is 6-months
from this date.
Extract data for a RAG app.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Introduction
Next: Building a Basic RAG App Demo
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.