| --- |
| language: |
| - th |
| license: apache-2.0 |
| pipeline_tag: summarization |
| tags: |
| - summarization |
| - thai |
| - mbart |
| - text-summarization |
| - sequence-to-sequence |
| - kordai |
| - thai-language |
| base_model: facebook/mbart-large-50 |
| --- |
| |
| # ☀️ Summer – Thai Text Summarization AI |
|
|
| <p align="center"> |
| <img src="https://i.ibb.co/fdSM9kTf/Untitled-designsummer.png" alt="Untitled-designsummer" border="0" width="250px"> |
| </p> |
|
|
| **Summer** is a state‑of‑the‑art Thai text summarization model fine‑tuned from **`facebook/mbart-large-50`** to generate concise, coherent, and context‑aware summaries of Thai‑language content. |
| It is designed to condense lengthy news articles, reports, and documents while preserving key information and maintaining natural linguistic flow. |
|
|
| --- |
|
|
| ## ✨ Features |
|
|
| - 🇹🇭 Native Thai text summarization |
| - 🔥 Fine‑tuned specifically for Thai linguistic patterns |
| - 📝 Generates fluent, readable, and information‑dense summaries |
| - ⚡ Optimised for both local and production inference |
| - 🧠 Built on mBART's powerful multilingual backbone |
| - 💡 Handles both short and long‑form Thai texts (up to 1024 tokens) |
|
|
| --- |
|
|
| ## 📋 Model Details |
|
|
| | Item | Value | |
| |------|-------| |
| | **Model** | `KordAI/summer` | |
| | **Base Model** | `facebook/mbart-large-50` | |
| | **Architecture** | MBartForConditionalGeneration | |
| | **Task** | Text Summarization | |
| | **Language** | Thai (th_TH) | |
| | **Fine‑tuning** | Supervised Fine‑Tuning (SFT) | |
| |
| --- |
| |
| ## 🎯 Intended Use |
| |
| This model is optimised for: |
| |
| - Thai news article summarisation |
| - Condensing reports and long‑form documents |
| - Digest creation for social media and blogs |
| - Academic paper summarisation (Thai) |
| - Chatbot response generation |
| - Content curation and rapid information extraction |
| |
| --- |
| |
| ## 🐍 Inference Code |
| |
| The following code is the recommended way to use Summer. It gives you full control over generation parameters and ensures correct handling of Thai language tokens. |
| |
| ```python |
| import torch |
| from transformers import AutoTokenizer, MBartForConditionalGeneration |
| |
| # 1. Configuration |
| MODEL_NAME = "KordAI/summer" |
| THAI_LANG_CODE = "th_TH" |
| |
| print(f"Loading model and tokenizer from {MODEL_NAME}...") |
|
|
| # Load tokenizer and explicitly enforce Thai language tokens |
| tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) |
| tokenizer.src_lang = THAI_LANG_CODE |
| tokenizer.tgt_lang = THAI_LANG_CODE |
|
|
| # Load the merged model weights |
| device = "cuda" if torch.cuda.is_available() else "cpu" |
| model = MBartForConditionalGeneration.from_pretrained( |
| MODEL_NAME, |
| torch_dtype=torch.float16 if device == "cuda" else torch.float32 |
| ).to(device) |
| |
| # 2. Input Thai Text |
| thai_article = ( |
| "กรมอุตุนิยมวิทยา ร่วมกับสถาบันวิจัยสภาวะแวดล้อม ได้เปิดเผยรายงานดัชนีความร้อนสะสมและสถานการณ์ " |
| "เอลนีโญที่มีแนวโน้มรุนแรงขึ้นอย่างต่อเนื่องในภูมิภาคเอเชียตะวันออกเฉียงใต้ โดยส่งผลกระทบโดยตรงต่อ " |
| "ปริมาณน้ำฝนเฉลี่ยในประเทศไทยที่ลดต่ำลงกว่าเกณฑ์ปกติถึงร้อยละ 15 ในช่วงต้นปีที่ผ่านมา ส่งผลให้ " |
| "เขื่อนหลักในภาคเหนือและภาคกลาง อาทิ เขื่อนภูมิพลและเขื่อนสิริกิต์ มีปริมาณน้ำใช้การได้จริงเหลือเพียง " |
| "ประมาณร้อยละ 30 ของความจุเท่านั้น ซึ่งถือเป็นระดับวิกฤตที่ต้องเฝ้าระวังอย่างใกล้ชิด " |
| "นักวิชาการด้านสิ่งแวดล้อมเตือนว่า ปรากฏการณ์นี้จะไม่เพียงแต่ส่งผลกระทบต่อภาคการเกษตรและการเพาะปลูก " |
| "ข้าวนาปรังเท่านั้น แต่ยังส่งผลกระทบต่อเนื่องไปถึงระบบนิเวศชายฝั่ง เนื่องจากปริมาณน้ำจืดที่ไหลลงสู่ " |
| "อ่าวไทยมีปริมาณลดลง ทำให้เกิดปัญหาป่าชายเลนเสื่อมโทรมและน้ำเค็มรุกคืบเข้าสู่พื้นที่เกษตรกรรมในแถบ " |
| "สมุทรปราการและฉะเชิงเทรา รัฐบาลจึงเตรียมประกาศมาตรการขอความร่วมมือจากทุกภาคส่วนให้ช่วยกันประหยัดน้ำ " |
| "และปรับเปลี่ยนพฤติกรรมการใช้น้ำ รวมถึงวางแผนระบบการจัดสรรน้ำแบบขั้นบันไดเพื่อสำรองน้ำไว้ใช้ในการ " |
| "อุปโภคบริโภคที่จำเป็นตลอดช่วงฤดูแล้งนี้" |
| ) |
| |
| print("\n--- Input Article ---") |
| print(thai_article) |
|
|
| # 3. Tokenize input text |
| inputs = tokenizer( |
| thai_article, |
| return_tensors="pt", |
| max_length=1024, |
| truncation=True |
| ).to(device) |
| |
| # 4. Generate Summary |
| print("\nGenerating summary...") |
| with torch.no_grad(): |
| summary_ids = model.generate( |
| inputs["input_ids"], |
| attention_mask=inputs["attention_mask"], |
| max_length=512, |
| num_beams=4, |
| no_repeat_ngram_size=3, |
| early_stopping=True, |
| # Force mBART to start generating with the Thai language token identifier |
| forced_bos_token_id=tokenizer.lang_code_to_id[THAI_LANG_CODE] |
| ) |
| |
| # 5. Decode and Print Output |
| summary_text = tokenizer.decode(summary_ids[0], skip_special_tokens=True) |
|
|
| print("\n--- Generated Summary ---") |
| print(summary_text) |
| ``` |
| |
| --- |
| |
| ## 🏋️ Training |
| |
| This model is fine‑tuned from **`facebook/mbart-large-50`** using supervised instruction tuning on a curated, large‑scale Thai summarisation corpus. |
| |
| ### Training Details |
| |
| - **Framework**: Transformers + PyTorch |
| - **Dataset**: pythainlp/thaisum |
| - **Optimisation**: AdamW with linear warmup |
| - **Training Objective**: Sequence‑to‑sequence summarisation |
| - **Language**: Thai (th_TH) |
|
|
| During training, the model learns to: |
|
|
| 1. Identify salient information in Thai text |
| 2. Maintain grammatical and stylistic consistency |
| 3. Generate fluent, natural summaries |
| 4. Preserve essential context and meaning without redundancy |
|
|
| --- |
|
|
| ## ⚠️ Limitations |
|
|
| - **Summary length**: Output length may occasionally deviate from desired bounds. |
| - **Domain specificity**: Performance may degrade on highly technical, legal, or medical texts. |
| - **Factual accuracy**: As with any generative model, occasional hallucinations or misrepresentations may occur. |
| - **Processing speed**: The mBART architecture is heavier than smaller distilled models. |
| - **Ambiguous content**: Poetic, ironic, or highly ambiguous Thai text may be challenging. |
| - **Proper nouns**: Rare or newly‑coined terms may require manual verification. |
|
|
| --- |
|
|
| ## 🔍 Performance Tips |
|
|
| - **Input length**: Keep inputs under 1024 tokens (approx. 500–700 Thai words). |
| - **Beam search**: Use `num_beams=4–8` for improved quality. |
| - **Length control**: Adjust `min_length` and `max_length` based on your use case. |
| - **Temperature**: For more deterministic outputs, keep temperature low (<1.0). |
| - **No repeat n‑gram**: Set `no_repeat_ngram_size=3` to avoid repetition. |
| - **Early stopping**: Enable for faster generation without quality loss. |
|
|
| --- |
|
|
| ## 🙏 Acknowledgements |
|
|
| Special thanks to: |
|
|
| - **Facebook AI** for the **`mbart-large-50`** base model |
| - **KordAI** for developing and fine‑tuning the summarisation model |
| - **Unsloth** for enabling efficient supervised fine‑tuning |
| - **Hugging Face** for the Transformers ecosystem |
| - The open‑source AI community for advancing multilingual NLP |
|
|
| --- |
|
|
| ## 📖 Citation |
|
|
| ```bibtex |
| @misc{summer2026, |
| title={Summer – Thai Text Summarization AI}, |
| author={KordAI}, |
| year={2026}, |
| publisher={Hugging Face}, |
| howpublished={https://huggingface.co/KordAI/summer} |
| } |
| ``` |
|
|
| --- |
|
|
| ## 📬 Contact |
|
|
| For questions, feedback, or collaboration opportunities: |
|
|
| - **KordAI Team**: naphon.jang@kmutt.ac.th |
| - **Hugging Face**: [KordAI/summer](https://huggingface.co/KordAI/summer) |
|
|
| --- |
|
|
| <p align="center"> |
| <strong>☀️ Summer – Making Thai Text Shorter, Not Less Important</strong> |
| </p> |
| ``` |