Skip to content

Instantly share code, notes, and snippets.

@mseeks
Created February 13, 2024 02:03
Show Gist options
  • Save mseeks/c1c590e8be6d14cf186f99c795c5e1c0 to your computer and use it in GitHub Desktop.
Save mseeks/c1c590e8be6d14cf186f99c795c5e1c0 to your computer and use it in GitHub Desktop.
Auto-CoT Example Pseudo-Code
def auto_cot(prompt, model):
# Initialize an empty list to store reasoning steps
reasoning_steps = []
# Generate initial reasoning step
current_step = model.generate_initial_step(prompt)
while not is_final_step(current_step):
# Append the current reasoning step to the list
reasoning_steps.append(current_step)
# Use the current reasoning step as the next prompt
prompt = form_next_prompt(current_step)
# Generate the next reasoning step
current_step = model.generate_next_step(prompt)
# Append the final step to the list
reasoning_steps.append(current_step)
return reasoning_steps
# Example usage:
model = YourLLM()
prompt = 'Explain why the sky is blue.'
reasoning_chain = auto_cot(prompt, model)
for step in reasoning_chain:
print(step)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment