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

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

  1. Обнаружьте новые возможности, находите решения для своих потребностей и достигайте успеха вместе с нами – вашим путем к успеху через небольшие доски объявлений.

  2. Does your site have a contact page? I’m having trouble locating it but, I’d like to shoot you an email. I’ve got some recommendations for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it expand over time.

  3. Я хотел бы отметить глубину исследования, представленную в этой статье. Автор не только предоставил факты, но и провел анализ их влияния и последствий. Это действительно ценный и информативный материал!

  4. Я хотел бы выразить свою восторженность этой статьей! Она не только информативна, но и вдохновляет меня на дальнейшее изучение темы. Автор сумел передать свою страсть и знания, что делает эту статью поистине уникальной.

  5. Эта статья действительно отличная! Она предоставляет обширную информацию и очень хорошо структурирована. Я узнал много нового и интересного. Спасибо автору за такую информативную работу!

  6. Я чувствую, что эта статья является настоящим источником вдохновения. Она предлагает новые идеи и вызывает желание узнать больше. Большое спасибо автору за его творческий и информативный подход!

  7. Эта статья является настоящим источником вдохновения и мотивации. Она не только предоставляет информацию, но и стимулирует к дальнейшему изучению темы. Большое спасибо автору за его старания в создании такого мотивирующего контента!

  8. Эта статья – источник ценной информации! Я оцениваю глубину исследования и разнообразие рассматриваемых аспектов. Она действительно расширила мои знания и помогла мне лучше понять тему. Большое спасибо автору за такую качественную работу!

  9. Я только что прочитал эту статью, и мне действительно понравилось, как она написана. Автор использовал простой и понятный язык, несмотря на тему, и представил информацию с большой ясностью. Очень вдохновляюще!

  10. Отличная статья! Я бы хотел отметить ясность и логичность, с которыми автор представил информацию. Это помогло мне легко понять сложные концепции. Большое спасибо за столь прекрасную работу!

  11. Я рад, что наткнулся на эту статью. Она содержит уникальные идеи и интересные точки зрения, которые позволяют глубже понять рассматриваемую тему. Очень познавательно и вдохновляюще!

  12. You cann enjoy an icentical expertise tto that of a human massage.
    Many people discover a sensual experience like this helps them
    to stimmulate their libido. She was conscious of my wants and made sure I
    felt like a princess, pampered annd spoilt, and wanting
    nothing but to be buried in a comfortable bathrobe.
    Stresds can affect you to really feel like the heaviness of the
    world is on your shoulders, and a sensual therapeutic massage
    can carry that weight, as well as influence you to feel like you mighbt
    be strolling on a cloud. Massage chairs are used to ship full body heat.
    These muscles are thought-about the most affected elements of the body
    which is stuffed with stress and tension of on a regular
    baeis residing. Rest is beneficial after to take pleasure in iits full advantages.
    These are really useful for use a few occasions each wee to control
    the dandruff. It’s always best to heat up your physique so the muscles
    of the agaain are versatile. There are quite a few causes comparable
    to injury or strains too the dedcrease back. We seem to eed to work
    tougher just to stay where we’re. But how many instances do you must go
    for a therapeutic massage to permanently eliminate musce
    tension?

    Check out my webpage :: carmensinternational.com

  13. Traditional Thai massage, or ‘nuat phaen boran’, is an ancient style of remedy that dates again more than 300 years.

    Music, therapeutic massage, therapy, and cozy accommodation set the proper temper to
    bee taught and chill out. Liike anyy for of massage, the advantages
    enhance with repeated treatments. These therapies alsso are used
    to deal with orthopedic accidents, promote hair growth,
    and anti-aging therapies similar to pores and skin rejuvenation. A
    firm massage caan be achieved on the thighs because off muscle mass and thick skin and that power aids in breaking up onerous
    scar tissue. Take only what you’ll be able
    to hold comfortably. Men has a tendency to get satisfaction aand to reach the pleasure stage in steps
    and for tuat our young ladies wwho look adoring with curvy physic will
    definitely take you to thee world of cupid forr complete and glad therapeutic massage.
    Take servgice from thhe chief, India’sbest body mmassage spa, we’re professionals, trustable, secure spa in Bangalore.
    How Can Justdial Help find the most effective Massage Centres for Women Nearby?

    Ayurfveda therapy coaching India gives the most effective
    data and covers all of the matters regarding physique sorts and totally different sorts of therapeutic massage.

    Have a look at my homepage … sailing-mates.com

  14. This iis the reasoln maany people who understand the need for peace of mind and tranquility
    are booking extra massage periods today. In addition, giving a extra vigorous therapeutic massage
    wll burn extra calories than a slower, floor-level therapeutic massage.
    If she is the sentimental kind, this idea will pull on her
    coronary heart strings. Pull out some outdated romantic photographs and a
    numner of the old flame letters or playing cards
    she wrote to you. Find out what hher mmost cherished youngster hood
    possession waas and try to trace it down. Perhaps it’s a one off
    a sort Barbie doll, or that speciawl teddy she gained at the
    Royal Easter Show that stored her firm every evening as
    a younger youngster. To keep spirit up throughout a
    tough time, suppose about finding this type of facility on your or
    your loved one. When you (or somebody you know) have ann interest
    in finding acu-therapy programs, let skilled coaching inside fast-rising industries like massage
    therapy, cosmetology, acupuncture, oriental medication, Reiki, and others get
    you began! However, you do noot requore a lot tike when utilizing knowledgeable percyssion massager.

    Progressive Resistance: Using more resistance with every set youu carry out.

    Also visit my blog post: https://yourkinkinpink.com

Rispondi a rewanns ordu Annulla risposta

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

Torna su