nekomata-7b-pfn-qfin

Model Description

nekomata-7b-pfn-qfin is a fine-tuned model based on rinna/nekomata-7b. This is the base model, which is good at generating continuous sentences for finance. nekomata-7b-pfn-qfin is fine-tuned on 370M tokens from multiple special datasets generated by Preferred Networks, which is clear to use for commercial usage. The fine-tuned were carried out at a 2048 context length. This model is released under Tongyi Qianwen LICENSE AGREEMENT.

The research article is available on arXiv.

Benchmarking

The benchmark score is obtained using Japanese Language Model Financial Evaluation Harness For the benchmark, 0-shot and default prompts are used.

|      Task      |Metric|  nekomaba-7b   |       Ours      |
|----------------|------|------|---|------|------|---|------|
|chabsa          |f1    |0.8134|   |      |0.8127|   |      |
|cma_basics      |acc   |0.3158|±  |0.0764|0.3684|±  |0.0793|
|cpa_audit       |acc   |0.2085|±  |0.0203|0.1809|±  |0.0193|
|fp2             |acc   |0.2484|±  |0.0198|0.2674|±  |0.0203|
|security_sales_1|acc   |0.4912|±  |0.0668|0.5088|±  |0.0668|
|----------------|------|------|---|------|------|---|------|
|OVER ALL        |      |0.4155           |0.4276           |

Usage

Install the required libraries as follows:

>>> python -m pip install numpy sentencepiece torch transformers accelerate transformers_stream_generator tiktoken einops

Execute the following python code:

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("pfnet/nekomata-7b-pfn-qfin", trust_remote_code=True)

# Use GPU with bf16 (recommended for supported devices)
# model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-7b-pfn-qfin", device_map="auto", trust_remote_code=True, bf16=True)

# Use GPU with fp16
# model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-7b-pfn-qfin", device_map="auto", trust_remote_code=True, fp16=True)

# Use GPU with fp32
# model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-7b-pfn-qfin", device_map="auto", trust_remote_code=True, fp32=True)

# Use CPU
# model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-7b-pfn-qfin", device_map="cpu", trust_remote_code=True)

# Automatically select device and precision
model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-7b-pfn-qfin", device_map="auto", trust_remote_code=True)

text = "日本銀行は"
input_ids = tokenizer(text, return_tensors="pt").input_ids.to(model.device)
with torch.no_grad():
  generated_tokens = model.generate(
      inputs=input_ids,
      max_new_tokens=32,
      do_sample=True,
      temperature=1.0,
      repetition_penalty=1.1
  )[0]
generated_text = tokenizer.decode(generated_tokens)
print(generated_text)
# 日本銀行は、2016年9月に「長短金利操作付き量的・質的金融緩和」を導入し、長期国

Model Details

  • Model size: 7b
  • Fine-tuned tokens: 370M tokens (Japanese: 300M tokens, English: 13M tokens, Digits: 14M tokens)
  • Context length: 2048
  • Developed by: Preferred Networks, Inc
  • Model type: Causal decoder-only
  • Language(s): Japanese and English
  • License: Tongyi Qianwen LICENSE AGREEMENT

Bias, Risks, and Limitations

nekomata-7b-pfn-qfin is a new technology that carries risks with use. Testing conducted to date has been in English and Japanese, and has not covered, nor could it cover all scenarios. For these reasons, as with all LLMs, nekomata-7b-pfn-qfin’s potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate, biased or other objectionable responses to user prompts. This model is not designed for legal, tax, investment, financial, or other advice. Therefore, before deploying any applications of nekomata-7b-pfn-qfin, developers should perform safety testing and tuning tailored to their specific applications of the model.

How to cite

@misc{hirano2024,
      title={Construction of Domain-specified Japanese Large Language Model for Finance through Continual Pre-training}, 
      author={Masanori Hirano and Kentaro Imajo},
      year={2024},
      eprint={2404.10555},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Contributors

Preferred Networks, Inc.

  • Masanori Hirano
  • Kentaro Imajo

License

Tongyi Qianwen LICENSE AGREEMENT

Downloads last month
21
Safetensors
Model size
7.72B params
Tensor type
BF16
·
Inference Examples
Inference API (serverless) does not yet support model repos that contain custom code.