BENDeep
BENDeep is a pytorch based deep learning solution for Bengali NLP Task like bengali translation, bengali sentiment analysis and so on.
Installation
pip install bendeep
Dependency
- pytorch 1.5.0+
Pretrained Model
API
Sentiment Analysis
Analyzing Sentiment
This sentiment analysis model is a RNN based GRU model trained with socian sentiment dataset with loss 0.073 in 150 epochs.
Dataset size: 4000 sentences
from bendeep import sentiment
model_path = "senti_trained.pt"
vocab_path = "vocab.txt"
text = "রোহিঙ্গা মুসলমানদের দুর্ভোগের অন্ত নেই।জলে কুমির ডাংগায় বাঘ।আজকে দুটি ঘটনা আমাকে ভীষণ ব্যতিত করেছে।নিরবে কিছুক্ষন অশ্রু বিসর্জন দিয়ে মনটাকে হাল্কা করার ব্যর্থ প্রয়াস চালিয়েছি।"
sentiment.analyze(model_path, vocab_path, text)
Training Sentiment Model
To train this model you need a csv file with one column review means text and another column sentiment with 0 or 1, where 1 for positive and 0 for negative sentiment.
Example:
,review,sentiment
0,তোমাকে খুব সুন্দর লাগছে।,1
1,আজকের আবহাওয়া খুব খারাপ।,0
| review | sentiment | |
|---|---|---|
| 0 | তোমাকে খুব সুন্দর লাগছে। | 1 |
| 1 | আজকের আবহাওয়া খুব খারাপ। | 0 |
from bendeep import sentiment
data_path = "sentiment_data.csv"
sentiment.train(data_path)
# you can also pass these parameter
# sentiment.train(data_path, batch_size = 64, epochs=100, model_name="trained.pt")
after successfully training it will complete training and save model as trained.pt also save vocab file as vocab.txt
Machine Translation
Translate Bengali to English
This model is a seq2seq attentional model trained with this dataset with loss 0.0.
from bendeep import translation
from bendeep.translation import EncoderRNN
from bendeep.translation import AttnDecoderRNN
data_path = "data/translation/eng-ben.txt"
encoder = "models/translation/encoder.pt"
decoder = "models/translation/decoder.pt"
input_sentence = "আমার শীত করছে।"
translation.bn2en(data_path, encoder, decoder, input_sentence)
# outupt
# > আমার শীত করছে ।
# = i feel cold .
Training Translation Model
To train translation model you need a dataset in .txt format with tab separate input and target sentences.
Example:
I eat rice. আমি ভাত খাই।
He goes to school. সে বিদ্যালয়ে যায়।
from bendeep import translation
from bendeep.translation import EncoderRNN
from bendeep.translation import AttnDecoderRNN
data_path = "data/translation/eng-ben.txt"
translation.training(data_path, iteration=10000)
after successfully training it will complete training and save encoder and decoder model as encoder.pt, decoder.pt. Also display some random evaluation results.
References
Metadata
Release files for bendeep 1.2
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 |
|---|---|---|---|---|
| bendeep-1.2.tar.gz | 10.6 MB | Without provenance | Details for bendeep-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bendeep-1.2-py3-none-any.whl | Python 3 | none | any | Details for bendeep-1.2-py3-none-any.whl |
Total release size: 10.6 MB
Release files / bendeep-1.2.tar.gz
| Download URL | bendeep-1.2.tar.gz |
|---|---|
| Size | 10.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
172f7b15f5c661705f753bc970051105c9e0506c89fbf0e384d3604e99090be8
|
|
BLAKE2b-256 checksum How to use checksums |
a3e1a060858ac0aa9feac62c3e1d74608395796fb89f78e14e8d418039b1781a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9
|
Release files / bendeep-1.2-py3-none-any.whl
| Download URL | bendeep-1.2-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1ecaedf24b9b036b4563a51e60122d6ebfd3db179c18fd493a1fa18aee4ac388
|
|
BLAKE2b-256 checksum How to use checksums |
4d52279d35a893bba7bad6454d74dc860850ed2cb77c7b70b18539e53d548cee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9
|
Security for bendeep 1.2
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.