Skip to content

Commit a8b0cd5

Browse files
committed
Fix formatting for LLM intro
1 parent 510f2e9 commit a8b0cd5

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

docs/language_model/llm/llm_intro_hyperparameter_tuning.ipynb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,12 @@
170170
"id": "b7df2c30-a498-4661-a37e-ae19741fa6ba",
171171
"metadata": {},
172172
"source": [
173-
"### Temperature Tuning"
174-
]
175-
},
176-
{
177-
"cell_type": "markdown",
178-
"id": "ffdb3f34-042e-4107-a1cd-afaaadc8e9c0",
179-
"metadata": {},
180-
"source": [
173+
"### Temperature Tuning\n",
174+
"\n",
181175
"The `temperature` parameter in LLMs plays a pivotal role in determining the predictability of the output. \n",
176+
"\n",
182177
"- **Lower temperature values (e.g., 0.2)** lead to more predictable and consistent responses, but may risk being overly constrained or repetitive.\n",
178+
"\n",
183179
"- **Higher temperature values (e.g., 1.0)** introduce more randomness and diversity, but can result in less consistency and occasional incoherence.\n",
184180
"The choice of temperature value is a trade-off between consistency and variety, and should be tailored to the specific requirements of your task."
185181
]
@@ -345,10 +341,12 @@
345341
"id": "65d80452-c074-4341-ae3d-168aadb913e5",
346342
"metadata": {},
347343
"source": [
348-
"In the Python code above leverage on `numpy` library, you can see that\n",
344+
"In the Python code above leveraging on `numpy` library, you can see that\n",
345+
"\n",
349346
"- `softargmax` is a function that computes the soft(arg)max of an array of logits `x` for a given temperature `T`.\n",
350347
"- We define an array of logits and compute the soft(arg)max for different temperatures.\n",
351348
"- When you run this code, you'll see that as the temperature increases, the soft(arg)max output becomes more uniform (i.e., the probabilities are more evenly distributed), and as the temperature decreases, the soft(arg)max output becomes more peaky (i.e., one probability dominates the others). This illustrates how temperature can control the randomness of the model's output.\n",
349+
"\n",
352350
"- To close this off, taking the max of the soft(arg)max output, you will observe how it gets more random in the max value as the soft(arg)max output becomes more uniform. This links to the concept of how the next word gets more random because of the max of the uniformity of the soft(arg)max output."
353351
]
354352
},
@@ -548,9 +546,12 @@
548546
"id": "328f3191-2721-442b-9006-e36ab3e909b4",
549547
"metadata": {},
550548
"source": [
551-
"In the code above,\n",
549+
"In the code above\n",
550+
"\n",
552551
"- `top_k` is a function that computes the top `k` logits from an array of logits.\n",
552+
"\n",
553553
"- We define an array of logits and compute the top `k` logits for different values of `k`.\n",
554+
"\n",
554555
"- When you run this code, you'll see that as `k` increases, more logits are considered. This illustrates how `top_k` can control the number of tokens considered by the model."
555556
]
556557
},
@@ -581,7 +582,7 @@
581582
"name": "python",
582583
"nbconvert_exporter": "python",
583584
"pygments_lexer": "ipython3",
584-
"version": "3.11.5"
585+
"version": "3.11.0"
585586
}
586587
},
587588
"nbformat": 4,

docs/language_model/llm/llm_intro_hyperparameter_tuning.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ In our second question, we change the question to "What is a Large Language Mode
8686
### Temperature Tuning
8787

8888
The `temperature` parameter in LLMs plays a pivotal role in determining the predictability of the output.
89+
8990
- **Lower temperature values (e.g., 0.2)** lead to more predictable and consistent responses, but may risk being overly constrained or repetitive.
91+
9092
- **Higher temperature values (e.g., 1.0)** introduce more randomness and diversity, but can result in less consistency and occasional incoherence.
9193
The choice of temperature value is a trade-off between consistency and variety, and should be tailored to the specific requirements of your task.
9294

@@ -194,10 +196,12 @@ for T in [0.1, 1.0]:
194196

195197

196198

197-
In the Python code above leverage on `numpy` library, you can see that
199+
In the Python code above leveraging on `numpy` library, you can see that
200+
198201
- `softargmax` is a function that computes the soft(arg)max of an array of logits `x` for a given temperature `T`.
199202
- We define an array of logits and compute the soft(arg)max for different temperatures.
200203
- When you run this code, you'll see that as the temperature increases, the soft(arg)max output becomes more uniform (i.e., the probabilities are more evenly distributed), and as the temperature decreases, the soft(arg)max output becomes more peaky (i.e., one probability dominates the others). This illustrates how temperature can control the randomness of the model's output.
204+
201205
- To close this off, taking the max of the soft(arg)max output, you will observe how it gets more random in the max value as the soft(arg)max output becomes more uniform. This links to the concept of how the next word gets more random because of the max of the uniformity of the soft(arg)max output.
202206

203207
### Top-K Tuning
@@ -321,9 +325,12 @@ for k in [2, 3, 4]:
321325

322326

323327

324-
In the code above,
328+
In the code above
329+
325330
- `top_k` is a function that computes the top `k` logits from an array of logits.
331+
326332
- We define an array of logits and compute the top `k` logits for different values of `k`.
333+
327334
- When you run this code, you'll see that as `k` increases, more logits are considered. This illustrates how `top_k` can control the number of tokens considered by the model.
328335

329336
## Summary

0 commit comments

Comments
 (0)