Máte potíže s umělou inteligencí nebo s vývojem celého balíku? Naši odborníci jsou tu pro vás: poradenství na míru, technická integrace a další. Obraťte se na [email protected].

Jak používat GPT-3, GPT-J a GPT-Neo, s výukou několika snímků

GPT-3, GPT-J a GPT-Neo jsou velmi výkonné modely umělé inteligence. Zde vám ukážeme, jak tyto modely efektivně používat díky učení několika snímků. Několikanásobné učení je jako trénování/dolaďování modelu umělé inteligence, a to jednoduše zadáním několika příkladů v podnětu.

GPT-3

GPT-3, vydaný společností OpenAI, je nejvýkonnější model umělé inteligence, který byl kdy vydán pro porozumění textu a jeho generování.

Byl vyškolen na 175 miliard parametrů, což jej činí mimořádně univerzálním a schopným porozumět téměř čemukoli!

Pomocí GPT-3 můžete dělat nejrůznější věci, jako jsou chatboti, vytváření obsahu, extrakce entit, klasifikace, sumarizace a mnoho dalšího. Chce to ale trochu cviku a správné používání tohoto modelu není snadné.

GPT-J a GPT-Neo

GPT-Neo a GPT-J jsou modely zpracování přirozeného jazyka s otevřeným zdrojovým kódem, které vytvořil kolektiv autorů. výzkumníků, kteří pracují na otevřeném zdrojovém kódu umělé inteligence (viz webové stránky EleutherAI).

GPT-J má 6 miliard parametrů, což z něj činí nejpokročilejší open-source systém zpracování přirozeného jazyka. model v době psaní tohoto článku. Jedná se o přímou alternativu k proprietárnímu modelu GPT-3 Curie společnosti OpenAI.

Tyto modely jsou velmi univerzální. Lze je použít pro téměř všechny případy zpracování přirozeného jazyka: generování textu, sentiment. analýza, a mnoho dalšího (viz níže). Jejich efektivní využití je však někdy vyžaduje praxi. Jejich doba odezvy (latence) může být také delší než u standardnějších metod zpracování přirozeného jazyka. modelů.

GPT-J i GPT-Neo jsou k dispozici v rozhraní API služby NLP Cloud. Níže vám ukazujeme získané příklady pomocí GPT-J koncového bodu služby NLP Cloud na GPU pomocí klienta Python. Pokud chcete příklady zkopírovat, vložte je, napište na adresu . nezapomeňte přidat svůj vlastní token API. Chcete-li nainstalovat klienta Python, spusťte nejprve následující příkaz: pip install nlpcloud.

Učení s několika výstřely

Učení s několika snímky spočívá v tom, že pomáhá modelu strojového učení vytvářet předpovědi pouze na základě několika údajů. příkladů. Zde není třeba trénovat nový model: modely jako GPT-3, GPT-J a GPT-Neo jsou tak velké, že mohou snadno přizpůsobit mnoha kontextům, aniž by bylo nutné je znovu trénovat.

Pokud modelu zadáte jen několik příkladů, pomůže to výrazně zvýšit jeho přesnost.

Při zpracování přirozeného jazyka jde o to, abyste tyto příklady předávali spolu se vstupním textem. Podívejte se na příklady níže!

Upozorňujeme také, že pokud vám učení několika snímků nestačí, můžete si na webu OpenAI vyladit GPT-3 a na NLP Cloud GPT-J tak, aby se model byl dokonale přizpůsoben vašemu případu použití.

Na hřišti NLP Cloud si můžete snadno vyzkoušet učení několika snímků. (zkuste to zde).

Analýza sentimentu pomocí GPT-J

Test na hřiště

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""Message: Support has been terrible for 2 weeks...
            Sentiment: Negative
            ###
            Message: I love your API, it is simple and so fast!
            Sentiment: Positive
            ###
            Message: GPT-J has been released 2 months ago.
            Sentiment: Neutral
            ###
            Message: The reactivity of your team has been amazing, thanks!
            Sentiment:""",
    min_length=1,
    max_length=1,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

Positive

Jak vidíte, skutečnost, že nejprve uvedeme 3 příklady se správným formátem, vede GPT-J k pochopení. že chceme provést analýzu sentimentu. A jeho výsledek je dobrý.

Můžete společnosti GPT-J pomoci porozumět různým pomocí vlastního oddělovače, jako je následující: ###. Něco takového bychom mohli dokonale využít: ---. Nebo jednoduše nový řádek. Pak nastavíme "end_sequence", což je parametr služby NLP Cloud, který říká GPT-J, aby po novém řádku přestal generovat obsah + ###: end_sequence="###".

Generování kódu HTML pomocí GPT-J

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""description: a red button that says stop
    code: <button style=color:white; background-color:red;>Stop</button>
    ###
    description: a blue box that contains yellow circles with red borders
    code: <div style=background-color: blue; padding: 20px;><div style=background-color: yellow; border: 5px solid red; border-radius: 50%; padding: 20px; width: 100px; height: 100px;>
    ###
    description: a Headline saying Welcome to AI
    code:""",
    max_length=500,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

<h1 style=color: white;>Welcome to AI</h1>

Generování kódu pomocí GPT-J je opravdu úžasné. Částečně je to díky tomu, že GPT-J byl vycvičen na obrovském množství kódových bázích.

Generování kódu SQL pomocí GPT-J

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""Question: Fetch the companies that have less than five people in it.
            Answer: SELECT COMPANY, COUNT(EMPLOYEE_ID) FROM Employee GROUP BY COMPANY HAVING COUNT(EMPLOYEE_ID) < 5;
            ###
            Question: Show all companies along with the number of employees in each department
            Answer: SELECT COMPANY, COUNT(COMPANY) FROM Employee GROUP BY COMPANY;
            ###
            Question: Show the last record of the Employee table
            Answer: SELECT * FROM Employee ORDER BY LAST_NAME DESC LIMIT 1;
            ###
            Question: Fetch three employees from the Employee table;
            Answer:""",
    max_length=100,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

SELECT * FROM Employee ORDER BY ID DESC LIMIT 3;

Automatické generování jazyka SQL funguje v systému GPT-J velmi dobře, zejména díky deklarativní povaze jazyka SQL, a. že SQL je poměrně omezený jazyk s relativně malými možnostmi (ve srovnání s většinou jazyků, které jsou v SQL obsaženy). programovacích jazyků).

Pokročilá extrakce entit (NER) pomocí GPT-J

Test na hřiště

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""[Text]: Fred is a serial entrepreneur. Co-founder and CEO of Platform.sh, he previously co-founded Commerce Guys, a leading Drupal ecommerce provider. His mission is to guarantee that as we continue on an ambitious journey to profoundly transform how cloud computing is used and perceived, we keep our feet well on the ground continuing the rapid growth we have enjoyed up until now. 
        [Name]: Fred
        [Position]: Co-founder and CEO
        [Company]: Platform.sh
        ###
        [Text]: Microsoft (the word being a portmanteau of "microcomputer software") was founded by Bill Gates on April 4, 1975, to develop and sell BASIC interpreters for the Altair 8800. Steve Ballmer replaced Gates as CEO in 2000, and later envisioned a "devices and services" strategy.
        [Name]:  Steve Ballmer
        [Position]: CEO
        [Company]: Microsoft
        ###
        [Text]: Franck Riboud was born on 7 November 1955 in Lyon. He is the son of Antoine Riboud, the previous CEO, who transformed the former European glassmaker BSN Group into a leading player in the food industry. He is the CEO at Danone.
        [Name]:  Franck Riboud
        [Position]: CEO
        [Company]: Danone
        ###
        [Text]: David Melvin is an investment and financial services professional at CITIC CLSA with over 30 years’ experience in investment banking and private equity. He is currently a Senior Adviser of CITIC CLSA.
""",
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

[Name]: David Melvin
[Position]: Senior Adviser
[Company]: CITIC CLSA

Jak vidíte, GPT-J umí velmi dobře extrahovat strukturovaná data z nestrukturovaného textu. To je opravdu působivé, jak GPT-J řeší extrakci entit, aniž by bylo nutné jakékoli přeškolení! Obvykle, extrakce nových typů entit (jako je jméno, pozice, země atd.) vyžaduje celý nový proces. anotace, školení, nasazení... Zde je to zcela bezproblémové.

Odpovídání na otázky pomocí GPT-J

Test na hřiště

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""Context: NLP Cloud was founded in 2021 when the team realized there was no easy way to reliably leverage Natural Language Processing in production.
            Question: When was NLP Cloud founded?
            Answer: 2021
            ###
            Context: NLP Cloud developed their API by mid-2020 and they added many pre-trained open-source models since then.
            Question: What did NLP Cloud develop?
            Answer: API
            ###
            Context: All plans can be stopped anytime. You only pay for the time you used the service. In case of a downgrade, you will get a discount on your next invoice.
            Question: When can plans be stopped?
            Answer: Anytime
            ###
            Context: The main challenge with GPT-J is memory consumption. Using a GPU plan is recommended.
            Question: Which plan is recommended for GPT-J?
            Answer:""",
    min_length=1,
    max_length=20,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

Plán GPU

Odpovědi na otázky fungují velmi dobře. Toho lze dosáhnout i pomocí jiných specializovaných modelů zpracování přirozeného jazyka, ale možná ne se stejným přesností.

Vytváření výukových programů pomocí GPT-J

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""Here is a tutorial about how to make a cake.
        
            1. Take some flour.
            2. Take some sugar.""",
    max_length=500)
print(generation["generated_text"])

Výstup:

Here is a tutorial how to make a cake.
        
                    1. Take some flour.
                    2. Take some sugar.
                    3. Take some butter.
                    4. Take some eggs.
                    5. Take some water.
                    6. Take some baking powder.
                    7. Take some vanilla.
                    8. Mix all together.
                    9. Bake in a pan.
                    10. Enjoy.
                    
Well, that's it. You can make this for your birthday or a party or you can even make it for your kids. They will love this.

Jak vidíte, je docela působivé, jak GPT-J automaticky následuje vaše počáteční formátování, a generovaný obsah je také velmi dobrý. Možná z toho vytvoříte pořádný dort (zatím jsem nezkoušela ačkoli).

Oprava gramatiky a pravopisu pomocí GPT-J

Test na na hřišti

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""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:""",
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

Nechci jít.

Pravopisné a gramatické opravy fungují podle očekávání. Pokud chcete být konkrétnější ohledně umístění chybu ve větě, možná budete chtít použít speciální model.

Strojový překlad pomocí GPT-J

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""Hugging Face a révolutionné le NLP.
            Translation: Hugging Face revolutionized NLP.
            ###
            Cela est incroyable!
            Translation: This is unbelievable!
            ###
            Désolé je ne peux pas.
            Translation: Sorry but I cannot.
            ###
            NLP Cloud permet de deployer le NLP en production facilement.
            Translation""",
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

NLP Cloud makes it easy to deploy NLP to production.

Strojový překlad obvykle vyžaduje specializované modely (často 1 pro každý jazyk). Zde se zpracovávají všechny jazyky GPT-J, což je docela působivé.

Generování tweetů pomocí GPT-J

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""keyword: markets
            tweet: Take feedback from nature and markets, not from people
            ###
            keyword: children
            tweet: Maybe we die so we can come back as children.
            ###
            keyword: startups
            tweet: Startups should not worry about how to put out fires, they should worry about how to start them.
            ###
            keyword: NLP
            tweet:""",
    max_length=200,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

People want a way to get the benefits of NLP without paying for it.

Zde je zábavný a snadný způsob, jak generovat krátké tweety podle kontextu.

Chatbot a konverzační AI s GPT-J

Test na na hřišti

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""This is a discussion between a [human] and a [robot]. 
The [robot] is very nice and empathetic.

[human]: Hello nice to meet you.
[robot]: Nice to meet you too.
###
[human]: How is it going today?
[robot]: Not so bad, thank you! How about you?
###
[human]: I am ok, but I am a bit sad...
[robot]: Oh? Why that?
###
[human]: I broke up with my girlfriend...
[robot]: """,
    min_length=1,
    max_length=20,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

Oh? How did that happen?

Jak vidíte, GPT-J správně chápe, že jste v konverzačním režimu. A velmi výkonný je, že pokud změníte tón v kontextu, odpovědi modelu se budou řídit stejným tónem. tónu (sarkasmus, hněv, zvědavost...).

O tom, jak vytvořit chatbota pomocí technologie GPT-3/GPT-J, neváhejte si ji přečíst!

Klasifikace záměrů pomocí GPT-J

Test na hřiště

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""I want to start coding tomorrow because it seems to be so fun!
            Intent: start coding
            ###
            Show me the last pictures you have please.
            Intent: show pictures
            ###
            Search all these files as fast as possible.
            Intent: search files
            ###
            Can you please teach me Chinese next week?
            Intent:""",
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

learn chinese

To je docela působivé, jak GPT-J dokáže z vaší věty rozpoznat záměr. Funguje to velmi dobře pro více složitější věty. Můžete jej dokonce požádat, aby záměr naformátoval jinak, pokud chcete. Můžete například automaticky vygenerovat Javascript název funkce, například "learnChinese".

Parafrázování pomocí GPT-J

Test na hřiště

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""[Original]: Algeria recalled its ambassador to Paris on Saturday and closed its airspace to French military planes a day later after the French president made comments about the northern Africa country. 
        [Paraphrase]: Last Saturday, the Algerian government recalled its ambassador and stopped accepting French military airplanes in its airspace. It happened one day after the French president made comments about Algeria.
        ###
        [Original]: President Macron was quoted as saying the former French colony was ruled by a "political-military system" with an official history that was based not on truth, but on hatred of France.
        [Paraphrase]: Emmanuel Macron said that the former colony was lying and angry at France. He also said that the country was ruled by a "political-military system".
        ###
        [Original]: The diplomatic spat came days after France cut the number of visas it issues for citizens of Algeria and other North African countries.
        [Paraphrase]: Diplomatic issues started appearing when France decided to stop granting visas to Algerian people and other North African people.
        ###
        [Original]: After 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.
        [Paraphrase]:""",
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True,
    min_length=0,
    max_length=50)
print(generation["generated_text"])

Výstup:

French President Emmanuel Macron hopes the diplomatic tension with Algeria will calm down. He wants to make progress in the relations with the former French colony. President Macron says he has a good relationship with his Algerian counterpart and he is glad that they have a cordial relationship. The president was quoted as saying that Algeria was ruled by a "political-military system" with an official history that was based not on truth, but on hatred of France. France cut the number of visas it issues for citizens of Algeria and other North African countries.

GPT-J provedl úpravy našeho odstavce, přičemž zachoval hlavní smysl, který je to, co parafrázování. Mohli byste dokonale podpořit GPT-J, aby vracel více původních parafrází tím, že předáváním různých příkladů na vstupu a hraním si s parametry API, jako je teplota, top_p, trest za opakování...

Shrnutí pomocí GPT-J

Test na hřiště

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""[Original]: America has changed dramatically during recent years. Not only has the number of graduates in traditional engineering disciplines such as mechanical, civil, electrical, chemical, and aeronautical engineering declined, but in most of the premier American universities engineering curricula now concentrate on and encourage largely the study of engineering science.  As a result, there are declining offerings in engineering subjects dealing with infrastructure, the environment, and related issues, and greater concentration on high technology subjects, largely supporting increasingly complex scientific developments. While the latter is important, it should not be at the expense of more traditional engineering.
        Rapidly developing economies such as China and India, as well as other industrial countries in Europe and Asia, continue to encourage and advance the teaching of engineering. Both China and India, respectively, graduate six and eight times as many traditional engineers as does the United States. Other industrial countries at minimum maintain their output, while America suffers an increasingly serious decline in the number of engineering graduates and a lack of well-educated engineers. 
        (Source:  Excerpted from Frankel, E.G. (2008, May/June) Change in education: The cost of sacrificing fundamentals. MIT Faculty 
        [Summary]: MIT Professor Emeritus Ernst G. Frankel (2008) has called for a return to a course of study that emphasizes the traditional skills of engineering, noting that the number of American engineering graduates with these skills has fallen sharply when compared to the number coming from other countries. 
        ###
        [Original]: So how do you go about identifying your strengths and weaknesses, and analyzing the opportunities and threats that flow from them? SWOT Analysis is a useful technique that helps you to do this.
        What makes SWOT especially powerful is that, with a little thought, it can help you to uncover opportunities that you would not otherwise have spotted. And by understanding your weaknesses, you can manage and eliminate threats that might otherwise hurt your ability to move forward in your role.
        If you look at yourself using the SWOT framework, you can start to separate yourself from your peers, and further develop the specialized talents and abilities that you need in order to advance your career and to help you achieve your personal goals.
        [Summary]: SWOT Analysis is a technique that helps you identify strengths, weakness, opportunities, and threats. Understanding and managing these factors helps you to develop the abilities you need to achieve your goals and progress in your career.
        ###
        [Original]: Jupiter is the fifth planet from the Sun and the largest in the Solar System. It is a gas giant with a mass one-thousandth that of the Sun, but two-and-a-half times that of all the other planets in the Solar System combined. Jupiter is one of the brightest objects visible to the naked eye in the night sky, and has been known to ancient civilizations since before recorded history. It is named after the Roman god Jupiter.[19] When viewed from Earth, Jupiter can be bright enough for its reflected light to cast visible shadows,[20] and is on average the third-brightest natural object in the night sky after the Moon and Venus.
        Jupiter is primarily composed of hydrogen with a quarter of its mass being helium, though helium comprises only about a tenth of the number of molecules. It may also have a rocky core of heavier elements,[21] but like the other giant planets, Jupiter lacks a well-defined solid surface. Because of its rapid rotation, the planet's shape is that of an oblate spheroid (it has a slight but noticeable bulge around the equator).
        [Summary]: Jupiter is the largest planet in the solar system. It is a gas giant, and is the fifth planet from the sun.
        ###
        [Original]: For 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.
        [Summary]:""",
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True,
    min_length=20,
    max_length=200)
print(generation["generated_text"])

Výstup:

Season 3 of Succession ended with Logan Roy trying to sell his company to Lukas Matsson.

Shrnutí textu je složitý úkol. GPT-J je v tom velmi dobrý, pokud mu dáte správné podmínky. příklady. Velikost shrnutí a tón shrnutí velmi závisí na příkladech, které si vyberete. jste vytvořili. Například nemusíte vytvořit stejný typ příkladů, ať už se snažíte vytvořit jednoduchý souhrn pro děti, nebo pokročilý lékařský souhrn pro lékaře. Pokud je vstupní velikost GPT-J pro vaše příklady shrnutí příliš malá, možná budete chtít GPT-J pro vaši úlohu shrnutí doladit.

Klasifikace textu s nulovým počtem snímků pomocí GPT-J

Test na hřiště

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""Message: When the spaceship landed on Mars, the whole humanity was excited
        Topic: space
        ###
        Message: I love playing tennis and golf. I'm practicing twice a week.
        Topic: sport
        ###
        Message: Managing a team of sales people is a tough but rewarding job.
        Topic: business
        ###
        Message: I am trying to cook chicken with tomatoes.
        Topic:""",
    min_length=1,
    max_length=5,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

food

Zde je snadný a účinný způsob, jak kategorizovat kus textu díky tzv. "nulovému záběru". učení", aniž byste museli předem deklarovat kategorie.

Extrakce klíčových slov a frází pomocí GPT-J

Test na hřišti

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""Information Retrieval (IR) is the process of obtaining resources relevant to the information need. For instance, a search query on a web search engine can be an information need. The search engine can return web pages that represent relevant resources.
        Keywords: information, search, resources
        ###
        David Robinson has been in Arizona for the last three months searching for his 24-year-old son, Daniel Robinson, who went missing after leaving a work site in the desert in his Jeep Renegade on June 23. 
        Keywords: searching, missing, desert
        ###
        I believe that using a document about a topic that the readers know quite a bit about helps you understand if the resulting keyphrases are of quality.
        Keywords: document, understand, keyphrases
        ###
        Since transformer models have a token limit, you might run into some errors when inputting large documents. In that case, you could consider splitting up your document into paragraphs and mean pooling (taking the average of) the resulting vectors.
        Keywords:""",
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

paragraphs, transformer, input, errors

Extrakce klíčových slov spočívá v získání hlavních myšlenek z textu. Jedná se o zajímavé zpracování přirozeného jazyka a GPT-J si s ním dokáže velmi dobře poradit. Extrakci klíčových frází viz níže (totéž, ale s s více slovy).

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""Information Retrieval (IR) is the process of obtaining resources relevant to the information need. For instance, a search query on a web search engine can be an information need. The search engine can return web pages that represent relevant resources.
        Keywords: information retrieval, search query, relevant resources
        ###
        David Robinson has been in Arizona for the last three months searching for his 24-year-old son, Daniel Robinson, who went missing after leaving a work site in the desert in his Jeep Renegade on June 23. 
        Keywords: searching son, missing after work, desert
        ###
        I believe that using a document about a topic that the readers know quite a bit about helps you understand if the resulting keyphrases are of quality.
        Keywords: document, help understand, resulting keyphrases
        ###
        Since transformer models have a token limit, you might run into some errors when inputting large documents. In that case, you could consider splitting up your document into paragraphs and mean pooling (taking the average of) the resulting vectors.
        Keywords:""",
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

large documents, paragraph, mean pooling

Stejný příklad jako výše s tím rozdílem, že tentokrát nechceme extrahovat jedno slovo, ale několik slov. (tzv. klíčovou frázi).

Popis produktu a generování reklamy

Test na hřišti

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""Generate a product description out of keywords.

        Keywords: shoes, women, $59
        Sentence: Beautiful shoes for women at the price of $59.
        ###
        Keywords: trousers, men, $69
        Sentence: Modern trousers for men, for $69 only.
        ###
        Keywords: gloves, winter, $19
        Sentence: Amazingly hot gloves for cold winters, at $19.
        ###
        Keywords: t-shirt, men, $39
        Sentence:""",
    min_length=5,
    max_length=30,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

Extraordinary t-shirt for men, for $39 only.

Je možné požádat GPT-J o vygenerování popisu produktu nebo reklamy obsahující konkrétní klíčová slova. Zde jsme pouze generujeme jednoduchou větu, ale v případě potřeby bychom mohli snadno vygenerovat celý odstavec.

Blog Post Generation

Test na hřiště

import nlpcloud
client = nlpcloud.Client("gpt-j", "your_token", gpu=True)
generation = client.generation("""[Title]: 3 Tips to Increase the Effectiveness of Online Learning
[Blog article]: <h1>3 Tips to Increase the Effectiveness of Online Learning</h1>
<p>The hurdles associated with online learning correlate with the teacher’s inability to build a personal relationship with their students and to monitor their productivity during class.</p>
<h2>1. Creative and Effective Approach</h2>
<p>Each aspect of online teaching, from curriculum, theory, and practice, to administration and technology, should be formulated in a way that promotes productivity and the effectiveness of online learning.</p>
<h2>2. Utilize Multimedia Tools in Lectures</h2>
<p>In the 21st century, networking is crucial in every sphere of life. In most cases, a simple and functional interface is preferred for eLearning to create ease for the students as well as the teacher.</p>
<h2>3. Respond to Regular Feedback</h2>
<p>Collecting student feedback can help identify which methods increase the effectiveness of online learning, and which ones need improvement. An effective learning environment is a continuous work in progress.</p>
###
[Title]: 4 Tips for Teachers Shifting to Teaching Online 
[Blog article]: <h1>4 Tips for Teachers Shifting to Teaching Online </h1>
<p>An educator with experience in distance learning shares what he’s learned: Keep it simple, and build in as much contact as possible.</p>
<h2>1. Simplicity Is Key</h2>
<p>Every teacher knows what it’s like to explain new instructions to their students. It usually starts with a whole group walk-through, followed by an endless stream of questions from students to clarify next steps.</p>
<h2>2. Establish a Digital Home Base</h2>
<p>In the spirit of simplicity, it’s vital to have a digital home base for your students. This can be a district-provided learning management system like Canvas or Google Classrooms, or it can be a self-created class website. I recommend Google Sites as a simple, easy-to-set-up platform.</p>
<h2>3. Prioritize Longer, Student-Driven Assignments</h2>
<p>Efficiency is key when designing distance learning experiences. Planning is going to take more time and require a high level of attention to detail. You will not be able to correct mistakes on the fly or suddenly pivot when kids are disengaged.</p>
<h2>4. Individual Touchpoints Are Game-Changers</h2>
<p>You can create these touchpoints through any medium you like: emails, video messages, phone calls, messages through your learning management system, comments on shared documents, etc.</p>
###
[Title]: 3 Best Free Image Converter Software Programs
[Blog article]: <h1>3 Best Free Image Converter Software Programs</h1>
<p>Best free image converters for JPG, BMP, PSD, TIF, GIF, RAW, and more</p>
<h2>1. XnConvert</h2>
<p>XnConvert is the Swiss Army knife of image converters. With XnView, you can convert any of around 500 image formats to your choice of around 80 others. If you have a rare image format that you can't open, XnView can probably convert it.</p>
<h2>2. CoolUtils Online Image Converter</h2>
<p>The CoolUtils Online Image Converter is just that—an image converter that exists completely online, no download required. Unlike some online image converters, this one does the image converting for you in real-time—no waiting on an email link.</p>
<h2>3. FileZigZag</h2>
<p>FileZigZag is another online image converter service that will convert most common graphics formats. Just upload the original image, choose the desired output, and then wait for the download link to appear on the page.</p>
###
[Title]: 4 Best Tips to Find a Girlfriend
[Blog article]: """,
    max_length=500,
    length_no_input=True,
    end_sequence="###",
    remove_end_sequence=True,
    remove_input=True)
print(generation["generated_text"])

Výstup:

<h1>Text Generation API</h1>
<h2>What is Text Generation?</h2>
<p>Text generation is the process of generating text from a block of text. It is not simply the inverse of summarization: a text generator will take a short piece of text as an input and generate a longer one.</p>
<p>For example you have the following text:</p>
Ahead of the opening of the meeting,
<p>In this case the goal of the API is to automatically generate the following:</p>
Ahead of the opening of the meeting, Prime Minister Justin Trudeau spoke to reporters at the Montreal airport where he was travelling to speak at the conference.
<p>So basically we want to leverage the output of the API as the input for the text generator, and we will then be able to generate some sentences based on the input we already have.</p>
<h2>Text generation with GPT-2</h2>
<p>We will leverage GPT-2 in order to have a starting point for the text generator. In this case, we will use the API as the input for the text generator, and we will use the output of the API as the input for GPT-2.
However, we want to fine-tune GPT-2 to generate more complex sentences and to have better results.</p>

Není to působivé? Tento vygenerovaný článek na blogu je malý, ale můžete vygenerovat mnohem delší články. Na adrese Struktura vygenerovaného blogového článku skutečně závisí na struktuře, kterou jste použili ve svých příkladech s několika snímky. Chcete-li získat složitější struktury a relevantnější obsah, je klíčem k úspěchu jemné vyladění GPT-J.

Závěr

Jak vidíte, učení několika snímků je skvělá technika, která pomáhá GPT-3, GPT-J a GPT-Neo dosáhnout úžasných výsledků. úspěchů! Klíčem k úspěchu je zde předání správného kontextu před zadáním požadavku.

I v případě jednoduchého generování textu se doporučuje předat co nejvíce kontextu, aby se usnadnilo generování textu. modelu.

Doufám, že se vám to bude hodit! Pokud máte nějaké dotazy ohledně toho, jak tyto modely co nejlépe využít, prosím. neváhejte se nás zeptat.

Julien Salinas
Technický ředitel společnosti NLP Cloud