Distributional language model (both textual and binary) for Polish (word embeddings) trained on KGR10 corpus (over 4 billion of words) using Fasttext with the following variants (all possible combinations):
In the repository you can find 4 selected models, that were examined in the paper (see Citation).
A model that performed the best is the default model/config (see default_config.json).
Usage
To use these embedding models easily, it is required to install embeddings.
pip install clarinpl-embeddings
Utilising the default model (the easiest way)
Word embedding:
python
1from embeddings.embedding.auto_flair import AutoFlairWordEmbedding
2from flair.data import Sentence
34sentence = Sentence("Myśl z duszy leci bystro, Nim się w słowach złamie.")56embedding = AutoFlairWordEmbedding.from_hub("clarin-pl/fastText-kgr10")7embedding.embed([sentence])89for token in sentence:10print(token)11print(token.embedding)
Document embedding (averaged over words):
python
1from embeddings.embedding.auto_flair import AutoFlairDocumentEmbedding
2from flair.data import Sentence
34sentence = Sentence("Myśl z duszy leci bystro, Nim się w słowach złamie.")56embedding = AutoFlairDocumentEmbedding.from_hub("clarin-pl/fastText-kgr10")7embedding.embed([sentence])89print(sentence.embedding)
Customisable way
Word embedding:
python
1from embeddings.embedding.static.embedding import AutoStaticWordEmbedding
2from embeddings.embedding.static.fasttext import KGR10FastTextConfig
3from flair.data import Sentence
45config = KGR10FastTextConfig(method='cbow', dimension=100)6embedding = AutoStaticWordEmbedding.from_config(config)78sentence = Sentence("Myśl z duszy leci bystro, Nim się w słowach złamie.")9embedding.embed([sentence])1011for token in sentence:12print(token)13print(token.embedding)
Document embedding (averaged over words):
python
1from embeddings.embedding.static.embedding import AutoStaticDocumentEmbedding
2from embeddings.embedding.static.fasttext import KGR10FastTextConfig
3from flair.data import Sentence
45config = KGR10FastTextConfig(method='cbow', dimension=100)6embedding = AutoStaticDocumentEmbedding.from_config(config)78sentence = Sentence("Myśl z duszy leci bystro, Nim się w słowach złamie.")9embedding.embed([sentence])1011print(sentence.embedding)
Citation
The link below leads to the NextCloud directory with all variants of embeddings. If you use it, please cite the following article:
@article{kocon2018embeddings,
author = {Koco\'{n}, Jan and Gawor, Micha{\l}},
title = {Evaluating {KGR10} {P}olish word embeddings in the recognition of temporal
expressions using {BiLSTM-CRF}},
journal = {Schedae Informaticae},
volume = {27},
year = {2018},
url = {http://www.ejournals.eu/Schedae-Informaticae/2018/Volume-27/art/13931/},
doi = {10.4467/20838476SI.18.008.10413}
}