# Copyright 2026 Knowledge Computing Lab (KCL), Peking University # SPDX-License-Identifier: Apache-2.0 """Decision Index engine for PKU-KCL-Meteor, run in process by the kit. From this repository's directory (or with it on PYTHONPATH): python -m decision_index pipeline --engine decision_index_engine:MeteorEngine --out runs/ Options (``--option key=value``): ``model`` (this directory by default, or a Hub id), ``revision``, ``device`` (default ``cuda:0``), ``batch_size`` (at most this many questions per forward pass, default 32), ``max_batch_tokens`` (at most this many padded tokens per forward pass, default 32768; a longer single question still runs whole) and ``verify`` (``fast``, ``full`` or ``none`` check of the files against MODEL_MANIFEST.json, default ``fast``). """ import sys from pathlib import Path from decision_index.engines.base import Engine, Unsupported ROOT = Path(__file__).resolve().parent if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) class MeteorEngine(Engine): name = "pku-kcl-meteor" latency = ("In-process request wall time: prompt rendering, tokenization, one forward pass per question " "and the readout; excludes model loading.") def __init__(self, model=None, revision=None, device="cuda:0", batch_size=32, max_batch_tokens=32768, verify="fast", **options): if options: raise ValueError(f"unknown MeteorEngine options: {sorted(options)}") super().__init__() from meteor import Meteor self.model = Meteor(model, revision=revision, device=device, batch_size=batch_size, max_batch_tokens=max_batch_tokens, verify=verify) self.provenance = {"kind": "in-process", **self.model.provenance()} def __call__(self, state, questions, **inputs): from meteor import CapacityError if inputs: raise Unsupported("PKU-KCL-Meteor reads text only; got " + ", ".join(sorted(inputs))) try: response = self.model.decide(state, questions) except CapacityError as error: raise Unsupported(str(error)) from None return response, response def runtime(self): return self.model.runtime() def synchronize(self): self.model.synchronize() def close(self): self.model.close()