Far scrivere un romanzo a GPT-3

La copertina (generata dall'AI) di "La Porta del Tempo: battaglia contro il Signore dei Sogni"

Si fa un gran parlare (e sparlare…) di ChatGPT e delle potenzialità della sua Intelligenza Artificiale.

Ho visto tanti esempi, buoni e cattivi, allarmati o eccitati, di usare questa potentissima tecnologia. Ma quasi tutti erano solo chiacchierate con ChatGPT, oppure poco più.

Ho voluto provare qualcosa in più: usare le API (Application Programming Interface) di ChatGPT spingendo un po’ più in là il confine dell’esplorazione. Visto che sicuramente la capacità di questo LLM (Large Language Model) è tutta sulla linguistica, mi è parso naturale esplorare la possibilità di fargli scrivere un romanzo in autonomia. E, vista la mia passionaccia per la narrativa, ho scelto di provare a fargli usare come “stile di scrittura” il mio.

Beh, to make a long story short: successo pieno! Se volete vedere il risultato, ecco qui il link al PDF: https://bit.ly/PortaDelTempo

Impressionante no? Vi voglio dettagliare i passaggi.

  1. Ho creato uno script di una sessantina di linee di codice e gli ho passato in input un unico spunto iniziale: “Il protagonista Jon Doe è un pluriassassino ed è stato condannato ad essere proiettato tre secoli nel futuro. Si risveglia nel futuro ma non ha cognizione del suo stato e dovrà ricostruire la sua identità“.
  2. Con lo script ho fatto generare una quarantina di passaggi della trama del romanzo con un tecnica di “proponi – riassumi – proponi…” in cui non ho dato nessun contributo umano alla generazione del testo.
  3. Ho usato l’ultimo riassunto ottenuto per far generare (sempre via API) sia il titolo (“La Porta del Tempo: battaglia contro il Signore dei Sogni“) che l’immagine di copertina (quella che trovate in testa all’articolo) e alcune illustrazioni (qui ho usato la API images/generations cioè quella di DALL-E).

Qui il passaggio più complesso: addestrare un modello al mio stile di scrittura. Ho proceduto così:

  1. Ho raccolto una buona fetta di mia “produzione letteraria” (circa 150.000 parole, cioè 600.000 caratteri) e ho spezzettato il testo in 300 “chunk” da una pagina circa (by the way: codice Python scritto mediante ChatGPT, tanto per gradire).
  2. Con un altro script ho dato in pasto i trecento prompt a GPT-3 chiedendo di estrarne una sintesi minimale. Ho impacchettato il tutto usando le sintesi come “prompt” e i testi originali come “completion” e ho addestrato in fine-tuning un nuovo modello di GPT-3 (per i curiosi si chiama “davinci:ft-andrea-bonvicini:stileab-2023-01-15-14-50-14“)
  3. Ho preso il primo spunto del romanzo suggerito da GPT-3 al passo 2 e gli ho fatto generare la prima pagina del romanzo, intitolata “La stanza era vuota“. Beh, vi posso giurare che lo stile collima con il mio in maniera davvero impressionante…

Al termine dell’elaborazione (nota da ricordare: l’unico input umano sono poche righe di testo per lo spunto iniziale) ho tutto direttamente in un documento Word generato in automatico e quel che mi basta è formattarlo con qualche click, impaginare le immagini… et voilà! (ecco qui di nuovo il link al PDF: https://bit.ly/PortaDelTempo)

A questo punto avrei potuto continuare il loop e fargli generare le altre pagine ma mi è bastato, anche perché usare le API di GPT-3 ha un costo. Già, il costo: meno di 35 dollari… di cui la gran fetta (32-33$ dollari circa) per addestrare il modello linguistico.

In buona sostanza, una volta addestrato il modello con il mio personale stile di scrittura, potrei generare romanzi “a manetta” al costo di un paio di dollari l’uno…

Lesson learned, ora:

  • la potenza degli strumenti è davvero impressionante;
  • per sfruttarla ChatGPT è una bella interfaccia semplice e intuitiva, ma le API possono dare ottime soddisfazioni in termini di automazione e di settaggio fine del risultato;
  • se vuoi ottenere testi consistenti è necessario il fine-tuning di un modello;
  • fare il fine-tuning è piuttosto semplice (GPT-3 mette a disposizione una serie di strumenti CLI che velocizzano il tutto e non è male l’idea di coinvolgere sempre GPT-3 nel processo di definizione prompt-completion);
  • bastano (e probabilmente avanzano) 300 coppie prompt-completion per addestrare il modello.

Ringraziamenti

Spunti di programmazione li ho trovati in due esperti, uno italiano e uno statunitense:

A loro i miei più sentiti ringraziamenti!

Far scrivere un romanzo a GPT-3

2.401 commenti su “Far scrivere un romanzo a GPT-3

  1. Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across. Seo Hizmeti Skype : live:by_umut

  2. I strongly recommend stay away from this platform. My personal experience with it has been only frustration and doubts about deceptive behavior. Proceed with extreme caution, or better yet, seek out a more reputable service to meet your needs.

  3. I urge you steer clear of this platform. My personal experience with it has been only disappointment as well as suspicion of deceptive behavior. Proceed with extreme caution, or better yet, look for a more reputable service for your needs.

  4. Мы рекомендуем посетить веб-сайт https://telegra.ph/Internet-magazin-Rybachok-Vash-vernyj-sputnik-v-mire-rybnoj-lovli-04-09-2.

    Кроме того, не забудьте добавить сайт в закладки: [url=https://telegra.ph/Internet-magazin-Rybachok-Vash-vernyj-sputnik-v-mire-rybnoj-lovli-04-09-2]https://telegra.ph/Internet-magazin-Rybachok-Vash-vernyj-sputnik-v-mire-rybnoj-lovli-04-09-2[/url]

  5. I�m often to blogging and i really appreciate your content. The article has actually peaks my interest. I�m going to bookmark your web site and maintain checking for brand spanking new information.

  6. Мы рекомендуем посетить веб-сайт https://telegra.ph/Internet-magazin-Rybachok-Vash-nadezhnyj-pomoshchnik-v-mire-rybolovstva-04-09-3.

    Кроме того, не забудьте добавить сайт в закладки: [url=https://telegra.ph/Internet-magazin-Rybachok-Vash-nadezhnyj-pomoshchnik-v-mire-rybolovstva-04-09-3]https://telegra.ph/Internet-magazin-Rybachok-Vash-nadezhnyj-pomoshchnik-v-mire-rybolovstva-04-09-3[/url]

  7. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Seo Hizmeti Skype : live:by_umut

  8. Мы рекомендуем посетить веб-сайт https://telegra.ph/Internet-magazin-Rybachok-Vash-nadezhnyj-pomoshchnik-v-mire-rybolovstva-04-09-2.

    Кроме того, не забудьте добавить сайт в закладки: [url=https://telegra.ph/Internet-magazin-Rybachok-Vash-nadezhnyj-pomoshchnik-v-mire-rybolovstva-04-09-2]https://telegra.ph/Internet-magazin-Rybachok-Vash-nadezhnyj-pomoshchnik-v-mire-rybolovstva-04-09-2[/url]

  9. I urge you steer clear of this site. My own encounter with it has been only disappointment and suspicion of fraudulent activities. Proceed with extreme caution, or better yet, seek out an honest site to meet your needs.

  10. Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across.Seo Hizmeti Skype : live:by_umut

  11. Fantastic! I recently read your post and I’m blown away. Your analysis on this topic is extremely valuable. I’ve learned so much and can’t wait to read more. Your work is inspiring!

  12. Fantastic! I just read your blog post and I’m blown away. Your perspective on the topic is spot-on. I’ve learned so much and am eager to see what you write next. Thanks for sharing!

  13. Мы рекомендуем посетить веб-сайт https://telegra.ph/Internet-magazin-Rybachok-Mesto-gde-rybalka-nachinaetsya-s-vybora-snaryazheniya-04-09.

    Кроме того, не забудьте добавить сайт в закладки: [url=https://telegra.ph/Internet-magazin-Rybachok-Mesto-gde-rybalka-nachinaetsya-s-vybora-snaryazheniya-04-09]https://telegra.ph/Internet-magazin-Rybachok-Mesto-gde-rybalka-nachinaetsya-s-vybora-snaryazheniya-04-09[/url]

  14. Hi there! This is my first comment here so I just wanted to give
    a quick shout out and tell you I truly enjoy reading your
    blog posts. Can you recommend any other blogs/websites/forums that cover the
    same subjects? Many thanks!

  15. Wow! I recently read your article and I’m thoroughly impressed. Your insight on the topic is spot-on. I’ve gained a new perspective and can’t wait to see your next post. Your work is inspiring!

  16. Woah! I’m really digging the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s difficult to
    get that “perfect balance” between user friendliness and visual appearance.
    I must say you have done a awesome job with this. Also, the blog loads very quick for
    me on Chrome. Excellent Blog!

    my web site … vpn special code

  17. Мы рекомендуем посетить веб-сайт https://telegra.ph/Internet-magazin-Rybachok-Vash-nadezhnyj-pomoshchnik-v-mire-rybolovstva-04-09.

    Кроме того, не забудьте добавить сайт в закладки: [url=https://telegra.ph/Internet-magazin-Rybachok-Vash-nadezhnyj-pomoshchnik-v-mire-rybolovstva-04-09]https://telegra.ph/Internet-magazin-Rybachok-Vash-nadezhnyj-pomoshchnik-v-mire-rybolovstva-04-09[/url]

  18. naturally like your web site however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth on the other hand I will surely come again again.

  19. This is really interesting, You�re a very skilled blogger. I�ve joined your feed and look forward to seeking more of your magnificent post. Also, I�ve shared your site in my social networks!

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Torna su