GENZITSU / UsefulMaterials

34 stars 0 forks source link

almost weekly useful materials - 11/1 - #139

Open GENZITSU opened 6 months ago

GENZITSU commented 6 months ago

ファッションにおける類似商品検索アルゴリズムの性能評価

DROBEというファッションECサイト上のデータを用いて、画像 or 言語を用いた類似商品検索の性能評価を定量/定性で行った結果をまとめているブログ

設定

スクリーンショット 2023-10-18 9 38 10

評価は3万件のDROBEデータで実施

結果

スクリーンショット 2023-10-18 9 41 17

定性評価だと以下

スクリーンショット 2023-10-18 9 42 55

スクリーンショット 2023-10-18 9 43 04

商品説明文を用いたBERTがカテゴリ/色に対する正解率が低い模様 → 説明文にはさまざまな情報が含まれるので、だけから色やカテゴリを取るのは確かに難しそう?

color jitterが入っているsim siamで学習したResNetが色に対する正解率低いのも面白い (まぁそれはそうなるだろうという感じ)

コメント

CLIP強いなというのと、自己教師あり学習で用いるaugmentationは利用目的に応じて調整しないとダメだなという学び

出典

GENZITSU commented 6 months ago

Training Generative Question-Answering on Synthetic Data Obtained from an Instruct-tuned Model

context aware QAにおいて、GPT3.5で生成した日本語QAペアと人手で作成したQAペアとで、QAモデルの性能がどう変化するかを検証した論文 from stockmark

検証設定

結果

スクリーンショット 2023-10-18 14 54 27 スクリーンショット 2023-10-18 14 54 32

わかったこと

コメント

出典

GENZITSU commented 6 months ago

検索システムと自然言語処理AIを合わせ、編集作業を効率化する(Yahoo!ニュースのAI事例)

多様なニュースを元に人手で作成しているQA作成業務をRetrieve-Readerアーキテクチャーにより効率化した事例の紹介

スクリーンショット 2023-10-20 16 09 45

概要

Yahooニュースでは毎日100本程度のニュースをトピックスとして選出し、それにまつわるQ&Aを編集者が考案しており、業務負荷がかなり高い。

これの効率化として、編集者が考案したQに対するAを生成するシステムをRAGを構築

アーキテクチャ

Retrieval-Readerというアーキテクチャーを利用。

一度検索したドキュメントから関連部分を抽出した後に、Qに対するAの生成を実施

スクリーンショット 2023-10-20 16 17 14

Retrieve部分

Reader部分

検索性能の精度は人手で正解不正解を確認しており、Top5の正解率が43%, Top10で63%だったとのこと。 質問応答の精度はROUGE-Lで69%、予測した回答に正解の回答が含まれている割合が40%

コメント

当初Readした内容も元にgenerateしてるのかと思ったが、readした内容だけを提示して、最後の生成は人でやってるという形だった。 JSQuADのデータを元に、抽出型モデルの作成もできるし、リランクモデルも作れるしで、ポテンシャル高そう。

出典

GENZITSU commented 6 months ago

LLMコンペ 1st place

勉強になったところだけ抜粋

Context Retriever

Contextの与え方

Generator

LLMの利用

個別の選択肢ごとにencodeし、全選択肢の平均値も入れた上で、binary classificationで推論

image

訓練データセット中の正解コンテキストだけで学習すると過学習するのでノイズを入れることが重賞

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 2nd place

勉強になったところだけ抜粋

Context Retriever

このpyseriniはsparse search/dense search両方に対応しており、hybrid検索も可能な模様

Reranker

deberta-v3-baseでquestion/answerに対するMultiple Choice形式で学習 教師データはdeberta-v3-largeモデルによるpseudo-mask (question/answeringのconfidenceなどを使用?)

Generator

deberta-v3-large, mistral-7b-instruct-v0-1-4gによるMultipleChoice形式で学習 難しい問題にはmistral-7bの出力を使うことで精度を向上させる

最終的な出力を得る際にXGBsootを用いてスコアリングを実施

error analysis

似たような選択肢が出てくる際に正答率が下がることを確認し、特別の後処理を追加 none of the above が正解となる場合にmap@3が下がることを確認し、対策を実施

ablation

RerankerモデルとMistral7bの貢献が大きそう

568eb4eb-a564-4951-896b-bc88df04ddeb

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 3rd place

勉強になったところだけ抜粋

Overview

4506aaf9-7ac4-47dc-aa36-ba3a2cf9c320

Context Retriever

Reranker

system_message = f"""
You will be provided with TEXT from wikipedia. \
The TEXT will be delimited with {delimiter} characters.
Output a python list of 3 dict objects, where each object is \
a multiple choice question whose answers should be in \
the given TEXT and that has 5 choices each. Each object should have the following format:
    'question': <question on the TEXT>
    'option_1': <question answer option>
    'option_2': <question answer option>
    'option_3': <question answer option>
    'option_4': <question answer option>
    'option_5': <question answer option>
    'answer': <answer option key label>
    'reference_sentence': <original sentence from the TEXT that supports the answer>

You should tell me which one of your proposed options is right \
by assigning the corresponding option's key label in the 'answer' field. Also, provide the original sentence \
from the TEXT that supports the answer in the 'reference_sentence' field.

The question, the answer, and question answer options should be broad, \
challenging, long, detailed, and based on the TEXT provided.

Additionally, ensure the token distribution of question follows these statistics:
- Mean: 14.22 tokens
- Std Deviation: 7.223939 tokens
- Min: 4 token
- 25th Percentile: 9 tokens
- Median: 13 tokens
- 75th Percentile: 17.25 tokens
- Max: 49 tokens

Additionally, ensure the token distribution of each answer follows these statistics:
- Mean: 30.840 tokens
- Std Deviation: 19.883692 tokens
- Min: 1 token
- 25th Percentile: 16 tokens
- Median: 27.5 tokens
- 75th Percentile: 43.25 tokens
- Max: 100 tokens

Only output the list of objects, with nothing else.
"""

Generator

追加の学習データを作成

MultipleChoice形式で以下を学習

難しい問題には70B級のモデルを利用

ablation

Rerankerモデルと難しい問題へのLLMの貢献が大きそう

72e8376f-5337-42e1-99de-34974c15f89a

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 4th place

勉強になったところだけ抜粋

Context Retriever

Generator

chatgptで作成されたQAデータセットで deberta-v3-largeを学習 (明言されてはいないがMultipleChoice形式か)

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 5th place

勉強になったところだけ抜粋

Overview

11d53aa4-fd2c-4bb0-a5bb-1d3c601121f6

Context Retriever

情報の欠落に配慮したwikipedia datasetのparsing

Sparse RetrievalとDense Retrievalの組み合わせ

Generator

chatgptでオリジナルのQAデータセットで Mistral 7BとLlama 70Bを学習

モデルの学習にはQLoRAを利用

推論形式は以下のテンプレートの後に、"▁A", "▁B", "▁C", "▁D", "▁E" トークンが続く確率で予測

{context_0}

Question: {prompt}
A. {A}
B. {B}
C. {C}
D. {D}
E. {E}
Answer:

xformersのmemory_efficient_attention を 全layerに適用することで 消費GPUを線形に保つ (結果として6GBしか利用しなかった)

from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    torch_dtype=torch.float16,
    use_safetensors=True,
).to("cuda")

pipe.enable_xformers_memory_efficient_attention()

with torch.inference_mode():
    sample = pipe("a small cat")

attention maskの工夫による効率的なTTA

問題の難易度ごとに、使用するモデルを切り替えることで精度を向上

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 6th place

勉強になったところだけ抜粋

Context Retriever

数字や数式を適切にrenderingするために独自のSTEM wikiコーパスを作成

chunk分はsectionごとに実施し、大きいsectionは300tokenほどになるように分割

検索はDense Retriever + Rerankerの2段構成

Generator

難易度別に利用モデルを変更して推論

SpanClassificationとは以下のような推論方法

5f629f57-b0a8-4c2b-b673-834a2d337853

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 7th place

勉強になったところだけ抜粋

Overview

inbox_6102861_b579b81a690fa6d046945483570c4cdf_llm-overview-v4

Context Retriever

様々なデータソース x Retrieverによって多様なcontextを取得

Generator

LLMの推論時にmax_new_tokens=1を指定し、余計なtokenを生成しない。

LLMをReward Modelで学習することで、AutoModelForSequenceClassificationがサポートしていないモデルも学習可能にする

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 10th place

勉強になったところだけ抜粋

Overview

9e1a91c6-92b3-475c-82fa-c5a956693e05

Context Retriever

複数のwiki datasetからのretrieve

wikipedia dumpに対する処理

公開wikiデータに対する処理

Generator

gpt3.5で生成した60KのQAデータで学習

1つのdeberta-v3-largeモデル(おそらくMultipleChoice形式)に入力するcontextを変化させることでensembleを実施

入力contextは長い方がよく、学習時の2倍の長さを入れて実施

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 11th place

勉強になったところだけ抜粋

Context Retriever

4つのデータソースからコンテキストを抽出

英語のwikiからfaissに突っ込んで上記3方法の中でのtop5をコンテキストとして利用

faissにgpuを利用することで高速な検索が可能に

sentence_index = read_index("/kaggle/input/wikipedia-faiss-index-gte-small/wiki_idx.index")

res = faiss.StandardGpuResources()
sentence_index = faiss.index_cpu_to_gpu(res, 0, sentence_index)

Generator

多様なモデルでのensemble

モデルの学習時に、良いコンテキストばかりを入れると悪影響を及ぼしたので、不完全なコンテキストを入れて学習させたものをensembleに入れる

コメント

ここまでくると被りもおおくなるので、記載事項も減る

出典

GENZITSU commented 6 months ago

LLMコンペ 12th place

勉強になったところだけ抜粋

Overview

0ca16c51-0b46-49d7-8f09-c66319097571

Context Retriever

3種のデータソースからコンテキストを抽出 (この際ベクトル検索後TF-IDFでReRankしているところが珍しい)

indexの容量が膨大になるので、6つに分割して、batchごとに距離計算をして検索を実施

bge-reranker-large を用いたリランキングよりも、TFIDFの方が良かった

Generator

deberta-v3-largeのMultipleChoice形式で推論

ChatGPT3.5で作成したデータ等でモデルを学習

入力token数を512 ~ 1280など様々なものに変えてensemble

コメント

ここまでくると被りもおおくなるので、記載事項も減る

出典

GENZITSU commented 6 months ago

LLMコンペ 13th place

勉強になったところだけ抜粋

Context Retriever

cirrussearch wiki dumpのデータを文章単位でchunk化

Generator

deberta-v3-large系のモデルをMultipleChoice形式で学習

学習に利用したモデル

検索上位20件を以下のように分割してTTAを実施

平均値と最大値をもとにしたensemble

df = pd.read_csv("test.csv")  # len(df) == n_test_data
df["id"] = np.arange(len(df))
df = ensemble(df)  # len(df) = n_test_data * n_tta * n_models
df = df.groupby("id").mean() + df.groupby("id").max()

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 14th place

勉強になったところだけ抜粋

Context Retriever

問題対象となるデータの範囲を推測し、カテゴリのグラフ情報を用いてwikipediaページを収集

context searchは e5-largeとbgeモデルをfine tuningしたモデルで実施

Generator

debertaをMultipleChoice形式で利用

実際は以下の観点で細かい変更を施したたものを3つ作成しensemble

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 15th place

勉強になったところだけ抜粋

Overview

990365e1-a08d-432a-b82a-cbdfdff9e0ea

Context Retriever

複数のデータソース x Retrieverでcontextを抽出

全てのベクトルモデルの学習にSimCSEを利用 (具体的にどのモデルを利用したかは不明)

5つのRetrieverを用いて、コンテキストを抽出

Context 1

Context 2

Context 3

Context 4

Context 5

Generator

[0.807] Sharing my trained-with-context model を参考にしたと書かれていたので、おそらくDeBERTaV3-Large を MultipleChoice形式で利用したと思われる

推論時は5種類のcontext x 2種のモデルの系10この出力を重み付き平均の形でensemble

コメント

省略

出典

GENZITSU commented 6 months ago

LLMコンペ 金券解法 まとめ

コンポーネントごとにまとめなおしたもの

Retriever

chunk方法

Dense Retriever

e5-small-v2, e5-base-v2, e5-large-v2, gte-small , gte-base, gte-large , bge-small , bge-sbase , bge-large, all-MiniLM-L6-v2, bge-small-en, bge-small-en, bge-small-en-v1.5bge-small-en-v1.5bge-large-en, bge-base-en-v1.5, msmarco-bert-base-dot-v5, all-mpnet-base-v2, multilingual-e5-small, instructor-xl

Dense Retrieverのfine-tuning

encode時の工夫

Context encode時の方法

Query encode時の方法

Sparse Retriever

Retrieve時の工夫

Reranker

利用されたモデル

推論形式

教師データの作成方法

Generator

追加学習データの作成

利用されたモデル

推論形式

学習に関するtips

推論に関するtips

ensembleの方法

コメント

非常に学びの多いコンペでした。

出典