derek-thomas HF staff commited on
Commit
73927d2
1 Parent(s): ac0fd77

Removing local media

Browse files
.gitattributes CHANGED
@@ -33,4 +33,3 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
- *.ipynb filter=lfs diff=lfs merge=lfs -text
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
Latency_and_Throughput_Manim.ipynb CHANGED
@@ -1,3 +1,387 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:64de21a449869bdaa2743ec584d5854848ebbf93e272402d48d1bdc1f9db32a7
3
- size 11414091
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "substantial-impact",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Welcome to Manim!"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "first-armenia",
14
+ "metadata": {},
15
+ "source": [
16
+ "This is a temporary test environment in which you can play around with Manim without the need of installing it locally. Some basic knowledge of Python is helpful! Keep in mind that this is a *temporary* environment, though: your changes will not be saved and cannot be shared with others. To save your work, you will need to download the notebook file (\"File > Download as > Notebook (.ipynb)\"). Enjoy!\n",
17
+ "\n",
18
+ "> *Useful resources:* [Documentation](https://docs.manim.community), [Discord](https://discord.gg/mMRrZQW), [Reddit](https://www.reddit.com/r/manim/)"
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "markdown",
23
+ "id": "honest-cruise",
24
+ "metadata": {},
25
+ "source": [
26
+ "## Setup"
27
+ ]
28
+ },
29
+ {
30
+ "cell_type": "code",
31
+ "execution_count": null,
32
+ "id": "f8ffa0be-d1ae-4b1d-8827-01e11ef5be68",
33
+ "metadata": {
34
+ "tags": []
35
+ },
36
+ "outputs": [],
37
+ "source": [
38
+ "!wget -O user.svg https://pic.onlinewebfonts.com/thumbnails/icons_308642.svg"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "markdown",
43
+ "id": "governing-increase",
44
+ "metadata": {},
45
+ "source": [
46
+ "We begin our short walkthrough by importing everything from the library. Run the following code cell to do so (focus the cell and hit the *Run* button above, or press `Shift`+`Enter` – you can find more information about how to navigate and work with Jupyter notebooks in the *Help* menu at the top of this page).\n",
47
+ "\n",
48
+ "The second line controls the maximum width used to display videos in this notebook, and the third line controls the verbosity of the log output. Feel free to adapt both of these settings to your liking."
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": null,
54
+ "id": "eaab1b64-4833-4e7d-97e7-3c5324c742df",
55
+ "metadata": {
56
+ "tags": []
57
+ },
58
+ "outputs": [],
59
+ "source": [
60
+ "from manim import *\n",
61
+ "\n",
62
+ "config.media_width = \"75%\"\n",
63
+ "config.verbosity = \"WARNING\""
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "execution_count": null,
69
+ "id": "257cf337-948e-4ef7-aae3-2fb7b5b58602",
70
+ "metadata": {
71
+ "tags": []
72
+ },
73
+ "outputs": [],
74
+ "source": [
75
+ "%%manim -qm --format=gif LatencyVisualization\n",
76
+ "\n",
77
+ "from manim import *\n",
78
+ "\n",
79
+ "text = \"The cake is a lie\"\n",
80
+ "text_list = text.split(\" \")\n",
81
+ "rounds = 3\n",
82
+ "class LatencyVisualization(Scene):\n",
83
+ "\n",
84
+ " def construct(self):\n",
85
+ " # Setup LLM and user\n",
86
+ " llm_box = Rectangle(width=2, height=1).set_fill(BLUE, opacity=0.5).set_stroke(BLUE, width=2).to_edge(LEFT)\n",
87
+ " llm_text = Text(\"LLM\", color=WHITE).move_to(llm_box.get_center())\n",
88
+ " user_svg = SVGMobject(\"user.svg\", fill_color=WHITE, stroke_color=WHITE).scale(0.5).to_edge(RIGHT)\n",
89
+ " user_text = Text(\"User\", font_size=20).move_to(user_svg.get_bottom())\n",
90
+ " user = VGroup(user_svg, user_text)\n",
91
+ " \n",
92
+ " title_text = Text(\"Latency\").scale(0.75).to_edge(UP)\n",
93
+ " conclusion_text = Text(\"Latency is the time it takes for you to receive a response\").scale(0.5).to_edge(DOWN)\n",
94
+ " self.play(FadeIn(llm_box), FadeIn(llm_text), FadeIn(user), Write(title_text), Write(conclusion_text))\n",
95
+ "\n",
96
+ " # Dynamic Packet Flow\n",
97
+ " start_point = llm_box.get_right() + RIGHT * 0.5\n",
98
+ " end_point = user_svg.get_left() + LEFT * 0.5\n",
99
+ "\n",
100
+ " packets = VGroup()\n",
101
+ " \n",
102
+ " # Timer setup\n",
103
+ " timer = ValueTracker(0)\n",
104
+ " timer_text = always_redraw(lambda: Text(f\"Latency: {timer.get_value():.2f}s\", font_size=24).to_corner(UR))\n",
105
+ "\n",
106
+ " self.add(timer_text)\n",
107
+ "\n",
108
+ " def create_packet(word):\n",
109
+ " packet = Square(color=BLUE).scale(0.3).move_to(start_point)\n",
110
+ " packet_text = Text(word, font_size=12).move_to(packet.get_center())\n",
111
+ " packet_with_text = VGroup(packet, packet_text)\n",
112
+ " packets.add(packet_with_text)\n",
113
+ " self.add(packet_with_text)\n",
114
+ " return packet_with_text.animate.move_to(end_point).set_rate_func(rate_functions.linear)\n",
115
+ " \n",
116
+ " for _ in range(rounds):\n",
117
+ " for word in text_list:\n",
118
+ " self.wait(0.2) # Adjust the wait time to change flow rate\n",
119
+ " packet_animation = create_packet(word)\n",
120
+ " self.play(packet_animation, timer.animate.set_value(timer.get_value() + 2), run_time=2)\n",
121
+ " self.play(FadeOut(packets[-1]), run_time=0.5) # Fade out the last packet (the one that reached the user)\n",
122
+ " timer.set_value(0) # Reset timer for next packet\n",
123
+ "\n",
124
+ " self.wait(1)\n",
125
+ " self.play(FadeOut(packets))\n",
126
+ "\n",
127
+ " # Conclusion\n",
128
+ " self.wait(2)\n",
129
+ " self.play(FadeOut(conclusion_text), FadeOut(llm_box), FadeOut(llm_text), FadeOut(user), FadeOut(timer_text))\n"
130
+ ]
131
+ },
132
+ {
133
+ "cell_type": "markdown",
134
+ "id": "c894dbaf-021d-4441-9c0b-679bdca8ab8b",
135
+ "metadata": {},
136
+ "source": [
137
+ "## Throughput"
138
+ ]
139
+ },
140
+ {
141
+ "cell_type": "code",
142
+ "execution_count": null,
143
+ "id": "4d20b052-e155-412a-9f32-6ea1a890c361",
144
+ "metadata": {
145
+ "tags": []
146
+ },
147
+ "outputs": [],
148
+ "source": [
149
+ "%%manim -qm EmojiScene\n",
150
+ "from manim import *\n",
151
+ "\n",
152
+ "class EmojiScene(Scene):\n",
153
+ " def construct(self):\n",
154
+ " # Use Unicode escape sequence for the butterfly emoji\n",
155
+ " text = Text(\"Butterfly: \\U0001F98B 🦋\", font=\"Apple Color Emoji\")\n",
156
+ " self.add(text)\n",
157
+ " self.play(FadeIn(text))\n",
158
+ " self.wait(2)\n",
159
+ "\n",
160
+ "# Render the scene\n",
161
+ "scene = EmojiScene()\n",
162
+ "scene.render()\n"
163
+ ]
164
+ },
165
+ {
166
+ "cell_type": "code",
167
+ "execution_count": null,
168
+ "id": "f0e03d7a-0db1-41aa-8a79-4a9f0f5615e7",
169
+ "metadata": {
170
+ "jupyter": {
171
+ "outputs_hidden": true
172
+ },
173
+ "tags": []
174
+ },
175
+ "outputs": [],
176
+ "source": [
177
+ "%%manim -qm FontDemo\n",
178
+ "from manim import *\n",
179
+ "\n",
180
+ "class FontDemo(Scene):\n",
181
+ " def construct(self):\n",
182
+ " font_names = [\n",
183
+ " 'Academy Engraved LET', 'Adelle Sans Devanagari', 'AkayaKanadaka', 'AkayaTelivigala',\n",
184
+ " 'Al Bayan', 'Al Nile', 'Al Tarikh', 'American Typewriter', 'Andale Mono', 'Annai MN',\n",
185
+ " 'Apple Braille', 'Apple Chancery', 'Apple Color Emoji', 'Apple LiGothic', 'Apple LiSung',\n",
186
+ " 'Apple SD Gothic Neo', 'Apple Symbols', 'AppleGothic', 'AppleMyungjo', 'Arial', 'Arial Black',\n",
187
+ " 'Arial Hebrew', 'Arial Hebrew Scholar', 'Arial Narrow', 'Arial Rounded MT Bold', 'Arial Unicode MS',\n",
188
+ " 'Arima Koshi', 'Arima Madurai', 'Avenir', 'Avenir Next', 'Avenir Next Condensed', 'Ayuthaya',\n",
189
+ " 'BM Dohyeon', 'BM Hanna 11yrs Old', 'BM Hanna Air', 'BM Hanna Pro', 'BM Jua', 'BM Kirang Haerang',\n",
190
+ " 'BM Yeonsung', 'Baghdad', 'Bai Jamjuree', 'Baloo 2', 'Baloo Bhai 2', 'Baloo Bhaijaan',\n",
191
+ " 'Baloo Bhaina 2', 'Baloo Chettan 2', 'Baloo Da 2', 'Baloo Paaji 2', 'Baloo Tamma 2',\n",
192
+ " 'Baloo Tammudu 2', 'Baloo Thambi 2', 'Bangla MN', 'Bangla Sangam MN', 'Baoli SC', 'Baoli TC',\n",
193
+ " 'Baskerville', 'Beirut', 'BiauKai', 'Big Caslon', 'Bodoni 72', 'Bodoni 72 Oldstyle',\n",
194
+ " 'Bodoni 72 Smallcaps', 'Bodoni Ornaments', 'Bradley Hand', 'Brush Script MT', 'Cambay Devanagari',\n",
195
+ " 'Chakra Petch', 'Chalkboard', 'Chalkboard SE', 'Chalkduster', 'Charm', 'Charmonman', 'Charter',\n",
196
+ " 'Cochin', 'Comic Sans MS', 'Copperplate', 'Corsiva Hebrew', 'Courier New', 'DIN Alternate',\n",
197
+ " 'DIN Condensed', 'Damascus', 'DecoType Naskh', 'Devanagari MT', 'Devanagari Sangam MN', 'Didot',\n",
198
+ " 'Diwan Kufi', 'Diwan Thuluth', 'Euphemia UCAS', 'Fahkwang', 'Farah', 'Farisi', 'Futura',\n",
199
+ " 'GB18030 Bitmap', 'Galvji', 'Geeza Pro', 'Geneva', 'Georgia', 'Gill Sans', 'Gotu', 'Grantha Sangam MN',\n",
200
+ " 'Graphik', 'Gujarati MT', 'Gujarati Sangam MN', 'GungSeo', 'Gurmukhi MN', 'Gurmukhi MT',\n",
201
+ " 'Gurmukhi Sangam MN', 'Hannotate SC', 'Hannotate TC', 'HanziPen SC', 'HanziPen TC', 'HeadLineA',\n",
202
+ " 'Hei', 'Heiti SC', 'Heiti TC', 'Helvetica', 'Helvetica Neue', 'Herculanum', 'Hiragino Maru Gothic ProN',\n",
203
+ " 'Hiragino Mincho ProN', 'Hiragino Sans', 'Hiragino Sans CNS', 'Hiragino Sans GB', 'Hoefler Text',\n",
204
+ " 'Hubballi', 'ITF Devanagari', 'ITF Devanagari Marathi', 'Impact', 'InaiMathi', 'Jaini', 'Jaini Purva',\n",
205
+ " 'K2D', 'Kai', 'Kailasa', 'Kaiti SC', 'Kaiti TC', 'Kannada MN', 'Kannada Sangam MN', 'Katari',\n",
206
+ " 'Kavivanar', 'Kefa', 'Khmer MN', 'Khmer Sangam MN', 'Klee', 'KoHo', 'Kodchasan', 'Kohinoor Bangla',\n",
207
+ " 'Kohinoor Devanagari', 'Kohinoor Gujarati', 'Kohinoor Telugu', 'Kokonor', 'Krub', 'Krungthep',\n",
208
+ " 'KufiStandardGK', 'Lahore Gurmukhi', 'Lantinghei SC', 'Lantinghei TC', 'Lao MN', 'Lao Sangam MN',\n",
209
+ " 'Lava Devanagari', 'Lava Kannada', 'Lava Telugu', 'LiHei Pro', 'LiSong Pro', 'Libian SC', 'Libian TC',\n",
210
+ " 'LingWai SC', 'LingWai TC', 'Lucida Grande', 'Luminari', 'Maku', 'Malayalam MN', 'Malayalam Sangam MN',\n",
211
+ " 'Mali', 'Marker Felt', 'Menlo', 'Microsoft Sans Serif', 'Mishafi', 'Mishafi Gold', 'Modak', 'Monaco',\n",
212
+ " 'Monaspace Argon', 'Monaspace Argon Var', 'Monaspace Krypton', 'Monaspace Krypton Var', 'Monaspace Neon',\n",
213
+ " 'Monaspace Neon Var', 'Monaspace Radon', 'Monaspace Radon Var', 'Monaspace Xenon', 'Monaspace Xenon Var',\n",
214
+ " 'Monospace', 'Mshtakan', 'Mukta', 'Mukta Mahee', 'Mukta Malar', 'Mukta Vaani', 'Muna', 'Myanmar MN',\n",
215
+ " 'Myanmar Sangam MN', 'Nadeem', 'Nanum Brush Script', 'Nanum Gothic', 'Nanum Myeongjo', 'Nanum Pen Script',\n",
216
+ " 'New Peninim MT', 'Niramit', 'Noteworthy', 'Noto Nastaliq Urdu', 'Noto Sans Batak', 'Noto Sans Kannada',\n",
217
+ " 'Noto Sans Myanmar', 'Noto Sans NKo', 'Noto Sans Oriya', 'Noto Sans Tagalog', 'Noto Serif Kannada',\n",
218
+ " 'Noto Serif Myanmar', 'October Compressed Devanagari', 'October Compressed Tamil',\n",
219
+ " 'October Condensed Devanagari', 'October Condensed Tamil', 'October Devanagari', 'October Tamil', 'Optima',\n",
220
+ " 'Oriya MN', 'Oriya Sangam MN', 'Osaka', 'PCMyungjo', 'PSL Ornanong Pro', 'PT Mono', 'PT Sans',\n",
221
+ " 'PT Sans Caption', 'PT Sans Narrow', 'PT Serif', 'PT Serif Caption', 'Padyakke Expanded One', 'Palatino',\n",
222
+ " 'Papyrus', 'Party LET', 'Phosphate', 'PilGi', 'PingFang HK', 'PingFang SC', 'PingFang TC',\n",
223
+ " 'Plantagenet Cherokee', 'Raanana', 'Rockwell', 'STFangsong', 'STHeiti', 'STIX Two Math', 'STIX Two Text',\n",
224
+ " 'STKaiti', 'STSong', 'Sama Devanagari', 'Sama Gujarati', 'Sama Gurmukhi', 'Sama Kannada', 'Sama Malayalam',\n",
225
+ " 'Sama Tamil', 'Sana', 'Sans', 'Sarabun', 'Sathu', 'Savoye LET', 'Serif', 'Shobhika', 'Shree Devanagari 714',\n",
226
+ " 'SignPainter', 'Silom', 'SimSong', 'Sinhala MN', 'Sinhala Sangam MN', 'Skia', 'Snell Roundhand',\n",
227
+ " 'Songti SC', 'Songti TC', 'Srisakdi', 'Sukhumvit Set', 'Symbol', 'Tahoma', 'Tamil MN', 'Tamil Sangam MN',\n",
228
+ " 'Telugu MN', 'Telugu Sangam MN', 'Thonburi', 'Times New Roman', 'Tiro Bangla', 'Tiro Devanagari Hindi',\n",
229
+ " 'Tiro Devanagari Marathi', 'Tiro Devanagari Sanskrit', 'Tiro Gurmukhi', 'Tiro Kannada', 'Tiro Tamil',\n",
230
+ " 'Tiro Telugu', 'Toppan Bunkyu Gothic', 'Toppan Bunkyu Midashi Gothic', 'Toppan Bunkyu Midashi Mincho',\n",
231
+ " 'Toppan Bunkyu Mincho', 'Trattatello', 'Trebuchet MS', 'Tsukushi A Round Gothic', 'Tsukushi B Round Gothic',\n",
232
+ " 'Verdana', 'Waseem', 'Wawati SC', 'Wawati TC', 'Webdings', 'Wingdings', 'Wingdings 2', 'Wingdings 3',\n",
233
+ " 'Xingkai SC', 'Xingkai TC', 'YuGothic', 'YuKyokasho', 'YuKyokasho Yoko', 'YuMincho', 'YuMincho +36p Kana',\n",
234
+ " 'Yuanti SC', 'Yuanti TC', 'Yuppy SC', 'Yuppy TC', 'Zapf Dingbats', 'Zapfino', 'cursive', 'fantasy', 'system-ui'\n",
235
+ " ]\n",
236
+ "\n",
237
+ " texts = []\n",
238
+ " for font_name in font_names:\n",
239
+ " text_part = Text(f\"{font_name}: 🦋 \\U0001F98B\", font=font_name).scale(0.75)\n",
240
+ " combined_text = VGroup(text_part).arrange(RIGHT, buff=0.1)\n",
241
+ " texts.append(combined_text)\n",
242
+ "\n",
243
+ " for i in range(0, len(texts), 15):\n",
244
+ " batch = VGroup(*texts[i:i+15]).arrange(DOWN, buff=0.5)\n",
245
+ " batch.scale_to_fit_height(config.frame_height - 1)\n",
246
+ " self.play(FadeIn(batch))\n",
247
+ " self.wait(1)\n",
248
+ " self.play(FadeOut(batch))\n",
249
+ "\n",
250
+ " self.wait(2)\n"
251
+ ]
252
+ },
253
+ {
254
+ "cell_type": "code",
255
+ "execution_count": null,
256
+ "id": "37ad0a6c-e068-4ace-b31f-2c8c1eb8f52b",
257
+ "metadata": {
258
+ "tags": []
259
+ },
260
+ "outputs": [],
261
+ "source": [
262
+ "%%manim -qm ThroughputVisualization\n",
263
+ "\n",
264
+ "from manim import *\n",
265
+ "\n",
266
+ "class ThroughputVisualization(Scene):\n",
267
+ " text = [\"His hands can't hit what he can't see\", \n",
268
+ " \"Float like a 🦋, sting like a bee\",\n",
269
+ " \"I'm so mean, I make medic -ine sick.\",\n",
270
+ " \"Suffer now and retire as a champ -ion\"]\n",
271
+ " batch_size = 4\n",
272
+ " rounds = 1\n",
273
+ "\n",
274
+ " def construct(self):\n",
275
+ " # Split text into words\n",
276
+ " words = [sentence.split() for sentence in self.text]\n",
277
+ " max_len = max(len(sentence) for sentence in words)\n",
278
+ " \n",
279
+ " # Extend shorter sentences with empty strings to match the longest sentence\n",
280
+ " for sentence in words:\n",
281
+ " sentence.extend([''] * (max_len - len(sentence)))\n",
282
+ " \n",
283
+ " # Transpose to get words from each sentence in each pass\n",
284
+ " transposed_words = list(map(list, zip(*words)))\n",
285
+ "\n",
286
+ " # Setup LLM and user\n",
287
+ " llm_box = Rectangle(width=2, height=1).set_fill(GREEN, opacity=0.5).set_stroke(GREEN, width=2).to_edge(LEFT).shift(DOWN)\n",
288
+ " llm_text = Text(\"LLM\", color=WHITE).move_to(llm_box.get_center())\n",
289
+ " user_svg = SVGMobject(\"user.svg\", fill_color=WHITE, stroke_color=WHITE).scale(0.5).to_edge(RIGHT).shift(DOWN)\n",
290
+ " user_text = Text(\"User\", font_size=20).move_to(user_svg.get_bottom())\n",
291
+ " user = VGroup(user_svg, user_text)\n",
292
+ " \n",
293
+ " title_text = Text(\"Throughput\").scale(0.75).to_edge(UP)\n",
294
+ " conclusion_text = Text(\"Throughput is the amount of data processed in a given time\").scale(0.5).to_edge(DOWN)\n",
295
+ " self.play(FadeIn(llm_box), FadeIn(llm_text), FadeIn(user), Write(title_text), Write(conclusion_text))\n",
296
+ "\n",
297
+ " # Dynamic Packet Flow\n",
298
+ " start_point = llm_box.get_right() + RIGHT * 0.5\n",
299
+ " end_point = user_svg.get_left() + LEFT * 1\n",
300
+ " storage_start = start_point + UP * 2.5 + LEFT * 1.5\n",
301
+ " \n",
302
+ " # Define initial storage positions in a block formation\n",
303
+ " storage_positions = [\n",
304
+ " storage_start,\n",
305
+ " storage_start + RIGHT * 6,\n",
306
+ " storage_start + DOWN * 1,\n",
307
+ " storage_start + RIGHT * 6 + DOWN * 1,\n",
308
+ " ]\n",
309
+ " storage_offsets = [0, 0, 0, 0] # Initialize offsets for each storage position\n",
310
+ "\n",
311
+ " packets = VGroup()\n",
312
+ " \n",
313
+ " # Timer setup\n",
314
+ " timer = ValueTracker(0)\n",
315
+ " timer_text = always_redraw(lambda: Text(f\"Time: {timer.get_value():.2f}s\\nThroughput: 4 Tokens/s\", font_size=18).to_corner(UR))\n",
316
+ "\n",
317
+ " self.add(timer_text)\n",
318
+ "\n",
319
+ " def create_packet_group(words):\n",
320
+ " packet_group = VGroup()\n",
321
+ " for i, word in enumerate(words):\n",
322
+ " row, col = divmod(i, 2)\n",
323
+ " packet = Square(color=GREEN).scale(0.3).move_to(start_point + RIGHT * col * 0.6 + DOWN * row * 0.6)\n",
324
+ " packet_text = Text(word, font_size=12).move_to(packet.get_center())\n",
325
+ " packet_with_text = VGroup(packet, packet_text)\n",
326
+ " packet_group.add(packet_with_text)\n",
327
+ " packet_group.next_to(llm_box)\n",
328
+ " return packet_group\n",
329
+ "\n",
330
+ " for _ in range(self.rounds):\n",
331
+ " for word_group in transposed_words:\n",
332
+ " if any(word_group): # Check if there are any non-empty words\n",
333
+ " packet_group = create_packet_group(word_group)\n",
334
+ " packets.add(packet_group)\n",
335
+ " self.play(FadeIn(packet_group))\n",
336
+ " self.play(packet_group.animate.move_to(end_point), timer.animate.set_value(timer.get_value() + 1), run_time=1)\n",
337
+ "\n",
338
+ " # Determine which storage position to use\n",
339
+ " new_storage_position = []\n",
340
+ " for i, packet in enumerate(packet_group):\n",
341
+ " storage_index = i % self.batch_size\n",
342
+ " storage_position = storage_positions[storage_index] + RIGHT * storage_offsets[storage_index]\n",
343
+ " new_storage_position.append(packet.animate.move_to(storage_position))\n",
344
+ " storage_offsets[storage_index] += 0.6 # Adjust based on the width of packet group\n",
345
+ " self.play(*new_storage_position, run_time=0.5)\n",
346
+ "\n",
347
+ " self.wait(0.1) # Adjust the wait time to change flow rate\n",
348
+ " timer.set_value(0) # Reset timer for next batch\n",
349
+ "\n",
350
+ " self.wait(1)\n",
351
+ "\n",
352
+ " # Conclusion\n",
353
+ " self.wait(2)\n",
354
+ " self.play(FadeOut(packets), FadeOut(conclusion_text), FadeOut(llm_box), FadeOut(llm_text), FadeOut(user), FadeOut(timer_text))\n"
355
+ ]
356
+ },
357
+ {
358
+ "cell_type": "code",
359
+ "execution_count": null,
360
+ "id": "0d487ddf-4725-497e-a37b-2d9b6f69338f",
361
+ "metadata": {},
362
+ "outputs": [],
363
+ "source": []
364
+ }
365
+ ],
366
+ "metadata": {
367
+ "kernelspec": {
368
+ "display_name": "Python 3 (ipykernel)",
369
+ "language": "python",
370
+ "name": "python3"
371
+ },
372
+ "language_info": {
373
+ "codemirror_mode": {
374
+ "name": "ipython",
375
+ "version": 3
376
+ },
377
+ "file_extension": ".py",
378
+ "mimetype": "text/x-python",
379
+ "name": "python",
380
+ "nbconvert_exporter": "python",
381
+ "pygments_lexer": "ipython3",
382
+ "version": "3.10.8"
383
+ }
384
+ },
385
+ "nbformat": 4,
386
+ "nbformat_minor": 5
387
+ }