CoolFace
Modelpublic

devxyasir/historical-gpt2-finetuned

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes12downloads
Model Card

๐Ÿง  historical-gpt2-finetuned

โœจ Model Summary

A custom fine-tuned version of gpt2 trained on 500 conversational question-answer pairs focused on the Two-Nation Theory, the Pakistan Movement, and key historical figures like Jinnah and Iqbal. This model generates historically-aligned answers in a chatbot-style format, simulating a Q\&A assistant.


๐Ÿ“Œ Model Details

PropertyValue
Base ModelGPT-2 (gpt2)
Fine-tuned ByMuhammad Yasir (DevSecure)
LanguageEnglish (conversational, formal tone)
Dataset Size500 examples (JSONL format)
Use CaseConversational history tutor, education, research
Training Loss0.1233 (after 3 epochs)
Trained onCustom .jsonl file with Two-Nation Theory Q\&A
LicenseMIT

๐Ÿ“š Dataset Description

The dataset simulates a dialogue between:

  • โ€”Yasir (asking questions)
  • โ€”AI (providing accurate, historical answers)

Example:

json
{"text": "Yasir: What was the Two-Nation Theory?\nAI: The Two-Nation Theory stated that Muslims and Hindus were two distinct nations with their own customs, religion, and traditions, and therefore Muslims should have a separate homeland.\n"}

Source Materials Used for Data Curation:

  • โ€”Wikipedia: Two-Nation Theory
  • โ€”Books: Jinnah of Pakistan, India Wins Freedom, Iqbal's Speeches
  • โ€”Academic journals and historical PDFs

๐ŸŽฏ Intended Use

โœ… Direct Use

  • โ€”Chatbot-style app for history Q\&A
  • โ€”Teaching tool for Pakistan studies
  • โ€”Historical assistant for students and researchers
  • โ€”Offline history tutor for smart learning platforms

๐Ÿšซ Out-of-Scope

  • โ€”Use in political argumentation or manipulation
  • โ€”Interpretation of modern geopolitical conflicts
  • โ€”Multilingual outputs (no Urdu in current version)

โš ๏ธ Risks, Biases, and Limitations

  • โ€”Model reflects curated historical narratives from available sources; potential for bias in interpretation.
  • โ€”May hallucinate or extrapolate when asked questions far beyond the dataset scope.
  • โ€”Not intended for factual legal or political conclusions.

๐Ÿ›  How to Use (Code Snippet)

python
from transformers import pipeline

generator = pipeline("text-generation", model="jamyasir/historical-gpt2-finetuned")

prompt = "Yasir: What was Gandhi's opinion on the Two-Nation Theory?\nAI:"
response = generator(prompt, max_length=100, do_sample=True, temperature=0.7)[0]['generated_text']
print(response)

๐Ÿ“ˆ Training & Hyperparameters

ConfigValue
Epochs3
OptimizerAdamW (default)
Max Length128 tokens
TokenizerGPT-2 (pad_token = eos_token)
Learning Rate5e-5
FrameworkHugging Face Trainer

โœ… Evaluation Examples

Seen Prompt

Prompt: Yasir: Who introduced the Two-Nation Theory?\nAI: Response:

The concept was popularized by Allama Iqbal in 1930 and later advocated by Muhammad Ali Jinnah.

Unseen Prompt

Prompt: Yasir: Why did Jinnah believe Muslims needed a separate homeland?\nAI: Response:

Jinnah believed that due to religious and cultural differences, Muslims needed an independent state to preserve their identity and rights.

๐ŸŒฑ Environmental Impact

  • โ€”Hardware: Local GPU (RTX 3060) / CPU fallback
  • โ€”Training Time: \~5 minutes
  • โ€”Carbon Emissions: Negligible for 500-sample fine-tuning

๐Ÿง  Architecture & Objective

  • โ€”Base: GPT-2, decoder-only transformer
  • โ€”Objective: Causal Language Modeling (CLM)
  • โ€”Modified? No architectural changes; fine-tuning only

โœ๏ธ Citation

bibtex
@misc{yasir2025twonationgpt2,
  author       = {Muhammad Yasir},
  title        = {GPT-2 Fine-Tuned on Two-Nation Theory Debates},
  howpublished = {\url{https://huggingface.co/jamyasir/historical-gpt2-finetuned}},
  year         = {2025}
}

๐Ÿ™Œ Author

Muhammad Yasir AI Engineer | Full Stack Developer ๐Ÿ“ Lodhran, Pakistan ๐ŸŒ Portfolio โœ‰๏ธ jamyasir0534@gmail.com ๐Ÿค— Hugging Face Profile