-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Emscripten interface to llama2.c
This is based on the initial prototype by @ggerganov: https://github.com/ggerganov/llama2.c/tree/web
- Loading branch information
Showing
10 changed files
with
1,098 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>llama2.c-emscripten example</title> | ||
<script src="llama2.js"></script> | ||
</head> | ||
<body> | ||
<input id="prompt" placeholder="Prompt"></input> <input type="button" id="generate" value="Generate"></input> | ||
<div id="output"></div> | ||
|
||
<script> | ||
(async () => { | ||
|
||
const llama2 = await new LLAMA2(); | ||
|
||
document.querySelector('#generate').addEventListener('click', async function() { | ||
const prompt = document.querySelector('#prompt').value; | ||
|
||
const options = { | ||
temperature: 0.9, | ||
}; | ||
|
||
const out = await llama2.generate(prompt); | ||
document.querySelector('#output').innerHTML = out; | ||
}); | ||
|
||
llama2.on('token', () => { | ||
console.log('token', llama2.tokens[llama2.tokens.length-1]); | ||
}); | ||
|
||
llama2.on('word', (word) => { | ||
console.log('word', word); | ||
}); | ||
|
||
})(); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.