Spaces:
Runtime error
Runtime error
Alex Cabrera
commited on
Commit
•
3d72bf8
1
Parent(s):
9cbdbe1
update
Browse files- .zeno_cache/folders.pickle +2 -2
- .zeno_cache/reports.pickle +2 -2
- .zeno_cache/slices.pickle +2 -2
- __pycache__/model.cpython-38.pyc +0 -0
- model.py +40 -14
- requirements.txt +1 -1
.zeno_cache/folders.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
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:
|
3 |
-
size
|
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:
|
3 |
-
size
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
32 |
-
|
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
|
|
|
|
|
50 |
|
51 |
|
52 |
@distill
|
@@ -62,7 +74,9 @@ def bleu(df, ops):
|
|
62 |
dataset=eval_dict,
|
63 |
)
|
64 |
|
65 |
-
return
|
|
|
|
|
66 |
|
67 |
|
68 |
@distill
|
@@ -78,7 +92,9 @@ def chrf(df, ops):
|
|
78 |
dataset=eval_dict,
|
79 |
)
|
80 |
|
81 |
-
return
|
|
|
|
|
82 |
|
83 |
|
84 |
@distill
|
@@ -94,29 +110,39 @@ def length_ratio(df, ops):
|
|
94 |
dataset=eval_dict,
|
95 |
)
|
96 |
|
97 |
-
return
|
|
|
|
|
98 |
|
99 |
|
100 |
@metric
|
101 |
def avg_bert_score(df, ops: ZenoOptions):
|
102 |
-
|
|
|
|
|
103 |
|
104 |
|
105 |
@metric
|
106 |
def avg_bleu(df, ops: ZenoOptions):
|
107 |
-
|
|
|
|
|
108 |
|
109 |
|
110 |
@metric
|
111 |
def avg_chrf(df, ops: ZenoOptions):
|
112 |
-
|
|
|
|
|
113 |
|
114 |
|
115 |
@metric
|
116 |
def avg_length_ratio(df, ops: ZenoOptions):
|
117 |
-
|
|
|
|
|
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.
|
2 |
inspiredco
|
3 |
sentence_transformers
|
1 |
+
zenoml>=0.4.5
|
2 |
inspiredco
|
3 |
sentence_transformers
|