You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ch05/07_gpt_to_llama/README.md
+185-1Lines changed: 185 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,4 +8,188 @@ This folder contains code for converting the GPT implementation from chapter 4 a
8
8
-[converting-llama2-to-llama3.ipynb](converting-llama2-to-llama3.ipynb): contains code to convert the Llama 2 model to Llama 3, Llama 3.1, and Llama 3.2
9
9
-[standalone-llama32.ipynb](standalone-llama32.ipynb): a standalone notebook implementing Llama 3.2
### Using Llama 3.2 via the `llms-from-scratch` package
16
+
17
+
For an easy way to use the Llama 3.2 1B and 3B models, you can also use the `llms-from-scratch` PyPI package based on the source code in this repository at [pkg/llms_from_scratch](../../pkg/llms_from_scratch).
18
+
19
+
20
+
##### 1) Installation
21
+
22
+
```bash
23
+
pip install llms_from_scratch blobfile
24
+
```
25
+
26
+
##### 2) Model and text generation settings
27
+
28
+
Specify which model to use:
29
+
30
+
```python
31
+
MODEL_FILE="llama3.2-1B-instruct.pth"
32
+
# MODEL_FILE = "llama3.2-1B-base.pth"
33
+
# MODEL_FILE = "llama3.2-3B-instruct.pth"
34
+
# MODEL_FILE = "llama3.2-3B-base.pth"
35
+
```
36
+
37
+
Basic text generation settings that can be defined by the user. Note that the recommended 8192-token context size requires approximately 3 GB of VRAM for the text generation example.
38
+
39
+
```python
40
+
MODEL_CONTEXT_LENGTH=8192# Supports up to 131_072
41
+
42
+
# Text generation settings
43
+
if"instruct"inMODEL_FILE:
44
+
PROMPT="What do llamas eat?"
45
+
else:
46
+
PROMPT="Llamas eat"
47
+
48
+
MAX_NEW_TOKENS=150
49
+
TEMPERATURE=0.
50
+
TOP_K=1
51
+
```
52
+
53
+
54
+
##### 3) Weight download and loading
55
+
56
+
This automatically downloads the weight file based on the model choice above:
0 commit comments