Views
No views yet
1.7.0 version corresponding to your platforms/CUDA versions. PyTorch version higher than 1.7.0 should also work. For example, if you use Linux and CUDA11 (how to check CUDA version), install PyTorch by the following command,pip install torch==1.7.0+cu110 -f https://download.pytorch.org/whl/torch_stable.html<11 or CPU, install PyTorch by the following command,pip install torch==1.7.0pip install -r requirements.txttransformers==4.11.3 and adapter-transformers==2.2.0. Using them from other versions may cause some unexpected bugs.transformers:1import torch
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
4# Import our model. The package will take care of downloading the models automatically
5tokenizer = AutoTokenizer.from_pretrained("roberta-base")
6model = AutoModelForSequenceClassification.from_pretrained("UIC-Liu-Lab/CPT", trust_remote_code=True)
7
8# Tokenize input texts
9texts = [
10 "There's a kid on a skateboard.",
11 "A kid is skateboarding.",
12 "A kid is inside the house."
13]
14inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="pt")
15
16# Task id and smax
17t = torch.LongTensor([0]).to(model.device) # using task 0's CL-plugin, choose from {0, 1, 2, 3}
18smax = 400
19
20# Get the model output!
21res = model(**inputs, return_dict=True, t=t, s=smax)model = AutoModel.from_pretrained({PATH TO THE DOWNLOAD MODEL}).Restaurant -> AI -> ACL -> AGNews, you can use the downloaded weights to fine-tune the corresponding end-task. The results (MF1/Acc) will be consistent with follows.| Restaurant | AI | ACL | AGNews | Avg. | |
|---|---|---|---|---|---|
| UIC-Liu-Lab/CPT | 53.90 / 75.13 | 30.42 / 30.89 | 37.56 / 38.53 | 63.77 / 65.79 | 46.41 / 52.59 |
1@inproceedings{ke2022continual,
2 title={Continual Training of Language Models for Few-Shot Learning},
3 author={Ke, Zixuan and Lin, Haowei and Shao, Yijia and Xu, Hu and Shu, Lei, and Liu, Bing},
4 booktitle={Empirical Methods in Natural Language Processing (EMNLP)},
5 year={2022}
6}