Alex Cabrera commited on
Commit
3d72bf8
1 Parent(s): 9cbdbe1
.zeno_cache/folders.pickle CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ec0a6ccf9debf1c16781445c4b9106080d00478b0559469336db7c7b7b9711c8
3
- size 5
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19281bb6fc631cdb795cea9f902f9465c8ff5409e82a301b7591f01ee4af8ad4
3
+ size 24
.zeno_cache/reports.pickle CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5a57816ff3f04b1bdc6a6d5a1d175d1e47567d142418d61c26cc68a9ce1fdbc1
3
- size 495
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44eec79c11cdc8f4e8714169e443e66d5179006a7820090853a53938da1730c7
3
+ size 4518
.zeno_cache/slices.pickle CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:dd65105a5888dad5c884bdf3843c502a0f9c39e39812df8812b669e3a1a0ad31
3
- size 562
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9a43792055fe2c3b9618c8df10df889113b25a580f57eaad709f8d8228e8344
3
+ size 1447
__pycache__/model.cpython-38.pyc ADDED
Binary file (4.15 kB). View file
model.py CHANGED
@@ -2,9 +2,18 @@ import os
2
 
3
  import numpy as np
4
  import pandas as pd
5
- from inspiredco.critique import Critique
6
 
7
- from zeno import ZenoOptions, distill, metric, model
 
 
 
 
 
 
 
 
 
 
8
 
9
  # client = Critique(api_key=os.environ["INSPIREDCO_API_KEY"])
10
 
@@ -28,9 +37,10 @@ def pred_fns(name):
28
  model_df[["text", "translation"]], on="text", how="left"
29
  )
30
  df_join = df_join.merge(embed_df, on="text", how="left")
31
- return df_join["translation"].fillna(""), [
32
- np.fromstring(d[1:-1], sep=",") for d in df_join["embed"]
33
- ]
 
34
 
35
  return pred
36
 
@@ -46,7 +56,9 @@ def bert_score(df, ops):
46
  metric="bert_score", config={"model": "bert-base-uncased"}, dataset=eval_dict
47
  )
48
 
49
- return [round(r["value"], 6) for r in result["examples"]]
 
 
50
 
51
 
52
  @distill
@@ -62,7 +74,9 @@ def bleu(df, ops):
62
  dataset=eval_dict,
63
  )
64
 
65
- return [round(r["value"], 6) for r in result["examples"]]
 
 
66
 
67
 
68
  @distill
@@ -78,7 +92,9 @@ def chrf(df, ops):
78
  dataset=eval_dict,
79
  )
80
 
81
- return [round(r["value"], 6) for r in result["examples"]]
 
 
82
 
83
 
84
  @distill
@@ -94,29 +110,39 @@ def length_ratio(df, ops):
94
  dataset=eval_dict,
95
  )
96
 
97
- return [round(r["value"], 6) for r in result["examples"]]
 
 
98
 
99
 
100
  @metric
101
  def avg_bert_score(df, ops: ZenoOptions):
102
- return df[ops.distill_columns["bert_score"]].mean()
 
 
103
 
104
 
105
  @metric
106
  def avg_bleu(df, ops: ZenoOptions):
107
- return df[ops.distill_columns["bleu"]].mean()
 
 
108
 
109
 
110
  @metric
111
  def avg_chrf(df, ops: ZenoOptions):
112
- return df[ops.distill_columns["chrf"]].mean()
 
 
113
 
114
 
115
  @metric
116
  def avg_length_ratio(df, ops: ZenoOptions):
117
- return df[ops.distill_columns["length_ratio"]].mean()
 
 
118
 
119
 
120
  @distill
121
  def length(df, ops):
122
- return df[ops.data_column].str.len()
2
 
3
  import numpy as np
4
  import pandas as pd
 
5
 
6
+ # from inspiredco.critique import Critique
7
+
8
+ from zeno import (
9
+ ZenoOptions,
10
+ distill,
11
+ metric,
12
+ model,
13
+ ModelReturn,
14
+ DistillReturn,
15
+ MetricReturn,
16
+ )
17
 
18
  # client = Critique(api_key=os.environ["INSPIREDCO_API_KEY"])
19
 
37
  model_df[["text", "translation"]], on="text", how="left"
38
  )
39
  df_join = df_join.merge(embed_df, on="text", how="left")
40
+ return ModelReturn(
41
+ model_output=df_join["translation"].fillna(""),
42
+ embedding=[np.fromstring(d[1:-1], sep=",") for d in df_join["embed"]],
43
+ )
44
 
45
  return pred
46
 
56
  metric="bert_score", config={"model": "bert-base-uncased"}, dataset=eval_dict
57
  )
58
 
59
+ return DistillReturn(
60
+ distill_output=[round(r["value"], 6) for r in result["examples"]]
61
+ )
62
 
63
 
64
  @distill
74
  dataset=eval_dict,
75
  )
76
 
77
+ return DistillReturn(
78
+ distill_output=[round(r["value"], 6) for r in result["examples"]]
79
+ )
80
 
81
 
82
  @distill
92
  dataset=eval_dict,
93
  )
94
 
95
+ return DistillReturn(
96
+ distill_output=[round(r["value"], 6) for r in result["examples"]]
97
+ )
98
 
99
 
100
  @distill
110
  dataset=eval_dict,
111
  )
112
 
113
+ return DistillReturn(
114
+ distill_output=[round(r["value"], 6) for r in result["examples"]]
115
+ )
116
 
117
 
118
  @metric
119
  def avg_bert_score(df, ops: ZenoOptions):
120
+ if len(df) == 0:
121
+ return MetricReturn(metric=0)
122
+ return MetricReturn(metric=df[ops.distill_columns["bert_score"]].fillna(0).mean())
123
 
124
 
125
  @metric
126
  def avg_bleu(df, ops: ZenoOptions):
127
+ if len(df) == 0:
128
+ return MetricReturn(metric=0)
129
+ return MetricReturn(metric=df[ops.distill_columns["bleu"]].fillna(0).mean())
130
 
131
 
132
  @metric
133
  def avg_chrf(df, ops: ZenoOptions):
134
+ if len(df) == 0:
135
+ return MetricReturn(metric=0)
136
+ return MetricReturn(metric=df[ops.distill_columns["chrf"]].fillna(0).mean())
137
 
138
 
139
  @metric
140
  def avg_length_ratio(df, ops: ZenoOptions):
141
+ if len(df) == 0:
142
+ return MetricReturn(metric=0)
143
+ return MetricReturn(metric=df[ops.distill_columns["length_ratio"]].fillna(0).mean())
144
 
145
 
146
  @distill
147
  def length(df, ops):
148
+ return DistillReturn(distill_output=df[ops.data_column].str.len())
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- zenoml>=0.3.14
2
  inspiredco
3
  sentence_transformers
1
+ zenoml>=0.4.5
2
  inspiredco
3
  sentence_transformers