Skip to main content

arcasha-router (Python)

Observation-Driven Adaptive Routing (ODAR) — belief-driven routing engine for heterogeneous LLM pools. Python port of @arcasha/router (ArcAsha のルーティングコア)。依存なし (pure Python) で、WebGPU アプリや エッジ AI プロジェクトに埋め込めます。

インストール

pip install -e .        # 開発 (このディレクトリから)
# または (公開後):  pip install arcasha-router

使い方 (フル情報 / シャドウループ)

from arcasha_router import (
    BayesianBelief, LinUCBShadowRouter, compute_rewards, find_oracle,
)

experts = [
    {"nodeId": "node-a", "modelId": "M1", "family": "qwen", "paramsM": 596, "memoryGB": 1.2, "temperature": 0.6},
    # ...
]
router = LinUCBShadowRouter(experts)   # alpha=0.3, lambda=1.0

# 1 ステップ: 全エキスパート評価 (shadow) → 報酬 → 選択 → Full-Information 更新
ctx = {
    "task": {"id": "t1", "capability": "coding", "prompt": "..."},
    "states": states,     # nodeId -> {"capability": {...}, "latencyMs": int, "stability": float}
    "rewards": rewards,   # compute_rewards(experts, results, states, max_lat, max_params)
    "order": [e["nodeId"] for e in experts],
    "step": step,
}
chosen = router.select(ctx)
router.observe(ctx)       # 全アームの報酬で更新

API

シンボル 内容
BayesianBelief / EmaLatency 状態推定 (μ, confidence=1-exp(-n/8), effective, 事前分布シード)
LinUCBShadowRouter 提案手法 (disjoint LinUCB + シャドウ = フル情報)
UCBShadowRouter / FixedRouter / RandomRouter / RoundRobinRouter ベースライン
build_features 8 次元特徴量
compute_rewards / find_oracle 多目的報酬 (Q+L+C+S) と Oracle
evaluate_all / evaluate_task ルールベース評価 + シャドウ実行 (async)

検証

cd packages/arcasha-router-py
python demo.py

出力例 (合成プール): LinUCB-Shadow が 60 ステップで最良ノード (node-b) を即学習 し、regret=0。UCB-Shadow / Random は探索コストを払う。

研究: Observation-Driven Routing for Distributed Heterogeneous Language Models (Zenodo 10.5281/zenodo.21755612)。MIT License — ArcAsha (Akasha-OS).

Metadata

Release files for arcasha-router 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arcasha-router 0.1.0
File Size Uploaded
arcasha_router-0.1.0.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arcasha-router 0.1.0
File Interpreter ABI Platform
arcasha_router-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 kB

Release files / arcasha_router-0.1.0.tar.gz

Download URL arcasha_router-0.1.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
323491904423e1f2870f121bf39e32745c1810985db8ae4ff2617b933f4068db
BLAKE2b-256 checksum
How to use checksums
b08cf3aef10e757ca6dc8b1817d10ad1e18650785763a928c004f9ae0ea024d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / arcasha_router-0.1.0-py3-none-any.whl

Download URL arcasha_router-0.1.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f1f7e1c45bbf55bf66b1716ba6d7c19d5fef6dfca7de8c3e0b6fce1fb8703a1
BLAKE2b-256 checksum
How to use checksums
12c28241837d9049db5857f19f8a2fe2d7c2b7908658c02e27954630ebaf1f5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page