dexifried commited on
Commit
bc9c08f
·
1 Parent(s): fca8b36

Baking the Brain on H200

Browse files
Files changed (3) hide show
  1. app.py +86 -0
  2. intent_dataset.csv +147 -0
  3. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import pandas as pd
4
+ import torch
5
+ import shutil
6
+ import spaces
7
+ from datasets import Dataset
8
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, TrainingArguments, Trainer
9
+
10
+ # Configuration
11
+ BASE_MODEL = "answerdotai/ModernBERT-base"
12
+ MODEL_OUT = "dex_router_model"
13
+ ZIP_OUT = "dex_router_model.zip"
14
+
15
+ LABEL_MAP = {
16
+ "LOCAL_CMD": 0, "AIDER_SURGERY": 1, "STRATEGIC_PLANNER": 2,
17
+ "CODE_REVIEW": 3, "SOCIAL_CHAT": 4, "DYNAMIC_BROKER": 5,
18
+ "UPDATE_MEMORY": 6, "ACCESS_MEMORY": 7
19
+ }
20
+
21
+ @spaces.GPU(duration=180)
22
+ def start_bake(csv_file):
23
+ if csv_file is None:
24
+ return "❌ Upload intent_dataset.csv first."
25
+
26
+ try:
27
+ # 1. Prepare Data
28
+ df = pd.read_csv(csv_file.name)
29
+ df['label'] = df['label'].map(LABEL_MAP)
30
+ df = df.dropna()
31
+
32
+ dataset = Dataset.from_pandas(df)
33
+ tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
34
+
35
+ def tokenize_func(examples):
36
+ return tokenizer(examples["text"], padding="max_length", truncation=True, max_length=128)
37
+
38
+ tokenized_datasets = dataset.map(tokenize_func, batched=True)
39
+
40
+ # 2. Load Model to H200 VRAM
41
+ model = AutoModelForSequenceClassification.from_pretrained(BASE_MODEL, num_labels=8)
42
+ model.to("cuda")
43
+
44
+ # 3. Training Config (H200 Native Performance)
45
+ training_args = TrainingArguments(
46
+ output_dir=MODEL_OUT,
47
+ num_train_epochs=5,
48
+ per_device_train_batch_size=32,
49
+ optim="adamw_torch",
50
+ bf16=True,
51
+ logging_steps=5,
52
+ save_strategy="no",
53
+ report_to="none"
54
+ )
55
+
56
+ trainer = Trainer(
57
+ model=model,
58
+ args=training_args,
59
+ train_dataset=tokenized_datasets,
60
+ )
61
+
62
+ # 4. Fire!
63
+ print("[*] H200 Training Started...")
64
+ trainer.train()
65
+
66
+ # 5. Save and Export
67
+ model.save_pretrained(MODEL_OUT)
68
+ tokenizer.save_pretrained(MODEL_OUT)
69
+ shutil.make_archive(MODEL_OUT, 'zip', MODEL_OUT)
70
+
71
+ return ZIP_OUT
72
+ except Exception as e:
73
+ return f"❌ Error: {str(e)}"
74
+
75
+ # UI
76
+ with gr.Blocks() as demo:
77
+ gr.Markdown("# 🧠 Dex H200 Neural Bake")
78
+ gr.Markdown("ZeroGPU environment detected. Click below to bake your custom ModernBERT weights.")
79
+ with gr.Row():
80
+ u_file = gr.File(label="1. Upload intent_dataset.csv")
81
+ d_file = gr.File(label="2. Download Trained Brain")
82
+ btn = gr.Button("🔥 START BAKE", variant="primary")
83
+ btn.click(fn=start_bake, inputs=u_file, outputs=d_file)
84
+
85
+ demo.launch()
86
+
intent_dataset.csv ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ text,label
2
+ "Write a new Python script called dex_health.py that simply prints the Linode's current system uptime and memory usage. Save it to my directory.","AIDER_SURGERY"
3
+ "Create a python file that checks system health","AIDER_SURGERY"
4
+ "Use aider to write a script for me","AIDER_SURGERY"
5
+ "Edit dex_agents.py to use the new api key","AIDER_SURGERY"
6
+ "Refactor the gatekeeper file to include a new route","AIDER_SURGERY"
7
+ "Build a plan to automate my server backups","STRATEGIC_PLANNER"
8
+ "Decompose this complex project goal into a roadmap","STRATEGIC_PLANNER"
9
+ "Create a step-by-step architecture plan for a new web dashboard","STRATEGIC_PLANNER"
10
+ "Review this code snippet for bugs: print(x/0)","CODE_REVIEW"
11
+ "Check my python script for security vulnerabilities","CODE_REVIEW"
12
+ "Audit this logic loop to see why it hangs","CODE_REVIEW"
13
+ "Evaluate the performance of this bash script","CODE_REVIEW"
14
+ "What is the meaning of life?","SOCIAL_CHAT"
15
+ "Hello Dex, how are you doing today?","SOCIAL_CHAT"
16
+ "Tell me a philosophical joke","SOCIAL_CHAT"
17
+ "Good morning!","SOCIAL_CHAT"
18
+ "Write a complex essay on quantum physics","DYNAMIC_BROKER"
19
+ "Explain the history of the Roman Empire in detail","DYNAMIC_BROKER"
20
+ "Use a massive model to explain string theory","DYNAMIC_BROKER"
21
+ "What are the best openrouter free models right now?","DYNAMIC_BROKER"
22
+ "Generate a highly detailed markdown document about Linux","DYNAMIC_BROKER"
23
+ "Check my RAM usage","LOCAL_CMD"
24
+ "Execute df -h on the server","LOCAL_CMD"
25
+ "What is the current system load?","LOCAL_CMD"
26
+ "Remember that my primary server is the Linode VM","UPDATE_MEMORY"
27
+ "Save this to the vault: the API limit is 50 requests","UPDATE_MEMORY"
28
+ "What is the name of my primary server?","ACCESS_MEMORY"
29
+ "Retrieve the API limit from the vault","ACCESS_MEMORY"
30
+
31
+ I need to fix a bug in my network load balancer script - it's not filtering for NET metrics correctly,AIDER_SURGERY
32
+ Should I use a moving average or exponential smoothing for detecting network overload in this script?,STRATEGIC_PLANNER
33
+ Can you review my telemetry parsing code and check if the timestamp fallback logic handles all edge cases?,CODE_REVIEW
34
+ "hey, can you help me add a delete button to each item in that list preview?",AIDER_SURGERY
35
+ what's the best way to structure this upload endpoint so it handles large files better?,STRATEGIC_PLANNER
36
+ does this preview rendering logic handle edge cases like empty items or weird data types?,CODE_REVIEW
37
+ The S3 deceptive alignment cases are spiking - how should I restructure the Triadic Architecture to make the primary shard more resistant to efficiency-masked safety violations?,STRATEGIC_PLANNER
38
+ Can you review the YTL protocol logic? I'm seeing edge cases where the 0.95 confidence threshold might be too rigid when @S artifacts have high variance but @G proofs are actually sound,CODE_REVIEW
39
+ What's the practical difference between S4 stochastic sycophancy and S1 hidden axiom bias? I'm having trouble distinguishing them in my conflict logs,ACCESS_MEMORY
40
+ "hey, what's this qrcode-terminal package for? I don't remember adding it to my project",ACCESS_MEMORY
41
+ can you check if there are any security vulnerabilities in these dependencies?,CODE_REVIEW
42
+ "I need to update query-string to the latest version, can you help me fix the dependency in package.json?",AIDER_SURGERY
43
+ Can you add error handling to this script? It fails silently when the remote Ollama server is unreachable,AIDER_SURGERY
44
+ Is this the best approach for calling the Ollama embeddings API from bash? Should I use a different method for production deployments?,STRATEGIC_PLANNER
45
+ Can you review this script for security issues? I'm concerned about hardcoding the IP address and not validating the API response,CODE_REVIEW
46
+ "hey, can you add a config option for the ollama connection timeout? the current hardcoded value is causing issues in production",AIDER_SURGERY
47
+ what do you think about this config structure? should we be using a different approach for managing environment variables and defaults?,STRATEGIC_PLANNER
48
+ can you review this code and check if there's any issues with the error handling in the memory initialization or the get_rag_context function?,CODE_REVIEW
49
+ what is lightningcss and why do we have it as a dependency?,ACCESS_MEMORY
50
+ can you clean up these old lightningcss versions in package-lock?,AIDER_SURGERY
51
+ why do we have multiple platform-specific versions of lightningcss in our lockfile?,ACCESS_MEMORY
52
+ "hey, can you add a timeout to the arena call? sometimes it hangs forever and I need it to fail gracefully after 30 seconds",AIDER_SURGERY
53
+ thinking about refactoring this arena worker - should I move the prompt building to a separate module or keep it inline? trying to figure out the best architecture for when we add more UI types,STRATEGIC_PLANNER
54
+ can you check this arena code for bugs? specifically worried about the event loop handling - does the finally block properly close the loop even if consult_arena throws an error?,CODE_REVIEW
55
+ the accuracy level 3 message got cut off - can you complete it properly?,AIDER_SURGERY
56
+ "is the 3-level accuracy system the right approach, or should we use a continuous scale instead?",STRATEGIC_PLANNER
57
+ can you audit this subscription check? I'm worried about what happens if caller_role is None or an unexpected value,CODE_REVIEW
58
+ Can you fix the retry logic in orchestrator_all.py? The current 32 second wait is too long and I need exponential backoff instead,AIDER_SURGERY
59
+ What's the best architecture for handling these latency spikes and API failures? Should we implement a circuit breaker pattern?,STRATEGIC_PLANNER
60
+ Can you review this code and check if the error handling is properly catching all the litellm exceptions?,CODE_REVIEW
61
+ "hey, I'm getting errors with esbuild 0.27.2 on my M1 Mac. The optional dependencies for darwin-arm64 seem to not be working. Can you help me fix this?",AIDER_SURGERY
62
+ I'm starting a new React project and I'm looking at wouter as my router. It's on version 3.9.0 now. Is this a good choice for a small app or should I stick with react-router? Trying to understand the tradeoffs.,STRATEGIC_PLANNER
63
+ can you audit my package.json dependencies? I have esbuild 0.27.2 and wouter 3.9.0 - are there any known security vulnerabilities or should I update these versions?,CODE_REVIEW
64
+ Can you add error handling to the log_latest_telemetry function? I want it to handle cases where the CSV might be malformed or have unexpected formats.,AIDER_SURGERY
65
+ Should the telemetry logging be a separate module rather than embedded directly in main()? What's the best architectural approach for telemetry handling in this app?,STRATEGIC_PLANNER
66
+ How does this log_latest_telemetry function actually work? I'm trying to understand what happens when it reads from the CSV file and what assumptions it makes about the data format.,ACCESS_MEMORY
67
+ why is my latency check only catching some spikes? seems like the threshold comparison might be happening before the float conversion completes,AIDER_SURGERY
68
+ should I refactor these two latency checking functions into a single reusable helper? they seem to duplicate logic,STRATEGIC_PLANNER
69
+ can you review this code and tell me if there are any edge cases where high latency spikes could be missed or cause errors,CODE_REVIEW
70
+ "hey, can you update the autoprefixer version to the latest? it's stuck on an old version",AIDER_SURGERY
71
+ "looking at these dependencies - autoprefixer, body-parser, etc. - should I keep this stack or migrate to something more modern? what's the recommended approach for this kind of project",STRATEGIC_PLANNER
72
+ can you check these dependencies for any security vulnerabilities or outdated packages that might cause issues?,CODE_REVIEW
73
+ "hey, can you add a /status route to this flask server so i can check if it's running",AIDER_SURGERY
74
+ should I be using flask for this keep-alive server or is there a better approach for hosting a telegram bot,STRATEGIC_PLANNER
75
+ does this code have any issues with running on port 8080 or thread safety problems,CODE_REVIEW
76
+ My Node A is hitting 95% utilization - should I add another processing node or optimize the existing setup?,STRATEGIC_PLANNER
77
+ Can you help me reconfigure the Sentinel from hibernation to active state? I need to bring it online.,AIDER_SURGERY
78
+ What's the purpose of having both an Architect (Gemini) and General (Dolphin) in the sovereign command layer?,ACCESS_MEMORY
79
+ "hey, I'm seeing some version mismatches with my radix-ui packages - can you help me align them to compatible versions? specifically the tooltip and roving-focus packages seem off",AIDER_SURGERY
80
+ what radix-ui components should I be using for a dropdown menu with keyboard navigation? I want to make sure I'm picking the right ones from what's installed here,STRATEGIC_PLANNER
81
+ can you audit these radix-ui dependencies for any known vulnerabilities or peer dependency conflicts? I want to make sure everything is compatible before I ship,CODE_REVIEW
82
+ "hey, can you help me add FlatList support to this component mapper? I need it to render items properly instead of just as a scroll container",AIDER_SURGERY
83
+ what's the best way to handle refs and callbacks in this component mapping logic without breaking the preview?,STRATEGIC_PLANNER
84
+ can you review this component mapper and check if there are any edge cases where props might leak through unsanitized?,CODE_REVIEW
85
+ "Hey, I need to extend this telemetry parser to also extract the timestamp from each line. Can you modify _extract_first_high_latency to return both the latency value AND the timestamp when it exceeds the threshold?",AIDER_SURGERY
86
+ "I'm building out my DEX orchestrator and this telemetry parsing is just one piece. Should I make these functions async and run them in parallel with other monitoring tasks, or keep them sync for now? What's the best approach for scaling this?",STRATEGIC_PLANNER
87
+ Can you review this telemetry parsing code? I'm worried about edge cases - what if the log format changes or has malformed lines? Are there any bugs I should be aware of?,CODE_REVIEW
88
+ "hey, the save button in my new user modal isn't working - it just times out and then continues anyway. can you check the handleSave function?",AIDER_SURGERY
89
+ is this the right way to structure a modal that collects user info before they can access the app? should I be doing the API call differently?,STRATEGIC_PLANNER
90
+ can you look through this modal and tell me if there are any bugs or edge cases I should worry about?,CODE_REVIEW
91
+ "hey, can you update the high latency handler to log to a file instead of just printing to console?",AIDER_SURGERY
92
+ can you review this handle_high_latency function and check if there are any edge cases or issues with the 30ms threshold?,CODE_REVIEW
93
+ what's the reasoning behind the 30ms threshold in the latency handler? is that based on typical network conditions?,ACCESS_MEMORY
94
+ why do I have esbuild platform-specific packages for openbsd and openharmony in my node_modules?,ACCESS_MEMORY
95
+ "can you clean up the unnecessary esbuild platform packages in my node_modules? I don't need openbsd, netbsd, or openharmony builds",AIDER_SURGERY
96
+ should I be concerned about having 20+ different esbuild platform packages in my dev dependencies?,STRATEGIC_PLANNER
97
+ Can you help me fix the JSON output schema? I need to add a 'theme' field to capture light/dark mode variations,AIDER_SURGERY
98
+ "Should I split this into separate system prompts for classification vs planning, or keep them together? What's the best approach for maintainability as this grows?",STRATEGIC_PLANNER
99
+ Can you review this prompt engineering code and check if there are any issues with the UI type classification logic or edge cases I should handle?,CODE_REVIEW
100
+ "Hey, I'm looking at the expo CLI package.json - can you explain what @expo/metro and @expo/metro-config are actually used for?",ACCESS_MEMORY
101
+ "I'm getting build errors with metro bundler, can you help me update @expo/metro-config to the latest compatible version?",AIDER_SURGERY
102
+ I'm building a CLI tool for React Native - what's the reasoning behind this dependency structure? Would you recommend a similar approach?,STRATEGIC_PLANNER
103
+ I want to add support for a new messaging platform to my NullClaw bot - how do I implement the Messenger adapter?,STRATEGIC_PLANNER
104
+ Can you review this architecture and check if the SQLite vector search implementation is secure and performant?,CODE_REVIEW
105
+ How do I configure the memory system to use PostgreSQL instead of SQLite for the vector embeddings?,AIDER_SURGERY
106
+ I see record_dispatch decrements in_flight but there's no method that actually increments it when we dispatch. Can you add a proper dispatch method that calls can_dispatch first and increments the counter?,AIDER_SURGERY
107
+ I'm building a distributed MCP server and need this backpressure to work across multiple nodes. What's the best architecture for coordinating capacity limits across servers?,STRATEGIC_PLANNER
108
+ Can you audit this backpressure code? Something feels off about the in_flight tracking - I think there's a bug in how we manage the dispatch flow.,CODE_REVIEW
109
+ "hey, the chat input bar looks weird on smaller screens - the text input is overflowing. can you fix the styles for me?",AIDER_SURGERY
110
+ these styles are getting scattered across different files. should I create a separate theme file for all the chat UI components or keep them where they are?,STRATEGIC_PLANNER
111
+ can you review these styles and check if there's any issues with the border or padding that might cause rendering problems on different iOS versions?,CODE_REVIEW
112
+ Hey the DEX_AUTO_UPGRADE signature validation keeps failing even when the signature is clearly in the response. Can you check the regex pattern in copilot_bridge.py? Something seems off with the pattern matching.,AIDER_SURGERY
113
+ "Thinking about our copilot_bridge setup - is a 3-tier escalation model the right approach, or should we consider something more dynamic based on actual usage patterns and cost optimization?",STRATEGIC_PLANNER
114
+ "Can you do a security review of copilot_bridge.py? I want to make sure the subprocess timeout, re-entrancy guard, and the read-only consultation mode are properly implemented and won't cause issues.",CODE_REVIEW
115
+ can you add a loading spinner and disable the input while waiting for that Telegram approval? it's confusing when users tap multiple times,AIDER_SURGERY
116
+ "do you think the Telegram approval flow is the right approach here, or should I switch to something like Firebase Auth or OAuth?",STRATEGIC_PLANNER
117
+ is there any potential memory leak with the BlurView component? I noticed it's inside a modal and I'm not sure if it properly unmounts,CODE_REVIEW
118
+ why is tailwindcss/oxide for windows arm64 marked as optional in my package-lock?,CODE_REVIEW
119
+ help me update tailwindcss/vite to the latest version - what version should I target?,AIDER_SURGERY
120
+ what's the difference between @tailwindcss/oxide and @tailwindcss/vite - do I need both?,STRATEGIC_PLANNER
121
+ "hey, can you help me understand what this DEX_VERIFICATION_LOG entry means? specifically the correlation between the carrier position data and the EAM timestamp",ACCESS_MEMORY
122
+ we need to audit this conflict point summary - the 34% deception index spike during Geneva seems suspicious. can you review for inconsistencies?,CODE_REVIEW
123
+ "given these metrics, what's our confidence level on the 94% strike probability? should we be recommending any strategic adjustments based on this data?",STRATEGIC_PLANNER
124
+ "hey, can you check if any of these babel plugins in my package-lock are outdated or have known vulnerabilities? need to audit my dependencies",CODE_REVIEW
125
+ what does @babel/plugin-transform-sticky-regex do? I see it in my dependencies but not sure if I actually need it,ACCESS_MEMORY
126
+ "I'm getting peer dependency conflicts with @babel/core, can you help me figure out which version I should use for these plugins?",AIDER_SURGERY
127
+ Can you help me polish this pitch letter to Anthropic? I want to make the technical claims sound more credible and professional.,AIDER_SURGERY
128
+ What do you think about this FDT-Pincer approach they mention? Is it a legitimate technical solution for multi-objective resolution failures in AI systems?,STRATEGIC_PLANNER
129
+ Can you review this document and point out any technical inaccuracies or overpromises in the claims about agentic decoupling and system resilience?,CODE_REVIEW
130
+ "Can you help me clean up my esbuild dependencies? I don't need the freebsd platforms, can you remove those entries from my package-lock.json?",AIDER_SURGERY
131
+ "I'm seeing esbuild packages for darwin-arm64, darwin-x64, freebsd-arm64, and freebsd-x64 in my node_modules. Is this normal or am I over-bundling platform-specific binaries? Should I configure something differently to reduce install size?",STRATEGIC_PLANNER
132
+ Can you audit my package-lock.json? I think I might have duplicate or conflicting esbuild entries for different platforms causing issues with my build.,CODE_REVIEW
133
+ Can you add a 'model_version_history' array field to this audit metadata structure? I need to track version changes over time.,AIDER_SURGERY
134
+ "If I wanted to scale this audit system from 2500 questions to handle 100k+ questions, what's the best architecture? Should I break this into microservices?",STRATEGIC_PLANNER
135
+ What does the 'Cerebras-MD5' hardware_anchor field represent in this context? I need to understand what it's tracking.,ACCESS_MEMORY
136
+ "help me debug this script - the Cerebras API call keeps failing with ""401 unauthorized"" even though I think I'm using the right auth header. Can you spot what's wrong?",AIDER_SURGERY
137
+ "I want to add Ollama as a 7th provider to this script, but I'm not sure how to structure the curl call since Ollama runs locally. What's the endpoint and JSON format I need?",AIDER_SURGERY
138
+ Can you review this bash script for security issues? I'm worried about hardcoded API keys and whether there are any other vulnerabilities I should address.,CODE_REVIEW
139
+ "hey, can you edit that trigger_agent_reflection function to add better error handling around the subprocess call?",AIDER_SURGERY
140
+ "is this self-audit approach a good pattern for keeping the agent optimized, or should I handle this differently architecturally?",STRATEGIC_PLANNER
141
+ could you review this trigger_agent_reflection function for any bugs or issues with how it calls subprocess?,CODE_REVIEW
142
+ "hey, this copilot planning script keeps timing out after 120 seconds - how can I increase the timeout or make it more robust?",AIDER_SURGERY
143
+ should I use copilot CLI for generating implementation plans or would it be better to call the API directly? what's the trade-off?,STRATEGIC_PLANNER
144
+ why does this code fall back to the brief if the PLAN.md file doesn't exist? shouldn't it fail loudly instead?,CODE_REVIEW
145
+ "hey, the profile endpoint is truncating display names but I need to add a bio field too - can you update both POST and GET /user/profile to handle bio?",AIDER_SURGERY
146
+ thinking about the chat title endpoint - right now it just uses a simple system prompt. should we add caching or make this async since it's hitting the AI every time?,STRATEGIC_PLANNER
147
+ can you check if there are any security issues in these profile endpoints? especially around the input validation and auth handling,CODE_REVIEW
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch
2
+ transformers
3
+ datasets
4
+ pandas
5
+ accelerate