-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddb2cec
commit 2b2c679
Showing
3 changed files
with
72 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ollama from '../../src/browser.js' | ||
|
||
async function main() { | ||
// Tokenize some text | ||
const tokResponse = await ollama.tokenize({ | ||
model: 'llama3.2', | ||
text: 'Hello, how are you?' | ||
}) | ||
|
||
console.log('Tokens from model:', tokResponse.tokens) | ||
|
||
// Detokenize the tokens back to text | ||
const detokResponse = await ollama.detokenize({ | ||
model: 'llama3.2', | ||
tokens: tokResponse.tokens | ||
}) | ||
|
||
console.log('Text from model:', detokResponse.text) | ||
} | ||
|
||
main().catch(console.error) |
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