当前位置:主页 > 查看内容

阅读理解回答问题(Question Answering)---一个更强的BERT预训练

发布时间:2021-09-06 00:00| 位朋友查看

简介:1?引言 ?在 Transformers之问题对答(Question Answering) 中, 使用了mrm8488/bert-multi-cased-finetuned-xquadv1数据集回答问题, 这个数据集是一个多语言预训练模型:?BERT(base-multilingual-cased) fine-tuned for multilingual Q A. 并且使用了最简单的管……

1?引言 ?在 Transformers之问题对答(Question Answering) 中, 使用了mrm8488/bert-multi-cased-finetuned-xquadv1数据集回答问题, 这个数据集是一个多语言预训练模型:?BERT(base-multilingual-cased) fine-tuned for multilingual Q A. 并且使用了最简单的管道pileline()调用方法. 就像我们已经看到的一样,?这个模型得出的结果不理想, 因此本文探索了一个更高级的预训练模型.


2 模型描述 本文的试验模型采用了bert-large-uncased-whole-word-masking-finetuned-squad数据集作为问题回答模型。在默认状态下, 这个模型保存在C:\Users\m\.cache\huggingface\transformers文件夹内. 该模型不区分字母的大小写, 使用了屏蔽语言模拟masked language modeling (MLM)?目标对英语语言进行预训练。可以在问题回答管道中使用它 或者使用它来输出给定查询和上下文的原始结果。BERT模型在BookCorpus上进行了预训练 该数据集由11,038本未出版的书籍和英文维基百科组成(不包括列表、表格和标题)。


与其他BERT模型不同的是 这个模型使用了全词屏蔽Whole Word Masking技术进行训练。在这种情况下 一个词所对应的所有标记(tokens)都会被一次性屏蔽掉, 而整体屏蔽率保持不变。训练是相同的 -- 每个被屏蔽的WordPiece标记都是独立预测的。在预训练之后 这个模型在SQuAD数据集上用一个微调脚本进行了微调。?


BERT是一个以自我监督方式在大型英语数据语料库上预训练的transformers?模型。这意味着它只对原始文本进行了预训练 没有人以任何方式给它们贴标签 这就是为什么它可以使用大量公开可用的数据 并通过一个自动过程从这些文本中生成输入和标签。更确切地说 它的预训练有两个目标:?


(1) Masked language modeling (MLM):?掩蔽语言模拟(MLM)---取一个句子 模型随机掩蔽输入中15%的单词 然后通过模型运行整个掩蔽的句子预测掩蔽的单词。这与传统的递归神经网络RNN不同 RNN通常是一个接一个地看单词 或者与自回归模型GPT不同 GPT在内部屏蔽未来的标记。而MLM允许模型学习句子的双向表示。


3?调用方法 Transformers之问题对答(Question Answering) [transformers-pipeline-question-answering.py]使用了管道pipleline方法 本例使用AutoTokenizer方法[Transformers-AutoModelForQuestionAnswering.py]。


from?transformers?import?AutoTokenizer,?AutoModelForQuestionAnsweringimport?torchtokenizer? ?AutoTokenizer.from_pretrained( bert-large-uncased-whole-word-masking-finetuned-squad )model? ?AutoModelForQuestionAnswering.from_pretrained( bert-large-uncased-whole-word-masking-finetuned-squad )


4?测试结果 ?我们使用与上文内容相同的句子作为比较对象 提出以下四个问题:: 内容: ? The development of a step-path failure surface is mainly controlled by the orientation and spatial characteristics of the present major rock structure including major joints sets, shear planes and fault planes.? ?(1) 问题:? What kinds of factors controlled the?development of a step-path failure surface? 回答:?orientation and spatial characteristics of the present major rock structure including major joints sets, shear planes and fault planes


5 新的测试 内容:? The?Chuquicamata mine in northern Chile?has?one of the largest open pits in the world, measuring approximately 4 km long, 3 km wide, and?1 km deep. Removing ore and waste from the mine on conveyors or by truck, using the haul roads such as that illustrated in Fig. 25, is a complex and expensive process. Hence, planning started more than 10 years ago for a transition from open pit to?block caving underground?as the mining method. ?[智利北部的丘基卡马塔矿是世界上最大的露天矿之一 长约4公里 宽3公里 深1公里。用传送带或卡车将矿石和矸石从矿井中运出 使用如图25所示的运输道路 这是一个复杂而昂贵的过程。因此 10多年前就开始规划采矿方法 从露天矿过渡到地下块体崩落法。]


本文转自网络,原文链接:https://developer.aliyun.com/article/787805
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!
上一篇:SQLPlus环境设置 下一篇:没有了

推荐图文

  • 周排行
  • 月排行
  • 总排行

随机推荐