Bengal Language Model
Bengali language model is build with fastai's ULMFit and ready for prediction and classfication task.
NB:
- This tool mostly followed inltk
- We separated
Bengalipart with better evaluation results
Installation
pip install bnlm
Evaluation Result
Language Model
- Accuracy 48.26% on validation dataset
- Perplexity: ~22.79
Training
To train with your own corpus follow this repository
Features and API
Download pretrained Model
To start, first download pretrained Language Model and Sentencepiece model
from bnlm.bnlm import download_models
download_models()
Predict N Words
from bnlm.bnlm import BengaliTokenizer
from bnlm.bnlm import predict_n_words
model_path = 'model'
input_sen = "আমি বাজারে"
output = predict_n_words(input_sen, 3, model_path)
print("Word Prediction: ", output)
Get Sentence Encoding
from bnlm.bnlm import BengaliTokenizer
from bnlm.bnlm import get_sentence_encoding
model_path = 'model'
sp_model = "model/bn_spm.model"
input_sentence = "আমি ভাত খাই।"
encoding = get_sentence_encoding(input_sentence, model_path, sp_model)
print("sentence encoding is: ", encoding)
Get Embedding Vectors
from bnlm.bnlm import BengaliTokenizer
from bnlm.bnlm import get_embedding_vectors
model_path = 'model'
sp_model = "model/bn_spm.model"
input_sentence = "আমি ভাত খাই।"
embed = get_embedding_vectors(input_sentence, model_path, sp_model)
print("sentence embedding is : ", embed)
Sentence Similarity
from bnlm.bnlm import BengaliTokenizer
from bnlm.bnlm import get_sentence_encoding
from bnlm.bnlm import get_similar_sentences
model_path = 'model'
sp_model = "model/bn_spm.model"
sentence_1 = "আমি ভাত খাই।"
sentence_2 = "আমি ভাত খাই।"
sim = get_sentence_similarity(sentence_1, sentence_2, model_path, sp_model)
print("similarity is: ", sim)
Get Simillar Sentences
from bnlm.bnlm import BengaliTokenizer
from bnlm.bnlm import get_embedding_vectors
from bnlm.bnlm import get_similar_sentences
model_path = 'model'
sp_model = "model/bn_spm.model"
input_sentence = "আমি ভাত খাই।"
sen_pred = get_similar_sentences(input_sentence, 3, model_path, sp_model)
print(sen_pred)
Classification
upcomming
Metadata
Release files for bnlm 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bnlm-1.0.0.tar.gz | 4.5 kB | Without provenance | Details for bnlm-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bnlm-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for bnlm-1.0.0-py3-none-any.whl |
Total release size: 11.0 kB
Release files / bnlm-1.0.0.tar.gz
| Download URL | bnlm-1.0.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5eb8d80c80fc25beee0a16035974f60ed58c2d71532eab5bec97f4f8979d649
|
|
BLAKE2b-256 checksum How to use checksums |
cc75369394d455c7b5068091cca7609bacb50ad120c56cb1f13d33014ad38758
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.9
|
Release files / bnlm-1.0.0-py3-none-any.whl
| Download URL | bnlm-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
142135b438c5b361d455aa9ef876c2bd239a1b2ab2fc6a3d8123633cbb60eb80
|
|
BLAKE2b-256 checksum How to use checksums |
91ccde65b81d2b4c013bd5d829e83b919ae1b7f62691f4cced31a6aab6a75fe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.9
|
Security for bnlm 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.