Downloads · 30 days
7
14% of all-time downloads
nguyennghia0902/electra-small-discriminator_0.0005_32
electra-small-discriminator_0.0005_32 is a question answering model from nguyennghia0902. Use it when the input is a question plus a passage. It is set up for transformers. The card lists the license as apache-2.0.
probably proofread and complete it, then remove this comment. --
Downloads · 30 days
7
14% of all-time downloads
All-time downloads
49
Public
Repo size
542 MB
Likes
0
Public
Click a slice to open those files.
.h554.2 MB · 98%
From the Hugging Face model README
This model is a fine-tuned version of google/electra-small-discriminator on Vietnamese dataset. It achieves the following results on the evaluation set:
The following hyperparameters were used during training:
| Train Loss | Train End Logits Accuracy | Train Start Logits Accuracy | Validation Loss | Validation End Logits Accuracy | Validation Start Logits Accuracy | Epoch |
|---|---|---|---|---|---|---|
| 3.4201 | 0.2553 | 0.2310 | 2.6430 | 0.3942 | 0.3704 | 1 |
| 2.7588 | 0.3762 | 0.3462 | 2.2758 | 0.4660 | 0.4482 | 2 |
| 2.4695 | 0.4323 | 0.3983 | 2.0056 | 0.5211 | 0.5006 | 3 |
| 2.2478 | 0.4745 | 0.4407 | 1.7412 | 0.5763 | 0.5595 | 4 |
| 2.0321 | 0.5186 | 0.4864 | 1.5126 | 0.6289 | 0.6095 | 5 |
| 1.8186 | 0.5614 | 0.5319 | 1.2839 | 0.6719 | 0.6647 | 6 |
| 1.6012 | 0.6060 | 0.5760 | 1.0431 | 0.7322 | 0.7264 | 7 |
| 1.3677 | 0.6561 | 0.6257 | 0.8193 | 0.7857 | 0.7770 | 8 |
| 1.1450 | 0.7023 | 0.6765 | 0.6373 | 0.8275 | 0.8215 | 9 |
| 0.9748 | 0.7441 | 0.7181 | 0.5570 | 0.8476 | 0.8405 | 10 |
from transformers import ElectraTokenizerFast, TFElectraForQuestionAnswering
model_hf = "nguyennghia0902/electra-small-discriminator_0.0005_32"
tokenizer = ElectraTokenizerFast.from_pretrained(model_hf)
reload_model = TFElectraForQuestionAnswering.from_pretrained(model_hf)
question = "Ký túc xá Đại học Quốc gia Thành phố Hồ Chí Minh bao gồm có bao nhiêu khu?"
context = "Ký túc xá Đại học Quốc gia Thành phố Hồ Chí Minh (Ký túc xá ĐHQG-TPHCM) là hệ thống ký túc xá xây tại Khu đô thị Đại học Quốc gia Thành phố Hồ Chí Minh (còn gọi với tên phổ biến: Khu đô thị ĐHQG-HCM hay Làng Đại học Thủ Đức). Ký túc xá ĐHQG-TPHCM gồm có 02 khu: A và B. Địa chỉ: Đường Tạ Quang Bửu, Khu phố 6, phường Linh Trung, thành phố Thủ Đức, Thành phố Hồ Chí Minh, điện thoại: 1900 05 55 59 (111). "
inputs = tokenizer(question, context, return_offsets_mapping=True, return_tensors="tf",m ax_length=512, truncation=True)
offset_mapping = inputs.pop("offset_mapping")
outputs = reload_model(**inputs)
answer_start_index = int(tf.math.argmax(outputs.start_logits, axis=-1)[0])
answer_end_index = int(tf.math.argmax(outputs.end_logits, axis=-1)[0])
start_char = offset_mapping[0][answer_start_index][0]
end_char = offset_mapping[0][answer_end_index][1]
predicted_answer_text = context[start_char:end_char]
print(predicted_answer_text)