Text Generation
Transformers
English
zenith
tenstorrent
code
reasoning
Mixture of Experts
ring-attention
eq-adapter
matrix-corp
Instructions to use Matrix-Corp/Zenith-7b-V1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Matrix-Corp/Zenith-7b-V1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Matrix-Corp/Zenith-7b-V1")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Matrix-Corp/Zenith-7b-V1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Matrix-Corp/Zenith-7b-V1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Matrix-Corp/Zenith-7b-V1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Matrix-Corp/Zenith-7b-V1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Matrix-Corp/Zenith-7b-V1
- SGLang
How to use Matrix-Corp/Zenith-7b-V1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Matrix-Corp/Zenith-7b-V1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Matrix-Corp/Zenith-7b-V1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Matrix-Corp/Zenith-7b-V1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Matrix-Corp/Zenith-7b-V1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Matrix-Corp/Zenith-7b-V1 with Docker Model Runner:
docker model run hf.co/Matrix-Corp/Zenith-7b-V1
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,265 +1,286 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
#
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
--
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
```
|
| 66 |
-
|
| 67 |
-
##
|
| 68 |
-
|
| 69 |
-
```
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
βββ
|
| 93 |
-
βββ
|
| 94 |
-
βββ
|
| 95 |
-
βββ
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
#
|
| 109 |
-
#
|
| 110 |
-
#
|
| 111 |
-
#
|
| 112 |
-
#
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
#
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
``
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
-
|
| 164 |
-
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
##
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
-
|
| 232 |
-
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
-
|
| 236 |
-
-
|
| 237 |
-
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 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.
|