coroianpetruta commited on
Commit
9bb6eef
1 Parent(s): 50b88d8

DPO feedback format

Browse files
Files changed (1) hide show
  1. app.py +67 -17
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', 'encoded_key', 'decoded_bytes', 'firebase_creds',
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 = ["What is the way to get to the mosque?",
32
- "Practice makes perfect.",
33
- "The cat is eating the small mouse.",
34
- "I'm not good at learning foreign languages.",
35
- "What do you mean you don't know?",
36
- "I should have sent a letter of apology.",
37
- "His handwriting is poor.",
38
- "He bowed his head."]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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('feedback')
60
  # Push new data to the database
61
- ref.push({
62
- 'prompt': trans_prompt,
63
- 'translation_1': translation1,
64
- 'translation_2': translation2,
65
- 'feedback': button
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]