Introduction of mbert-base-parsinlu-multiple-choice
Model Details of mbert-base-parsinlu-multiple-choice
Multiple-Choice Question Answering (مدل برای پاسخ به سوالات چهار جوابی)
This is a mbert-based model for multiple-choice question answering.
Here is an example of how you can run this model:
from typing importListimport torch
from transformers import AutoConfig, AutoModelForMultipleChoice, AutoTokenizer
model_name = "persiannlp/mbert-base-parsinlu-multiple-choice"
tokenizer = AutoTokenizer.from_pretrained(model_name)
config = AutoConfig.from_pretrained(model_name)
model = AutoModelForMultipleChoice.from_pretrained(model_name, config=config)
defrun_model(question: str, candicates: List[str]):
assertlen(candicates) == 4, "you need four candidates"
choices_inputs = []
for c in candicates:
text_a = ""# empty context
text_b = question + " " + c
inputs = tokenizer(
text_a,
text_b,
add_special_tokens=True,
max_length=128,
padding="max_length",
truncation=True,
return_overflowing_tokens=True,
)
choices_inputs.append(inputs)
input_ids = torch.LongTensor([x["input_ids"] for x in choices_inputs])
output = model(input_ids=input_ids)
print(output)
return output
run_model(question="وسیع ترین کشور جهان کدام است؟", candicates=["آمریکا", "کانادا", "روسیه", "چین"])
run_model(question="طامع یعنی ؟", candicates=["آزمند", "خوش شانس", "محتاج", "مطمئن"])
run_model(
question="زمینی به ۳۱ قطعه متساوی مفروض شده است و هر روز مساحت آماده شده برای احداث، دو برابر مساحت روز قبل است.اگر پس از (۵ روز) تمام زمین آماده شده باشد، در چه روزی یک قطعه زمین آماده شده ",
candicates=["روز اول", "روز دوم", "روز سوم", "هیچکدام"])
mbert-base-parsinlu-multiple-choice huggingface.co is an AI model on huggingface.co that provides mbert-base-parsinlu-multiple-choice's model effect (), which can be used instantly with this persiannlp mbert-base-parsinlu-multiple-choice model. huggingface.co supports a free trial of the mbert-base-parsinlu-multiple-choice model, and also provides paid use of the mbert-base-parsinlu-multiple-choice. Support call mbert-base-parsinlu-multiple-choice model through api, including Node.js, Python, http.
mbert-base-parsinlu-multiple-choice huggingface.co is an online trial and call api platform, which integrates mbert-base-parsinlu-multiple-choice's modeling effects, including api services, and provides a free online trial of mbert-base-parsinlu-multiple-choice, you can try mbert-base-parsinlu-multiple-choice online for free by clicking the link below.
persiannlp mbert-base-parsinlu-multiple-choice online free url in huggingface.co:
mbert-base-parsinlu-multiple-choice is an open source model from GitHub that offers a free installation service, and any user can find mbert-base-parsinlu-multiple-choice on GitHub to install. At the same time, huggingface.co provides the effect of mbert-base-parsinlu-multiple-choice install, users can directly use mbert-base-parsinlu-multiple-choice installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
mbert-base-parsinlu-multiple-choice install url in huggingface.co: