
# patrakar/ पत्रकार (Nepali News Classifier)

Last updated: September 2022

## Model Details

**patrakar** is a DistilBERT pre-trained sequence classification transformer model which classifies Nepali language news into 9 newsgroup category, such as:

- politics
- opinion
- bank
- entertainment
- economy
- health
- literature
- sports
- tourism

It is developed by Sahaj Raj Malla  to be generally usefuly for general public and so that others could explore them for commercial and scientific purposes. This model was trained on [Sakonii/distilgpt2-nepali](https://huggingface.co/Sakonii/distilgpt2-nepali) model.

It achieves the following results on the test dataset:

| Total Number of samples | Accuracy(%)
|:-------------:|:---------------:
| 5670        | 95.475         

### Model date
September 2022

### Model type
Sequence classification model

### Model version
1.0.0

## Model Usage
This model can be used directly with a pipeline for text generation. Since the generation relies on some randomness, we set a seed for reproducibility:

```python

from transformers import pipeline, set_seed

set_seed(42)

model_name = "sahajrajmalla/patrakar"
classifier = pipeline('text-classification', model=model_name)

text = "नेकपा (एमाले)का नेता गोकर्णराज विष्टले सहमति र सहकार्यबाटै संविधान बनाउने तथा जनताको जीवनस्तर उकास्ने काम गर्नु नै अबको मुख्य काम रहेको बताएका छन् ।"

classifier(text)
```


Here is how we can use the model to get the features of a given text in PyTorch:
```python
!pip install transformers torch

from transformers import AutoTokenizer
from transformers import AutoModelForSequenceClassification

import torch
import torch.nn.functional as F



# initializing model and tokenizer
model_name = "sahajrajmalla/patrakar"

# downloading tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_name)

# downloading model
model = AutoModelForSequenceClassification.from_pretrained(model_name)

def tokenize_function(examples):
    return tokenizer(examples["data"], padding="max_length", truncation=True)


# predicting with the model
sequence_i_want_to_predict = "राजनीतिक स्थिरता नहुँदा विकास निर्माणले गति लिन सकेन"

# initializing our labels
label_list = [
                "bank",
                "economy",
                "entertainment",
                "health",
                "literature",
                "opinion",
                "politics",
                "sports",
                "tourism"
]

batch = tokenizer(sequence_i_want_to_predict, padding=True, truncation=True, max_length=512, return_tensors='pt')

with torch.no_grad():
    outputs = model(**batch)
    predictions = F.softmax(outputs.logits, dim=1)
    labels = torch.argmax(predictions, dim=1)

print(f"The sequence: \n\n {word_i_want_to_predict} \n\n is predicted to be of newsgroup {label_list[labels.item()]}")
```

## Training data
This model is trained on 50,945 rows of Nepali language news grouped [dataset](https://www.kaggle.com/competitions/text-it-meet-22/data?select=train.csv) found on Kaggle which was also used in IT Meet 2022 Text challenge.


## Framework versions
- Transformers 4.20.1
- Pytorch 1.9.1
- Datasets 2.0.0
- Tokenizers 0.11.6
{"license": "mit", "tags": ["nepali-nlp", "nepali-news-classificiation", "nlp", "transformers", "deep-learning", "pytorch", "transfer-learning"], "widget": [{"text": "\u0928\u0947\u0915\u092a\u093e (\u090f\u092e\u093e\u0932\u0947)\u0915\u093e \u0928\u0947\u0924\u093e \u0917\u094b\u0915\u0930\u094d\u0923\u0930\u093e\u091c \u0935\u093f\u0937\u094d\u091f\u0932\u0947 \u0938\u0939\u092e\u0924\u093f \u0930 \u0938\u0939\u0915\u093e\u0930\u094d\u092f\u092c\u093e\u091f\u0948 \u0938\u0902\u0935\u093f\u0927\u093e\u0928 \u092c\u0928\u093e\u0909\u0928\u0947 \u0924\u0925\u093e \u091c\u0928\u0924\u093e\u0915\u094b \u091c\u0940\u0935\u0928\u0938\u094d\u0924\u0930 \u0909\u0915\u093e\u0938\u094d\u0928\u0947 \u0915\u093e\u092e \u0917\u0930\u094d\u0928\u0941 \u0928\u0948 \u0905\u092c\u0915\u094b \u092e\u0941\u0916\u094d\u092f \u0915\u093e\u092e \u0930\u0939\u0947\u0915\u094b \u092c\u0924\u093e\u090f\u0915\u093e \u091b\u0928\u094d \u0964", "example_title": "Example 1"}, {"text": "\u0930\u093e\u091c\u0928\u0940\u0924\u093f\u0915 \u0938\u094d\u0925\u093f\u0930\u0924\u093e \u0928\u0939\u0941\u0901\u0926\u093e \u0935\u093f\u0915\u093e\u0938 \u0928\u093f\u0930\u094d\u092e\u093e\u0923\u0932\u0947 \u0917\u0924\u093f \u0932\u093f\u0928 \u0938\u0915\u0947\u0928 \u0964", "example_title": "Example 2"}, {"text": "\u0920\u0942\u0932\u094b \u0909\u0926\u094d\u092f\u094b\u0917 \u0916\u094b\u0932\u094d\u0928 \u092e\u0939\u093f\u0932\u093e\u0932\u093e\u0908 \u090b\u0923 \u0926\u093f\u0907\u0928\u094d\u0928", "example_title": "Example 3"}], "model-index": [{"name": "patrakar", "results": []}]}
transformers pytorch distilbert text-classification nepali-nlp nepali-news-classificiation nlp deep-learning transfer-learning license:mit autotrain_compatible endpoints_compatible region:us
TAGS
#transformers #pytorch #distilbert #text-classification #nepali-nlp #nepali-news-classificiation #nlp #deep-learning #transfer-learning #license-mit #autotrain_compatible #endpoints_compatible #region-us 

patrakar/ पत्रकार (Nepali News Classifier)
==========================================


Last updated: September 2022


Model Details
-------------


patrakar is a DistilBERT pre-trained sequence classification transformer model which classifies Nepali language news into 9 newsgroup category, such as:


* politics
* opinion
* bank
* entertainment
* economy
* health
* literature
* sports
* tourism


It is developed by Sahaj Raj Malla to be generally usefuly for general public and so that others could explore them for commercial and scientific purposes. This model was trained on Sakonii/distilgpt2-nepali model.


It achieves the following results on the test dataset:



### Model date


September 2022


### Model type


Sequence classification model


### Model version


1.0.0


Model Usage
-----------


This model can be used directly with a pipeline for text generation. Since the generation relies on some randomness, we set a seed for reproducibility:


Here is how we can use the model to get the features of a given text in PyTorch:


Training data
-------------


This model is trained on 50,945 rows of Nepali language news grouped dataset found on Kaggle which was also used in IT Meet 2022 Text challenge.


Framework versions
------------------


* Transformers 4.20.1
* Pytorch 1.9.1
* Datasets 2.0.0
* Tokenizers 0.11.6



### Model date


September 2022 ### Model type


Sequence classification model ### Model version


1.0.0


Model Usage
-----------


This model can be used directly with a pipeline for text generation. Since the generation relies on some randomness, we set a seed for reproducibility:


Here is how we can use the model to get the features of a given text in PyTorch:


Training data
-------------


This model is trained on 50,945 rows of Nepali language news grouped dataset found on Kaggle which was also used in IT Meet 2022 Text challenge.


Framework versions
------------------


* Transformers 4.20.1
* Pytorch 1.9.1
* Datasets 2.0.0
* Tokenizers 0.11.6
TAGS
#transformers #pytorch #distilbert #text-classification #nepali-nlp #nepali-news-classificiation #nlp #deep-learning #transfer-learning #license-mit #autotrain_compatible #endpoints_compatible #region-us 
 ### Model date


September 2022 ### Model type


Sequence classification model ### Model version


1.0.0


Model Usage
-----------


This model can be used directly with a pipeline for text generation. Since the generation relies on some randomness, we set a seed for reproducibility:


Here is how we can use the model to get the features of a given text in PyTorch:


Training data
-------------


This model is trained on 50,945 rows of Nepali language news grouped dataset found on Kaggle which was also used in IT Meet 2022 Text challenge.


Framework versions
------------------


* Transformers 4.20.1
* Pytorch 1.9.1
* Datasets 2.0.0
* Tokenizers 0.11.6
passage: TAGS
#transformers #pytorch #distilbert #text-classification #nepali-nlp #nepali-news-classificiation #nlp #deep-learning #transfer-learning #license-mit #autotrain_compatible #endpoints_compatible #region-us 
### Model date


September 2022### Model type


Sequence classification model### Model version


1.0.0


Model Usage
-----------


This model can be used directly with a pipeline for text generation. Since the generation relies on some randomness, we set a seed for reproducibility:


Here is how we can use the model to get the features of a given text in PyTorch:


Training data
-------------


This model is trained on 50,945 rows of Nepali language news grouped dataset found on Kaggle which was also used in IT Meet 2022 Text challenge.


Framework versions
------------------


* Transformers 4.20.1
* Pytorch 1.9.1
* Datasets 2.0.0
* Tokenizers 0.11.6