jahidhasan commited on
Commit
3daefcf
·
verified ·
1 Parent(s): f8d5d8c

Upload OS Reasoning Model v2.0

Browse files
README.md ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ tags:
5
+ - operating-systems
6
+ - reasoning
7
+ - education
8
+ - computer-science
9
+ - microsoft/DialoGPT-medium
10
+ - fine-tuned
11
+ datasets:
12
+ - custom-os-corpus
13
+ metrics:
14
+ - accuracy
15
+ - reasoning-quality
16
+ widget:
17
+ - text: "What is a process in operating systems?"
18
+ example_title: "Process Concept"
19
+ - text: "How does virtual memory work?"
20
+ example_title: "Virtual Memory"
21
+ - text: "Compare mutex locks and semaphores."
22
+ example_title: "Synchronization Comparison"
23
+ - text: "How would you solve the producer-consumer problem?"
24
+ example_title: "Problem Solving"
25
+ ---
26
+
27
+ # OS Reasoning Model v2.0
28
+
29
+ ## Model Description
30
+
31
+ It is a updated version of Operating Systems reasoning model, fine-tuned from **microsoft/DialoGPT-medium** specifically for educational purposes for Operating Systems course. The model can helps:
32
+
33
+ - **Step-by-step reasoning** about OS concepts
34
+ - **Problem-solving** for OS-related challenges
35
+ - **Comparative analysis** of different OS mechanisms
36
+ - **Educational explanations** suitable for students and professionals
37
+
38
+ ## Key Improvements (v2.0)
39
+
40
+ ### Architecture
41
+ - **Base Model**: microsoft/DialoGPT-medium (state-of-the-art reasoning capabilities)
42
+ - **Training Strategy**: Structured reasoning templates with quality scoring
43
+ - **Data Quality**: Enhanced content extraction with concept density filtering
44
+ - **Response Format**: Structured step-by-step reasoning format
45
+
46
+ ### Training Data
47
+ - **Total Examples**: 147 high-quality reasoning examples
48
+ - **Content Sources**: Curated from authoritative OS textbooks (OSTEP, xv6, etc.)
49
+ - **Reasoning Types**: Concept explanation, problem-solving, comparative analysis
50
+
51
+ ## Training Statistics
52
+
53
+ ### Example Distribution by Type
54
+ - **Concept Explanation**: 106 examples
55
+ - **Comparison**: 41 examples
56
+
57
+ ### Top OS Concepts
58
+ - **memory**: 23 examples
59
+ - **process**: 15 examples
60
+ - **security**: 12 examples
61
+ - **device**: 10 examples
62
+ - **lock**: 5 examples
63
+ - **task**: 5 examples
64
+ - **authentication**: 5 examples
65
+ - **heap**: 4 examples
66
+ - **memory vs virtual memory**: 4 examples
67
+ - **virtual memory**: 4 examples
68
+
69
+ ## 💻 Usage
70
+
71
+ ### Quick Start
72
+ ```python
73
+ from transformers import AutoTokenizer, AutoModelForCausalLM
74
+ import torch
75
+
76
+ # Load model and tokenizer
77
+ model_name = "jahidhasan/os_reasoning_model-v2"
78
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
79
+ model = AutoModelForCausalLM.from_pretrained(
80
+ model_name,
81
+ torch_dtype=torch.bfloat16,
82
+ device_map="auto",
83
+ trust_remote_code=True
84
+ )
85
+
86
+ def ask_os_question(question):
87
+ prompt = f'''<|begin_of_text|><|start_header_id|>system<|end_header_id|>
88
+
89
+ You are an expert in Operating Systems. Provide clear, step-by-step reasoning for OS concepts and problems.
90
+
91
+ <|eot_id|><|start_header_id|>user<|end_header_id|>
92
+
93
+ {question}
94
+
95
+ <|eot_id|><|start_header_id|>assistant<|end_header_id|>
96
+
97
+ '''
98
+
99
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
100
+
101
+ with torch.no_grad():
102
+ outputs = model.generate(
103
+ **inputs,
104
+ max_new_tokens=500,
105
+ do_sample=True,
106
+ temperature=0.7,
107
+ top_p=0.9,
108
+ repetition_penalty=1.1
109
+ )
110
+
111
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
112
+
113
+ # Extract assistant response
114
+ assistant_start = response.find("<|start_header_id|>assistant<|end_header_id|>")
115
+ if assistant_start != -1:
116
+ response = response[assistant_start + len("<|start_header_id|>assistant<|end_header_id|>"):].strip()
117
+
118
+ return response
119
+
120
+ # Example usage
121
+ question = "What is a deadlock in operating systems and how can it be prevented?"
122
+ answer = ask_os_question(question)
123
+ print(answer)
124
+ ```
125
+
126
+ ### Example Outputs
127
+
128
+ **Question**: "What is virtual memory in operating systems?"
129
+
130
+ **Response**:
131
+ ```
132
+ Let me explain virtual memory step by step:
133
+
134
+ Step 1: Definition and Context
135
+ Virtual memory is a memory management technique that provides an abstraction layer between the physical memory and the processes running on the system.
136
+
137
+ Step 2: How it Works
138
+ The mechanism involves mapping virtual addresses to physical addresses through page tables, allowing processes to have their own virtual address space that may be larger than physical RAM.
139
+
140
+ Step 3: Why it's Important
141
+ This is crucial because it enables memory isolation between processes, allows efficient memory utilization, and provides the illusion of unlimited memory to applications.
142
+
143
+ Step 4: Practical Example
144
+ In practice, when a process accesses a virtual address, the Memory Management Unit (MMU) translates it to a physical address, handling page faults when data needs to be loaded from storage.
145
+
146
+ Therefore, virtual memory is a fundamental abstraction that plays a vital role in modern operating system memory management.
147
+ ```
148
+
149
+ ## Technical Details
150
+
151
+ ### Model Architecture
152
+ - **Base**: microsoft/DialoGPT-medium
153
+ - **Fine-tuning**: Full parameter fine-tuning with LoRA optimization
154
+ - **Context Length**: 1024 tokens (optimized for detailed reasoning)
155
+ - **Precision**: BFloat16 for numerical stability
156
+
157
+ ### Training Configuration
158
+ - **Epochs**: 3 (optimal for generalization)
159
+ - **Batch Size**: 16 (with gradient accumulation)
160
+ - **Learning Rate**: 1e-5 (conservative for large model)
161
+ - **Optimizer**: AdamW with cosine scheduling
162
+ - **Regularization**: Weight decay + label smoothing
163
+
164
+ ### Performance Optimizations
165
+ - **Flash Attention 2**: Efficient attention computation
166
+ - **Gradient Checkpointing**: Memory-efficient training
167
+ - **Mixed Precision**: BFloat16 for speed and stability
168
+
169
+ ## Limitations and Considerations
170
+
171
+ - **Domain-Specific**: Optimized for OS topics, may not generalize to other domains
172
+ - **Training Data Bias**: Based on specific textbooks and may reflect their perspectives
173
+ - **Computational Requirements**: Requires GPU for optimal inference speed
174
+ - **Context Window**: Limited to 1024 tokens for input context
175
+
176
+ ## 🔄 Version History
177
+
178
+ ### v2.0 (Current)
179
+ - Upgraded to microsoft/DialoGPT-medium architecture
180
+ - Enhanced training data with quality scoring
181
+ - Improved reasoning structure and templates
182
+ - Better evaluation and testing framework
183
+
184
+ ### v1.0 (Previous)
185
+ - Initial release with DistilGPT-2 base
186
+ - Basic reasoning capabilities
187
+ - Limited training data quality
188
+
189
+ ## Training Data Sources
190
+
191
+ - **OSTEP (Operating Systems: Three Easy Pieces)** - Comprehensive OS textbook
192
+ - **xv6 Documentation** - MIT's teaching operating system
193
+ - **Educational Resources** - Curated learning materials
194
+
195
+ *All training data respects copyright and fair use guidelines.*
196
+
197
+ ## 🤝 Contributing
198
+
199
+ We welcome contributions to improve the model:
200
+
201
+ - **Issue Reports**: Found a problem? Let us know!
202
+ - **Training Data**: High-quality OS content suggestions
203
+ - **Evaluation**: Help us test on diverse OS scenarios
204
+ - **Documentation**: Improvements to usage examples
205
+
206
+ ## 📄 Citation
207
+
208
+ If you use this model in your research or educational work, please cite:
209
+
210
+ ```bibtex
211
+ @misc{os-reasoning-model-v2,
212
+ author = {Jahid Hasan},
213
+ title = {Operating System Reasoning Model v2.0},
214
+ year = {2025},
215
+ publisher = {Hugging Face},
216
+ url = {https://huggingface.co/jahidhasan/os_reasoning_model-v2},
217
+ note = {Fine-tuned from microsoft/DialoGPT-medium}
218
+ }
219
+ ```
220
+
221
+ **Trained with ❤️ for Operating Systems Education**
222
+
chat_template.jinja ADDED
@@ -0,0 +1 @@
 
 
1
+ {% for message in messages %}{{ message.content }}{{ eos_token }}{% endfor %}
checkpoint-20/chat_template.jinja ADDED
@@ -0,0 +1 @@
 
 
1
+ {% for message in messages %}{{ message.content }}{{ eos_token }}{% endfor %}
checkpoint-20/config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": [
4
+ "GPT2LMHeadModel"
5
+ ],
6
+ "attn_pdrop": 0.1,
7
+ "bos_token_id": 50256,
8
+ "embd_pdrop": 0.1,
9
+ "eos_token_id": 50256,
10
+ "initializer_range": 0.02,
11
+ "layer_norm_epsilon": 1e-05,
12
+ "model_type": "gpt2",
13
+ "n_ctx": 1024,
14
+ "n_embd": 1024,
15
+ "n_head": 16,
16
+ "n_inner": null,
17
+ "n_layer": 24,
18
+ "n_positions": 1024,
19
+ "reorder_and_upcast_attn": false,
20
+ "resid_pdrop": 0.1,
21
+ "scale_attn_by_inverse_layer_idx": false,
22
+ "scale_attn_weights": true,
23
+ "summary_activation": null,
24
+ "summary_first_dropout": 0.1,
25
+ "summary_proj_to_labels": true,
26
+ "summary_type": "cls_index",
27
+ "summary_use_proj": true,
28
+ "task_specific_params": {
29
+ "conversational": {
30
+ "max_length": 1000
31
+ }
32
+ },
33
+ "torch_dtype": "float16",
34
+ "transformers_version": "4.55.4",
35
+ "use_cache": true,
36
+ "vocab_size": 50257
37
+ }
checkpoint-20/generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 50256,
4
+ "eos_token_id": 50256,
5
+ "transformers_version": "4.55.4"
6
+ }
checkpoint-20/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-20/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c75c18657617ced672b037e3443c2e72807709a24f0c715daf0764b6d292fa4a
3
+ size 709676376
checkpoint-20/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da992268a7428730edf16ba3b031ca24682012eb88484d8c657ed5bcb3a247e0
3
+ size 1419537099
checkpoint-20/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62d029c66cac9889cbf604ef2d007948d1309d51fa9aacff4a31cb6a6819b981
3
+ size 14645
checkpoint-20/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:499a2280d2e7e862f2cca100ddc5f374381b31b2dedc0d64c195d4d0812f1652
3
+ size 1465
checkpoint-20/special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": true,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
checkpoint-20/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-20/tokenizer_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "50256": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ }
13
+ },
14
+ "bos_token": "<|endoftext|>",
15
+ "clean_up_tokenization_spaces": true,
16
+ "eos_token": "<|endoftext|>",
17
+ "errors": "replace",
18
+ "extra_special_tokens": {},
19
+ "model_max_length": 1024,
20
+ "pad_token": "<|endoftext|>",
21
+ "padding_side": "right",
22
+ "tokenizer_class": "GPT2Tokenizer",
23
+ "unk_token": "<|endoftext|>"
24
+ }
checkpoint-20/trainer_state.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 2.0,
6
+ "eval_steps": 500,
7
+ "global_step": 20,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [],
12
+ "logging_steps": 50,
13
+ "max_steps": 20,
14
+ "num_input_tokens_seen": 0,
15
+ "num_train_epochs": 2,
16
+ "save_steps": 250,
17
+ "stateful_callbacks": {
18
+ "TrainerControl": {
19
+ "args": {
20
+ "should_epoch_stop": false,
21
+ "should_evaluate": false,
22
+ "should_log": false,
23
+ "should_save": true,
24
+ "should_training_stop": true
25
+ },
26
+ "attributes": {}
27
+ }
28
+ },
29
+ "total_flos": 273038004191232.0,
30
+ "train_batch_size": 1,
31
+ "trial_name": null,
32
+ "trial_params": null
33
+ }
checkpoint-20/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a103e3aa2f82184d70ff55cbc0e3b4ad65d31772257a9e9167dd60228b912fb0
3
+ size 5713
checkpoint-20/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": [
4
+ "GPT2LMHeadModel"
5
+ ],
6
+ "attn_pdrop": 0.1,
7
+ "bos_token_id": 50256,
8
+ "embd_pdrop": 0.1,
9
+ "eos_token_id": 50256,
10
+ "initializer_range": 0.02,
11
+ "layer_norm_epsilon": 1e-05,
12
+ "model_type": "gpt2",
13
+ "n_ctx": 1024,
14
+ "n_embd": 1024,
15
+ "n_head": 16,
16
+ "n_inner": null,
17
+ "n_layer": 24,
18
+ "n_positions": 1024,
19
+ "reorder_and_upcast_attn": false,
20
+ "resid_pdrop": 0.1,
21
+ "scale_attn_by_inverse_layer_idx": false,
22
+ "scale_attn_weights": true,
23
+ "summary_activation": null,
24
+ "summary_first_dropout": 0.1,
25
+ "summary_proj_to_labels": true,
26
+ "summary_type": "cls_index",
27
+ "summary_use_proj": true,
28
+ "task_specific_params": {
29
+ "conversational": {
30
+ "max_length": 1000
31
+ }
32
+ },
33
+ "torch_dtype": "float16",
34
+ "transformers_version": "4.55.4",
35
+ "use_cache": true,
36
+ "vocab_size": 50257
37
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 50256,
4
+ "eos_token_id": 50256,
5
+ "transformers_version": "4.55.4"
6
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c75c18657617ced672b037e3443c2e72807709a24f0c715daf0764b6d292fa4a
3
+ size 709676376
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": true,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "50256": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ }
13
+ },
14
+ "bos_token": "<|endoftext|>",
15
+ "clean_up_tokenization_spaces": true,
16
+ "eos_token": "<|endoftext|>",
17
+ "errors": "replace",
18
+ "extra_special_tokens": {},
19
+ "model_max_length": 1024,
20
+ "pad_token": "<|endoftext|>",
21
+ "padding_side": "right",
22
+ "tokenizer_class": "GPT2Tokenizer",
23
+ "unk_token": "<|endoftext|>"
24
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a103e3aa2f82184d70ff55cbc0e3b4ad65d31772257a9e9167dd60228b912fb0
3
+ size 5713
vocab.json ADDED
The diff for this file is too large to render. See raw diff