Installation#

Using PIP#

Simply use PIP to install malaya,

pip3 install malaya

It will automatically all dependencies except for PyTorch. So you can choose your own PyTorch CPU / GPU version.

Make sure PyTorch >= 1.10.

Getting started#

[1]:
import malaya
/home/husein/dev/malaya/malaya/tokenizer.py:214: FutureWarning: Possible nested set at position 3397
  self.tok = re.compile(r'({})'.format('|'.join(pipeline)))
/home/husein/dev/malaya/malaya/tokenizer.py:214: FutureWarning: Possible nested set at position 3927
  self.tok = re.compile(r'({})'.format('|'.join(pipeline)))

If no error or warning, you are good to go!

Simple sentiment analysis#

[2]:
model = malaya.sentiment.huggingface()
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
[4]:
model.predict(['Dia ni dlm pemerhatian kita,,,bole dkatakn "gertak kuat",,,bhsa utra kta "gempaq kuat",'])
[4]:
['neutral']