AbstractPhil commited on
Commit
06529d6
Β·
verified Β·
1 Parent(s): 999dc94

Update README - Run 20251012_191456

Browse files
Files changed (1) hide show
  1. README.md +212 -0
README.md ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ tags:
5
+ - image-classification
6
+ - imagenet
7
+ - multi-scale
8
+ - crystal-geometry
9
+ - david
10
+ datasets:
11
+ - imagenet-1k
12
+ metrics:
13
+ - accuracy
14
+ model-index:
15
+ - name: David-partial_shared-hierarchical_tree
16
+ results:
17
+ - task:
18
+ type: image-classification
19
+ dataset:
20
+ name: ImageNet-1K
21
+ type: imagenet-1k
22
+ metrics:
23
+ - type: accuracy
24
+ value: 66.69
25
+ ---
26
+
27
+ # David: Multi-Scale Crystal Classifier
28
+
29
+ **David** is a multi-scale deep learning classifier that uses crystal geometry (pentachora/4-simplexes)
30
+ as class prototypes with role-weighted similarity computation (Rose Loss).
31
+
32
+ ## Model Details
33
+
34
+ ### Architecture
35
+ - **Preset**: balanced
36
+ - **Sharing Mode**: partial_shared
37
+ - **Fusion Mode**: hierarchical_tree
38
+ - **Scales**: [256, 512, 768, 1024]
39
+ - **Feature Dim**: 512
40
+ - **Parameters**: 8,758,271
41
+
42
+ ### Training Configuration
43
+ - **Dataset**: AbstractPhil/imagenet-clip-features-orderly
44
+ - **Model Variant**: ['clip_vit_b32', 'clip_vit_laion_b32']
45
+ - **Epochs**: 10
46
+ - **Batch Size**: 1024
47
+ - **Learning Rate**: 0.01
48
+ - **Rose Loss Weight**: 0.2 β†’ 0.8
49
+ - **Cayley Loss**: True
50
+
51
+ ## Performance
52
+
53
+ ### Best Results
54
+ - **Validation Accuracy**: 66.69%
55
+ - **Best Epoch**: 0
56
+ - **Final Train Accuracy**: 54.53%
57
+
58
+ ### Per-Scale Performance
59
+ - **Scale 256**: 66.69%
60
+
61
+
62
+ ## Usage
63
+
64
+ ### Quick Model Lookup
65
+
66
+ **Check `MODELS_INDEX.json` in the repo root** - it lists all trained models sorted by accuracy with links to weights and configs.
67
+
68
+ ### Repository Structure
69
+
70
+ ```
71
+ AbstractPhil/david-shared-space/
72
+ β”œβ”€β”€ MODELS_INDEX.json # πŸ“Š Master index of all models (sorted by accuracy)
73
+ β”œβ”€β”€ README.md # This file
74
+ β”œβ”€β”€ best_model.json # Latest best model info
75
+ β”œβ”€β”€ weights/
76
+ β”‚ └── david_balanced/
77
+ β”‚ └── 20251012_191456/
78
+ β”‚ β”œβ”€β”€ MODEL_SUMMARY.txt # 🎯 Human-readable performance summary
79
+ β”‚ β”œβ”€β”€ training_history.json # πŸ“ˆ Epoch-by-epoch training curve
80
+ β”‚ β”œβ”€β”€ best_model_acc66.69.safetensors # ⭐ Accuracy in filename!
81
+ β”‚ β”œβ”€β”€ best_model_acc66.69_metadata.json
82
+ β”‚ β”œβ”€β”€ final_model.safetensors
83
+ β”‚ β”œβ”€β”€ checkpoint_epoch_X_accYY.YY.safetensors
84
+ β”‚ β”œβ”€β”€ david_config.json
85
+ β”‚ └── train_config.json
86
+ └── runs/
87
+ └── david_balanced/
88
+ └── 20251012_191456/
89
+ └── events.out.tfevents.* # TensorBoard logs
90
+ ```
91
+
92
+ ### Loading the Model
93
+
94
+ ```python
95
+ from geovocab2.train.model.core.david import David, DavidArchitectureConfig
96
+ from huggingface_hub import hf_hub_download
97
+
98
+ # Browse available models in MODELS_INDEX.json first!
99
+
100
+ # Specify model variant and run
101
+ model_name = "david_balanced"
102
+ run_id = "20251012_191456"
103
+ accuracy = "66.69" # From MODELS_INDEX.json
104
+
105
+ # Download config
106
+ config_path = hf_hub_download(
107
+ repo_id="AbstractPhil/david-shared-space",
108
+ filename=f"weights/{model_name}/{run_id}/david_config.json"
109
+ )
110
+ config = DavidArchitectureConfig.from_json(config_path)
111
+
112
+ # Download weights (accuracy in filename!)
113
+ weights_path = hf_hub_download(
114
+ repo_id="AbstractPhil/david-shared-space",
115
+ filename=f"weights/{model_name}/{run_id}/best_model_acc{accuracy}.safetensors"
116
+ )
117
+
118
+ # Download training history (optional - see full training curve)
119
+ history_path = hf_hub_download(
120
+ repo_id="AbstractPhil/david-shared-space",
121
+ filename=f"weights/{model_name}/{run_id}/training_history.json"
122
+ )
123
+
124
+ # Load model
125
+ from safetensors.torch import load_file
126
+ david = David.from_config(config)
127
+ david.load_state_dict(load_file(weights_path))
128
+ david.eval()
129
+ ```
130
+
131
+ ### Inference
132
+
133
+ ```python
134
+ import torch
135
+ import torch.nn.functional as F
136
+
137
+ # Assuming you have CLIP features (512-dim for ViT-B/16)
138
+ features = get_clip_features(image) # [1, 512]
139
+
140
+ # Load anchors
141
+ anchors_dict = torch.load("anchors.pth")
142
+
143
+ # Forward pass
144
+ with torch.no_grad():
145
+ logits, _ = david(features, anchors_dict)
146
+ predictions = logits.argmax(dim=-1)
147
+ ```
148
+
149
+ ## Architecture Overview
150
+
151
+ ### Multi-Scale Processing
152
+ David processes inputs at multiple scales (256, 512, 768, 1024),
153
+ allowing it to capture both coarse and fine-grained features.
154
+
155
+ ### Shared Representation Space
156
+ This variation shares multiple versions of clip-vit models in the same representation space.
157
+
158
+ ### Crystal Geometry
159
+ Each class is represented by a pentachoron (4-simplex) in embedding space with 5 vertices:
160
+ - **Anchor**: Primary class representative
161
+ - **Need**: Complementary direction
162
+ - **Relation**: Contextual alignment
163
+ - **Purpose**: Functional direction
164
+ - **Observer**: Meta-perspective
165
+
166
+ ### Rose Loss
167
+ Similarity computation uses role-weighted cosine similarities:
168
+ ```
169
+ score = w_anchor * sim(z, anchor) + w_need * sim(z, need) + ...
170
+ ```
171
+
172
+ ### Fusion Strategy
173
+ **hierarchical_tree**: Intelligently combines predictions from multiple scales.
174
+
175
+ ## Training Details
176
+
177
+ ### Loss Components
178
+ - **Cross-Entropy**: Standard classification loss
179
+ - **Rose Loss**: Pentachora role-weighted margin loss (weight: 0.2β†’0.8)
180
+ - **Cayley Loss**: Geometric regularization (enabled)
181
+
182
+ ### Optimization
183
+ - **Optimizer**: AdamW
184
+ - **Weight Decay**: 1e-05
185
+ - **Scheduler**: cosine_restarts
186
+ - **Gradient Clip**: 10.0
187
+ - **Mixed Precision**: False
188
+
189
+ ## Citation
190
+
191
+ ```bibtex
192
+ @software{david_classifier_2025,
193
+ title = {David: Multi-Scale Crystal Classifier},
194
+ author = {AbstractPhil},
195
+ year = {2025},
196
+ url = {https://huggingface.co/AbstractPhil/david-shared-space},
197
+ note = {Run ID: 20251012_191456}
198
+ }
199
+ ```
200
+
201
+ ## License
202
+
203
+ MIT License
204
+
205
+ ## Acknowledgments
206
+
207
+ Built with crystal lattice geometry and multi-scale deep learning.
208
+ Special thanks to Claude (Anthropic) for debugging assistance.
209
+
210
+ ---
211
+
212
+ *Generated on 2025-10-12 19:18:12*