計畫簡介
FinRobot是由AI4Finance基金會開發的一個開源AI代理平台,專為金融套用設計。這個平台使用大型語言模型(LLMs)作為核心技術,致力於透過智慧代理解決復雜的金融問題。它包括多層架構,如金融AI代理層、金融LLMs演算法層、LLMOps和DataOps層,以及多源LLM基礎模型層,支持多樣化的金融分析和操作,如市場預測、檔分析和交易策略。此外,FinRobot還具有智慧排程器,最佳化模型的整合和選擇。
掃碼加入AI交流群
獲得更多技術支持和交流
(請註明自己的職業)
生態系
FinRobot生態系的整體架構分為四個獨特的層次,每個層次都旨在處理金融AI處理和套用的特定方面:
金融AI代理層: 現在,金融AI代理層包括金融鏈式思考(CoT)提示功能,增強了復雜分析和決策能力。市場預測代理、檔分析代理和交易策略代理利用CoT將金融挑戰分解為邏輯步驟,將他們的先進演算法和領域專業知識與金融市場的動態演變相結合,以提供精確、可操作的洞察。
金融LLMs演算法層: 金融LLMs演算法層配置和使用專門調整的模型,針對特定領域和全球市場分析。
LLMOps和DataOps層: LLMOps層實施多源整合策略,為特定的金融任務選擇最合適的LLMs,使用一系列最先進的模型。
多源LLM基礎模型層: 這個基礎層支持各種通用和專用LLM的隨插即用功能。
工作流程
感知模組:該模組捕捉並解釋來自市場資料來源、新聞和經濟指標的多模態金融數據。它采用先進技術對數據進行結構化,以便進行全面分析。
大腦模組:作為核心處理單元,該模組從感知模組接收數據,並利用大型語言模型(LLMs)及金融思維鏈(CoT)過程生成結構化指令。
行動模組:該模組執行來自大腦模組的指令,套用工具將分析洞察轉化為可行的結果。行動包括交易、投資組合調整、生成報告或發送警報,從而積極影響金融環境。
智慧排程器
智慧排程器是確保模型多樣性並最佳化每個任務最適合的LLM的選擇和整合的核心。
導向代理: 該元件指揮任務分配過程,確保根據代理的效能指標和特定任務的適用性來分配任務。
代理註冊: 管理代理的註冊並跟蹤系統內代理的可用性,促進高效的任務分配過程。
代理介面卡: 客製代理功能以適應特定任務,提高其在整個系統中的效能和整合度。
工作管理員: 管理和儲存為各種金融任務客製的不同的通用及精細調整的基於LLM的代理,定期更新以確保其相關性和效果。
DEMO
1.市場預測代理(預測股票走向)
輸入一個公司的股票程式碼、近期基本財務數據和市場新聞,預測其股票走勢。
·輸入
import autogen
from finrobot.utils import get_current_date, register_keys_from_json
from finrobot.agents.workflow import SingleAssistant
·配置
# Read OpenAI API keys from a JSON file
llm_config = {
"config_list": autogen.config_list_from_json(
"../OAI_CONFIG_LIST",
filter_dict={"model": ["gpt-4-0125-preview"]},
),
"timeout": 120,
"temperature": 0,
}
# Register FINNHUB API keys
register_keys_from_json("../config_api_keys")
·執行
company = "NVDA"
assitant = SingleAssistant(
"Market_Analyst",
llm_config,
# set to "ALWAYS"if you want to chat instead of simply receiving the prediciton
human_input_mode="NEVER",
)
assitant.chat(
f"Use all the tools provided to retrieve information available for {company} upon {get_current_date()}. Analyze the positive developments and potential concerns of {company} "
"with 2-4 most important factors respectively and keep them concise. Most factors should be inferred from company related news. "
f"Then make a rough prediction (e.g. up/down by 2-3%) of the {company} stock price movement for next week. Provide a summary analysis to support your prediction."
)
·結果
2. 財務分析代理用於撰寫報告(股權研究報告)
輸入一個公司的10-k表格、財務數據和市場數據,輸出一個股權研究報告。
·輸入
import os
import autogen
from textwrap import dedent
from finrobot.utils import register_keys_from_json
from finrobot.agents.workflow import SingleAssistantShadow
·配置
llm_config = {
"config_list": autogen.config_list_from_json(
"../OAI_CONFIG_LIST",
filter_dict={
"model": ["gpt-4-0125-preview"],
},
),
"timeout": 120,
"temperature": 0.5,
}
register_keys_from_json("../config_api_keys")
# Intermediate strategy modules will be saved in this directory
work_dir = "../report"
os.makedirs(work_dir, exist_ok=True)
assistant = SingleAssistantShadow(
"Expert_Investor",
llm_config,
max_consecutive_auto_reply=None,
human_input_mode="TERMINATE",
)
·執行
company = "Microsoft"
fyear = "2023"
message = dedent(
f"""
With the tools you've been provided, write an annual report based on {company}'s {fyear} 10-k report, format it into a pdf.
Pay attention to the followings:
- Explicitly explain your working plan before you kick off.
- Use tools one by one for clarity, especially when asking for instructions.
- All your file operations should be done in "{work_dir}".
- Display any image in the chat once generated.
- All the paragraphs should combine between 400 and 450 words, don't generate the pdf until this is explicitly fulfilled.
"""
)
assistant.chat(message, use_cache=True, max_turns=50,
summary_method="last_msg")
·結果
金融報告任務:
· 收集初步數據:10-K 報告、市場數據、財務比率
· 分析財務報表:資產負債表、損益表、現金流量表
· 公司概況和業績:公司描述、業務亮點、部門分析
· 風險評估:評估風險
· 財務表現視覺化:繪制市盈率和每股收益
· 綜合發現成段落:將所有部份合成一個連貫的總結
· 生成 PDF 報告:使用工具自動生成 PDF
· 品質保證:檢查字數
計畫連結
https://github.com/AI4Finance-Foundation/FinRobot
關註「 開源AI計畫落地 」公眾號
與AI時代更靠近一點