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.2

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.2
File Size Uploaded Provenance Actions
weirling_rank-0.1.2.tar.gz 14.2 kB With provenance Details for weirling_rank-0.1.2.tar.gz

Built distribution (wheel)

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

Total release size: 27.3 kB

Release files / weirling_rank-0.1.2.tar.gz

Download URL weirling_rank-0.1.2.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
76af25949b6e734ff7dbecf8e3694ccb91ad4d6f9afa55cb14bd03b14eaecaae
BLAKE2b-256 checksum
How to use checksums
48074b5c9fa755d2dbca7e6489173a5e53b4d47f6b5b9e32a46121cb1f6aa49c
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 25, 2026.

Transparency log

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

Download URL weirling_rank-0.1.2-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d46842023ced7f62edc5d5ff8b62f745e0fa4be5b7a95daa87d0e4fd31b6ea2
BLAKE2b-256 checksum
How to use checksums
329928347dc0d6029bc806067f6962002156b38e955790169e6dc96b25ba5135
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 25, 2026.

Transparency log

Security for weirling-rank 0.1.2

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.2.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 25, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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