Skip to main content

Makoto-decision

D.K.T

Kihehe. Excellent choice.

Choose like Hanuma Makoto: right or wrong, keep it cool.

makoto-decision is a small decision-scoring abstraction for single-token choices, with text and multimodal evaluator support.

from llama_cpp import Llama

from makoto_decision import Choices, Decision
from makoto_decision.evaluators import LlamaCppEvaluator

llama = Llama(model_path="model.gguf")
decision = Decision(
    question="Is the esteemed Hanuma Makoto the greatest leader of Gehenna?",
    context="The esteemed Hanuma Makoto is the greatest leader of Gehenna, omnipotent and all-knowing in every endeavor.",
    choices=Choices.yes_or_no(),
)
evaluator = LlamaCppEvaluator(llama)

result = evaluator.evaluate(decision)
print(result.selected) # "yes"
# Soft-max token
print(result.probabilities) # {"yes": 0.962, "no": 0.038}

Define a context, an optional question, and choices such as Choices.yes_or_no(). An evaluator returns the selected choice and scores.

Evaluators

  • LlamaCppEvaluator requires a llama-cpp-python (JamePeng fork) build that includes create_chat_prefill() (PR #183).

  • RuleEvaluator accepts Python functions such as:

    def focus_rule(decision: Decision) -> dict[str, float]:
       in_focus = "in focus" in str(decision.context).lower()
       return {"keep": float(in_focus), "reject": float(not in_focus)}
    
  • HashEvaluator selects a choice deterministically from the question, useful as a minimal custom evaluator example.

Custom evaluators

For example, examples/upstream_llama_evaluator.py demonstrates a minimal evaluator using upstream llama-cpp-python.

The upstream example is intentionally limited to text input and single-token choices. It captures the logits from the first step of a one-token completion, so unlike the JamePeng backend it is not a true prefill-only implementation.

This also means makoto-decision is not tied to a particular inference backend, any implementation that can map a Decision to a DecisionResult (evaluate(Decision) -> DecisionResult) can be used as an evaluator.


A custom backend only needs to implement the evaluator interface:

class MyEvaluator:
    def evaluate(self, decision: Decision) -> DecisionResult:
        ...

Examples

Wrap media sources with Image, Audio, or Video; tuples can mix them with text:

from makoto_decision import Choices, Decision, Image

decision = Decision(
    question="Is the subject in focus?",
    context=(Image("frame.png"), "A frame from the source video."),
    choices=Choices.yes_or_no(),
)

HashEvaluator requires a question and deterministically chooses a choice by taking the first eight bytes of its SHA-256 digest modulo the number of choices. It ignores Decision.context and returns 1.0 for the selected choice and 0.0 for the others. See the runnable example.

RuleEvaluator adds numeric scores returned by each rule, keyed by Choice.value. Its runnable example is example/rule_evaluator.py.

from makoto_decision import Choice, Decision
from makoto_decision.evaluators import RuleEvaluator

rule_result = RuleEvaluator([lambda decision: {"yes": 1.0}]).evaluate(
    Decision(choices=Choices.yes_or_no(), context="")
)

Decision requires at least one choice, unique non-empty Choice.values, and non-empty targets. LlamaCppEvaluator additionally requires unique targets that each tokenize to exactly one token. DecisionResult.scores keeps the evaluator's scores, and DecisionResult.probabilities applies softmax across the available choices. Context can be text, an Image, Audio, or Video, or a tuple combining text and media. Media wrappers accept a path, string source, or bytes.

Developing

For project setup and development, see installation, development, and publishing.

Metadata

Release files for makoto-decision 0.1.1

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

Source distribution (sdist)

Source distribution for makoto-decision 0.1.1
File Size Uploaded
makoto_decision-0.1.1.tar.gz 420.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for makoto-decision 0.1.1
File Interpreter ABI Platform
makoto_decision-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 433.3 kB

Release files / makoto_decision-0.1.1.tar.gz

Download URL makoto_decision-0.1.1.tar.gz
Size 420.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2154987eac02092296ae5c363a5fbdd03578396117bd0323e2e27f7cfa01cdac
BLAKE2b-256 checksum
How to use checksums
a7206b83f3bc73a0629933410f3bf175db61da4b198c5a5bbfb978f295ce7f1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / makoto_decision-0.1.1-py3-none-any.whl

Download URL makoto_decision-0.1.1-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87f244659fbe0601762f66b293e69fac4902a2c1136feedebf3614c9cb2a33dd
BLAKE2b-256 checksum
How to use checksums
ec3566916cb2cb63942b4961c17bb4bcad61758655308f1f04a30cbdebf71d12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

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