HuggingFace镜像/xlmr-base-texas-squad-da
模型介绍文件和版本分析
下载使用量0

如何使用

import argparse

import torch
from openmind import pipeline, is_torch_npu_available
from openmind_hub import snapshot_download
import time

def parse_args():
    parser = argparse.ArgumentParser(description="Eval the model")
    parser.add_argument(
        "--model_name_or_path",
        type=str,
        help="Path to the model",
       default="zhouhui/xlmr-base-texas-squad-da",
        )
    args = parser.parse_args()
    return args


def main():
    args = parse_args()
    model_path = args.model_name_or_path
    if is_torch_npu_available():
        device = "npu:0"
    elif torch.cuda.is_available():
        device = "cuda:0"
    else:
        device = "cpu"
    #device = "cpu"
    start_time = time.time()
    qa = pipeline("question-answering", model=model_path, tokenizer=model_path, device=device)
    qa_input = {
            "question": "Why is model conversion important?",
            "context": "The option on convert models between FARM and openmind gives freedom to the user and let people easily switch between frameworks."
    }
    ans = qa(qa_input)
    print()
    print(ans)
    print()
    end_time = time.time()
    print(f"硬件环境:{device},推理执行时间:{end_time - start_time}秒")


if __name__ == "__main__":
    main()

TExAS-SQuAD-da

该模型是 xlm-roberta-base 在 TExAS-SQuAD-da 数据集上的微调版本。 其在评估集上取得了以下结果:

  • 精确匹配率(Exact match):63.96%
  • F1 分数(F1-score):68.40%

相比之下,jacobshein/danish-bert-botxo-qa-squad 模型的精确匹配率为 30.37%,F1 分数为 37.15%。

训练过程

训练超参数

训练过程中使用了以下超参数:

  • 学习率(learning_rate):2e-05
  • 训练批次大小(train_batch_size):8
  • 评估批次大小(eval_batch_size):8
  • 随机种子(seed):42
  • 梯度累积步数(gradient_accumulation_steps):4
  • 总训练批次大小(total_train_batch_size):32
  • 优化器(optimizer):Adam,参数 betas=(0.9,0.999),epsilon=1e-08
  • 学习率调度器类型(lr_scheduler_type):线性
  • 训练轮数(num_epochs):3

训练结果

训练损失(Training Loss)轮次(Epoch)步数(Step)验证损失(Validation Loss)
1.64381.041831.4711
1.40792.083661.4356
1.25323.0125491.4509

框架版本

  • Transformers 4.12.2
  • Pytorch 1.8.1+cu101
  • Datasets 1.12.1
  • Tokenizers 0.10.3