Skip to main content

Bangla FastText Model & Toolkit

We have constructed a dataset that contains Bangla text data for training unsupervised ML model, and it contains around 14 GB of text data. One of the largest in Bengali Language model called BanglaLM: Bangla Corpus For Language Model Research. The Bangla FastText model had been developed based on this dataset. We used google cloud to train model. We developed two models based on skipgram and cbow training method. This is open source python module to use these two models easily. We also developed sentence embedding systems for the using of sklearn classifiers. It showed better perfromance than facebook pretrained fasttext model on Bangla Wikidataset.

Dataset (Bengali)

Link for the BanglaLM dataset :

-> Github: BanglaLM: Bangla Corpus For Language Model Research

-> Kaggle: BanglaLM: Bangla Corpus For Language Model Research

Model link:

Bangla FastText

Installation

To install the latest release, we can do :

!pip install BanglaFastText

or, to get the latest development version of BanglaFastText, we can install from our github repository :

$ https://github.com/Kowsher/Bangla-Fasttext.git
$ cd Bangla-Fasttext
$ sudo pip install .
$ # or :
$ sudo python setup.py install

For further information and introduction see README.md

Getting started

In order to learn word vectors, as described here, BanglaFastText function like this:

import BanglaFastText

#There are two variations of training methods cbow and skipgram. By default, it's cbow method and the model preparation path is set default as current working directory 
>>> Bn = BanglaFastText.BanglaFasttext()

#If want to save the model in manual path, we can by using 'sav_path' parameter.

# Skipgram model :
>>> Bn = BanglaFastText.BanglaFasttext(method='skipgram', save_path = './content/model')
# 'path' is the directory to save the downloaded model
>>> model = Bn.model_load()

# or, cbow model :
>>> Bn = BanglaFastText.BanglaFasttext(method='cbow', save_path = './content/model')
>>> model = Bn.model_load()

Where method parameter is to choose the training method and path is to save model.

Loading a model object

If we have already model then we can simply read and load the model as :

# To read a model
>>> Bn = BanglaFastText.BanglaFasttext(model_path = './model_name')

# to load the model as object we can
>>> model = Bn.model_load()

Playing with the parameters

# to get vector of a word
>>> model['দেশ']

# to get most similar words
>>> model.most_similar("দেশ")

# to find word similarity
>>> Bn.word_similarity('কিতাব', 'বই')

# to find sentence similarity
>>> Bn.sent_similarity('আমি দেশকে ভালোবাসি', 'অনেক সুন্দর আমাদের দেশ')

#  for sentence embedding 
>>> corpus = ['আমি দেশকে ভালোবাসি', 'অনেক সুন্দর আমাদের দেশ']
>>> X = Bn.sent_embd(corpus)

Fine Tuning

If we want to fine tuning or update weights by our dataset

>>> corpus = ['আমি দেশকে ভালোবাসি', 'অনেক সুন্দর আমাদের দেশ']
>>> Bn.fine_tuning(corpus, epochs=5)
>>> model = Bn.model_load()

......
>>> tuned_model = Bn.fine_tuning(corpus, epochs=5) # to get the raw model after finetuned, if we want to use it further  

Metadata

Release files for BanglaFastText 2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for BanglaFastText 2.3
File Interpreter ABI Platform
BanglaFastText-2.3-py3-none-any.whl Python 3 none any Details

Release files / BanglaFastText-2.3-py3-none-any.whl

Download URL BanglaFastText-2.3-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f74d79ebfc3b5a8bae6c7e84252bed4be73a0c89d8121bc7305cd377511dee10
BLAKE2b-256 checksum
How to use checksums
6b4f8e9d796f11714e366ceb8efdbdf1a89c7244c7e9ba4cce6f395bb254f28c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release history Release notifications | RSS feed

This release

2.3 This release

1 release file

2.2

1 release file

2.1

1 release file

1.1

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page