Zandy-Wandy commited on
Commit
2eb1da9
Β·
verified Β·
1 Parent(s): 1ea8a03

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +285 -264
README.md CHANGED
@@ -1,265 +1,286 @@
1
- # Zenith-7B V1
2
-
3
- Standard GPU-optimized language model with code generation and emotional intelligence capabilities.
4
-
5
- ## Features
6
-
7
- - **7B Parameter Model**: Efficient for consumer GPUs (8-16GB VRAM)
8
- - **Code Generation**: Fine-tuned on Qwen2.5-Coder base for exceptional programming abilities
9
- - **Emotional Intelligence**: EQ adapter for recognizing and responding to emotions
10
- - **OpenThoughts Integration**: Trained on high-quality reasoning data
11
- - **LoRA/QLoRA Support**: Efficient fine-tuning with 4-bit quantization
12
- - **Ollama Compatible**: Ready-to-use Modelfile for easy deployment
13
-
14
- ## Quick Start
15
-
16
- ### Installation
17
-
18
- ```bash
19
- # Clone and setup
20
- cd Zenith/V1/7B
21
- pip install -r requirements.txt
22
- ```
23
-
24
- ### Training
25
-
26
- ```bash
27
- # Full fine-tuning
28
- python train.py \
29
- --base_model Qwen/Qwen2.5-Coder-7B \
30
- --train_data path/to/train.json \
31
- --epochs 3 \
32
- --batch_size 4 \
33
- --learning_rate 2e-5
34
-
35
- # LoRA fine-tuning (recommended for most users)
36
- python train.py \
37
- --base_model Qwen/Qwen2.5-Coder-7B \
38
- --train_data path/to/train.json \
39
- --use_lora \
40
- --lora_r 16 \
41
- --lora_alpha 32 \
42
- --epochs 3 \
43
- --batch_size 8
44
- ```
45
-
46
- ### Inference
47
-
48
- ```bash
49
- # Interactive mode
50
- python inference.py --checkpoint ./outputs/checkpoint-final
51
-
52
- # Single prompt
53
- python inference.py \
54
- --checkpoint ./outputs/checkpoint-final \
55
- --prompt "Write a Python function to reverse a linked list" \
56
- --max_new_tokens 512
57
- ```
58
-
59
- ### Ollama Deployment
60
-
61
- ```bash
62
- # Build and run with Ollama
63
- ollama create zenith-7b -f Modelfile
64
- ollama run zenith-7b "Explain quantum computing in simple terms"
65
- ```
66
-
67
- ## Project Structure
68
-
69
- ```
70
- Zenith/V1/7B/
71
- β”œβ”€β”€ configs/ # Configuration files
72
- β”‚ β”œβ”€β”€ zenith_config.py # Model architecture config
73
- β”‚ β”œβ”€β”€ data_config.py # Data processing config
74
- β”‚ └── training_config.py # Training hyperparameters
75
- β”œβ”€β”€ data/ # Data processing modules
76
- β”‚ β”œβ”€β”€ openthoughts_processor.py
77
- β”‚ β”œβ”€β”€ quality_filter.py
78
- β”‚ β”œβ”€β”€ curriculum_sampler.py
79
- β”‚ β”œβ”€β”€ advanced_tokenizer.py
80
- β”‚ └── preprocessing.py
81
- β”œβ”€β”€ src/ # Source code
82
- β”‚ β”œβ”€β”€ models/
83
- β”‚ β”‚ β”œβ”€β”€ zenith_model.py
84
- β”‚ β”‚ β”œβ”€β”€ dense_layer.py
85
- β”‚ β”‚ └── moe_layer.py
86
- β”‚ └── utils/
87
- β”œβ”€β”€ scripts/ # Utility scripts
88
- β”œβ”€β”€ tests/ # Test suite
89
- β”œβ”€β”€ train.py # Main training script
90
- β”œβ”€β”€ inference.py # Inference and generation
91
- β”œβ”€β”€ test_model.py # Model validation tests
92
- β”œβ”€β”€ finetune_qwen.py # Qwen fine-tuning guide
93
- β”œβ”€β”€ Modelfile # Ollama configuration
94
- β”œβ”€β”€ requirements.txt # Python dependencies
95
- └── README.md # This file
96
- ```
97
-
98
- ## Configuration
99
-
100
- The model uses a unified configuration system in `configs/zenith_config.py`:
101
-
102
- ```python
103
- from configs.zenith_config import get_7b_config
104
-
105
- config = get_7b_config()
106
- # Parameters:
107
- # - hidden_size: 4096
108
- # - num_layers: 32
109
- # - num_heads: 32
110
- # - num_experts: 0 (dense only, set >1 for MoE)
111
- # - use_eq_adapter: True (emotional intelligence)
112
- # - max_seq_len: 8192
113
- ```
114
-
115
- ## Data Processing
116
-
117
- ### OpenThoughts Integration
118
-
119
- The data pipeline supports the OpenThoughts-1.2M dataset:
120
-
121
- ```python
122
- from data.openthoughts_processor import OpenThoughtsProcessor, OpenThoughtsConfig
123
-
124
- config = OpenThoughtsConfig(
125
- dataset_name="open-thoughts/OpenThoughts3-1.2M",
126
- streaming=True,
127
- quality_filtering=True,
128
- curriculum_learning=True,
129
- augmentation=True
130
- )
131
- processor = OpenThoughtsProcessor(config)
132
- dataset = processor.load_dataset()
133
- ```
134
-
135
- ### Quality Filtering
136
-
137
- Multi-dimensional quality assessment:
138
- - Length appropriateness
139
- - Language detection (English only)
140
- - Repetition detection
141
- - Coherence scoring
142
- - Structure validation
143
- - Thought quality (for CoT data)
144
-
145
- ### Curriculum Learning
146
-
147
- Progressive training stages:
148
- 1. **Foundation**: High-quality, well-structured samples
149
- 2. **Reasoning**: Chain-of-thought and problem-solving
150
- 3. **Code**: Programming and technical content
151
- 4. **Full**: Complete dataset with all samples
152
-
153
- ## Advanced Features
154
-
155
- ### MoE (Mixture of Experts)
156
-
157
- Enable sparse activation for better performance:
158
-
159
- ```bash
160
- python train.py --use_moe --num_experts 8
161
- ```
162
-
163
- - Top-2 routing with load balancing
164
- - 60% of layers use MoE (middle layers)
165
- - Shared router groups for efficiency
166
-
167
- ### EQ Adapter
168
-
169
- Emotional intelligence module:
170
-
171
- ```bash
172
- python train.py --use_eq_adapter --eq_loss_weight 0.1
173
- ```
174
-
175
- - Frustration detection (regression)
176
- - 8-emotion classification
177
- - Fused with attention mechanism
178
-
179
- ### LoRA/QLoRA
180
-
181
- Efficient fine-tuning with low-rank adaptation:
182
-
183
- ```bash
184
- # LoRA
185
- python train.py --use_lora --lora_r 16 --lora_alpha 32
186
-
187
- # QLoRA (4-bit quantization)
188
- python train.py --use_qlora --use_lora --lora_r 8
189
- ```
190
-
191
- ## Testing
192
-
193
- Run the test suite:
194
-
195
- ```bash
196
- python test_model.py
197
- ```
198
-
199
- Tests include:
200
- - Model creation and initialization
201
- - Forward pass and gradient flow
202
- - Text generation
203
- - Multi-task outputs (EQ adapter)
204
- - Loss computation
205
-
206
- ## Requirements
207
-
208
- See `requirements.txt` for full dependencies. Key packages:
209
-
210
- - torch>=2.0.0
211
- - transformers>=4.35.0
212
- - datasets>=2.14.0
213
- - accelerate>=0.24.0
214
- - peft>=0.6.0 (for LoRA)
215
- - bitsandbytes>=0.41.0 (for QLoRA)
216
- - tensorboard>=2.14.0
217
-
218
- ## Performance Tips
219
-
220
- 1. **Mixed Precision**: Use `--mixed_precision bf16` for faster training (Ampere+ GPUs)
221
- 2. **Gradient Checkpointing**: Enabled by default to reduce memory
222
- 3. **Batch Size**: Adjust based on VRAM (4-8 for 7B full, 16-32 for LoRA)
223
- 4. **Sequence Length**: Longer sequences use more memory; adjust `--max_seq_length`
224
-
225
- ## Troubleshooting
226
-
227
- ### Out of Memory
228
- - Reduce batch size
229
- - Use gradient accumulation
230
- - Enable LoRA/QLoRA
231
- - Use mixed precision
232
- - Reduce sequence length
233
-
234
- ### Slow Training
235
- - Increase batch size if possible
236
- - Use more gradient accumulation steps
237
- - Ensure data loading is not the bottleneck
238
- - Use mixed precision
239
-
240
- ### Poor Quality Outputs
241
- - Train longer (more epochs)
242
- - Use higher quality data
243
- - Adjust learning rate (try 1e-5 to 5e-5)
244
- - Enable curriculum learning
245
- - Use quality filtering
246
-
247
- ## Citation
248
-
249
- If you use Zenith-7B in your research, please cite:
250
-
251
- ```bibtex
252
- @misc{zenith-7b-2025,
253
- title={Zenith-7B: A Hybrid MoE Model for Code and Emotional Intelligence},
254
- year={2025},
255
- publisher={Zenith Project}
256
- }
257
- ```
258
-
259
- ## License
260
-
261
- [Specify your license here]
262
-
263
- ## Contact
264
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  For issues and questions, please open an issue on the project repository.
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ base_model: Qwen/Qwen2.5-Coder-7B
6
+ tags:
7
+ - zenith
8
+ - tenstorrent
9
+ - code
10
+ - reasoning
11
+ - moe
12
+ - ring-attention
13
+ - eq-adapter
14
+ - matrix-corp
15
+ pipeline_tag: text-generation
16
+ library_name: transformers
17
+ model_type: zenith
18
+ hardware:
19
+ - tenstorrent-blackhole-p300a
20
+ ---
21
+
22
+ # Zenith-7B V1
23
+
24
+ Standard GPU-optimized language model with code generation and emotional intelligence capabilities.
25
+
26
+ ## Features
27
+
28
+ - **7B Parameter Model**: Efficient for consumer GPUs (8-16GB VRAM)
29
+ - **Code Generation**: Fine-tuned on Qwen2.5-Coder base for exceptional programming abilities
30
+ - **Emotional Intelligence**: EQ adapter for recognizing and responding to emotions
31
+ - **OpenThoughts Integration**: Trained on high-quality reasoning data
32
+ - **LoRA/QLoRA Support**: Efficient fine-tuning with 4-bit quantization
33
+ - **Ollama Compatible**: Ready-to-use Modelfile for easy deployment
34
+
35
+ ## Quick Start
36
+
37
+ ### Installation
38
+
39
+ ```bash
40
+ # Clone and setup
41
+ cd Zenith/V1/7B
42
+ pip install -r requirements.txt
43
+ ```
44
+
45
+ ### Training
46
+
47
+ ```bash
48
+ # Full fine-tuning
49
+ python train.py \
50
+ --base_model Qwen/Qwen2.5-Coder-7B \
51
+ --train_data path/to/train.json \
52
+ --epochs 3 \
53
+ --batch_size 4 \
54
+ --learning_rate 2e-5
55
+
56
+ # LoRA fine-tuning (recommended for most users)
57
+ python train.py \
58
+ --base_model Qwen/Qwen2.5-Coder-7B \
59
+ --train_data path/to/train.json \
60
+ --use_lora \
61
+ --lora_r 16 \
62
+ --lora_alpha 32 \
63
+ --epochs 3 \
64
+ --batch_size 8
65
+ ```
66
+
67
+ ### Inference
68
+
69
+ ```bash
70
+ # Interactive mode
71
+ python inference.py --checkpoint ./outputs/checkpoint-final
72
+
73
+ # Single prompt
74
+ python inference.py \
75
+ --checkpoint ./outputs/checkpoint-final \
76
+ --prompt "Write a Python function to reverse a linked list" \
77
+ --max_new_tokens 512
78
+ ```
79
+
80
+ ### Ollama Deployment
81
+
82
+ ```bash
83
+ # Build and run with Ollama
84
+ ollama create zenith-7b -f Modelfile
85
+ ollama run zenith-7b "Explain quantum computing in simple terms"
86
+ ```
87
+
88
+ ## Project Structure
89
+
90
+ ```
91
+ Zenith/V1/7B/
92
+ β”œβ”€β”€ configs/ # Configuration files
93
+ β”‚ β”œβ”€β”€ zenith_config.py # Model architecture config
94
+ β”‚ β”œβ”€β”€ data_config.py # Data processing config
95
+ β”‚ └── training_config.py # Training hyperparameters
96
+ β”œβ”€β”€ data/ # Data processing modules
97
+ β”‚ β”œβ”€β”€ openthoughts_processor.py
98
+ β”‚ β”œβ”€β”€ quality_filter.py
99
+ β”‚ β”œβ”€β”€ curriculum_sampler.py
100
+ β”‚ β”œβ”€β”€ advanced_tokenizer.py
101
+ β”‚ └── preprocessing.py
102
+ β”œβ”€β”€ src/ # Source code
103
+ β”‚ β”œβ”€β”€ models/
104
+ β”‚ β”‚ β”œβ”€β”€ zenith_model.py
105
+ β”‚ β”‚ β”œβ”€β”€ dense_layer.py
106
+ β”‚ β”‚ └── moe_layer.py
107
+ β”‚ └── utils/
108
+ β”œβ”€β”€ scripts/ # Utility scripts
109
+ β”œβ”€β”€ tests/ # Test suite
110
+ β”œβ”€β”€ train.py # Main training script
111
+ β”œβ”€β”€ inference.py # Inference and generation
112
+ β”œβ”€β”€ test_model.py # Model validation tests
113
+ β”œβ”€β”€ finetune_qwen.py # Qwen fine-tuning guide
114
+ β”œβ”€β”€ Modelfile # Ollama configuration
115
+ β”œβ”€β”€ requirements.txt # Python dependencies
116
+ └── README.md # This file
117
+ ```
118
+
119
+ ## Configuration
120
+
121
+ The model uses a unified configuration system in `configs/zenith_config.py`:
122
+
123
+ ```python
124
+ from configs.zenith_config import get_7b_config
125
+
126
+ config = get_7b_config()
127
+ # Parameters:
128
+ # - hidden_size: 4096
129
+ # - num_layers: 32
130
+ # - num_heads: 32
131
+ # - num_experts: 0 (dense only, set >1 for MoE)
132
+ # - use_eq_adapter: True (emotional intelligence)
133
+ # - max_seq_len: 8192
134
+ ```
135
+
136
+ ## Data Processing
137
+
138
+ ### OpenThoughts Integration
139
+
140
+ The data pipeline supports the OpenThoughts-1.2M dataset:
141
+
142
+ ```python
143
+ from data.openthoughts_processor import OpenThoughtsProcessor, OpenThoughtsConfig
144
+
145
+ config = OpenThoughtsConfig(
146
+ dataset_name="open-thoughts/OpenThoughts3-1.2M",
147
+ streaming=True,
148
+ quality_filtering=True,
149
+ curriculum_learning=True,
150
+ augmentation=True
151
+ )
152
+ processor = OpenThoughtsProcessor(config)
153
+ dataset = processor.load_dataset()
154
+ ```
155
+
156
+ ### Quality Filtering
157
+
158
+ Multi-dimensional quality assessment:
159
+ - Length appropriateness
160
+ - Language detection (English only)
161
+ - Repetition detection
162
+ - Coherence scoring
163
+ - Structure validation
164
+ - Thought quality (for CoT data)
165
+
166
+ ### Curriculum Learning
167
+
168
+ Progressive training stages:
169
+ 1. **Foundation**: High-quality, well-structured samples
170
+ 2. **Reasoning**: Chain-of-thought and problem-solving
171
+ 3. **Code**: Programming and technical content
172
+ 4. **Full**: Complete dataset with all samples
173
+
174
+ ## Advanced Features
175
+
176
+ ### MoE (Mixture of Experts)
177
+
178
+ Enable sparse activation for better performance:
179
+
180
+ ```bash
181
+ python train.py --use_moe --num_experts 8
182
+ ```
183
+
184
+ - Top-2 routing with load balancing
185
+ - 60% of layers use MoE (middle layers)
186
+ - Shared router groups for efficiency
187
+
188
+ ### EQ Adapter
189
+
190
+ Emotional intelligence module:
191
+
192
+ ```bash
193
+ python train.py --use_eq_adapter --eq_loss_weight 0.1
194
+ ```
195
+
196
+ - Frustration detection (regression)
197
+ - 8-emotion classification
198
+ - Fused with attention mechanism
199
+
200
+ ### LoRA/QLoRA
201
+
202
+ Efficient fine-tuning with low-rank adaptation:
203
+
204
+ ```bash
205
+ # LoRA
206
+ python train.py --use_lora --lora_r 16 --lora_alpha 32
207
+
208
+ # QLoRA (4-bit quantization)
209
+ python train.py --use_qlora --use_lora --lora_r 8
210
+ ```
211
+
212
+ ## Testing
213
+
214
+ Run the test suite:
215
+
216
+ ```bash
217
+ python test_model.py
218
+ ```
219
+
220
+ Tests include:
221
+ - Model creation and initialization
222
+ - Forward pass and gradient flow
223
+ - Text generation
224
+ - Multi-task outputs (EQ adapter)
225
+ - Loss computation
226
+
227
+ ## Requirements
228
+
229
+ See `requirements.txt` for full dependencies. Key packages:
230
+
231
+ - torch>=2.0.0
232
+ - transformers>=4.35.0
233
+ - datasets>=2.14.0
234
+ - accelerate>=0.24.0
235
+ - peft>=0.6.0 (for LoRA)
236
+ - bitsandbytes>=0.41.0 (for QLoRA)
237
+ - tensorboard>=2.14.0
238
+
239
+ ## Performance Tips
240
+
241
+ 1. **Mixed Precision**: Use `--mixed_precision bf16` for faster training (Ampere+ GPUs)
242
+ 2. **Gradient Checkpointing**: Enabled by default to reduce memory
243
+ 3. **Batch Size**: Adjust based on VRAM (4-8 for 7B full, 16-32 for LoRA)
244
+ 4. **Sequence Length**: Longer sequences use more memory; adjust `--max_seq_length`
245
+
246
+ ## Troubleshooting
247
+
248
+ ### Out of Memory
249
+ - Reduce batch size
250
+ - Use gradient accumulation
251
+ - Enable LoRA/QLoRA
252
+ - Use mixed precision
253
+ - Reduce sequence length
254
+
255
+ ### Slow Training
256
+ - Increase batch size if possible
257
+ - Use more gradient accumulation steps
258
+ - Ensure data loading is not the bottleneck
259
+ - Use mixed precision
260
+
261
+ ### Poor Quality Outputs
262
+ - Train longer (more epochs)
263
+ - Use higher quality data
264
+ - Adjust learning rate (try 1e-5 to 5e-5)
265
+ - Enable curriculum learning
266
+ - Use quality filtering
267
+
268
+ ## Citation
269
+
270
+ If you use Zenith-7B in your research, please cite:
271
+
272
+ ```bibtex
273
+ @misc{zenith-7b-2025,
274
+ title={Zenith-7B: A Hybrid MoE Model for Code and Emotional Intelligence},
275
+ year={2025},
276
+ publisher={Zenith Project}
277
+ }
278
+ ```
279
+
280
+ ## License
281
+
282
+ [Specify your license here]
283
+
284
+ ## Contact
285
+
286
  For issues and questions, please open an issue on the project repository.