基于qwen-1.8模型微调的对话抽取模型,能从小说片段中批量提取摘要和对话
下载量 17
发布时间 : 1/26/2024
模型介绍
内容详情
替代品
模型简介
该模型专门用于从小说文本中抽取对话内容和摘要信息,支持中英文文本处理,输出结构化JSON格式结果
模型特点
多语言支持
同时支持中文和英文小说的内容抽取
结构化输出
自动生成包含摘要和对话的JSON格式结果
批量处理能力
可处理连续文本块和多章节内容
模型能力
文本摘要生成
对话内容识别
说话人判断
结构化数据输出
使用案例
文学分析
小说对话分析
从小说文本中提取对话内容用于角色分析
示例显示能准确识别对话内容和说话人
内容摘要生成
自动生成小说片段的要点摘要
示例显示能生成连贯的段落摘要
数据预处理
对话数据集构建
为对话系统准备训练数据
可批量处理大量小说文本
license: apache-2.0 language:
- zh
- en tags:
- text-generation-inference
凉宫春日对话抽取模型
我们希望构建一个能从小说片段中批量提取摘要和对话的模型。
本模型实现了这一目标。使用约3万部中文小说和2万部英文小说数据进行训练,基于qwen-1.8模型进行了3个epoch的微调。该模型理论上支持中英文小说的内容抽取。
主项目地址 https://github.com/LC1332/Chat-Haruhi-Suzumiya
推理代码
https://github.com/LC1332/Chat-Haruhi-Suzumiya/blob/main/notebook/Dialogue_Speaker_Extract_Test.ipynb
from transformers import AutoTokenizer, AutoModel, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("silk-road/Haruhi-Dialogue-Speaker-Extract_qwen18", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("silk-road/Haruhi-Dialogue-Speaker-Extract_qwen18", device_map="auto", trust_remote_code=True)
sys_prompt = "给定输入段落,抽取其中对话并以json格式输出。请逐步思考:1. 将段落概括为要点形式,存入summary字段 2. 抽取每句对话内容(dialogue),判断说话人(said by),存入conversations字段"
text = "您的小说文本"
response_str, history = model.chat(tokenizer, text, history=[], system=sys_prompt)
标准提示词
中文版:
给定输入段落,抽取其中对话并以json格式输出。请逐步思考:1. 将段落概括为要点形式,存入summary字段 2. 抽取每句对话内容(dialogue),判断说话人(said by),存入conversations字段
英文版:
Given an input paragraph, extract the dialogues within it, and output them in JSON format.
Let's think about it step by step:
- Summarize the input paragraph into bullet points and store it in the 'summary' field.
- Extract the content of each dialogue ('dialogue'), identify the speaker for each sentence ('said by'), and store these in 'conversations'.
待办事项
- [x] 扩展至多文本块推理
- [x] 提供英文示例
- [ ] 提供多章节并行推理示例
- [ ] JSON解析失败时尝试从原始文本提取摘要
- [ ] 失败时额外调用OpenAI进行推理
中文输出示例
{'summary': '- 彭蠡不在家中,老刀感到担忧并等待着彭蠡回家的时间,同时观察周围环境和人们的消费行为,表现出内心的饥饿感和焦虑情绪。', 'conversations': [{'dialogue': '哎,你们知道那儿一盘回锅肉多少钱吗?', 'said_by': '小李'}, {'dialogue': '靠,菜里有沙子。', 'said_by': '小丁'}, {'dialogue': '人家那儿一盘回锅肉,就三百四。', 'said_by': '小李'}, {'dialogue': '什么玩意?这么贵。', 'said_by': '小丁'}, {'dialogue': '你吃不了这么多。', 'said_by': '小李'}]}
{'summary': '- 彭蠡在家等待彭蠡回家,表现出内心的饥饿感和焦虑情绪,同时对彭蠡的行为表示不满和失望。彭蠡则对老刀的行为表现出冷漠和不屑的态度。', 'conversations': [{'dialogue': '我没时间和你解释。我需要去第一空间,你告诉我怎么走。', 'said_by': '老刀'}, {'dialogue': '回我家说,要走也从那儿走。', 'said_by': '彭蠡'}, {'dialogue': '回家啦,回家啦。转换马上开始了。', 'said_by': '车上的人'}, {'dialogue': '你不告诉我为什么,我就不告诉你怎么走。', 'said_by': '彭蠡'}, {'dialogue': '你躲在垃圾道里?去第二空间?那你得等24小时啊。', 'said_by': '彭蠡'}, {'dialogue': '二十万块。等一礼拜也值啊。', 'said_by': '老刀'}, {'dialogue': '你就这么缺钱花?', 'said_by': '彭蠡'}, {'dialogue': '糖糖还有一年多该去幼儿园了。我来不及了。', 'said_by': '老刀'}, {'dialogue': '你别说了。', 'said_by': '彭蠡'}]}
{'summary': '- 彭蠡对彭蠡的行为表现出不满和失望,同时对老刀的行为表现出冷漠和不屑的态度。', 'conversations': [{'dialogue': '你真是作死,她又不是你闺女,犯得着吗。', 'said_by': '彭蠡'}, {'dialogue': '别说这些了。快告我怎么走。', 'said_by': '老刀'}, {'dialogue': '你可得知道,万一被抓着,可不只是罚款,得关上好几个月。', 'said_by': '彭蠡'}, {'dialogue': '你不是去过好多次吗?', 'said_by': '老刀'}, {'dialogue': '只有四次。第五次就被抓了。', 'said_by': '彭蠡'}, {'dialogue': '那也够了。我要是能去四次,抓一次也无所谓。', 'said_by': '老刀'}, {'dialogue': '别说了。你要是真想让我带你去,我就带你去。', 'said_by': '彭蠡'}]}
- 彭蠡不在家中,老刀感到担忧并等待着彭蠡回家的时间,同时观察周围环境和人们的消费行为,表现出内心的饥饿感和焦虑情绪。
小李 : 哎,你们知道那儿一盘回锅肉多少钱吗?
小丁 : 靠,菜里有沙子。
小李 : 人家那儿一盘回锅肉,就三百四。
小丁 : 什么玩意?这么贵。
小李 : 你吃不了这么多。
- 彭蠡在家等待彭蠡回家,表现出内心的饥饿感和焦虑情绪,同时对彭蠡的行为表示不满和失望。彭蠡则对老刀的行为表现出冷漠和不屑的态度。
老刀 : 我没时间和你解释。我需要去第一空间,你告诉我怎么走。
彭蠡 : 回我家说,要走也从那儿走。
车上的人 : 回家啦,回家啦。转换马上开始了。
彭蠡 : 你不告诉我为什么,我就不告诉你怎么走。
彭蠡 : 你躲在垃圾道里?去第二空间?那你得等24小时啊。
老刀 : 二十万块。等一礼拜也值啊。
彭蠡 : 你就这么缺钱花?
老刀 : 糖糖还有一年多该去幼儿园了。我来不及了。
彭蠡 : 你别说了。
- 彭蠡对彭蠡的行为表现出不满和失望,同时对老刀的行为表现出冷漠和不屑的态度。
彭蠡 : 你真是作死,她又不是你闺女,犯得着吗。
老刀 : 别说这些了。快告我怎么走。
彭蠡 : 你可得知道,万一被抓着,可不只是罚款,得关上好几个月。
老刀 : 你不是去过好多次吗?
彭蠡 : 只有四次。第五次就被抓了。
老刀 : 那也够了。我要是能去四次,抓一次也无所谓。
彭蠡 : 别说了。你要是真想让我带你去,我就带你去。
英文输出示例
{'summary': "雪中的巴黎,木村的工作室,艺术家与观察者展开对话。", 'conversations': [{'dialogue': 'You should hear the stories they tell of you at the café. If Émile is to be believed, you arrived here as an ukiyo-e courtesan, nothing more than paper wrapped around a porcelain bowl. A painter—he will not say which of us it was, of course—bought the bowl and the print along with it.', 'said_by': 'Artist'}, {'dialogue': 'And the painter pulled me from the print with the sheer force of his imagination, I’m sure. Émile is a novelist and can hardly be trusted to give an accurate account. The reality of my conception is vastly more mundane, I assure you…though it does involve a courtesan.', 'said_by': 'Woman'}, {'dialogue': 'A grain of truth makes for the best fiction. nude, but leave the jewelry and the shoes. I’ll paint you on the chaise. We’ll have three hours in the proper light, and I will pay you four francs.', 'said_by': 'Artist'}, {'dialogue': 'Victorine gets five!', 'said_by': 'Woman'}, {'dialogue': 'Victorine is a redhead.', 'said_by': 'Artist'}, {'dialogue': 'My name is Mariko, by the way, but everyone calls me Mari.', 'said_by': 'Mariko'}]}
{'summary': "雪中的巴黎,木村的工作室,艺术家与观察者进行亲密对话和互动。", 'conversations': [{'dialogue': 'I’m on the chaise', 'said_by': 'Artist'}, {'dialogue': 'Bring your left hip forward. No, not that far. Bend the leg a bit more, yes. Turn your head to face the canvas.', 'said_by': 'Artist'}, {'dialogue': 'Like a Manet', 'said_by': 'Artist'}, {'dialogue': 'Don’t like a model that talks while you work, huh?', 'said_by': 'Artist'}, {'dialogue': 'I don’t like being compared to other artists.', 'said_by': 'Artist'}, {'dialogue': 'Then you must paint me so well that I forget about the others.', 'said_by': 'Artist'}, {'dialogue': 'Tilt your head into the light. And look at me intently. Intently. As though I were the one naked on the chaise.', 'said_by': 'Artist'}, {'dialogue': 'You did better than I would have expected.', 'said_by': 'Artist'}, {'dialogue': 'There are other poses I could show you, if you like?', 'said_by': 'Artist'}, {'dialogue': 'But the sooner I get started on this portrait, the better.', 'said_by': 'Artist'}]}
{'summary': "木村的工作室,艺术家与观察者进行亲密对话和互动。木村以强烈而冷漠的拥抱回应,引发激情互动。事后艺术家入睡,留下叙述者感到不完整和渴望。", 'num': 14, 'conversations': [{'dialogue': 'I could show you other poses.', 'said_by': 'Kimura'}, {'dialogue': 'Yes.', 'said_by': 'Kimura'}, {'dialogue': 'See you tomorrow?', 'said_by': 'Artist'}]}
雪中的巴黎,木村的工作室,艺术家与观察者展开对话。
Artist : You should hear the stories they tell of you at the café. If Émile is to be believed, you arrived here as an ukiyo-e courtesan, nothing more than paper wrapped around a porcelain bowl. A painter—he will not say which of us it was, of course—bought the bowl and the print along with it.
Woman : And the painter pulled me from the print with the sheer force of his imagination, I’m sure. Émile is a novelist and can hardly be trusted to give an accurate account. The reality of my conception is vastly more mundane, I assure you…though it does involve a courtesan.
Artist : A grain of truth makes for the best fiction. nude, but leave the jewelry and the shoes. I’ll paint you on the chaise. We’ll have three hours in the proper light, and I will pay you four francs.
Woman : Victorine gets five!
Artist : Victorine is a redhead.
Mariko : My name is Mariko, by the way, but everyone calls me Mari.
雪中的巴黎,木村的工作室,艺术家与观察者进行亲密对话和互动。
Artist : I’m on the chaise
Artist : Bring your left hip forward. No, not that far. Bend the leg a bit more, yes. Turn your head to face the canvas.
Artist : Like a Manet
Artist : Don’t like a model that talks while you work, huh?
Artist : I don’t like being compared to other artists.
Artist : Then you must paint me so well that I forget about the others.
Artist : Tilt your head into the light. And look at me intently. Intently. As though I were the one naked on the chaise.
Artist : You did better than I would have expected.
Artist : There are other poses I could show you, if you like?
Artist : But the sooner I get started on this portrait, the better.
木村的工作室,艺术家与观察者进行亲密对话和互动。木村以强烈而冷漠的拥抱回应,引发激情互动。事后艺术家入睡,留下叙述者感到不完整和渴望。
Kimura : I could show you other poses.
Kimura : Yes.
Artist : See you tomorrow?
Bart Large Cnn
MIT
基于英语语料预训练的BART模型,专门针对CNN每日邮报数据集进行微调,适用于文本摘要任务
文本生成
英语
B
facebook
3.8M
1,364
Parrot Paraphraser On T5
Parrot是一个基于T5的释义框架,专为加速训练自然语言理解(NLU)模型而设计,通过生成高质量释义实现数据增强。
文本生成
Transformers

P
prithivida
910.07k
152
Distilbart Cnn 12 6
Apache-2.0
DistilBART是BART模型的蒸馏版本,专门针对文本摘要任务进行了优化,在保持较高性能的同时显著提升了推理速度。
文本生成
英语
D
sshleifer
783.96k
278
T5 Base Summarization Claim Extractor
基于T5架构的模型,专门用于从摘要文本中提取原子声明,是摘要事实性评估流程的关键组件。
文本生成
Transformers

英语
T
Babelscape
666.36k
9
Unieval Sum
UniEval是一个统一的多维评估器,用于自然语言生成任务的自动评估,支持多个可解释维度的评估。
文本生成
Transformers

U
MingZhong
318.08k
3
Pegasus Paraphrase
Apache-2.0
基于PEGASUS架构微调的文本复述模型,能够生成语义相同但表达不同的句子。
文本生成
Transformers

英语
P
tuner007
209.03k
185
T5 Base Korean Summarization
这是一个基于T5架构的韩语文本摘要模型,专为韩语文本摘要任务设计,通过微调paust/pko-t5-base模型在多个韩语数据集上训练而成。
文本生成
Transformers

韩语
T
eenzeenee
148.32k
25
Pegasus Xsum
PEGASUS是一种基于Transformer的预训练模型,专门用于抽象文本摘要任务。
文本生成
英语
P
google
144.72k
198
Bart Large Cnn Samsum
MIT
基于BART-large架构的对话摘要模型,专为SAMSum语料库微调,适用于生成对话摘要。
文本生成
Transformers

英语
B
philschmid
141.28k
258
Kobart Summarization
MIT
基于KoBART架构的韩语文本摘要模型,能够生成韩语新闻文章的简洁摘要。
文本生成
Transformers

韩语
K
gogamza
119.18k
12
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers

支持多种语言
L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers

英语
C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统
中文
R
uer
2,694
98
AIbase是一个专注于MCP服务的平台,为AI开发者提供高质量的模型上下文协议服务,助力AI应用开发。
简体中文