🚀 FinMA-7B-NLP
FinMA-7B-NLP是一款金融大語言模型(LLM),它是PIXIU項目的一部分。該模型旨在理解複雜的金融語言和概念,並經過微調以遵循自然語言指令,從而提升其在下游金融任務中的表現。具體而言,FinMA-7B-NLP僅在PIXIU數據集的NLP任務上進行訓練,因此它特別適用於情感分析、新聞標題分類、命名實體識別和問答等任務。
🚀 快速開始
使用Hugging Face Transformers庫
你可以在Python項目中使用Hugging Face Transformers庫來使用FinMA-7B-NLP模型。以下是加載該模型的簡單示例:
from transformers import LlamaTokenizer, LlamaForCausalLM
tokenizer = LlamaTokenizer.from_pretrained('ChanceFocus/finma-7b-nlp')
model = LlamaForCausalLM.from_pretrained('ChanceFocus/finma-7b-nlp', device_map='auto')
在這個示例中,LlamaTokenizer
用於加載分詞器,LlamaForCausalLM
用於加載模型。device_map='auto'
參數用於在GPU可用時自動使用GPU。
使用Hugging Face推理API
你還可以通過Hugging Face推理API使用該模型。這使你無需設置自己的推理環境即可生成文本。該模型可以按需在推理API上加載。
✨ 主要特性
- 專注金融領域:專門針對金融NLP任務進行訓練,能更好地理解和處理金融語言。
- 多模型協同:作為PIXIU項目的一部分,與其他模型(如FinMA-7B-full和FinMA-30B)協同,滿足不同的金融任務需求。
📦 安裝指南
使用該模型需要安裝Hugging Face Transformers庫,你可以使用以下命令進行安裝:
pip install transformers
💻 使用示例
基礎用法
from transformers import LlamaTokenizer, LlamaForCausalLM
tokenizer = LlamaTokenizer.from_pretrained('ChanceFocus/finma-7b-nlp')
model = LlamaForCausalLM.from_pretrained('ChanceFocus/finma-7b-nlp', device_map='auto')
input_text = "請分析這條金融新聞的情感傾向"
input_ids = tokenizer(input_text, return_tensors='pt').input_ids
output = model.generate(input_ids)
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
print(generated_text)
📚 詳細文檔
PIXIU項目中的其他模型
除了FinMA-7B-NLP,PIXIU項目還包括另外兩個模型:
- FinMA-7B-full:該模型使用PIXIU數據集的完整指令數據進行訓練,涵蓋NLP和預測任務。這使其成為一個更全面的模型,能夠處理更廣泛的金融任務。
- FinMA-30B:該模型是FinMA的更大版本,在LLaMA-30B模型上進行微調。與FinMA-7B-NLP一樣,它使用NLP指令數據進行訓練。
關於項目
該模型是PIXIU項目的一部分,PIXIU是一個開源資源,包含首個金融大語言模型(LLM)、指令調優數據和評估基準,用於全面評估金融LLM。其目標是持續推動金融人工智能(AI)的開源發展。
如需更多信息,你可以訪問GitHub上的PIXIU項目。
📄 許可證
FinMA-7B-NLP採用MIT許可證。更多詳細信息,請參閱MIT文件。
📚 引用
如果你在工作中使用了FinMA-7B-NLP,請引用PIXIU論文:
@misc{xie2023pixiu,
title={PIXIU: A Large Language Model, Instruction Data and Evaluation Benchmark for Finance},
author={Qianqian Xie and Weiguang Han and Xiao Zhang and Yanzhao Lai and Min Peng and Alejandro Lopez-Lira and Jimin Huang},
year={2023},
eprint={2306.05443},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
📋 模型信息
屬性 |
詳情 |
數據集 |
chancefocus/pixiu、ChanceFocus/FLUPE |
語言 |
en |
推理 |
false |
許可證 |
mit |
評估指標 |
accuracy、exact_match、f1 |
庫名稱 |
transformers |
標籤 |
finance、llama、llms |