Machine Learning Q and AI
中文譯名 大模型技術30講,主要總結了大模型相關的技術要點,結合學術和工程化,對LLM從業者來說,是一份非常好的學習實踐技術地圖.
本文是Machine Learning Q and AI
讀書筆記的第3篇,對應原書第三章 《小樣本學習》.
TL;DR
小樣本學習,其實就是Few-Shot, 要注意,這里討論的的Few-Shot不是提示詞工程(Prompt Engineering)范疇內的.
Few-Shot
Few-shot learning is a flavor of supervised learning for small training sets with a very small example-to-class ratio. In regular supervised learning, we train models by iterating over a training set where the model always sees a fixed set of classes. In few shot learning, we are working on a support set from which we create multiple training tasks to assemble training episodes where each training task consists of different classes.
少樣本學習(Few-shot learning)是一種針對小規模訓練集的監督學習方法,其樣本與類別比例極低。在傳統的監督學習中,我們通過迭代訓練集來訓練模型,模型總是面對固定的類別集合。而在少樣本學習中,我們從一個支撐集(support set)中創建多個訓練任務,組裝成多個訓練場景(training episodes),每個訓練任務都包含不同的類別。
在小樣本學習中,每個標簽下的樣本數遠小于常規機器學習任務。定義小樣本學習任務一般用N-way K-shot
. 其中 N N N代表標簽數, K K K代表樣本數.
數據集和術語
Rather than fitting the model to the training dataset, we can think of few-shot learning as “learning to learn.” In contrast to supervised learning, we don’t have a training dataset but a so-called support set. From the support set, we sample training tasks that mimic the use-case scenario during prediction. For example, for 3-way 1-shot learning, a training task consists of 3 classes with 1 example each. With each training task comes a query image that is to be classified. The model is trained on several training tasks from the support set; this is called an episode.
監督學習中,我們讓模型擬合訓練集,并且在測試集上對模型進行評估. 通常來說,訓練集中每個標簽都會有很多個樣本. Iris
數據集每個標簽有50個樣本,這是非常少的. Deep Learning常用的MNIST
數據集,每個標簽有5000個樣本,還是被認為是少的.
小樣本學習可以認為是讓模型“學會如何學習”,而不是在訓練集上擬合.
支撐集
支撐集的概念如下圖所示:
回合
小樣本學習模擬使用模型推理的各個場景,從支撐集中抽樣,形成訓練任務,每個訓練任務都附帶一個用于推理的查詢集,模型會從支撐集中抽樣形成的訓練任務上進行訓練,每次訓練完成,稱為一個回合(episode).
基類和基集
在測試階段,模型將接收到一個和訓練階段標簽不同的任務,在訓練中遇到的標簽稱為基類,支撐集通常也稱為基集.
總結
小樣本學習有許多不同的類型,最常見的是元學習,本質上是更新模型參數以便模型更好的適應新的任務.