File size: 1,333 Bytes
43a1a56 00dc43d |
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 |
<!DOCTYPE html>
<html>
<head>
<title>Goals of the World Health Organization</title>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/dist/transformers.min.js"></script>
<script>
async function generateGoals() {
// Load the GPT-2 model
const model = await transformers.gpt2.GPT2Model.fromPretrained("gpt2");
// Set up the tokenizer
const tokenizer = await transformers.gpt2.GPT2Tokenizer.fromPretrained("gpt2");
// Define the input text
const input = "The goals of the World Health Organization are";
// Encode the input text
const encodedInput = tokenizer.encode(input);
// Generate the output text using the GPT-2 model
const output = await model.generate(tf.tensor2d(encodedInput, [1, encodedInput.length]), { maxOutputLength: 200 });
// Decode the output text
const decodedOutput = tokenizer.decode(output.arraySync()[0], { skipSpecialTokens: true });
// Display the output text in the HTML page
document.getElementById("goals").innerHTML = decodedOutput;
}
</script>
</head>
<body onload="generateGoals()">
<h1>Goals of the World Health Organization</h1>
<p id="goals">Loading...</p>
</body>
</html> |