دالة فقدان خالية من درجة الحرارة للتعلم التبايني Temperature-free loss function for contrastive learning

شارك:
المجلة: Neural Networks، المجلد: 204
DOI: https://doi.org/10.1016/j.neunet.2026.109222
PMID: https://pubmed.ncbi.nlm.nih.gov/42269189
تاريخ النشر: 2026-06-04
المؤلف: Bum Jun Kim وآخرون
الموضوع الرئيسي: تكييف المجال والتعلم من عدد قليل من الأمثلة

نظرة عامة

في هذا القسم، يناقش المؤلفون التقدم في التعلم التبايني، مع التركيز بشكل خاص على استخدام خسارة InfoNCE، التي كانت لها دور حاسم في تحقيق تقدم كبير في التعلم الذاتي. جانب حاسم من استخدام خسارة InfoNCE هو ضبط معامل درجة الحرارة، الذي يضبط درجات التشابه بين أزواج البيانات. ومع ذلك، فإن الحاجة إلى تجارب واسعة من التجريب والخطأ لتحديد درجة حرارة مثالية تطرح تحديات للتنفيذ العملي. للتخفيف من هذه المشكلة، يقترح المؤلفون نهجًا جديدًا يستبدل ضبط درجة الحرارة بدالة الظل العكسي، مما يؤدي إلى خسارة InfoNCE معدلة خالية من المعاملات.

تشير النتائج إلى أن ضبط درجة الحرارة التقليدي في خسارة InfoNCE يمكن أن يؤدي إلى آثار ضارة على الانحدار التدرجي، مما يخلق توازنًا بين الحفاظ على التدرجات النشطة عند نقاط غير مثالية وتحقيق التقارب عند النقاط المثالية. يتم تعقيد هذا التوازن أكثر بعوامل مثل عدد الأزواج المستخدمة في التدريب، مما يشير إلى أنه لا يوجد درجة حرارة قابلة للتطبيق عالميًا. لا يبسط الأسلوب المقترح نشر خسارة InfoNCE فحسب، بل يعزز أيضًا خصائصه النظرية، مما يؤدي إلى تحسين الأداء في التعلم التبايني عبر خمسة مجموعات بيانات مرجعية دون الحاجة إلى ضبط درجة الحرارة.

مقدمة

تناقش مقدمة ورقة البحث التقدم في التعلم العميق، وخاصة من خلال التعلم الذاتي، الذي يهدف إلى اشتقاق تمثيلات البيانات دون الاعتماد على مجموعات بيانات موسومة. يتم التركيز بشكل كبير على التعلم التبايني، الذي يستخدم درجات التشابه من وجهات نظر بيانات مختلفة لتعلم تمثيلات فعالة. يتم تسليط الضوء على خسارة InfoNCE، وهي نهج شائع في هذا السياق، لدورها في التمييز بين أزواج البيانات المتشابهة وغير المتشابهة. ومع ذلك، فإن أداء التعلم التبايني حساس لمعامل درجة الحرارة المستخدم في خسارة InfoNCE، حيث أفادت الدراسات الحالية بقيم مثالية متباينة، مما يؤدي إلى تحديات في ضبط المعاملات.

لمعالجة هذه التحديات، يقترح المؤلفون طريقة جديدة تقضي على الحاجة إلى ضبط درجة الحرارة في خسارة InfoNCE من خلال استبدال تقسيم درجة الحرارة بخريطة احتمالات مقاسة. لا يبسط هذا النهج عملية التدريب من خلال إزالة البحث الواسع عن قيم درجة الحرارة المثالية فحسب، بل يعزز أيضًا الأداء من خلال التخفيف من المشكلات المتعلقة بتلاشي التدرجات أثناء التحسين. تؤكد الورقة أن طريقتهم تحقق نتائج مماثلة أو متفوقة على الأساليب التقليدية المعتمدة على درجة الحرارة، كما يتضح من خلال التجارب الشاملة.

النتائج

في هذا القسم، يقدم المؤلفون نتائج إضافية من تجاربهم على معالجة اللغة الطبيعية وأنظمة التوصية التسلسلية، باستخدام MABEL (He et al., 2022) و DCRec (Yang et al., 2023)، على التوالي. تم إجراء التجارب باستخدام مجموعات بيانات StereoSet (Nadeem et al., 2021)، و CrowS-Pairs (Nangia et al., 2020)، و MovieLens-20M (Harper & Konstan, 2016). بالنسبة لـ MABEL، تضمنت معلمات التدريب 2 عصر، ومعدل تعلم قدره $5 \times 10^{-5}$، وحجم دفعة صغيرة قدره 16، ودقة FP16، وأقصى طول تسلسل قدره 128، ودرجة حرارة قدرها 0.05. بالمقابل، تم تدريب DCRec بحجم دفعة صغيرة قدره 512، واحتمالية تسرب قدرها 0.5، وحجم تفاعل أعلى قدره 4، ووزن توافق متوسط قدره 0.4، ومعاملات لخسارة التباين وتباين KL تم تعيينها عند 0.1 و 0.01، على التوالي، مع درجة حرارة قدرها 0.8.

تشير النتائج، الملخصة في الجداول 5 و 6، إلى أن الأساليب المقترحة تتفوق باستمرار على الخط الأساسي، الذي يتم تعريفه من خلال أداء تقسيم درجة الحرارة باستخدام قيم درجة الحرارة المبلغ عنها. تشمل النتائج المبلغ عنها مقاييس أداء متوسطة والانحرافات المعيارية المستمدة من عشرة تجارب مع بذور عشوائية متباينة، مما يبرز قوة الأساليب المقترحة في تعزيز أداء النموذج عبر المهام التي تم تقييمها.

المناقشة

في هذا القسم، يقوم المؤلفون بتقييم نقدي للتحديات المرتبطة بنظام تقسيم درجة الحرارة في خسارة InfoNCE للتعلم التبايني. يبرزون أن اختيار قيمة درجة حرارة مناسبة، يشار إليها بـ $\tau$، أمر حاسم لتحسين الأداء ولكنه غالبًا ما يتطلب ضبطًا واسعًا للمعاملات. لا تزال الأساليب السابقة، مثل درجات الحرارة المزدوجة والاستراتيجيات التكيفية، تتطلب تعديلات يدوية ويمكن أن تعقد عملية التحسين. يجادل المؤلفون بأن تقسيم درجة الحرارة لا يفرض فقط حدودًا تمثيلية على القيم المدخلة في دالة softmax، بل يؤدي أيضًا إلى مشكلات مثل تلاشي التدرجات، خاصة عند النقاط المثالية، مما يمكن أن يعيق التقارب أثناء التدريب.

لمعالجة هذه القيود، يقترح المؤلفون طريقة جديدة تستبدل تقسيم درجة الحرارة بخريطة تشابهات جيب التمام باستخدام دالة الاحتمالات، على وجه التحديد $logit(p) = \log\left(\frac{p}{1-p}\right)$، حيث يتم اشتقاق $p$ من تشابه جيب التمام. يضمن هذا النهج بقاء التدرجات نشطة أثناء التدريب مع تحقيق تدرجات صفرية فقط عند النقطة المثالية، مما يعزز عملية تحسين الانحدار التدرجي. يتم إثبات أن الطريقة المقترحة خالية من المعاملات وسهلة الدمج في الأطر الحالية، مع إظهار النتائج التجريبية تحسين الأداء عبر مهام متنوعة، بما في ذلك تصنيف الصور واكتشاف الشذوذ، مقارنة بالأساليب التقليدية المعتمدة على درجة الحرارة.

Journal: Neural Networks, Volume: 204
DOI: https://doi.org/10.1016/j.neunet.2026.109222
PMID: https://pubmed.ncbi.nlm.nih.gov/42269189
Publication Date: 2026-06-04
Author(s): Bum Jun Kim et al.
Primary Topic: Domain Adaptation and Few-Shot Learning

Overview

In this section, the authors discuss advancements in contrastive learning, particularly focusing on the use of InfoNCE loss, which has been instrumental in achieving significant progress in self-supervised learning. A critical aspect of employing InfoNCE loss is the tuning of a temperature hyperparameter, which calibrates similarity scores between data pairs. However, the necessity for extensive trial-and-error experiments to identify an optimal temperature poses challenges for practical implementation. To mitigate this issue, the authors propose a novel approach that substitutes temperature scaling with the inverse hyperbolic tangent function, resulting in a modified InfoNCE loss that is hyperparameter-free.

The findings indicate that the traditional temperature scaling in InfoNCE loss can lead to detrimental effects on gradient descent, creating a trade-off between maintaining active gradients at suboptimal points and achieving convergence at optimal points. This trade-off is further complicated by factors such as the number of pairs used in training, suggesting that a universally applicable temperature does not exist. The proposed method not only simplifies the deployment of InfoNCE loss but also enhances its theoretical properties, leading to improved performance in contrastive learning across five benchmark datasets without the need for temperature tuning.

Introduction

The introduction of the research paper discusses the advancements in deep learning, particularly through self-supervised learning, which aims to derive data representations without relying on labeled datasets. A significant focus is placed on contrastive learning, which utilizes similarity scores from various data views to learn effective representations. The InfoNCE loss, a common approach in this context, is highlighted for its role in distinguishing between similar and dissimilar data pairs. However, the performance of contrastive learning is sensitive to the temperature parameter used in the InfoNCE loss, with existing studies reporting varying optimal values, leading to challenges in hyperparameter tuning.

To address these challenges, the authors propose a novel method that eliminates the need for temperature tuning in InfoNCE loss by replacing the temperature division with a scaled log-odds mapping. This approach not only simplifies the training process by removing the extensive search for optimal temperature values but also enhances performance by mitigating issues related to vanishing gradients during optimization. The paper asserts that their method achieves comparable or superior results to traditional temperature-dependent approaches, as demonstrated through comprehensive experiments.

Results

In this section, the authors present additional results from their experiments on natural language processing and sequential recommendation systems, utilizing MABEL (He et al., 2022) and DCRec (Yang et al., 2023), respectively. The experiments were conducted using the StereoSet (Nadeem et al., 2021), CrowS-Pairs (Nangia et al., 2020), and MovieLens-20M (Harper & Konstan, 2016) datasets. For MABEL, the training parameters included 2 epochs, a learning rate of $5 \times 10^{-5}$, a mini-batch size of 16, FP16 precision, a maximum sequence length of 128, and a temperature of 0.05. In contrast, DCRec was trained with a mini-batch size of 512, a dropout probability of 0.5, a top co-interaction size of 4, a mean conformity weight of 0.4, and coefficients for contrastive loss and KL divergence set at 0.1 and 0.01, respectively, with a temperature of 0.8.

The results, summarized in Tables 5 and 6, indicate that the proposed methods consistently outperform the baseline, which is defined by the performance of the division by temperature scheme using the reported temperature values. The reported findings include average performance metrics and standard deviations derived from ten runs with varying random seeds, highlighting the robustness of the proposed approaches in enhancing model performance across the evaluated tasks.

Discussion

In this section, the authors critically evaluate the challenges associated with the division by temperature scheme in InfoNCE loss for contrastive learning. They highlight that the selection of an appropriate temperature value, denoted as $\tau$, is crucial for optimizing performance but often necessitates extensive hyperparameter tuning. Previous approaches, such as dual temperatures and adaptive strategies, still require manual adjustments and can complicate the optimization process. The authors argue that the division by temperature not only imposes representational limits on the logits fed into the softmax function but also leads to issues like vanishing gradients, particularly at optimal points, which can hinder convergence during training.

To address these limitations, the authors propose a novel method that replaces the division by temperature with a mapping of cosine similarities using the log-odds function, specifically $logit(p) = \log\left(\frac{p}{1-p}\right)$, where $p$ is derived from the cosine similarity. This approach ensures that the gradients remain alive during training while achieving zero gradients only at the optimal point, thus enhancing the gradient descent optimization process. The proposed method is demonstrated to be hyperparameter-free and easily integrable into existing frameworks, with experimental results showing improved performance across various tasks, including image classification and anomaly detection, compared to traditional temperature-dependent methods.