KoichiYasuoka's picture
initial release
2c30a68
metadata
tags:
  - japanese
  - question-answering
  - dependency-parsing
datasets:
  - universal_dependencies
license: cc-by-sa-4.0
pipeline_tag: question-answering
widget:
  - text: 国語
    context: 全学年にわたって小学校の国語の教科書に挿し絵が用いられている
  - text: 教科書
    context: 全学年にわたって小学校の国語の教科書に挿し絵が用いられている
  - text: 
    context: 全学年にわたって小学校の国語[MASK]教科書に挿し絵が用いられている

deberta-base-japanese-aozora-ud-head

Model Description

This is a DeBERTa(V2) model pretrained on 青空文庫 for dependency-parsing (head-detection on long-unit-words) as question-answering, derived from deberta-base-japanese-aozora and UD_Japanese-GSDLUW. Use [MASK] inside context to avoid ambiguity when specifing a multiple-used word as question.

How to Use

import torch
from transformers import AutoTokenizer,AutoModelForQuestionAnswering
tokenizer=AutoTokenizer.from_pretrained("KoichiYasuoka/deberta-base-japanese-aozora-ud-head")
model=AutoModelForQuestionAnswering.from_pretrained("KoichiYasuoka/deberta-base-japanese-aozora-ud-head")
question="国語"
context="全学年にわたって小学校の国語の教科書に挿し絵が用いられている"
inputs=tokenizer(question,context,return_tensors="pt",return_offsets_mapping=True)
offsets=inputs.pop("offset_mapping").tolist()[0]
outputs=model(**inputs)
start,end=torch.argmax(outputs.start_logits),torch.argmax(outputs.end_logits)
print(context[offsets[start][0]:offsets[end][-1]])