Views
No views yet

1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained("instruction-pretrain/finance-Llama3-8B")
4tokenizer = AutoTokenizer.from_pretrained("instruction-pretrain/finance-Llama3-8B")
5
6# Put your input here, NO prompt template is required
7user_input = '''Use this fact to answer the question: Title of each class Trading Symbol(s) Name of each exchange on which registered
8Common Stock, Par Value $.01 Per Share MMM New York Stock Exchange
9MMM Chicago Stock Exchange, Inc.
101.500% Notes due 2026 MMM26 New York Stock Exchange
111.750% Notes due 2030 MMM30 New York Stock Exchange
121.500% Notes due 2031 MMM31 New York Stock Exchange
13
14Which debt securities are registered to trade on a national securities exchange under 3M's name as of Q2 of 2023?'''
15
16inputs = tokenizer(user_input, return_tensors="pt", add_special_tokens=True).input_ids.to(model.device)
17outputs = model.generate(input_ids=inputs, max_new_tokens=400)[0]
18
19answer_start = int(inputs.shape[-1])
20pred = tokenizer.decode(outputs[answer_start:], skip_special_tokens=True)
21
22print(pred)1git clone https://github.com/microsoft/LMOps
2cd LMOps/adaptllm
3pip install -r requirements.txt1DOMAIN='finance'
2
3# if the model can fit on a single GPU: set MODEL_PARALLEL=False
4# elif the model is too large to fit on a single GPU: set MODEL_PARALLEL=True
5MODEL_PARALLEL=False
6
7# number of GPUs, chosen from [1,2,4,8]
8N_GPU=1
9
10# Set as True
11add_bos_token=True
12
13bash scripts/inference.sh ${DOMAIN} 'instruction-pretrain/finance-Llama3-8B' ${add_bos_token} ${MODEL_PARALLEL} ${N_GPU}1@inproceedings{
2cheng2024adapting,
3title={Adapting Large Language Models via Reading Comprehension},
4author={Daixuan Cheng and Shaohan Huang and Furu Wei},
5booktitle={The Twelfth International Conference on Learning Representations},
6year={2024},
7url={https://openreview.net/forum?id=y886UXPEZ0}
8}