|
|
<!DOCTYPE html> |
|
|
<html lang="en"> |
|
|
<head> |
|
|
<meta charset="UTF-8"> |
|
|
<title>Summarizer</title> |
|
|
</head> |
|
|
<body> |
|
|
<h1>Summarization Demo</h1> |
|
|
<textarea id="inputText" rows="10" cols="60">Paste text here...</textarea><br> |
|
|
<button id="summarizeBtn">Summarize</button> |
|
|
<p id="output"></p> |
|
|
|
|
|
<script type="module"> |
|
|
import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.0.0/dist/transformers.esm.js"; |
|
|
|
|
|
const generator = await pipeline("summarization", "Xenova/distilbart-cnn-6-6"); |
|
|
|
|
|
document.getElementById("summarizeBtn").onclick = async () => { |
|
|
const text = document.getElementById("inputText").value; |
|
|
const output = await generator(text, { max_new_tokens: 100 }); |
|
|
document.getElementById("output").innerText = output[0].summary_text; |
|
|
}; |
|
|
</script> |
|
|
</body> |
|
|
</html> |
|
|
|