-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Open
Description
Title: Feature: Secure Fibonacci Multiplier for Heavy Ranker – Positivity, Fair Tiers, Allegiance Booster (Post-c54bec0)
Body:
Following commit c54bec0 (Sept 9, 2025), I propose a secure, user-friendly enhancement to the Heavy Ranker (projects/home/recap/ranking.py
) to boost positivity, balance tiers, block bots, and foster user allegiance to X, aligning with goals of uplifting small accounts, reducing negativity, and integrating Grok AI (#0, #1, #6). The Fibonacci-based approach creates a harmonic synergy, rewarding quality content while ensuring fairness for all users.
Proposal:
- Fibonacci Boosts: Amplify positive sentiment (2.0 max) and thoughtful replies (>10 words, 8.0 max) with Fib(n)/5.0. Caps: small (<1K followers) 2.5x, median (1K–100K) 2.0x, big (>100K) 1.5x with volatility penalty.
- Bot-Proof Shield: Downrank fakes with 1/(Fib(n)+1), cutoff at fakeness >8 (score * 0.01). Signals: like velocity (>150), reply diversity (<0.3), account age (<7 days), reply length variance. Randomized weights (0.8–1.2x) block bot counterattacks.
- Tiers:
- Small: 2.5x cap, 0.2% “Fibonacci Spark” (+1 level) for discovery.
- Median: 2.0x cap, 1.1x stability.
- Big: Volatile (0.7x for low quality), privileges (halved penalties for 5-hour activity or 2-week day-off with 2x ranking boost).
- RMS Prediction: Pre-boosts high early engagement.
- Transparency: Logs boost, penalty, tier, privileges, anti-bot signals, and user-friendly messages (e.g., “Great replies boosted your post!”) for “Why This Post?” UI.
- Allegiance Booster: Rewards thoughtful content, softens bot detection to avoid penalizing genuine users, and uses Spark to engage new voices, fostering loyalty to X.
Why It Fits:
- Boosts positivity (leverages
reply=13.5
,reply_engaged_by_author=75.0
) for “unregretted user-seconds” (#28). - Uplifts small accounts with equitable boosts and Spark (#6).
- Anti-gameable with precise bot detection (#0).
- Encourages allegiance via transparency, fair rewards, and a fun Fibonacci approach, optimized for PyTorch and Grok AI (#1).
Sample Code:
import random
from datetime import datetime, timedelta
from transformers import pipeline
from typing import Dict, Tuple
import numpy as np
# Initialize Grok proxy (sentiment analysis, PyTorch-based)
sentiment_pipeline = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english", framework="pt")
def fibonacci(n: int) -> int:
"""Computes nth Fibonacci number for dynamic boosts/penalties."""
if n <= 0:
return 0
elif n == 1:
return 1
a, b = 0, 1
for _ in range(2, n + 1):
a, b = b, a + b
return b
def quality_score(post: Dict) -> float:
"""Scores post quality (0-10): positivity (2.0 max) + reply thoughtfulness (8.0 max, >10 words)."""
post_sent = sentiment_pipeline(post['text'])[0]
pos_score = 2.0 if post_sent['label'] == 'POSITIVE' else 0.0
reply_avg_len = sum(len(r['text'].split()) for r in post.get('replies', [])) / max(len(post['replies']), 1)
thoughtfulness = min(8.0, reply_avg_len / 3.2) # ~16 words = 5.0
return min(10.0, pos_score + thoughtfulness)
def fakeness_score(post: Dict) -> float:
"""Scores bot-like behavior (0-10, cutoff >8). Signals: velocity, diversity, age, reply variance."""
like_velocity = post['likes'] / (post['age_hours'] + 1)
reply_diversity = len(set(r['text'] for r in post.get('replies', []))) / max(len(post['replies']), 1)
account_age_days = (datetime.now() - post.get('author_created_at', datetime.now())).days
replies = post.get('replies', [])
originality = 5.0
if len(replies) > 1:
lengths = [len(r['text'].split()) for r in replies]
max_len_diff = max(lengths) - min(lengths)
originality = min(5.0, 5.0 * max_len_diff / max(1, sum(lengths) / len(lengths)))
random_weight = random.uniform(0.8, 1.2) # Randomize to deter bot gaming
score = random_weight * (
(3.0 if like_velocity > 150 else 0.0) +
(3.0 if reply_diversity < 0.3 else 0.0) +
(2.0 if account_age_days < 7 else 0.0) +
(2.0 if originality < 2.0 else 0.0)
)
return min(10.0, score)
def rms_engagement(post: Dict) -> float:
"""Predicts engagement via RMS of early signals vs. historical averages."""
recent_signals = [post.get('likes_first_hour', post['likes'] / 2), post.get('replies_first_hour', len(post['replies']) / 2)]
historical_avg = [post.get('author_avg_likes', 10), post.get('author_avg_replies', 2)]
squared_diff = [(s - h) ** 2 for s, h in zip(recent_signals, historical_avg)]
return (sum(squared_diff) / len(squared_diff)) ** 0.5
def adjust_fib_level_with_rms(post: Dict, base_level: int) -> int:
"""Bumps Fibonacci level if RMS predicts high engagement."""
threshold = post.get('author_rms_threshold', 50.0)
return base_level + 1 if rms_engagement(post) > threshold else base_level
def big_account_privileges(post: Dict) -> Tuple[float, float]:
"""Big-account privileges: halved penalties for 5-hour shift or 2-week day-off, 2x boost for day-off."""
is_big = post['author_followers'] > 100_000
account_age_days = (datetime.now() - post.get('author_created_at', datetime.now())).days
active_hours = post.get('author_daily_active_hours', 0.0)
day_off_eligible = account_age_days < 365 and post.get('author_day_off_count', 0) < 14
penalty_reduction = 1.0
monetization_boost = 1.0
if is_big:
if active_hours >= 5 or (day_off_eligible and post.get('is_day_off_post', False)):
penalty_reduction = 2.0
if day_off_eligible and post.get('is_day_off_post', False):
monetization_boost = 2.0
post['author_day_off_count'] = post.get('author_day_off_count', 0) + 1
return penalty_reduction, monetization_boost
def heavy_ranker_score(post: Dict, probs: Dict[str, float]) -> Tuple[float, Dict]:
"""Enhances Heavy Ranker with Fibonacci boosts, anti-bot penalties, tiers, privileges, RMS, and transparency.
Inputs:
post: Dict with text, likes, replies, author_followers, age_hours, etc.
probs: Dict of MaskNet probabilities (e.g., scored_tweets_model_weight_fav).
Returns: (final_score, explanation dict).
"""
# Base score from Heavy Ranker weighted sum
weights = {
'scored_tweets_model_weight_fav': 0.5,
'scored_tweets_model_weight_retweet': 1.0,
'scored_tweets_model_weight_reply': 13.5,
'scored_tweets_model_weight_good_profile_click': 12.0,
'scored_tweets_model_weight_video_playback50': 0.005,
'scored_tweets_model_weight_reply_engaged_by_author': 75.0,
'scored_tweets_model_weight_good_click': 11.0,
'scored_tweets_model_weight_good_click_v2': 10.0,
'scored_tweets_model_weight_negative_feedback_v2': -74.0,
'scored_tweets_model_weight_report': -369.0
}
base_score = sum(weights.get(key, 0.0) * prob for key, prob in probs.items())
# Fibonacci enhancement
quality_level = int(quality_score(post))
adjusted_level = adjust_fib_level_with_rms(post, quality_level)
fakeness_level = int(fakeness_score(post))
penalty = 0.01 if fakeness_level > 8 else 1.0 / (fibonacci(fakeness_level) + 1)
penalty_reduction, monetization_boost = big_account_privileges(post)
penalty *= penalty_reduction
spark = 1 if random.random() < 0.002 and post['author_followers'] < 100_000 else 0 # 0.2% Spark
adjusted_level += spark
if post['author_followers'] > 100_000: # Big: Volatile
boost = min(fibonacci(adjusted_level) / 5.0 * monetization_boost, 2.0)
volatility = max(0.7, 1.0 - 0.1 * (10 - quality_level))
boost *= volatility
elif 1000 <= post['author_followers'] <= 100_000: # Median: Stable
boost = min(fibonacci(adjusted_level) / 5.0 * 1.1, 2.0)
else: # Small: Amplified
boost = min(fibonacci(adjusted_level) / 5.0, 2.5)
final_score = base_score * boost * penalty
explanation = {
'base_score': round(base_score, 2),
'quality_level': adjusted_level,
'boost': f'Fib({adjusted_level})={boost:.2f}x{" +Spark! Your post got a discovery boost!" if spark else ""}',
'penalty': f'1/(Fib({fakeness_level})+1)={penalty:.2f}x{" +Cutoff! Suspected bot activity reduced ranking." if fakeness_level > 8 else ""}',
'account_tier': 'big' if post['author_followers'] > 100_000 else 'median' if post['author_followers'] >= 1000 else 'small',
'privileges': f'Penalty reduction: {penalty_reduction}x, Day-off boost: {monetization_boost}x' if post['author_followers'] > 100_000 else 'None',
'rms_pred': f'RMS={rms_engagement(post):.2f}, Threshold={post.get("author_rms_threshold", 50.0):.2f}',
'anti_bot_note': f'Fakeness={fakeness_level}; Signals: velocity, diversity, age, reply variance',
'user_message': 'Great replies boosted your post!' if quality_level > 5 else 'Post more positive content or thoughtful replies to boost your rank!'
}
return final_score, explanation
# Simulation for testers
if __name__ == "__main__":
small_post = {
'text': 'Grateful for this community! 🌟',
'likes': 20,
'replies': [{'text': 'Love this positivity! Keep spreading joy! (20 words)'}],
'author_followers': 500,
'age_hours': 2,
'likes_first_hour': 15,
'replies_first_hour': 1,
'author_avg_likes': 5,
'author_avg_replies': 1,
'author_rms_threshold': 10.0,
'author_created_at': datetime.now() - timedelta(days=30)
}
small_probs = {
'scored_tweets_model_weight_fav': 0.8,
'scored_tweets_model_weight_reply': 0.3,
'scored_tweets_model_weight_negative_feedback_v2': 0.1
}
score1, expl1 = heavy_ranker_score(small_post, small_probs)
print(f"Small Post Score: {score1:.2f}, Explanation: {expl1}")
big_fake_post = {
'text': 'Buy now!',
'likes': 1000,
'replies': [{'text': 'Yes!'}] * 5,
'author_followers': 200_000,
'age_hours': 1,
'author_daily_active_hours': 3.0,
'author_created_at': datetime.now() - timedelta(days=5),
'author_day_off_count': 0,
'is_day_off_post': False,
'likes_first_hour': 800,
'author_avg_likes': 200,
'author_avg_replies': 10,
'author_rms_threshold': 300.0
}
big_fake_probs = {
'scored_tweets_model_weight_fav': 0.9,
'scored_tweets_model_weight_negative_feedback_v2': 0.2
}
score2, expl2 = heavy_ranker_score(big_fake_post, big_fake_probs)
print(f"Big Fake Post Score: {score2:.2f}, Explanation: {expl2}")
big_dayoff_post = {
'text': 'Surprise post! Loving the vibes today! 😊',
'likes': 300,
'replies': [{'text': 'Great to see you back! (12 words)'}],
'author_followers': 150_000,
'age_hours': 1,
'author_daily_active_hours': 2.0,
'author_created_at': datetime.now() - timedelta(days=200),
'author_day_off_count': 5,
'is_day_off_post': True,
'likes_first_hour': 200,
'author_avg_likes': 150,
'author_avg_replies': 5,
'author_rms_threshold': 200.0
}
big_dayoff_probs = {
'scored_tweets_model_weight_fav': 0.7,
'scored_tweets_model_weight_reply': 0.4,
'scored_tweets_model_weight_negative_feedback_v2': 0.05
}
score3, expl3 = heavy_ranker_score(big_dayoff_post, big_dayoff_probs)
print(f"Big Day-Off Post Score: {score3:.2f}, Explanation: {expl3}")
median_post = {
'text': 'Sharing some cool ideas today! 🚀',
'likes': 50,
'replies': [{'text': 'This is inspiring! Let’s discuss more! (18 words)'}],
'author_followers': 5000,
'age_hours': 1.5,
'likes_first_hour': 30,
'replies_first_hour': 1,
'author_avg_likes': 20,
'author_avg_replies': 2,
'author_rms_threshold': 25.0,
'author_created_at': datetime.now() - timedelta(days=90)
}
median_probs = {
'scored_tweets_model_weight_fav': 0.6,
'scored_tweets_model_weight_reply': 0.2,
'scored_tweets_model_weight_negative_feedback_v2': 0.05
}
score4, expl4 = heavy_ranker_score(median_post, median_probs)
print(f"Median Post Score: {score4:.2f}, Explanation: {expl4}")
Metadata
Metadata
Assignees
Labels
No labels