Jak działa ChatGPT…

…ale nie tylko chat GPT, ale wszystkie Wielkie Modele Językowe (LLM).

I nie tyle chodzi o opisanie używanego przez GPT algorytmu, ile o ogólne opisanie jego idei. Podane tu treści i przykłady opierają się na wpisie Stephena Wolframa na jego blogu „What Is ChatGPT Doing … and Why Does It Work?” [1].

Po obejrzeniu i przeanalizowaniu (bo chyba w przypadku AI1 chyba trudno mówić o czytaniu) ogromnej ilości tekstów (stąd Wielkie Modele Językowe) zdobywamy wiedzę na temat tego jaki wyraz (z największym prawdopodobieństwem) wystąpi po już obecnej grupie wyrazów.

Zacznijmy od czegoś prostego: wyjściowy tekst to the funniest

Korzystam z Mathematici w wersji 14.1, która daje dostęp do modelu językowego GPT2, bazującego na tekstach z sieci.

Pięć (5) najbardziej prawdopodobnych słów to:

  • “bit” -> 0.0119902,
  • “and” -> 0.0138373,
  • “moment” -> 0.0254639,
  • “part” -> 0.229557,
  • “thing” -> 0.403103

Prawdopodobieństwo 0.4 to znaczy 40%! Idźmy tym śladem. Co będzie po the funniest thing

Teraz nie jest już tak zdecydowanie, ale ciągle nieźle:

  • “s” -> 0.0362336,
  • “ever” -> 0.0480867,
  • “of” -> 0.0776113,
  • “is” -> 0.096235,
  • “I” -> 0.104976

10% na I!

Teraz najbardziej prawdopodobne jest ’ve (czyli I have).

Inteligencja podpowiada, żeby dodać ever (prawdopodobieństwo 66%!)

W kolejnym kroku dostajemy seen (55%) ,heard (15%), had (prawie 6%)…

Tu wyszło trochę gorzej, bo z najwyższym prawdopodobieństwem proponuje dać kropkę (i zakończyć zdanie — 16%). Co ma trochę sensu, bo pewno coś mogło być najśmieszniejszą rzeczą, którą widzieliśmy. Nie pójdziemy tym śladem, tylko wybierzemy którąś z kolejnych propozycji: was (13%) albo is (10%). Idziemy w czas przeszły…

Model sugeruje żeby dodać when (26%) albo zacząć opisywać tę śmieszną rzecz (the — 8%)…

I tak można bawić się dalej.

Natomiast jak już mamy nauczony model — prawdopodobieństwa nie będą się zmieniać. Zatem za każdym razem, po rozpoczęciu jakiegoś tekstu rezultaty będą takie same.

Zazwyczaj algorytm jest modyfikowany w taki sposób, żeby w kolejnych etapach wybory były dokonywane w pewny sposób, losowo. Dodawany jest kolejny parametr zwany temperaturą [2].

I teraz gdy temperatura = 0.1 możemy dostać coś takiego:

“The funniest part of this is that I’m not sure if I’m going to be able to do it.”

Gdy temperatura = 1

“The funniest and barmiest jokes you’ll hear below are on Nate Montilos, Joe Nickel ("We”

a gdy temperatura = 5

The funniest Creat excisecertropolitan Weed tightening halt curing nutrients Adams Ru soon doubling lowest How traditional infants coating sink highlighting

AI zaczyna halucynować (czyli opowiadać bzdury).

I jeszcze kilka przykładów

Tym razem tekstem wyjściowym było “Albert Einstein was a German-born theoretical physicist” a efektami działania sztucznej inteligencji coś takiego (temperatura = 1):

Albert Einstein was a German-born theoretical physicist studying alien life. In 1947, after expressing his views on Homo sapiens having health problems and claiming that relics of the Old Testament show them as beings once more, to observe the Human conversation, Einstein

czyli dosyć śmieszne, albo coś takiego (temperatura = 0.5)

Albert Einstein was a German-born theoretical physicist who formulated the theory of relativity in 1877. Einstein’s work on relativity, which has been widely cited as the basis for the modern understanding of the universe, was published in 1882, and was published in 1883. In the following year,

Całkiem sensownie…

Gdy temperatura obniżyła się do 0.1, nie pozwoliła wygenerować niczego sensownego:

Albert Einstein was a German-born theoretical physicist who was born in 1885 in the city of Berlin. He was a member of the German Academy of Sciences and the German Academy of Sciences. He was a member of the German Academy of Sciences and the German Academy of Sciences. He was a member of the German Academy of Sciences and the German Academy of Sciences. He was a member of the German Academy of Sciences and the German Academy of Sciences. He was a member of the German Academy of Sciences and the German Academy of Sciences. He was a

Żeby się tym pobawić trzeba mieć dostęp do Mathematici.

Źródła

  1. S. Wolfram, What Is ChatGPT Doing … and Why Does It Work?, Stephen Wolfram Writings, lut. 2023. [Online]. Available: https://writings.stephenwolfram.com/2023/02/what-is-chatgpt-doing-and-why-does-it-work/ [Accessed: sie. 8, 2024].
  2. S. Wolfram, The New World of LLM Functions: Integrating LLM Technology into the Wolfram Language, Stephen Wolfram Writings, maj. 2023. [Online]. Available: https://writings.stephenwolfram.com/2023/05/the-new-world-of-llm-functions-integrating-llm-technology-into-the-wolfram-language/ [Accessed: sie. 9, 2024].

  1. AI czyli Artificial Intelligence jest częściej używane niż swojskie SI (Sztuczna Inteligencja). ↩︎

Wojciech Myszka
Wojciech Myszka
dr inż. adiunkt

Tak się tylko rozglądam…