-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_dual_probe.py
More file actions
55 lines (45 loc) · 1.74 KB
/
run_dual_probe.py
File metadata and controls
55 lines (45 loc) · 1.74 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
50
51
52
53
54
55
import os
import sys
from dual_probe_analysis import DualProbeAnalyzer
def main():
# Configuration
config = {
'model_name': 'meta-llama/Llama-2-13b-chat-hf',
'json_path': './data/storyanalogy_multiple_choice.json',
'batch_size': 2,
'device': 'cuda',
'representation_type': 'hidden_states'
}
print(f"Model: {config['model_name']}")
print(f"Dataset: {config['json_path']}")
print(f"Representation type: {config['representation_type']}")
print()
# Check if dataset exists
if not os.path.exists(config['json_path']):
print(f"Dataset not found at: {config['json_path']}")
print("Please check the path and try again.")
return
try:
print("Initializing dual probe analyzer...")
analyzer = DualProbeAnalyzer(config['model_name'])
print("Running analogy probe analysis...")
results, df_results = analyzer.run_dual_probe_analysis(
config['json_path'],
config['batch_size'],
config['representation_type']
)
print("\nAnalysis complete")
# Show summary statistics
analogy_cv_scores = [metrics['analogy_cv_mean'] for metrics in results.values()]
print(f"\nAnalogy CV Mean Statistics:")
print(f" Mean: {sum(analogy_cv_scores)/len(analogy_cv_scores):.3f}")
print(f" Max: {max(analogy_cv_scores):.3f}")
print(f" Min: {min(analogy_cv_scores):.3f}")
except Exception as e:
print(f"Error during analysis: {str(e)}")
print("Please check your configuration and try again.")
import traceback
traceback.print_exc()
return
if __name__ == "__main__":
main()