Skip to content

Repository files navigation

AI2ML

AI2ML is a hybrid AI + ML control plane for reducing the cost of large language model usage. The big LLM stays the generalist reasoning layer, while AI2ML continuously monitors traffic, turns repeated behavior into datasets, trains a smaller model, and deploys that smaller model to absorb routine work.

This repository now contains a complete local MVP of that loop.

What AI2ML Solves

Large LLMs are expensive to run at scale. In real systems, many requests are not truly novel. They repeat the same narrow patterns again and again:

  • classification
  • routing
  • filtering
  • cache decisions
  • simple delegation decisions
  • structured pre-processing before an LLM call

AI2ML keeps the expensive LLM for hard or novel cases and gradually builds a cheaper ML layer for the repetitive ones.

Implemented Technology

The codebase implements a full five-stage pipeline:

  1. MonitorAgent generates or captures workload events.
  2. CollectorAgent validates and persists those events.
  3. AggregatorAgent transforms raw events into ML-ready aggregate rows.
  4. TrainerAgent builds a lightweight delegation model from the aggregates.
  5. ProviderAgent deploys the latest model and serves predictions.

The current trainer/provider layer is intentionally lightweight and dependency free. It uses a heuristic model as the built-in baseline so the whole AI2ML loop works locally without external ML infrastructure. That baseline can later be replaced by a richer ML backend.

Repository Layout

  • agents.py contains the main agent implementations.
  • main.py builds the runtime and exposes run_full_pipeline().
  • server.py exposes the Flask API.
  • storage.py persists agent snapshots, events, aggregates, and model versions.
  • config.py defines runtime and agent configs.
  • Agents.md documents the architecture and schemas.

Local Run

  1. Create and activate a virtual environment.
  2. Install dependencies with pip install -r requirements.txt.
  3. Run the API with python3 server.py.
  4. Optionally run a full local demo loop with python3 main.py.

API Overview

Main endpoints:

  • GET /health
  • GET /api/status
  • GET /api/agents
  • POST /api/pipeline/monitor
  • POST /api/pipeline/collect
  • POST /api/pipeline/aggregate
  • POST /api/pipeline/train
  • POST /api/pipeline/deploy
  • POST /api/pipeline/run
  • GET /api/data/events
  • GET /api/data/aggregates
  • GET /api/models
  • POST /api/models/predict
  • POST /api/models/compare

Example Flow

Run the entire AI2ML loop in one request:

curl -X POST http://localhost:5000/api/pipeline/run \
  -H 'Content-Type: application/json' \
  -d '{"behavior_type":"user_engagement","duration_hours":24,"event_count":120}'

Ask the deployed model whether a request should stay on the LLM or be delegated:

curl -X POST http://localhost:5000/api/models/predict \
  -H 'Content-Type: application/json' \
  -d '{"input_data":{"event_type":"classification"}}'

Stored Data

Runtime data is persisted under ./data:

  • agent_data.pkl
  • collected_events.json
  • aggregated_data.csv
  • model_versions.json

Contributing

If you want to improve AI2ML, send ideas, fixes, or architectural proposals as GitHub pull requests. Proposal-style PRs are welcome, especially for new routing strategies, aggregation logic, model backends, and infrastructure integrations.

License Summary

AI2ML is licensed under the custom terms in LICENSE.

In short:

  • commercial use is allowed
  • attribution is required
  • you may not resell AI2ML itself as a standalone product
  • you may not present AI2ML as if it were your original standalone work

The standard MIT text is included only as a reference in LICENSE-MIT.md. The operative license for this project is the custom LICENSE.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages