AI in Action: BASIC CONCEPTS ABOUT LLM

LLMs - Large Language Models

LLMs are neural networks that can process and generate natural language text.

Midjourney Bot
APP
 — Today at 19:22
LLMs are neural networks that can process and generate natural language text. - Image #1 @Ahdpea8
Midjourney Bot APP — Today at 19:22 LLMs are neural networks that can process and generate natural language text. - Image #1 @Ahdpea8

TRAINING PHASE

They are trained on a dataset of billions of sentences using unsupervised learning techniques. In the training process LLMs learn what is the most likely word to came next to the previous one based on huge amount of data.

INPUT BY USER

LLMs accept as input a text prompt by a user and in relation with it generate in output text, word by word (token by token).

GENERATION OF THE OUTPUT

The generation process consists in predicting the next word on the base of previously generated words. LLMs are trained in doing this without any consciousness which is a prerogative of the human mind.

In this example we use as data the dystopian novel “Nineteen Eighty-Four – 1984” by English writer George Orwell, published on 1949.

Using the text of the novel as a data source, the following tables were produced. I show only a part of them:

Word/TokenOccurrences
the6249
of3309
a2482
and2326
to2236
was2213
He1959
It1864
in1759
that1457
had1311
his1079
you1011
not827
with771
as672
At654
they642
for615
IS614
but611
be608
on604
were583
there559
Winston526
him512
i495
which443
s439
one426
or424
Word/TokenWord NextScoreProbability
ofthe7430,01139
Itwas5890,00903
inthe5740,00880
Hehad3550,00544
hewas2730,00418
onthe2300,00352
wasa2250,00345
therewas2230,00342
tothe2120,00325
OBrien2050,00314
tobe2030,00311
andthe2030,00311
hadbeen2020,00310
theparty1950,00299
atthe1830,00280
thathe1670,00256
fromthe1610,00247
witha1580,00242
didnot1480,00227
thatthe1470,00225
ofa1450,00222
ofhis1450,00222
outof1420,00218
wasnot1300,00199
withthe1270,00195
hecould1240,00190
itis1240,00190
inhis1230,00188
ina1220,00187
Theywere1220,00187
seemedto1150,00176
wasthe1100,00169
couldnot1090,00167
hesaid1090,00167
thesame1030,00158
forthe1010,00155
bythe950,00146
fora920,00141
intothe920,00141
shehad870,00133
asthough820,00126
theyhad800,00123
thatit800,00123
havebeen790,00121
anda780,00120
ithad770,00118
Theother760,00116
ofthem760,00116
tohim750,00115
thetelescreen750,00115
BIGBROTHER730,00112

This is a simple diagram to understand how the text is generated word by word.

For example, if I start with BIG, LLM will probably generate BROTHER, and continuing we can produce this sentence:

BIGBROTHERwasasortofthethought
Probability0,001120,00050,003450,000950,001040,000230,00087

By using “prompt” mechanism you can ask ChatGPT for what you want using the natural language.

But how ChatGPT “UNDERSTAND” text inserted by the user?

The text is transformed and each word represented by a code that computer can processed.

A way to represent individual words is Word2Vec technique in natural language processing (NLP), in which each word is represented by a vector (a set of numbers). This helped a computer to assign a meaning to the word.

Word2Vec stands for “words as vectors”. It means expressing each word in your text corpus in n-dimensional space. The word’s weight in each dimension defines it for the model.

The meaning of the words is based on the context defined by its neighboring words where they are associated.

A simple example of word representation using the Word2Vec approach in two-dimensional space.

Man = [1,4]

Woman = [1,3]

Manager = [4,2]

Actress = [4,1]

Manager-Man+Woman=Actress
[4,2][1,4][1,3][4,1]


In the following picture we have the graphic representation.

This is what happens when you sent some prompt to ChatGPT.

  1. The text is converted and split in tokens;

[10,10], [10,31], [10,15], [14,44], [8,5], …

(you, are , an, ICT, specialist, with, a, lot, of, experience)

  1. An algorithm (like ChatGPT) makes some prediction and output text word by word.

[10,10],…

(you,can,have, an, important, and, well-paid, job)

Let us now analyze some techniques to better exploit the potential of ChatGPT.

DIRECTIONAL PROMPTING

If you submit the same question to ChatGPT many times, you will likely receive different answers.

How can you use directional prompting in order to get more precise answer?

You have to give more information and to be more descriptive when you define a prompt. You have to give clear instruction. This will help the model to understand of what you want. If you ask for generic question, you receive generic answer.

Generic question:

More specific question:

More contextual and specific question:

OUTPUT FORMATTING

If you want to have a specific output or format of the output from ChatGPT, for example CSV (Comma Separated Values), Microsoft Excel, Microsoft Word or simply txt or maybe code as well, you have to specify as in the following examples.

We want statistical data in CSV format:

[01] openai.com;

[02] KENNETH WARD CHURCH, Emerging Trends Word2Vec, IBM 2016;

Leave a Reply

Your email address will not be published. Required fields are marked *