英文

英国图书馆图书类型检测器

注: 该模型卡片仍在完善中。

模型描述

该经过微调的 distilbert-base-cased 模型是根据书籍的标题预测该书籍是否为小说或非小说。

预期用途和限制

该模型是使用 Digitised printed books (18th-19th century) 书籍集创建的数据进行训练的。该集合中的数据集包含来自19世纪的49,455本数字化书籍(65,227卷),主要为英文书籍,但也包括其他语言的少量书籍。尽管该数据集的部分数据具有与类型相关的元数据,但大部分数据集目前不包含此信息。

该模型最初是为 Living with Machines 项目开发的一部分,以便能够对大量的书籍数据集进行“切分”,根据“粗糙”的类型分类(即标题是小说还是非小说)将其分成不同的类别。

模型的局限性主要体现在以下几个方面:

标题格式

模型的训练数据(稍后会更详细地讨论)主要包括19世纪的书籍标题,这些标题按照英国图书馆的编目惯例进行了分类。由于不同机构在编目时采取的方法不同,使用来自不同目录的标题运行该模型可能会引入域漂移,并导致模型性能下降。

以下是训练数据中的20个随机示例:

  • 'The Canadian farmer. A missionary incident [Signed: W. J. H. Y, i.e. William J. H. Yates.]
  • 'A new musical Interlude, called the Election [By M. P. Andrews.]',
  • 'An Elegy written among the ruins of an Abbey. By the author of the Nun [E. Jerningham]',
  • "The Baron's Daughter. A ballad by the author of Poetical Recreations [i.e. William C. Hazlitt]. F.P",
  • 'A Little Book of Verse, etc',
  • 'The Autumn Leaf Poems',
  • 'The Battle of Waterloo, a poem',
  • 'Maximilian, and other poems, etc',
  • 'Fabell? mostellari?: or Devonshire and Wiltshire stories in verse; including specimens of the Devonshire dialect',
  • 'The Grave of a Hamlet and other poems, chiefly of the Hebrides ... Selected, with an introduction, by his son J. Hogben']

日期

该模型是使用包含 Digitised printed books (18th-19th century) 书籍集的数据进行训练的。该数据集涵盖了一个较长的时期(从1500年到1900年)。但是,该数据集偏向于较晚的年份。用于训练该模型的带有类型标注的训练数据的日期分布如下:

Date
mean 1864.83
std 43.0199
min 1540
25% 1847
50% 1877
75% 1893

语言

虽然该模型在多语言方面是有能力的,因为它具有非英文书名的训练数据,但这些数据出现的频率较低。原始训练数据的语言统计如下:

Language Count
English 22987
Russian 461
French 424
Spanish 366
German 347
Dutch 310
Italian 212
Swedish 186
Danish 164
Hungarian 132
Polish 112
Latin 83
Greek,Modern(1453-) 42
Czech 25
Portuguese 24
Finnish 14
Serbian 10
Bulgarian 7
Icelandic 4
Irish 4
Hebrew 2
NorwegianNynorsk 2
Lithuanian 2
Slovenian 2
Cornish 1
Romanian 1
Slovak 1
Scots 1
Sanskrit 1
如何使用

有几种不同的方法可以使用该模型。要在本地运行该模型,最简单的方法是使用🤗 Transformers pipelines :

from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
tokenizer = AutoTokenizer.from_pretrained("davanstrien/bl-books-genre")
model = AutoModelForSequenceClassification.from_pretrained("davanstrien/bl-books-genre")
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
classifier("Oliver Twist")

这将返回一个带有预测标签和分数的字典

[{'label': 'Fiction', 'score': 0.9980145692825317}]

如果您打算在初步实验之后继续使用该模型,强烈建议创建一些用于验证模型预测的数据。由于该模型是根据特定的书籍标题语料库进行训练的,如果您想在与训练语料库不同的书籍标题集合上运行该模型,也有可能有益于对模型进行微调。

训练数据

训练数据是使用Zooniverse平台创建的,并由 British Library 的编目员进行了注释。 Snorkel 通过各种标注函数扩展了此原始训练数据。因此,其中一些标签不是由人类生成的。有关创建注释过程的更多信息,请参阅 here 。

训练过程

该模型是使用 blurr 库进行训练的。训练过程的笔记本可在 Predicting Genre with Machine Learning 中找到。

评估结果

模型在保留的训练集上的结果为:

              precision    recall  f1-score   support

     Fiction       0.88      0.97      0.92       296
 Non-Fiction       0.98      0.93      0.95       554

    accuracy                           0.94       850
   macro avg       0.93      0.95      0.94       850
weighted avg       0.95      0.94      0.94       850

如模型的偏见和限制部分简要讨论的,这些结果应谨慎对待。**