이전 페이지에서는 소프트맥스 레이어를 심층 레이어에 통합하는 방법을 설명했습니다.
신경망 네트워크입니다. 이 페이지에서는
사용할 수 있습니다.
학습 데이터
소프트맥스 학습 데이터는 쿼리 특성 \(x\) 및
사용자가 상호작용한 항목으로 구성된 벡터(
확률 분포 \(p\)). 이러한 테스트는
다음 그림 모델의 변수는 모델이 학습한
서로 다른 레이어에 있습니다 다음에서 주황색으로 표시되어 있습니다.
있습니다. 모델은 일반적으로
확률적 경사하강법입니다.
네거티브 샘플링
손실 함수가 두 확률 벡터를 비교하므로
\(p, \hat p(x) \in \mathbb R^n\) (정답과
각각 모델의 출력을 계산하여
손실의 기울기 (단일 쿼리의 경우 \(x\))는
코퍼스 크기가 너무 크면 \(n\) 엄청나게 많은 비용이 듭니다.
양수 항목에 대해서만 경사를 계산하도록 시스템을 설정할 수 있습니다.
(정답 벡터에서 활성 상태인 항목) 그러나 시스템에서
양성 쌍에서만 학습하므로 모델은 접히는 문제를 겪을 수 있습니다.
확인하시기 바랍니다.
접이식
다음 그림에서 각 색상이
검색어 및 항목 카테고리를 보여줍니다. 각 쿼리 (정사각형으로 표시)만
대부분 같은 색상의 항목 (원으로 표시됨)과 상호작용합니다.
예를 들어 YouTube에서는 카테고리마다 각기 다른 언어를 사용합니다.
일반적인 사용자는 대부분 특정 언어로 된 동영상과 상호작용합니다.
모델은 주어진 데이터의 쿼리/항목 임베딩을 배치하는 방법을
색깔이 서로 비교하여 색깔이 서로 어떻게 변하고 있는지를
색상)이지만 다른 색상의 임베딩이 동일한 영역에 위치할 수 있습니다.
큰 영향을 줄 수 있습니다. 이 현상은 광섬유에서
폴딩으로 표시하는 경우, 쿼리 시점에 잘못된 추천으로 이어질 수 있습니다.
모델이 한 항목의 최고 점수를 잘못 예측했을 때
확인할 수 있습니다
제외 예는 '관련성 없음' 라벨이 지정된 항목입니다. 할 수 있습니다.
학습 중에 모델 음성 예시를 보여주면
서로 다른 그룹의 임베딩은 서로 푸시되어야 합니다.
모든 항목을 사용하여 경사를 계산하는 대신
긍정적인 항목만 사용하기 때문에 (모델이 특정 예측을 할 가능성이 낮기 때문에)
네거티브 샘플링을 사용할 수 있습니다. 더 정확히 말하면 여러분은
다음 항목을 사용한 근사치 경사
모든 포함 항목 (타겟 라벨에 표시되는 항목)
제외 항목 샘플 ( \({1, …, n}\)의\(j\) )
제외 항목을 샘플링하는 방법에는 여러 가지가 있습니다.
균일하게 샘플링할 수 있습니다.
이 값이 높은 항목 j에 더 높은 확률을 부여할 수 있습니다.
\(\psi(x) . V_j\)점 직관적으로 이러한 예는
경사에 가장 많이 기여하는 부분) 이러한 예는
하드 네거티브라고 합니다
행렬 분해와 소프트맥스 비교
DNN 모델은 행렬 분해의 많은 제한사항을 해결하지만 일반적으로
학습과 쿼리에 더 많은 비용이 듭니다 아래 표에는
중요한 차이점에 대해 알아보겠습니다.
행렬 분해
소프트맥스 DNN
쿼리 특성
포함하기 쉽지 않습니다.
포함될 수 있습니다.
콜드 스타트
어휘가 없는 상황을 쉽게 처리하지 못함
쿼리 또는 항목을 만들 수 있습니다 일부 휴리스틱을 사용할 수 있습니다 (예:
새 쿼리, 유사한 쿼리의 평균 임베딩).
새로운 쿼리를 손쉽게 처리합니다.
접이식
손쉽게 접기
이를 사용하여 WALS에서 관찰되지 않은 가중치를 조정할 수 있습니다.
접히기 쉽습니다. 사용해야 함
네거티브 샘플링 또는 중력과 같은 기법이 필요합니다.
학습 확장성
대규모로 쉽게 확장 가능
수억 개 이상의 항목을 포함할 수 있지만
희소 행렬입니다.
대규모로 확장하기 어려움
확인할 수 있습니다 해싱,
네거티브 샘플링 등
확장성 제공
임베딩 U, V는 정적이고
후보 세트를 미리 계산하여 저장할 수 있습니다.
항목 임베딩 V는 정적임
저장할 수 있습니다
쿼리 임베딩은 일반적으로
계산해야 하므로 모델을 학습하는 데
있습니다.
요약:
일반적으로 대규모 코퍼스에는 행렬 분해가 더 나은 선택입니다.
확장이 더 쉽고, 쿼리 비용이 저렴하며, 접히는 빈도가 낮습니다.
DNN 모델은 맞춤설정된 선호도를 더 잘 캡처할 수 있지만
쿼리하기가 더 어렵고 쿼리 비용이 더 많이 듭니다 DNN 모델이 권장됨
스코어링을 위한 행렬 분해까지, DNN 모델은
관련성을 더 잘 포착할 수 있습니다 또한 일반적으로
접히는 것에 대한 허용이 되는 경우도 있습니다.
관련이 있다고 가정하는 사전 필터링된 후보 세트의 순위를 매깁니다.
[null,null,["최종 업데이트: 2024-07-26(UTC)"],[[["\u003cp\u003eThis page focuses on the training data and process for a softmax deep neural network recommendation system.\u003c/p\u003e\n"],["\u003cp\u003eNegative sampling is crucial to avoid "folding," where embeddings from different categories are incorrectly grouped together.\u003c/p\u003e\n"],["\u003cp\u003eNegative sampling involves training the model on both positive (relevant) and negative (irrelevant) examples.\u003c/p\u003e\n"],["\u003cp\u003eCompared to Matrix Factorization, softmax DNNs are more flexible but computationally expensive and susceptible to folding.\u003c/p\u003e\n"],["\u003cp\u003eWhile Matrix Factorization is better for large-scale applications, DNNs excel at capturing personalized preferences for recommendation tasks.\u003c/p\u003e\n"]]],[],null,["# Softmax training\n\nThe previous page explained how to incorporate a softmax layer into a deep\nneural network for a recommendation system. This page takes a closer look at the\ntraining data for this system.\n\nTraining data\n-------------\n\nThe softmax training data consists of the query features \\\\(x\\\\) and\na vector of items the user interacted with (represented as a\nprobability distribution \\\\(p\\\\)). These are marked in blue in\nthe following figure. The variables of the model are the weights\nin the different layers. These are marked as orange in the following\nfigure. The model is typically trained using any variant of\nstochastic gradient descent.\n\n### Negative sampling\n\nSince the loss function compares two probability vectors\n\\\\(p, \\\\hat p(x) \\\\in \\\\mathbb R\\^n\\\\) (the ground truth and\nthe output of the model, respectively), computing the\ngradient of the loss (for a single query \\\\(x\\\\)) can be\nprohibitively expensive if the corpus size \\\\(n\\\\) is too big.\n\nYou could set up a system to compute gradients only on the positive items\n(items that are active in the ground truth vector). However, if the system\nonly trains on positive pairs, the model may suffer from folding, as\nexplained below. \nFolding \nIn the following figure, assume that each color represents a different category of queries and items. Each query (represented as a square) only mostly interacts with the items (represented as a circle) of the same color. For example, consider each category to be a different language in YouTube. A typical user will mostly interact with videos of one given language.\n\nThe model may learn how to place the query/item embeddings of a given\ncolor relative to each other (correctly capturing similarity within that\ncolor), but embeddings from different colors may end up in the same region\nof the embedding space, by chance. This phenomenon, known\nas **folding**, can lead to spurious recommendations: at query time,\nthe model may incorrectly predict a high score for an item from a\ndifferent group.\n\n**Negative examples** are items labeled \"irrelevant\" to a given query.\nShowing the model negative examples during training teaches the model that\nembeddings of different groups should be pushed away from each other.\n\nInstead of using all items to compute the gradient (which can be too\nexpensive) or using only positive items (which makes the model prone to\nfolding), you can use negative sampling. More precisely, you compute an\napproximate gradient, using the following items:\n\n- All positive items (the ones that appear in the target label)\n- A sample of negative items (\\\\(j\\\\) in \\\\({1, ..., n}\\\\))\n\nThere are different strategies for sampling negatives:\n\n- You can sample uniformly.\n- You can give higher probability to items j with higher score \\\\(\\\\psi(x) . V_j\\\\). Intuitively, these are examples that contribute the most to the gradient); these examples are often called hard negatives.\n\n| **Extra resources:**\n|\n| - For a more comprehensive account of the technology, architecture, and models used in YouTube, see [Deep Neural Networks\n| for YouTube Recommendations](https://research.google.com/pubs/pub45530.html).\n| - See [Xin et al., Folding:\n| Why Good Models Sometimes Make Spurious Recommendations](https://dl.acm.org/citation.cfm?id=3109911) for more details on folding.\n| - To learn more about negative sampling, see [Bengio and Senecal,\n| Adaptive Importance Sampling to Accelerate Training of a Neural\n| Probabilistic Language Model.](https://ieeexplore.ieee.org/document/4443871/)\n\nOn matrix factorization versus softmax\n--------------------------------------\n\nDNN models solve many limitations of Matrix Factorization, but are typically\nmore expensive to train and query. The table below summarizes some of the\nimportant differences between the two models.\n\n| | Matrix Factorization | Softmax DNN |\n|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Query features | Not easy to include. | Can be included. |\n| Cold start | Does not easily handle out-of vocab queries or items. Some heuristics can be used (for example, for a new query, average embeddings of similar queries). | Easily handles new queries. |\n| Folding | Folding can be easily reduced by adjusting the unobserved weight in WALS. | Prone to folding. Need to use techniques such as negative sampling or gravity. |\n| Training scalability | Easily scalable to very large corpora (perhaps hundreds of millions items or more), but only if the input matrix is sparse. | Harder to scale to very large corpora. Some techniques can be used, such as hashing, negative sampling, etc. |\n| Serving scalability | Embeddings U, V are static, and a set of candidates can be pre-computed and stored. | Item embeddings V are static and can be stored. The query embedding usually needs to be computed at query time, making the model more expensive to serve. |\n\nIn summary:\n\n- Matrix factorization is usually the better choice for large corpora. It is easier to scale, cheaper to query, and less prone to folding.\n- DNN models can better capture personalized preferences, but are harder to train and more expensive to query. DNN models are preferable to matrix factorization for scoring because DNN models can use more features to better capture relevance. Also, it is usually acceptable for DNN models to fold, since you mostly care about ranking a pre-filtered set of candidates assumed to be relevant."]]