Petr Tsvetkov commited on
Commit
2d03034
β€’
1 Parent(s): e027012

Update the parameters

Browse files
generation_steps/examples.py CHANGED
@@ -1,7 +1,7 @@
1
  import config
2
  from api_wrappers import hf_data_loader
3
 
4
- N_EXAMPLES = 5
5
 
6
 
7
  def get_example_prompt_end_to_start(start_msg, end_msg):
 
1
  import config
2
  from api_wrappers import hf_data_loader
3
 
4
+ N_EXAMPLES = 15
5
 
6
 
7
  def get_example_prompt_end_to_start(start_msg, end_msg):
generation_steps/metrics_analysis.py CHANGED
@@ -34,6 +34,10 @@ def rouge2_fn(pred, ref):
34
  return ROUGE.compute(predictions=[pred], references=[ref])["rouge2"]
35
 
36
 
 
 
 
 
37
  BERTSCORE = evaluate.load('bertscore', cache_dir=config.CACHE_DIR)
38
 
39
 
@@ -45,13 +49,30 @@ def gptscore_fn(pred, ref):
45
  return gpt_eval.compute(prediction=pred, reference=ref)
46
 
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  METRICS = {
49
- "gptscore": gptscore_fn,
50
  "bleu": bleu_fn,
51
  "meteor": meteor_fn,
52
  "rouge1": rouge1_fn,
53
  "rouge2": rouge2_fn,
 
54
  "bertscore": bertscore_fn,
 
 
55
  }
56
 
57
 
@@ -98,6 +119,13 @@ def correlations_for_group(group):
98
  f"{metric}_pearson": group[f"{metric}_related"].corr(group[f"{metric}_independent"], method="pearson"),
99
  f"{metric}_spearman": group[f"{metric}_related"].corr(group[f"{metric}_independent"], method="spearman")
100
  })
 
 
 
 
 
 
 
101
  return pd.Series(functools.reduce(operator.ior, correlations, {}))
102
 
103
 
 
34
  return ROUGE.compute(predictions=[pred], references=[ref])["rouge2"]
35
 
36
 
37
+ def rougeL_fn(pred, ref):
38
+ return ROUGE.compute(predictions=[pred], references=[ref])["rougeL"]
39
+
40
+
41
  BERTSCORE = evaluate.load('bertscore', cache_dir=config.CACHE_DIR)
42
 
43
 
 
49
  return gpt_eval.compute(prediction=pred, reference=ref)
50
 
51
 
52
+ CHRF = evaluate.load("chrf")
53
+
54
+
55
+ def chrf_fn(pred, ref):
56
+ return CHRF.compute(predictions=[pred], references=[[ref]])["score"]
57
+
58
+
59
+ TER = evaluate.load("ter")
60
+
61
+
62
+ def ter_fn(pred, ref):
63
+ return TER.compute(predictions=[pred], references=[[ref]])["score"]
64
+
65
+
66
  METRICS = {
67
+ # "gptscore": gptscore_fn,
68
  "bleu": bleu_fn,
69
  "meteor": meteor_fn,
70
  "rouge1": rouge1_fn,
71
  "rouge2": rouge2_fn,
72
+ "rougeL": rougeL_fn,
73
  "bertscore": bertscore_fn,
74
+ "chrF": chrf_fn,
75
+ "ter": ter_fn
76
  }
77
 
78
 
 
119
  f"{metric}_pearson": group[f"{metric}_related"].corr(group[f"{metric}_independent"], method="pearson"),
120
  f"{metric}_spearman": group[f"{metric}_related"].corr(group[f"{metric}_independent"], method="spearman")
121
  })
122
+ for other_metric in METRICS:
123
+ correlations.append({
124
+ f"ind_{metric}_rel_{other_metric}_pearson": group[f"{other_metric}_related"].corr(
125
+ group[f"{metric}_independent"], method="pearson"),
126
+ f"ind_{metric}_rel_{other_metric}_spearman": group[f"{other_metric}_related"].corr(
127
+ group[f"{metric}_independent"], method="spearman")
128
+ })
129
  return pd.Series(functools.reduce(operator.ior, correlations, {}))
130
 
131
 
generation_steps/synthetic_end_to_start.py CHANGED
@@ -7,7 +7,7 @@ import statistics
7
  from api_wrappers import grazie_wrapper, hf_data_loader
8
  from generation_steps import examples
9
 
10
- GENERATION_MULTIPLIER = 3
11
  REL_INSERTIONS_THRESHOLD = 0.5
12
  GENERATION_ATTEMPTS = 5
13
 
 
7
  from api_wrappers import grazie_wrapper, hf_data_loader
8
  from generation_steps import examples
9
 
10
+ GENERATION_MULTIPLIER = 2
11
  REL_INSERTIONS_THRESHOLD = 0.5
12
  GENERATION_ATTEMPTS = 5
13
 
generation_steps/synthetic_start_to_end.py CHANGED
@@ -7,7 +7,7 @@ import statistics
7
  from api_wrappers import grazie_wrapper
8
  from generation_steps import examples
9
 
10
- GENERATION_MULTIPLIER = 3
11
  REL_DELETIONS_THRESHOLD = 0.75
12
  GENERATION_ATTEMPTS = 5
13
 
 
7
  from api_wrappers import grazie_wrapper
8
  from generation_steps import examples
9
 
10
+ GENERATION_MULTIPLIER = 2
11
  REL_DELETIONS_THRESHOLD = 0.75
12
  GENERATION_ATTEMPTS = 5
13