Update README.md
Browse files
README.md
CHANGED
|
@@ -33,6 +33,22 @@ This design enables:
|
|
| 33 |
- Fast adaptation to downstream tasks
|
| 34 |
- Improved few-shot and full-data performance
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
## Training Details
|
| 37 |
|
| 38 |
- **Base model:** Qwen2.5-3B-Instruct
|
|
|
|
| 33 |
- Fast adaptation to downstream tasks
|
| 34 |
- Improved few-shot and full-data performance
|
| 35 |
|
| 36 |
+
Usage:
|
| 37 |
+
|
| 38 |
+
Before running the following code, we need to import the modules from https://github.com/baoguangsheng/faast
|
| 39 |
+
|
| 40 |
+
```
|
| 41 |
+
tokenizer = AutoTokenizer.from_pretrained(args.model_path, trust_remote_code=True)
|
| 42 |
+
model = AutoModelForCausalLM.from_pretrained(args.model_path, trust_remote_code=True)
|
| 43 |
+
|
| 44 |
+
fewshot_samples = ['sample 1', 'sample 2', ...]
|
| 45 |
+
inputs = tokenizer(fewshot_samples, return_tensors="pt", padding=True)
|
| 46 |
+
|
| 47 |
+
model.reset_projection() # clear existing fast weights
|
| 48 |
+
model.learn(**inputs) # learn new fast weights
|
| 49 |
+
model.generate(...) # do the task using the learned fast weights
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
## Training Details
|
| 53 |
|
| 54 |
- **Base model:** Qwen2.5-3B-Instruct
|