ainize/klue-bert-base-mrc
ainize
Pregunta y respuesta
ainize/klue-bert-base-mrc es un modelo de lenguaje entrenado en datos de QA extractiva de KLUE-MRC. Es un modelo de BERT especialmente diseñado para tareas de Preguntas y Respuestas (QA), implementado usando PyTorch y Transformers.
Como usar
En Transformers
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("ainize/klue-bert-base-mrc")
model = AutoModelForQuestionAnswering.from_pretrained("ainize/klue-bert-base-mrc")
context = "tu contexto"
question = "tu pregunta"
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)
Funcionalidades
- Pregunta y Respuesta
- Transformers
- PyTorch
- Modelo de lenguaje coreano
- Inferencia en Endpoint
Casos de uso
- Responder preguntas basadas en un contexto proporcionado