🚀 FinanceConnect
FinanceConnect是一款先進的開源聊天模型,專為金融和經濟領域的交流而設計。它基於強大的Llama2 - 13B架構構建,並在FinTalk - 19k和Alpaca數據集的組合上進行了微調,是金融專業人士、研究人員和愛好者的寶貴資源。
🚀 快速開始
FinanceConnect專為金融和經濟對話量身打造,藉助其強大功能,用戶可以輕鬆獲取金融領域的見解和信息。若要體驗FinanceConnect模型的能力,可通過精心設計的Python接口實現。以下是使用步驟和代碼片段:
前提條件
1. 確保所需包已安裝
import torch
from typing import Any, Dict
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
HfArgumentParser,
TrainingArguments,
PreTrainedTokenizerFast,
pipeline,
logging,
)
import time
2. 初始化模型和分詞器
model_name = "ceadar-ie/FinanceConnect-13B"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, load_in_8bit = True, device_map = "auto", trust_remote_code=True)
3. 創建文本生成函數
def generate_text(input_text):
tokenizer.padding_side = "right"
num_words_input = len(input_text.split())
start_time = time.time()
pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length = 1000)
prompt = f"<s>[INST] {input_text} [/INST]"
result = pipe(prompt)
generated_text = result[0]['generated_text'].replace(prompt, "").strip()
end_time = time.time()
time_taken = end_time - start_time
num_words_generated = len(generated_text.split())
print("Generated Output:")
print(generated_text)
print('=' * 60 )
print("\nNumber of Words in Input Text:", num_words_input)
print("Number of Words in Generated Output:", num_words_generated)
print("Time Taken to Generate Output: {:.2f} seconds".format(time_taken))
✨ 主要特性
- 領域專業化:FinanceConnect模型專注於金融對話,為金融研究人員和愛好者提供專業資源。
- 模型API可訪問性:提供簡單的Python集成方式,用於生成金融內容見解。
- 性能優化:在CPU和GPU平臺上均能高效運行。
- 數據表示:結合全面的金融數據集,使內容生成達到專業水平。
📦 模型詳情
屬性 |
詳情 |
架構 |
Llama2 - 13B |
訓練數據集 |
[FinTalk - 19k](https://huggingface.co/datasets/ceadar - ie/FinTalk - 19k),[Alpaca](https://huggingface.co/datasets/tatsu - lab/alpaca) |
開發者 |
CeADAR Connect Group |
模型類型 |
大語言模型 |
語言 |
英語 |
微調基礎模型 |
Llama2 - 13B |
📚 數據集使用情況
該模型藉助FinTalk - 19k和Alpaca數據集的優勢,這兩個數據集專注於金融知識,為模型提供了與金融行業相關的見解和信息。如需深入瞭解數據集,請訪問:[FinTalk - 19k](https://huggingface.co/datasets/ceadar - ie/FinTalk - 19k),[Alpaca](https://huggingface.co/datasets/tatsu - lab/alpaca)。
🔧 基準測試
基準測試 |
BloombergGPT 50B |
FinanceConnect 13B |
MMLU |
39.8 |
52.08 |
FPB |
51.1 |
57.2 |
成本 |
267萬美元 |
27美元 |
基準測試 |
FinanceConnect 13B |
MMLU |
52.08 |
ARC |
55.12 |
HellaSwag |
77.73 |
TruthfulQA |
38.80 |
Winogrande |
71.82 |
GSM8K |
1.6 |
💻 使用示例
基礎用法
以下是使用FinanceConnect模型的基礎示例,通過上述創建的generate_text
函數生成文本:
input_text = "List in detail ten key factors influencing the current state of the global economy."
generate_text(input_text)
高級用法
在實際應用中,用戶可以根據不同的金融場景,調整輸入文本以獲取更精準的信息。例如:
input_text = "Explain the concept of quantitative easing and its impact on financial markets."
generate_text(input_text)
🔧 訓練細節
訓練超參數
- per_device_train_batch_size = 10
- gradient_accumulation_steps = 4
- optim = "paged_adamw_32bit"
- learning_rate = 2e - 4
- max_grad_norm = 0.3
- warmup_ratio = 0.03
📄 許可證
FinanceConnect模型由CeADAR Connect Group開發,結合了Llama2、FinTalk - 8k和Alpaca的許可框架。根據Meta的條款,用戶被授予非排他性、全球性、不可轉讓、免版稅的有限許可,用於使用和修改Llama材料,包括Llama2模型及其相關文檔。在重新分發時,必須包含提供的協議和特定的歸屬聲明。此外,根據FinTalk數據集(Apache 2.0)和Alpaca數據集(cc - by - nc - 4.0)的許可,該模型在這三個許可的框架下進行分發。
⚠️ 模型侷限性
適用範圍外的使用
FinanceConnect專門為金融討論和知識交流而設計,不適用於以下情況:
- 一般對話。
- 金融領域之外的特定任務。
- 與物理設備或應用程序的直接交互。
偏差、風險和侷限性
- 數據集偏差:FinTalk - 19k和Alpaca數據集可能存在固有偏差,影響模型的輸出。
- 過度依賴:該模型是輔助工具,不能替代人類專業知識,決策時應謹慎考慮。
- 內容理解:模型缺乏人類般的理解能力,無法判斷知識的真實性。
- 語言限制:模型主要使用英語,使用其他語言時性能可能下降。
- 知識截止:模型可能不瞭解其最後一次訓練更新之後的事件或趨勢。
📖 引用
@misc {ceadar_2023,
author = { {CeADAR} },
title = { FinanceConnect-13B (Revision 5f7841d) },
year = 2023,
url = { https://huggingface.co/ceadar-ie/FinanceConnect-13B },
doi = { 10.57967/hf/1405 },
publisher = { Hugging Face }
}
📞 聯繫信息
如果您對FinanceConnect有任何進一步的疑問或反饋,請發送郵件至ahtsham.zafar@ucd.ie。