Spaces:
Running
Running
Commit
•
9bb6eef
1
Parent(s):
50b88d8
DPO feedback format
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: enro-app.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
-
__all__ = ['model_name', 'tokenizer', 'model', 'example_translations', '
|
5 |
-
'get_translations', 'save_option_to_repo', 'get_random_sentence', 'update_prompt']
|
6 |
|
7 |
# %% enro-app.ipynb 1
|
8 |
from transformers import MarianMTModel, MarianTokenizer
|
@@ -28,14 +28,58 @@ def get_translations(input_text):
|
|
28 |
return random_translations[0], random_translations[1]
|
29 |
|
30 |
# %% enro-app.ipynb 5
|
31 |
-
example_translations =
|
32 |
-
"
|
33 |
-
"The
|
34 |
-
"
|
35 |
-
"
|
36 |
-
"
|
37 |
-
"
|
38 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# %% enro-app.ipynb 6
|
41 |
import os
|
@@ -56,14 +100,20 @@ if not firebase_admin._apps:
|
|
56 |
|
57 |
# %% enro-app.ipynb 7
|
58 |
def save_option_to_repo(trans_prompt, translation1, translation2, button):
|
59 |
-
ref = db.reference('
|
60 |
# Push new data to the database
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
def get_random_sentence():
|
69 |
return random.sample(example_translations, 1)[0]
|
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: enro-app.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
+
__all__ = ['model_name', 'tokenizer', 'model', 'example_translations', 'sentences', 'encoded_key', 'decoded_bytes',
|
5 |
+
'firebase_creds', 'get_translations', 'save_option_to_repo', 'get_random_sentence', 'update_prompt']
|
6 |
|
7 |
# %% enro-app.ipynb 1
|
8 |
from transformers import MarianMTModel, MarianTokenizer
|
|
|
28 |
return random_translations[0], random_translations[1]
|
29 |
|
30 |
# %% enro-app.ipynb 5
|
31 |
+
example_translations = sentences = [
|
32 |
+
"The mouse jumped.",
|
33 |
+
"The mouse ran away.",
|
34 |
+
"The mouse squeaked loudly.",
|
35 |
+
"The mouse hid quickly.",
|
36 |
+
"The mouse nibbled cheese.",
|
37 |
+
"The mouse dashed off.",
|
38 |
+
"The mouse found crumbs.",
|
39 |
+
"The mouse searched intently.",
|
40 |
+
"The mouse peered out.",
|
41 |
+
"The mouse sniffed carefully.",
|
42 |
+
"The mouse climbed up.",
|
43 |
+
"The mouse scurried along.",
|
44 |
+
"The mouse escaped swiftly.",
|
45 |
+
"The mouse burrowed deeply.",
|
46 |
+
"The mouse explored curiously.",
|
47 |
+
"That mouse squeaked.",
|
48 |
+
"That mouse dashed away.",
|
49 |
+
"That mouse looked around.",
|
50 |
+
"That mouse gnawed wood.",
|
51 |
+
"That mouse hid cleverly.",
|
52 |
+
"That mouse chewed through.",
|
53 |
+
"That mouse fled quickly.",
|
54 |
+
"That mouse found food.",
|
55 |
+
"That mouse evaded capture.",
|
56 |
+
"That mouse peeked out.",
|
57 |
+
"That mouse twitched nervously.",
|
58 |
+
"That mouse made noise.",
|
59 |
+
"That mouse crawled away.",
|
60 |
+
"That mouse gnawed plastic.",
|
61 |
+
"That mouse explored boldly.",
|
62 |
+
"Mice are fast.",
|
63 |
+
"Mice are clever.",
|
64 |
+
"Mice are quick.",
|
65 |
+
"Mice are tiny.",
|
66 |
+
"Mice are playful.",
|
67 |
+
"Mice are resourceful.",
|
68 |
+
"Mice are shy.",
|
69 |
+
"Mice are cute.",
|
70 |
+
"Mice live together.",
|
71 |
+
"Mice hide well.",
|
72 |
+
"Mice avoid predators.",
|
73 |
+
"Mice chew everything.",
|
74 |
+
"Mice burrow underground.",
|
75 |
+
"Mice love food.",
|
76 |
+
"Mice squeak often.",
|
77 |
+
"Mice find crumbs.",
|
78 |
+
"Mice travel far.",
|
79 |
+
"Mice reproduce rapidly.",
|
80 |
+
"Mice build nests.",
|
81 |
+
"Mice hide indoors."
|
82 |
+
]
|
83 |
|
84 |
# %% enro-app.ipynb 6
|
85 |
import os
|
|
|
100 |
|
101 |
# %% enro-app.ipynb 7
|
102 |
def save_option_to_repo(trans_prompt, translation1, translation2, button):
|
103 |
+
ref = db.reference('dpo_feedback')
|
104 |
# Push new data to the database
|
105 |
+
if button == "Translation 1":
|
106 |
+
ref.push({
|
107 |
+
'prompt': trans_prompt,
|
108 |
+
'chosen': translation1,
|
109 |
+
'rejected': translation2
|
110 |
+
})
|
111 |
+
if button == "Translation 2":
|
112 |
+
ref.push({
|
113 |
+
'prompt': trans_prompt,
|
114 |
+
'chosen': translation2,
|
115 |
+
'rejected': translation1
|
116 |
+
})
|
117 |
|
118 |
def get_random_sentence():
|
119 |
return random.sample(example_translations, 1)[0]
|