無料のCoursera機械学習入門コース「Generative AI with Large Language Models」を受講しました。そろそろLLMや生成AIも理解しないと、という動機です。無料と言っても、ハンズオンをするには7000円ほど払う必要があるので注意してください(私は払いました)。ハンズオンはAWSで実施しますが、コース料金と別の課金はありません。
体系的に基礎を学べ、わかりやすい点はオススメです。以前受講したCoursera機械学習入門コースも良かったです。ただ、ところどころである程度知識ないと理解が浅くなるポイントもありました(例: RNNやTransformer)。知識なくてもそのままやってしまえばいいと思いますが、少し気持ち悪いかもしれません。逆に一つ一つをゼロから覚えていくと時間がいくらっても足りないと思います。
サマリ
以下がサマリです。あまりよく理解できていない点もどんどん飛ばしています。Coursera上ではIntermidiate Levelです。
項目 | 内容 |
---|---|
目的 | LLMと生成AIの基礎を学ぶため |
期間(実績) | 約3日 |
総時間(実績) | 22時間弱 |
期間と期限 | 全3週 |
使用プログラム言語 | Python |
講義形式 | ビデオ・スライド・クイズ・プログラム演習 ※基本英語だが、ビデオは日本語字幕あり |
学んだことサマリ
基本的には数式もほとんど出てこないので、理解がしやすいです。今回の講座ではモデルの中身の説明はほとんどなく、いかに実用に持っていくかに焦点が当たっています。そのため、自身の目的のために独自データでのファインチューニング方法や、APIとの連携などの説明が多いです。一般人の財力では訓練なんて基本できない世界なので、どうしてもそのような講座になるのでしょう。
学習における注意点
まずは
どうせ無料なんで気楽に始めて、ハンズオンがやりたかったり修了証が欲しかったりしたら有償に切り替えればいいです。
前提知識
前提知識について色々書いていますが、あくまで個人体験に基づく私感です。
数学前提能力
数式はほとんど出てこないので、あまり気にしなくていいと思います。もちろん、深く理解するためには必要かとは思いますが、講義内容を理解するには、そんな必要ないと思いました。
英語前提能力
リンク先動画を字幕で見て理解できるかが前提英語能力です。ただ、日本語字幕や英語のTranscriptもあるのでハードルは高くないです。英語アレルギーのような人には、無理にこの講座にこだわらなくても世の中にはどこかに日本語の良い講座や勉強方法もあるはずです。
プログラミング前提知識
Pythonでのハンズオンがありますが、基本提供されているJupyterを実行するだけなので、そんなに必須ではありません。もちろんプログラムを読めて変更できれば、理解は深まります。
機械学習前提知識
以下の点を事前に知っていると理解が深まるとは思います。Tansformerに関しては、記事「[Transformer入門]TensorFlowチュートリアル: Transformer」のときに学習していたのが非常に役立ちました。
- ニューラルネットワークやディープラーニング基礎
- NLPの基礎(RNNやTransformer)
- 強化学習の基礎(私は全く知らなかったので理解がイマイチ)
学習内容
章単位概要
各章の概要です。ここでの「学習時間」は(コース公式に記載している時間ではなく)実際にかけた時間です。1度学習した後に、このブログ記事書いたり見直したりで追加で4時間くらいかけています。
週.章 | 内容 | コンテンツ数 | 学習時間 | 備考 |
---|---|---|---|---|
1 | Generative AI use cases, project lifecycle, and model pre-training | 25 | 6h | |
1.1. | Introduction to LLMs and the generative Al project lifecycle | 17 | 4h | LLM概要, Prompt Engineering, Inference parameters, 生成AIのプロジェクトライフサイクル |
1.2. | LLM pre-training and scaling laws | 8 | 2h | LLM Pre-training方法, Scaling時考慮点, ドメイン適合 |
2 | Fine-tuning and evaluating large language models | 14 | 5h | |
2.1. | Fine-tuning LLMs with instruction | 7 | 2h | Fine-tuning方法, 精度評価方法とベンチマーク |
2.2. | Parameter efficient fine-tuning(PEFT) | 7 | 3h | 少ない演算能力でのFine-tuning方法 |
3 | Reinforcement learning and LLM-powered applications | 27 | 7.5h | |
3.1. | Reinforcement learning from human feedback | 13 | 4h | LLMを実用的・効果的に使うための人間評価とその反映 |
3.2. | LLM-powered applications | 12 | 3h | LLMを実用的・効果的にに使うためのシステム連携 |
3.3. | Course conclusion and ongoing reseach | 2 | 0.5h | Responsible AIと講座まとめ |
詳細内容
ここでの「Time」は(実際にかけた時間ではなく)コース公式に記載している時間です。
1. Generative AI use cases, project lifecycle, and model pre-training
以下が学習目標(公式をそのまま記載)
- Discuss model pre-training and the value of continued pre-training vs fine-tuning
- Define the terms Generative AI, large language models, prompt, and describe the transformer architecture that powers LLMs
- Describe the steps in a typical LLM-based, generative AI model lifecycle and discuss the constraining factors that drive decisions at each step of model lifecycle
- Discuss computational challenges during model pre-training and determine how to efficiently reduce memory footprint
- Define the term scaling law and describe the laws that have been discovered for LLMs related to training dataset size, compute budget, inference requirements, and other factors.
1.1. Introduction to LLMs and the generative Al project lifecycle
No. | Title | Type | Time | Remarks |
---|---|---|---|---|
1 | Course Introduction | Video | 6min | |
2 | Contributor Acknowledgments | Reading | 10min | 講師紹介。ほぼ全員AWS関係者。 |
3 | Introduction - Week 1 | Video | 5min | 1週目の概要 |
4 | Generative AI & LLMs | Video | 4min | パラメータ数, Prompt, Model, Competion |
5 | Intake Survey | App Item | 1min | |
6 | Have questions, issues or ideas? Join our Community! | App Item | 5min | |
7 | LLM use cases and tasks | Video | 2min | ユースケース |
8 | Text generation before transformers | Video | 2min | RNNの簡単紹介 |
9 | Transformers architecture | Video | 7min | TransformerとAttention |
10 | Generating text with transformers | Video | 5min | Transformerでのテキスト生成 |
11 | Transformers: Attention is all you need | Reading | 10min | 論文紹介 |
12 | Prompting and prompt engineering | Video | 5min | In-context LearningとZero/One/Few-shot inference |
13 | Generative configuration | Video | 7min | Inference Pramaeters |
14 | Generative AI project lifecycle | Video | 4min | 生成AI プロジェクトライフサイクル |
15 | Introduction to AWS labs | Video | 4min | AWS Lab紹介 |
16 | Lab 1 walkthrough | Video | 14min | 1週目ハンズオンの説明 |
17 | Lab 1 - Generative AI Use Case: Summarize Dialogue | App Item | 2h | Prompt EngineeringとInference parameter調整 |
1.2. LLM pre-training and scaling laws
No. | Title | Type | Time | Remarks |
---|---|---|---|---|
1 | Pre-training large language models | Video | 9min | Autoencoding, Autoregressive, Seq2Seq |
2 | Computational challenges of training LLMs | Video | 10min | BFLOAT16でのQantization |
3 | Optional video: Efficient multi-GPU compute strategies | Video | 8min | |
4 | Scaling laws and compute-optimal models | Video | 8min | 演算予算・データサイズ・モデルサイズのトレードオフ |
5 | Pre-training for domain adaptation | Video | 5min | ドメイン固有の訓練とBloombergGPT |
6 | Week 1 quiz | Graded Assignment | 1h | 10問で簡単 |
7 | Week 1 resources | Reading | 10min | 論文リンク |
2. Fine-tuning and evaluating large language models
以下が学習目標(公式をそのまま記載)
- Describe how fine-tuning with instructions using prompt datasets can improve performance on one or more tasks
- Define catastrophic forgetting and explain techniques that can be used to overcome it
- Define the term Parameter-efficient Fine Tuning (PEFT)
- Explain how PEFT decreases computational cost and overcomes catastrophic forgetting
- Explain how fine-tuning with instructions using prompt datasets can increase LLM performance on one or more tasks
2.1. Fine-tuning LLMs with instruction
No. | Title | Type | Time | Remarks |
---|---|---|---|---|
1 | Introduction - Week 2 | Video | 4min | |
2 | Instruction fine-tuning | Video | 7min | In-context Learningの限界とFine-Tuning |
3 | Fine-tuning on a single task | Video | 3min | 単一タスク(文章要約等)への適合 |
4 | Multi-task instruction fine-tuning | Video | 8min | FLAN(Fine-tuned LAnguage Net) |
5 | Scaling instruct models | Reading | 10min | FLANの論文紹介 |
6 | Model evaluation | Video | 10min | ROUGEとBLEU |
7 | Benchmarks | Video | 5min | GLUE, SuperGLUE, HELM, MMLU, BIG-Bench |
2.2. Parameter efficient fine-tuning(PEFT)
No. | Title | Type | Time | Remarks |
---|---|---|---|---|
1 | Parameter efficient fine-tuning (PEFT) | Video | 4min | Selective, Reparametererization, Additive |
2 | PEFT techniques 1: LoRA | Video | 8min | LoRAでの低ランク近似(Reparametererization) |
3 | PEFT techniques 2: Soft prompts | Video | 7min | Prompt tuning(Additive) |
4 | Lab 2 walkthrough | Video | 17min | |
5 | Lab 2 - Fine-tune a generative AI model for dialogue summarization | App Item | 2h | Full Fine-tuneとPEFT(LoRA)とROUGE評価 |
6 | Week 2 quiz | Graded Assignment | 1h | 簡単な10問 |
7 | Week 2 Resources | Reading | 10min | 論文リンク集 |
3. Reinforcement learning and LLM-powered applications
以下が学習目標(公式をそのまま記載)
- Describe how RLHF uses human feedback to improve the performance and alignment of large language models
- Explain how data gathered from human labelers is used to train a reward model for RLHF
- Define chain-of-thought prompting and describe how it can be used to improve LLMs reasoning and planning abilities
- Discuss the challenges that LLMs face with knowledge cut-offs, and explain how information retrieval and augmentation techniques can overcome these challenges
3.1. Reinforcement learning from human feedback
No. | Title | Type | Time | Remarks |
---|---|---|---|---|
1 | Introduction - Week 3 | Video | 4min | |
2 | Aligning models with human values | Video | 3min | Helpful, Honest, Harmlessの3Hを考慮 |
3 | Reinforcement learning from human feedback (RLHF) | Video | 8min | LLMモデルと別にReward Modelを作って学習 |
4 | RLHF: Obtaining feedback from humans | Video | 6min | 訓練データの作り方 |
5 | RLHF: Reward model | Video | 2min | RLHFの報酬モデルと損失関数 |
6 | RLHF: Fine-tuning with reinforcement learning | Video | 3min | 強化学習のFine-Tuning |
7 | Optional video: Proximal policy optimization | Video | 13min | PPO。数式あり難しい。 |
8 | RLHF: Reward hacking | Video | 6min | Rewardが望ましくない状況の回避 |
9 | KL divergence | Reading | 10min | 強化学習での最適化 |
10 | Scaling human feedback | Video | 6min | Constitutioanl AIでの自動訓練。RLAIF(Reinforcement Learning from AI Feedback) |
11 | Lab 3 walkthrough | Video | 18min | |
12 | [IMPORTANT] Reminder about end of access to Lab Notebooks | Reading | 2min | |
13 | Lab 3 - Fine-tune FLAN-T5 with reinforcement learning to generate more-positive summaries | App Item | 2h | RLHFで有害情報を除くようなFine Tuning。 |
3.2. LLM-powered applications
No. | Title | Type | Time | Remarks |
---|---|---|---|---|
1 | Model optimizations for deployment | Video | 7min | Distillation, Quantization, Pruning |
2 | Generative AI Project Lifecycle Cheat Sheet | Video | 2min | LLMと向き合うCheat Sheet |
3 | Using the LLM in applications | Video | 9min | RAG(Retrieval Augmented Generation)で外部連携 |
4 | Interacting with external applications | Video | 4min | E-CommerceのBotの例 |
5 | Helping LLMs reason and plan with chain-of-thought | Video | 5min | 主に計算問題に対して思考途中経過も含めて学習 |
6 | Program-aided language models (PAL) | Video | 7min | PALのフローなど |
7 | ReAct: Combining reasoning and action | Video | 9min | PropmtでReasoningとAction PlanningのChain of thoughtを結合 |
8 | ReAct: Reasoning and action | Reading | 10min | ReActの論文リンクと簡易紹介 |
9 | LLM application architectures | Video | 5min | LLMを使ったアプリのアーキテクチャ |
10 | Optional video: AWS Sagemaker JumpStart | Video | 5min | |
11 | Week 3 Quiz | Graded Assignment | 1h | 少し難しくて2回もリトライ |
12 | Week 3 resources | Reading | 10min | 各学習内容の論文やGitHubへのリンク |
3.3. Course conclusion and ongoing reseach
No. | Title | Type | Time | Remarks |
---|---|---|---|---|
1 | Responsible AI | Video | 9min | Toxicity, Hullucinations, Intellectual Property |
2 | Course conclusion | Video | 3min | LLM関連としてHotな研究領域紹介など |