It allows to cluster book-length texts or find similarities between long-form texts using a embedding space of 1024 dimensions. The model is used in production at the Maken site.
python
1import re
2from pathlib import Path
34from gensim.models.doc2vec import Doc2Vec
5from huggingface_hub import snapshot_download
67model = Doc2Vec.load(str(8 Path(snapshot_download("NbAiLab/maken-books"))/"model.bin"9))1011book ="A long text"12words =[c for c in re.split(r"\W+", book)iflen(c)>0]13embedding = model.infer_vector(words)14# array([ 0.01048528, -0.00491689, 0.01981961, ..., 0.00250911,15# -0.00657777, -0.01207202], dtype=float32)
Bias, Risks, and Limitations
The majority of books used for training are written in the Norwegian languages, either Bokmål or Nynorsk. As such, the semantics of the embedding space might not work as expected with books in other languages, as no work has been done to align those.
Training Details
Training Data
Books from the National Library of Norway up to Nov 21st 2022.
Training Procedure
Preprocessing [optional]
Plain text files split on white spaces with re.split(r"\W+", book).
The models published in this repository are intended for a generalist purpose and are available to third parties. These models may have bias and/or any other undesirable distortions. When third parties, deploy or provide systems and/or services to other parties using any of these models (or using systems based on these models) or become users of the models, they should note that it is their responsibility to mitigate the risks arising from their use and, in any event, to comply with applicable regulations, including regulations regarding the use of artificial intelligence. In no event shall the owner of the models (The National Library of Norway) be liable for any results arising from the use made by third parties of these models.