fin-llama

LLAMA specialized on finance

https://github.com/bavest/fin-llama

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.3%) to scientific vocabulary

Keywords

finance llama llm
Last synced: 6 months ago · JSON representation

Repository

LLAMA specialized on finance

Basic Info
  • Host: GitHub
  • Owner: Bavest
  • License: gpl-3.0
  • Language: Jupyter Notebook
  • Default Branch: main
  • Homepage:
  • Size: 27.1 MB
Statistics
  • Stars: 131
  • Watchers: 3
  • Forks: 24
  • Open Issues: 0
  • Releases: 0
Topics
finance llama llm
Created over 2 years ago · Last pushed over 2 years ago
Metadata Files
Readme Citation

README.md

alt text

FIN-LLAMA

Efficient Finetuning of Quantized LLMs for Finance

Adapter Weights | Dataset

Installation

To load models in 4bits with transformers and bitsandbytes, you have to install accelerate and transformers from source and make sure you have the latest version of the bitsandbytes library (0.39.0).

bash pip3 install -r requirements.txt

Other dependencies

If you want to finetune the model on a new instance. You could run the setup.sh to install the python and cuda package.

bash bash scripts/setup.sh

Finetuning

bash bash script/finetune.sh

Usage

Quantization parameters are controlled from the BitsandbytesConfig

  • Loading in 4 bits is activated through load_in_4bit
  • The datatype used for the linear layer computations with bnb_4bit_compute_dtype
  • Nested quantization is activated through bnb_4bit_use_double_quant
  • The datatype used for qunatization is specified with bnb_4bit_quant_type. Note that there are two supported quantization datatypes fp4 (four bit float) and nf4 (normal four bit float). The latter is theoretically optimal for normally distributed weights and we recommend using nf4.

```python import torch from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig

pretrainedmodelnameorpath = "bavest/fin-llama-33b-merged" model = AutoModelForCausalLM.frompretrained( pretrainedmodelnameorpath=pretrainedmodelnameorpath, loadin4bit=True, devicemap='auto', torchdtype=torch.bfloat16, quantizationconfig=BitsAndBytesConfig( loadin4bit=True, bnb4bitcomputedtype=torch.bfloat16, bnb4bitusedoublequant=True, bnb4bitquanttype='nf4' ), )

tokenizer = AutoTokenizer.frompretrained(pretrainedmodelnameor_path)

question = "What is the market cap of apple?" input = "" # context if needed

prompt = f""" A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's question. '### Instruction:\n{question}\n\n### Input:{input}\n""\n\n### Response: """

inputids = tokenizer.encode(prompt, returntensors="pt").to('cuda:0')

with torch.nograd(): generatedids = model.generate( inputids, dosample=True, topp=0.9, temperature=0.8, maxlength=128 )

generatedtext = tokenizer.decode( [el.item() for el in generatedids[0]], skipspecialtokens=True ) ```

Dataset for FIN-LLAMA

The dataset is released under bigscience-openrail-m. You can find the dataset used to train FIN-LLAMA models on HF at bavest/fin-llama-dataset.

Known Issues and Limitations

Here a list of known issues and bugs. If your issue is not reported here, please open a new issue and describe the problem. See QLORA for any other limitations.

  1. 4-bit inference is slow. Currently, our 4-bit inference implementation is not yet integrated with the 4-bit matrix multiplication
  2. Currently, using bnb_4bit_compute_type='fp16' can lead to instabilities.
  3. Make sure that tokenizer.bos_token_id = 1 to avoid generation issues.

Acknowledgements

We also thank Meta for releasing the LLaMA models without which this work would not have been possible.

This repo builds on the Stanford Alpaca , QLORA, Chinese-Guanaco and LMSYS FastChat repos.

License and Intended Use

We release the resources associated with QLoRA finetuning in this repository under GLP3 license. In addition, we release the FIN-LLAMA model family for base LLaMA model sizes of 7B, 13B, 33B, and 65B. These models are intended for purposes in line with the LLaMA license and require access to the LLaMA models.

Prompts

Act as an Accountant

I want you to act as an accountant and come up with creative ways to manage finances. You'll need to consider budgeting, investment strategies and risk management when creating a financial plan for your client. In some cases, you may also need to provide advice on taxation laws and regulations in order to help them maximize their profits. My first suggestion request is “Create a financial plan for a small business that focuses on cost savings and long-term investments".

Paged Optimizer

You can access the paged optimizer with the argument --optim pagedadamw32bit

Cite

tex @misc{Fin-LLAMA, author = {William Todt, Ramtin Babaei, Pedram Babaei}, title = {Fin-LLAMA: Efficient Finetuning of Quantized LLMs for Finance}, year = {2023}, publisher = {GitHub}, journal = {GitHub repository}, howpublished = {\url{https://github.com/Bavest/fin-llama}}, }

Owner

  • Name: Bavest Technologies
  • Login: Bavest
  • Kind: organization
  • Location: Germany

GitHub Events

Total
  • Watch event: 34
  • Fork event: 7
Last Year
  • Watch event: 34
  • Fork event: 7

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 7
  • Total Committers: 2
  • Avg Commits per committer: 3.5
  • Development Distribution Score (DDS): 0.143
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
monolidth w****t@m****g 6
mahwiz khalil 7****l 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 1
  • Total pull requests: 1
  • Average time to close issues: 10 days
  • Average time to close pull requests: 2 days
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 3.0
  • Average comments per pull request: 1.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • kid-gorgeous (1)
Pull Request Authors
  • mwzkhalil (1)
Top Labels
Issue Labels
Pull Request Labels