Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LLM性能改善の実践知 Kaggleでの学びを現場に活かす思考法

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for sin chir0 sin chir0
March 03, 2026
470

LLM性能改善の実践知 Kaggleでの学びを現場に活かす思考法

Avatar for sin chir0

sin chir0

March 03, 2026
Tweet

Transcript

  1. - Kaggle - Kaggle 2x Master (Competitions, Notebooks) - 業務

    - Sansan株式会社 技術本部 研究開発部 - LLMをファインチューニングし、プロダクトを改善 - 書籍 - Kaggleではじめる大規模言語モデル入門 - Polarsとpandasで学ぶ データ処理アイデアレシピ55 - 趣味 - マラソン(サブ 5.5) 自己紹介 齋藤 慎一朗
  2. アジェンダ 1. 大規模言語モデルの性能改善・高速化の解説(4章、5章の解説) 2. Kaggle LLMコンペにおける性能改善、高速化の実例 3. Kaggleの経験が実務にどう活きているか ※ Kaggle

    LLMコンペ: Kaggleコンペティションにおいて LLMがソリューションとして使われることが多いコンペ (本資 料のみでの定義)
  3. - Kaggle・実務ともに、推論環境に制約があるから。 - どのような制約があるのか? - Kaggleの場合は、例えば T4 × 2 (GPUメモリ

    16GB × 2)を利用した場合に、提出の制限時間に間 に合うよう推論できることである。 - 実務の場合は、LLMによるメリットに対し、コストを払える GPUにて運用可能なことである。 なぜ軽量化・高速化が必要か?
  4. 量子化の主な手法 手法 実現するためのライブラリ例 説明 LLM.int8()[9], NF4[10] bitsandbytes[11] LLM.int8()は、活性の外れ値はそのままの値を保持 し、通常の値は8bit量子化を行う。 NF4は、bitsandbytesで利用される、量子化に適した

    データ型である。 GPTQ[12] GPTQModel[13], llm-compressor[14] 勾配情報を用いて、重みを局所的に最適化しつつ量 子化誤差を最小化する。 AWQ[15] llm-awq[16], llm-compressor 活性の誤差が目立ちやすい部分のみスケーリングで 補正する。 SignRound[17] auto-round[18] 符号に基づく近似誤差を利用して、丸め操作の方向 を最適化する。
  5. Paged Attention[22] - バッチ推論におけるKVキャッシュの無駄を改善する仕組みである。 - KVキャッシュは、バッチ推論を前提としていないため、バッチ推論時に無駄が存在 する。 - 例えば、生成予定のトークン数が 512であり、実際に生成したトークン数が

    64トークンだった場合、 KVキャッシュは生成予定のトークン数分メモリを確保するため、 512 - 64 = 448トークン分のメモリ の確保は無駄となる。 - Paged Attentionは、KV キャッシュをKV ブロックと呼ばれる固定サイズの ブロック に分割し、動的に割り当てることで、このような無駄を無くす。
  6. - コンペ概要 - 名前 - LMSYS - Chatbot Arena Human

    Preference Predictions [24] - 時期 - 2024年5月 ~ 8月 - タスク - 同じプロンプトに対する 2つのLLMの回答に対して、ユーザの嗜好を予測する。 テストデータに適した巨大モデルを学習し性能改善した。 LMSYSコンペの画面の一部([24]より引用)
  7. - 実例 - unsloth/gemma-2-9b-it-bnb-4bit[25]をQLoRAファインチューニングする手法を用いたノートブック [26]が公開された。本手法にて、当時のリーダーボードの上位 5%以内に入ることができた。 - 高い性能を出せた理由は、 Gemma 2

    の事前学習に使用するデータの一部に、本コンペのデータ 提供プラットフォームのデータが含まれていたことが一つの要因と考えられる。 - 9Bと巨大なLLMでも、GPUメモリ48GBの環境にて、約15時間でファインチューニングをすることが でき、T4 x 2のKaggle環境において推論できることが明らかになった。 テストデータに適した巨大モデルを学習し性能改善した。 Notebook画面の一部([26]より引用)
  8. vLLMによる高速な推論を活用した。 - コンペ概要 - 名前 - MAP - Charting Student

    Math Misunderstandings [27] - 時期 - 2025年7月 ~ 10月 - タスク - 数学の問題に対する生徒の回答に対して、どのような誤解を存在するかを予測する。 MAPコンペの画面の一部([27]より引用)
  9. - 実例 - vLLMを用いることで、Qwen/Qwen3-8B[28]の推論を、約16,000行のテストデータに対して、約 10 分で完了した。[30] - 参考として、同じデータを Transformersを用いて推論する場合は約 40分かかった。

    - よって、vLLMを使うことで、推論時間を大幅に削減できる。 - 直近のKaggle LLMコンペにおける推論エンジンとして頻繁に使われている。 vLLMによる高速な推論を活用した。
  10. - コンペ概要 - 名前 - The Learning Agency Lab -

    PII Data Detection [30] - 時期 - 2024年1月 ~ 4月 - タスク - 生徒が書いたエッセイのテキストから固有表現を抽出する。 合成データを追加で学習することで性能改善した。 PIIコンペの画面の一部([30]より引用)
  11. - 実例 - 本コンペは推論対象となるデータについて、ホストから提供されたデータが少なかった。例えば、住 所を表す固有表現は学習データ内に 2件しか存在していない。 - よって、参加者は各自で合成データを作成し、学習データの拡張をしていた。 - 特に、Nicholas

    Broadさんが公開したDiscussionでは、プロンプトエンジニアリングを活用した高品 質なデータセットが作成されていた。具体的には、誰がエッセイを記載するかという人物の情報 (ペ ルソナ)を生成AIで作り出し、ペルソナを更に生成 AIに与えていた。[31] - この合成データを追加で学習することで、モデルの性能を改善することができた。 合成データを追加で学習することで性能改善した。 ペルソナの例([31]より引用)
  12. [1] https://developers.openai.com/api/docs/guides/optimizing-llm-accuracy [2] Jason Wei, Xuezhi Wang, Dale Schuurmans, et

    al. 2022. Chain-of-thought Prompting Elicits Reasoning in Large Language Models. In Proceedings of the NeurIPS 2022. [3] Xuezhi Wang, Jason Wei, Dale Schuurmans, et al. 2023. Self-Consistency Improves Chain of Thought Reasoning in Language Models. In Proceedings of the ICLR 2023. [4] 高野・齋藤・石原『Kaggleではじめる大規模言語モデル入門』講談社( 2026) [5] https://github.com/huggingface/transformers [6] https://github.com/huggingface/trl [7] https://github.com/huggingface/sentence-transformers [8] Edward J. Hu, Yelong Shen, Phillip Wallis, et al. 2022. LoRA: Low-Rank Adaptation of Large Language Models. In Proceedings of the ICLR 2022. [9] Tim Dettmers, Mike Lewis, Younes Belkada, et al. 2022. LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale. In Proceedings of the NeurIPS 2022. [10] Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, et al. 2023. QLoRA: Efficient Finetuning of Quantized LLMs. In Proceedings of the NeurIPS 2023. [11] https://github.com/bitsandbytes-foundation/bitsandbytes [12] Elias Frantar, Saleh Ashkboos, Torsten Hoefler, et al. 2023. GPTQ: Accurate Quantization for Generative Pre- trained Transformers. In Proceedings of the ICLR 2023. [13] https://github.com/ModelCloud/GPTQModel [14] https://github.com/vllm-project/llm-compressor [15] Ji Lin, Jiaming Tang, Haotian Tang, et al. 2024. AWQ: Activation-aware Weight Quantization for On-device LLM Compression and Acceleration. GetMobile: Mobile Computing and Communications, 28(4):12–17. 引用
  13. 引用 [16] https://github.com/mit-han-lab/llm-awq [17] Wenhua Cheng, Weiwei Zhang, Haihao Shen,

    et al. 2024. Optimize Weight Rounding via Signed Gradient Descent for the Quantization of LLMs. In Findings of the EMNLP 2024. [18] https://github.com/intel/auto-round [19] Jianping Gou, Baosheng Yu, Stephen J. Maybank, et al. 2021. Knowledge Distillation: A Survey. International Journal of Computer Vision, 129(6):1789–1819. [20] https://medium.com/my-musings-with-llms/understanding-kv-cache-and-paged-attention-in-llms-a-deep-dive-into-efficient-inference-62fa372432ce [21] Tri Dao, Daniel Y. Fu, Stefano Ermon, et al. 2022. FLASHATTENTION: Fast and Memory-efficient Exact Attention with IO-awareness. In Proceedings of the NeurIPS 2022. [22] Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, et al. 2023. Efficient Memory Management for Large Language Model Serving with PagedAttention. In Proceedings of the SOSP 2023. [23] https://github.com/vllm-project/vllm [24] https://www.kaggle.com/competitions/lmsys-chatbot-arena [25] https://huggingface.co/unsloth/gemma-2-9b-it-bnb-4bit [26] https://www.kaggle.com/code/emiz6413/training-gemma-2-9b-4-bit-qlora-fine-tuning [27] https://www.kaggle.com/competitions/map-charting-student-math-misunderstandings/overview [28] https://huggingface.co/Qwen/Qwen3-8B [29] https://www.kaggle.com/code/sinchir0/lb-0-942-infer-fullft-qwen3-8b-by-sfttrainer [30] https://www.kaggle.com/competitions/pii-detection-removal-from-educational-data [31] https://www.kaggle.com/competitions/pii-detection-removal-from-educational-data/discussion/472221