金融领域开源大模型来了!


FinGPT[1] 是一个开源的创新平台,专为金融行业定制大语言模型(LLMs)。该框架由四大核心要素构成:数据来源、数据工程处理、大语言模型(LLMs)以及应用实施。这些要素共同确保了 FinGPT 的功能性和对金融环境变化的适应能力。

FinGPT 以数据为核心,重视数据的采集、净化和预处理工作,构建了一个从数据源到数据工程,再到模型构建和应用实现的全面框架。
为了应对金融数据的快速变化特性,FinGPT 采用了轻量级的低秩适应技术以及强化学习策略对模型进行精准调整。通过这些技术,FinGPT 能够灵活地适应金融市场的即时变动。FinGPT 的应用前景广阔,包括智能投顾、算法交易、风险管理等。
近期热文
当 AI 遇上爬虫:让数据提取变得前所未有的简单!
超强 OCR 神器:支持批量 OCR、文档识别、公式识别,离线可用、完全免费!
2024 年最完整的 AI Agents 清单来了,涉及 13 个领域,上百个 Agents!
FinGPT 股价走势预测
FinGPT-Forecaster[2] 将过去几周与指定公司相关的随机市场新闻和可选基本财务数据作为输入,并对公司的积极发展和潜在问题做出回应。然后,它会给出未来一周的股价走势预测及其分析摘要。
FinGPT 生态
FinGPT RAG[3]
一个定制化的金融情绪分析框架,利用增强型大型语言模型,通过整合外部知识库检索,增强了信息的深度和上下文理解,确保进行精确细致的预测分析。
FinGPT FinNLP[4]
FinNLP 构建了一个面向金融领域 LLM 和 NLP 爱好者的综合平台,它提供了一套完整的训练和微调流程,专为金融领域的语言模型定制。
FinGPT Benchmark[5]
FinGPT 开发团队引入了一种针对金融领域开源大型语言模型(LLM)进行优化的新型指令调整范式,增强了这些模型对各种金融数据集的适应性,同时还有助于从特定任务、多任务和零次指令调整任务中进行经济高效的系统基准测试。
FinGPT 数据集与模型
数据集
模型
FinGPT 快速上手
下面,我将介绍如何使用 FinGPT/fingpt-sentiment_llama2-13b_lora[6] 实现情感分析。
1.安装依赖
!pip install transformers==4.32.0 peft==0.5.0!pip install sentencepiece!pip install accelerate!pip install torch!pip install peft!pip install datasets!pip install bitsandbytes
2.运行推理
from transformers import AutoModel, AutoTokenizer, AutoModelForCausalLM, LlamaForCausalLM, LlamaTokenizerFastfrom peft import PeftModel  # 0.5.0# Load Modelsbase_model = "NousResearch/Llama-2-13b-hf" peft_model = "FinGPT/fingpt-sentiment_llama2-13b_lora"tokenizer = LlamaTokenizerFast.from_pretrained(base_model, trust_remote_code=True)tokenizer.pad_token = tokenizer.eos_tokenmodel = LlamaForCausalLM.from_pretrained(base_model, trust_remote_code=True, device_map = "cuda:0", load_in_8bit = True,)model = PeftModel.from_pretrained(model, peft_model)model = model.eval()# Make promptsprompt = ['''Instruction: What is the sentiment of this news? Please choose an answer from {negative/neutral/positive}Input: FINANCING OF ASPOCOMP 'S GROWTH Aspocomp is aggressively pursuing its growth strategy by increasingly focusing on technologically more demanding HDI printed circuit boards PCBs .Answer: ''','''Instruction: What is the sentiment of this news? Please choose an answer from {negative/neutral/positive}Input: According to Gran , the company has no plans to move all production to Russia , although that is where the company is growing .Answer: ''','''Instruction: What is the sentiment of this news? Please choose an answer from {negative/neutral/positive}Input: A tinyurl link takes users to a scamming site promising that users can earn thousands of dollars by becoming a Google ( NASDAQ : GOOG ) Cash advertiser .Answer: ''',]# Generate resultstokens = tokenizer(prompt, return_tensors='pt', padding=True, max_length=512)res = model.generate(**tokens, max_length=512)res_sentences = [tokenizer.decode(i) for i in res]out_text = [o.split("Answer: ")[1] for o in res_sentences]# show resultsfor sentiment in out_text:    print(sentiment)# Output:    # positive# neutral# negative
https://github.com/AI4Finance-Foundation/FinGPT
往期文章
超强 MedicalGPT:训练医疗领域大模型,支持 Qwen-2 和 Llama-3 等十几种开源模型!
30.3K Star 超强工具:让你用本地微信聊天记录,训练你的专属 AI 聊天助手!
开源流式数字人来了:实现音视频同步对话,基本可达商用效果!
PDF 转 Markdown 神器,精准且快速:支持 90 多种语言 OCR,还支持提取表格、图片和公式!
自动化爬虫神器:把网页转成大模型所需数据,助力 AI 应用与大模型训练全面优化!
欢迎您与我交流 AI 技术/工具

关注 AI 真好玩,带你玩转各类 AI 工具,掌控数字未来!
如果这篇文章对您有所帮助,请点赞、关注,并分享给您的朋友。感谢您的支持!
参考资料
[1] 
FinGPT: https://github.com/AI4Finance-Foundation/FinGPT[2] 
FinGPT-Forecaster: https://huggingface.co/spaces/FinGPT/FinGPT-Forecaster[3] 
FinGPT RAG: https://github.com/AI4Finance-Foundation/FinGPT/tree/master/fingpt/FinGPT_RAG[4] 
FinGPT FinNLP: https://github.com/AI4Finance-Foundation/FinNLP[5] 
FinGPT Benchmark: https://github.com/AI4Finance-Foundation/FinGPT/tree/master/fingpt/FinGPT_Benchmark[6] 
FinGPT/fingpt-sentiment_llama2-13b_lora: https://huggingface.co/FinGPT/fingpt-sentiment_llama2-13b_lora
到顶部