ماذا فعلت خطأ؟ قياس حساسية وثبات نماذج اللغة الكبيرة تجاه هندسة المطالبات
What Did I Do Wrong? Quantifying LLMs’ Sensitivity and Consistency to Prompt Engineering

المجلة: Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers)
DOI: https://doi.org/10.18653/v1/2025.naacl-long.73
تاريخ النشر: 2025-01-01
المؤلف: Federico Errica وآخرون
الموضوع الرئيسي: الذكاء الاصطناعي في القانون

نظرة عامة

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

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

مقدمة

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

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

طرق

في هذا القسم، يقدم المؤلفون مقياسين رئيسيين لتقييم أداء نماذج اللغة الكبيرة (LLMs) في مهام التصنيف: الحساسية والاتساق. تقيس الحساسية مدى اختلاف تنبؤات نموذج اللغة الكبيرة مع إعادة صياغة نفس المطالبة. يتم تعريفها باستخدام الإنتروبيا المعنوية، $S_\tau(x) = -E_{y \sim p_\tau(\cdot|x)} [\ln p_\tau(y|x)] / \ln(C)$، حيث $C$ هو عدد الفئات. يتم حساب الحساسية المتوقعة، $S_\tau$، كمتوسط الحساسية عبر جميع العينات. لا تتطلب هذه المقياس تسميات الحقيقة الأساسية وتعمل كمؤشر على متانة نموذج اللغة الكبيرة تجاه اختلافات المطالبات؛ قد يتطلب النموذج شديد الحساسية تحسينات شاملة في المطالبات.

المقياس الثاني، الاتساق، يقيم مدى تشابه توزيعات المخرجات لعينتين من نفس الفئة باستخدام مسافة التباين الكلي (TVD). يتم تعريف الاتساق الثنائي كـ $C_y(x, x’) = 1 – \text{TVD}(p_\tau(\cdot|x), p_\tau(\cdot|x’))، مع حساب الاتساق المتوقع عبر جميع أزواج العينات في نفس الفئة. ينتج نموذج اللغة الكبيرة المتسق توزيعات مخرجات مشابهة لمدخلات مختلفة من نفس الفئة، بينما قد تشير عدم الاتساق إلى مشاكل أساسية في النموذج بدلاً من المطالبة. يقترح المؤلفون أنه في سيناريوهات الإنتاج، من الأفضل اختيار نماذج اللغة الكبيرة ذات الحساسية المنخفضة ($S_\tau \to 0$) والاتساق العالي ($C_y \to 1$) للتخفيف من التغيرات غير المتوقعة في الأداء. بالإضافة إلى ذلك، يشيرون إلى أن عدم اليقين في المخرجات، الذي عرّفه هوانغ وآخرون (2024)، يختلف عن الحساسية، حيث يركز على عدم اليقين في التنبؤات لمدخل ثابت ومطالبة.

نقاش

في قسم النقاش، يضع المؤلفون أبحاثهم في سياق ثلاثة مجالات رئيسية: تأثير الميزات الزائفة، قياس عدم اليقين، وتحسين المطالبات، وكلها جزء لا يتجزأ من هندسة المطالبات. يبرزون أن الاختلافات في المطالبات يمكن أن تؤثر بشكل كبير على دقة واستقرار نماذج اللغة الكبيرة (LLMs). على سبيل المثال، وجد مكوي وآخرون (2023) أن أداء نماذج اللغة الكبيرة مرتبط ارتباطًا وثيقًا باحتمالية المطالبة المدخلة والمخرجات الصحيحة، بينما أظهر تشاو وآخرون (2021) أن ترتيب الأمثلة في المطالبات القليلة يمكن أن يؤدي إلى دقة غير متوقعة في مهام مثل تحليل المشاعر. يشير المؤلفون أيضًا إلى أطر مثل Format-Spread، التي تتنبأ بتغيرات الأداء دون الحاجة إلى الوصول إلى أوزان نماذج اللغة الكبيرة، ويؤكدون على الحاجة إلى نهج منظم مثل توليد معزز بالاسترجاع للتخفيف من المشكلات المتعلقة بالميزات الزائفة.

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

القيود

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

Journal: Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers)
DOI: https://doi.org/10.18653/v1/2025.naacl-long.73
Publication Date: 2025-01-01
Author(s): Federico Errica et al.
Primary Topic: Artificial Intelligence in Law

Overview

In this section, the authors discuss the transformative impact of Large Language Models (LLMs) on software design and interaction, particularly highlighting their efficiency in processing and extracting information from text. However, they identify a significant challenge for developers: the inconsistent behavior of LLMs in response to slight variations in prompts. To address this issue, the authors propose two new metrics for evaluating LLM performance in classification tasks: sensitivity and consistency. Sensitivity assesses how predictions change with different prompt rephrasings without requiring ground truth labels, while consistency evaluates the stability of predictions across rephrasings within the same class.

The authors empirically compare these metrics in text classification tasks, aiming to enhance understanding of LLM failure modes and guide prompt engineering. Their findings suggest that an LLM with high sensitivity and accuracy may not be suitable for production environments, where minor prompt alterations can occur. The authors emphasize the potential for these metrics to inform prompt optimization strategies and express interest in extending sensitivity to other tasks, such as code generation. They conclude by advocating for the integration of sensitivity and consistency into automatic prompt engineering frameworks, positing that these metrics could significantly improve LLM robustness and reliability in both academic and industrial contexts.

Introduction

The introduction of this research paper discusses the challenges faced by software engineers when integrating Large Language Models (LLMs) into their workflows, particularly in relation to prompt engineering. The authors highlight that while LLMs have transformed text processing by allowing natural language interactions, the effectiveness of these models is heavily influenced by the prompts provided. They note that minor changes in prompt wording or variable naming can lead to significant variations in LLM predictions, which can frustrate developers and lead to the abandonment of these tools. This raises the critical question of how to quantify an LLM’s sensitivity to prompt variations.

To address this issue, the authors propose two diagnostic metrics that complement traditional accuracy measures: sensitivity to input variations and consistency of predictions across similar examples. These metrics aim to evaluate the robustness of LLMs against semantically equivalent prompt changes and the stability of their predictions within the same class. By focusing on these aspects, the authors argue that it is possible to reduce the unpredictability of LLM behavior in production environments. They empirically test these metrics, demonstrating that they provide valuable insights into LLM performance and can guide prompt improvement by identifying problematic samples.

Methods

In this section, the authors introduce two key metrics for evaluating the performance of large language models (LLMs) in classification tasks: sensitivity and consistency. Sensitivity quantifies how much the predictions of an LLM vary with different rephrasings of the same prompt. It is defined using normalized entropy, $S_\tau(x) = -E_{y \sim p_\tau(\cdot|x)} [\ln p_\tau(y|x)] / \ln(C)$, where $C$ is the number of classes. The expected sensitivity, $S_\tau$, is computed as the average sensitivity across all samples. This metric does not require ground truth labels and serves as an indicator of the robustness of the LLM to prompt variations; a highly sensitive model may necessitate extensive prompt optimization.

The second metric, consistency, assesses how similar the output distributions are for two samples from the same class using Total Variation Distance (TVD). The pair-wise consistency is defined as $C_y(x, x’) = 1 – \text{TVD}(p_\tau(\cdot|x), p_\tau(\cdot|x’))$, with expected consistency calculated over all pairs of samples in the same class. A consistent LLM produces similar output distributions for different inputs of the same class, while inconsistency may indicate underlying issues with the model rather than the prompt. The authors suggest that in production scenarios, selecting LLMs with low sensitivity ($S_\tau \to 0$) and high consistency ($C_y \to 1$) is preferable to mitigate unexpected performance variations. Additionally, they note that output uncertainty, defined by Huang et al. (2024), is distinct from sensitivity, as it focuses on the uncertainty of predictions for a fixed input and prompt.

Discussion

In the discussion section, the authors contextualize their research within three key areas: the influence of spurious features, uncertainty quantification, and prompt optimization, all of which are integral to prompt engineering. They highlight that variations in prompts can significantly impact the accuracy and stability of large language models (LLMs). For instance, McCoy et al. (2023) found that LLM performance is closely tied to the likelihood of the input prompt and the correct output, while Zhao et al. (2021) demonstrated that the order of examples in few-shot prompting can lead to unpredictable accuracy in tasks like sentiment analysis. The authors also reference frameworks such as Format-Spread, which predict performance variations without needing access to LLM weights, and emphasize the need for structured approaches like Retrieval Augmented Generation to mitigate issues related to spurious features.

The section further explores uncertainty quantification, noting that LLMs can exhibit stochastic behavior, leading to varied predictions for the same prompt. Several studies have attempted to quantify this uncertainty, with Huang et al. (2024) proposing a rank calibration error metric to assess deviations in performance. The authors also discuss prompt optimization as a method to enhance LLM performance, citing Zhao et al. (2021) who introduced a calibration technique to address class imbalance. They conclude that while automated prompt engineering shows promise, there remains a need for deeper understanding of the underlying causes of errors in LLMs. The authors advocate for the use of sensitivity and consistency metrics to identify problematic samples and improve prompt strategies, ultimately aiming to enhance the robustness and trustworthiness of LLMs.

Limitations

The proposed metrics in this research are limited to classification problems, which, while prevalent in information extraction, necessitate future exploration to extend their applicability to more general tasks. Additionally, there exists a trade-off between the quality of the approximation for computing sensitivity and the consistency of the results. This trade-off is influenced by factors such as the potentially biased sampler \( S \), the number \( Q \) of different prompt rephrasings, and the computational cost associated with running additional queries. Future research should also consider whether incorporating higher moments, such as variance, into the proposed metrics can yield more informative insights without relying on class labels.