Machine_S
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Exploiting Cloze Questions for Few Shot Text Classification and Natural Language Inference ###### tags: `Research`, `prompt`, `PTMs` > [Paper link](https://arxiv.org/pdf/2001.07676.pdf) | [Note link](https://blog.csdn.net/qq_36426650/article/details/120788059) | [Code link](https://github.com/timoschick/pet) | EACL 2021 ## Abstract This paper introduces Pattern-Exploiting Training (PET), a **semi-supervised** training procedure that **reformulates input examples as cloze-style phrases** to help language models understand a given task. These phrases are then used to **assign soft labels to a large set of unlabeled examples**. Finally, standard supervised training is performed on the resulting training set. PET outperforms supervised training and strong semi-supervised approaches in **low-resource settings** by a large margin ## Introduction Before this paper, applying standard supervised learning to small training sets often performs poorly. For instance, assume the model is given the following pieces of text: * $T_1$: This was the best pizza I’ve ever had. * $T_2$: You can get better sushi for half the price. And the labels of $T_1$ and $T_2$ are $l$ and $l'$ If the model asked to infer the correct label for $T_3$ * $T_3$: Pizza was average. Not worth the price. But, things get easiler if the model know that the underlying task is to identify whether the text says anything about prices. --- In this work, they show that providing task descriptions can successfully be combined with standard supervised learning in few-shot settings, it's called **P**attern-**E**xploiting **T**raining (PET), a **semi-supervised training** procedure that uses natural language patterns to **reformulate input examples into cloze-style phrases.** <center> <img src = "https://i.imgur.com/amWJXJx.png"> </center><br> PET works in three steps: First, for each pattern a separate PLM is **finetuned on a small training set $\mathcal{T}$** The ensemble of all models is then used to annotate a large unlabeled dataset $\mathcal{D}$ **with soft labels**. Finally, a standard **classifier** is trained on the soft-labeled dataset. They also devise iPET, an **iterative variant of PET** in which this process is repeated with increasing training set sizes. ## Related Work * Zero-shot learning of challenging tasks (question answering (QA) / reading comprehension), it requires a semantic parser * Cloze-style phrases to probe the knowledge that PLMs acquire during pretraining * Few-shot learning in NLP (exploiting examples from related tasks / data augmentation) The idea behind iPET – training multiple generations of models on data labeled by previous generations ## Pattern-Exploiting Training * $M$: masked language model with vocabulary $V$ * mask token $\_ \_ \_ \_ \in V$ (also means $[\rm{MASK}]$) * $\mathcal{L}$: a set of labels for target classification task $A$ An input for task $A$ as a sequence of phrases $\rm{\textbf{x}}$ $= (s_1, ..., s_k)$ with $s_i \in V^*$ For example, $k = 2$ if $A$ is textual inference (two input sentences). They define a *pattern* to be a function $P$ that takes $\rm{\textbf{x}}$ as input and outputs a phrase or sentence $P($$\rm{\textbf{x}}$$) \in V^*$ that contains exactly **one mask token** its output can be viewed as a **cloze question**. Furthermore, they define a *verbalizer* as an injective function $v \ : \ \mathcal{L} \rightarrow V$ that maps each label to a word from $M$'s vocabulary. $(P, v)$ as a *pattern-verbalizer pair* (PVP) * $P$ create $[\rm{MASK}]$ from $\mathrm{\textbf{x}}$ * $v$ is the relation, which means $\mathcal{L} \rightarrow V$ (e.g. positive $\rightarrow$ great) :::info **How they solve task $A$ using PVP ($P, v$)** Given an input $\rm{\textbf{x}}$, and applying $P$ to obtain an input representation $P($$\rm{\textbf{x}}$$)$ Using $M$ to determine the label $y \in \mathcal{L}$ for which $v(y)$ is the most likely substitute for the mask. ::: ### PVP Training and Inference Given some input $\rm{\textbf{x}}$, and define the score for label $l \in \mathcal{L}$ as $$ s_{\mathbf{p}}(l \mid \mathbf{x})=M(v(l) \mid P(\mathbf{x})) $$ and obtain a probability distribution over labels using softmax: $$ q_{\mathbf{p}}(l \mid \mathbf{x})=\frac{e^{s_{\mathbf{p}}(l \mid \mathbf{x})}}{\sum_{l^{\prime} \in \mathcal{L}} e^{s_{\mathbf{p}}\left(l^{\prime} \mid \mathbf{x}\right)}} $$ ### Auxiliary Language Modeling This paper suffer from a problem, whinch few training examples are available and catastrophic forgetting can occur. So they use language modeling as auxiliary task. Final loss combine both cross-entropy $L_{CE}$ and language modeling loss $L_{\mathrm{MLM}}$, $\alpha$ here set $10^{-4}$ $$ L = (1 - \alpha) \cdot L_{CE} + \alpha \cdot L_{\mathrm{MLM}} $$ ### Combining PVPs To handle which PVPs perform well, they use strategy similar to knowledge distillation. 1. They define a set $\mathcal{P}$ of PVPs that intuitively make sense for a given task $A$. 2. Finetuning a separate language model $M_{\mathrm{\textbf{p}}}$ for each $\mathrm{\textbf{p}} \in \mathcal{P}$ 3. Using the ensemble $\mathcal{M} = \{ M_{\mathrm{\textbf{p}}} \ | \ \mathrm{\textbf{p}} \in \mathcal{P}\}$ of finetuned models to annotate examples from $\mathcal{D}$, they combine the unnormalized class scores for each example $\mathrm{\mathbf{x}} \in \mathcal{D}$ as $$ s_{\mathcal{M}}(l \mid \mathbf{x})=\frac{1}{Z} \sum_{\mathbf{p} \in \mathcal{P}} w(\mathbf{p}) \cdot s_{\mathbf{p}}(l \mid \mathbf{x}) $$ where $Z = \sum_{\mathrm{\textbf{p}} \in \mathcal{P}} w(\mathrm{\textbf{p}})$ and the $w(\mathrm{\textbf{p}})$ are weighting terms for the PVPs. And they experiment with two different realizations of this weighing term * $w(\mathrm{\textbf{p}}) = 1$ for all $\mathrm{\textbf{p}}$ * $w(\mathrm{\textbf{p}})$ to be the accuracy obtained using $\mathrm{\textbf{p}}$ on the training set *before* training 4. Finetuning a PLM $C$ with standard sequence classification head on $\mathcal{T}_C$ ![](https://i.imgur.com/qggwOYE.png) ### Iterative PET (iPET) iPET train several *generations* of models on datasets of increasing size, avoiding issue that some patterns perform (possibly much) worse than others, the training set $\mathcal{T}_C$ for the final model may therefore contain many mislabeled examples. 1. Firstly, enlarge the original dataset $\mathcal{T}$ by labeling selected examples from $\mathcal{D}$ using a random subset of trained PET models. 2. Then training a new generation of PET models on the enlarged dataset (repeatedly) * $\mathcal{M}^0=\left\{M_1^0, \ldots, M_n^0\right\}$ be the initial set of PET models finetuned on $\mathcal{T}$ * Each $M_i^j$ is trained for PVP $\mathrm{\textbf{p}}_i$ on its own training set $\mathcal{T}^j_i$ * In each iteration, we multiply the training set size by a fixed constant $d \in \mathbb{N}$ To maintain the label ratio of the original dataset, they use those steps below: 1. Obtaining $\mathcal{N} \subset \mathcal{M}^{j-1} \backslash\left\{M_i^{j-1}\right\}$ by randomly choosing $\lambda \cdot (n - 1)$ models from the previous generation with $\lambda (0. 1]$ 2. Using the subset to create a labeled dataset $$ \mathcal{T}_{\mathcal{N}}=\left\{\left(\mathbf{x}, \arg \max _{l \in \mathcal{L}} s_{\mathcal{N}}(l \mid \mathbf{x})\right) \mid \mathbf{x} \in \mathcal{D}\right\} $$ To avoid training future generations on mislabeled data, we prefer examples for which the ensemble of models is confident in its prediction. When drawing from $\mathcal{T_N}$, setting the proability of each ($\mathrm{\textbf{x}}, y$) proportional to $s_{\mathcal{N}} (l \ | \ \mathrm{\textbf{x}})$ 3. Then combining new dataset as $\mathcal{T}_i^j=\mathcal{T} \cup \bigcup_{l \in \mathcal{L}} \mathcal{T}_{\mathcal{N}}(l)$ 4. After training $k$ generations of PET models, using $\mathcal{M}^k$ to create $\mathcal{T}_C$ and train $C$ as in basic PET. ## Experiments Evaluating on four English datasets: Yelp Reviews, AG’s News, Yahoo Questions and MNLI. Using x-stance to investigate how well PET works for other languages. RoBERTa large as language model, for x-stance, using XLM-R ### Sentiment Analysis Type Tasks * Yelp <table> <tr> <th> Patterns </th> <th> Verbalizer </th> </tr> <tr> <td> <img src="https://i.imgur.com/8hW3CuU.png"> </td> <td> <img src="https://i.imgur.com/HAg1s5g.png"> </td> </tr> </table> ### Thematic classification tasks * AGNews / Yahoo <table> <tr> <th> Patterns </th> <th> Verbalizer </th> </tr> <tr> <td> <img src="https://i.imgur.com/EZtb6JL.png"> </td> <td> <center> maps categories 1–4 to <br> “World”, “Sports”, “Business” and “Tech” </center> </td> </tr> <tr> <td> <img src="https://i.imgur.com/EZtb6JL.png"> </td> <td> <center> maps categories 1–10 to <br> “Society”, “Science”, “Health”, <br> “Education”, “Computer”, “Sports”, <br> “Business”, “Entertainment”, “Relationship” and “Politics” </center> </td> </tr> </table> ### Sentence pair type task * MNLI <table> <tr> <th> Patterns </th> <th> Verbalizer </th> </tr> <tr> <td> <img src="https://i.imgur.com/3ZDN3zW.png"> </td> <td> <img src="https://i.imgur.com/wqTcHqZ.png"> </td> </tr> </table> ![](https://i.imgur.com/shbXgTA.png) <center> <img src="https://i.imgur.com/D0hNgzd.png"> </center> ### X-Stance Multilingual stance detection dataset with German, French and Italian examples <table> <tr> <th> Patterns </th> <th> Verbalizer </th> </tr> <tr> <td> <img src="https://i.imgur.com/RKZBcAg.png)"> </td> <td> mapping 0 to “Yes” and 1 to “No” </td> </tr> </table> <center> <img src="https://i.imgur.com/N4o1ahb.png"> </center> ## Analysis ### Combining PVPs <center> <img src="https://i.imgur.com/T27j1Ft.png"> </center> ### Auxiliary Language Modeling <center> <img src="https://i.imgur.com/UAyirki.png"> </center> ### Iterative PET <center> <img src="https://i.imgur.com/cNxREEi.png"> </center> ### In-Domain Pretraining <center> <img src="https://i.imgur.com/1r0eSaI.png"> </center> ## Conclusion PET, consists of defining pairs of **cloze question patterns** and **verbalizers** that help leverage the knowledge contained within pretrained language models for downstream tasks. When the initial amount of training data is limited, PET gives large improvements over standard supervised training and strong semi-supervised approaches.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully