Curate Reasoning data with Claude-3.7 Sonnet
Prerequisites
Steps
1. Setup environment vars
export ANTHROPIC_API_KEY=<your_api_key>"""Example of reasoning on simple questions using curator."""
import os
from datasets import load_dataset
from bespokelabs import curator
class Reasoner(curator.LLM):
return_completions_object = True
def prompt(self, input):
return input["question"]
def parse(self, input, response):
"""Parse the LLM response to extract reasoning and solution."""
content = response["content"]
thinking = ""
text = ""
for content_block in content:
if content_block["type"] == "thinking":
thinking = content_block["thinking"]
elif content_block["type"] == "text":
text = content_block["text"]
elif content_block["type"] == "redacted_thinking":
print("Redacted thinking block! (notifying you for fun)")
input["claude_thinking_trajectory"] = thinking
input["claude_attempt"] = text
return input3. Configure the Anthropic model
4. Generate Data
Example Output
question
claude_thinking_trajectory
claude_attempt
Api Reference
Last updated