HyperAIHyperAI

Command Palette

Search for a command to run...

GAN-BERT: تعلّم توليدي تنافسي لتصنيف نصوص متين باستخدام عدد قليل من الأمثلة الموسومة

Danilo Croce Giuseppe Castellucci Roberto Basili

الملخص

تقدّم المعماريات الحديثة القائمة على المحوّلات، مثل BERT، نتائج مبهرة في العديد من مهام معالجة اللغة الطبيعية. غير أنّ معظم المعايير المعتمدة تتكوّن من آلاف الأمثلة (وأحيانًا مئات الآلاف). في كثير من السيناريوهات الواقعية، يكون الحصول على بيانات موصولة عالية الجودة مكلفًا ويستغرق وقتًا طويلًا؛ في المقابل، يمكن عمومًا جمع الأمثلة غير الموسومة التي تميّز المهمة المستهدفة بسهولة. وقد طُرحت إحدى الطرق الواعدة لتمكين التعلّم شبه المُوجّه في مجال معالجة الصور، استنادًا إلى الشبكات التوليدية التنافسية شبه المُوجّهة. في هذه الورقة، نقترح GAN-BERT الذي يوسّع الضبط الدقيق لمعماريات شبيهة بـ BERT ببيانات غير موسومة في إطار توليدي تنافسي. تُظهر النتائج التجريبية أن الحاجة إلى أمثلة موصولة يمكن تخفيضها بشكل كبير (حتى 50-100 مثالًا موصولًا فقط)، مع الحفاظ على أداء جيد في عدة مهام لتصنيف الجمل.

One-sentence Summary

Researchers from the University of Rome, Tor Vergata and Amazon propose GAN-BERT, which extends BERT-like fine-tuning with unlabeled data in a semi-supervised generative adversarial setting, reducing the required annotated examples to only 50–100 while maintaining good performance on several sentence classification tasks.

Key Contributions

  • GAN-BERT extends BERT fine-tuning with a semi-supervised generative adversarial setting in which a generator produces fake examples and BERT serves as the discriminator.
  • The method reduces annotation requirements, achieving good sentence classification performance with only 50 to 100 labeled examples and results comparable to fully supervised settings with fewer than 200 labeled examples.
  • The semi-supervised adversarial schema consistently improves over BERT without adding inference cost, since the generator is used only during training.

Introduction

Transformer-based models such as BERT achieve strong NLP performance after fine-tuning on large annotated datasets, but their accuracy degrades significantly when only a few hundred labeled examples are available, especially for classification tasks with many categories. Since manual annotation is expensive, semi-supervised generative adversarial networks are an attractive alternative, yet their use in NLP has been limited to a kernel-based GAN that operates over fixed precomputed embeddings rather than updating the representation space. The authors introduce GAN-BERT, which places BERT in a semi-supervised GAN framework as the discriminator, uses unlabeled data to improve representations, and enables results comparable to fully supervised training with fewer than 200 labeled examples.

Method

The authors leverage Semi-supervised GANs (SS-GANs) to enable semi-supervised learning within a GAN framework. In this setup, a discriminator is trained over a (k+1)(k + 1)(k+1)-class objective. True examples are classified into one of the target (1,,k)(1, \dots, k)(1,,k) classes, while generated samples are classified into the (k+1)(k + 1)(k+1)-th class. Formally, let DDD and GGG denote the discriminator and generator, and pdp_dpd and pGp_\mathcal{G}pG denote the real data distribution and the generated examples, respectively. The loss function of DDD is defined as LD=LDsup+LDunsupL_D = L_{D_{sup}} + L_{D_{unsup}}LD=LDsup+LDunsup, where:

LDsup=Ex,ypdlog[pm(y^=yx,y(1,,k))]LDunsup=Expdlog[1pm(y^=yx,y=k+1)]ExGlog[pm(y^=yx,y=k+1)]\begin{array}{c} L_{D_{sup}} = - \mathbb{E}_{x, y \sim p_d} \log [ p_m(\hat{y} = y | x, y \in (1, \dots, k)) ] \\ L_{D_{unsup}} = - \mathbb{E}_{x \sim p_d} \log [ 1 - p_m(\hat{y} = y | x, y = k + 1) ] - \mathbb{E}_{x \sim \mathcal{G}} \log [ p_m(\hat{y} = y | x, y = k + 1) ] \end{array}LDsup=Ex,ypdlog[pm(y^=yx,y(1,,k))]LDunsup=Expdlog[1pm(y^=yx,y=k+1)]ExGlog[pm(y^=yx,y=k+1)]

LDsupL_{D_{sup}}LDsup measures the error in assigning the wrong class to a real example among the original kkk categories. LDunsupL_{D_{unsup}}LDunsup measures the error in incorrectly recognizing a real unlabeled example as fake and failing to recognize a fake example. The generator loss LGL_GLG combines a feature matching loss and an unsupervised loss, encouraging GGG to produce examples whose intermediate representations are similar to real ones.

To adapt this for natural language processing, the authors introduce GAN-BERT, which extends a pre-trained BERT model by integrating SS-GAN layers during the fine-tuning stage. Given an input sentence, BERT produces vector representations, and the hCLSh_{CLS}hCLS representation is adopted as the sentence embedding for target tasks.

As shown in the figure below:

The architecture adds a discriminator DDD for classifying examples and a generator GGG acting adversarially on top of BERT. The generator GGG is a Multi Layer Perceptron (MLP) that takes a 100-dimensional noise vector drawn from N(μ,σ2)N(\mu, \sigma^2)N(μ,σ2) as input and produces a vector hfakeRdh_{fake} \in \mathbb{R}^dhfakeRd. The discriminator is another MLP that receives a vector hRdh_* \in \mathbb{R}^dhRd, which can be either hfakeh_{fake}hfake produced by the generator or hCLSh_{CLS}hCLS for unlabeled or labeled examples from the real distribution. The last layer of DDD is a softmax-activated layer outputting a k+1k + 1k+1 vector of logits.

During the training process, the system optimizes two competing losses, LDL_DLD and LGL_GLG. In the forward step, when real instances are sampled (h=hCLSh_* = h_{CLS}h=hCLS), DDD classifies them into one of the kkk categories. When h=hfakeh_* = h_{fake}h=hfake, it classifies the example into the k+1k + 1k+1 category. During back-propagation, unlabeled examples contribute only to LDunsupL_{D_{unsup}}LDunsup, meaning they are considered in the loss computation only if they are erroneously classified into the k+1k + 1k+1 category; in all other cases, their contribution to the loss is masked out. Labeled examples contribute to the supervised loss LDsupL_{D_{sup}}LDsup. Examples generated by GGG contribute to both LDL_DLD and LGL_GLG. When updating DDD, the BERT weights are also modified to fine-tune its inner representations using both labeled and unlabeled data. After training, the generator GGG is discarded, retaining the original BERT model for inference without additional computational cost.

Experiment

The experiments compare GAN-BERT with a fine-tuned BERT-base model on topic classification, question classification, sentiment analysis, and natural language inference, using progressively larger labeled sets and additional unlabeled examples. GAN-BERT consistently improves over BERT when only few labeled examples are available, while BERT often diverges at 1% of labels, and the benefit is more pronounced for tasks with many categories. The advantage also appears on SST-5 and is systematic on MNLI up to about 0.5% of annotated examples, after which both models perform similarly.


بناء الذكاء الاصطناعي بالذكاء الاصطناعي

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

البرمجة التعاونية باستخدام الذكاء الاصطناعي
وحدات GPU جاهزة للعمل
أفضل الأسعار

HyperAI Newsletters

اشترك في آخر تحديثاتنا
سنرسل لك أحدث التحديثات الأسبوعية إلى بريدك الإلكتروني في الساعة التاسعة من صباح كل يوم اثنين
مدعوم بواسطة MailChimp