텍스트 분류를 위해 소수의 샷 전송을위한 SetFit 접근법을 사용합니다.
편집 : 나는 또한 능동적 학습으로 실험을 했으므로 이제 Active.py도 있습니다. 맑은 날 더 잘 정리할 것입니다.
$ ~/Dev/projects/setfit$ python main.py --help
Usage: main.py [OPTIONS]
Options:
-d, --dataset-name TEXT The name of the dataset as it appears on the
HuggingFace hub e.g. SetFit/SentEval-CR |
SetFit/bbc-news | SetFit/enron_spam ...
-c, --case INTEGER 0, 1, 2, or 3: which experiment are we
running. See readme or docstrings to know
more but briefly: **0**: SentTF ->
Constrastive Pretrain -> +LogReg on task.
**1**: SentTF -> +Dense on task. **2**:
SentTF -> +LogReg on task. **3**:
FewShotPrompting based Clf over Flan-t5-xl
[required]
-r, --repeat INTEGER The number of times we should run the entire
experiment (changing the seed).
-bs, --batch-size INTEGER ... you know what it is.
-ns, --num-sents INTEGER Size of our train set. Set short values
(under 100)
-e, --num-epochs INTEGER Epochs for fitting Clf+SentTF on the main
(classification) task.
-eft, --num-epochs-finetune INTEGER
Epochs for both contrastive pretraining of
SentTF.
-ni, --num-iters INTEGER Number of text pairs to generate for
contrastive learning. Values above 20 can
get expensive to train.
-tot, --test-on-test If true, we report metrics on testset. If
not, on a 20% split of train set. Off by
default.
-ft, --full-test We truncate the testset of every dataset to
have 100 instances. If you know what you're
doing, you can test on the full dataset.NOTE
that if you're running this in case 3 you
should probably be a premium member and not
be paying per use.
--help Show this message and exit.
참고
./hf_token.keyHuggingf추신 :이 파일을 .gitignore에 추가했습니다
$ python active.py --help
Usage: active.py [OPTIONS]
Options:
-d, --dataset-name TEXT The name of the dataset as it appears on the
HuggingFace hub e.g. SetFit/SentEval-CR |
SetFit/bbc-news | SetFit/enron_spam | imdb ...
-ns, --num-sents INTEGER Size of our train set. I.e., the dataset at the
END of AL. Not the start of it.
-nq, --num-queries INTEGER Number of times we query the unlabeled set and
pick some labeled examples. Set short values
(under 10)
-ft, --full-test We truncate the testset of every dataset to have
100 instances. If you know what you're doing,
you can test on the full dataset.NOTE that if
you're running this in case 3 you should
probably be a premium member and not be paying
per use.
--help Show this message and exit.
또는 필요한 라이브러리를 설치 한 후 간단히 ./run.sh 를 실행할 수 있습니다 ( requirements.txt 참조).
그 후, 노트북 summarise.ipynb 실행하여 결과를 요약하고 시각화 할 수 있습니다 (이 코드를 추가하는 경우).
추신 :
--full-test에주의를 기울이십시오. 기본적으로 우리는 모든 테스트를 처음 100 인스턴스로 잘라냅니다.
그것들은 setfit을 lib을 만든 멋지고 친절한 사람들이 청소 한 모든 분류 데이터 세트입니다. 그러나이 세 가지 필드 (i) 텍스트 (str), (ii) 레이블 (int) 및 (iii) label_text (str)가있는 경우 HF 데이터 세트를 사용할 수 있습니다.
내 결과는 다음과 같습니다.
이 표는이 + 활성 학습 설정의 결과를 나타냅니다. 달리 명시되지 않으면 각 실험을 5 번 반복합니다. 이 숫자는 열차 세트에 100 개의 인스턴스 만 있으면 작업 정확도를보고합니다.
| BBC-News | SST2 | SENTEVAL-CR | IMDB | enron_spam | |
|---|---|---|---|---|---|
| setfit ft | 0.978 ± 0.004 | 0.860 ± 0.018 | 0.882 ± 0.029 | 0.924 ± 0.026 | 0.960 ± 0.017 |
| 대조적 인 setfit ft | 0.932 ± 0.015 | 0.854 ± 0.019 | 0.886 ± 0.005 | 0.902 ± 0.019 | 0.942 ± 0.020 |
| 일반 FT | 0.466 ± 0.133 | 0.628 ± 0.098 | 0.582 ± 0.054 | 0.836 ± 0.166 | 0.776 ± 0.089 |
| LLM 프롬프트 | 0.950 ± 0.000 | 0.930 ± 0.000 | 0.900 ± 0.000 | 0.930 ± 0.000 | 0.820 ± 0.000 |
| 전신 Al | 0.980 ± 0.000 | 0.910 ± 0.000 | 0.910 ± 0.000 | 0.870 ± 0.000 | 0.980 ± 0.000 |
[1] : LLM 프롬프트는 10 개의 인스턴스만으로 수행됩니다 (실제 프롬프트는 길이에 따라 더 적게 포함될 수 있음). 또한 다른 씨앗에 대해서도 반복되지 않습니다.
[2] : 대조적 인 Al도 다른 씨앗에 대해 반복되지 않습니다.