Skip to content

Commit c376f6c

Browse files
committed
format fixes
1 parent 3853381 commit c376f6c

51 files changed

Lines changed: 102 additions & 69 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/AI/AI-llm-architecture/0.-basic-llm-concepts.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 0. Basic LLM Concepts
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
## Pretraining
46

57
Pretraining is the foundational phase in developing a large language model (LLM) where the model is exposed to vast and diverse amounts of text data. During this stage, **the LLM learns the fundamental structures, patterns, and nuances of language**, including grammar, vocabulary, syntax, and contextual relationships. By processing this extensive data, the model acquires a broad understanding of language and general world knowledge. This comprehensive base enables the LLM to generate coherent and contextually relevant text. Subsequently, this pretrained model can undergo fine-tuning, where it is further trained on specialized datasets to adapt its capabilities for specific tasks or domains, enhancing its performance and relevance in targeted applications.
@@ -297,3 +299,5 @@ During the backward pass:
297299
- **Efficiency:** Avoids redundant calculations by reusing intermediate results.
298300
- **Accuracy:** Provides exact derivatives up to machine precision.
299301
- **Ease of Use:** Eliminates manual computation of derivatives.
302+
303+
{{#include /banners/hacktricks-training.md}}

src/AI/AI-llm-architecture/1.-tokenizing.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 1. Tokenizing
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
## Tokenizing
46

57
**Tokenizing** is the process of breaking down data, such as text, into smaller, manageable pieces called _tokens_. Each token is then assigned a unique numerical identifier (ID). This is a fundamental step in preparing text for processing by machine learning models, especially in natural language processing (NLP).
@@ -96,3 +98,5 @@ print(token_ids[:50])
9698

9799
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
98100

101+
102+
{{#include /banners/hacktricks-training.md}}

src/AI/AI-llm-architecture/2.-data-sampling.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 2. Data Sampling
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
## **Data Sampling**
46

57
**Data Sampling** is a crucial process in preparing data for training large language models (LLMs) like GPT. It involves organizing text data into input and target sequences that the model uses to learn how to predict the next word (or token) based on the preceding words. Proper data sampling ensures that the model effectively captures language patterns and dependencies.
@@ -238,3 +240,5 @@ tensor([[ 367, 2885, 1464, 1807],
238240

239241
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
240242

243+
244+
{{#include /banners/hacktricks-training.md}}

src/AI/AI-llm-architecture/3.-token-embeddings.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 3. Token Embeddings
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
## Token Embeddings
46

57
After tokenizing text data, the next critical step in preparing data for training large language models (LLMs) like GPT is creating **token embeddings**. Token embeddings transform discrete tokens (such as words or subwords) into continuous numerical vectors that the model can process and learn from. This explanation breaks down token embeddings, their initialization, usage, and the role of positional embeddings in enhancing model understanding of token sequences.
@@ -216,3 +218,5 @@ print(input_embeddings.shape) # torch.Size([8, 4, 256])
216218

217219
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
218220

221+
222+
{{#include /banners/hacktricks-training.md}}

src/AI/AI-llm-architecture/4.-attention-mechanisms.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 4. Attention Mechanisms
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
## Attention Mechanisms and Self-Attention in Neural Networks
46

57
Attention mechanisms allow neural networks to f**ocus on specific parts of the input when generating each part of the output**. They assign different weights to different inputs, helping the model decide which inputs are most relevant to the task at hand. This is crucial in tasks like machine translation, where understanding the context of the entire sentence is necessary for accurate translation.
@@ -427,3 +429,6 @@ For another compact and efficient implementation you could use the [`torch.nn.Mu
427429

428430
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
429431

432+
433+
{{#include /banners/hacktricks-training.md}}
434+

src/AI/AI-llm-architecture/5.-llm-architecture.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 5. LLM Architecture
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
## LLM Architecture
46

57
> [!TIP]
@@ -697,4 +699,7 @@ print("Output length:", len(out[0]))
697699

698700
## References
699701

700-
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
702+
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
703+
704+
705+
{{#include /banners/hacktricks-training.md}}

src/AI/AI-llm-architecture/6.-pre-training-and-loading-models.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 6. Pre-training & Loading models
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
## Text Generation
46

57
In order to train a model we will need that model to be able to generate new tokens. Then we will compare the generated tokens with the expected ones in order to train the model into **learning the tokens it needs to generate**.
@@ -968,3 +970,5 @@ There 2 quick scripts to load the GPT2 weights locally. For both you can clone t
968970

969971
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
970972

973+
974+
{{#include /banners/hacktricks-training.md}}

src/AI/AI-llm-architecture/7.0.-lora-improvements-in-fine-tuning.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 7.0. LoRA Improvements in fine-tuning
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
## LoRA Improvements
46

57
> [!TIP]
@@ -60,4 +62,6 @@ def replace_linear_with_lora(model, rank, alpha):
6062

6163
## References
6264

63-
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
65+
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
66+
67+
{{#include /banners/hacktricks-training.md}}

src/AI/AI-llm-architecture/7.1.-fine-tuning-for-classification.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 7.1. Fine-Tuning for Classification
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
## What is
46

57
Fine-tuning is the process of taking a **pre-trained model** that has learned **general language patterns** from vast amounts of data and **adapting** it to perform a **specific task** or to understand domain-specific language. This is achieved by continuing the training of the model on a smaller, task-specific dataset, allowing it to adjust its parameters to better suit the nuances of the new data while leveraging the broad knowledge it has already acquired. Fine-tuning enables the model to deliver more accurate and relevant results in specialized applications without the need to train a new model from scratch.
@@ -113,4 +115,6 @@ You can find all the code to fine-tune GPT2 to be a spam classifier in [https://
113115

114116
## References
115117

116-
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
118+
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
119+
120+
{{#include /banners/hacktricks-training.md}}

src/AI/AI-llm-architecture/7.2.-fine-tuning-to-follow-instructions.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 7.2. Fine-Tuning to follow instructions
22

3+
{{#include /banners/hacktricks-training.md}}
4+
35
> [!TIP]
46
> The goal of this section is to show how to **fine-tune an already pre-trained model to follow instructions** rather than just generating text, for example, responding to tasks as a chat bot.
57
@@ -103,4 +105,6 @@ You can find an example of the code to perform this fine tuning in [https://gith
103105

104106
## References
105107

106-
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
108+
- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
109+
110+
{{#include /banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)