forked from mll-lab-nu/RAGEN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_answer_examples.py
More file actions
41 lines (32 loc) · 1.38 KB
/
Copy pathshow_answer_examples.py
File metadata and controls
41 lines (32 loc) · 1.38 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
#!/usr/bin/env python3
import pandas as pd
import numpy as np
import re
def show_answer_examples():
"""Show specific examples with answer tags."""
df = pd.read_parquet('data/sokoban/train_dual_agent.parquet')
example = df.iloc[0]
prompt = example['prompt']
if isinstance(prompt, np.ndarray):
prompt = prompt.tolist()
for i, msg in enumerate(prompt):
print(f"\n=== Message {i+1} (Role: {msg['role']}) ===")
content = msg['content']
# Find and extract answer tags
answer_matches = re.findall(r'<answer>(.*?)</answer>', content, re.IGNORECASE | re.DOTALL)
if answer_matches:
print(f"Found {len(answer_matches)} answer tags:")
for j, answer in enumerate(answer_matches):
print(f" Answer {j+1}: '{answer.strip()}'")
# Show content around answer tags
lines = content.split('\n')
for line_num, line in enumerate(lines):
if '<answer>' in line.lower():
print(f"\nContext around answer (line {line_num+1}):")
start = max(0, line_num - 2)
end = min(len(lines), line_num + 3)
for k in range(start, end):
marker = ">>> " if k == line_num else " "
print(f"{marker}{lines[k]}")
if __name__ == "__main__":
show_answer_examples()