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()This model is a fine-tuned version of xlm-roberta-base on the TExAS-SQuAD-da dataset. It achieves the following results on the evaluation set:
In comparison, the jacobshein/danish-bert-botxo-qa-squad model achieves 30.37% EM and 37.15% F1.
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.6438 | 1.0 | 4183 | 1.4711 |
| 1.4079 | 2.0 | 8366 | 1.4356 |
| 1.2532 | 3.0 | 12549 | 1.4509 |