๐Ÿง  Aura-Agent: Seizure Prediction with smolagents CodeAgent + Knowledge Distillation

#14
by Babajaan - opened

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

  • Tool subclass with setup() is perfect for heavy model loading โ€” weights only load on first call
  • @tool decorator is clean for simple stateless utilities
  • additional_authorized_imports is 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! ๐Ÿ™

Sign up or log in to comment