Qamembert
QAmembert是基于CamemBERT基础版针对法语问答任务进行微调的模型,训练数据包含四种法语问答数据集,支持答案存在和不存在两种情况。
下载量 37
发布时间 : 1/10/2023
模型简介
该模型专门用于法语问答任务,能够处理答案存在于上下文和答案不存在两种情况,适用于多种法语问答场景。
模型特点
多数据集训练
使用四种法语问答数据集进行训练,总计221,348组上下文/问题/答案三元组,涵盖多种问答格式。
支持无答案情况
能够处理答案不存在于上下文中的情况,采用SQuAD 2.0格式进行训练和评估。
高性能
在多个法语问答数据集上表现出色,F1值和精确匹配指标优于同类模型。
模型能力
法语问答
处理无答案情况
上下文理解
使用案例
教育
法语学习辅助
帮助学生通过问答形式学习法语知识
提供准确的答案和上下文理解
信息检索
法语文档问答
从法语文档中快速获取特定问题的答案
高效准确地提取相关信息
🚀 QAmembert
QAmembert 是基于 CamemBERT base 微调的模型,用于法语问答任务。它在多个法语问答数据集上进行训练,能有效处理上下文中有答案和无答案的问答情况。
🚀 快速开始
环境准备
确保你已经安装了 transformers
库,可使用以下命令进行安装:
pip install transformers
代码示例
以下是使用 QAmembert 进行问答的示例代码:
from transformers import pipeline
qa = pipeline('question-answering', model='CATIE-AQ/QAmembert', tokenizer='CATIE-AQ/QAmembert')
result = qa({
'question': "Combien de personnes utilisent le français tous les jours ?",
'context': "Le français est une langue indo-européenne de la famille des langues romanes dont les locuteurs sont appelés francophones. Elle est parfois surnommée la langue de Molière. Le français est parlé, en 2023, sur tous les continents par environ 321 millions de personnes : 235 millions l'emploient quotidiennement et 90 millions en sont des locuteurs natifs. En 2018, 80 millions d'élèves et étudiants s'instruisent en français dans le monde. Selon l'Organisation internationale de la francophonie (OIF), il pourrait y avoir 700 millions de francophones sur Terre en 2050."
})
if result['score'] < 0.01:
print("La réponse n'est pas dans le contexte fourni.")
else :
print(result['answer'])
✨ 主要特性
- 多数据集训练:基于四个法语问答数据集进行微调,涵盖了 SQuAD 1.0 和 SQuAD 2.0 格式的数据,训练数据丰富。
- 处理不同格式:能够处理上下文中有答案和无答案的问答情况,具有较强的适应性。
- 评估指标良好:在多个评估数据集上表现良好,如 FQuAD 1.0、qwant/squad_fr 和 frenchQA 等。
📦 数据集
数据集 | 格式 | 训练集划分 | 验证集划分 | 测试集划分 |
---|---|---|---|---|
piaf | SQuAD 1.0 | 9 224 个问答对 | X | X |
piaf_v2 | SQuAD 2.0 | 9 224 个问答对 | X | X |
fquad | SQuAD 1.0 | 20 731 个问答对 | 3 188 个问答对(未用于训练,作为测试数据集) | 2 189 个问答对(未在本工作中使用,因不可免费获取) |
fquad_v2 | SQuAD 2.0 | 20 731 个问答对 | 3 188 个问答对(未用于训练,作为测试数据集) | X |
lincoln/newsquadfr | SQuAD 1.0 | 1 650 个问答对 | 455 个问答对(未在本工作中使用) | X |
lincoln/newsquadfr_v2 | SQuAD 2.0 | 1 650 个问答对 | 455 个问答对(未在本工作中使用) | X |
pragnakalp/squad_v2_french_translated | SQuAD 2.0 | 79 069 个问答对 | X | X |
pragnakalp/squad_v2_french_translated_v2 | SQuAD 2.0 | 79 069 个问答对 | X | X |
所有这些数据集被合并为一个名为 frenchQA 的单一数据集。
📚 评估结果
评估使用了 evaluate Python 包进行。
FQuaD 1.0(验证集)
使用的评估指标为 SQuAD 1.0。
模型 | 精确匹配率 | F1 分数 |
---|---|---|
etalab-ia/camembert-base-squadFR-fquad-piaf | 53.60 | 78.09 |
QAmembert(上一版本) | 54.26 | 77.87 |
QAmembert(当前版本) | 53.98 | 78.00 |
QAmembert-large | 55.95 | 81.05 |
qwant/squad_fr(验证集)
使用的评估指标为 SQuAD 1.0。
模型 | 精确匹配率 | F1 分数 |
---|---|---|
etalab-ia/camembert-base-squadFR-fquad-piaf | 60.17 | 78.27 |
QAmembert(上一版本) | 60.40 | 77.27 |
QAmembert(当前版本) | 60.95 | 77.30 |
QAmembert-large | 65.58 | 81.74 |
frenchQA
该数据集包含上下文中无答案的问题。使用的评估指标为 SQuAD 2.0。
模型 | 精确匹配率 | F1 分数 | 答案 F1 分数 | 无答案 F1 分数 |
---|---|---|---|---|
etalab-ia/camembert-base-squadFR-fquad-piaf | n/a | n/a | n/a | n/a |
QAmembert(上一版本) | 60.28 | 71.29 | 75.92 | 66.65 |
QAmembert(当前版本) | 77.14 | 86.88 | 75.66 | 98.11 |
QAmembert-large | 77.14 | 88.74 | 78.83 | 98.65 |
💻 使用示例
基础用法
以下是上下文中有答案的示例:
from transformers import pipeline
qa = pipeline('question-answering', model='CATIE-AQ/QAmembert', tokenizer='CATIE-AQ/QAmembert')
result = qa({
'question': "Combien de personnes utilisent le français tous les jours ?",
'context': "Le français est une langue indo-européenne de la famille des langues romanes dont les locuteurs sont appelés francophones. Elle est parfois surnommée la langue de Molière. Le français est parlé, en 2023, sur tous les continents par environ 321 millions de personnes : 235 millions l'emploient quotidiennement et 90 millions en sont des locuteurs natifs. En 2018, 80 millions d'élèves et étudiants s'instruisent en français dans le monde. Selon l'Organisation internationale de la francophonie (OIF), il pourrait y avoir 700 millions de francophones sur Terre en 2050."
})
if result['score'] < 0.01:
print("La réponse n'est pas dans le contexte fourni.")
else :
print(result['answer'])
235 millions
# 详细信息
result
{'score': 0.9945194721221924,
'start': 269,
'end': 281,
'answer': '235 millions'}
高级用法
以下是上下文中无答案的示例:
from transformers import pipeline
qa = pipeline('question-answering', model='CATIE-AQ/QAmembert', tokenizer='CATIE-AQ/QAmembert')
result = qa({
'question': "Quel est le meilleur vin du monde ?",
'context': "La tour Eiffel est une tour de fer puddlé de 330 m de hauteur (avec antennes) située à Paris, à l’extrémité nord-ouest du parc du Champ-de-Mars en bordure de la Seine dans le 7e arrondissement. Son adresse officielle est 5, avenue Anatole-France.
Construite en deux ans par Gustave Eiffel et ses collaborateurs pour l'Exposition universelle de Paris de 1889, célébrant le centenaire de la Révolution française, et initialement nommée « tour de 300 mètres », elle est devenue le symbole de la capitale française et un site touristique de premier plan : il s’agit du quatrième site culturel français payant le plus visité en 2016, avec 5,9 millions de visiteurs. Depuis son ouverture au public, elle a accueilli plus de 300 millions de visiteurs."
})
if result['score'] < 0.01:
print("La réponse n'est pas dans le contexte fourni.")
else :
print(result['answer'])
La réponse n'est pas dans le contexte fourni.
# 详细信息
result
{'score': 3.619904940035945e-13,
'start': 734,
'end': 744,
'answer': 'visiteurs.'}
通过 Space 进行测试
可以通过 这里 的 Space 来测试该模型。
🔧 技术细节
本模型基于 CamemBERT base 进行微调,使用了四个法语问答数据集。所有数据集被合并为一个名为 frenchQA 的单一数据集,共使用了超过 221,348 个上下文/问题/答案三元组进行微调,6,376 个进行测试。具体方法可参考 英文博客 或 法文博客。
🌱 环境影响
碳排放量使用 机器学习影响计算器 进行估算,该计算器基于 Lacoste 等人 (2019) 的研究。使用硬件、运行时间、云服务提供商和计算区域来估算碳影响。
- 硬件类型:A100 PCIe 40/80GB
- 使用时长:5 小时 36 分钟
- 云服务提供商:私有基础设施
- 碳效率(kg/kWh):0.076kg(根据 electricitymaps 估算;由于无法获取训练当天的数据,我们采用了 2023 年 3 月法国的平均碳强度。)
- 碳排放 (功耗 x 时间 x 基于电网位置的碳排放量):0.1 kg 二氧化碳当量
📚 引用
QAmemBERT
@misc {qamembert2023,
author = { {ALBAR, Boris and BEDU, Pierre and BOURDOIS, Loïck} },
organization = { {Centre Aquitain des Technologies de l'Information et Electroniques} },
title = { QAmembert (Revision 9685bc3) },
year = 2023,
url = { https://huggingface.co/CATIE-AQ/QAmembert},
doi = { 10.57967/hf/0821 },
publisher = { Hugging Face }
}
PIAF
@inproceedings{KeraronLBAMSSS20,
author = {Rachel Keraron and
Guillaume Lancrenon and
Mathilde Bras and
Fr{\'{e}}d{\'{e}}ric Allary and
Gilles Moyse and
Thomas Scialom and
Edmundo{-}Pavel Soriano{-}Morales and
Jacopo Staiano},
title = {Project {PIAF:} Building a Native French Question-Answering Dataset},
booktitle = {{LREC}},
pages = {5481--5490},
publisher = {European Language Resources Association},
year = {2020}
}
FQuAD
@article{dHoffschmidt2020FQuADFQ,
title={FQuAD: French Question Answering Dataset},
author={Martin d'Hoffschmidt and Maxime Vidal and Wacim Belblidia and Tom Brendl'e and Quentin Heinrich},
journal={ArXiv},
year={2020},
volume={abs/2002.06071}
}
lincoln/newsquadfr
Hugging Face repository: https://hf.co/datasets/lincoln/newsquadfr
pragnakalp/squad_v2_french_translated
Hugging Face repository: https://hf.co/datasets/pragnakalp/squad_v2_french_translated
CamemBERT
@inproceedings{martin2020camembert,
title={CamemBERT: a Tasty French Language Model},
author={Martin, Louis and Muller, Benjamin and Su{\'a}rez, Pedro Javier Ortiz and Dupont, Yoann and Romary, Laurent and de la Clergerie, {\'E}ric Villemonte and Seddah, Djam{\'e} and Sagot, Beno{\^\i}t},
booktitle={Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics},
year={2020}
}
📄 许可证
本项目采用 MIT 许可证。
Distilbert Base Cased Distilled Squad
Apache-2.0
DistilBERT是BERT的轻量级蒸馏版本,参数量减少40%,速度提升60%,保留95%以上性能。本模型是在SQuAD v1.1数据集上微调的问答专用版本。
问答系统 英语
D
distilbert
220.76k
244
Distilbert Base Uncased Distilled Squad
Apache-2.0
DistilBERT是BERT的轻量级蒸馏版本,参数量减少40%,速度提升60%,在GLUE基准测试中保持BERT 95%以上的性能。本模型专为问答任务微调。
问答系统
Transformers 英语

D
distilbert
154.39k
115
Tapas Large Finetuned Wtq
Apache-2.0
TAPAS是基于BERT架构的表格问答模型,通过自监督方式在维基百科表格数据上预训练,支持对表格内容进行自然语言问答
问答系统
Transformers 英语

T
google
124.85k
141
T5 Base Question Generator
基于t5-base的问答生成模型,输入答案和上下文,输出相应问题
问答系统
Transformers

T
iarfmoose
122.74k
57
Bert Base Cased Qa Evaluator
基于BERT-base-cased的问答对评估模型,用于判断问题和答案是否语义相关
问答系统
B
iarfmoose
122.54k
9
Tiny Doc Qa Vision Encoder Decoder
MIT
一个基于MIT许可证的文档问答模型,主要用于测试目的。
问答系统
Transformers

T
fxmarty
41.08k
16
Dpr Question Encoder Single Nq Base
DPR(密集段落检索)是用于开放领域问答研究的工具和模型。该模型是基于BERT的问题编码器,使用自然问题(NQ)数据集训练。
问答系统
Transformers 英语

D
facebook
32.90k
30
Mobilebert Uncased Squad V2
MIT
MobileBERT是BERT_LARGE的轻量化版本,在SQuAD2.0数据集上微调而成的问答系统模型。
问答系统
Transformers 英语

M
csarron
29.11k
7
Tapas Base Finetuned Wtq
Apache-2.0
TAPAS是一个基于Transformer的表格问答模型,通过自监督学习在维基百科表格数据上预训练,并在WTQ等数据集上微调。
问答系统
Transformers 英语

T
google
23.03k
217
Dpr Question Encoder Multiset Base
基于BERT的密集段落检索(DPR)问题编码器,用于开放领域问答研究,在多个QA数据集上训练
问答系统
Transformers 英语

D
facebook
17.51k
4
精选推荐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