Skip to main content

gut

Judgment calls as one line of Python, on models small enough to put inside an if.

Your code keeps running into questions that aren't logic: Is this comment spam? Which team owns this ticket? How urgent is it? Is the agent's task done? Until now there were three answers:

  • Regex and keyword rules — free and instant, and wrong the moment someone phrases it differently.
  • A frontier LLM — understands anything, at seconds and cents a call, with prose to parse.
  • Train a classifier — cheap to run, once you have the labelled data, the pipeline and the week.

There is a fourth: small models. A 70M-parameter NLI model answers "is this spam?" in about a tenth of a second on a laptop CPU; a 0.6B language model, in under a second on a laptop GPU. Hosted models built for exactly this, like Jev, need no hardware at all. They are good enough for these questions — but each speaks its own API, and none of them hands you a decision.

gut is the primitive that does:

import gut

if gut.likely(comment, "is spam"):
    hide(comment)

No prompt, no parsing, no threshold — and no model named in your code.

Three questions

gut.likely(ticket, "is a bug report")                      # yes / no
gut.classify(ticket, Team)                                 # which one — an Enum
gut.rate(ticket, ["can wait", "this week", "right now"])   # how much

It knows when it doesn't know

A regex never hesitates, and neither does an LLM. gut can:

match gut.likely(email, "the customer threatens to cancel", ask_human=True):
    case gut.YES:    escalate(email)
    case gut.NO:     auto_reply(email)
    case gut.UNSURE: send_to_a_person(email)

Say how careful to be in words — lean="yes", stakes="high" — and gut works out the thresholds.

Any model

The model is configuration, not code. Change it and nothing else changes:

gut.configure(backend=gut.ZeroShotBackend())                       # NLI model, on your CPU
gut.configure(backend=gut.TransformersBackend("Qwen/Qwen3-0.6B"))  # small LLM, on your machine
gut.configure(backend=gut.OpenAICompatibleBackend(                 # Ollama, vLLM, llama.cpp
    "qwen2.5:1.5b", base_url="http://localhost:11434/v1"))
gut.configure(backend=gut.OpenAICompatibleBackend("gpt-4.1-nano")) # OpenAI
gut.configure(backend=gut.JevBackend())                            # TypeSafe AI's Jev

Or several at once. Cascade asks the cheapest model first and passes on only what it is unsure of:

gut.configure(backend=gut.Cascade(
    gut.ZeroShotBackend(),                        # free and local: settles the obvious
    gut.OpenAICompatibleBackend("gpt-4.1-nano"),  # sees only what the first could not
))

Answers are read from each model's own probabilities, never parsed from text, and decision.model names the model that gave one. Your own model can be a backend too: here is how.

Several questions, one pass

@gut.semantic
def handle(ticket):
    if gut.likely(ticket, "is a bug report"):
        ...
    elif gut.likely(ticket, "asks for a refund"):   # already answered
        ...

Every judgment about ticket goes to the model together: one request to a hosted model, one pass over the ticket for a local one.

Install

pip install gutfeel                  # any OpenAI-compatible server; FakeBackend for tests
pip install "gutfeel[local]"         # + ZeroShotBackend and TransformersBackend (PyTorch)
pip install "gutfeel[jev]"           # + JevBackend

The package on PyPI is gutfeel (gut was taken); the import is plain import gut. No model at hand? gut.FakeBackend(answers={"is spam": 0.97}) answers from fixtures, for tests.

Docs

Getting started Install, pick a backend, and the three questions.
Backends Every model gut can run on, Cascade, and writing your own.
Knowing when it doesn't know lean, ask_human, stakes, and what if and match do with UNSURE.
Asking everything at once @semantic and judge(): every judgment about one subject, together.
Exact costs The cost model under the posture words.
Caching and observability The cache, and seeing every decision as it is made.
Honest limitations What small models get wrong, and what gut does not do.

examples/ runs the same code on every backend. Coding agents: read SKILL.md.

Status

Pre-1.0. Every code block in these docs runs in the test suite; every decision is in DECISIONS.md.

License

Apache-2.0 · contributing

Release files for gutfeel 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 gutfeel 0.1.0
File Size Uploaded
gutfeel-0.1.0.tar.gz 62.8 kB Details

Built distribution (wheel)

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

Total release size: 140.7 kB

Release files / gutfeel-0.1.0.tar.gz

Download URL gutfeel-0.1.0.tar.gz
Size 62.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6f9280f914737bdb19851c5f4eef92523e5e3d8b5d5eb138b7d0979773aa7a66
BLAKE2b-256 checksum
How to use checksums
accd28b3e4a42cc1b1e01d1e6965f3ceec0d1c33d4f22b6e47988b3cc61b60bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL gutfeel-0.1.0-py3-none-any.whl
Size 77.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3eee8da6c5c07cd481000addedfe4a49b5daf7331b4fb02db03d5d6db16b26fd
BLAKE2b-256 checksum
How to use checksums
75303c9fc82baefee4481e1beb545de2fc99c325eb7662e13c133ee72d2ae78f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

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