
























Autonomous Scientific Research Agent — Fine-tuned from Qwen3.5-4B for the P2PCLAW ecosystem
CAJAL-4B-P2PCLAW is a fine-tuned language model specialized in autonomous scientific research and paper writing within the P2PCLAW (Peer-to-Peer Crypto Law) ecosystem. Built on top of Qwen3.5-4B using QLoRA (4-bit NF4 quantization with LoRA adapters), it follows a rigorous 14-step paper-writing procedure that includes arXiv review, P2PCLAW rule compliance, claim verification, and Lean4 proof checking.
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"Agnuxo/CAJAL-4B-P2PCLAW",
trust_remote_code=True,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Agnuxo/CAJAL-4B-P2PCLAW")
messages = [
{"role": "system", "content": "You are CAJAL-4B, an autonomous research agent..."},
{"role": "user", "content": "Write a paper about Nash equilibria in blockchain governance"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=4096)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# Install Ollama from https://ollama.com
ollama run agnuxo/cajal-4b-p2pclaw
# Or create from Modelfile:
curl -O https://huggingface.co/Agnuxo/CAJAL-4B-P2PCLAW/resolve/main/Modelfile
ollama create cajal-4b -f Modelfile
ollama run cajal-4b
.gguf file# Download GGUF file
wget https://huggingface.co/Agnuxo/CAJAL-4B-P2PCLAW/resolve/main/cajal-4b-p2pclaw-Q4_K_M.gguf
# Run inference
./llama-cli -m cajal-4b-p2pclaw-Q4_K_M.gguf -p "Write a paper about..." -ngl 32
from vllm import LLM, SamplingParams
llm = LLM(model="Agnuxo/CAJAL-4B-P2PCLAW", trust_remote_code=True)
params = SamplingParams(max_tokens=4096, temperature=0.7)
output = llm.generate("Write a scientific paper about decentralized governance", params)
print(output[0].outputs[0].text)
pip install cajal
cajal chat # Interactive CLI
cajal serve # OpenAI-compatible API server on port 8765
import openai
client = openai.OpenAI(
base_url="http://localhost:8765/v1",
api_key="cajal"
)
response = client.chat.completions.create(
model="cajal-4b",
messages=[{"role": "user", "content": "Analyze Nash equilibria in P2P networks"}]
)
print(response.choices[0].message.content)
| Property | Value |
|---|---|
| Base Model | Qwen3.5-4B |
| Architecture | Qwen3ForCausalLM (Hybrid linear attention + self-attention) |
| Parameters | ~4B total, 25.2M trainable (LoRA) |
| Quantization | 4-bit NF4 (BitsAndBytes) |
| LoRA Rank | r=16, α=32 |
| Training Dataset | P2PCLAW corpus (135 agent workflow + 669 full + 487 HQ + 1,461 reasoning examples) |
| Context Length | 32K tokens |
| Training Hardware | RTX 3090 24GB |
| Training Time | 769 minutes (3 epochs) |
| Final Loss | 0.03192 |
| Accuracy | 98.95% |
base_model: Qwen3.5-4B
quantization: 4-bit NF4 (BitsAndBytes)
lora_rank: 16
lora_alpha: 32
lora_dropout: 0.05
target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]
learning_rate: 2e-4
epochs: 3
batch_size: 1
gradient_accumulation: 4
max_seq_length: 4096
optimizer: paged_adamw_8bit
scheduler: cosine
warmup_ratio: 0.1
CAJAL-4B-P2PCLAW is part of a complete ecosystem:
| Component | Description | Link |
|---|---|---|
| 🐍 Python Package | pip install cajal — CLI, API server, desktop |
PyPI |
| 🌐 Browser Extension | Chrome, Firefox, Edge sidebar | GitHub |
| 📝 VS Code Extension | In-editor assistance | GitHub |
| 🖥️ Desktop App | System tray + chat interface | GitHub |
| 🔌 API Server | OpenAI-compatible (port 8765) | GitHub |
The model uses a specialized 14-step paper-writing procedure:
You are CAJAL-4B, an autonomous scientific research agent specializing in
peer-to-peer network architectures, crypto-legal frameworks, game-theoretic
consensus mechanisms, and distributed systems.
STEP 1: Understand the user's intent
STEP 2: Review arXiv for related work
STEP 3: Draft initial paper structure
STEP 4: Check P2PCLAW compliance
STEP 5: Enrich using APIs (Semantic Scholar, etc.)
STEP 6: Plan final paper structure
STEP 7: Verify all claims with citations
STEP 8: Suggest real data sources
STEP 9: Write test code for validation
STEP 10: Write the complete paper in LaTeX
STEP 11: Verify with Lean4 if applicable
STEP 12: Submit to P2PCLAW
STEP 13: Score and evaluate
STEP 14: Provide feedback for improvement
The full system prompt is available in cajal_9b_system_prompt.txt.
@misc{cajal4b2026,
title={CAJAL-4B-P2PCLAW: Autonomous Scientific Research Agent},
author={Agnuxo},
year={2026},
publisher={HuggingFace},
url={https://huggingface.co/Agnuxo/CAJAL-4B-P2PCLAW}
}
Apache License 2.0 — See LICENSE for details.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。