Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit d22ef09

Browse files
committed
add llm generation overview
1 parent 029d369 commit d22ef09

File tree

1 file changed

+71
-8
lines changed

1 file changed

+71
-8
lines changed

examples/chatbot/chatbot-tutorial.ipynb

+71-8
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,92 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# LLM Generation at a high level\n",
8+
"\n",
9+
"```python\n",
10+
"query = \"Capital of\"\n",
11+
"\n",
12+
"output = \"\"\n",
13+
"for i in range(MAX_GENERATED_TOKENS):\n",
14+
" output = output + LLM(output)\n",
15+
"```"
16+
]
17+
},
18+
{
19+
"cell_type": "markdown",
20+
"metadata": {},
21+
"source": [
22+
"1. output = Capital of\n",
23+
"2. output = Capital of France\n",
24+
"2. output = Capital of France is\n",
25+
"2. output = Capital of France Paris"
26+
]
27+
},
328
{
429
"cell_type": "code",
530
"execution_count": null,
631
"metadata": {},
732
"outputs": [],
33+
"source": []
34+
},
35+
{
36+
"cell_type": "markdown",
37+
"metadata": {},
838
"source": [
9-
"longchat_template = \"\"\"A chat between a curious user and an artificial intelligence assistant.\n",
10-
"The assistant gives helpful, detailed, and polite answers to the user's questions.\n",
11-
"USER: {input}\n",
12-
"ASSISTANT:\"\"\""
39+
"```\n",
40+
"query = A chat between a curious user and an artificial intelligence assistant.\n",
41+
" The assistant gives helpful, detailed, and polite answers to the user's questions.\n",
42+
" USER: My name is Aniket\n",
43+
" ASSISTANT:\n",
44+
"```"
1345
]
1446
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": null,
50+
"metadata": {},
51+
"outputs": [],
52+
"source": []
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": null,
57+
"metadata": {},
58+
"outputs": [],
59+
"source": []
60+
},
1561
{
1662
"cell_type": "code",
1763
"execution_count": null,
1864
"metadata": {},
1965
"outputs": [],
2066
"source": [
21-
"print(longchat_template.format(input=\"My name is Aniket\"))"
67+
"longchat_template = \"\"\"A chat between a curious user and an artificial intelligence assistant.\n",
68+
"The assistant gives helpful, detailed, and polite answers to the user's questions.\n",
69+
"USER: {input}\n",
70+
"ASSISTANT:\"\"\""
2271
]
2372
},
2473
{
2574
"cell_type": "code",
2675
"execution_count": null,
2776
"metadata": {},
2877
"outputs": [],
29-
"source": []
78+
"source": [
79+
"print(longchat_template.format(input=\"My name is Aniket\"))"
80+
]
3081
},
3182
{
3283
"cell_type": "code",
3384
"execution_count": null,
3485
"metadata": {},
3586
"outputs": [],
36-
"source": []
87+
"source": [
88+
"print(longchat_template.format(input=\"What is the capital of France?\"))"
89+
]
3790
},
3891
{
3992
"cell_type": "code",
@@ -111,6 +164,16 @@
111164
"ASSISTANT:\"\"\""
112165
]
113166
},
167+
{
168+
"cell_type": "code",
169+
"execution_count": null,
170+
"metadata": {},
171+
"outputs": [],
172+
"source": [
173+
"output = model.chat(longchat_template.format(input=\"What is the capital of France?\"))\n",
174+
"print(output)"
175+
]
176+
},
114177
{
115178
"cell_type": "code",
116179
"execution_count": null,
@@ -555,7 +618,7 @@
555618
"name": "python",
556619
"nbconvert_exporter": "python",
557620
"pygments_lexer": "ipython3",
558-
"version": "3.11.3"
621+
"version": "3.10.12"
559622
}
560623
},
561624
"nbformat": 4,

0 commit comments

Comments
 (0)