hamza-allali commited on
Commit
07957cf
·
verified ·
1 Parent(s): 4de7b1d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +91 -0
README.md CHANGED
@@ -1,3 +1,94 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ pipeline_tag: text2text-generation
6
+ library_name: pytorch
7
+ tags:
8
+ - transformer
9
+ - pytorch
10
+ - from-scratch
11
+ - linux
12
+ - seq2seq
13
  ---
14
+
15
+ # Linux Command Transformer
16
+
17
+ A small Transformer Encoder-Decoder trained from scratch with PyTorch to generate Linux commands from natural language descriptions.
18
+
19
+ This model was developed as a personal learning project to better understand the Transformer architecture, its training process, and its limitations.
20
+
21
+ The Transformer implementation was guided by [Umar Jamil's Transformer from Scratch walkthrough](https://www.youtube.com/watch?v=ISNdQcPhsts).
22
+
23
+ ## Model Architecture
24
+
25
+ The model follows the original Transformer Encoder-Decoder architecture introduced in *Attention Is All You Need*.
26
+
27
+ | Parameter | Value |
28
+ |---|---|
29
+ | Encoder Layers | 2 |
30
+ | Decoder Layers | 2 |
31
+ | Model Dimension | 64 |
32
+ | Attention Heads | 4 |
33
+ | Feed Forward Dimension | 128 |
34
+ | Tokenizer | GPT-2 |
35
+ | Maximum Source Length | 64 |
36
+ | Maximum Target Length | 96 |
37
+
38
+ The model was trained with randomly initialized weights. No pretrained language model weights were used.
39
+
40
+ ## Training
41
+
42
+ The model was trained on approximately 8,000 natural language–Linux command pairs, using an NVIDIA RTX 4060 Laptop GPU with 8 GB of VRAM.
43
+
44
+ Training configuration:
45
+
46
+ - Optimizer: AdamW
47
+ - Learning rate: 0.001
48
+ - Loss: Cross-Entropy
49
+ - Gradient clipping: 1.0
50
+ - Maximum epochs: 10
51
+
52
+ The best checkpoint was selected at epoch 6, with a validation loss of **2.0178**.
53
+
54
+ ## Evaluation Results
55
+
56
+ The model was evaluated on 796 test examples.
57
+
58
+ | Metric | Accuracy |
59
+ |---|---:|
60
+ | Exact Match | 11.68% |
61
+ | Command Accuracy | 81.03% |
62
+ | First Argument Accuracy | 36.35% |
63
+ | Command + First Argument Accuracy | 35.45% |
64
+
65
+ The model identifies the correct main Linux utility in many cases, but generating complete commands with accurate arguments remains challenging.
66
+
67
+ The argument-related metrics were calculated on 773 examples containing at least one argument. Metrics use whitespace-based command splitting rather than full shell parsing.
68
+
69
+ ## Usage
70
+
71
+ This is a custom PyTorch architecture and cannot be loaded directly using `AutoModel.from_pretrained()`.
72
+
73
+ The repository provides:
74
+
75
+ - `model.pt` — Trained model weights
76
+ - `config.json` — Architecture configuration
77
+ - `tokenizer/` — GPT-2 tokenizer configuration with additional special tokens
78
+
79
+ To run inference, use the implementation provided in the associated GitHub repository.
80
+
81
+ The inference script downloads the model from Hugging Face, reconstructs the Transformer architecture, loads the weights, and generates Linux commands.
82
+
83
+ ## Limitations
84
+
85
+ The model was trained on a relatively small dataset, and training experiments were constrained by the available GPU resources.
86
+
87
+ Although it achieves 81.03% Command Accuracy, its Exact Match Accuracy is only 11.68%.
88
+
89
+ This model is intended for educational and experimental purposes. Generated commands should be reviewed before execution, especially commands that modify or delete files.
90
+
91
+ ## References
92
+
93
+ - [Attention Is All You Need](https://arxiv.org/abs/1706.03762)
94
+ - [Umar Jamil — Coding a Transformer from Scratch](https://www.youtube.com/watch?v=ISNdQcPhsts)