Ali Kefia
commited on
Commit
·
6ffe4f3
1
Parent(s):
d3733b4
usage
Browse files
usage.py
CHANGED
@@ -19,20 +19,22 @@ def get_model():
|
|
19 |
|
20 |
def get_record():
|
21 |
df = pl.read_csv(DATA / "eval.csv")
|
22 |
-
|
|
|
|
|
|
|
23 |
text_fields = ["meta_title", "meta_description", "content"]
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
|
30 |
def main():
|
31 |
-
model = get_model()
|
32 |
record = get_record()
|
33 |
-
|
34 |
-
|
35 |
-
print(f"is news (real): {
|
36 |
print(f"is news (pred): {pred}")
|
37 |
|
38 |
|
|
|
19 |
|
20 |
def get_record():
|
21 |
df = pl.read_csv(DATA / "eval.csv")
|
22 |
+
return {col: val for col, val in zip(df.columns, df.sample().row(0))}
|
23 |
+
|
24 |
+
|
25 |
+
def pred_record(rec):
|
26 |
text_fields = ["meta_title", "meta_description", "content"]
|
27 |
+
text = "\n\n".join(rec[k] for k in text_fields)
|
28 |
+
embeds = embed([text])
|
29 |
+
(pred,) = get_model().predict(embeds)
|
30 |
+
return pred
|
31 |
|
32 |
|
33 |
def main():
|
|
|
34 |
record = get_record()
|
35 |
+
is_news = record["is_news_article"]
|
36 |
+
pred = pred_record(record)
|
37 |
+
print(f"is news (real): {is_news}")
|
38 |
print(f"is news (pred): {pred}")
|
39 |
|
40 |
|