sagorbrur / bnlp

BNLP is a natural language processing toolkit for Bengali Language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RuntimeError: Internal: /sentencepiece/python/bundled/sentencepiece/src/trainer_interface.cc(397) [!sentences_.empty()]

rakib06 opened this issue · comments

  • Training SentencePiece
from bnlp import SentencepieceTokenizer

bsp = SentencepieceTokenizer()
data = "raw_text.txt"
model_prefix = "test"
vocab_size = 5
bsp.train(data, model_prefix, vocab_size) 

Can you please tell me about raw_text.txt content or can you please send me a sample/demo for this?

I'm getting this error when I'm trying to training it using a simple bangla text file...with a bunch of paragraph.

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-23-a41838931dc6> in <module>
      3 model_prefix = "test"
      4 vocal_size = 5
----> 5 bsp.train(data, model_prefix, vocal_size)

/usr/local/venvs/rkb_320_projects/CNN/env/lib/python3.6/site-packages/bnlp/tokenizer/sentencepiece.py in train(self, data, model_prefix, vocab_size)
     13         """
     14         train_args = "--model_prefix="+model_prefix+" --input="+data+" --vocab_size="+str(vocab_size)
---> 15         bsp.SentencePieceTrainer.train(train_args)
     16         print("%s.model and %s.vocab is saved on your current directory"%(model_prefix, model_prefix))
     17 

/usr/local/venvs/rkb_320_projects/CNN/env/lib64/python3.6/site-packages/sentencepiece/__init__.py in Train(arg, **kwargs)
    405       """Train Sentencepiece model. Accept both kwargs and legacy string arg."""
    406       if arg is not None and type(arg) is str:
--> 407         return SentencePieceTrainer._TrainFromString(arg)
    408 
    409       def _encode(value):

/usr/local/venvs/rkb_320_projects/CNN/env/lib64/python3.6/site-packages/sentencepiece/__init__.py in _TrainFromString(arg)
    383     @staticmethod
    384     def _TrainFromString(arg):
--> 385         return _sentencepiece.SentencePieceTrainer__TrainFromString(arg)
    386 
    387     @staticmethod

RuntimeError: Internal: /sentencepiece/python/bundled/sentencepiece/src/trainer_interface.cc(397) [!sentences_.empty()] 

Hello @rakib06
Here raw_text.txt means plain text with no preprocessing done.
Such as wikipedia data. simply copy any website bangla text and paste it to a hello.txt file. and try to train again.

I am not clear about your problem arised here. :(
Can you share your simple bangla text file so that I can reproduce this error or try to train again?

Hi @rakib06
Your raw data is not correct.
Here is an example of raw text for sentencepiece model training.(below).
Please check and try to train again. you may get error of vocabulary size. try to change vocabulary size according to the error description.
regards
Sagor

ঢাকা দক্ষিণ সিটি করপোরেশন (ডিএসসিসি) এলাকায় রাত আটটার পর দোকানপাট, ব্যবসায়িক প্রতিষ্ঠান বন্ধ করা হবে বলে জানিয়েছেন সিটির মেয়র শেখ ফজলে নূর তাপস। তিনি আজ বুধবার দুপুরে রাজধানীর টিকাটুলিতে এক অনুষ্ঠানে এ কথা বলেন। তবে কবে থেকে এটি কার্যকর হবে, এ বিষয়ে সুনির্দিষ্টভাবে কিছু জানাননি ডিএসসিসির মেয়র।
ডিএসসিসির মেয়র বলেন, ‘আমরা একটি সুষ্ঠু ব্যবস্থাপনার আওতায় শহরটাকে নিয়ে আসতে চাই। আমরা রাত আটটার মধ্যে সব ব্যবসায়িক প্রতিষ্ঠান, দোকানপাট বন্ধ করতে চাই।’
মেয়র তাপস বলেন, ‘বহির্বিশ্বে দেখি একটি সুনির্দিষ্ট সময়ের পরে সবকিছু বন্ধ হয়ে যায়। পাঁচটা, ছয়টা, সাতটা, আটটা, নয়টা—বিভিন্ন ক্ষেত্রে এলাকাভিত্তিক সেই সময়সীমা নির্ধারণ করা হয়। আমরা মনে করি ঢাকাবাসীর জন্য ঢাকা শহরের দোকানপাট, ব্যবসায়িক প্রতিষ্ঠান রাত আটটার মধ্যে বন্ধ করলে আমাদের সামগ্রিক কার্যক্রম একটি সুষ্ঠু ব্যবস্থাপনার আওতায় আনতে পারব।’
তাপস বলেন, ‘আটটার মধ্যে দোকানপাট বন্ধ করা হলে ঢাকা শহর যানজট থেকে অনেকটা মুক্তি পাবে। পরিবারের সঙ্গে সময় কাটাতে পারব, সন্তানদের সময় দিতে পারব, যা অত্যন্ত গুরুত্বপূর্ণ।’  
মেয়র আরও বলেন, ‘আমাদের সন্তানদের যদি সুনাগরিক হিসেবে গড়ে তুলতে হয়, তাহলে সব পিতামাতার সন্তানের সঙ্গে সময় দেওয়া অত্যন্ত গুরুত্বপূর্ণ। আমরা অনেক সময় সেটা ভুলে যাই, সেটা খেয়াল করি না।’  

Hi @rakib06
Assuming your problem has solved.
I am closing this issue.
If you find any problem please raise another issue.
regards