Skip to main content

weirling-rank

Explainable, personalized recommendation ranker for feeds and reading digests. Extracted from Weirling.

weirling-rank is a pure-Python library with zero database or network dependencies (only requiring NumPy). It scores candidate items against a user profile using a vectorized pass and provides exact per-signal decompositions and human-readable explanations.

Eight Pre-Consumption Signals

Every feature score is normalized into [0.0, 1.0] and computable before the user sees the item:

  1. semantic: Cosine similarity to interest graph medoids and bridge topics.
  2. reading_depth: Similarity-weighted historical completion of related articles.
  3. suggestion: Historical completion rate for discovery items.
  4. explicit_feedback: Closeness to positively rated articles minus closeness to negatively rated ones.
  5. source_trust: Beta posterior of user engagement outcomes on the feed.
  6. content_quality: Length, citation density, and depth heuristics shrunk toward user reading patterns.
  7. temporal_context: Blended age curve (long-term, medium-term, and fresh) with saturation penalty.
  8. novelty: Distance from recent reading history peaking at the user target.

Signals without evidence stay at neutral 0.5 and are recorded in no_data.

Installation

pip install weirling-rank

Quickstart

import numpy as np
from datetime import datetime, UTC
from weirling_rank import (
    Candidate,
    UserRankingState,
    Interest,
    rank_candidates,
    SIGNALS,
)

# 1. Define candidate items with embeddings and metadata
vec_a = np.array([1.0, 0.0, 0.0], dtype=np.float32)
vec_b = np.array([0.0, 1.0, 0.0], dtype=np.float32)

cand_a = Candidate(
    id="article-1",
    title="Deep Dive into Distributed Systems",
    embedding=vec_a,
    word_count=1200,
    has_citations=True,
    published_at=datetime.now(UTC),
)
cand_b = Candidate(
    id="article-2",
    title="Cooking Perfect Pasta",
    embedding=vec_b,
    word_count=600,
    published_at=datetime.now(UTC),
)

# 2. Build user ranking state with interest clusters and weights
user_state = UserRankingState(
    user_id="user-123",
    weights={s: 1.0 / len(SIGNALS) for s in SIGNALS},
    interests=[
        Interest(vector=vec_a, importance=1.0, label="Distributed Systems"),
    ],
    prefers_fresh=True,
    novelty_target=0.35,
)

# 3. Rank candidates
scored = rank_candidates(user_state, [cand_a, cand_b])

for item in scored:
    print(f"{item.item.title}: PRS = {item.prs:.3f}")
    print(f"  Explanation: {item.explanation}")
    print(f"  Component features: {item.features}")

Releases

Automatic. When a change to backend/weirling_rank/ or packages/weirling-rank/ is merged to main, CI bumps the version from the last weirling-rank-v* tag, tags it, builds, publishes to PyPI (Trusted Publishing, no token) and creates a GitHub Release weirling-rank-vX.Y.Z with the wheel and the change list. The bump is a patch by default; put [rank:minor] in a commit message for a minor release, [rank:major] or BREAKING for a major one, [rank:skip] for none.

License

MIT

Metadata

Release files for weirling-rank 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 weirling-rank 0.1.1
File Size Uploaded Provenance
weirling_rank-0.1.1.tar.gz 13.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for weirling-rank 0.1.1
File Interpreter ABI Platform
weirling_rank-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 26.3 kB

Release files / weirling_rank-0.1.1.tar.gz

Download URL weirling_rank-0.1.1.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c79a418b5fd1473b33c94ee5bbe90af4a3c95b9081cadb94dabcffff12d242f9
BLAKE2b-256 checksum
How to use checksums
2ec0976b3ce9c1279fc4ac159dc73b71b99f86903283e5b30b919a73a4df8b25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

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

Download URL weirling_rank-0.1.1-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18c3badb9c5a5f9ba6f6ed490c5145331383d910962fc5119b2243be3784988d
BLAKE2b-256 checksum
How to use checksums
655fe14084f91e21ab7fbaf04811e5b803a9ddf2adc17f219196dbc4d57d368c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for weirling-rank 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for weirling_rank-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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