from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
model_name_or_path = "m3hrdadfi/xlmr-large-qa-sv"
nlp = pipeline('question-answering', model=model_name_or_path, tokenizer=model_name_or_path)
context = """Sveriges nationaldag och svenska flaggans dag firas den 6 juni varje år och är en helgdag i Sverige. Tidigare firades 6 juni enbart som "svenska flaggans dag" och det var först 1983 som dagen även fick status som nationaldag. """
questions = [
"Vilket datum är den svenska nationaldagen?",
"Vad innebär helgdag i Sverige?",
"Vilket år tillkom Sveriges nationaldag?"
]
kwargs = {}
for question in questions:
r = nlp(question=question, context=context, **kwargs)
answer = " ".join([token.strip() for token in r["answer"].strip().split() if token.strip()])
print(f"{question}{answer}")
Output
Vilket datum är den svenska nationaldagen? 6 juni
Vad innebär helgdag i Sverige? svenska flaggans dag
Vilket år tillkom Sveriges nationaldag? 1983
Runs of m3hrdadfi xlmr-large-qa-sv on huggingface.co
9
Total runs
0
24-hour runs
0
3-day runs
-1
7-day runs
-2
30-day runs
More Information About xlmr-large-qa-sv huggingface.co Model
xlmr-large-qa-sv huggingface.co
xlmr-large-qa-sv huggingface.co is an AI model on huggingface.co that provides xlmr-large-qa-sv's model effect (), which can be used instantly with this m3hrdadfi xlmr-large-qa-sv model. huggingface.co supports a free trial of the xlmr-large-qa-sv model, and also provides paid use of the xlmr-large-qa-sv. Support call xlmr-large-qa-sv model through api, including Node.js, Python, http.
xlmr-large-qa-sv huggingface.co is an online trial and call api platform, which integrates xlmr-large-qa-sv's modeling effects, including api services, and provides a free online trial of xlmr-large-qa-sv, you can try xlmr-large-qa-sv online for free by clicking the link below.
m3hrdadfi xlmr-large-qa-sv online free url in huggingface.co:
xlmr-large-qa-sv is an open source model from GitHub that offers a free installation service, and any user can find xlmr-large-qa-sv on GitHub to install. At the same time, huggingface.co provides the effect of xlmr-large-qa-sv install, users can directly use xlmr-large-qa-sv installed effect in huggingface.co for debugging and trial. It also supports api for free installation.