Update README.md
Browse files
README.md
CHANGED
@@ -44,7 +44,7 @@ We explore supervised multitask pre-training by proposing ***Instruction Pre-Tra
|
|
44 |
## Domain-Adaptive Continued Pre-Training
|
45 |
Following [AdaptLLM](https://huggingface.co/AdaptLLM/finance-chat), we augment the domain-specific raw corpora with instruction-response pairs generated by our [context-based instruction synthesizer](https://huggingface.co/instruction-pretrain/instruction-synthesizer).
|
46 |
|
47 |
-
### 1.
|
48 |
```python
|
49 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
50 |
|
@@ -70,30 +70,43 @@ pred = tokenizer.decode(outputs[answer_start:], skip_special_tokens=True)
|
|
70 |
print(pred)
|
71 |
```
|
72 |
|
73 |
-
### 2.
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
#
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
-
# number of GPUs, chosen from [1,2,4,8]
|
90 |
-
N_GPU=1
|
91 |
-
|
92 |
-
# Set as True
|
93 |
-
add_bos_token=True
|
94 |
-
|
95 |
-
bash scripts/inference.sh ${DOMAIN} 'instruction-pretrain/finance-Llama3-8B' ${add_bos_token} ${MODEL_PARALLEL} ${N_GPU}
|
96 |
-
```
|
97 |
|
98 |
## Citation
|
99 |
If you find our work helpful, please cite us:
|
|
|
44 |
## Domain-Adaptive Continued Pre-Training
|
45 |
Following [AdaptLLM](https://huggingface.co/AdaptLLM/finance-chat), we augment the domain-specific raw corpora with instruction-response pairs generated by our [context-based instruction synthesizer](https://huggingface.co/instruction-pretrain/instruction-synthesizer).
|
46 |
|
47 |
+
### 1. chat with the finance-Llama3-8B model:
|
48 |
```python
|
49 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
50 |
|
|
|
70 |
print(pred)
|
71 |
```
|
72 |
|
73 |
+
### 2. evaluate any Huggingface LMs on domain-dpecific tasks (💡New!)
|
74 |
+
You can use the following scripts to reproduce our results and evaluate any other Huggingface models on domain-specific tasks. Note that these scripts are not applicable to models that require specific prompt templates (e.g., Llama2-chat, Llama3-Instruct).
|
75 |
+
|
76 |
+
1). Set Up Dependencies
|
77 |
+
```bash
|
78 |
+
git clone https://github.com/microsoft/LMOps
|
79 |
+
cd LMOps/adaptllm
|
80 |
+
pip install -r requirements.txt
|
81 |
+
```
|
82 |
+
|
83 |
+
2). Evaluate the Model
|
84 |
+
```bash
|
85 |
+
# Select the domain from ['biomedicine', 'finance', 'law']
|
86 |
+
DOMAIN='finance'
|
87 |
+
|
88 |
+
# Specify any Huggingface LM name (Not applicable to models requiring specific prompt templates)
|
89 |
+
MODEL='instruction-pretrain/finance-Llama3-8B'
|
90 |
+
|
91 |
+
# Model parallelization:
|
92 |
+
# - Set MODEL_PARALLEL=False if the model fits on a single GPU.
|
93 |
+
# We observe that LMs smaller than 10B always meet this requirement.
|
94 |
+
# - Set MODEL_PARALLEL=True if the model is too large and encounters OOM on a single GPU.
|
95 |
+
MODEL_PARALLEL=False
|
96 |
+
|
97 |
+
# Choose the number of GPUs from [1, 2, 4, 8]
|
98 |
+
N_GPU=1
|
99 |
+
|
100 |
+
# Whether to add a BOS token at the beginning of the prompt input:
|
101 |
+
# - Set to False for AdaptLLM.
|
102 |
+
# - Set to True for instruction-pretrain models.
|
103 |
+
# If unsure, we recommend setting it to False, as this is suitable for most LMs.
|
104 |
+
add_bos_token=True
|
105 |
+
|
106 |
+
# Run the evaluation script
|
107 |
+
bash scripts/inference.sh ${DOMAIN} ${MODEL} ${add_bos_token} ${MODEL_PARALLEL} ${N_GPU}
|
108 |
+
```
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
## Citation
|
112 |
If you find our work helpful, please cite us:
|