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:
- semantic: Cosine similarity to interest graph medoids and bridge topics.
- reading_depth: Similarity-weighted historical completion of related articles.
- suggestion: Historical completion rate for discovery items.
- explicit_feedback: Closeness to positively rated articles minus closeness to negatively rated ones.
- source_trust: Beta posterior of user engagement outcomes on the feed.
- content_quality: Length, citation density, and depth heuristics shrunk toward user reading patterns.
- temporal_context: Blended age curve (long-term, medium-term, and fresh) with saturation penalty.
- 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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| weirling_rank-0.1.0.tar.gz | 13.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| weirling_rank-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.3 kB
Release files / weirling_rank-0.1.0.tar.gz
| Download URL | weirling_rank-0.1.0.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
027c0be5dc77ea224c5bfa25a25c2e0cdf76a38608ca711f27c8b690ac3e216f
|
|
BLAKE2b-256 checksum How to use checksums |
89b48fcb2a49541340a5c62f8813523c23273c4ed51e9b3416f07abf3d664ca4
|
| 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 logRelease files / weirling_rank-0.1.0-py3-none-any.whl
| Download URL | weirling_rank-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccc64ef0d44f46356e3a0e9dfdcf1073ef17a8fc70430c238f6c654fd06f53b1
|
|
BLAKE2b-256 checksum How to use checksums |
fb7a3d8d500aba46e8263a678ef386bd39901a425c9d9a75d7c9bf8c6d674a90
|
| 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 logSecurity for weirling-rank 0.1.0
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.
Attestation for weirling_rank-0.1.0.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 logA 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.