GGUF
English
finance
Inference Endpoints
mav23 commited on
Commit
b57e701
1 Parent(s): 07202de

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. README.md +165 -0
  3. finance-llama3-8b.Q4_0.gguf +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ finance-llama3-8b.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3
3
+ language:
4
+ - en
5
+ tags:
6
+ - finance
7
+ datasets:
8
+ - Open-Orca/OpenOrca
9
+ - GAIR/lima
10
+ - WizardLM/WizardLM_evol_instruct_V2_196k
11
+ ---
12
+ # Instruction Pre-Training: Language Models are Supervised Multitask Learners (EMNLP 2024)
13
+ This repo contains the **finance model developed from Llama3-8B** in our paper [Instruction Pre-Training: Language Models are Supervised Multitask Learners](https://huggingface.co/papers/2406.14491).
14
+
15
+ We explore supervised multitask pre-training by proposing ***Instruction Pre-Training***, a framework that scalably augments massive raw corpora with instruction-response pairs to pre-train language models. The instruction-response pairs are generated by an efficient instruction synthesizer built on open-source models. ***Instruction Pre-Training* outperforms *Vanilla Pre-training* in both general pre-training from scratch and domain-adaptive continual pre-training.** In pre-training from scratch, *Instruction Pre-Training* not only improves pre-trained base models but also benefits more from further instruction tuning. **In continual pre-training, *Instruction Pre-Training* enables Llama3-8B to be comparable to or even outperform Llama3-70B.**
16
+
17
+ <p align='center'>
18
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/66711d2ee12fa6cc5f5dfc89/vRdsFIVQptbNaGiZ18Lih.png" width="400">
19
+ </p>
20
+
21
+ **************************** **Updates** ****************************
22
+ * 2024/9/20: Our paper has been accepted by EMNLP 2024 main conference🎉
23
+ * 2024/9/11: Updated [FAQ on continual pre-training from Llama3](https://huggingface.co/instruction-pretrain/instruction-synthesizer)
24
+ * 2024/8/29: Updated [guidelines](https://huggingface.co/instruction-pretrain/medicine-Llama3-8B) on evaluating any 🤗Huggingface models on the domain-specific tasks
25
+ * 2024/7/31: Updated pre-training suggestions in the `Advanced Usage` section of [instruction-synthesizer](https://huggingface.co/instruction-pretrain/instruction-synthesizer)
26
+ * 2024/7/15: We scaled up the pre-trained tokens from 100B to 250B, with the number of synthesized instruction-response pairs reaching 500M. The performance trend on downstream tasks throughout the pre-training process:
27
+ <p align='left'>
28
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/66711d2ee12fa6cc5f5dfc89/0okCfRkC6uALTfuNxt0Fa.png" width="500">
29
+ </p>
30
+ * 2024/6/21: Released the [paper](https://huggingface.co/papers/2406.14491), [code](https://github.com/microsoft/LMOps), and [resources](https://huggingface.co/instruction-pretrain)
31
+
32
+ ## Resources
33
+ **🤗 We share our data and models with example usages, feel free to open any discussions at [this page](https://huggingface.co/papers/2406.14491)! 🤗**
34
+
35
+ - Thanks to the demo [davanstrien/instruction-synthesizer](https://huggingface.co/spaces/davanstrien/instruction-synthesizer) for implementing our approach
36
+ - Context-Based Instruction Synthesizer: [instruction-synthesizer](https://huggingface.co/instruction-pretrain/instruction-synthesizer)
37
+ - Fine-Tuning Data for the Synthesizer: [ft-instruction-synthesizer-collection](https://huggingface.co/datasets/instruction-pretrain/ft-instruction-synthesizer-collection)
38
+ - General Models Pre-Trained from Scratch (on 100B tokes):
39
+ - [InstructLM-500M](https://huggingface.co/instruction-pretrain/InstructLM-500M)
40
+ - [InstructLM-1.3B](https://huggingface.co/instruction-pretrain/InstructLM-1.3B)
41
+ - Domain-Specific Models Pre-Trained from Llama3-8B:
42
+ - [Finance-Llama3-8B](https://huggingface.co/instruction-pretrain/finance-Llama3-8B)
43
+ - [Biomedicine-Llama3-8B](https://huggingface.co/instruction-pretrain/medicine-Llama3-8B)
44
+ - General Instruction-Augmented Corpora: [general-instruction-augmented-corpora](https://huggingface.co/datasets/instruction-pretrain/general-instruction-augmented-corpora)
45
+ - Domain-Specific Instruction-Augmented Corpora (no finance data to avoid ethical issues): [medicine-instruction-augmented-corpora](https://huggingface.co/datasets/instruction-pretrain/medicine-instruction-augmented-corpora)
46
+
47
+ ## Domain-Adaptive Continued Pre-Training
48
+ 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).
49
+
50
+ ### 1. To chat with the finance-Llama3-8B model:
51
+ ```python
52
+ from transformers import AutoModelForCausalLM, AutoTokenizer
53
+
54
+ model = AutoModelForCausalLM.from_pretrained("instruction-pretrain/finance-Llama3-8B")
55
+ tokenizer = AutoTokenizer.from_pretrained("instruction-pretrain/finance-Llama3-8B")
56
+
57
+ # Put your input here, NO prompt template is required
58
+ user_input = '''Use this fact to answer the question: Title of each class Trading Symbol(s) Name of each exchange on which registered
59
+ Common Stock, Par Value $.01 Per Share MMM New York Stock Exchange
60
+ MMM Chicago Stock Exchange, Inc.
61
+ 1.500% Notes due 2026 MMM26 New York Stock Exchange
62
+ 1.750% Notes due 2030 MMM30 New York Stock Exchange
63
+ 1.500% Notes due 2031 MMM31 New York Stock Exchange
64
+
65
+ Which debt securities are registered to trade on a national securities exchange under 3M's name as of Q2 of 2023?'''
66
+
67
+ inputs = tokenizer(user_input, return_tensors="pt", add_special_tokens=True).input_ids.to(model.device)
68
+ outputs = model.generate(input_ids=inputs, max_new_tokens=400)[0]
69
+
70
+ answer_start = int(inputs.shape[-1])
71
+ pred = tokenizer.decode(outputs[answer_start:], skip_special_tokens=True)
72
+
73
+ print(pred)
74
+ ```
75
+
76
+ ### 2. To evaluate any Huggingface LMs on domain-specific tasks (💡New!)
77
+ You can use the following script to reproduce our results and evaluate any other Huggingface models on domain-specific tasks. Note that the script is NOT applicable to models that require specific prompt templates (e.g., Llama2-chat, Llama3-Instruct).
78
+
79
+ 1). Set Up Dependencies
80
+ ```bash
81
+ git clone https://github.com/microsoft/LMOps
82
+ cd LMOps/adaptllm
83
+ pip install -r requirements.txt
84
+ ```
85
+
86
+ 2). Evaluate the Model
87
+ ```bash
88
+ # Select the domain from ['biomedicine', 'finance']
89
+ DOMAIN='finance'
90
+
91
+ # Specify any Huggingface LM name (Not applicable to models requiring specific prompt templates)
92
+ MODEL='instruction-pretrain/finance-Llama3-8B'
93
+
94
+ # Model parallelization:
95
+ # - Set MODEL_PARALLEL=False if the model fits on a single GPU.
96
+ # We observe that LMs smaller than 10B always meet this requirement.
97
+ # - Set MODEL_PARALLEL=True if the model is too large and encounters OOM on a single GPU.
98
+ MODEL_PARALLEL=False
99
+
100
+ # Choose the number of GPUs from [1, 2, 4, 8]
101
+ N_GPU=1
102
+
103
+ # Whether to add a BOS token at the beginning of the prompt input:
104
+ # - Set to False for AdaptLLM.
105
+ # - Set to True for instruction-pretrain models.
106
+ # If unsure, we recommend setting it to False, as this is suitable for most LMs.
107
+ add_bos_token=True
108
+
109
+ # Run the evaluation script
110
+ bash scripts/inference.sh ${DOMAIN} ${MODEL} ${add_bos_token} ${MODEL_PARALLEL} ${N_GPU}
111
+ ```
112
+
113
+ ## FAQ on Continual Pre-Training from LLama3
114
+ **Q1: Do you use the official Llama3 instruction prompt for pre-training?**
115
+
116
+ No, the provided Llama3 instruction prompt is designed for the [instruction-tuned model](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct), but our continual pre-training is conducted on the [pre-trained base model](https://huggingface.co/meta-llama/Meta-Llama-3-8B) where only BOS (`<|begin_of_text|>`) and EOS (`<|end_of_text|>`) tokens are required.
117
+
118
+ **Q2: For the general instructions from OpenOrca, do you concatenate each instruction with its output using '\n'?**
119
+
120
+ No, as mentioned in the pre-training suggestions, we use a simple whitespace to concatenate each question with its response for the general instruction data from OpenOrca. This is because OpenOrca's data is already templated with diverse natural languge templates (such as those with `\n`), so a whitespace is sufficient to formulate the data.
121
+
122
+ Note that when using our templated instruction-augmented texts, you don't need to add any concatenations.
123
+
124
+ **Q3: What about those system prompts in OpenOrca?**
125
+
126
+ We simply discard the system prompts.
127
+
128
+ **To put it all together, the text before tokenization looks like this:**
129
+
130
+ ```python
131
+ general_instruction_response_text = "<|begin_of_text|>{question} {response}<|end_of_text|>"
132
+
133
+ instruction_augmented_text = "<|begin_of_text|>{instruction augmented text}<|end_of_text|>"
134
+ ```
135
+ Then, for tokenization, you don't need to add BOS and EOS token ids. The tokenization code looks like this:
136
+ ```python
137
+ text_ids = tokenizer(text, add_special_tokens=False, **kwargs).input_ids
138
+ ```
139
+
140
+
141
+
142
+ ## Citation
143
+ If you find our work helpful, please cite us:
144
+
145
+ [Instruction Pre-Training](https://huggingface.co/papers/2406.14491) (EMNLP 2024)
146
+ ```bibtex
147
+ @article{cheng2024instruction,
148
+ title={Instruction Pre-Training: Language Models are Supervised Multitask Learners},
149
+ author={Cheng, Daixuan and Gu, Yuxian and Huang, Shaohan and Bi, Junyu and Huang, Minlie and Wei, Furu},
150
+ journal={arXiv preprint arXiv:2406.14491},
151
+ year={2024}
152
+ }
153
+ ```
154
+
155
+ [Adapt LLM to Domains](https://huggingface.co/papers/2309.09530) (ICLR 2024)
156
+ ```bibtex
157
+ @inproceedings{
158
+ cheng2024adapting,
159
+ title={Adapting Large Language Models via Reading Comprehension},
160
+ author={Daixuan Cheng and Shaohan Huang and Furu Wei},
161
+ booktitle={The Twelfth International Conference on Learning Representations},
162
+ year={2024},
163
+ url={https://openreview.net/forum?id=y886UXPEZ0}
164
+ }
165
+ ```
finance-llama3-8b.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3e5af50dd7663b9c6989229d862a7afddd8e979fb5e662680fe01e630b81317
3
+ size 4661211424