mirror of
https://github.com/rasbt/LLMs-from-scratch.git
synced 2026-04-10 12:33:42 +00:00
simplify requirements file (#76)
This commit is contained in:
committed by
GitHub
parent
3e122fa656
commit
329d046b5d
@@ -2,18 +2,9 @@
|
|||||||
|
|
||||||
This document provides more information on double-checking your installed Python version and packages. (Please see the [../01_optional-python-setup-preferences](../01_optional-python-setup-preferences) folder for more information on installing Python and Python packages.)
|
This document provides more information on double-checking your installed Python version and packages. (Please see the [../01_optional-python-setup-preferences](../01_optional-python-setup-preferences) folder for more information on installing Python and Python packages.)
|
||||||
|
|
||||||
I used the following main libraries in this book. Newer versions of these libraries are likely compatible as well. However, if you experience any problems with the code, you can try these library versions as a fallback:
|
I used the following libraries listed [here](https://github.com/rasbt/LLMs-from-scratch/blob/main/requirements.txt) for this book. Newer versions of these libraries are likely compatible as well. However, if you experience any problems with the code, you can try these library versions as a fallback.
|
||||||
|
|
||||||
- numpy 1.24.3
|
To install these requirements most conveniently, you can use the `requirements.txt` file in the root directory for this code repository and execute the following command:
|
||||||
- scipy 1.10.1
|
|
||||||
- pandas 2.0.2
|
|
||||||
- matplotlib 3.7.1
|
|
||||||
- jupyterlab 4.0
|
|
||||||
- watermark 2.4.2
|
|
||||||
- torch 2.0.1
|
|
||||||
- tiktoken 0.5.1
|
|
||||||
|
|
||||||
To install these requirements most conveniently, you can use the `requirements.txt` file:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
@@ -36,7 +27,6 @@ If you see the following issues, it's likely that your JupyterLab instance is co
|
|||||||
|
|
||||||
<img src="figures/jupyter-issues.jpg" width="450px">
|
<img src="figures/jupyter-issues.jpg" width="450px">
|
||||||
|
|
||||||
|
|
||||||
In this case, you may want to use `watermark` to check if you opened the JupyterLab instance in the right conda environment using the `--conda` flag:
|
In this case, you may want to use `watermark` to check if you opened the JupyterLab instance in the right conda environment using the `--conda` flag:
|
||||||
|
|
||||||
<img src="figures/watermark.jpg" width="350px">
|
<img src="figures/watermark.jpg" width="350px">
|
||||||
|
|||||||
@@ -10,15 +10,14 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"[OK] Your Python version is 3.11.4\n",
|
"[OK] Your Python version is 3.10.12\n",
|
||||||
"[OK] numpy 1.25.2\n",
|
"numpy >= 1.24.3 \n",
|
||||||
"[OK] scipy 1.11.1\n",
|
"matplotlib >= 3.7.1. \n",
|
||||||
"[OK] pandas 2.0.3\n",
|
"jupyterlab >= 4.0. \n",
|
||||||
"[OK] matplotlib 3.7.2\n",
|
"tensorflow >= 2.15.0 \n",
|
||||||
"[OK] jupyterlab 4.0.4\n",
|
"torch >= 2.0.1 \n",
|
||||||
"[OK] watermark 2.4.3\n",
|
"tqdm >= 4.66.1 \n",
|
||||||
"[OK] torch 2.0.1\n",
|
"tiktoken >= 0.5.1 \n"
|
||||||
"[OK] tiktoken 0.5.1\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -28,14 +27,6 @@
|
|||||||
"d = get_requirements_dict()\n",
|
"d = get_requirements_dict()\n",
|
||||||
"check_packages(d)"
|
"check_packages(d)"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "d5ca05fc-98e0-4bba-a95e-350e1764a12c",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -54,7 +45,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.11.4"
|
"version": "3.10.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@@ -42,11 +42,18 @@ def get_packages(pkgs):
|
|||||||
|
|
||||||
def get_requirements_dict():
|
def get_requirements_dict():
|
||||||
PROJECT_ROOT = dirname(realpath(__file__))
|
PROJECT_ROOT = dirname(realpath(__file__))
|
||||||
REQUIREMENTS_FILE = join(PROJECT_ROOT, "requirements.txt")
|
PROJECT_ROOT_UP_TWO = dirname(dirname(PROJECT_ROOT))
|
||||||
|
REQUIREMENTS_FILE = join(PROJECT_ROOT_UP_TWO, "requirements.txt")
|
||||||
d = {}
|
d = {}
|
||||||
with open(REQUIREMENTS_FILE) as f:
|
with open(REQUIREMENTS_FILE) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
|
if not line.strip():
|
||||||
|
continue
|
||||||
|
line = line.split("#")[0]
|
||||||
|
print(line)
|
||||||
line = line.split(" ")
|
line = line.split(" ")
|
||||||
|
if not line[0].strip() or not line[-1].strip():
|
||||||
|
continue
|
||||||
d[line[0]] = line[-1]
|
d[line[0]] = line[-1]
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
numpy >= 1.24.3
|
|
||||||
scipy >= 1.10.1
|
|
||||||
pandas >= 2.0.2
|
|
||||||
matplotlib >= 3.7.1
|
|
||||||
jupyterlab >= 4.0
|
|
||||||
watermark >= 2.4.2
|
|
||||||
torch >= 2.0.1
|
|
||||||
tiktoken >= 0.5.1
|
|
||||||
@@ -35,7 +35,7 @@ class GPTDatasetV1(Dataset):
|
|||||||
return self.input_ids[idx], self.target_ids[idx]
|
return self.input_ids[idx], self.target_ids[idx]
|
||||||
|
|
||||||
|
|
||||||
def create_dataloader_v1(txt, batch_size=4, max_length=256,
|
def create_dataloader_v1(txt, batch_size=4, max_length=256,
|
||||||
stride=128, shuffle=True, drop_last=True):
|
stride=128, shuffle=True, drop_last=True):
|
||||||
# Initialize the tokenizer
|
# Initialize the tokenizer
|
||||||
tokenizer = tiktoken.get_encoding("gpt2")
|
tokenizer = tiktoken.get_encoding("gpt2")
|
||||||
@@ -78,7 +78,7 @@ class MultiHeadAttention(nn.Module):
|
|||||||
|
|
||||||
# We implicitly split the matrix by adding a `num_heads` dimension
|
# We implicitly split the matrix by adding a `num_heads` dimension
|
||||||
# Unroll last dim: (b, num_tokens, d_out) -> (b, num_tokens, num_heads, head_dim)
|
# Unroll last dim: (b, num_tokens, d_out) -> (b, num_tokens, num_heads, head_dim)
|
||||||
keys = keys.view(b, num_tokens, self.num_heads, self.head_dim)
|
keys = keys.view(b, num_tokens, self.num_heads, self.head_dim)
|
||||||
values = values.view(b, num_tokens, self.num_heads, self.head_dim)
|
values = values.view(b, num_tokens, self.num_heads, self.head_dim)
|
||||||
queries = queries.view(b, num_tokens, self.num_heads, self.head_dim)
|
queries = queries.view(b, num_tokens, self.num_heads, self.head_dim)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
numpy >= 1.24.3
|
numpy >= 1.24.3 # ch05
|
||||||
scipy >= 1.10.1
|
matplotlib >= 3.7.1. # ch04, ch05
|
||||||
pandas >= 2.0.2
|
jupyterlab >= 4.0. # all
|
||||||
matplotlib >= 3.7.1
|
tensorflow >= 2.15.0 # ch05
|
||||||
jupyterlab >= 4.0
|
torch >= 2.0.1 # all
|
||||||
watermark >= 2.4.2
|
tqdm >= 4.66.1 # ch05
|
||||||
torch >= 2.0.1
|
tiktoken >= 0.5.1 # ch02, ch04, ch05
|
||||||
tiktoken >= 0.5.1
|
|
||||||
Reference in New Issue
Block a user