pythainlp/thaiqa_squad
Updated • 204 • 12
How to use Thammarak/wangchanBERTa-QA-thaiqa_squad with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("question-answering", model="Thammarak/wangchanBERTa-QA-thaiqa_squad") # Load model directly
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("Thammarak/wangchanBERTa-QA-thaiqa_squad")
model = AutoModelForQuestionAnswering.from_pretrained("Thammarak/wangchanBERTa-QA-thaiqa_squad", device_map="auto")Pretraining Model: wangchanberta-base-att-spm-uncased.
This is the wangchanberta-base-att-spm-uncased model, fine-tuned using the thaiqa_squad dataset.
https://github.com/tommyA8/wangchanBERTa-fined-tune-thaiqa_squad
Remove HTML tags using BeautifulSoup and remove punctuation using string.punctuation.
from bs4 import BeautifulSoup
example = """<doc id="376583" url="https://th.wikipedia.org/wiki?curid=376583" title="ลูนา 1">
ลูนา 1 ลูนา 1 (อี-1 ซีรีส์) ซึ่งในขณะนั้นรู้จักกันในชื่อ เมชตา (; "ความฝัน") เป็นยานอวกาศลำแรกที่เดินทางไปถึงบริเวณใกล้เคียงของดวงจันทร์
และเป็นยานอวกาศลำแรกในโครงการลูนาของโซเวียตที่สามารถปล่อยขึ้นไปในทิศทางเดียวกับดวงจันทร์ได้สำเร็จ</doc>"""
example = BeautifulSoup(example).get_text()
print(example)
#"ลูนา 1 ลูนา 1 (อี-1 ซีรีส์) ซึ่งในขณะนั้นรู้จักกันในชื่อ เมชตา (; "ความฝัน") เป็นยานอวกาศลำแรกที่เดินทางไปถึงบริเวณใกล้เคียงของดวงจันทร์และเป็นยานอวกาศลำแรกในโครงการลูนาของโซเวียตที่สามารถปล่อยขึ้นไปในทิศทางเดียวกับดวงจันทร์ได้สำเร็จ"
import string
punct = string.punctuation
no_punct = [char for char in example if char not in punct]
example = ''.join(no_punct)
print(example)
#"ลูนา 1 ลูนา 1 อี1 ซีรีส์ ซึ่งในขณะนั้นรู้จักกันในชื่อ เมชตา ความฝัน เป็นยานอวกาศลำแรกที่เดินทางไปถึงบริเวณใกล้เคียงของดวงจันทร์ และเป็นยานอวกาศลำแรกในโครงการลูนาของโซเวียตที่สามารถปล่อยขึ้นไปในทิศทางเดียวกับดวงจันทร์ได้สำเร็จ"