---
title: "Wikipedia + Huggingface"
video_id: QuHmoZSJ1hQ
url: https://www.youtube.com/watch?v=QuHmoZSJ1hQ
workflow_page: https://workflows-of-ai.com/workflow/wikipedia-huggingface
language: en
captions: generated
---

0:00 hey there Marcus here today I will uh
0:03 introduce two new plugins one is very
0:06 minor uh and one is a lot more
0:11 important uh so if we just start with
0:13 the minor I'm just going to say a couple
0:15 of words about it and that's the media
0:19 interpolator uh and that's basically
0:21 taking a search word or a you know a
0:23 product the name or whatever and filling
0:27 another large text field with data from
0:30 Wikipedia um it is Media Wiki agnostic
0:35 so in theory you can probably use it on
0:37 fandom.com or Wiki quote or some other
0:41 uh larger website that's using media
0:43 Wiki um but for most purposes it's just
0:48 going to use Wikipedia and it's already
0:51 uh configured to use Wikipedia by
0:54 default um and the reason for this is
0:57 basically that the
0:58 AI when they are trying to find you know
1:01 the next tokens in the vector
1:04 space sometimes it can go wrong because
1:07 of how they have been trained and there
1:10 there is it is a very hard uh issue to
1:14 do something about to be honest so the
1:17 AI will hallucinate the only way you can
1:20 get rid of this if you want truthful
1:23 answers is basically to give it context
1:25 like this is a text that has a lot of
1:27 information in it can you summarize or
1:30 answer this question what whatever you
1:32 want
1:34 right uh so that's all about the media
1:36 Wiki the more more important one is that
1:38 there's a hugging face module now uh
1:41 this is a generic module so you could
1:44 actually use it
1:45 for uh or the idea is if there's more
1:49 contributors doing a lot of other stuff
1:52 with hugging face models please get in
1:55 contact with me and we I will make you
1:58 maintainers as well
2:00 uh so we don't have a AI interpolator
2:03 hugging face but there's a hugging face
2:05 mod module with a API to huging face and
2:08 on top of that this has a AI
2:10 interpolator hugging phas module
2:13 then
2:15 um this tutorial is pretty Advanced you
2:19 have to know hugging face you have to
2:20 have account at hugging face you have to
2:22 know how to take care of uh or how how
2:26 you find the models you want to use and
2:29 so on so in hugging phase there's
2:33 500,000 plus models that someone has you
2:37 know created from scratch or scratch or
2:40 fine-tuned and so on uh but out of those
2:45 500,000 there are around 40,000 as far
2:48 as I could uh count at the current date
2:52 that has uh something called the hugging
2:55 face in inference API which means that
2:58 they are basically able to uh be run and
3:02 there's two versions of this API so I'm
3:05 just we're going to be playing with
3:07 Google schema today uh but I will
3:10 explain how this module is completely
3:12 model agnostic actually so but I will
3:15 show you here on the deploy so I'm
3:17 logged in that's why I see this by the
3:19 way there is inference API and there's
3:21 inference end points and these are the
3:23 two versions that you can use with the
3:25 module currently so there's a serverless
3:29 version that is actually free but this
3:32 comes with a lot of caveats so you know
3:35 if you're going to prototype this feel
3:37 free to use it sometimes it will just
3:39 fail because it's down you will get a
3:41 warning message that it's down it got a
3:44 400 400 or a 5003 or something like that
3:49 that's a response um but sometimes it
3:53 works uh and uh also to be clear these
3:57 free apis does not exist on every model
4:00 especially uh models that requires a lot
4:03 of uh vam from uh from expensive gpus so
4:09 because of that there is of course also
4:11 then a paid end point where you can get
4:14 a dedicated
4:16 machine um I will talk more about that
4:19 in later videos where for this video I'm
4:23 going to set up everything so it's
4:24 completely free actually you don't need
4:27 you know all the videos I do usually I
4:29 just you know say yeah I just change
4:31 this service and this service and this
4:32 service and that's fine when you know
4:34 you have a company paying for it like in
4:36 my case or I privately can pay for it
4:40 but that's not always the choice uh the
4:42 the there's not always an option right
4:46 so because of that it's pretty nice that
4:48 hugging phas lets you try out stuff like
4:51 this I will say though unless you have a
4:55 workflow on production where you can
4:57 wait for the generation or where one
5:00 part of a generation change is allowed
5:03 to fail for maybe for hours don't use
5:07 this in production pay for it if you
5:10 need it to to actually always
5:13 answer um I'm also not going to go in
5:16 that much to why this this
5:20 is so much more important than all the
5:22 other AI
5:24 models uh so sorry AI plugins but the
5:29 the guest of it is basically a lot of
5:31 these models are open source you can't
5:34 censor them you can get them to answer
5:37 like you actually write or uh you know
5:41 create images with yourself inside the
5:43 image and so on because you can find you
5:45 these you can also create these models
5:48 from
5:50 scratch uh and then just a little bit
5:54 about uh how you can find these so there
5:57 is huggingface doco models and under
6:00 there there are a lot of categories and
6:02 these categories basically map to
6:05 different rules in the AI interpolator
6:07 So today we're just going to use the
6:09 text
6:10 generation uh uh text generation task
6:15 which is here so you can see all the
6:17 modules models that exist this is based
6:20 on uh trending right now so because
6:25 Gemma was just released like I'm not
6:27 sure if it's Gemma or Gemma I say Gemma
6:30 was just released a week ago it's super
6:33 popular now of course so we're going to
6:34 use Gemma to be it and it is basically
6:37 to give it instruction so it's a typical
6:39 shat
6:41 model
6:42 um so that is the instruction oh yeah
6:45 the workflow we're going to do it's very
6:47 simple but it's just to give you an idea
6:49 what you can actually do with these mod
6:51 uh plugins so it's that we're going to
6:55 create a content type that aners
7:00 uh question or fill us out information
7:03 basically for our um for our website in
7:07 this case I'm going to create something
7:09 called software and it's going to answer
7:12 some question regarding uh well I will
7:14 use truple in this case of course so I'm
7:17 logged in here uh in Drupal
7:21 then uh I haven't done the normal
7:23 introduction by the way what Drupal is
7:25 and so on this is so complex that you
7:27 you have to know Drupal before you start
7:29 playing around with this so I'm not
7:31 going to introduce druple in this case
7:33 uh what I will switch to here is the
7:36 code right because we actually need I
7:39 just started this in D dev then what we
7:41 need is this modu uh
7:45 module
7:47 which uh
7:49 we let's see here we're going to use
7:53 this one so
7:56 D and we get the hugging face beta
8:00 and then we're going to get the AI
8:01 interor media wikip beta as
8:10 well AI interor media Wiki
8:15 oops
8:17 Wiki ah
8:22 misspelled
8:25 so and you see they get installed here
8:28 the only thing you have to think about
8:29 about here minimum stability has to be
8:30 de because these modules are still not
8:32 production ready uh so they are added I
8:36 had the AI interpolator by the way since
8:39 before just so you know but that would
8:41 of course be uh installed also then so
8:44 we just search for hugging face we're
8:45 going to use a anator huging face this
8:47 is going to install huging face core and
8:50 then the media
8:51 Wiki so we just installed this it says
8:55 that it's going to install the core as
8:57 well uh and then what we need to do is
9:00 go to configuration web service as an
9:02 hugging face config and there we have to
9:04 put a API token so that you can find
9:09 under uh let's see here it should be
9:11 under settings
9:13 and then it's under authentication maybe
9:17 no access token here we go so I will
9:20 just create a new token here
9:25 um
9:26 testing it's okay for reading
9:30 and we show this I'm just going to copy
9:32 this this will be removed by the way by
9:35 the time you see this so you can't steal
9:38 this from me we just save this and then
9:42 we have set up hugin phase so the next
9:45 uh point is that we want to create a
9:47 content type that we call software then
9:50 uh we disable
9:51 this we don't need to preview uh and we
9:55 just add Fields now then we remove the
9:58 body field we're not not going to need
9:59 that but what we want to do is to have a
10:03 plain text field that's text plane long
10:07 that we call a wikip Wikipedia article
10:12 right and this should only be one and
10:15 here we enable the AI interpolator and
10:17 we choose the rule uh Wikipedia media
10:21 Wiki and we're going to base this on the
10:24 title so I'm going to write Drupal in
10:26 the title and this is going to go into
10:27 Wikipedia search for Drupal and uh
10:30 basically fill out this field
10:32 then uh we can use direct because this
10:35 is fast uh we just want a extract I
10:39 think should be enough so I'm just going
10:41 to ask you how many users that exist
10:44 right we want to strip HTML because this
10:46 was a plain text field and we're going
10:48 to use it for context and it's better
10:51 just not to have an HTML there uh search
10:54 before fetching means that it will do a
10:56 search if I do some misspelling right
10:59 drle or something like that instead of
11:01 druple then it will kind of figure out
11:04 that it's Drupal I
11:05 mean uh then I we create another field
11:08 that is uh just uh yeah we take a form
11:13 it takes
11:14 long uh so the text
11:17 generation currently because most of the
11:19 models are not close to open a GPT 4
11:25 does not have many different uh uh field
11:30 types that it can answer to because when
11:33 we ask gp4 we can ask in a complex Jon
11:36 way so in this case it's only available
11:37 for the long text Fields so um I will
11:42 write members
11:46 here and then we set full HTML we enable
11:50 the AI
11:51 interpolator and now we're going to use
11:53 the hugging face text generation so this
11:56 is the thing that talks to text
11:58 generation ation models we're going to
12:00 use space mode and we're going to use
12:02 the Wikipedia article right uh and now I
12:07 just copy from I written it here before
12:10 so based on the following text answer
12:12 the question answer the question with
12:14 factual information no description is
12:16 needed in the answer a description what
12:18 the text says so that's
12:21 just the thing is some of these mod
12:25 models want to be very verose and in my
12:28 case I just want to know how many
12:29 members actually exists and that's it
12:33 right uh and then we just write
12:36 [Music]
12:38 um
12:39 text and we're going to use context
12:42 which is the Wikipedia article in this
12:44 case right and then we write
12:48 question how
12:50 many uh how
12:53 many
12:55 members does truple have
12:59 wait let me just do a Drupal
13:03 Wikipedia check on how to actually write
13:06 this uh let's see
13:09 here members members what did I write
13:12 how many members do ruple okay one do uh
13:15 139 and then since these are cheex
13:17 generation it helps when you kind of
13:20 force where the next thing should come
13:23 so we just write the answer and that's
13:24 what we want to fill in right under
13:27 advanced settings we have to make sure
13:29 that this weight is higher than the
13:30 Wikipedia fetching so the Wikipedia
13:32 article exists
13:34 beforehand uh these are a lot of
13:37 settings that you will have to tweak
13:39 around especially with smaller models if
13:41 you want any result that
13:43 actually is of use for you uh especially
13:47 when it actually writes text I mean in
13:49 this case I think it will be fine to
13:51 keep it as this I think actually the
13:54 Gemma even and the Gemma 2 B that runs
13:58 on a normal you know a normal laptop
14:01 with 16 GB of RAM I think that will be
14:03 able to answer
14:05 this um so we just leave it like this
14:09 right and we're going to use the free
14:11 end
14:12 point uh and I'm just going to start
14:15 writing so there is a auto complete here
14:18 and I take Gemma 2 B it save this and
14:23 then we're just going to add this
14:25 software then and we're just going to
14:27 write druple here
14:29 save
14:30 it and hopefully you see it fills in the
14:33 Wikipedia article and members 1.3 39
14:37 million members including
14:39 124,000 users actively contributing and
14:42 this is taken from this context which
14:44 means now that it's asking truthfully so
14:48 uh this is cool from many point of views
14:51 because it's asking U answering
14:53 truthfully it's using a model that's
14:56 free but that's I mean mean that's the
15:00 current state of hugging face who knows
15:01 maybe they don't keep this
15:03 free uh but it's also using a model that
15:06 you could download and fine-tune
15:08 yourself to actually write text as you
15:12 want it to be written right uh and you
15:17 could also add things that you find that
15:20 they sensor that you might be interested
15:23 in in writing about using AI right so
15:28 yeah that's basically it that's how you
15:30 use the the hugging phase and the AI
15:35 interpolator media Wiki the media Wiki I
15:37 probably won't or it might be
15:39 incorporated in some workflows in the
15:41 future but it's not more complex than
15:43 what I showed you now however the huging
15:45 phase I will come back to uh we're going
15:48 to look into fine-tuning our own models
15:51 and using that and other things how you
15:53 can set up a dedicated API endpoint and
15:56 so
15:57 on um
15:59 so yeah that's it thank you for
16:02 watching
