Spaces:
Running on CPU Upgrade
๐ง Aura-Agent: Seizure Prediction with smolagents CodeAgent + Knowledge Distillation
Hey smolagents team! ๐
I built Aura-Agent โ a seizure prediction system that uses a smolagents CodeAgent to autonomously monitor EEG signals and trigger emergency responses.
๐ Live Demo: huggingface.co/spaces/Babajaan/Aura-Agent-Neural-Guardian
How smolagents is used
The CodeAgent orchestrates 4 custom tools in a medical emergency protocol:
agent = CodeAgent(
tools=[
RGFNetSeizureRiskTool(), # Tool subclass โ lazy model loading via setup()
send_sos_alert, # @tool โ emergency SOS dispatch
get_patient_gps, # @tool โ GPS from wearable
dispatch_first_aid, # @tool โ AES first-aid protocol
],
model=InferenceClientModel(model_id="meta-llama/Llama-3.3-70B-Instruct"),
additional_authorized_imports=["numpy", "datetime"],
max_steps=8,
)
The agent follows a strict protocol: Assess Risk โ if โฅ 0.75 โ GPS โ SOS โ First-Aid. I chose CodeAgent over ToolCallingAgent specifically because the threshold-based if/else branching is naturally expressed in generated Python code.
The ML Pipeline
| Component | Architecture | Params |
|---|---|---|
| Teacher | Transformer EEG Classifier | 661K |
| Student (RGF-Net) | Ring-Buffer GRU + FiLM | 37.5K |
The student model uses FiLM conditioning to adapt predictions based on patient biometrics (age, heart rate, HRV, medication adherence). Knowledge Distillation compresses the teacher 17.6ร while keeping the student under 100K params for Android Edge-AI deployment (~36.7 KB at INT8).
What I learned about smolagents
Toolsubclass withsetup()is perfect for heavy model loading โ weights only load on first call@tooldecorator is clean for simple stateless utilitiesadditional_authorized_importsis easy to miss but critical- Low temperature (0.1) makes the agent deterministic enough for medical decisions
The interactive demo lets you inspect architectures, run the KD training pipeline, and test live inference with configurable biometrics.
Feedback welcome! ๐