Update zero-shot-classification.html
Browse files
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 |
-
//
|
10 |
-
|
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 |
-
|
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/[email protected]';
|
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>
|