Julien Chaumond commited on
Commit
e246102
1 Parent(s): 1909611

Feedback from @thomwolf , @victorsanh et. al.

Browse files
front/assets/Icon-info.svg ADDED
front/assets/thumbnail-large.png ADDED
front/favicon.ico ADDED
front/index.html CHANGED
@@ -2,10 +2,14 @@
2
  <html>
3
  <head>
4
  <meta charset="utf-8">
5
- <title>Hugging Face – Convo</title>
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
7
  <link rel="stylesheet" href="/dist/style.css">
8
  <link href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono|IBM+Plex+Sans:400,700" rel="stylesheet">
 
 
 
 
9
  </head>
10
  <body>
11
  <div class="header">
@@ -14,7 +18,7 @@
14
  🦄 How to build a State-of-the-Art Conversational AI with Transfer Learning
15
  </div>
16
  <div class="links">
17
- <a target="_blank" href="https://medium.com/@Thomwolf/2d818ac26313"><img src="/assets/iconmonstr-medium-1.svg"></a>
18
  <a target="_blank" href="https://github.com/huggingface/transfer-learning-conv-ai"><img src="/assets/iconmonstr-github-1.svg"></a>
19
  </div>
20
  </div>
@@ -34,10 +38,10 @@
34
  </div>
35
  <div class="box box1">
36
  <div class="clearfix">
37
- <div class="title"><!--Attention: How it works-->Start chatting</div>
38
  </div>
39
  <div class="description">
40
- The machine learning model created a comprehensive consistent persona based on
41
  these few lines of bio. You can now chat with this persona below.
42
  </div>
43
  <div class="gauge">
@@ -76,24 +80,27 @@
76
 
77
 
78
  <div class="decoder-settings">
79
- <div class="title">Decoder settings</div>
 
 
 
80
  <div class="setting">
81
  <div class="desc">
82
  <span>Top-k</span><span class="js-val"></span>
83
  </div>
84
- <input class="slider" type="range" min="0" max="1000" step="1" value="0">
85
  </div>
86
  <div class="setting">
87
  <div class="desc">
88
  <span>Top-p</span><span class="js-val"></span>
89
  </div>
90
- <input class="slider" type="range" min="0" max="1" step="any" value="0.9">
91
  </div>
92
  <div class="setting">
93
  <div class="desc">
94
  <span>Temperature</span><span class="js-val"></span>
95
  </div>
96
- <input class="slider" type="range" min="0" max="100" step="any" value="0.7">
97
  </div>
98
  </div>
99
 
 
2
  <html>
3
  <head>
4
  <meta charset="utf-8">
5
+ <title>Hugging Face – ConvAI</title>
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
7
  <link rel="stylesheet" href="/dist/style.css">
8
  <link href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono|IBM+Plex+Sans:400,700" rel="stylesheet">
9
+ <meta property="og:url" content="https://convai.huggingface.co/">
10
+ <meta property="og:image" content="https://convai.huggingface.co/assets/thumbnail-large.png">
11
+ <meta property="fb:app_id" content="1321688464574422">
12
+ <meta name="description" content="🦄 How to build a State-of-the-Art Conversational AI with Transfer Learning">
13
  </head>
14
  <body>
15
  <div class="header">
 
18
  🦄 How to build a State-of-the-Art Conversational AI with Transfer Learning
19
  </div>
20
  <div class="links">
21
+ <a target="_blank" href="https://medium.com/huggingface/how-to-build-a-state-of-the-art-conversational-ai-with-transfer-learning-2d818ac26313"><img src="/assets/iconmonstr-medium-1.svg"></a>
22
  <a target="_blank" href="https://github.com/huggingface/transfer-learning-conv-ai"><img src="/assets/iconmonstr-github-1.svg"></a>
23
  </div>
24
  </div>
 
38
  </div>
39
  <div class="box box1">
40
  <div class="clearfix">
41
+ <div class="title">Start chatting</div>
42
  </div>
43
  <div class="description">
44
+ The machine learning model created a consistent persona based on
45
  these few lines of bio. You can now chat with this persona below.
46
  </div>
47
  <div class="gauge">
 
80
 
81
 
82
  <div class="decoder-settings">
83
+ <div class="title">
84
+ Decoder settings
85
+ <a target="_blank" href="https://medium.com/huggingface/how-to-build-a-state-of-the-art-conversational-ai-with-transfer-learning-2d818ac26313#79c5"><img src="/assets/Icon-info.svg"></a>
86
+ </div>
87
  <div class="setting">
88
  <div class="desc">
89
  <span>Top-k</span><span class="js-val"></span>
90
  </div>
91
+ <input class="slider" type="range" min="0" max="200" step="1" value="0">
92
  </div>
93
  <div class="setting">
94
  <div class="desc">
95
  <span>Top-p</span><span class="js-val"></span>
96
  </div>
97
+ <input class="slider js-inverted" type="range" min="0" max="1" step="any" value="0.9">
98
  </div>
99
  <div class="setting">
100
  <div class="desc">
101
  <span>Temperature</span><span class="js-val"></span>
102
  </div>
103
+ <input class="slider" type="range" min="0" max="2" step="any" value="0.6">
104
  </div>
105
  </div>
106
 
front/js-src/controller.ts CHANGED
@@ -4,9 +4,13 @@ const App = {
4
  text: "",
5
  },
6
  messages: [] as Message[],
 
7
  messagesRoot: document.querySelector('div.messages') as HTMLDivElement,
8
  divPersona: document.querySelector('div.persona') as HTMLDivElement,
9
  linkSuggest: document.querySelector('.chat-suggestion .js-suggestion') as HTMLLinkElement,
 
 
 
10
  };
11
 
12
  document.addEventListener('DOMContentLoaded', () => {
@@ -45,7 +49,7 @@ document.addEventListener('DOMContentLoaded', () => {
45
  App.persona = await Api.shared.getShuffle();
46
  tokenizePersona();
47
  history.replaceState(null, "", `/persona/${App.persona.slug}`);
48
- /// Also reset messages.
49
  App.messages = [];
50
  App.messagesRoot.innerHTML = "";
51
  loadSuggestion();
@@ -77,11 +81,18 @@ document.addEventListener('DOMContentLoaded', () => {
77
  } else {
78
  spanVal.className = "js-val red";
79
  }
 
 
 
 
 
 
 
 
 
 
80
  };
81
- const sliders = Array.from(
82
- document.querySelectorAll('.decoder-settings input.slider')
83
- ) as HTMLInputElement[];
84
- for (const slider of sliders) {
85
  handleSliderChange(slider);
86
  slider.addEventListener('input', () => {
87
  handleSliderChange(slider);
@@ -90,8 +101,32 @@ document.addEventListener('DOMContentLoaded', () => {
90
 
91
  const gauge = document.querySelector('div.gauge') as HTMLDivElement;
92
  gauge.addEventListener('click', () => {
93
- gauge.classList.toggle('active');
94
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  /**
97
  * Chat input
 
4
  text: "",
5
  },
6
  messages: [] as Message[],
7
+ /// HTMLElements
8
  messagesRoot: document.querySelector('div.messages') as HTMLDivElement,
9
  divPersona: document.querySelector('div.persona') as HTMLDivElement,
10
  linkSuggest: document.querySelector('.chat-suggestion .js-suggestion') as HTMLLinkElement,
11
+ sliders: Array.from(
12
+ document.querySelectorAll('.decoder-settings input.slider')
13
+ ) as HTMLInputElement[],
14
  };
15
 
16
  document.addEventListener('DOMContentLoaded', () => {
 
49
  App.persona = await Api.shared.getShuffle();
50
  tokenizePersona();
51
  history.replaceState(null, "", `/persona/${App.persona.slug}`);
52
+ /// Also reset messages and reload suggestion.
53
  App.messages = [];
54
  App.messagesRoot.innerHTML = "";
55
  loadSuggestion();
 
81
  } else {
82
  spanVal.className = "js-val red";
83
  }
84
+ const isInverted = slider.classList.contains('js-inverted');
85
+ if (isInverted) {
86
+ if (spanVal.classList.contains('green')) {
87
+ spanVal.classList.remove('green');
88
+ spanVal.classList.add('red');
89
+ } else if (spanVal.classList.contains('red')) {
90
+ spanVal.classList.remove('red');
91
+ spanVal.classList.add('green');
92
+ }
93
+ }
94
  };
95
+ for (const slider of App.sliders) {
 
 
 
96
  handleSliderChange(slider);
97
  slider.addEventListener('input', () => {
98
  handleSliderChange(slider);
 
101
 
102
  const gauge = document.querySelector('div.gauge') as HTMLDivElement;
103
  gauge.addEventListener('click', () => {
104
+ gauge.classList.add('active');
105
  });
106
+ const gaugeEls = Array.from(
107
+ document.querySelectorAll('.gauge .gauge-el-wrapper')
108
+ );
109
+ for (const gaugeEl of gaugeEls) {
110
+ gaugeEl.addEventListener('click', () => {
111
+ const i = gaugeEls.indexOf(gaugeEl);
112
+ if (i === 0) {
113
+ App.sliders[0].value = `180`;
114
+ App.sliders[1].value = `0.1`;
115
+ App.sliders[2].value = `1.9`;
116
+ } else if (i === 1) {
117
+ App.sliders[0].value = `70`;
118
+ App.sliders[1].value = `0.5`;
119
+ App.sliders[2].value = `1.2`;
120
+ } else {
121
+ App.sliders[0].value = `0`;
122
+ App.sliders[1].value = `0.9`;
123
+ App.sliders[2].value = `0.6`;
124
+ }
125
+ for (const slider of App.sliders) {
126
+ handleSliderChange(slider);
127
+ }
128
+ });
129
+ }
130
 
131
  /**
132
  * Chat input
front/less/style.less CHANGED
@@ -106,8 +106,8 @@ div.subheader {
106
  .gauge {
107
  .clearfix();
108
  padding: 14px 0;
109
- cursor: pointer;
110
  .gauge-el-wrapper {
 
111
  position: relative;
112
  box-sizing: border-box;
113
  float: left;
@@ -129,6 +129,7 @@ div.subheader {
129
  background-color: red;
130
  }
131
  .legend {
 
132
  font-size: 11px;
133
  font-weight: bold;
134
  position: absolute;
@@ -153,6 +154,14 @@ div.decoder-settings {
153
  padding: 2px 6px;
154
  .title {
155
  font-size: 11px;
 
 
 
 
 
 
 
 
156
  }
157
  .setting {
158
  .desc {
@@ -183,7 +192,7 @@ div.chat-container {
183
  }
184
  .placeholder-start {
185
  position: absolute;
186
- top: 100px;
187
  left: 0; right: 0;
188
  .inner {
189
  width: 260px;
@@ -269,3 +278,23 @@ span.attention-level {
269
  &.level3 { background-color: #FFCF00; }
270
  &.level4 { background-color: #BEFF00; }
271
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  .gauge {
107
  .clearfix();
108
  padding: 14px 0;
 
109
  .gauge-el-wrapper {
110
+ cursor: pointer;
111
  position: relative;
112
  box-sizing: border-box;
113
  float: left;
 
129
  background-color: red;
130
  }
131
  .legend {
132
+ .user-select(none);
133
  font-size: 11px;
134
  font-weight: bold;
135
  position: absolute;
 
154
  padding: 2px 6px;
155
  .title {
156
  font-size: 11px;
157
+ img {
158
+ margin-left: 4px;
159
+ vertical-align: middle;
160
+ opacity: 0.5;
161
+ &:hover {
162
+ opacity: 0.8;
163
+ }
164
+ }
165
  }
166
  .setting {
167
  .desc {
 
192
  }
193
  .placeholder-start {
194
  position: absolute;
195
+ top: 45%;
196
  left: 0; right: 0;
197
  .inner {
198
  width: 260px;
 
278
  &.level3 { background-color: #FFCF00; }
279
  &.level4 { background-color: #BEFF00; }
280
  }
281
+
282
+
283
+ /**
284
+ * Media queries
285
+ */
286
+
287
+ @media (max-width: 630px) {
288
+ div.decoder-settings {
289
+ position: static;
290
+ margin-top: 32px;
291
+ width: initial;
292
+ }
293
+ }
294
+
295
+ @media (min-height: 800px) {
296
+ /// would probably be way better with css variables
297
+ div.chat-container .messages {
298
+ height: 300px;
299
+ }
300
+ }