Communitygithub.com

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

xAI によって広められた Source→Hydrator→Filter→Scorer→Selector→SideEffect の6段階フレームワークを使用して、構成可能なレコメンデーション、ランキング、フィードパイプラインを設計します。

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

このスキルは、コンポーザブルなレコメンデーション、ランキング、フィードパイプラインを構築するための、仕様定義とスキャフォールディングを提供します。核となるのは、xAI のオープンソース「For You」アルゴリズム(Apache 2.0)で広められた6段階パターン(Source→Hydrator→Filter→Scorer→Selector→SideEffect)です。このスキルはそのパターンを独立して再実装したもの(MITライセンス)であり、元のコードをコピーしたものではありません。レコメンデーションシステム、フィードアルゴリズム、ランキングパイプライン、RAG検索リランカーなど、あらゆる「トップKアイテムの選択」問題に適用できます。ワークフローは8つのステップからなり、ユースケースの明確化から始まり、最終的にはTypeScript、Go、Pythonなどのユーザーのスタックに応じた実行可能なスキャフォールドを生成します。単一スコアと複数アクション予測の比較、候補の分離評価、オンライン/オフライン処理といった重要なトレードオフを表面化し、単独のスキルとして機能します。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/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)で実行可能なスキャフォールドを必要としている場合
  • トリガーとなるキーワード: 「レコメンデーションシステム」「フィードアルゴリズム」「ランキングパイプライン」「おすすめフィード」「候補パイプライン」「コンテンツレコメンダー」「レコメンドシステムのパイプラインアーキテクチャ」「RAG検索リランカー」

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

  • モデルアーキテクチャの作業(トランスフォーマー設計、ツータワー検索、埋め込み学習) — このスキルはモデルそのものではなく、モデル周りの基盤を提供します
  • 純粋なMLトレーニングパイプライン — スコアリング関数はユーザーの責任です
  • デプロイされたパイプラインの運用(監視、自動スケーリング) — 対象外

6段階フレームワーク

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

この順序が重要な理由

  • Source は Hydration の前: 候補を強化するコストを払う前に、どの候補が存在するかを把握するため
  • Hydration は Filter の前: 多くのフィルターはソースが提供しなかったメタデータを必要とするため
  • Filter は Scoring の前: スコアリングは高コストな段階です。先に不適格なものを除外します
  • Scorer チェーン(単一スコアラーではない): 実際のシステムでは、MLスコアリング + 多様性リランキング + ビジネスルールを組み合わせます
  • Selector は Scoring の後: スコアリングを決定論的かつキャッシュ可能に保ちます
  • SideEffect は最後かつ非同期: サイドエフェクトがユーザーのレスポンスをブロックしてはなりません

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

以下の8つのステップをユーザーと一緒に進めます:

  1. ユースケースを明確化(1ラウンド、3つの質問): ランキング対象のアイテムは? 入力コンテキストは? 言語/ランタイムは?
  2. 候補ソースを特定: 通常はネットワーク内(フォロー/所有/購読)+ ネットワーク外(ML検索/トレンド/「いいね」したものと類似)
  3. 必要なハイドレーションをリストアップ: 各フィルターとスコアラーについて、ソースが提供しなかったデータは何か?
  4. フィルターをリストアップ: 重複、自分自身、経過時間、ブロック/ミュート、過去配信済み、適合性。順序が重要 — 安価なものを先に、高価なものを後に。
  5. スコアラーチェーンを設計: 一次(ML)→ 結合器(重み付き複数アクション)→ 多様性 → ビジネスルール
  6. セレクター: 最終スコアで降順ソートし、トップKを取得(またはネットワーク内/ネットワーク外の層別ミックス)
  7. サイドエフェクト: 配信済み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-like」や「For You」ブランドで命名しないでください。パターンは自由ですが、ブランドはそうではありません。推奨される命名: 「候補パイプライン」「フィードパイプライン」「ランキングパイプライン」「レコメンドパイプライン」。
  4. トレードオフを表面化すること。 複数アクション vs 単一、分離 vs 結合、オンライン vs オフライン — 決して暗黙のデフォルトにしないこと。
  5. 生成されたスキャフォールドは実行可能でなければならない。 擬似コードをコードとして渡さないこと。
  6. フィルターの順序は重要。 安価なものを先に、高価なものを後に。普遍的なものをユーザー固有のものより先に。
  7. サイドエフェクトはブロックしてはならない。 fire-and-forget パターンでラップすること(goroutine / await なしの Promise / 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 — 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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

関連スキル