Platform
Resources
Pricing
Sign in
Get started
Simon Willison
Workspace
Fork
Public
By
Simon Willison
Edited
Jan 1, 2024
Insert cell
Insert cell
transformers
=
import
(
"https://cdn.jsdelivr.net/npm/@xenova/transformers"
)
Insert cell
generator
=
await
transformers
.
pipeline
(
"text-generation"
,
"Xenova/TinyLlama-1.1B-Chat-v1.0"
)
Insert cell
messages
=
[
{
role
:
"system"
,
content
:
"You are a friendly assistant."
}
,
{
role
:
"user"
,
content
:
"Explain thermodynamics in simple terms."
}
]
Insert cell
prompt
=
generator
.
tokenizer
.
apply_chat_template
(
messages
,
{
tokenize
:
false
,
add_generation_prompt
:
true
}
)
Insert cell
generator
(
prompt
,
{
max_new_tokens
:
256
,
temperature
:
0.7
,
do_sample
:
true
,
top_k
:
50
}
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
transformers
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
generator
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
messages
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
prompt
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML