How to Efficiently Solve Low Accuracy and High Cost Issues in Japanese Text Generation with T5

Challenges in Japanese Text Generation

When working on Japanese text summarization, title generation, and document classification tasks, do you face these problems?

1. Accuracy Issues

  • Traditional rule-based methods cannot generate natural Japanese text
  • English-oriented models cannot handle Japanese grammar and expressions
  • Need to build separate models for multiple tasks

2. Development Cost Issues

  • Time and resources required for task-specific model development
  • Different approaches needed for document classification, summarization, and title generation
  • Enormous effort required for preparing training data and building models

3. Operational Complexity

  • Need to manage and operate multiple models
  • Different APIs and interfaces for each task
  • Complex model updates and maintenance

Real-world Text Generation Challenge Cases

Failure Case: Limitations of Task-specific Individual Development

# Traditional approach
classification_model = load_bert_classifier()      # For document classification
summarization_model = load_summarization_model()   # For summarization
title_generation_model = load_title_model()        # For title generation

# Problems:
# - Managing 3 separate models
# - 3x memory usage
# - High development and maintenance costs

The solution to this problem is Japanese T5 (Text-To-Text Transfer Transformer).

[Read More]

日本語の分散表現の計算方法まとめ

単語単位の分散表現

  • Word2vec
    • 自然言語処理における分散表現の一つのオリジナル
    • 基本原理くらいは知っていてもいいかもしれない
    • gensimがよく使われる
  • Fasttext で文書分類問題までやったった
    • fastと名前がついているだけあってfacebookが公開しているモデルは高速に動作する
    • 分散表現とクラス分類に対応していたり、利便性が高い
    • 特にこのモデルで利用されている分かち書きの特徴から未知語に強いとされている
  • 日本語Wikipediaで学習済みのBERTが公開されているので使い方メモ
    • Google の検索エンジンにも採用されている、らしい
    • 自然言語処理の研究を大きく変えたモデル
    • 関連する技術であるTransformerは自然言語処理だけでなく、画像処理の界隈にも流用された
    • huggingfaceで日本語版のBERTも色々と公開されている
  • 日本語に対応したT5
    • この日本語版のモデルの作者が公開しているサンプルがわかりやすい
    • また同じ作者がSBERTのモデルも公開している

文単位の分散表現

  • tf-idf
    • 最初の選択肢
    • 単語の出現頻度を計算してスコアを割り当てる
    • gensimがよく使われる
  • BM25
    • 単語の出現頻度を計算してスコアを出す
    • QAモデルの最初の大雑把な検索によく使われる印象
  • doc2vec
    • word2vecの文書版
    • gensimがよく使われる
  • Universal Sentence Encoder
    • 結構重宝する
    • そこそこ性能もよく使い勝手がいい
  • SBERT
    • GPUがないとしんどいかも
    • 性能自体は上のUSEよりも体感ではいい

日本語で学習済みのT5がhugging face で公開されたので使い方メモ

T5(Text-To-Text Transfer Transformer) とは

  • 事前学習における入出力を文に統一してしまうことで、 複数の形式の問題に対しても適応できる様式となった。
  • モデルの基本構造としては Transformer が使われており、その点はBERTと共通している。
  • 事前学習の形式をすべてテキストによる指定にするというアイデアはGPT-3などでも用いられている。
    • 0 shot learning など入力文で模範解答例を入力するだけで、出力を操作するということも行われている
    • “操作の指定:入力文1、出力に期待する文、操作の指定:入力文2"で、“出力文2"が得られるという次第

できること

  • 下流のタスクとして転移学習を行うことで以下のようなことが実行できる。
    • 文書分類
    • タイトル生成
    • 文章生成
    • 生成要約

生成要約の例

  • 一つの原文から2種類の要約文を生成するファインチューニングが思いの外うまく働いた。

データとしては

[Read More]