Bermain dengan pendekatan setFit untuk transfer beberapa tembakan untuk klasifikasi teks.
Sunting: Saya juga melakukan beberapa percobaan dengan pembelajaran aktif jadi sekarang saya juga memiliki Active.py. Saya akan mengaturnya pada suatu hari yang lebih cerah.
$ ~/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.
CATATAN : Jika Anda ingin meminta LLMS yang di -host di HuggingFace (Kasus 3), Anda harus membuat akun Anda di HUBGINGFACE HUB dan menghasilkan token akses setelah itu Anda harus menempelkannya dalam file
./hf_token.key.PS: Jangan khawatir saya telah menambahkan file ini ke .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.
Atau Anda cukup menjalankan ./run.sh setelah menginstal pustaka yang diperlukan (lihat requirements.txt )
Setelah itu, Anda dapat menjalankan notebook summarise.ipynb untuk meringkas dan memvisualisasikan (jika saya berkeliling untuk menambahkan kode ini) hasilnya.
PS: Perhatikan
--full-test. Secara default kami memotong setiap tes yang diatur ke 100 instance pertama.
Mereka semua adalah kumpulan data klasifikasi yang telah dibersihkan oleh orang -orang baik dan baik yang membuat setfit lib. Tetapi Anda dapat menggunakan dataset HF apa pun yang asalkan memiliki ketiga bidang ini: (i) Teks (str), (ii) label (int), dan (iii) label_text (str).
Inilah hasil saya:
Tabel ini menyajikan hasil dari + pengaturan pembelajaran aktif ini. Kecuali ditentukan sebaliknya, kami mengulangi setiap percobaan 5 kali. Angka -angka ini melaporkan akurasi tugas ketika kami hanya memiliki 100 contoh di set kereta.
| 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 |
| Tidak ada setfit ft kontras | 0,932 ± 0,015 | 0,854 ± 0,019 | 0,886 ± 0,005 | 0,902 ± 0,019 | 0,942 ± 0,020 |
| Ft biasa | 0,466 ± 0,133 | 0,628 ± 0,098 | 0,582 ± 0,054 | 0,836 ± 0,166 | 0,776 ± 0,089 |
| Dorongan llm | 0,950 ± 0,000 | 0,930 ± 0,000 | 0,900 ± 0,000 | 0,930 ± 0,000 | 0,820 ± 0,000 |
| KONTEKTIF AL | 0,980 ± 0,000 | 0,910 ± 0,000 | 0,910 ± 0,000 | 0,870 ± 0,000 | 0,980 ± 0,000 |
[1]: Permintaan LLM hanya dilakukan dengan 10 instance (prompt aktual mungkin mengandung lebih sedikit tergantung pada panjang). Ini juga tidak diulang untuk biji yang berbeda.
[2]: Kontrastif AL juga tidak diulangi untuk biji yang berbeda.