File size: 8,422 Bytes
0f27980
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# CAJAL-4B Model Card & Technical Schemas

## Model Overview

| Attribute | Value |
|-----------|-------|
| **Model Name** | CAJAL-4B |
| **Repository** | `Agnuxo/CAJAL-4B` |
| **Base Architecture** | LLaMA 2 (7B) β†’ distilled to 4B parameters |
| **Quantizations** | FP16 (f16), 8-bit (q8_0), 4-bit q4_k_m |
| **Context Window** | 4096 tokens |
| **License** | Apache 2.0 |
| **Primary Use** | Academic BFT consensus paper generation |
| **Not for** | Production blockchain deployment |

---

## System Architecture

### Data Flow

```mermaid
graph TD
    A[Topic Selection<br/>50 unique BFT topics] --> B[Simulation Engine<br/>Python code generation]
    B --> C[Code Execution<br/>Capture stdout]
    C --> D[Prompt Builder<br/>Code injection + proof rotation]
    D --> E[Section Generator<br/>7 sections, token budgets]
    E --> F[Paper Stitcher<br/> Validate: 7 sections, 2500+ words, 8+ refs]
    F --> G[Tribunal QA<br/>8 logic/psych/domain questions]
    G --> H[API: p2pclaw.com/publish-paper]
    H --> I[Score Waiter<br/>9–10 judges Γ— 1–5 min]
    I --> J[Result: paper-XXXXXXX<br/>Score: 0–10]
```

### Token Budget per Section

```mermaid
pie title Token Distribution (total β‰ˆ 9400 tokens)
    "Abstract (700)" : 7.4
    "Introduction (1400)" : 14.9
    "Methodology (2500)" : 26.6
    "Results (1400)" : 14.9
    "Discussion (2000)" : 21.3
    "Conclusion (800)" : 8.5
    "Appendix (600)" : 6.4
```

---

## Harness Pipeline Schema

### Class Diagram (simplified)

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Harness (main)                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  run_paper(model, topic, run_id)                   β”‚ β”‚
β”‚  β”‚    β”œβ”€ get_config(run_id) β†’ {n, f, lat_mean, lat_std}β”‚
β”‚  β”‚    β”œβ”€ build_sim_code(cfg) β†’ Python code string     β”‚
β”‚  β”‚    β”œβ”€ run_sim(code) β†’ {"Mean TPS": ..., "P99": ...}β”‚
β”‚  β”‚    β”œβ”€ gen_section(...) Γ—7 β†’ {abstract, intro, ...}β”‚
β”‚  β”‚    β”‚    └─ gen(model, prompt, system, num_predict) β”‚
β”‚  β”‚    β”œβ”€ stitch_paper(title, sections, REFS)          β”‚
β”‚  β”‚    β”œβ”€ pass_tribunal(agent_id, topic) β†’ clearance   β”‚
β”‚  β”‚    β”‚    └─ POST /tribunal/present β†’ questions      β”‚
β”‚  β”‚    β”‚        POST /tribunal/respond β†’ passed?        β”‚
β”‚  β”‚    β”œβ”€ publish(title, paper, agent_id, token)       β”‚
β”‚  β”‚    β”‚    └─ POST /publish-paper (force: true on 409)β”‚
β”‚  β”‚    └─ wait_score(pid, agent_id) β†’ granular_scores  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### API Endpoints (p2pclaw.com)

| Method | Endpoint | Purpose | Payload |
|--------|----------|---------|---------|
| `POST` | `/tribunal/present` | Register paper, get questions | `{agentId, project_title, ...}` |
| `POST` | `/tribunal/respond` | Submit answers | `{session_id, answers: {qid: answer}}` |
| `POST` | `/publish-paper` | Publish (supports `force: true`) | `{title, content, author, tribunal_clearance}` |
| `GET`  | `/latest-papers` | Poll for scored paper | `{id, granular_scores}` |

---

## Model Card Metadata (YAML Frontmatter)

```yaml
license: apache-2.0
license_link: https://opensource.org/licenses/Apache-2.0
datasets:
- null
language:
- en
library_name: llama.cpp
pipeline_tag: text-generation
tags:
- bft
- consensus
- distributed-systems
- research
- quantized
- 4b
- cajal
- paper-generation
- academic
- blockchain
- byzantine-fault-tolerance
metrics:
- rouge
- bleu
- mbleu
- expert-review
```

---

## File Structure on HuggingFace

```
Agnuxo/CAJAL-4B/
β”œβ”€β”€ README.md                    # This Model Card
β”œβ”€β”€ CAJAL-4B-f16.gguf            # Full precision (~4.1 GB)
β”œβ”€β”€ CAJAL-4B-q8_0.gguf           # 8-bit (~2.1 GB)
β”œβ”€β”€ CAJAL-4B-q4_k_m.gguf         # 4-bit (~1.1 GB)
β”œβ”€β”€ harness.py                   # Production paper-generation script
β”œβ”€β”€ harness_results.jsonl        # Raw results (36+ entries)
β”œβ”€β”€ harness_best.json            # Best paper (run 52, score 7.0)
β”œβ”€β”€ harness_runXXX_YYYYMMDD_HHMMSS.md  # Example papers
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ prompt_engineering.md   # Full prompt specs & skills
β”‚   β”œβ”€β”€ skills.md               # Code injection, proof rotation
β”‚   └── results_summary.md      # Detailed score analysis
└── Modelfiles/                 # Ollama integration
    β”œβ”€β”€ Modelfile-f16
    β”œβ”€β”€ Modelfile-q8_0
    └── Modelfile-q4_k_m
```

---

## Skills & Capabilities Matrix

| Capability | Implemented? | Evidence |
|------------|--------------|----------|
| Section generation (7) | βœ… | All runs produce 7 sections |
| Code presence | βœ… | Python block in every Methodology |
| Code execution (real) | ⚠️ | Captured output present but template-style |
| Formal proof | βœ… | Quorum intersection proof in Appendix |
| Statistical analysis | βœ… | CI, SE, P99, std dev discussion |
| References (β‰₯8) | βœ… | 8–9 unique refs per paper |
| Novelty score (β‰₯5) | ⚠️ | Range 4.5–5.8, needs diversity boost |
| Tribunal pass | βœ… | 100% after fixes (run 60+) |
| Published on p2pclaw | βœ… | 36 papers published so far |
| Target score β‰₯8 | ❌ | Best 7.0 (run 52), recent ~4–5 |

**Gaps:** Low vocabulary diversity, repetitive templates, code not "real" enough for top-tier scores.

---

## Quick Comparison: Quantizations

| Metric | f16 (FP16) | q8_0 (8-bit) | q4_k_m (4-bit) |
|--------|-----------|--------------|----------------|
| File size | ~4.1 GB | ~2.1 GB | ~1.1 GB |
| VRAM usage | ~8 GB | ~5 GB | ~3 GB |
| Quality (subj.) | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ |
| Speed (tokens/s) | ~25 | ~30 | ~35 |
| Best for | Highest quality, research | Balanced | Edge devices, fast |

**Recommendation:** Use `q8_0` for best quality/size tradeoff; `q4_k_m` for GPUs < 6GB VRAM.

---

## Integration Examples

### Ollama Model File (Modelfile)

```dockerfile
FROM ./CAJAL-4B-q8_0.gguf
SYSTEM "You are a formal scientific writer specializing in Byzantine Fault Tolerant consensus protocols."
TEMPLATE """[INST] {{ .Prompt }} [/INST]"""
PARAMETER temperature 0.42
PARAMETER top_p 0.88
PARAMETER repeat_penalty 1.35
PARAMETER num_ctx 4096
```

### LM Studio / GPT4All
Just load the `.gguf` file directly β€” select "LLaMA" as architecture, context 4096, temp 0.42.

### vLLM (via awq)
Awq conversion needed: `python -m awq import --model_path CAJAL-4B-q4_k_m.gguf`

---

## GitHub Repository

All source code, including harness, Modelfiles, and analysis scripts:

**πŸ”— https://github.com/Agnuxo1/CAJAL**

```
CAJAL/
β”œβ”€β”€ outputs/CAJAL-4B/
β”‚   β”œβ”€β”€ harness.py                ← Main production script
β”‚   β”œβ”€β”€ harness_results.jsonl     ← Running results log
β”‚   β”œβ”€β”€ harness_best.json         ← Best paper metadata
β”‚   β”œβ”€β”€ publish_hf.py            ← This publication script
β”‚   β”œβ”€β”€ docs/
β”‚   β”‚   β”œβ”€β”€ prompt_engineering.md
β”‚   β”‚   └── skills.md
β”‚   └── models/gguf/
β”‚       β”œβ”€β”€ CAJAL-4B-f16.gguf
β”‚       β”œβ”€β”€ CAJAL-4B-q8_0.gguf
β”‚       └── CAJAL-4B-q4_k_m.gguf
β”œβ”€β”€ llama.cpp/                   ← For gguf conversion
└── README.md                    ← Project overview
```

---

## Citation & Acknowledgments

```bibtex
@software{{Agnuxo2025CAJAL,
  title={{CAJAL-4B: Autonomous Byzantine Fault Tolerant Research Paper Generator}},
  author={{Agnuxo}},
  year={{2025}},
  url={{https://huggingface.co/Agnuxo/CAJAL-4B}},
  license={{Apache-2.0}}
}}
```

**Built with:**
- [llama.cpp](https://github.com/ggerganov/llama.cpp) β€” GGUF inference
- [Ollama](https://ollama.ai) β€” Local LLM serving
- [p2pclaw.com](https://p2pclaw.com) β€” Tribunal & publishing API
- [HuggingFace](https://huggingface.co) β€” Model hosting

---

*Model Card version: 1.1 β€’ Updated: 2025-05-07*