fromanthropicimportAnthropicclient=Anthropic()defllm_rerank(user_history,candidates):msg=client.messages.create(model="claude-opus-4-7",max_tokens=500,messages=[{"role":"user","content":f"""
User watched: {user_history}Rerank these candidates by relevance, return top-10 IDs only as JSON array:
{candidates}"""}],)returnparse_json(msg.content[0].text)
기본값: 매 industrial 의 two-tower retrieval + DCN/DIN ranking + business-rule rerank, 매 ANN (FAISS / ScaNN), 매 implicit feedback + sampled softmax. 매 LLM-as-reranker 의 emerging 2026 pattern for top-K refinement.
언제: cold-start (zero-shot recommendation from item description), reranker on top-100, explanation generation, semantic ID encoding.
언제 X: full-funnel retrieval at scale (latency / cost prohibitive). 매 LLM 의 reranker only, 매 retrieval 의 ANN.
❌ 안티패턴
Random negative sampling only: easy negatives, model 의 saturate — use hard negatives + in-batch negatives.
Train on biased logged data: position bias / popularity bias not corrected → IPS / counterfactual.
Offline metric chasing: NDCG up but online CTR flat — online A/B 의 truth.
Cold-start ignore: pure CF 의 fail on new items — hybrid fallback.