ilar06 commited on
Commit
fee0fd3
·
verified ·
1 Parent(s): 9c076df

Update text-to-text-generation.html

Browse files
Files changed (1) hide show
  1. text-to-text-generation.html +12 -36
text-to-text-generation.html CHANGED
@@ -8,10 +8,8 @@
8
  <script type="module">
9
  // Import the library
10
  import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';
11
-
12
  // Make it available globally
13
  window.pipeline = pipeline;
14
-
15
  </script>
16
 
17
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
@@ -85,56 +83,34 @@
85
  </div>
86
 
87
  <script>
88
-
89
  let generator;
90
-
91
  // Initialize the sentiment analysis model
92
  async function initializeModel() {
93
  generator = await pipeline('text2text-generation', 'Xenova/LaMini-Flan-T5-783M');
94
-
95
  }
96
-
97
  async function generateText() {
98
  const textFieldValue = document.getElementById("text-to-textGenerationText").value.trim();
99
-
100
-
101
- const currentDate = new Date().toDateString();
102
- const currentTime = new Date().toLocaleTimeString();
103
-
104
-
105
-
106
-
107
  const result = await generator(textFieldValue, {
108
  max_new_tokens: 100,
109
  });
110
-
111
  document.getElementById("outputArea").innerText = `Current Date: ${currentDate}\nCurrent Time: ${currentTime}\n\n${JSON.stringify(result, null, 2)}`;
112
  }
113
-
114
-
115
  async function generateText2() {
116
  const textFieldValue = document.getElementById("text-to-textGenerationText2").value.trim();
117
-
118
- const currentDate = new Date().toDateString();
119
- const currentTime = new Date().toLocaleTimeString();
120
-
121
-
122
- const result = await generator (textFieldValue, {
123
- // To-Do: generator 객체에 temperature 파라미터 값을 지정하십시오.
124
- max_new_tokens: 200,
125
- temperature: 0.9,
126
- repetition_penalty: 2.0,
127
- no_repeat_ngram_size: 3,
128
  });
129
- // To-Do: result의 값을 stringd으로 변환하여 outputArea2에 출력하십시오.
130
- document.getElementById("outputArea2").innerText = `Current Date: ${currentDate}\nCurrent Time: ${currentTime}\n\n${JSON.stringify(result, null, 2)}`;
131
-
132
-
133
- // 힌트: document.getElementById("outputArea2") 사용
134
-
135
-
136
  }
137
-
138
  // Initialize the model after the DOM is completely loaded
139
  window.addEventListener("DOMContentLoaded", initializeModel);
140
  </script>
 
8
  <script type="module">
9
  // Import the library
10
  import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';
 
11
  // Make it available globally
12
  window.pipeline = pipeline;
 
13
  </script>
14
 
15
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
 
83
  </div>
84
 
85
  <script>
 
86
  let generator;
 
87
  // Initialize the sentiment analysis model
88
  async function initializeModel() {
89
  generator = await pipeline('text2text-generation', 'Xenova/LaMini-Flan-T5-783M');
 
90
  }
 
91
  async function generateText() {
92
  const textFieldValue = document.getElementById("text-to-textGenerationText").value.trim();
93
+ const currentDate = new Date().toDateString();
94
+ const currentTime = new Date().toLocaleTimeString();
 
 
 
 
 
 
95
  const result = await generator(textFieldValue, {
96
  max_new_tokens: 100,
97
  });
 
98
  document.getElementById("outputArea").innerText = `Current Date: ${currentDate}\nCurrent Time: ${currentTime}\n\n${JSON.stringify(result, null, 2)}`;
99
  }
 
 
100
  async function generateText2() {
101
  const textFieldValue = document.getElementById("text-to-textGenerationText2").value.trim();
102
+ const currentDate = new Date().toDateString();
103
+ const currentTime = new Date().toLocaleTimeString();
104
+ const result = await generator(textFieldValue, {
105
+ max_new_tokens: 200,
106
+ temperature: 0.9,
107
+ repetition_penalty: 2.0,
108
+ no_repeat_ngram_size: 3,
109
+ // top_k: 20,
110
+ // do_sample: true,
 
 
111
  });
112
+ document.getElementById("outputArea2").innerText = `Current Date: ${currentDate}\nCurrent Time: ${currentTime}\n\n${JSON.stringify(result, null, 2)}`;
 
 
 
 
 
 
113
  }
 
114
  // Initialize the model after the DOM is completely loaded
115
  window.addEventListener("DOMContentLoaded", initializeModel);
116
  </script>