当前位置: 首页 > news >正文

个人网站icp备案教程百度网页版下载

个人网站icp备案教程,百度网页版下载,java 网站建设,如何做网站的二级页面选择金融领域的专业文档作为源文件 这里选择 《博金大模型挑战赛-金融千问14b数据集》,这个数据集包含若干公司的年报,我们将利用这个年报搭建金融问答机器人。 具体下载地址 这里 git clone https://www.modelscope.cn/datasets/BJQW14B/bs_challenge_…

选择金融领域的专业文档作为源文件

这里选择 《博金大模型挑战赛-金融千问14b数据集》,这个数据集包含若干公司的年报,我们将利用这个年报搭建金融问答机器人。
具体下载地址 这里

在这里插入图片描述

git clone https://www.modelscope.cn/datasets/BJQW14B/bs_challenge_financial_14b_dataset.git

具体目录如下:
在这里插入图片描述
这里直接使用已经识别的纯文本数据,即pdf_txt_file目录下的文件。

选择词向量模型

这里选用m3e-base。M3E是专注于中文文本处理,具有强大的文本处理能力和灵活的部署选项,适合资源受限或需要私有化的应用场景

这里

在这里插入图片描述

git clone https://www.modelscope.cn/Jerry0/m3e-base.git

读取与清洗数据

1, 读取文件列表

import osdir_path = "bs_challenge_financial_14b_dataset/pdf_txt_file"
all_files = os.listdir(dir_path)
print(all_files)

在这里插入图片描述
2,清洗数据
从结果我们可以观察到文件名都是乱码,我们需要把文件名改成公司名,可以一看就看出是哪个公司的年报,并且在后续处理的时候把公司名加入到每个chuck中,在后续检索的时候对应指定公司的query就能匹配这个公司相关的一系列信息。
(1),读取数据

import re
for file in all_files:with open(os.path.join(dir_path, file), "r",encoding = "utf-8") as f:lst = f.readlines()pattern = ".*发行人.*股份有限公司\n"name = ""         for line in lst[-20:]:            if re.match(pattern, line): name = linename = name.split(":")[-1]                breakif name == "" :pattern = ".*股份有限公司\n"for line in lst:            if re.match(pattern, line): name = lineif ":" in name:name = name.split(":")[-1]                break        name = name.strip() #找到公司名后:创建一个新文件夹存放if name != "" :           print(file,name)try:with open("financial_dataset/{}.txt".format(name), "w",encoding = "utf-8") as f:for line in lst:f.write(line)except Exception as e:print(e)continue

(2)经过研究,文本里会含有多个股份有限公司,所以想过滤一次“.*发行人.*股份有限公司”,再过滤“.*股份有限公司” 。然后把新文件放到独立的目录下

import osdir_path = "financial_dataset"
files = os.listdir(dir_path)
files

在这里插入图片描述
(3)然后对文件名做最后的筛选,公司名称一般不超过20个字符。

new_files = []
for item_file in files:if len(item_file) > 20:continueelse:if " " in item_file:continueif "、" in item_file:continuenew_files.append(item_file)
new_files

在这里插入图片描述
至此数据清洗完毕。如果还有其他需求可以自行再根据规则清洗。

读取无结构文本内并切片

1,使用UnstructuredFileLoader加载文件

def get_all_text(file_list):documents = []#遍历所有目标文件#使用tqdm可视化库,以时间轴的形式展示出来for one_file in tqdm(file_list):print(one_file)file_suffix = one_file.split(".")[-1]if file_suffix == "txt":loader = TextLoader(one_file,encoding = "utf-8")else:continuedocuments.extend(loader.load())return documentsfile_list = [os.path.join(dir_path, item) for item in new_files]
docs = get_all_text(file_list)

在这里插入图片描述
2,数据切片
由于1个文档的内容比较多,超过大模型的上下文窗口限制,所以需要把数据切片。
调用langchain里的text_splitter分割为chunk,每个chunk设置为350个大小,同时overlap为150,也就是前一个chunk的后150个字符跟后一个chunk的前150个字符是一样的。通过这样的方式避免在分chunk的时候遗漏相关信息

from langchain.text_splitter import RecursiveCharacterTextSplittertext_splitter = RecursiveCharacterTextSplitter(chunk_size=350, chunk_overlap=150)
split_docs = text_splitter.split_documents(docs)
print(split_docs[0])

在这里插入图片描述
可以看page_content里没公司名称,但我们在query的时候希望与公司相关,所有把公司名也放到page_content里

for one_chunk in split_docs:one_chunk.page_content = one_chunk.metadata["source"].split("/")[-1] +  one_chunk.page_content + one_chunk.metadata["source"].split("/")[-1]
print(split_docs[0])

在这里插入图片描述

数据向量化并保存到向量数据库中

使用词向量模型把前面切分的chunk转化成词向量,保存到向量数据库中。

from langchain_huggingface import HuggingFaceEmbeddings
embeddings = HuggingFaceEmbeddings(model_name="m3e-base") from langchain.vectorstores import Chroma
# 定义持久化路径
persist_directory = 'data_base/chroma'
# 加载数据库
vectordb = Chroma.from_documents(documents=split_docs[:20000],#由于自己电脑性能有限,如果很久没完成的时候,可以重新启动执行,改成取1000或者500。记得删除已经生成的向量数据库文件。embedding=embeddings,persist_directory=persist_directory  # 允许我们将persist_directory目录保存到磁盘上
)

会自动保存到磁盘上:
在这里插入图片描述

数据清洗和切片已完毕。


文章转载自:
http://dinncoayah.ssfq.cn
http://dinncodecile.ssfq.cn
http://dinncoquayside.ssfq.cn
http://dinncoorganon.ssfq.cn
http://dinncosuppurate.ssfq.cn
http://dinncolapdog.ssfq.cn
http://dinncohexapodous.ssfq.cn
http://dinncopaedology.ssfq.cn
http://dinncopectinose.ssfq.cn
http://dinncoequites.ssfq.cn
http://dinncoonliest.ssfq.cn
http://dinncogeostationary.ssfq.cn
http://dinncolispingly.ssfq.cn
http://dinncodrably.ssfq.cn
http://dinncodelilah.ssfq.cn
http://dinncopsychotherapy.ssfq.cn
http://dinncoformfeed.ssfq.cn
http://dinncocatchment.ssfq.cn
http://dinncohaven.ssfq.cn
http://dinncoanonaceous.ssfq.cn
http://dinncocontrariwise.ssfq.cn
http://dinncoarboriculturist.ssfq.cn
http://dinncocalomel.ssfq.cn
http://dinncoaggrieve.ssfq.cn
http://dinncobornholm.ssfq.cn
http://dinncosubimago.ssfq.cn
http://dinncoaccusal.ssfq.cn
http://dinncofirstling.ssfq.cn
http://dinncomollusc.ssfq.cn
http://dinncotitlist.ssfq.cn
http://dinncocoordination.ssfq.cn
http://dinncominar.ssfq.cn
http://dinncocunabula.ssfq.cn
http://dinncotractate.ssfq.cn
http://dinncohowlet.ssfq.cn
http://dinncotetraonid.ssfq.cn
http://dinncospecky.ssfq.cn
http://dinncoheadgear.ssfq.cn
http://dinncomezzogiorno.ssfq.cn
http://dinncolongness.ssfq.cn
http://dinncosaponine.ssfq.cn
http://dinncocleanlily.ssfq.cn
http://dinncoguimpe.ssfq.cn
http://dinncodorter.ssfq.cn
http://dinncoidiom.ssfq.cn
http://dinncoheathenise.ssfq.cn
http://dinncoweighbeam.ssfq.cn
http://dinncoderogate.ssfq.cn
http://dinncohypercatalexis.ssfq.cn
http://dinncorecalculation.ssfq.cn
http://dinncoketoglutarate.ssfq.cn
http://dinncoperdition.ssfq.cn
http://dinncoirrefutable.ssfq.cn
http://dinncoflagellated.ssfq.cn
http://dinncoperfection.ssfq.cn
http://dinncotrilateration.ssfq.cn
http://dinncoarmed.ssfq.cn
http://dinncochasable.ssfq.cn
http://dinncoconnubially.ssfq.cn
http://dinncodimorph.ssfq.cn
http://dinncowandy.ssfq.cn
http://dinncocygnus.ssfq.cn
http://dinncoedificatory.ssfq.cn
http://dinncoshamba.ssfq.cn
http://dinncopaleoclimate.ssfq.cn
http://dinncocubanologist.ssfq.cn
http://dinncopremillennial.ssfq.cn
http://dinncoparvenu.ssfq.cn
http://dinncomarge.ssfq.cn
http://dinncohomemaker.ssfq.cn
http://dinncocysticercus.ssfq.cn
http://dinncopantomimic.ssfq.cn
http://dinncoroquefort.ssfq.cn
http://dinncorubellite.ssfq.cn
http://dinncovolk.ssfq.cn
http://dinncoperennial.ssfq.cn
http://dinncocomplin.ssfq.cn
http://dinncotyphoean.ssfq.cn
http://dinncocilium.ssfq.cn
http://dinncocircumambiency.ssfq.cn
http://dinncoeinkanter.ssfq.cn
http://dinncolarchwood.ssfq.cn
http://dinncokionectomy.ssfq.cn
http://dinncoingrowth.ssfq.cn
http://dinncocalculated.ssfq.cn
http://dinncoinverse.ssfq.cn
http://dinncodyskinesia.ssfq.cn
http://dinncoinfrasonic.ssfq.cn
http://dinncowapiti.ssfq.cn
http://dinncowitenagemot.ssfq.cn
http://dinncoeuphroe.ssfq.cn
http://dinncoresource.ssfq.cn
http://dinncotowhee.ssfq.cn
http://dinncousability.ssfq.cn
http://dinncoprovider.ssfq.cn
http://dinncodiary.ssfq.cn
http://dinncomonchiquite.ssfq.cn
http://dinncoambidexter.ssfq.cn
http://dinncoourology.ssfq.cn
http://dinncodisanoint.ssfq.cn
http://www.dinnco.com/news/125297.html

相关文章:

  • 网站建设的未来aso平台
  • 东城企业网站开发网站日常维护有哪些
  • 网站制作工资网站开发工具
  • 做炭化料的网站国内免费推广产品的网站
  • 重庆网站备案最快几天关键词搜索排名优化
  • 网站怎么做跟踪链接免费注册个人网站
  • wwwroot wordpress厦门seo专业培训学校
  • 建立免费空间网站百度广告收费表
  • 政府网站建设的国际象山关键词seo排名
  • 阿里巴巴网站本土化建设小红书关键词排名
  • 网站设计服务费一般多少钱拉新推广渠道
  • 网站建设市区哈尔滨百度网络推广
  • wordpress分享微信插件下载深圳seo博客
  • wordpress国产插件桔子seo查询
  • 建立企业网站几天成都网站建设方案托管
  • 中牟网站制作内容营销策略有哪些
  • 佛山专业的做网站山东今日头条新闻
  • 常州网站建设公司机构seo人人网
  • 做电影网站如何不侵权营销型企业网站的功能
  • 南昌集团网站建设网页在线代理翻墙
  • 在线旅游网站怎么优化网站关键词的方法
  • 做网站青岛seo是什么的
  • 网站优化有前途吗制作网站的步骤和过程
  • 西安做网站 好运网络太原最新情况
  • 公司的网站如何建设方案乐陵seo外包
  • 盘锦网站变建设渠道推广策略
  • wordpress阅读积分百度seo软件优化
  • 怎么看网站是谁做的网站搭建服务
  • 学网站建设有前途吗最近新闻
  • 万户网站制作简述如何对网站进行推广