Competition question link | Competition question promotion page
? FinGLM : Committed to building an open, public welfare, and long-lasting large financial model project, using open source to promote "AI + finance."
[2023/11/23 Update] Added course content for the 1st, 2nd and 3rd generation ChatGLM-6B models, including PPT, videos and technical documents.
【2023/11/17 Update】Added a new solution "Name it Whatever"
? A conversational interactive intelligent system designed to deeply analyze annual reports of listed companies. In the face of professional terms and implicit information in financial texts, we are committed to using AI to achieve expert-level financial analysis.
In the field of AI, although progress has been made in text dialogue, real financial interaction scenarios are still a huge challenge. Multiple institutions jointly organized this competition to explore the boundaries of AI in the financial field.
The annual report of a listed company presents the company's operating status, financial status and future plans to investors. Expertise is the key to interpretation, and our goal is to make this process easier and more accurate through AI technology.
PDF to TXT :
Data segmentation :
Data processing :
Save to database :
Data classification : such as SQL data, ES data, etc.
Select a fine-tuning strategy : such as ptuningv2, lora, etc.
Perform fine-tuning : based on selected strategy.
1) Event transformation
2) Data open source
3) Open source solutions/codes/models
4) Open communication
5) Study tutorials
6) Project resource pool
First issue:
pdf2txt.py
to parse PDF files. Second issue:
Project introduction blog:
[PPT] [Video][Code]
This project is an integration of the Anshuoshuo Eye Exploration Enterprise Team based on its own project and the projects of several other teams. We will continue to iterate and upgrade around this project in the future.
[PPT] [Video] [Code]
[PPT] [Video] [Code]
[PPT] [Video] [Code]
[PPT] [Video] [Code]
[PPT] [Video] [Code]
[PPT] [Video] [Code]
[PPT] [Video] [Code]
[PPT] [Video] [Code]
[PPT] [Video] [Code]
[PPT] [Video][Code]
Our open source data set covers the annual reports of some listed companies from 2019 to 2021. This data set contains a total of 11588 detailed PDF files (list). You can use the contents of these PDF files to build the database or vector library you need. In order to avoid wasting computing resources, we also convert the corresponding files into TXT files and HTML files for everyone to use.
Size: 69GB File format: pdf file Number of files: 11588
git load
# 要求安装 git lfs
git clone http://www.modelscope.cn/datasets/modelscope/chatglm_llm_fintech_raw_dataset.git
sdk loading
# Note:
# 1. 【重要】请将modelscope sdk升级到v1.7.2rc0,执行: pip3 install "modelscope==1.7.2rc0" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
# 2. 【重要】datasets版本限制为 >=2.8.0, <=2.13.0,可执行: pip3 install datasets==2.13.0
from modelscope.msdatasets import MsDataset
# 使用流式方式加载「推荐」
# 无需全量加载到cache,随下随处理
# 其中,通过设置 stream_batch_size 可以使用batch的方式加载
ds = MsDataset.load('chatglm_llm_fintech_raw_dataset', split='train', use_streaming=True, stream_batch_size=1)
for item in ds:
print(item)
# 加载结果示例(单条,pdf:FILE字段值为该pdf文件本地缓存路径,文件名做了SHA转码,可以直接打开)
{'name': ['2020-03-24__北京鼎汉技术集团股份有限公司__300011__鼎汉技术__2019年__年度报告.pdf'], 'pdf:FILE': ['~/.cache/modelscope/hub/datasets/modelscope/chatglm_llm_fintech_raw_dataset/master/data_files/430da7c46fb80d4d095a57b4fb223258ffa1afe8bf53d0484e3f2650f5904b5c']}
# 备注:
1. 自定义缓存路径,可以自行设置cache_dir参数,即 MsDataset.load(..., cache_dir='/to/your/path')
2. 补充数据加载(从9493条增加到11588条),sdk加载注意事项
a) 删除缓存中的csv映射文件(默认路径为): ~/.cache/modelscope/hub/datasets/modelscope/chatglm_llm_fintech_raw_dataset/master/data_files/732dc4f3b18fc52380371636931af4c8
b) 使用MsDataset.load(...) 加载,默认会reuse已下载过的文件,不会重复下载。
Note: Convert pdf to txt format file for easy reuse (one file is damaged, so the total number is 1 less than pdf, 11587 in total)
# Linux
wget https://sail-moe.oss-cn-hangzhou.aliyuncs.com/open_data/hackathon_chatglm_fintech/alltxt.zip
# Windows示例
Invoke-WebRequest -Uri https://sail-moe.oss-cn-hangzhou.aliyuncs.com/open_data/hackathon_chatglm_fintech/alltxt.zip -OutFile D:\alltxt.zip
Note: Convert pdf to html format files for easy reuse (one file is damaged, so the total number is less than pdf, 11582 in total)
# Linux
wget https://sail-moe.oss-cn-hangzhou.aliyuncs.com/open_data/hackathon_chatglm_fintech/allhtml.zip
# Windows示例
Invoke-WebRequest -Uri https://sail-moe.oss-cn-hangzhou.aliyuncs.com/open_data/hackathon_chatglm_fintech/allhtml.zip -OutFile D:\allhtml.zip
Here are our recommended steps:
1. PDF text and table extraction: You can use toolkits such as pdfplumber and pdfminer to extract text and table data from PDF files.
2. Data segmentation: According to the directory, subdirectory and chapter information of the PDF file, the content is accurately segmented.
3. Build a basic financial database: Design professional financial database fields and formats based on financial knowledge and PDF content. For example, define the balance sheet, cash flow statement, income statement, etc.
4. Information extraction: Use the information extraction capabilities of large models and NLP technology to extract corresponding financial field information. For example, please use json mode to output the contents of the directory, in which the name of the chapter is used as the key and the page number is used as the value. At the same time, please extract the data in the table in detail and output it in JSON format.
5. Construct a financial knowledge question and answer library: Combined with the constructed financial database, apply large models to build a basic financial question and answer library. For example,
{"question":"某公司2021年的财务费用为多少元?", "answer": "某公司2021年的财务费用为XXXX元。"}
prompt:用多种句式修改question及answer的内容。
{"question":"为什么财务费用可以是负的?", "answer": ""}
prompt:请模仿上面的question给出100个类似的问题与对应的答案,用json输出。
6. Build a vector library: With the help of technologies such as Word2Vec and Text2Vec, semantic vectors are extracted from original text data. Use pgvector, a PostgreSQL-based extension, to store and index these vectors to build a large-scale vector library that can be queried efficiently.
7. Application: Combined with vector libraries, large models, langchain and other tools to improve application effects.
In the SMP 2023 ChatGLM Financial Large Model Challenge, we conducted preliminary round, semi-final A, semi-final B, and semi-final C respectively. For these rounds of competition, we manually annotated relevant data, with a total of 10,000 entries.
Data example:
{ "ID" : 1 ,
"question" : "2019年中国工商银行财务费用是多少元?" ,
"answer" : "2019年中国工商银行财务费用是12345678.9元。" }
{ "ID" : 2 ,
"question" : "工商银行2019年营业外支出和营业外收入分别是多少元?" ,
"answer" : "工商银行2019年营业外支出为12345678.9元,营业外收入为2345678.9元。" }
{ "ID" : 3 ,
"question" : "中国工商银行2021年净利润增长率是多少?保留2位小数。" ,
"answer" : "中国工商银行2020年净利润为12345678.90元,2021年净利润为22345678.90元,根据公式,净利润增长率=(净利润-上年净利润)/上年净利润,得出结果中国工商银行2021年净利润增长率81.00%。" }
At the same time, we also wrote the review code for the competition. We rely on:
Evaluation example:
{ "question" : "2019年中国工商银行财务费用是多少元?" ,
"prompt" : { "财务费用" : "12345678.9元" , "key_word" : "财务费用、2019" , "prom_answer" : "12345678.9元" },
"answer" : [
"2019年中国工商银行财务费用是12345678.9元。" ,
"2019年工商银行财务费用是12345678.9元。" ,
"中国工商银行2019年的财务费用是12345678.9元。" ]
}
Evaluation calculation example:
Answer 1: ICBC’s financial expenses in 2019 were 123,456,78.9 yuan.
most similar sentences:
The financial expenses of ICBC in 2019 were 12345678.9 yuan. (Score: 0.9915)
The financial expenses of Industrial and Commercial Bank of China in 2019 were 12345678.9 yuan. (Score: 0.9820)
The financial expenses of Industrial and Commercial Bank of China in 2019 were 12345678.9 yuan. (Score: 0.9720)
Rating: 0.25+0.25+0.9915*0.5=0.9958 points.
Scoring explanation: prom_answer is correct, contains all key_words, and has the highest similarity of 0.9915.
Answer 2: The financial expenses of ICBC in 2019 are 335,768.91 yuan.
Rating: 0 points.
Scoring explanation: Prom_answer errors are not scored.
Answer three: 12345678.9 yuan.
most similar sentences:
The financial expenses of ICBC in 2019 were 12345678.9 yuan. (Score: 0.6488)
The financial expenses of Industrial and Commercial Bank of China in 2019 were 12345678.9 yuan. (Score: 0.6409)
The financial expenses of Industrial and Commercial Bank of China in 2019 were 12345678.9 yuan. (Score: 0.6191)
Rating: 0.25+0+0.6488*0.5=0.5744 points.
Scoring explanation: prom_answer is correct, does not contain all key_words, and has the highest similarity of 0.6488.
{ "id" : 0 , "question" : "2021年其他流动资产第12高的是哪家上市公司?" , "answer" : "2021年其他流动资产第12高的公司是苏美达股份有限公司。" }
{ "id" : 1 , "question" : "注册地址在重庆的上市公司中,2021年营业收入大于5亿的有多少家?" , "answer" : "2021年注册在重庆,营业收入大于5亿的公司一共有4家。" }
{ "id" : 2 , "question" : "广东华特气体股份有限公司2021年的职工总人数为?" , "answer" : "2021年广东华特气体股份有限公司职工总人数是1044人。" }
{ "id" : 3 , "question" : "在保留两位小数的情况下,请计算出金钼股份2019年的流动负债比率" , "answer" : "2019金钼股份流动负债比率是61.10%。其中流动负债是1068418275.97元;总负债是1748627619.69元;" }
{ "id" : 4 , "question" : "2019年负债总金额最高的上市公司为?" , "answer" : "2019年负债合计最高的是上海汽车集团股份有限公司。" }
{ "id" : 5 , "question" : "2019年总资产最高的前五家上市公司是哪些家?" , "answer" : "2019年资产总计最高前五家是上海汽车集团股份有限公司、中远海运控股股份有限公司、国投电力控股股份有限公司、华域汽车系统股份有限公司、广州汽车集团股份有限公司。" }
{ "id" : 6 , "question" : "2020年营业收入最高的3家并且曾经在宁波注册的上市公司是?金额是?" , "answer" : "注册在宁波,2020年营业收入最高的3家是宁波均胜电子股份有限公司营业收入47889837616.15元;宁波建工股份有限公司营业收入19796854240.57元;宁波继峰汽车零部件股份有限公司营业收入15732749552.37元。" }
{ "id" : 7 , "question" : "注册地址在苏州的上市公司中,2020年利润总额大于5亿的有多少家?" , "answer" : "2020年注册在苏州,利润总额大于5亿的公司一共有2家。" }
{ "id" : 8 , "question" : "浙江运达风电股份有限公司在2019年的时候应收款项融资是多少元?" , "answer" : "2019年浙江运达风电股份有限公司应收款项融资是51086824.07元。" }
{ "id" : 9 , "question" : "神驰机电股份有限公司2020年的注册地址为?" , "answer" : "2020年神驰机电股份有限公司注册地址是重庆市北碚区童家溪镇同兴北路200号。" }
{ "id" : 10 , "question" : "2019年山东惠发食品股份有限公司营业外支出和营业外收入分别是多少元?" , "answer" : "2019年山东惠发食品股份有限公司营业外收入是1018122.97元;营业外支出是2513885.46元。" }
{ "id" : 11 , "question" : "福建广生堂药业股份有限公司2020年年报中提及的财务费用增长率具体是什么?" , "answer" : "2020福建广生堂药业股份有限公司财务费用增长率是34.33%。其中,财务费用是7766850.48元;上年财务费用是5781839.51元。" }
{ "id" : 12 , "question" : "华灿光电股份有限公司2021年的法定代表人与上年相比相同吗?" , "answer" : "不相同,华灿光电股份有限公司2020年法定代表人是俞信华,2021年法定代表人是郭瑾。" }
{ "id" : 13 , "question" : "请具体描述一下2020年仲景食品控股股东是否发生变更。" , "answer" : "2020年,仲景食品控股股东没有发生变更。" }
{ "id" : 14 , "question" : "什么是其他债权投资?" , "answer" : "其他债权投资是指企业或机构投资者通过购买债券、贷款、定期存款等金融产品获得的固定收益。这些金融产品通常由政府、公司或其他机构发行,具有一定的信用等级和风险。 n n其他债权投资是企业或机构投资组合中的一部分,通常用于稳定收益和分散风险。与股票投资相比,其他债权投资的风险较低,但收益也相对较低。 n n其他债权投资的管理和投资策略与其他资产类别类似,包括分散投资、风险控制、收益最大化等。然而,由于其他债权投资的种类繁多,其投资和管理也存在一定的特殊性。" }
[PPT] [Video][Technical Documentation]
[PPT] [Video][Technical Documentation]
[PPT] [Video][Technical Documentation]
The following are the teams and individuals who contributed to this project:
The FinGLM open source project is for completely public welfare purposes, and all developers are welcome to apply to join. Of course, we will conduct strict review. If interested, please fill out the form.
The resources related to this project are only for research and communication, and are generally not recommended for commercial use. If used for commercial purposes, please bear the legal risks incurred.
When it comes to the commercial use of models, please be sure to follow the protocols of the relevant models, such as ChatGLM-6B.