hf_mirrors/frozen_news_classifier_ft
Model Introduction
Files & versions
Analysis

Model description

This model is a fine-tuned version of sentence-transformers/LaBSE on my news dataset. The goal of this model was to create a universal model for categorizing Russian-language news that would preserve the ability of the basic LaBSE model to generate multi-lingual text embeddings in a single vector space. It should be noted that the model allows to classify news articles in other languages available in LaBSE, but the quality of such classification will be worse than Russian-language news texts. The learning news dataset is a well-balanced sample of recent news from the last five years.

It achieves the following results on the evaluation set:

  • Loss: 0.7314
  • Accuracy: 0.7793
  • F1: 0.7753
  • Precision: 0.7785
  • Recall: 0.7793

How to use


from openmind import omdatasets, pipeline, is_torch_npu_available, AutoTokenizer
import argparse
import time
def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--model_name_or_path",
        type=str,
        help="Path to model",
        default="zhouhui/frozen_news_classifier_ft",
    )
    args = parser.parse_args()
    return args

args = parse_args()
model_path = args.model_name_or_path

if is_torch_npu_available():
    device = "npu:0"
else:
    device = "cpu"
#device = "cpu"
start_time = time.time()
unmasker = pipeline('text-classification', model=model_path,device=device)
print(unmasker("The man worked as a <mask>."))
end_time = time.time()
print(f"硬件环境:{device},推理执行时间:{end_time - start_time}秒")

Intended uses & limitations

Compared to my specialized model any-news-classifier, which is designed to solve news classification problems, this model shows meaningfully worse metrics.

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 1e-05
  • train_batch_size: 16
  • eval_batch_size: 16
  • seed: 42
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • lr_scheduler_type: linear
  • lr_scheduler_warmup_steps: 500
  • num_epochs: 10

Training results

Training LossEpochStepValidation LossAccuracyF1PrecisionRecall
0.84221.035960.81040.76810.76320.76690.7681
0.79232.071920.77380.77110.76660.77000.7711
0.75973.0107880.74850.77540.77160.77410.7754
0.75644.0143840.73140.77930.77530.77850.7793

Framework versions

  • Transformers 4.42.4
  • Pytorch 2.4.0+cu121
  • Datasets 2.21.0
  • Tokenizers 0.19.1