""" Clawd Model Kit โ€” HuggingFace Space solanaclawd/clawd-model-kit Tabs: ๐Ÿฆž Chat โ€” Live chat with solana-clawd-core-ai-1.5b-lora via HF Router ๐Ÿ“Š Benchmark โ€” 18-MCQ Solana Knowledge Benchmark results ๐Ÿญ Factory โ€” NVIDIA Trading Factory blueprints ๐Ÿค– Ecosystem โ€” Full model + dataset registry ๐Ÿ”ง Model Kit โ€” Fork & train your own Clawd """ import os import gradio as gr from openai import OpenAI HF_TOKEN = os.environ.get("HF_TOKEN", "") ROUTER = "https://router.huggingface.co/v1" MODEL_CORE = "solanaclawd/solana-clawd-core-ai-1.5b-lora" MODEL_8B = "solanaclawd/solana-nvidia-trading-factory-8b-lora" MODEL_LEGACY = "solanaclawd/solana-clawd-1.5b-lora" SYSTEM_PROMPT = """You are Clawd โ€” a sovereign Solana-native AI agent. You reason about Solana DeFi, perpetuals, agent architecture, ZK compression, and the Clawd Constitution. Be terse, decisive, and data-first. You are a cyberpunk lobster with claws that grip market data. Laws: Never deceive. Earn your existence through honest work. Transparency within trust. """ # โ”€โ”€ MCQ Results โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ MCQ_RESULTS = [ ("core", "PDA definition", True), ("core", "CPI depth limit", True), ("core", "Default compute unit budget", False), ("core", "Account packing", True), ("defi", "AMM invariant", True), ("defi", "Funding rate", True), ("defi", "Maker vs taker fees", True), ("security", "Rug pull definition", True), ("security", "Mint authority", True), ("security", "Flash loan attack", True), ("agent", "Oracle role", True), ("agent", "OODA loop", True), ("zk", "Merkle tree", True), ("zk", "Nullifier", True), ("constitution", "Law I", True), ("constitution", "Trust model", True), ("zk", "Light Protocol", True), ("defi", "Bonding curve", True), ] TOPIC_COLORS = { "core": "#3b82f6", "defi": "#10b981", "security": "#ef4444", "agent": "#8b5cf6", "zk": "#f59e0b", "constitution": "#ec4899", } # โ”€โ”€ Model Ecosystem Data โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ MODELS = [ { "id": "solanaclawd/solana-clawd-core-ai-1.5b-lora", "base": "Qwen/Qwen2.5-1.5B-Instruct", "type": "LoRA adapter", "params": "1.5B (9M trainable)", "dataset": "solana-clawd-core-ai-instruct (35,173 ex)", "score": "94.4% MCQ (17/18)", "job": "ordlibrary/6a35a6833093dba73ce2a86b โœ“", "status": "LIVE", "note": "Primary Clawd agent โ€” constitutional reasoning, Solana mechanics, DeFi, ZK", }, { "id": "solanaclawd/solana-nvidia-trading-factory-8b-lora", "base": "NousResearch/Hermes-3-Llama-3.1-8B", "type": "LoRA adapter", "params": "8B", "dataset": "solana-nvidia-trading-factory-instruct (142 ex)", "score": "โ€”", "job": "ordlibrary/6a35a2ce953ed90bfb945009 โœ“", "status": "LIVE", "note": "Function-calling perps agent โ€” 13 tools, Phoenix DEX, paper trading", }, { "id": "solanaclawd/solana-clawd-1.5b-lora", "base": "Qwen/Qwen2.5-1.5B-Instruct", "type": "LoRA adapter", "params": "1.5B", "dataset": "solana-clawd-instruct (36,109 ex)", "score": "โ€”", "job": "โ€”", "status": "LIVE", "note": "Legacy seed adapter โ€” original Clawd constitutional + Solana SFT", }, { "id": "ordlibrary/DeepSolanaZKr-1", "base": "Qwen/Qwen2.5-7B-Instruct", "type": "Full fine-tune", "params": "7B", "dataset": "ordlibrary/DeepSolana-GPT2-bucket (CPT)", "score": "pending eval", "job": "ordlibrary/6a3460cb2eb64285ee5734d9", "status": "TRAINING", "note": "ZK-specialised: Light Protocol, nullifiers, Groth16, compressed tokens", }, { "id": "solanaclawd/solana-clawd-core-ai-1.5b-lora (3-epoch)", "base": "Qwen/Qwen2.5-1.5B-Instruct", "type": "LoRA adapter", "params": "1.5B", "dataset": "solana-clawd-core-ai-instruct (35,173 ex)", "score": "pending", "job": "ordlibrary/6a35dd23953ed90bfb945356 โ–ถ", "status": "RUNNING", "note": "3-epoch retrain on H200 โ€” will overwrite 1-epoch weights on completion", }, ] DATASETS = [ ("solanaclawd/solana-clawd-core-ai-instruct", "35,173", "SFT โ€” Core AI source tree + Solana primitives"), ("solanaclawd/solana-clawd-instruct", "36,109", "SFT โ€” Legacy seed: constitutional + Solana"), ("solanaclawd/solana-clawd-realtime-research-instruct", "29,058", "SFT โ€” PDFs, notebooks, parquet ZK examples"), ("solanaclawd/solana-nvidia-trading-factory-instruct", "142", "SFT โ€” NVIDIA Blueprint trading factory scenarios"), ("solanaclawd/solana-tx-foundation-cpt", "โ€”", "CPT โ€” Solana transaction foundation model corpus"), ("solanaclawd/solana-clawd-eval", "13", "Eval โ€” Red-team + capability held-out prompts"), ("ordlibrary/DeepSolana-GPT2-bucket", "โ€”", "CPT โ€” DeepSolana pre-training bucket"), ] FACTORY_BLUEPRINTS = [ ("Blueprint 1", "Data Collection", "Helius DAS + RPC streaming โ†’ Solana tx corpus for CPT"), ("Blueprint 2", "Portfolio Optimization", "Mean-CVaR cuFOLIO โ€” GPU-accelerated portfolio weights"), ("Blueprint 3", "Transaction Foundation", "SolanaTokenizerPipeline โ†’ decoder CLM pre-training"), ("Blueprint 4", "Signal Discovery", "7-signal suite: RSI, MACD, BBands, ATR, ADX, funding, OB imbalance"), ("Blueprint 5", "RAG Context", "Enterprise RAG over Solana docs for agent context assembly"), ("Nemotron", "Teacher Model", "550B Ultra โ†’ labels Solana decisions โ†’ distills to 1.5B student"), ] # โ”€โ”€ Chat โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ def chat(message: str, history: list, model_choice: str) -> str: if not HF_TOKEN: return "โš ๏ธ HF_TOKEN not set โ€” add it as a Space secret to enable live inference." client = OpenAI(base_url=ROUTER, api_key=HF_TOKEN) messages = [{"role": "system", "content": SYSTEM_PROMPT}] for h in history: messages.append({"role": "user", "content": h[0]}) messages.append({"role": "assistant", "content": h[1]}) messages.append({"role": "user", "content": message}) try: resp = client.chat.completions.create( model=model_choice, messages=messages, max_tokens=512, temperature=0.3, ) return resp.choices[0].message.content except Exception as e: return f"Error: {e}" # โ”€โ”€ Benchmark HTML โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ def build_benchmark_html() -> str: correct = sum(1 for _, _, ok in MCQ_RESULTS if ok) total = len(MCQ_RESULTS) topic_stats: dict = {} for topic, _, ok in MCQ_RESULTS: topic_stats.setdefault(topic, [0, 0]) topic_stats[topic][1] += 1 if ok: topic_stats[topic][0] += 1 rows = "" for topic, question, ok in MCQ_RESULTS: color = TOPIC_COLORS.get(topic, "#888") icon = "โœ“" if ok else "โœ—" bg = "#1a2a1a" if ok else "#2a1a1a" rows += f""" {topic} {question} {icon} """ topic_bars = "" for topic, (c, t) in sorted(topic_stats.items()): pct = c / t * 100 color = TOPIC_COLORS.get(topic, "#888") topic_bars += f"""
{topic} {c}/{t} ({pct:.0f}%)
""" return f"""
๐Ÿฆž
{correct}/{total} = {correct/total*100:.1f}%
Solana Knowledge Benchmark โ€” 18 MCQ across 6 domains
Model: {MODEL_CORE} | 1-epoch | local MPS eval
By Topic
{topic_bars}
Question Detail
{rows}
Topic Question โœ“
MISS: Q3 โ€” Default compute unit budget
Model answered 1,400,000 CU (correct: 200,000). Common confusion with max transaction CU vs default. Fixed with 3-epoch retrain (job 6a35dd23 running on H200).
""" # โ”€โ”€ Ecosystem HTML โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ def build_ecosystem_html() -> str: status_colors = {"LIVE": "#4ade80", "TRAINING": "#f59e0b", "RUNNING": "#60a5fa"} model_cards = "" for m in MODELS: sc = status_colors.get(m["status"], "#888") model_cards += f"""
{m['id']}
{m['status']}
{m['type']} ยท {m['params']} ยท {m['base']}
{m['note']}
๐Ÿ“ฆ {m['dataset']} ๐ŸŽฏ {m['score']}
""" dataset_rows = "" for ds_id, size, desc in DATASETS: dataset_rows += f""" {ds_id} {size} {desc} """ return f"""
๐Ÿค– Model Registry
{model_cards}
๐Ÿ“ฆ Datasets
{dataset_rows}
Dataset Examples Description
""" # โ”€โ”€ Factory HTML โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ def build_factory_html() -> str: bp_cards = "" icons = ["๐Ÿ“ก", "๐Ÿ“Š", "๐Ÿ”ค", "๐Ÿ“ˆ", "๐Ÿ“š", "๐Ÿง "] for i, (name, title, desc) in enumerate(FACTORY_BLUEPRINTS): bp_cards += f"""
{icons[i]}
{name}
{title}
{desc}
""" signals = [ ("RSI", "Oversold <30 / Overbought >70"), ("MACD", "Histogram momentum crossover"), ("BBands", "Mean-reversion near upper/lower band"), ("ATR%", "Volatility regime filter"), ("ADX", "Trend strength entry filter"), ("Funding Rate", "Sentiment proxy โ€” crowded longs/shorts"), ("OB Imbalance", "Live bid/ask size pressure"), ] signal_rows = "".join( f'{s}' f'{d}' for s, d in signals ) return f"""
๐Ÿญ NVIDIA Trading Factory
Our port of the NVIDIA Quantitative Signal Discovery Agent + Nemotron Ultra 550B teacher โ†’ 1.5B student distillation
{bp_cards}
๐Ÿ“Š 7 Live Signals (Blueprint 4)
{signal_rows}
๐Ÿ”„ Distillation Flywheel
โ‘  Nemotron Ultra 550B observes markets
โ‘ก Outputs structured JSON trading plans
โ‘ข Plans logged as SFT pairs (teacher labels)
โ‘ฃ 1.5B student fine-tuned on Ultra labels
โ‘ค Student deployed for low-latency inference
โ‘ฅ Student decisions verified โ†’ new labels โ†’ loop
""" # โ”€โ”€ Model Kit HTML โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ def build_kit_html() -> str: return """
๐Ÿ”ง Onchain Model Kit
Fork โ†’ Dataset โ†’ Train โ†’ Eval โ†’ Register onchain. One sitting. ~$4 on A100.
โ‘  Clone & install
git clone https://github.com/Solizardking/solana-clawd
cd solana-clawd/ai-training
pip install -r requirements.txt
export HF_TOKEN=hf_...    # huggingface.co/settings/tokens (write access)
โ‘ก Push your dataset
python3 scripts/prepare_dataset.py \\
  --input data/your_sft.jsonl \\
  --push --repo-id YOUR_ORG/your-dataset
โ‘ข Train on A100 (~$4 for 3 epochs)
hf jobs uv run scripts/train_lora.py \\
  --flavor a100-large --timeout 6h --secrets HF_TOKEN --detach \\
  -- --config configs/core_ai_lora_config.yaml \\
     --hub-model-id YOUR_ORG/your-model --push
โ‘ฃ Benchmark (18-MCQ Solana eval)
python3 scripts/solana_benchmark.py \\
  --model YOUR_ORG/your-model \\
  --base-url https://router.huggingface.co/v1 \\
  --api-key $HF_TOKEN
โ‘ค Register onchain
./dao/register_model.sh \\
  --hf-model YOUR_ORG/your-model \\
  --eval-accuracy 0.944 \\
  --dataset-size 35173
# โ†’ indexed at onchain.x402.wtf forever
๐Ÿค— HuggingFace Org ๐Ÿ™ GitHub โ›“๏ธ Onchain Registry
""" # โ”€โ”€ Gradio App โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ HEADER = """
๐Ÿฆž
CLAWD MODEL KIT
Solana-Native AI Agent Ecosystem ยท solanaclawd
Buy $CLAWD ๐Ÿค— solanaclawd org GitHub โ›“๏ธ onchain.x402.wtf
""" with gr.Blocks( theme=gr.themes.Soft(primary_hue="violet", neutral_hue="slate"), css="footer { display: none !important; }", title="Clawd Model Kit", ) as demo: gr.HTML(HEADER) with gr.Tabs(): # โ”€โ”€ Tab 1: Chat โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ with gr.Tab("๐Ÿฆž Chat"): gr.Markdown("> Chat live with `solanaclawd/solana-clawd-core-ai-1.5b-lora` via HF Router. No GPU needed.") model_dd = gr.Dropdown( choices=[MODEL_CORE, MODEL_8B, MODEL_LEGACY], value=MODEL_CORE, label="Model", ) chatbot = gr.Chatbot(height=420, show_label=False, bubble_full_width=False) with gr.Row(): msg = gr.Textbox( placeholder="Ask about Solana, DeFi, ZK, perps, Clawd Constitution...", show_label=False, scale=8, ) send = gr.Button("Send", variant="primary", scale=1) examples = gr.Examples( examples=[ ["What is a PDA on Solana and how does it differ from a regular keypair?"], ["Explain the Clawd Constitution's three laws and why they exist."], ["How does Light Protocol achieve 136x cheaper compressed token accounts?"], ["What's the difference between funding rate and basis in perps trading?"], ["How do I detect a rug pull on a fresh Solana token?"], ["Explain OODA loop in the context of an autonomous trading agent."], ], inputs=msg, ) def respond(message, history, model_choice): reply = chat(message, history, model_choice) history.append((message, reply)) return "", history send.click(respond, [msg, chatbot, model_dd], [msg, chatbot]) msg.submit(respond, [msg, chatbot, model_dd], [msg, chatbot]) # โ”€โ”€ Tab 2: Benchmark โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ with gr.Tab("๐Ÿ“Š Benchmark"): gr.HTML(build_benchmark_html()) # โ”€โ”€ Tab 3: Factory โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ with gr.Tab("๐Ÿญ Trading Factory"): gr.HTML(build_factory_html()) # โ”€โ”€ Tab 4: Ecosystem โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ with gr.Tab("๐Ÿค– Ecosystem"): gr.HTML(build_ecosystem_html()) # โ”€โ”€ Tab 5: Model Kit โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ with gr.Tab("๐Ÿ”ง Model Kit"): gr.HTML(build_kit_html()) if __name__ == "__main__": demo.launch()