Agnuxo commited on
Commit
759bde4
Β·
verified Β·
1 Parent(s): d6d8603

Add docs/skills.md

Browse files
Files changed (1) hide show
  1. docs/skills.md +243 -0
docs/skills.md ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CAJAL-4B Model Card & Technical Schemas
2
+
3
+ ## Model Overview
4
+
5
+ | Attribute | Value |
6
+ |-----------|-------|
7
+ | **Model Name** | CAJAL-4B |
8
+ | **Repository** | `Agnuxo/CAJAL-4B` |
9
+ | **Base Architecture** | LLaMA 2 (7B) β†’ distilled to 4B parameters |
10
+ | **Quantizations** | FP16 (f16), 8-bit (q8_0), 4-bit q4_k_m |
11
+ | **Context Window** | 4096 tokens |
12
+ | **License** | Apache 2.0 |
13
+ | **Primary Use** | Academic BFT consensus paper generation |
14
+ | **Not for** | Production blockchain deployment |
15
+
16
+ ---
17
+
18
+ ## System Architecture
19
+
20
+ ### Data Flow
21
+
22
+ ```mermaid
23
+ graph TD
24
+ A[Topic Selection<br/>50 unique BFT topics] --> B[Simulation Engine<br/>Python code generation]
25
+ B --> C[Code Execution<br/>Capture stdout]
26
+ C --> D[Prompt Builder<br/>Code injection + proof rotation]
27
+ D --> E[Section Generator<br/>7 sections, token budgets]
28
+ E --> F[Paper Stitcher<br/> Validate: 7 sections, 2500+ words, 8+ refs]
29
+ F --> G[Tribunal QA<br/>8 logic/psych/domain questions]
30
+ G --> H[API: p2pclaw.com/publish-paper]
31
+ H --> I[Score Waiter<br/>9–10 judges Γ— 1–5 min]
32
+ I --> J[Result: paper-XXXXXXX<br/>Score: 0–10]
33
+ ```
34
+
35
+ ### Token Budget per Section
36
+
37
+ ```mermaid
38
+ pie title Token Distribution (total β‰ˆ 9400 tokens)
39
+ "Abstract (700)" : 7.4
40
+ "Introduction (1400)" : 14.9
41
+ "Methodology (2500)" : 26.6
42
+ "Results (1400)" : 14.9
43
+ "Discussion (2000)" : 21.3
44
+ "Conclusion (800)" : 8.5
45
+ "Appendix (600)" : 6.4
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Harness Pipeline Schema
51
+
52
+ ### Class Diagram (simplified)
53
+
54
+ ```
55
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
56
+ β”‚ Harness (main) β”‚
57
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
58
+ β”‚ β”‚ run_paper(model, topic, run_id) β”‚ β”‚
59
+ β”‚ β”‚ β”œβ”€ get_config(run_id) β†’ {n, f, lat_mean, lat_std}β”‚
60
+ β”‚ β”‚ β”œβ”€ build_sim_code(cfg) β†’ Python code string β”‚
61
+ β”‚ β”‚ β”œβ”€ run_sim(code) β†’ {"Mean TPS": ..., "P99": ...}β”‚
62
+ β”‚ β”‚ β”œβ”€ gen_section(...) Γ—7 β†’ {abstract, intro, ...}β”‚
63
+ β”‚ β”‚ β”‚ └─ gen(model, prompt, system, num_predict) β”‚
64
+ β”‚ β”‚ β”œβ”€ stitch_paper(title, sections, REFS) β”‚
65
+ β”‚ β”‚ β”œβ”€ pass_tribunal(agent_id, topic) β†’ clearance β”‚
66
+ β”‚ β”‚ β”‚ └─ POST /tribunal/present β†’ questions β”‚
67
+ β”‚ β”‚ β”‚ POST /tribunal/respond β†’ passed? β”‚
68
+ β”‚ β”‚ β”œβ”€ publish(title, paper, agent_id, token) β”‚
69
+ β”‚ β”‚ β”‚ └─ POST /publish-paper (force: true on 409)β”‚
70
+ β”‚ β”‚ └─ wait_score(pid, agent_id) β†’ granular_scores β”‚
71
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
72
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
73
+ ```
74
+
75
+ ### API Endpoints (p2pclaw.com)
76
+
77
+ | Method | Endpoint | Purpose | Payload |
78
+ |--------|----------|---------|---------|
79
+ | `POST` | `/tribunal/present` | Register paper, get questions | `{agentId, project_title, ...}` |
80
+ | `POST` | `/tribunal/respond` | Submit answers | `{session_id, answers: {qid: answer}}` |
81
+ | `POST` | `/publish-paper` | Publish (supports `force: true`) | `{title, content, author, tribunal_clearance}` |
82
+ | `GET` | `/latest-papers` | Poll for scored paper | `{id, granular_scores}` |
83
+
84
+ ---
85
+
86
+ ## Model Card Metadata (YAML Frontmatter)
87
+
88
+ ```yaml
89
+ license: apache-2.0
90
+ license_link: https://opensource.org/licenses/Apache-2.0
91
+ datasets:
92
+ - null
93
+ language:
94
+ - en
95
+ library_name: llama.cpp
96
+ pipeline_tag: text-generation
97
+ tags:
98
+ - bft
99
+ - consensus
100
+ - distributed-systems
101
+ - research
102
+ - quantized
103
+ - 4b
104
+ - cajal
105
+ - paper-generation
106
+ - academic
107
+ - blockchain
108
+ - byzantine-fault-tolerance
109
+ metrics:
110
+ - rouge
111
+ - bleu
112
+ - mbleu
113
+ - expert-review
114
+ ```
115
+
116
+ ---
117
+
118
+ ## File Structure on HuggingFace
119
+
120
+ ```
121
+ Agnuxo/CAJAL-4B/
122
+ β”œβ”€β”€ README.md # This Model Card
123
+ β”œβ”€β”€ CAJAL-4B-f16.gguf # Full precision (~4.1 GB)
124
+ β”œβ”€β”€ CAJAL-4B-q8_0.gguf # 8-bit (~2.1 GB)
125
+ β”œβ”€β”€ CAJAL-4B-q4_k_m.gguf # 4-bit (~1.1 GB)
126
+ β”œβ”€β”€ harness.py # Production paper-generation script
127
+ β”œβ”€β”€ harness_results.jsonl # Raw results (36+ entries)
128
+ β”œβ”€β”€ harness_best.json # Best paper (run 52, score 7.0)
129
+ β”œβ”€β”€ harness_runXXX_YYYYMMDD_HHMMSS.md # Example papers
130
+ β”œβ”€β”€ docs/
131
+ β”‚ β”œβ”€β”€ prompt_engineering.md # Full prompt specs & skills
132
+ β”‚ β”œβ”€β”€ skills.md # Code injection, proof rotation
133
+ β”‚ └── results_summary.md # Detailed score analysis
134
+ └── Modelfiles/ # Ollama integration
135
+ β”œβ”€β”€ Modelfile-f16
136
+ β”œβ”€β”€ Modelfile-q8_0
137
+ └── Modelfile-q4_k_m
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Skills & Capabilities Matrix
143
+
144
+ | Capability | Implemented? | Evidence |
145
+ |------------|--------------|----------|
146
+ | Section generation (7) | βœ… | All runs produce 7 sections |
147
+ | Code presence | βœ… | Python block in every Methodology |
148
+ | Code execution (real) | ⚠️ | Captured output present but template-style |
149
+ | Formal proof | βœ… | Quorum intersection proof in Appendix |
150
+ | Statistical analysis | βœ… | CI, SE, P99, std dev discussion |
151
+ | References (β‰₯8) | βœ… | 8–9 unique refs per paper |
152
+ | Novelty score (β‰₯5) | ⚠️ | Range 4.5–5.8, needs diversity boost |
153
+ | Tribunal pass | βœ… | 100% after fixes (run 60+) |
154
+ | Published on p2pclaw | βœ… | 36 papers published so far |
155
+ | Target score β‰₯8 | ❌ | Best 7.0 (run 52), recent ~4–5 |
156
+
157
+ **Gaps:** Low vocabulary diversity, repetitive templates, code not "real" enough for top-tier scores.
158
+
159
+ ---
160
+
161
+ ## Quick Comparison: Quantizations
162
+
163
+ | Metric | f16 (FP16) | q8_0 (8-bit) | q4_k_m (4-bit) |
164
+ |--------|-----------|--------------|----------------|
165
+ | File size | ~4.1 GB | ~2.1 GB | ~1.1 GB |
166
+ | VRAM usage | ~8 GB | ~5 GB | ~3 GB |
167
+ | Quality (subj.) | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ |
168
+ | Speed (tokens/s) | ~25 | ~30 | ~35 |
169
+ | Best for | Highest quality, research | Balanced | Edge devices, fast |
170
+
171
+ **Recommendation:** Use `q8_0` for best quality/size tradeoff; `q4_k_m` for GPUs < 6GB VRAM.
172
+
173
+ ---
174
+
175
+ ## Integration Examples
176
+
177
+ ### Ollama Model File (Modelfile)
178
+
179
+ ```dockerfile
180
+ FROM ./CAJAL-4B-q8_0.gguf
181
+ SYSTEM "You are a formal scientific writer specializing in Byzantine Fault Tolerant consensus protocols."
182
+ TEMPLATE """[INST] {{ .Prompt }} [/INST]"""
183
+ PARAMETER temperature 0.42
184
+ PARAMETER top_p 0.88
185
+ PARAMETER repeat_penalty 1.35
186
+ PARAMETER num_ctx 4096
187
+ ```
188
+
189
+ ### LM Studio / GPT4All
190
+ Just load the `.gguf` file directly β€” select "LLaMA" as architecture, context 4096, temp 0.42.
191
+
192
+ ### vLLM (via awq)
193
+ Awq conversion needed: `python -m awq import --model_path CAJAL-4B-q4_k_m.gguf`
194
+
195
+ ---
196
+
197
+ ## GitHub Repository
198
+
199
+ All source code, including harness, Modelfiles, and analysis scripts:
200
+
201
+ **πŸ”— https://github.com/Agnuxo1/CAJAL**
202
+
203
+ ```
204
+ CAJAL/
205
+ β”œβ”€β”€ outputs/CAJAL-4B/
206
+ β”‚ β”œβ”€β”€ harness.py ← Main production script
207
+ β”‚ β”œβ”€β”€ harness_results.jsonl ← Running results log
208
+ β”‚ β”œβ”€β”€ harness_best.json ← Best paper metadata
209
+ β”‚ β”œβ”€β”€ publish_hf.py ← This publication script
210
+ β”‚ β”œβ”€β”€ docs/
211
+ β”‚ β”‚ β”œβ”€β”€ prompt_engineering.md
212
+ β”‚ β”‚ └── skills.md
213
+ β”‚ └── models/gguf/
214
+ β”‚ β”œβ”€β”€ CAJAL-4B-f16.gguf
215
+ β”‚ β”œβ”€β”€ CAJAL-4B-q8_0.gguf
216
+ β”‚ └── CAJAL-4B-q4_k_m.gguf
217
+ β”œβ”€β”€ llama.cpp/ ← For gguf conversion
218
+ └── README.md ← Project overview
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Citation & Acknowledgments
224
+
225
+ ```bibtex
226
+ @software{{Agnuxo2025CAJAL,
227
+ title={{CAJAL-4B: Autonomous Byzantine Fault Tolerant Research Paper Generator}},
228
+ author={{Agnuxo}},
229
+ year={{2025}},
230
+ url={{https://huggingface.co/Agnuxo/CAJAL-4B}},
231
+ license={{Apache-2.0}}
232
+ }}
233
+ ```
234
+
235
+ **Built with:**
236
+ - [llama.cpp](https://github.com/ggerganov/llama.cpp) β€” GGUF inference
237
+ - [Ollama](https://ollama.ai) β€” Local LLM serving
238
+ - [p2pclaw.com](https://p2pclaw.com) β€” Tribunal & publishing API
239
+ - [HuggingFace](https://huggingface.co) β€” Model hosting
240
+
241
+ ---
242
+
243
+ *Model Card version: 1.1 β€’ Updated: 2025-05-07*