Communitygithub.com

レコメンドシステムパイプラインアーキテクト

xAIが広めた6段階フレームワーク(Source→Hydrator→Filter→Scorer→Selector→SideEffect)を使って、構成可能なレコメンデーション、ランキング、フィードパイプラインを設計するスキルです。

レコメンドシステムパイプラインアーキテクト とは?

このスキルは、レコメンデーションシステムやフィードアルゴリズムを構築するための、6段階のパイプライン設計パターンを提供します。xAIがオープンソース化した「For You」アルゴリズムで有名になったSource→Hydrator→Filter→Scorer→Selector→SideEffectの順序を厳密に守り、効率的で拡張性の高いパイプラインを設計できます。ユーザーはスコアリング関数を用意するだけで、多様なアクション予測や重み調整が可能なパイプラインを、TypeScript、Go、Pythonなどのスタックで素早くスキャフォールディングできます。このスキルは実際に動作するコードを生成し、ベンチマーク数値の捏造や商標の不適切な使用を禁止するなど、厳格なルールに従います。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/recsys-pipeline-architect

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

レコメンドシステムパイプラインアーキテクト は何をしますか?

構成可能なレコメンデーション、ランキング、フィードパイプラインを構築するための仕様・スキャフォールディングスキルです。xAIがオープンソース化したFor You アルゴリズム(Apache 2.0)で広まった6段階パターン — Source → Hydrator → Filter → Scorer → Selector → SideEffect をエンコードしています。このスキルはパターンの独立した再実装(MIT)であり、オリジナルのコードは一切コピーしていません。

上流: https://github.com/mturac/recsys-pipeline-architect

使用するタイミング

  • ユーザーが「ユーザー/コンテキストに最適な上位Kアイテム」を選択するシステムを構築したい場合
  • ユーザーが「Xをどのようにランキングすべきか」と質問したり、フィード/パーソナライゼーションの問題を説明した場合
  • ユーザーがスコアリング関数を持っており、その周辺のパイプライン基盤が必要な場合
  • 単一の関連性スコアから、調整可能な重みを持つマルチアクション予測に移行したい場合
  • LLM/MLスコアラーをラップし、フィルター、ハイドレーター、副作用、実行可能なスキャフォールドをスタック(TypeScript / Go / Python)に追加したい場合
  • トリガーとなるキーワード: 「レコメンデーションシステム」、「フィードアルゴリズム」、「ランキングパイプライン」、「おすすめフィード」、「候補パイプライン」、「コンテンツレコメンダー」、「recsys向けパイプラインアーキテクチャ」、「RAG検索リランカー」

使用すべきでないタイミング

  • モデルアーキテクチャの作業(トランスフォーマー設計、2タワー検索、埋め込み学習) — このスキルはモデルに関するパイプライン基盤であり、モデルそのものではありません
  • 純粋なMLトレーニングパイプライン — スコアリング関数はユーザーの責任です
  • デプロイ済みパイプラインの運用(モニタリング、オートスケーリング) — 範囲外

6段階フレームワーク

#段階役割並列実行可能?
1Source1つ以上の起点から候補を取得はい — 複数のSourceを並列実行
2Hydrator各候補をフィルタリングとスコアリングに必要なメタデータで補完はい — 独立したハイドレーターを並列実行
3Filter表示してはいけない候補(ブロック済み、期限切れ、重複、不適格)を削除順次 — 各フィルターは項目数が減った状態で動作
4Scorer生き残った各候補に1つ以上のスコアを割り当て順次 — 後続のスコアラーは以前のスコアを参照可能
5Selector最終スコアでソートし、上位Kを返す単一操作
6SideEffect配信済みIDをキャッシュ、インプレッションをログ、イベントを発行、カウンターを更新非同期 — レスポンスをブロックしてはならない

この順序の理由

  • Sourceの前にHydrationを実行しない: 候補が存在することを確認してから、それらを補完するコストを払う
  • Filterの前にHydrationを実行する: 多くのフィルターはSourceが提供しなかったメタデータを必要とする
  • Scorerの前にFilterを実行する: スコアリングは高コストな段階。まず不適格なものを削除する
  • チェーン状のScorer(単一ではない): 実際のシステムはMLスコアリング + 多様性リランキング + ビジネスルールを組み合わせる
  • Scorerの後にSelectorを配置する: スコアリングを決定論的かつキャッシュ可能に保つ
  • SideEffectは最後かつ非同期: 副作用は決してユーザーレスポンスをブロックしてはならない

呼び出し時のワークフロー

次の8ステップでユーザーをガイドします:

  1. ユースケースの明確化(1ラウンド、3つの質問): ランキング対象のアイテムは? 入力コンテキストは? 言語/ランタイムは?
  2. 候補Sourceの特定: 通常はネットワーク内(フォロー/所有/購読) + ネットワーク外(ML検索 / トレンド / 類似お気に入り)
  3. 必要なHydrationをリストアップ: 各フィルターとスコアラーについて、Sourceが提供しなかったデータは何か?
  4. フィルターをリストアップ: 重複、自分自身、経過時間、ブロック/ミュート、過去配信済み、適格性。安価なものから高価なものへ順序付け。
  5. スコアラーチェーンを設計: 一次(ML)→ 結合器(マルチアクションと重み)→ 多様性 → ビジネスルール
  6. Selector: 最終スコアで降順ソート、上位Kを取得(ネットワーク内/外で層別混合も可)
  7. SideEffect: 配信済みIDをキャッシュ、インプレッションイベントを発行、カウンターを更新、分析ログ — すべてfire-and-forget
  8. ユーザーのスタックにスキャフォールドを生成

提示すべき主要なトレードオフ(暗黙のデフォルトにしない)

1. 単一スコア vs マルチアクション予測

  • 単一スコア: 1つのモデルで関連性を予測。動作を変更するには → 再トレーニング。
  • マルチアクション: 複数のアクション(読む、いいね、シェア、スキップ、報告)に対してP(アクション)を予測し、サービング時に重みを組み合わせる。動作を変更するには → 重みを変更。再トレーニング不要。

X For Youシステムは、正と負の両方の重みを持つマルチアクションを使用。ユーザーが頻繁にチューニングする場合はマルチアクションを推奨。

2. スコアリングにおける候補の独立性

  • 独立: 各候補を独立してスコアリング。決定論的、キャッシュ可能。
  • 共同: スコアリング中に候補同士が相互作用(例: バッチ全体に対するトランスフォーマー)。より表現力豊かだが、バッチ間で非決定論的。

デフォルトは独立。特定の理由(例: 明示的なバッチ認識多様性)がある場合のみ共同を選択。

3. オンライン vs オフライン

  • リクエスト時(オンライン): 各リクエストでパイプラインを実行。レイテンシ予算: 100~300ms。デフォルト。
  • 事前計算(オフラインバッチ): パイプラインを定期的に実行し、結果をキャッシュ。より低レイテンシ、より低い鮮度。
  • ハイブリッド: 候補検索はオフライン、ランキングはオンライン。

厳格なルール

  1. ベンチマーク数値を捏造しない。 「どれくらい速いか?」 → 「ワークロードに依存するので、自分で実行してください。」
  2. 帰属の規律を守る。 パターンを参照する場合、「xAIのオープンソースFor Youアルゴリズムによって広められた」 / github.com/xai-org/x-algorithm(Apache 2.0)として帰属させる。
  3. 商標を使用しない。 ユーザーの成果物を「Xライク」と命名したり、「For You」ブランディングを使用しない。パターンは自由だが、ブランドはそうではない。推奨命名: 「候補パイプライン」、「フィードパイプライン」、「ランキングパイプライン」、「recsysパイプライン」。
  4. トレードオフを明示する。 マルチアクション vs 単一、独立 vs 共同、オンライン vs オフライン — 暗黙のデフォルトにしない。
  5. 生成されたスキャフォールドは実行可能でなければならない。 疑似コードをコードとして渡さない。
  6. フィルターの順序は重要。 安価なものを高価なものより前に。普遍的なものをユーザー固有のものより前に。
  7. 副作用は決してブロックしない。 ファイアアンドフォーゲットパターン(goroutine / promise awaitなし / asyncioタスク)でラップする。

アンチパターン

  • フィルタリングの前にスコアリング(削除される候補に計算リソースを浪費)
  • 同期的な副作用(キャッシュ書き込み / インプレッション発行がレスポンスをブロック)
  • 製品が複数の目的(エンゲージメント vs 安全性 vs 多様性 vs 広告)に対してチューニングする必要がある場合に、単一の「関連性」スコアを使用
  • デフォルトでの共同スコアリング(非決定論的、キャッシュが困難、リランキング段階と組み合わせにくい)
  • 「説明用」の疑似コードを生成 — スキャフォールドは実際に実行可能でなければならない

上流リポジトリの内容

上流リポジトリ https://github.com/mturac/recsys-pipeline-architect には以下が含まれます:

  • 完全な8ステップワークフローを備えた完全な SKILL.md
  • 5つのオンデマンドロード可能なリファレンスドキュメント: 4言語(TS/Go/Python/Rust)のインターフェース、マルチアクションスコアリングパターン、候補独立性、フィルタークックブック(12パターン)、スコアラークックブック(加重和、MMR、多様性ペナルティ、位置バイアス補正)
  • 3つの実行可能なサンプルスキャフォールド、すべてテストスイートでパス:
    • Strapi v5プラグイン(TypeScript / Jest — 3/3 パス)
    • Zentra互換パイプライン(Go with ジェネリクス — 3/3 パス)
    • PMAIタスク優先順位付けツール(Python / FastAPI / pytest — 3/3 パス)
  • v0.1.0 リリースタグ
  • MITライセンス; パターンはxAI X For Youアルゴリズム(Apache 2.0)に帰属

skills.shでインストール: npx skills add mturac/recsys-pipeline-architect

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

関連スキル