-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_fewshot_prompt.py
More file actions
49 lines (34 loc) · 1.25 KB
/
debug_fewshot_prompt.py
File metadata and controls
49 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
"""
Debug few-shot prompt formatting.
"""
import sys
import os
from pathlib import Path
# Add src to path
sys.path.append(str(Path(__file__).parent / "src"))
from adaptive.fewshot_examples import FewShotExampleLoader
def test_fewshot_prompt():
"""Test few-shot prompt formatting."""
loader = FewShotExampleLoader()
# Test problem
problem = "What is 2 + 2?"
print("🧪 Testing Few-Shot Prompt Formatting")
print("=" * 60)
# Test with different numbers of examples
for num_examples in [0, 2, 4, 8]:
print(f"\n📝 Testing with {num_examples} few-shot examples:")
print("-" * 40)
if num_examples > 0:
examples = loader.get_fewshot_examples("gsm8k", num_examples)
prompt = loader.format_fewshot_prompt(examples, problem)
else:
prompt = f"""Please solve the following problem step by step. Show your reasoning clearly and provide the final answer.
Problem: {problem}
Solution:"""
print(f"Prompt length: {len(prompt)} characters")
print(f"Prompt preview:")
print(prompt[:500] + "..." if len(prompt) > 500 else prompt)
print()
if __name__ == "__main__":
test_fewshot_prompt()