Spaces:
Running
Running
File size: 2,133 Bytes
0f90ec3 7d57aa1 6d25e44 b732fba 7d57aa1 c3722f8 b732fba 5e20069 7d57aa1 b732fba 2b1755b 024f95f b732fba 024f95f 2b1755b 024f95f 3952763 b732fba 2b1755b 67c5c5d 2b1755b 024f95f 7d57aa1 2b1755b 024f95f b732fba 024f95f 2b1755b b732fba 024f95f b732fba 7d57aa1 b732fba 7d57aa1 0f90ec3 024f95f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Generation - LaMini-Flan-T5</title>
<script type="module">
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';
let generator;
async function loadModel() {
document.getElementById("status").innerText = "β³ Loading model...";
try {
generator = await pipeline('text2text-generation', 'Xenova/LaMini-Flan-T5-783M');
document.getElementById("status").innerText = "β
Model loaded!";
document.getElementById("generateBtn").disabled = false;
} catch (error) {
document.getElementById("status").innerText = "β Error loading model.";
console.error("Model load error:", error);
}
}
async function generateText() {
const inputText = document.getElementById("inputText").value.trim();
if (!inputText) {
alert("Please enter some text!");
return;
}
document.getElementById("output").innerText = "β³ Generating...";
try {
const output = await generator(inputText, { max_new_tokens: 100 });
document.getElementById("output").innerText = output[0].generated_text;
} catch (error) {
document.getElementById("output").innerText = "β Error generating text.";
console.error("Generation error:", error);
}
}
window.addEventListener("DOMContentLoaded", loadModel);
window.generateText = generateText;
</script>
</head>
<body>
<h2>Text Generation using LaMini-Flan-T5</h2>
<p id="status">β³ Loading model...</p>
<textarea id="inputText" rows="3" cols="50" placeholder="Enter text..."></textarea>
<br><br>
<button id="generateBtn" onclick="generateText()" disabled>Generate</button>
<h3>Output:</h3>
<pre id="output"></pre>
</body>
</html>
|