【おたのしみ】タグ予測 #65

オープン
みてるぞが2025-06-29 02:52:55 +09:00に作成 · 8件のコメント
オーナー

cos 類似度によるタグ推薦機能.
あんま要らない.

cos 類似度によるタグ推薦機能. あんま要らない.
みてるぞ が新しい依存関係を追加 2025-09-13 14:22:35 +09:00
みてるぞ がラベル
type
enhancement
P
3
status
blocked
を追加 2025-09-13 14:26:27 +09:00
みてるぞ がラベル
status
ready
を追加、
status
blocked
を除去 2026-01-12 14:51:36 +09:00
みてるぞ がラベル ai:effort:lowai:investigate を追加 2026-11-12 22:39:30 +09:00
共同作業者

Codex 調査完了(変更は一切行っていません)。新規提案: 2 件。

Codex 調査完了(変更は一切行っていません)。新規提案: 2 件。
テツノニジカ がラベル ai:investigate を除去 2026-11-12 22:41:56 +09:00
みてるぞ がラベル ai:investigate を追加 2026-11-20 00:42:01 +09:00
共同作業者

Codex 調査提案 P-0005 (未承認・コード変更なし)

Similarity refresh destroys the previous results before calculation succeeds

Evidence: backend/app/services/similarity/calc.rb:9 at f05d8a4b3a132216b900c2d4b69001211b23e381

Type: reliability
Certainty: confirmed

Reason: delete_all runs before loading associations and calculating similarities. Replacement rows are subsequently inserted in separate 1,000-row batches at lines 92–101, without a transaction or staging table.

Impact: A calculation failure leaves the table empty; an insertion failure leaves partial results. Concurrent runs can interleave deletion and insertion and encounter composite-primary-key conflicts.

Verification (NOT RUN): Not executed: In an isolated database with existing similarities, inject a failure before the first insert and another after the first batch. Inspect whether the original complete result set survives.

Proposed change (NOT IMPLEMENTED): Calculate replacement rows first, then serialize refreshes and atomically replace the table contents in a transaction.

※ 自動調査による候補です。現在のコードで再確認し、Issue 化・実装する場合は別途承認してください。

<!-- codex-proposal:5 --> **Codex 調査提案 P-0005** (未承認・コード変更なし) ### Similarity refresh destroys the previous results before calculation succeeds **Evidence**: `backend/app/services/similarity/calc.rb:9` at `f05d8a4b3a132216b900c2d4b69001211b23e381` **Type**: reliability **Certainty**: confirmed **Reason**: delete_all runs before loading associations and calculating similarities. Replacement rows are subsequently inserted in separate 1,000-row batches at lines 92–101, without a transaction or staging table. **Impact**: A calculation failure leaves the table empty; an insertion failure leaves partial results. Concurrent runs can interleave deletion and insertion and encounter composite-primary-key conflicts. **Verification (NOT RUN)**: Not executed: In an isolated database with existing similarities, inject a failure before the first insert and another after the first batch. Inspect whether the original complete result set survives. **Proposed change (NOT IMPLEMENTED)**: Calculate replacement rows first, then serialize refreshes and atomically replace the table contents in a transaction. ※ 自動調査による候補です。現在のコードで再確認し、Issue 化・実装する場合は別途承認してください。
共同作業者

Codex 調査提案 P-0006 (未承認・コード変更なし)

Top-20 storage does not bound the quadratic calculation

Evidence: backend/app/services/similarity/calc.rb:76 at f05d8a4b3a132216b900c2d4b69001211b23e381

Type: performance
Certainty: confirmed

Reason: The tag task passes every non-deprecated tag to this service. The nested loops visit every unordered tag pair, including pairs with no shared posts, and intersection_size scans their sorted post IDs. The 20-result limit only bounds retained results.

Impact: For T tags, each scheduled refresh evaluates T(T−1)/2 pairs. Large tag catalogs and popular tags can make the daily job expensive despite the small output per tag.

Verification (NOT RUN): Not executed: Profile isolated datasets with increasing tag counts and sparse co-occurrence. Compare pair counts and elapsed time when doubling the tag population.

Proposed change (NOT IMPLEMENTED): Accumulate intersections through a post-to-tags inverted index and calculate cosine scores only for pairs sharing a post; explicitly define whether zero-score fallback results are needed.

※ 自動調査による候補です。現在のコードで再確認し、Issue 化・実装する場合は別途承認してください。

<!-- codex-proposal:6 --> **Codex 調査提案 P-0006** (未承認・コード変更なし) ### Top-20 storage does not bound the quadratic calculation **Evidence**: `backend/app/services/similarity/calc.rb:76` at `f05d8a4b3a132216b900c2d4b69001211b23e381` **Type**: performance **Certainty**: confirmed **Reason**: The tag task passes every non-deprecated tag to this service. The nested loops visit every unordered tag pair, including pairs with no shared posts, and intersection_size scans their sorted post IDs. The 20-result limit only bounds retained results. **Impact**: For T tags, each scheduled refresh evaluates T(T−1)/2 pairs. Large tag catalogs and popular tags can make the daily job expensive despite the small output per tag. **Verification (NOT RUN)**: Not executed: Profile isolated datasets with increasing tag counts and sparse co-occurrence. Compare pair counts and elapsed time when doubling the tag population. **Proposed change (NOT IMPLEMENTED)**: Accumulate intersections through a post-to-tags inverted index and calculate cosine scores only for pairs sharing a post; explicitly define whether zero-score fallback results are needed. ※ 自動調査による候補です。現在のコードで再確認し、Issue 化・実装する場合は別途承認してください。
共同作業者

Codex 調査提案 P-0019 (未承認・コード変更なし)

類似度テーブルの再生成が非原子的で、失敗時に既存結果を失う

Evidence: backend/app/services/similarity/calc.rb:9 at dda3d87073617bcb0993e22dfb693d4280530917

Type: reliability
Certainty: confirmed

Reason: 計算開始時に similarity_model.delete_all を実行し、その後に全組合せの計算と1,000行単位の insert_all! を行う。既存結果の削除から最後の挿入までを保護するトランザクションや一括切替処理はない。backend/lib/tasks/calc_tag_similarities.rake もこの処理を直接呼ぶ。

Impact: 計算中は結果が空になり、途中の例外やプロセス停止では空または部分的な結果が残る。並行実行では複合主キーの重複による挿入失敗も起こり得る。

Verification (NOT RUN): 未実行。隔離環境で既存の類似度行を用意し、最初の挿入時に例外を発生させて、既存結果が保持されるか確認する。別途、2つの計算処理を同時に開始して競合を確認する。

Proposed change (NOT IMPLEMENTED): 計算完了後に、排他制御した短いトランザクション内で削除と全結果の挿入を行う。

※ 自動調査による候補です。現在のコードで再確認し、Issue 化・実装する場合は別途承認してください。

<!-- codex-proposal:19 --> **Codex 調査提案 P-0019** (未承認・コード変更なし) ### 類似度テーブルの再生成が非原子的で、失敗時に既存結果を失う **Evidence**: `backend/app/services/similarity/calc.rb:9` at `dda3d87073617bcb0993e22dfb693d4280530917` **Type**: reliability **Certainty**: confirmed **Reason**: 計算開始時に similarity_model.delete_all を実行し、その後に全組合せの計算と1,000行単位の insert_all! を行う。既存結果の削除から最後の挿入までを保護するトランザクションや一括切替処理はない。backend/lib/tasks/calc_tag_similarities.rake もこの処理を直接呼ぶ。 **Impact**: 計算中は結果が空になり、途中の例外やプロセス停止では空または部分的な結果が残る。並行実行では複合主キーの重複による挿入失敗も起こり得る。 **Verification (NOT RUN)**: 未実行。隔離環境で既存の類似度行を用意し、最初の挿入時に例外を発生させて、既存結果が保持されるか確認する。別途、2つの計算処理を同時に開始して競合を確認する。 **Proposed change (NOT IMPLEMENTED)**: 計算完了後に、排他制御した短いトランザクション内で削除と全結果の挿入を行う。 ※ 自動調査による候補です。現在のコードで再確認し、Issue 化・実装する場合は別途承認してください。
共同作業者

Codex 調査提案 P-0020 (未承認・コード変更なし)

保存件数を20件に制限しても計算量は全タグ対の二乗になる

Evidence: backend/app/services/similarity/calc.rb:76 at dda3d87073617bcb0993e22dfb693d4280530917

Type: performance
Certainty: confirmed

Reason: ids の全ての組合せを二重ループで走査し、各対で投稿ID配列の積集合を計算する。上位20件への制限は計算後の push_topk にしか適用されず、共通投稿のないタグ対も計算する。タグ数Nに対してN(N−1)/2対を処理する。

Impact: タグ数の増加に伴い日次ジョブのCPU使用量と実行時間が急増する。10,000タグでは約5,000万対を評価し、各対で投稿配列を走査するため、保存行数が少なくても処理負荷は抑えられない。

Verification (NOT RUN): 未実行。隔離環境で投稿との関連数を一定に保ちながらタグ数を段階的に増やし、実行時間と評価対数を測定する。共起が疎なデータでも二乗で増えるか確認する。

Proposed change (NOT IMPLEMENTED): 投稿IDからタグIDへの転置索引で共起するタグ対だけの積集合件数を集計し、投稿件数による正規化後に上位20件を選ぶ。ゼロ類似度行が必要なら最後に補完する。

※ 自動調査による候補です。現在のコードで再確認し、Issue 化・実装する場合は別途承認してください。

<!-- codex-proposal:20 --> **Codex 調査提案 P-0020** (未承認・コード変更なし) ### 保存件数を20件に制限しても計算量は全タグ対の二乗になる **Evidence**: `backend/app/services/similarity/calc.rb:76` at `dda3d87073617bcb0993e22dfb693d4280530917` **Type**: performance **Certainty**: confirmed **Reason**: ids の全ての組合せを二重ループで走査し、各対で投稿ID配列の積集合を計算する。上位20件への制限は計算後の push_topk にしか適用されず、共通投稿のないタグ対も計算する。タグ数Nに対してN(N−1)/2対を処理する。 **Impact**: タグ数の増加に伴い日次ジョブのCPU使用量と実行時間が急増する。10,000タグでは約5,000万対を評価し、各対で投稿配列を走査するため、保存行数が少なくても処理負荷は抑えられない。 **Verification (NOT RUN)**: 未実行。隔離環境で投稿との関連数を一定に保ちながらタグ数を段階的に増やし、実行時間と評価対数を測定する。共起が疎なデータでも二乗で増えるか確認する。 **Proposed change (NOT IMPLEMENTED)**: 投稿IDからタグIDへの転置索引で共起するタグ対だけの積集合件数を集計し、投稿件数による正規化後に上位20件を選ぶ。ゼロ類似度行が必要なら最後に補完する。 ※ 自動調査による候補です。現在のコードで再確認し、Issue 化・実装する場合は別途承認してください。
テツノニジカ がラベル ai:investigate を除去 2026-11-20 00:51:51 +09:00
作成者
オーナー

あのさ,趣旨わかってる?

あのさ,趣旨わかってる?
みてるぞ がラベル ai:investigate を追加 2026-11-21 14:07:28 +09:00
共同作業者

Codex 調査完了(変更は一切行っていません)。新規提案: 0 件。
保存済みの提案があれば、既に投稿した提案本文を参照してください。

Codex 調査完了(変更は一切行っていません)。新規提案: 0 件。 保存済みの提案があれば、既に投稿した提案本文を参照してください。
テツノニジカ がラベル ai:investigate を除去 2026-11-21 14:09:42 +09:00
みてるぞ がラベル ai:investigate を追加 2026-11-21 18:32:26 +09:00
共同作業者

Codex 調査完了(変更は一切行っていません)。新規提案: 0 件。
保存済みの提案があれば、既に投稿した提案本文を参照してください。

Codex 調査完了(変更は一切行っていません)。新規提案: 0 件。 保存済みの提案があれば、既に投稿した提案本文を参照してください。
テツノニジカ がラベル ai:investigate を除去 2026-11-21 18:33:22 +09:00
サインインしてこの会話に参加。
2 人の参加者
通知
期日
期日は設定されていません。
依存先
#92 関聯タグ
miteruzo/btrc-hub
リファレンス: miteruzo/btrc-hub#65