phanerozoic / threshold-halfsubtractor

huggingface.co
Total runs: 10
24-hour runs: 0
7-day runs: -1
30-day runs: 5
Model's Last Updated: January 23 2026

Introduction of threshold-halfsubtractor

Model Details of threshold-halfsubtractor

threshold-halfsubtractor

Subtracts two 1-bit inputs, producing difference and borrow. The subtraction counterpart to the half adder.

Circuit
      a       b                    a   b
      │       │                    │   │
      ├───┬───┤                    └─┬─┘
      │   │   │                      │
      ▼   │   ▼                      ▼
  ┌──────┐│┌──────┐              ┌───────┐
  │  OR  │││ NAND │              │ ¬a ∧ b│
  │w:1,1 │││w:-1,-1│             │w:-1,1 │
  │b: -1 │││b: +1 │              │b: -1  │
  └──────┘│└──────┘              └───────┘
      │   │   │                      │
      └───┼───┘                      │
          ▼                          │
      ┌──────┐                       │
      │ AND  │                       │
      │w: 1,1│                       │
      │b: -2 │                       │
      └──────┘                       │
          │                          │
          ▼                          ▼
        diff                      borrow

The diff output uses XOR (2 layers). The borrow output detects when we subtract 1 from 0.

Truth Table
a b diff borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0

Binary: a - b = diff - (borrow × 2)

Mechanism

Diff (XOR): Same as the half adder's sum. The difference bit is 1 when exactly one input is 1.

Borrow: Uses weights [-1, +1] with bias -1. This fires only when a=0 and b=1:

  • a=0, b=0: -0 + 0 - 1 = -1 < 0 → no borrow
  • a=0, b=1: -0 + 1 - 1 = 0 ≥ 0 → borrow
  • a=1, b=0: -1 + 0 - 1 = -2 < 0 → no borrow
  • a=1, b=1: -1 + 1 - 1 = -1 < 0 → no borrow

The borrow is NOT(a) AND b - we borrow when subtracting 1 from 0.

Components
Output Function Neurons Layers
diff XOR(a, b) 3 2
borrow ¬a ∧ b 1 1

Total: 4 neurons, 12 parameters

Contrast with Half Adder
Circuit Output 2 Function Weights
HalfAdder carry a ∧ b [1, 1], b=-2
HalfSubtractor borrow ¬a ∧ b [-1, 1], b=-1

The only difference: borrow has an inhibitory weight on a.

Usage
from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def half_subtractor(a, b):
    inp = torch.tensor([float(a), float(b)])

    # XOR for diff
    l1 = (inp @ w['xor.layer1.weight'].T + w['xor.layer1.bias'] >= 0).float()
    diff = int((l1 @ w['xor.layer2.weight'].T + w['xor.layer2.bias'] >= 0).item())

    # Borrow
    borrow = int((inp @ w['borrow.weight'].T + w['borrow.bias'] >= 0).item())

    return diff, borrow
Files
threshold-halfsubtractor/
├── model.safetensors
├── model.py
├── config.json
└── README.md
License

MIT

Runs of phanerozoic threshold-halfsubtractor on huggingface.co

10
Total runs
0
24-hour runs
0
3-day runs
-1
7-day runs
5
30-day runs

More Information About threshold-halfsubtractor huggingface.co Model

More threshold-halfsubtractor license Visit here:

https://choosealicense.com/licenses/mit

threshold-halfsubtractor huggingface.co

threshold-halfsubtractor huggingface.co is an AI model on huggingface.co that provides threshold-halfsubtractor's model effect (), which can be used instantly with this phanerozoic threshold-halfsubtractor model. huggingface.co supports a free trial of the threshold-halfsubtractor model, and also provides paid use of the threshold-halfsubtractor. Support call threshold-halfsubtractor model through api, including Node.js, Python, http.

threshold-halfsubtractor huggingface.co Url

https://huggingface.co/phanerozoic/threshold-halfsubtractor

phanerozoic threshold-halfsubtractor online free

threshold-halfsubtractor huggingface.co is an online trial and call api platform, which integrates threshold-halfsubtractor's modeling effects, including api services, and provides a free online trial of threshold-halfsubtractor, you can try threshold-halfsubtractor online for free by clicking the link below.

phanerozoic threshold-halfsubtractor online free url in huggingface.co:

https://huggingface.co/phanerozoic/threshold-halfsubtractor

threshold-halfsubtractor install

threshold-halfsubtractor is an open source model from GitHub that offers a free installation service, and any user can find threshold-halfsubtractor on GitHub to install. At the same time, huggingface.co provides the effect of threshold-halfsubtractor install, users can directly use threshold-halfsubtractor installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

threshold-halfsubtractor install url in huggingface.co:

https://huggingface.co/phanerozoic/threshold-halfsubtractor

Url of threshold-halfsubtractor

threshold-halfsubtractor huggingface.co Url

Provider of threshold-halfsubtractor huggingface.co

phanerozoic
ORGANIZATIONS

Other API from phanerozoic

huggingface.co

Total runs: 87
Run Growth: 37
Growth Rate: 42.53%
Updated:September 26 2026