Engenharia rápida com a API OpenAI
Fouad Trad
Machine Learning Engineer

prompt = """Q: You start with 15 books in your collection. At the bookstore, you
purchase 8 new books. Then, you lend 3 to your friend and 2 to your cousin. Later,
you visit another bookstore and buy 5 more books. How many books do you have now?
A: The answer is"""
print(get_response(prompt))
25 books
prompt = """Q: You start with 15 books in your collection. At the bookstore, you
purchase 8 new books. Then, you lend 3 to your friend and 2 to your cousin. Later,
you visit another bookstore and buy 5 more books. How many books do you have now?
A: Let's think step by step"""
print(get_response(prompt))
Passo 1: Comece com o número de livros da coleção: 15 livros
Passo 2: Compre 8 livros na livraria: 15 + 8 = 23 livros
Passo 3: Empreste 3 livros ao amigo: 23 - 3 = 20 livros
Passo 4: Empreste 2 livros ao primo: 20 - 2 = 18 livros
Passo 5: Vá a outra livraria e compre mais 5: 18 + 5 = 23 livros
Portanto, você tem 23 livros agora.
example = """ Q: The odd numbers in this group add up to an even number: 9, 10, 13, 4, 2. A: Adding all the odd numbers (9, 13) gives 22. The answer is True. """question = """ Q: The odd numbers in this group add up to an even number: 15, 13, 82, 7. A: """prompt = example + question print(get_response(prompt))
Somando os ímpares (15, 13, 7) dá 35. A resposta é False.
Prompts multi-etapas

Prompts multi-etapas

Prompts chain-of-thought



Pode ser feito definindo múltiplos prompts ou um prompt que gera múltiplas respostas.
self_consistency_instruction = "Imagine três especialistas completamente independentes que raciocinam de formas diferentes respondendo a esta pergunta. A resposta final é obtida por voto da maioria. A pergunta é: "problem_to_solve = "If there are 10 cars in the parking lot and 3 more cars arrive. Half the original number of cars leave. Then, half of the current number of cars arrive. How many cars are there in the parking?"prompt = self_consistency_instruction + problem_to_solve print(get_response(prompt))
Especialista 1: Vamos passo a passo [...] Portanto, o total de carros no
estacionamento é 8 + 4 = 12.
Especialista 2: Primeiro, vamos calcular [...] Portanto, o total de carros no
estacionamento agora é 5 + 2 = 7 carros.
Especialista 3: Inicialmente, há 10 carros [...] Assim, a resposta final é 8 + 4 = 12
carros no estacionamento.
Com base no voto da maioria, a resposta final é que há 12 carros no
estacionamento.
Engenharia rápida com a API OpenAI