V NLP Cloud sme chceli zistiť, či sa dá GPT-J vyladiť ako inštruktážny model na správne pochopenie ľudských pokynov v prirodzenom jazyku bez použitia učenia s niekoľkými zábermi. Iné pokusy priniesli v komunite open-source zaujímavé výsledky, ako napríklad Flan-T5, BloomZ alebo Stanford Alpaca, preto sme chceli urobiť to isté na GPT-J s použitím súboru údajov Alpaca. Výsledky sú veľmi dobré!
Generatívne modely umelej inteligencie nie sú štandardne dobré v chápaní ľudských požiadaviek.
Aby tieto modely na generovanie textu pochopili, čo chcete, najlepším riešením je použiť učenie s niekoľkými zábermi. Vytvorili sme špeciálnu príručku o učení niekoľkých snímok nájdete ho tu. GPT-J je dobrým príkladom veľmi schopného modelu, ktorý správne funguje len pri učení sa pomocou niekoľkých snímok.
Aj keď zostavenie týchto príkladov zvyčajne nezaberie veľa času, pre nováčikov, ktorí chcú tieto modely umelej inteligencie správne používať, je to stále veľmi mätúce. Je oveľa jednoduchšie pýtať sa na veci prirodzene, ako by ste to robili s človekom.
Povedzme napríklad, že chcete opraviť pravopisné chyby pomocou GPT-J. Tu je príklad výzvy, ktorú musíte použiť:
I love goin to the beach.
Correction: I love going to the beach.
###
Let me hav it!
Correction: Let me have it!
###
It have too many drawbacks.
Correction: It has too many drawbacks.
###
I do not wan to go
Correction:
Ako vidíte, nie je to zložité, ale ani jednoduché. Ak GPT-J správne vyladíte, môžete ho zmeniť na "inštruktážny" model, čo znamená, že sa teraz môžete pýtať na nasledovné:
Correct spelling and grammar from the following text.
I do not wan to go
A vráti nasledujúce údaje:
I do not want to go.
Oveľa lepšie, však? Ako to môžeme dosiahnuť?
Stanfordská alpaka bola vydaná pred niekoľkými dňami. Ide o vyladenú verziu modelu Llama, ktorý vyvinula spoločnosť Facebook. Viac informácií o tomto projekte nájdete tu.
V podstate sa tímu Stanford Alpaca podarilo vytvoriť špičkový model inštrukcií vyladením Lamy na pomerne malom súbore údajov (52 tisíc príkladov), ktorý pozostával z ľudských inštrukcií. Zaujímavosťou je, že tento súbor údajov vytvorili programovo pomocou väčšieho modelu jazyka (GPT-3). Súbor údajov si môžete stiahnuť tu.
V NLP Cloude sme sa pokúsili vyladiť GPT-J pomocou tohto súboru údajov a dosiahli sme prekvapivo dobré výsledky!
Nový model Instruct GPT-J, ktorý sme vytvorili, sa teraz nachádza v centre Hugging Face, takže ho môžete ľahko používať: kliknite sem a pozrite si model.
Tu sa dozviete, ako môžete model použiť pomocou funkcie Hugging Face Transformers:
from transformers import pipeline
import torch
generator = pipeline(model="nlpcloud/instruct-gpt-j-fp16", torch_dtype=torch.float16, device=0)
prompt = "Correct spelling and grammar from the following text.\nI do not wan to go\n"
print(generator(prompt))
Tu je niekoľko podnetov, ktoré môžete vyskúšať:
Write a short story about space.\n
Generate a C++ program that sorts a list of integers in ascending order.\n
Paraphrase the following text.\nAfter a war lasting 20 years, following the decision taken first by President Trump and then by President Biden to withdraw American troops, Kabul, the capital of Afghanistan, fell within a few hours to the Taliban, without resistance.\n
Summarize the following text.\nFor all its whizz-bang caper-gone-wrong energy, and for all its subsequent emotional troughs, this week’s Succession finale might have been the most important in its entire run. Because, unless I am very much wrong, Succession – a show about people trying to forcefully mount a succession – just had its succession. And now everything has to change. The episode ended with Logan Roy defying his children by selling Waystar Royco to idiosyncratic Swedish tech bro Lukas Matsson. It’s an unexpected twist, like if King Lear contained a weird new beat where Lear hands the British crown to Jack Dorsey for a laugh, but it sets up a bold new future for the show. What will happen in season four? Here are some theories. Season three of Succession picked up seconds after season two ended. It was a smart move, showing the immediate swirl of confusion that followed Kendall Roy’s decision to undo his father, and something similar could happen here. This week’s episode ended with three of the Roy siblings heartbroken and angry at their father’s grand betrayal. Perhaps season four could pick up at that precise moment, and show their efforts to reorganise their rebellion against him. This is something that Succession undoubtedly does very well – for the most part, its greatest moments have been those heart-thumping scenes where Kendall scraps for support to unseat his dad – and Jesse Armstrong has more than enough dramatic clout to centre the entire season around the battle to stop the Matsson deal dead in its tracks.\n
Upozorňujeme, že vzhľadom na spôsob, akým bol tento model vyladený, by ste mali na konci pokynov vždy používať nové riadky.
Tento model je verziou fp16 nášho vyladeného modelu, ktorý veľmi dobre funguje na GPU so 16 GB VRAM, ako je napríklad NVIDIA Tesla T4.
Medzi verziami fp32 a fp16 sme nezaznamenali žiadny rozdiel z hľadiska kvality.
GPT-J bol už predtým veľmi dobrým modelom a teraz je ešte lepší, keď sa používa ako inštruktážny model.
Vďaka tejto technike môže teraz ktokoľvek premeniť svoj generatívny model umelej inteligencie na inštruktážny model!
Ak máte otázky alebo pripomienky k vyššie uvedenému, neváhajte sa na nás obrátiť!.
François
Dátový vedec v spoločnosti NLP Cloud