Tutti i problemi menzionati di seguito sono tratti da GSM8K set di dati e sono testati utilizzando OpenAI GPT-3.5 Turbo Istruzioni modello con configurazioni predefinite.

Testeremo varie tecniche specificatamente sul seguente problema aritmetico:

Jennifer purchased 40 cans of milk at the store before meeting her 
classmate Mark, who was also buying milk. Jennifer bought 6 additional
cans for every 5 cans Mark bought. If Mark purchased 50 cans, how many
cans of milk did Jennifer bring home from the store?

La risposta corretta al problema di cui sopra è 100 litri.

UN sparo si riferisce essenzialmente a un esempio. Lo zero-shot è una tecnica di suggerimento di base in cui viene posta una domanda al modello senza fornire alcuna dimostrazione. Questa tecnica, in generale, produce risultati favorevoli in modelli più ampi che sono stati addestrati su grandi quantità di dati.

Richiesta:

Q: {{ question }}
A:

Produzione:

 Jennifer brought home 76 cans of milk from the store.

Nella richiesta precedente non abbiamo anteposto alla domanda alcuna dimostrazione, il che ha impedito ai modelli di fornire la risposta corretta al problema aritmetico. I problemi di ragionamento e di buon senso raramente producono risultati soddisfacenti con suggerimenti a colpo zero. Pertanto, è essenziale includere esempi quando si affrontano tali problemi.

Con la richiesta di pochi scatti, forniamo al modello un piccolo numero di dimostrazioni, note anche come esemplari. Questi esempi servono a guidare il modello in modo che le domande successive possano essere gestite in modo simile. Il numero di dimostrazioni necessarie varia in base alla complessità del problema e allo specifico modello in uso.

Richiesta:

Q: Ken created a care package to send to his brother, who was away at boarding school. Ken placed a box on a scale, and then he poured into the box enough jelly beans to bring the weight to 2 pounds. Then, he added enough brownies to cause the weight to triple. Next, he added another 2 pounds of jelly beans. And finally, he added enough gummy worms to double the weight once again. What was the final weight of the box of goodies, in pounds?
A: 16

Q: Mark has a garden with flowers. He planted plants of three different colors in it. Ten of them are yellow, and there are 80% more of those in purple. There are only 25% as many green flowers as there are yellow and purple flowers. How many flowers does Mark have in his garden?
A: 35

Q: James writes a 3-page letter to 2 different friends twice a week. How many pages does he write a year?
A: 624

Q: Albert is wondering how much pizza he can eat in one day. He buys 2 large pizzas and 2 small pizzas. A large pizza has 16 slices and a small pizza has 8 slices. If he eats it all, how many pieces does he eat that day?
A: 48

Q: Betty is saving money for a new wallet which costs $100. Betty has only half of the money she needs. Her parents decided to give her $15 for that purpose, and her grandparents twice as much as her parents. How much more money does Betty need to buy the wallet?
A: 5

Q: {{ question }}
A:

Produzione:

76

Sebbene questa tecnica funzioni bene nell’affrontare problemi difficili, il modello potrebbe comunque non riuscire a trovare risultati soddisfacenti nei problemi di ragionamento aritmetico. Questo perché il modello non riesce a ragionare sui passi immediati.

Catena di pensiero a pochi colpi (CoT) il suggerimento fornisce al modello alcuni esempi per guidarlo attraverso il processo di raggiungimento di una soluzione. Questa guida, nota anche come passaggi di ragionamento intermedi, è fondamentale per aiutare il modello a elaborare i passaggi e generare logicamente l’output desiderato.

Richiesta:

Q: James writes a 3-page letter to 2 different friends twice a week. How many pages does he write a year? 
A: He writes each friend 3*2=6 pages a week So he writes 6*2=12 pages every week That means he writes 12*52=624 pages a year. The answer is 624.

Q: {{ question }}
A:

Produzione:

 Jennifer bought 40+6/5*50=40+12*10=40+120=160 cans of milk. The answer is 160.

Nell’output precedente, il modello ha tentato di ragionare attraverso i passaggi ma è arrivato alla risposta finale errata. Osserviamo che questa discrepanza può essere attribuita all’irrilevante esempio fornito. Esistono due modi per affrontare questo problema: fornire al modello più esempi o garantire che gli esempi forniti siano pertinenti. Di seguito, proviamo a correggere questo problema con un esempio pertinente.

Richiesta:

Q: Mark has a garden with flowers. He planted plants of three different colors in it. Ten of them are yellow, and there are 80% more of those in purple. There are only 25% as many green flowers as there are yellow and purple flowers. How many flowers does Mark have in his garden?
A: There are 80/100*10=8 more purple flowers than yellow flowers. So in Mark's garden, there are 10+8=18 purple flowers. Purple and yellow flowers sum up to 10+18=28 flowers. That means in Mark's garden there are 25/100*28=7 green flowers. So in total Mark has 28+7=35 plants in his garden. The answer is 35.

Q: {{ question }}
A:

Produzione:

 For every 5 cans Mark bought, Jennifer bought 6 additional cans. So for 50 cans, Jennifer bought 6/5*50=60 additional cans. In total, Jennifer bought 40+60=100 cans of milk. Therefore, Jennifer brought home 100 cans of milk from the store.

La risposta finale ottenuta è ora corretta. Considera il compito, la scelta del modello e la rilevanza degli esempi, poiché tutti contribuiscono ad arrivare alla soluzione corretta.

UN modello linguistico assistito da programma (PAL) non è una tecnica di suggerimento; si tratta invece di un’applicazione di ingegneria tempestiva. Similmente a CoT, PAL mira a ragionare sui passaggi intermedi. Tuttavia, invece di utilizzare il testo normale come passaggi di ragionamento, PAL utilizza passaggi programmatici intermedi utilizzando il runtime programmatico come l’interprete Python.

Richiesta:

Q: James writes a 3-page letter to 2 different friends twice a week. How many pages does he write a year? 
A: #James has
number_of_friends=2

#He writes each friend 3-page letter each time.
page_letter_size=3

#He writes twice to each friend in a week.
number_of_times_written_to_friend=2

#Total pages written in a week to each friend
pages_written_to_each_friend_per_week=page_letter_size*number_of_times_written_to_friend=6

#So, total pages written by him per week,
total_pages_each_week=pages_written_to_each_friend_per_week*number_of_friends=12

#Number of weeks in a year
total_weeks_in_a_year=52

#That means he writes,
total_pages_written_in_year=total_pages_each_week*total_weeks_in_a_year=624
#pages per year.

The answer is 624.

Q: {{ question }}
A:

Produzione:

#Jennifer initially bought 40 cans of milk.
initial_cans_bought=40

#For every 5 cans Mark bought, Jennifer bought 6 additional cans.
additional_cans_bought=6
mark_cans_bought=50

#So, for every 5 cans Mark bought, Jennifer bought 6 additional cans.
additional_cans_bought=6
mark_cans_bought=50

#Number of times Mark bought 5 cans
number_of_times_mark_bought=mark_cans_bought/5=10

#Total additional cans bought by Jennifer
total_additional_cans_bought=additional_cans_bought*number_of_times_mark_bought=60

#Total cans of milk brought home by Jennifer
total_cans_brought_home=initial_cans_bought+total_additional_cans_bought=40+60=100

The answer is 100 cans of milk.

Anche con l’esempio irrilevante che non è riuscito a fornire una risposta corretta utilizzando la tecnica CoT a pochi scatti, PAL è riuscito a trovare la soluzione finale corretta.

In una situazione in cui non sono disponibili dimostrazioni per la tecnica della catena di pensiero (CoT) a pochi colpi, un approccio semplice ed efficace consiste nel chiedere al modello stesso di ragionare attraverso i passaggi intermedi. Questa è chiamata catena di pensiero zero-shot (CoT). Puoi raggiungere questo obiettivo aggiungendo un testo simile a “Pensiamo passo dopo passo…” alla domanda immediata. Questa semplice tecnica ha mostrato risultati eccezionali.

Richiesta:

Q: {{ question }}
A: Let's think step by step...

Produzione:


1. Jennifer initially bought 40 cans of milk.
2. For every 5 cans Mark bought, Jennifer bought 6 additional cans.
3. Since Mark bought 50 cans, Jennifer bought 6 additional cans for every 5 cans, which means she bought (6/5) x 50 = 60 cans.
4. Therefore, Jennifer brought home a total of 40 + 60 = 100 cans of milk from the store.

Dall’esempio sopra, osserviamo che il modello ragiona con successo attraverso i passaggi e arriva alla soluzione corretta senza richiedere esempi o indicazioni.

Albero del pensiero (ToT) Il quadro comporta l’esplorazione di potenziali soluzioni in un modo simile alla navigazione in una struttura ad albero di pensieri, simile alla risoluzione dei problemi umani. Questo approccio offre la possibilità di ripercorrere i passaggi quando necessario, rispecchiando il modo in cui gli esseri umani possono rivalutare e adattare il proprio pensiero durante il processo di risoluzione dei problemi. In sostanza, ToT mira a replicare la natura adattiva e iterativa del ragionamento umano attraverso tentativi ed errori.

Sulla base del framework ToT, Dave Hulbert ha proposto il suggerimento dell’albero del pensiero. Questa tecnica utilizza un approccio semplice a prompt singolo, chiedendo al modello di valutare i passaggi intermedi.

Richiesta:

Identify and behave as three different experts that are appropriate to answering this question.
All experts will write down the step and their thinking about the step, then share it with the group.
Then, all experts will go on to the next step, etc.
At each step all experts will score their peers response between 1 and 5, 1 meaning it is highly unlikely, and 5 meaning it is highly likely.
If any expert is judged to be wrong at any point then they leave.
After all experts have provided their analysis, you then analyze all 3 analyses and provide either the consensus solution or your best guess solution.

Following is the question:
Q: {{ question }}
A:

Produzione:


Expert 1: Math Expert
Step 1: Calculate the total number of cans of milk purchased by Mark.
Mark bought 50 cans of milk.
Score: 5 (highly likely)

Step 2: Calculate the number of cans of milk purchased by Jennifer before meeting Mark.
Jennifer purchased 40 cans of milk.
Score: 5 (highly likely)

Step 3: Calculate the number of additional cans of milk purchased by Jennifer for every 5 cans Mark bought.
For every 5 cans Mark bought, Jennifer bought 6 additional cans.
Score: 5 (highly likely)

Step 4: Calculate the total number of cans of milk purchased by Jennifer.
Jennifer bought 40 + (6/5)*50 = 40 + 60 = 100 cans of milk.
Score: 5 (highly likely)

Step 5: Conclusion
Jennifer brought home 100 cans of milk from the store.
Score: 5 (highly likely)

Expert 2: Retail Expert
Step 1: Determine the average number of cans of milk purchased by customers at the store.
Based on previous sales data, the average number of cans of milk purchased by customers is 10.
Score: 4 (likely)

Step 2: Calculate the total number of cans of milk purchased by Mark.
Mark bought 50 cans of milk.
Score: 5 (highly likely)

Step 3: Calculate the number of cans of milk purchased by Jennifer before meeting Mark.
Jennifer purchased 40 cans of milk.
Score: 5 (highly likely)

Step 4: Calculate the total number of cans of milk purchased by Jennifer.
Jennifer bought 40 + (6/5)*50 = 40 + 60 = 100 cans of milk.
Score: 5 (highly likely)

Step 5: Conclusion
Jennifer brought home 100 cans of milk from the store.
Score: 5 (highly likely)

Expert 3: Psychology Expert
Step 1: Analyze Jennifer's behavior and decision-making process.
Jennifer may have purchased 40 cans of milk based on her own needs and preferences.
Score: 4 (likely)

Step 2: Analyze Mark's behavior and decision-making process.
Mark may have purchased 50 cans of milk based on his own needs and preferences.
Score: 4 (likely)

Step 3: Consider the influence of social norms and peer pressure.
Jennifer may have felt pressured to buy more cans of milk after seeing Mark's purchase.
Score: 3 (somewhat likely)

Step 4: Analyze the impact of Jennifer's decision to buy additional cans for every 5 cans Mark bought.
Jennifer may have made this decision based on a desire to keep up with Mark or to appear generous.
Score: 3 (somewhat likely)

Step 5: Conclusion
Jennifer brought home 100 cans of milk from the store, possibly influenced by social norms and peer pressure.
Score: 3 (somewhat likely)

Consensus Solution:
Based on the analysis of all three experts, it is highly likely that Jennifer brought home 100 cans of milk from the store. The math expert's analysis provides a solid calculation, while the retail expert's analysis takes into account the average number of cans purchased by customers. The psychology expert's analysis adds a different perspective by considering the influence of social norms and peer pressure. Overall, the consensus solution is that Jennifer brought home 100 cans of milk from the store.

La tecnica ToT impiegata nell’esempio precedente fornisce una soluzione accurata. Vale la pena ricordare che il prompt ToT utilizzato è tratto da Suggerimenti per il ToT di Dave Hulbert. Tuttavia, uno svantaggio di questa tecnica è un aumento significativo della dimensione del prompt.

Oltre alle tecniche ingegneristiche sopra menzionate, è possibile adottare alcuni metodi aggiuntivi per risolvere problemi di ragionamento aritmetico. Tuttavia, è importante notare che queste tecniche: Catena di pensiero automatica (Auto-CoT), Autocoerenza, Ragionamento automatico e utilizzo degli strumenti (ART)E Richiesta attiva – vanno oltre lo scopo di questo articolo.

Fonte: towardsdatascience.com

Lascia un commento

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