oceankim commited on
Commit
592510d
โ€ข
1 Parent(s): 928b7cd

Update zero-shot-classification.html

Browse files
Files changed (1) hide show
  1. zero-shot-classification.html +3 -17
zero-shot-classification.html CHANGED
@@ -6,8 +6,8 @@
6
  <title>Zero Shot Classification - Hugging Face Transformers.js</title>
7
 
8
  <script type="module">
9
- // To-Do: transformers.js ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ค‘ pipeline ํ•จ์ˆ˜๋ฅผ importํ•˜์‹ญ์‹œ์˜ค.
10
- import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.5.4';
11
  // Make it available globally
12
  window.pipeline = pipeline;
13
  </script>
@@ -90,39 +90,25 @@
90
  </div>
91
 
92
  <script>
93
-
94
  let classifier;
95
  let classifierMulti;
96
-
97
  // Initialize the sentiment analysis model
98
  async function initializeModel() {
99
- // To-Do: pipeline ํ•จ์ˆ˜์— task์™€ model์„ ์ง€์ •ํ•˜์—ฌ zero ์ƒท ๋ถ„๋ฅ˜ ๋ชจ๋ธ์„ ์ƒ์„ฑํ•˜์—ฌ classifier์— ์ €์žฅํ•˜์‹ญ์‹œ์˜ค. ๋ชจ๋ธ์€ Xenova/mobilebert-uncased-mnli ์‚ฌ์šฉ
100
- // Allocate pipeline
101
- classifier = await pipeline('zero-shot-classification', 'Xenova/moclassifierbilebert-uncased-mnli');
102
- // To-Do: pipeline ํ•จ์ˆ˜์— task์™€ model์„ ์ง€์ •ํ•˜์—ฌ zero ์ƒท ๋ถ„๋ฅ˜ ๋ชจ๋ธ์„ ์ƒ์„ฑํ•˜์—ฌ ใ…Šใ…Š์— ์ €์žฅํ•˜์‹ญ์‹œ์˜ค. ๋ชจ๋ธ์€ Xenova/nli-deberta-v3-xsmall ์‚ฌ์šฉ
103
- // Allocate pipeline
104
  classifierMulti = await pipeline('zero-shot-classification', 'Xenova/nli-deberta-v3-xsmall');
105
-
106
  }
107
-
108
  async function classifyText() {
109
  const text = document.getElementById("textText").value.trim();
110
  const labels = document.getElementById("labelsText").value.trim().split(",").map(item => item.trim());
111
-
112
  const result = await classifier(text, labels);
113
-
114
  document.getElementById("outputArea").innerText = JSON.stringify(result, null, 2);
115
  }
116
-
117
  async function classifyTextMulti() {
118
  const text = document.getElementById("textTextMulti").value.trim();
119
  const labels = document.getElementById("labelsTextMulti").value.trim().split(",").map(item => item.trim());
120
-
121
  const result = await classifierMulti(text, labels, { multi_label: true });
122
-
123
  document.getElementById("outputAreaMulti").innerText = JSON.stringify(result, null, 2);
124
  }
125
-
126
  // Initialize the model after the DOM is completely loaded
127
  window.addEventListener("DOMContentLoaded", initializeModel);
128
  </script>
 
6
  <title>Zero Shot Classification - Hugging Face Transformers.js</title>
7
 
8
  <script type="module">
9
+ // Import the library
10
+ import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.5.4';
11
  // Make it available globally
12
  window.pipeline = pipeline;
13
  </script>
 
90
  </div>
91
 
92
  <script>
 
93
  let classifier;
94
  let classifierMulti;
 
95
  // Initialize the sentiment analysis model
96
  async function initializeModel() {
97
+ classifier = await pipeline('zero-shot-classification', 'Xenova/mobilebert-uncased-mnli');
 
 
 
 
98
  classifierMulti = await pipeline('zero-shot-classification', 'Xenova/nli-deberta-v3-xsmall');
 
99
  }
 
100
  async function classifyText() {
101
  const text = document.getElementById("textText").value.trim();
102
  const labels = document.getElementById("labelsText").value.trim().split(",").map(item => item.trim());
 
103
  const result = await classifier(text, labels);
 
104
  document.getElementById("outputArea").innerText = JSON.stringify(result, null, 2);
105
  }
 
106
  async function classifyTextMulti() {
107
  const text = document.getElementById("textTextMulti").value.trim();
108
  const labels = document.getElementById("labelsTextMulti").value.trim().split(",").map(item => item.trim());
 
109
  const result = await classifierMulti(text, labels, { multi_label: true });
 
110
  document.getElementById("outputAreaMulti").innerText = JSON.stringify(result, null, 2);
111
  }
 
112
  // Initialize the model after the DOM is completely loaded
113
  window.addEventListener("DOMContentLoaded", initializeModel);
114
  </script>