Metadata-Version: 2.5
Name: khaos-ml
Version: 1.0.1
Summary: Local-first pre-trained models for domain-specific tasks: finance, physics, robotics, 3D, tabular, telemetry, graph and chemistry
Project-URL: Documentation, https://khaos-ml.mintlify.site/
Project-URL: Repository, https://github.com/fletxcher/khaos
Project-URL: Issues, https://github.com/fletxcher/khaos/issues
Project-URL: Models, https://huggingface.co/fletxcher
Author: fletxcher
Keywords: cheminformatics,entity-resolution,machine-learning,onnx,pde,pretrained-models,robotics,sec-filings
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: huggingface-hub
Requires-Dist: numpy
Requires-Dist: onnxruntime
Provides-Extra: 3d
Requires-Dist: trimesh; extra == '3d'
Provides-Extra: all
Requires-Dist: fastapi; extra == 'all'
Requires-Dist: pandas; extra == 'all'
Requires-Dist: python-multipart; extra == 'all'
Requires-Dist: rdkit; extra == 'all'
Requires-Dist: transformers; extra == 'all'
Requires-Dist: trimesh; extra == 'all'
Requires-Dist: uvicorn; extra == 'all'
Provides-Extra: chem
Requires-Dist: rdkit; extra == 'chem'
Provides-Extra: data
Requires-Dist: datasets; extra == 'data'
Requires-Dist: h5py; extra == 'data'
Requires-Dist: networkx; extra == 'data'
Requires-Dist: pandas; extra == 'data'
Requires-Dist: pyarrow; extra == 'data'
Requires-Dist: python-dotenv; extra == 'data'
Requires-Dist: rdkit; extra == 'data'
Requires-Dist: scikit-learn; extra == 'data'
Requires-Dist: scipy; extra == 'data'
Requires-Dist: trimesh; extra == 'data'
Requires-Dist: wfdb; extra == 'data'
Provides-Extra: dev
Requires-Dist: httpx; extra == 'dev'
Requires-Dist: onnx; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Provides-Extra: finance
Requires-Dist: beautifulsoup4; extra == 'finance'
Requires-Dist: lxml; extra == 'finance'
Requires-Dist: transformers; extra == 'finance'
Provides-Extra: graph
Requires-Dist: networkx; extra == 'graph'
Provides-Extra: serve
Requires-Dist: fastapi; extra == 'serve'
Requires-Dist: python-multipart; extra == 'serve'
Requires-Dist: uvicorn; extra == 'serve'
Provides-Extra: tabular
Requires-Dist: pandas; extra == 'tabular'
Requires-Dist: transformers; extra == 'tabular'
Provides-Extra: telemetry
Requires-Dist: scipy; extra == 'telemetry'
Provides-Extra: train
Requires-Dist: onnx; extra == 'train'
Requires-Dist: scikit-learn; extra == 'train'
Requires-Dist: torch; extra == 'train'
Requires-Dist: transformers; extra == 'train'
Description-Content-Type: text/markdown

# khaos: Pre-trained models for domain-specific tasks

khaos is a lightweight, modular, **local-first** machine learning framework for
Python. It ships compact pre-trained models for specialized engineering,
scientific and financial data, behind one small API, so you can run them on
standard CPU/edge hardware without sending data to an external service.

> **Version:** Khaos is on **v1**. The first release of every artifact is named
> `v1`; we do not use `v0.x` versions. The runtime, architectures and serving are in
> place, and artifacts are being trained and published domain by domain.

```python
import khaos

nlp = khaos.load("sec_10k_core")
doc = nlp("path/to/10k_filing.html")
print(doc.ents)    # extracted metrics, debt tranches, maturity dates
# [Entity(label="Revenue", value="$12.4B"), ...]
print(doc.vector)  # dense filing embedding
# [ 0.12 -0.03  0.88 ... ]
```

## Features

- One `khaos.load(...)` interface for every domain
- Pre-trained artifacts per vertical, fetched and cached from the Hugging Face Hub
- ONNX inference behind a lightweight core runtime; export from PyTorch, TensorFlow or any other library
- Heavy domain dependencies isolated as optional extras
- Pipelines resolved through a registry, so new artifacts plug in without touching core
- Built-in HTTP server (`khaos serve`) and Dockerfile for deployment
- `khaos` command-line interface for inspecting, downloading, serving and evaluating artifacts
- Domain-specific result containers: each vertical defines its own, with no shared base class

## Verticals and artifacts

| Extra | Domain | Example artifacts |
| --- | --- | --- |
| `khaos-ml[finance]` | SEC filings and XBRL extraction | `sec_10k_core`, `sec_8k_events`, `sec_form4_insider`, `sec_s1_ipo` |
| `khaos-ml[3d]` | CAD, meshes and point clouds | `geo_part_classifier`, `geo_mesh_embedding`, `geo_pointcloud_embedding` |
| `khaos-ml[tabular]` | Schema detection and entity resolution | `tab_column_types`, `tab_key_matching`, `tab_entity_dedupe`, `tab_anomaly_scoring` |
| `khaos-ml[telemetry]` | Industrial and IoT sensor time-series | `tele_sensor_vibration`, `tele_bio_ecg`, `tele_regime_shift` |
| `khaos-ml[graph]` | Graph and network topology encoders | `graph_node_embedding`, `graph_subgraph_embedding`, `graph_fraud_rings`, `graph_link_prediction` |
| `khaos-ml[chem]` | Molecular and material properties | `chem_mol_embedding`, `chem_logp`, `chem_solubility`, `chem_toxicity` |
| `khaos-ml` (core) | PDE simulation surrogates | `pde_darcy_flow_2d`, `pde_navier_stokes_steady_2d`, `pde_heat_diffusion_2d`, `pde_wave_evolution_2d` |
| `khaos-ml` (core) | Robot trajectory and kinematics encoders | `robo_kinematics_sm`, `robo_skill_segmentation`, `robo_failure_detection` |

See [`idea.txt`](idea.txt) for the full vision and roadmap.

## Installation

Requires Python 3.10+. The package is named `khaos-ml`; the import is `khaos`.

```bash
pip install khaos-ml              # or: poetry add khaos-ml / uv add khaos-ml
pip install "khaos-ml[all]"       # everything needed to run every artifact
```

## Serve it

Train elsewhere, export to ONNX, and serve:

```bash
pip install "khaos-ml[serve]"
khaos serve ./my-artifact --port 8000
curl -X POST localhost:8000/v1/artifacts/pde_darcy_flow_2d/predict \
  -H "Content-Type: application/json" -d '{"input": [[0.0, 0.1], [0.2, 0.3]]}'
```

See the [docs](https://khaos-ml.mintlify.site/) for the artifact format, authentication and Docker.

## Command line

```bash
khaos info                  # list known artifacts
khaos download <artifact>       # fetch an artifact from the Hugging Face Hub
khaos serve [artifact ...]      # serve artifacts over HTTP
khaos evaluate <artifact>       # evaluate an artifact (not implemented yet)
```

## Repository layout

```text
khaos/
├── pyproject.toml
├── khaos/              # importable package
│   ├── registry.py     # artifact registry and load()
│   ├── manifest.py     # artifact manifest (training -> runtime contract)
│   ├── modeling.py     # khaos.modeling.build(artifact)
│   ├── export.py       # export_artifact(): model -> manifest + ONNX
│   ├── layers.py       # ONNX-friendly transformer blocks
│   ├── pipeline.py     # BasePipeline, OnnxPipeline, ModalityProcessor
│   ├── serve/          # HTTP server
│   ├── cli/            # `khaos` command
│   └── finance/ geometry/ tabular/ telemetry/ graph/ chem/ physics/ robotics/
│                       # one subpackage per vertical (adapter, pipelines,
│                       # and its own containers.py)
├── artifacts/          # artifact definitions, one dir per domain
├── docs/               # documentation site (Mintlify)
├── training/           # per-artifact training and evaluation configs
└── tests/
```

Model weights are not stored in this repository; they are published to the
Hugging Face Hub and cached under `~/.cache/khaos`.

## Documentation

Read the docs at **https://khaos-ml.mintlify.site/**. They live in `docs/` and are built with [Mintlify](https://www.mintlify.com/docs):

```bash
npm i -g mint
cd docs && mint dev     # http://localhost:3000
```

## Run tests

```bash
pip install -e ".[dev]"
python -m pytest tests
```
