DEV Community

Tutty
Tutty

Posted on

Survey: Text Classification via Large Language

選定理由

LLMでテキスト分類を解く方法と効果を知りたい。Shannon AI、AWS、Nanyang University の共同研究。

Paper: https://arxiv.org/pdf/2305.08377.pdf
Code: https://github.com/ShannonAI/GPT-CLS-CARP

概要

【社会課題&技術課題】
GPT-NERのサーベイと同じ。

【従来手法】
RoBERTa等Transformerベースの識別系モデルが提案されているが、LLMはテキスト分類のタスクでは識別系モデルに比べて性能が著しく低い。これは(1) 複雑な言語表現(強調、対比、皮肉などいわゆる語用論の分野)に対処するための推論能力の不足、(2) インコンテキスト学習における許容されるトークン数の制限、などが原因と考えられる。

【提案】
テキスト分類をLLMで行うための Chain of Thought[Wei2022] の一種であるClue And Reasoning Prompting(CARP)を提案。CARPでは、まずLLMに対して表層的な手がかり(キーワード、トーン、意味関係、参照など)を見つけるようにプロンプトを与え、それに基づいて因果関係が結び付ける推論を行うようプロンプトで誘導し最終的な判断を行う。さらに、LLMへの入力トークン長制限に対処するために、CARPでは教師ラベルありデータセットでファインチューニングされたモデルを使用し、インコンテキスト学習でのサンプル文選択に活用する。

【効果】
LLMの一般化能力と教師信号から得られるタスク固有の判断根拠の両方を活用することが可能となり、5つのテキスト分類ベンチマークのうち4つで新たなSOTAのパフォーマンスを達成。さらにCARPが低リソース環境やドメイン適応が必要な場面でも、クラスごとにわずか16サンプルで1,024サンプルの教師あり学習識別モデルと同等のパフォーマンスを達成。

提案 : Clue And Reasoning Prompting (CARP)

fig1

Prompt Construction

GPT-REと同じように Task description, Demonstration, Input の3セクションから成る。Task descriptionの文例としては以下である。

Classify the overall sentiment of the input as positive or negative

Demonstrationは In-context few-shot learning を行うための学習サンプルとしての効果と出力フォーマットを制御する両方の効果を持っている。

Inputも含めた全体としては以下のような構成になる。

{Xdesc; \n; <demo>1; \n; ...; <demo>k; \n; Xinput}

Clues Collecting and Reasoning

テキスト分類に特化した言語表現の解釈能力を向上させるために、CoTをベースにしたステップ推論(CARP)を提案した。これは(推論のための)clueの収集、推論、意思決定というステップから成る。このプロセスは、人間の意思決定の方法を模倣しており、まず入力から判断根拠を収集し、本質的な情報とそうでない情報を分け、局所的な判断根拠を組み合わせて全体像を形成し、最終的な意思決定を作る。

入力に対するclueの抽出例は以下のように記述し、few-shotに用いる。

Input: Steers turns in a snappy screenplay that curls at the edges; it’s so clever you want to hate it.
Clues: "snappy", "clever", "want to hate it" are clues for determining the sentiment of the input sentence.

推論に関しては、LLMに対して表面的なキーワードを超えた深い視点を探求するように促し、否定、強調、皮肉などの言語表現を考慮して局所的な判断根拠を組み合わせ、最終的な判断を行う。以下の例は、収集された判断根拠に基づいて上記の例の判断をするための推論プロセスを示している。

  1. The phrase "snappy screenplay" implies that the screenplay is of a high quality and is well-crafted.
  2. The phrase "curls at the edges" implies that the screenplay is cleverly written.
  3. The phrase "so clever you want to hate it" is a paradoxical statement, which suggests that the sentiment is positive despite the use of the word "hate".

clueとreasoningに基づき、最終的な決定を行う。

Overall, the clues and reasoning process point to a positive sentiment for the input sentence.

tb1

入力テキスト文とゴールドラベルに対して生成された clue と reasoning のテキスト例が表1

Demonstration Sampling

fig2

CARPでは、一般的な意味エンコーディングモデルと比べてテキスト分類に特化したFine-tunedモデルを使用する。これにより、トークン上限数の問題を回避し、LLMの一般化能力とタスク固有の判断根拠の両方を活用できる。具体的には Roberta モデルを学習データでファインチューニングそ、[CLS]の埋め込みを文レベルの表現としてKNNでの文検索に使用する。

実験

表などは省略するが、4/5のデータセットでSOTA,識別系SOTAよりも高精度であった。

tb10

few-shot文の並べ方も精度に影響があり、スコアの低いものから高いものへ並べたほうが高くなる。

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more