Downloads · 30 days
67
0% of all-time downloads
ainize/klue-bert-base-mrc
klue-bert-base-mrc is a question answering model from ainize. Use it when the input is a question plus a passage. It is set up for transformers. The card lists the license as cc-by-sa-4.0.
Downloads · 30 days
67
0% of all-time downloads
All-time downloads
29.2K
Public
Repo size
880 MB
Likes
6
Public
Click a slice to open those files.
.bin440 MB · 100%
From the Hugging Face model README
Code: See Ainize Workspace
klue-bert-base-mrc DEMO: Ainize DEMO
klue-bert-base-mrc API: Ainize API
Language model: klue/bert-base
Language: Korean
Downstream-task: Extractive QA
Training data: KLUE-MRC
Eval data: KLUE-MRC
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("ainize/klue-bert-base-mrc")
model = AutoModelForQuestionAnswering.from_pretrained("ainize/klue-bert-base-mrc")
context = "your context"
question = "your question"
encodings = tokenizer(context, question, max_length=512, truncation=True,
padding="max_length", return_token_type_ids=False)
encodings = {key: torch.tensor([val]) for key, val in encodings.items()}
input_ids = encodings["input_ids"]
attention_mask = encodings["attention_mask"]
pred = model(input_ids, attention_mask=attention_mask)
start_logits, end_logits = pred.start_logits, pred.end_logits
token_start_index, token_end_index = start_logits.argmax(dim=-1), end_logits.argmax(dim=-1)
pred_ids = input_ids[0][token_start_index: token_end_index + 1]
prediction = tokenizer.decode(pred_ids)
Teachable NLP - Train NLP models with your own text without writing any code
Ainize - Deploy ML project using free gpu