{ "cells": [ { "cell_type": "markdown", "id": "d15d8294-3328-4e07-ad16-8a03e9bbfdb9", "metadata": {}, "source": [ "# YOUR FIRST LAB\n", "### Please read this section. This is valuable to get you prepared, even if it's a long read -- it's important stuff.\n", "\n", "## Your first Frontier LLM Project\n", "\n", "Let's build a useful LLM solution - in a matter of minutes.\n", "\n", "By the end of this course, you will have built an autonomous Agentic AI solution with 7 agents that collaborate to solve a business problem. All in good time! We will start with something smaller...\n", "\n", "Our goal is to code a new kind of Web Browser. Give it a URL, and it will respond with a summary. The Reader's Digest of the internet!!\n", "\n", "Before starting, you should have completed the setup for [PC](../SETUP-PC.md) or [Mac](../SETUP-mac.md) and you hopefully launched this jupyter lab from within the project root directory, with your environment activated.\n", "\n", "## If you're new to Jupyter Lab\n", "\n", "Welcome to the wonderful world of Data Science experimentation! Once you've used Jupyter Lab, you'll wonder how you ever lived without it. Simply click in each \"cell\" with code in it, such as the cell immediately below this text, and hit Shift+Return to execute that cell. As you wish, you can add a cell with the + button in the toolbar, and print values of variables, or try out variations. \n", "\n", "I've written a notebook called [Guide to Jupyter](Guide%20to%20Jupyter.ipynb) to help you get more familiar with Jupyter Labs, including adding Markdown comments, using `!` to run shell commands, and `tqdm` to show progress.\n", "\n", "## If you're new to the Command Line\n", "\n", "Please see these excellent guides: [Command line on PC](https://chatgpt.com/share/67b0acea-ba38-8012-9c34-7a2541052665) and [Command line on Mac](https://chatgpt.com/canvas/shared/67b0b10c93a081918210723867525d2b). \n", "\n", "## If you'd prefer to work in IDEs\n", "\n", "If you're more comfortable in IDEs like VSCode or Pycharm, they both work great with these lab notebooks too. \n", "If you'd prefer to work in VSCode, [here](https://chatgpt.com/share/676f2e19-c228-8012-9911-6ca42f8ed766) are instructions from an AI friend on how to configure it for the course.\n", "\n", "## If you'd like to brush up your Python\n", "\n", "I've added a notebook called [Intermediate Python](Intermediate%20Python.ipynb) to get you up to speed. But you should give it a miss if you already have a good idea what this code does: \n", "`yield from {book.get(\"author\") for book in books if book.get(\"author\")}`\n", "\n", "## I am here to help\n", "\n", "If you have any problems at all, please do reach out. \n", "I'm available through the platform, or at ed@edwarddonner.com, or at https://www.linkedin.com/in/eddonner/ if you'd like to connect (and I love connecting!) \n", "And this is new to me, but I'm also trying out X/Twitter at [@edwarddonner](https://x.com/edwarddonner) - if you're on X, please show me how it's done 😂 \n", "\n", "## More troubleshooting\n", "\n", "Please see the [troubleshooting](troubleshooting.ipynb) notebook in this folder to diagnose and fix common problems. At the very end of it is a diagnostics script with some useful debug info.\n", "\n", "## If this is old hat!\n", "\n", "If you're already comfortable with today's material, please hang in there; you can move swiftly through the first few labs - we will get much more in depth as the weeks progress.\n", "\n", "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Please read - important note

\n", " The way I collaborate with you may be different to other courses you've taken. I prefer not to type code while you watch. Rather, I execute Jupyter Labs, like this, and give you an intuition for what's going on. My suggestion is that you carefully execute this yourself, after watching the lecture. Add print statements to understand what's going on, and then come up with your own variations. If you have a Github account, use this to showcase your variations. Not only is this essential practice, but it demonstrates your skills to others, including perhaps future clients or employers...\n", "
\n", "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Treat these labs as a resource

\n", " I push updates to the code regularly. When people ask questions or have problems, I incorporate it in the code, adding more examples or improved commentary. As a result, you'll notice that the code below isn't identical to the videos. Everything from the videos is here; but in addition, I've added more steps and better explanations, and occasionally added new models like DeepSeek. Consider this like an interactive book that accompanies the lectures.\n", " \n", "
\n", "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Business value of these exercises

\n", " A final thought. While I've designed these notebooks to be educational, I've also tried to make them enjoyable. We'll do fun things like have LLMs tell jokes and argue with each other. But fundamentally, my goal is to teach skills you can apply in business. I'll explain business implications as we go, and it's worth keeping this in mind: as you build experience with models and techniques, think of ways you could put this into action at work today. Please do contact me if you'd like to discuss more or if you have ideas to bounce off me.\n", "
" ] }, { "cell_type": "code", "execution_count": 6, "id": "4e2a9393-7767-488e-a8bf-27c12dca35bd", "metadata": {}, "outputs": [], "source": [ "# imports\n", "\n", "import os\n", "import requests\n", "from dotenv import load_dotenv\n", "from bs4 import BeautifulSoup\n", "from IPython.display import Markdown, display\n", "from openai import OpenAI\n", "\n", "# If you get an error running this cell, then please head over to the troubleshooting notebook!" ] }, { "cell_type": "markdown", "id": "6900b2a8-6384-4316-8aaa-5e519fca4254", "metadata": {}, "source": [ "# Connecting to OpenAI (or Ollama)\n", "\n", "The next cell is where we load in the environment variables in your `.env` file and connect to OpenAI. \n", "\n", "If you'd like to use free Ollama instead, please see the README section \"Free Alternative to Paid APIs\", and if you're not sure how to do this, there's a full solution in the solutions folder (day1_with_ollama.ipynb).\n", "\n", "## Troubleshooting if you have problems:\n", "\n", "Head over to the [troubleshooting](troubleshooting.ipynb) notebook in this folder for step by step code to identify the root cause and fix it!\n", "\n", "If you make a change, try restarting the \"Kernel\" (the python process sitting behind this notebook) by Kernel menu >> Restart Kernel and Clear Outputs of All Cells. Then try this notebook again, starting at the top.\n", "\n", "Or, contact me! Message me or email ed@edwarddonner.com and we will get this to work.\n", "\n", "Any concerns about API costs? See my notes in the README - costs should be minimal, and you can control it at every point. You can also use Ollama as a free alternative, which we discuss during Day 2." ] }, { "cell_type": "code", "execution_count": 7, "id": "7b87cadb-d513-4303-baee-a37b6f938e4d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "API key found and looks good so far!\n" ] } ], "source": [ "# Load environment variables in a file called .env\n", "\n", "load_dotenv(override=True)\n", "api_key = os.getenv('OPENAI_API_KEY')\n", "\n", "# Check the key\n", "\n", "if not api_key:\n", " print(\"No API key was found - please head over to the troubleshooting notebook in this folder to identify & fix!\")\n", "elif not api_key.startswith(\"sk-proj-\"):\n", " print(\"An API key was found, but it doesn't start sk-proj-; please check you're using the right key - see troubleshooting notebook\")\n", "elif api_key.strip() != api_key:\n", " print(\"An API key was found, but it looks like it might have space or tab characters at the start or end - please remove them - see troubleshooting notebook\")\n", "else:\n", " print(\"API key found and looks good so far!\")\n" ] }, { "cell_type": "code", "execution_count": 8, "id": "019974d9-f3ad-4a8a-b5f9-0a3719aea2d3", "metadata": {}, "outputs": [], "source": [ "openai = OpenAI()\n", "\n", "# If this doesn't work, try Kernel menu >> Restart Kernel and Clear Outputs Of All Cells, then run the cells from the top of this notebook down.\n", "# If it STILL doesn't work (horrors!) then please see the Troubleshooting notebook in this folder for full instructions" ] }, { "cell_type": "markdown", "id": "442fc84b-0815-4f40-99ab-d9a5da6bda91", "metadata": {}, "source": [ "# Let's make a quick call to a Frontier model to get started, as a preview!" ] }, { "cell_type": "code", "execution_count": 9, "id": "a58394bf-1e45-46af-9bfd-01e24da6f49a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello! Welcome! I'm glad to hear from you. How can I assist you today?\n" ] } ], "source": [ "# To give you a preview -- calling OpenAI with these messages is this easy. Any problems, head over to the Troubleshooting notebook.\n", "\n", "message = \"Hello, GPT! This is my first ever message to you! Hi!\"\n", "response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=[{\"role\":\"user\", \"content\":message}])\n", "print(response.choices[0].message.content)" ] }, { "cell_type": "markdown", "id": "2aa190e5-cb31-456a-96cc-db109919cd78", "metadata": {}, "source": [ "## OK onwards with our first project" ] }, { "cell_type": "code", "execution_count": 10, "id": "c5e793b2-6775-426a-a139-4848291d0463", "metadata": {}, "outputs": [], "source": [ "# A class to represent a Webpage\n", "# If you're not familiar with Classes, check out the \"Intermediate Python\" notebook\n", "\n", "# Some websites need you to use proper headers when fetching them:\n", "headers = {\n", " \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36\"\n", "}\n", "\n", "class Website:\n", "\n", " def __init__(self, url):\n", " \"\"\"\n", " Create this Website object from the given url using the BeautifulSoup library\n", " \"\"\"\n", " self.url = url\n", " response = requests.get(url, headers=headers)\n", " soup = BeautifulSoup(response.content, 'html.parser')\n", " self.title = soup.title.string if soup.title else \"No title found\"\n", " for irrelevant in soup.body([\"script\", \"style\", \"img\", \"input\"]):\n", " irrelevant.decompose()\n", " self.text = soup.body.get_text(separator=\"\\n\", strip=True)" ] }, { "cell_type": "code", "execution_count": 12, "id": "2ef960cf-6dc2-4cda-afb3-b38be12f4c97", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Haq Nawaz - Bridging AI & Islamic Scholarship\n", "☰\n", "Introduction\n", "🕌 Imams of Haramain\n", "Imam Masjid-e-Nabawi\n", "Imam-e-Kaaba Juhany\n", "Imam Khalid Al-Ghamidi\n", "Projects\n", "ISDP\n", "Altasreef\n", "Easy Quran\n", "Mohaddis\n", "Tanzeem\n", "AI & NLP\n", "Mobile Apps\n", "The Noble Quran\n", "Tazkeer Ul Quran\n", "Seerat Quiz\n", "وجود باری تعالیٰ اور توحید\n", "Publications\n", "Awards\n", "Brainiac 2018\n", "NaSCon 2019\n", "Contact\n", "Haq Nawaz\n", "Islamic Scholar\n", "|\n", "NLP & AI Specialist\n", "|\n", "Islamic Digital Solutions Expert\n", "About Me\n", "Get in Touch\n", "Introduction\n", "I am\n", "Haq Nawaz\n", ", a faculty member at\n", "Jamia Ashrafia Lahore\n", ", a\n", "PhD Scholar in NLP\n", "at\n", "COMSATS University Lahore\n", ", and a\n", "Data Science Consultant at ILI.DIGITAL AG\n", ". I specialize in bridging modern artificial intelligence with\n", " classical Islamic sciences — leading pioneering efforts in\n", "Islamic software development\n", ", digitization, and\n", "AI-powered Qur'anic and Hadith tools\n", "for education,\n", " research, and public benefit.\n", "As one of the earliest contributors to\n", "Urdu Unicode content digitization\n", ", my work has\n", " enabled millions of words from classical texts—including the Qur’an,\n", " Hadith, and foundational Islamic literature—to become searchable,\n", " readable, and interactive across platforms. These efforts laid the\n", " groundwork for major portals such as\n", "Easy Quran wa Hadees\n", "and\n", "Tanzeem Islami Digital Library\n", ".\n", "I’ve developed award-winning educational platforms like\n", "Altasreef\n", ", which automates Arabic verb conjugations with Urdu translations and\n", " exam generation, earning 1st Prize at UET Lahore’s Brainiac 2018. At\n", " NaSCon 2019 (FAST-NUCES), my personal R&D project in\n", "Quranic NLP annotation\n", "—involving 5.4+ million\n", " attribute labels in three languages—was also recognized nationally.\n", "My mobile applications include the\n", "The Noble Quran\n", "and\n", "آسان ترجمہ قرآن\n", "apps, presenting the renowned English and Urdu translations and tafsir\n", " by\n", "Mufti Taqi Usmani\n", "for scholars and general readers\n", " alike. I’ve also developed\n", "Tazkeer-ul-Quran\n", ", which offers multilingual Qur’an translations and thematic\n", " organization for deep reflection; the\n", "Seerat Quiz\n", "app, designed to teach Seerah to school-going children through\n", " interactive learning; and\n", "وجود باري تعالى اور توحید\n", ", a digital presentation of Islamic scholarship, continuing my\n", " mission of\n", "digitizing authentic Islamic texts\n", "for the\n", " digital age.\n", "Visit of Imam Masjid-e-Nabawi Dr. Salah Al-Budair – August 15, 2024\n", "During the visit of\n", "Imam Masjid-e-Nabawi Dr. Salah Al-Budair\n", "on\n", "August 15, 2024\n", ", I had the honor of presenting our\n", " research and technological contributions in the field of\n", "Arabic morphology (علم الصرف)\n", ". We discussed how\n", " Natural Language Processing (NLP) and AI can simplify classical\n", " grammar learning for students.\n", "Your browser does not support the video tag.\n", "Visit of Imam-e-Kaaba Dr. Sheikh Abdullah Awad Al-Juhany – April 16,\n", " 2019\n", "During the visit of\n", "Imam-e-Kaaba Dr. Sheikh Abdullah Awad Al-Juhany\n", "on\n", "April 16, 2019\n", ", we explored the integration of\n", " technology in teaching\n", "classical Arabic\n", ". Our\n", " discussion focused on how digital tools and platforms can enhance the\n", " learning experience, making classical Arabic more accessible to\n", " students worldwide.\n", "Your browser does not support the video tag.\n", "Visit of Imam Khalid Al-Ghamidi – 2015\n", "During his 2015 visit to\n", "Jamia Ashrafia\n", ", I had\n", " the honor of presenting my work in\n", "Qur'anic Natural Language Processing (NLP)\n", "and\n", "Islamic tools\n", "to Sheikh Khalid Al-Ghamidi, Imam\n", " of Masjid Al-Haram. Our discussion highlighted the implementation\n", " of\n", "Qur'an morphological tagging\n", ", emphasizing its role in enhancing students' understanding of\n", " classical Arabic and deepening their comprehension of the Qur'anic\n", " text.\n", "🎓 Education\n", "PhD Scholar in Computer Science (NLP & AI)\n", "–\n", " COMSATS University Lahore\n", "Graduation in Dars-e-Nizami / Classical Arabic\n", "–\n", " Jamia Ashrafia, Lahore\n", "MS in Computer Science\n", "– University of Central\n", " Punjab, Lahore\n", "Projects & Innovations\n", "ISDP – Intensive Software Development Program\n", "– A groundbreaking initiative to empower graduates of Islamic\n", " Madrasahs with modern computer science and software engineering\n", " skills.\n", "Tailored curriculum for scholars with no prior tech background\n", "Practical training in web development, databases, and Python\n", "Students build real Islamic apps and digital tools for da'wah\n", "Promoting the digitization of Islamic knowledge through\n", " scholar-led innovation\n", "Graduates have secured positions in reputable software houses\n", " such as InstaCare and E Web Craft, contributing as mobile\n", " application and web developers.\n", "View success stories here\n", ".\n", "ISDP reflects my passion for integrating sacred knowledge with\n", " cutting-edge technology. It aims to equip our ulema with the tools\n", " to lead in the digital world — not just follow. The success of our\n", " graduates in the tech industry underscores the program's\n", " effectiveness in bridging traditional Islamic scholarship with\n", " modern technological expertise.\n", "Altasreef\n", "– An AI-powered Arabic morphology (علم الصرف) learning platform that\n", " combines linguistic knowledge with NLP techniques to support\n", " students of classical Arabic grammar.\n", "Generates full verb conjugations for ماضی معروف، مضارع معروف،\n", " امر، مجہول، منصوب، مجزوم، and more\n", "Covers multiple صرف patterns (باب) like باب سمع، باب فتح، باب\n", " نصر، باب استفعال، باب انفعال etc.\n", "Offers full interface and output in\n", "Urdu, English, and Arabic\n", "Integrates rule-based NLP logic to model triliteral verb roots\n", " with pattern-based transformations\n", "Automatically generates\n", "Urdu translations\n", "using\n", " morphology-aware translation patterns\n", "Includes an\n", "Online Exam Generator\n", "to create practice worksheets for students with or without\n", " answers (ideal for madrassah & school use)\n", "Exam sheets can be downloaded for offline revision or classroom\n", " printing\n", "This project was awarded\n", "1st Prize at the Brainiac Software Competition 2018\n", "(UET Lahore) for digitizing Islamic linguistic education. The\n", " underlying model and linguistic approach were also published as a\n", " research paper at\n", "AbjadNLP 2025 (COLING)\n", ":\n", "Read the paper\n", ".\n", "Easy Quran wa Hadees\n", "– A groundbreaking initiative and one of the\n", "first Urdu Unicode-based Quran and Hadith platforms in\n", " Pakistan\n", ". As a\n", "pioneer developer\n", ", I led the transformation\n", " of classical Islamic texts into a digital, Unicode-compliant\n", " format—setting a new benchmark in Islamic digitization.\n", "Provides the complete Quran with authentic translations in\n", "Urdu, English, and Arabic\n", "Includes key Hadith collections like\n", "Sahih Bukhari\n", ",\n", "Muslim\n", ",\n", "Abu Dawood\n", ", and more\n", "Uses early\n", "NLP and intelligent indexing techniques\n", "for\n", " fast, root-based and keyword search\n", "Offers advanced filters for Hadith search by narrator, topic, or\n", " source\n", "Audio playback support for Quranic recitation and memorization\n", "Features bookmarking, note-taking, and tagging capabilities\n", "Fully localized interface supporting\n", "multilingual access\n", "(Urdu, English, Arabic)\n", "This platform played a\n", "transformative role\n", "in\n", " opening digital Islamic access for Urdu-speaking users. Its\n", " underlying data and architecture have been\n", "adopted by numerous mobile apps and online platforms\n", "across Pakistan and globally. Easy Quran wa Hadees stands as a\n", "milestone in the history of Islamic digitization\n", ".\n", "Mohaddis.com\n", "– A comprehensive Hadith research platform designed for\n", " Urdu-speaking audiences, offering easy access to authenticated\n", " Hadith books with cutting-edge digital tools for exploration,\n", " referencing, and learning.\n", "Includes\n", "major Hadith books\n", ", including Sahih\n", " Bukhari, Sahih Muslim, Abu Dawood, Tirmidhi, Nasai, Ibn Majah,\n", " and Muwatta\n", "Equipped with\n", "advanced full-text search\n", "that\n", " works across Arabic and Urdu translations\n", "Allows filtering by\n", "book, subject, chapter, narrator, or Hadith number\n", "Offers parallel\n", "Arabic and Urdu rendering\n", "for\n", " each Hadith\n", "Integrated with\n", "Fiqh-based categorization\n", "and\n", " references to facilitate deeper learning and contextual\n", " understanding\n", "Continuously updated with\n", "editorial corrections and scholarly cross-referencing\n", "Shareable links to every Hadith and the ability to bookmark for\n", " future research\n", "Mohaddis.com stands out as a\n", "reference-grade Hadith resource\n", "and a key part of\n", " the modern Islamic digital library in Pakistan. Its combination of\n", " traditional content and modern UX has made it widely adopted in\n", " scholarly circles and educational institutes.\n", "Tanzeem Islami Digital Library\n", "– A pioneering content digitization project that transformed\n", " classical Islamic literature—originally authored in Urdu and typeset\n", " in InPage—into modern, searchable Unicode format. This initiative\n", " laid the foundation for preserving Islamic scholarship through\n", " technology.\n", "Digitized and indexed a vast collection of books by\n", "Islami thinkers, scholars, and reformers\n", "Utilized early\n", "InPage-to-Unicode conversion pipelines\n", "to make\n", " printed books digitally searchable\n", "Enables\n", "full-text search\n", "across books by\n", " keyword, topic, author, or chapter\n", "Supported by\n", "backend NLP tools\n", "for content\n", " tagging and semantic classification\n", "Offers both web-based browsing and categorized downloadable\n", " content (PDF + Unicode HTML)\n", "Public access to rare Islamic literature previously locked in\n", " print archives\n", "As one of the\n", "first major Urdu digitization efforts for Islamic books in\n", " Pakistan\n", ", this project set a trend in religious archiving and inspired\n", " many modern Islamic libraries and apps. The platform is now\n", " referenced by scholars, students, and researchers worldwide.\n", "Advancing AI, NLP & LLM Solutions\n", "I lead the development of intelligent language systems powered by\n", "Large Language Models (LLMs)\n", "and advanced retrieval mechanisms, applying state-of-the-art AI research to real-world applications.\n", "Large Language Model (LLM) Solutions\n", "Fine-tuned GPT-based models for text summarization, generation, and multi-turn conversations\n", "Implemented Named Entity Recognition (NER), classification, and topic modeling using transformer architectures\n", "Designed\n", "zero-shot and few-shot learning pipelines\n", "to support under-resourced languages like Arabic and Urdu\n", "Retrieval-Augmented Generation (RAG) & Vector-Based Search\n", "Built modular RAG systems combining retrieval pipelines with LLMs to deliver accurate, real-time responses\n", "Integrated\n", "vector databases\n", "for semantic search and contextual relevance\n", "Developed NLP solutions for diverse sectors including\n", "law, education, healthcare, and enterprise services\n", "AI System Deployment\n", "Integrated cloud services such as AWS (S3, Lambda, Textract, SageMaker) and Azure ML pipelines\n", "Led agile teams of developers and QA for rapid prototyping and production-grade deployment\n", "Utilized Docker, FastAPI, and scalable Python architectures for NLP APIs\n", "I also apply AI to\n", "Arabic morphology and morpheme-level analysis\n", "to develop tools that assist in classical Arabic understanding, such as pattern-based conjugation, morphological tagging, and root extraction.\n", "These innovations bring together AI research and production-ready NLP systems to solve complex language problems and deliver meaningful impact across industries.\n", "📱 Mobile Apps – Qur’anic Tech in Your Pocket\n", "Bridging the gap between sacred knowledge and modern convenience,\n", " these mobile applications are designed to make the Qur'an and Islamic\n", " studies accessible to everyone, anywhere, anytime.\n", "The Noble Quran\n", "– Official app featuring\n", "Mufti Taqi Usmani’s authoritative English translation\n", "of the Qur’an. Designed for students, scholars, and general readers\n", " seeking clarity and depth in Qur’anic interpretation.\n", "Complete English translation enriched with explanatory footnotes\n", " based on classical Tafsir sources\n", "Regex-based Arabic search functionality for advanced users to\n", " explore verse patterns and linguistic structures\n", "Streamlined verse-by-verse navigation and modern reading\n", " experience\n", "Offline readability, bookmarking, and search history tracking\n", "Widely used by scholars, researchers, and institutes as a\n", " reliable digital resource\n", "Tazkeer-ul-Quran (Android App)\n", "– A lightweight, modern Qur’anic reflection tool featuring\n", " topic-based verse collections, multilingual translations, and a\n", " clean user interface.\n", "Explore categorized themes and Qur’anic wisdom through\n", " handpicked verses\n", "Multilingual support: Urdu, English, Sindhi, Pashto, and Hindi\n", "Smart search engine allows searching in any language supported\n", " in the app\n", "Bookmark functionality for saving favorite verses\n", "Designed for both general users and advanced learners\n", "Seerat Quiz App\n", "– A fun and engaging Islamic quiz app focused on the\n", "Seerat (biography)\n", "of Prophet Muhammad ﷺ, specially\n", " designed for\n", "kids and school-going learners\n", ".\n", "Built for children and beginners to explore the Seerah in an\n", " interactive way\n", "Multiple-choice questions to reinforce learning about the life\n", " of the Prophet ﷺ\n", "Child-friendly interface with easy navigation and visual\n", " engagement\n", "Ideal for\n", "Islamic schools, homeschooling, and weekend\n", " madrassahs\n", "Score-based system to encourage progress and retention\n", "Lightweight, responsive, and crafted for mobile-first usage\n", "This app introduces young minds to the noble character and\n", " important milestones in the life of the Prophet ﷺ through engaging\n", " quizzes. It's a stepping stone toward developing love and\n", " connection with Seerah through modern technology.\n", "Tuheed (توَحید) App\n", "– A mobile presentation of the classic Islamic work\n", "\"وجود باری تعالیٰ اور توحید\"\n", "by\n", "Professor Dr. Malik Ghulam Murtaza (PhD)\n", ". This app\n", " brings the essential doctrine of\n", "Tawheed (Monotheism)\n", "to readers in a clean, digital\n", " experience.\n", "Covers the true meaning of Tawheed: the oneness of Allah in His\n", " being, attributes, and actions — without partner, peer, or need\n", "Explains Allah’s exclusive authority using\n", "Qur'anic verses, rational proofs, and classical\n", " definitions\n", "Includes citations like Surah Al-Ikhlas and definitions from\n", " scholars such as\n", "Imam Al-Jurjani\n", "Built from digitized content developed during my early work in\n", "Urdu Islamic content digitization\n", "projects\n", "Urdu-language app with smooth navigation and offline readability\n", "This app is part of my broader vision to\n", "digitally preserve and repurpose classical Islamic\n", " literature\n", "—transitioning it from scanned archives to searchable web\n", " libraries, and now to\n", "interactive mobile applications\n", ". It invites users\n", " to reflect on the foundation of Islamic belief:\n", "La ilaha illAllah\n", "— there is no deity but Allah.\n", "Publications\n", "Automated Generation of Arabic Verb Conjugations with\n", " Multilingual Urdu Translation: An NLP Approach\n", "–\n", "AbjadNLP 2025 Workshop, COLING\n", "Authors: Haq Nawaz (COMSATS University, Pakistan), Manal Elobaid\n", " (Qatar University), Ali al-Laith (Copenhagen University), Saif\n", " Ullah (ILI.digital, Pakistan)\n", "Read Paper (ACL Anthology)\n", "Arabic Natural Language Processing for Qur’anic Research: A\n", " Systematic Review\n", "–\n", "Artificial Intelligence Review, 2023\n", "Authors: Muhammad Huzaifa Bashir (Information Technology\n", " University, Pakistan), Aqil M. Azmi (King Saud University, Saudi\n", " Arabia), Haq Nawaz (Jamia Ashrafia & PUCIT, Pakistan), Wajdi\n", " Zaghouani (Hamad Bin Khalifa University, Qatar), Mona Diab (George\n", " Washington University, USA), Ala Al‑Fuqaha (HBKU, Qatar), Junaid\n", " Qadir (Qatar University)\n", "Read on Springer\n", "Stars at Qur’an QA 2022: Building Automatic Extractive Question\n", " Answering Systems for the Holy Qur’an with Transformer Models and\n", " Releasing a New Dataset\n", "–\n", "Qur'an QA Shared Task, OSACT Workshop, LREC 2022\n", "Authors: Ahmed Wasfey (Tactful AI), Eman Elrefai (BambooGeeks),\n", " Marwa Muhammad (Freelancer), Haq Nawaz (PUCIT)\n", "Read on ACL Anthology\n", "Sentimental Analysis of Social Media to Find Out Customer\n", " Opinion\n", "Intelligent Technologies and Applications, 2019\n", "Read on Springer\n", "Development of AI-Based System for Teaching Classical Arabic &\n", " Qur’anic Vocabularies\n", "QURANICA – International Journal of Quranic Research, 2018\n", "Read on UM Journal\n", "Data Set Generation for the Attributes of the Words of the Holy\n", " Quran\n", "Taibah University Conference, 2013\n", "Read on IEEE Xplore\n", "View all publications on Google Scholar\n", "🏆 1st Prize – Brainiac Software Competition 2018 (UET Lahore)\n", "Awarded for the development of\n", "Altasreef\n", ", an AI-powered Arabic morphology trainer that generates verb\n", " conjugations across classical patterns along with Urdu translations.\n", "The project was recognized for its\n", "innovation in digitizing classical Arabic linguistics\n", "and its utility for\n", "Classical Arabic, language learners, and NLP researchers\n", ". Altasreef introduced:\n", "Automated صرف (morphology) generation in Arabic\n", "Multilingual output: Arabic, Urdu, and English interface\n", "NLP-inspired pattern recognition and root-based transformation\n", "Downloadable exams for student practice\n", "Your browser does not support the video tag.\n", "This award recognized the project's excellence in applying\n", " cutting-edge technology to traditional Islamic education and\n", " showcased its relevance at the national level.\n", "🏆 NLP Research Award – NaSCon 2019 (FAST-NUCES)\n", "Recognized for groundbreaking personal R&D work in\n", "Natural Language Processing of Qur’anic text\n", ", where\n", " I manually segmented, tagged, and annotated a large-scale dataset of\n", " the Holy Quran for multi-language NLP applications.\n", "The core project involved:\n", "Tagging and annotating\n", "over 80,000+ Quranic words\n", "Marking\n", "23 detailed linguistic attributes per word\n", "including root, tense, gender, case, mood, and more\n", "Multi-language annotation:\n", "Arabic, Urdu, and English\n", "Over\n", "5.4 million total attribute labels\n", "across\n", " the entire corpus\n", "Designed for advanced NLP research, educational tools, and\n", " AI-based Quranic analysis\n", "Your browser does not support the video tag.\n", "This recognition at\n", "NaSCon 2019 (FAST-NUCES)\n", "celebrated my\n", "independent research in the Indo-Pak Uthmani script\n", ", and established a foundation for advanced Qur’anic datasets in\n", " multilingual NLP environments. The annotated dataset continues to\n", " support various AI projects in Arabic linguistics and Quranic\n", " education.\n", "Contact Me\n", "Let's connect! Feel free to reach out.\n", "Email Me\n", "GitHub\n", "LinkedIn\n", "© 2025 Haq Nawaz. All rights reserved.\n" ] } ], "source": [ "# Let's try one out. Change the website and add print statements to follow along.\n", "\n", "ed = Website(\"https://haqnawaz.org\")\n", "print(ed.title)\n", "print(ed.text)" ] }, { "cell_type": "markdown", "id": "6a478a0c-2c53-48ff-869c-4d08199931e1", "metadata": {}, "source": [ "## Types of prompts\n", "\n", "You may know this already - but if not, you will get very familiar with it!\n", "\n", "Models like GPT4o have been trained to receive instructions in a particular way.\n", "\n", "They expect to receive:\n", "\n", "**A system prompt** that tells them what task they are performing and what tone they should use\n", "\n", "**A user prompt** -- the conversation starter that they should reply to" ] }, { "cell_type": "code", "execution_count": 13, "id": "abdb8417-c5dc-44bc-9bee-2e059d162699", "metadata": {}, "outputs": [], "source": [ "# Define our system prompt - you can experiment with this later, changing the last sentence to 'Respond in markdown in Spanish.\"\n", "\n", "system_prompt = \"You are an assistant that analyzes the contents of a website \\\n", "and provides a short summary, ignoring text that might be navigation related. \\\n", "Respond in markdown.\"" ] }, { "cell_type": "code", "execution_count": 14, "id": "f0275b1b-7cfe-4f9d-abfa-7650d378da0c", "metadata": {}, "outputs": [], "source": [ "# A function that writes a User Prompt that asks for summaries of websites:\n", "\n", "def user_prompt_for(website):\n", " user_prompt = f\"You are looking at a website titled {website.title}\"\n", " user_prompt += \"\\nThe contents of this website is as follows; \\\n", "please provide a short summary of this website in markdown. \\\n", "If it includes news or announcements, then summarize these too.\\n\\n\"\n", " user_prompt += website.text\n", " return user_prompt" ] }, { "cell_type": "code", "execution_count": 15, "id": "26448ec4-5c00-4204-baec-7df91d11ff2e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "You are looking at a website titled Haq Nawaz - Bridging AI & Islamic Scholarship\n", "The contents of this website is as follows; please provide a short summary of this website in markdown. If it includes news or announcements, then summarize these too.\n", "\n", "☰\n", "Introduction\n", "🕌 Imams of Haramain\n", "Imam Masjid-e-Nabawi\n", "Imam-e-Kaaba Juhany\n", "Imam Khalid Al-Ghamidi\n", "Projects\n", "ISDP\n", "Altasreef\n", "Easy Quran\n", "Mohaddis\n", "Tanzeem\n", "AI & NLP\n", "Mobile Apps\n", "The Noble Quran\n", "Tazkeer Ul Quran\n", "Seerat Quiz\n", "وجود باری تعالیٰ اور توحید\n", "Publications\n", "Awards\n", "Brainiac 2018\n", "NaSCon 2019\n", "Contact\n", "Haq Nawaz\n", "Islamic Scholar\n", "|\n", "NLP & AI Specialist\n", "|\n", "Islamic Digital Solutions Expert\n", "About Me\n", "Get in Touch\n", "Introduction\n", "I am\n", "Haq Nawaz\n", ", a faculty member at\n", "Jamia Ashrafia Lahore\n", ", a\n", "PhD Scholar in NLP\n", "at\n", "COMSATS University Lahore\n", ", and a\n", "Data Science Consultant at ILI.DIGITAL AG\n", ". I specialize in bridging modern artificial intelligence with\n", " classical Islamic sciences — leading pioneering efforts in\n", "Islamic software development\n", ", digitization, and\n", "AI-powered Qur'anic and Hadith tools\n", "for education,\n", " research, and public benefit.\n", "As one of the earliest contributors to\n", "Urdu Unicode content digitization\n", ", my work has\n", " enabled millions of words from classical texts—including the Qur’an,\n", " Hadith, and foundational Islamic literature—to become searchable,\n", " readable, and interactive across platforms. These efforts laid the\n", " groundwork for major portals such as\n", "Easy Quran wa Hadees\n", "and\n", "Tanzeem Islami Digital Library\n", ".\n", "I’ve developed award-winning educational platforms like\n", "Altasreef\n", ", which automates Arabic verb conjugations with Urdu translations and\n", " exam generation, earning 1st Prize at UET Lahore’s Brainiac 2018. At\n", " NaSCon 2019 (FAST-NUCES), my personal R&D project in\n", "Quranic NLP annotation\n", "—involving 5.4+ million\n", " attribute labels in three languages—was also recognized nationally.\n", "My mobile applications include the\n", "The Noble Quran\n", "and\n", "آسان ترجمہ قرآن\n", "apps, presenting the renowned English and Urdu translations and tafsir\n", " by\n", "Mufti Taqi Usmani\n", "for scholars and general readers\n", " alike. I’ve also developed\n", "Tazkeer-ul-Quran\n", ", which offers multilingual Qur’an translations and thematic\n", " organization for deep reflection; the\n", "Seerat Quiz\n", "app, designed to teach Seerah to school-going children through\n", " interactive learning; and\n", "وجود باري تعالى اور توحید\n", ", a digital presentation of Islamic scholarship, continuing my\n", " mission of\n", "digitizing authentic Islamic texts\n", "for the\n", " digital age.\n", "Visit of Imam Masjid-e-Nabawi Dr. Salah Al-Budair – August 15, 2024\n", "During the visit of\n", "Imam Masjid-e-Nabawi Dr. Salah Al-Budair\n", "on\n", "August 15, 2024\n", ", I had the honor of presenting our\n", " research and technological contributions in the field of\n", "Arabic morphology (علم الصرف)\n", ". We discussed how\n", " Natural Language Processing (NLP) and AI can simplify classical\n", " grammar learning for students.\n", "Your browser does not support the video tag.\n", "Visit of Imam-e-Kaaba Dr. Sheikh Abdullah Awad Al-Juhany – April 16,\n", " 2019\n", "During the visit of\n", "Imam-e-Kaaba Dr. Sheikh Abdullah Awad Al-Juhany\n", "on\n", "April 16, 2019\n", ", we explored the integration of\n", " technology in teaching\n", "classical Arabic\n", ". Our\n", " discussion focused on how digital tools and platforms can enhance the\n", " learning experience, making classical Arabic more accessible to\n", " students worldwide.\n", "Your browser does not support the video tag.\n", "Visit of Imam Khalid Al-Ghamidi – 2015\n", "During his 2015 visit to\n", "Jamia Ashrafia\n", ", I had\n", " the honor of presenting my work in\n", "Qur'anic Natural Language Processing (NLP)\n", "and\n", "Islamic tools\n", "to Sheikh Khalid Al-Ghamidi, Imam\n", " of Masjid Al-Haram. Our discussion highlighted the implementation\n", " of\n", "Qur'an morphological tagging\n", ", emphasizing its role in enhancing students' understanding of\n", " classical Arabic and deepening their comprehension of the Qur'anic\n", " text.\n", "🎓 Education\n", "PhD Scholar in Computer Science (NLP & AI)\n", "–\n", " COMSATS University Lahore\n", "Graduation in Dars-e-Nizami / Classical Arabic\n", "–\n", " Jamia Ashrafia, Lahore\n", "MS in Computer Science\n", "– University of Central\n", " Punjab, Lahore\n", "Projects & Innovations\n", "ISDP – Intensive Software Development Program\n", "– A groundbreaking initiative to empower graduates of Islamic\n", " Madrasahs with modern computer science and software engineering\n", " skills.\n", "Tailored curriculum for scholars with no prior tech background\n", "Practical training in web development, databases, and Python\n", "Students build real Islamic apps and digital tools for da'wah\n", "Promoting the digitization of Islamic knowledge through\n", " scholar-led innovation\n", "Graduates have secured positions in reputable software houses\n", " such as InstaCare and E Web Craft, contributing as mobile\n", " application and web developers.\n", "View success stories here\n", ".\n", "ISDP reflects my passion for integrating sacred knowledge with\n", " cutting-edge technology. It aims to equip our ulema with the tools\n", " to lead in the digital world — not just follow. The success of our\n", " graduates in the tech industry underscores the program's\n", " effectiveness in bridging traditional Islamic scholarship with\n", " modern technological expertise.\n", "Altasreef\n", "– An AI-powered Arabic morphology (علم الصرف) learning platform that\n", " combines linguistic knowledge with NLP techniques to support\n", " students of classical Arabic grammar.\n", "Generates full verb conjugations for ماضی معروف، مضارع معروف،\n", " امر، مجہول، منصوب، مجزوم، and more\n", "Covers multiple صرف patterns (باب) like باب سمع، باب فتح، باب\n", " نصر، باب استفعال، باب انفعال etc.\n", "Offers full interface and output in\n", "Urdu, English, and Arabic\n", "Integrates rule-based NLP logic to model triliteral verb roots\n", " with pattern-based transformations\n", "Automatically generates\n", "Urdu translations\n", "using\n", " morphology-aware translation patterns\n", "Includes an\n", "Online Exam Generator\n", "to create practice worksheets for students with or without\n", " answers (ideal for madrassah & school use)\n", "Exam sheets can be downloaded for offline revision or classroom\n", " printing\n", "This project was awarded\n", "1st Prize at the Brainiac Software Competition 2018\n", "(UET Lahore) for digitizing Islamic linguistic education. The\n", " underlying model and linguistic approach were also published as a\n", " research paper at\n", "AbjadNLP 2025 (COLING)\n", ":\n", "Read the paper\n", ".\n", "Easy Quran wa Hadees\n", "– A groundbreaking initiative and one of the\n", "first Urdu Unicode-based Quran and Hadith platforms in\n", " Pakistan\n", ". As a\n", "pioneer developer\n", ", I led the transformation\n", " of classical Islamic texts into a digital, Unicode-compliant\n", " format—setting a new benchmark in Islamic digitization.\n", "Provides the complete Quran with authentic translations in\n", "Urdu, English, and Arabic\n", "Includes key Hadith collections like\n", "Sahih Bukhari\n", ",\n", "Muslim\n", ",\n", "Abu Dawood\n", ", and more\n", "Uses early\n", "NLP and intelligent indexing techniques\n", "for\n", " fast, root-based and keyword search\n", "Offers advanced filters for Hadith search by narrator, topic, or\n", " source\n", "Audio playback support for Quranic recitation and memorization\n", "Features bookmarking, note-taking, and tagging capabilities\n", "Fully localized interface supporting\n", "multilingual access\n", "(Urdu, English, Arabic)\n", "This platform played a\n", "transformative role\n", "in\n", " opening digital Islamic access for Urdu-speaking users. Its\n", " underlying data and architecture have been\n", "adopted by numerous mobile apps and online platforms\n", "across Pakistan and globally. Easy Quran wa Hadees stands as a\n", "milestone in the history of Islamic digitization\n", ".\n", "Mohaddis.com\n", "– A comprehensive Hadith research platform designed for\n", " Urdu-speaking audiences, offering easy access to authenticated\n", " Hadith books with cutting-edge digital tools for exploration,\n", " referencing, and learning.\n", "Includes\n", "major Hadith books\n", ", including Sahih\n", " Bukhari, Sahih Muslim, Abu Dawood, Tirmidhi, Nasai, Ibn Majah,\n", " and Muwatta\n", "Equipped with\n", "advanced full-text search\n", "that\n", " works across Arabic and Urdu translations\n", "Allows filtering by\n", "book, subject, chapter, narrator, or Hadith number\n", "Offers parallel\n", "Arabic and Urdu rendering\n", "for\n", " each Hadith\n", "Integrated with\n", "Fiqh-based categorization\n", "and\n", " references to facilitate deeper learning and contextual\n", " understanding\n", "Continuously updated with\n", "editorial corrections and scholarly cross-referencing\n", "Shareable links to every Hadith and the ability to bookmark for\n", " future research\n", "Mohaddis.com stands out as a\n", "reference-grade Hadith resource\n", "and a key part of\n", " the modern Islamic digital library in Pakistan. Its combination of\n", " traditional content and modern UX has made it widely adopted in\n", " scholarly circles and educational institutes.\n", "Tanzeem Islami Digital Library\n", "– A pioneering content digitization project that transformed\n", " classical Islamic literature—originally authored in Urdu and typeset\n", " in InPage—into modern, searchable Unicode format. This initiative\n", " laid the foundation for preserving Islamic scholarship through\n", " technology.\n", "Digitized and indexed a vast collection of books by\n", "Islami thinkers, scholars, and reformers\n", "Utilized early\n", "InPage-to-Unicode conversion pipelines\n", "to make\n", " printed books digitally searchable\n", "Enables\n", "full-text search\n", "across books by\n", " keyword, topic, author, or chapter\n", "Supported by\n", "backend NLP tools\n", "for content\n", " tagging and semantic classification\n", "Offers both web-based browsing and categorized downloadable\n", " content (PDF + Unicode HTML)\n", "Public access to rare Islamic literature previously locked in\n", " print archives\n", "As one of the\n", "first major Urdu digitization efforts for Islamic books in\n", " Pakistan\n", ", this project set a trend in religious archiving and inspired\n", " many modern Islamic libraries and apps. The platform is now\n", " referenced by scholars, students, and researchers worldwide.\n", "Advancing AI, NLP & LLM Solutions\n", "I lead the development of intelligent language systems powered by\n", "Large Language Models (LLMs)\n", "and advanced retrieval mechanisms, applying state-of-the-art AI research to real-world applications.\n", "Large Language Model (LLM) Solutions\n", "Fine-tuned GPT-based models for text summarization, generation, and multi-turn conversations\n", "Implemented Named Entity Recognition (NER), classification, and topic modeling using transformer architectures\n", "Designed\n", "zero-shot and few-shot learning pipelines\n", "to support under-resourced languages like Arabic and Urdu\n", "Retrieval-Augmented Generation (RAG) & Vector-Based Search\n", "Built modular RAG systems combining retrieval pipelines with LLMs to deliver accurate, real-time responses\n", "Integrated\n", "vector databases\n", "for semantic search and contextual relevance\n", "Developed NLP solutions for diverse sectors including\n", "law, education, healthcare, and enterprise services\n", "AI System Deployment\n", "Integrated cloud services such as AWS (S3, Lambda, Textract, SageMaker) and Azure ML pipelines\n", "Led agile teams of developers and QA for rapid prototyping and production-grade deployment\n", "Utilized Docker, FastAPI, and scalable Python architectures for NLP APIs\n", "I also apply AI to\n", "Arabic morphology and morpheme-level analysis\n", "to develop tools that assist in classical Arabic understanding, such as pattern-based conjugation, morphological tagging, and root extraction.\n", "These innovations bring together AI research and production-ready NLP systems to solve complex language problems and deliver meaningful impact across industries.\n", "📱 Mobile Apps – Qur’anic Tech in Your Pocket\n", "Bridging the gap between sacred knowledge and modern convenience,\n", " these mobile applications are designed to make the Qur'an and Islamic\n", " studies accessible to everyone, anywhere, anytime.\n", "The Noble Quran\n", "– Official app featuring\n", "Mufti Taqi Usmani’s authoritative English translation\n", "of the Qur’an. Designed for students, scholars, and general readers\n", " seeking clarity and depth in Qur’anic interpretation.\n", "Complete English translation enriched with explanatory footnotes\n", " based on classical Tafsir sources\n", "Regex-based Arabic search functionality for advanced users to\n", " explore verse patterns and linguistic structures\n", "Streamlined verse-by-verse navigation and modern reading\n", " experience\n", "Offline readability, bookmarking, and search history tracking\n", "Widely used by scholars, researchers, and institutes as a\n", " reliable digital resource\n", "Tazkeer-ul-Quran (Android App)\n", "– A lightweight, modern Qur’anic reflection tool featuring\n", " topic-based verse collections, multilingual translations, and a\n", " clean user interface.\n", "Explore categorized themes and Qur’anic wisdom through\n", " handpicked verses\n", "Multilingual support: Urdu, English, Sindhi, Pashto, and Hindi\n", "Smart search engine allows searching in any language supported\n", " in the app\n", "Bookmark functionality for saving favorite verses\n", "Designed for both general users and advanced learners\n", "Seerat Quiz App\n", "– A fun and engaging Islamic quiz app focused on the\n", "Seerat (biography)\n", "of Prophet Muhammad ﷺ, specially\n", " designed for\n", "kids and school-going learners\n", ".\n", "Built for children and beginners to explore the Seerah in an\n", " interactive way\n", "Multiple-choice questions to reinforce learning about the life\n", " of the Prophet ﷺ\n", "Child-friendly interface with easy navigation and visual\n", " engagement\n", "Ideal for\n", "Islamic schools, homeschooling, and weekend\n", " madrassahs\n", "Score-based system to encourage progress and retention\n", "Lightweight, responsive, and crafted for mobile-first usage\n", "This app introduces young minds to the noble character and\n", " important milestones in the life of the Prophet ﷺ through engaging\n", " quizzes. It's a stepping stone toward developing love and\n", " connection with Seerah through modern technology.\n", "Tuheed (توَحید) App\n", "– A mobile presentation of the classic Islamic work\n", "\"وجود باری تعالیٰ اور توحید\"\n", "by\n", "Professor Dr. Malik Ghulam Murtaza (PhD)\n", ". This app\n", " brings the essential doctrine of\n", "Tawheed (Monotheism)\n", "to readers in a clean, digital\n", " experience.\n", "Covers the true meaning of Tawheed: the oneness of Allah in His\n", " being, attributes, and actions — without partner, peer, or need\n", "Explains Allah’s exclusive authority using\n", "Qur'anic verses, rational proofs, and classical\n", " definitions\n", "Includes citations like Surah Al-Ikhlas and definitions from\n", " scholars such as\n", "Imam Al-Jurjani\n", "Built from digitized content developed during my early work in\n", "Urdu Islamic content digitization\n", "projects\n", "Urdu-language app with smooth navigation and offline readability\n", "This app is part of my broader vision to\n", "digitally preserve and repurpose classical Islamic\n", " literature\n", "—transitioning it from scanned archives to searchable web\n", " libraries, and now to\n", "interactive mobile applications\n", ". It invites users\n", " to reflect on the foundation of Islamic belief:\n", "La ilaha illAllah\n", "— there is no deity but Allah.\n", "Publications\n", "Automated Generation of Arabic Verb Conjugations with\n", " Multilingual Urdu Translation: An NLP Approach\n", "–\n", "AbjadNLP 2025 Workshop, COLING\n", "Authors: Haq Nawaz (COMSATS University, Pakistan), Manal Elobaid\n", " (Qatar University), Ali al-Laith (Copenhagen University), Saif\n", " Ullah (ILI.digital, Pakistan)\n", "Read Paper (ACL Anthology)\n", "Arabic Natural Language Processing for Qur’anic Research: A\n", " Systematic Review\n", "–\n", "Artificial Intelligence Review, 2023\n", "Authors: Muhammad Huzaifa Bashir (Information Technology\n", " University, Pakistan), Aqil M. Azmi (King Saud University, Saudi\n", " Arabia), Haq Nawaz (Jamia Ashrafia & PUCIT, Pakistan), Wajdi\n", " Zaghouani (Hamad Bin Khalifa University, Qatar), Mona Diab (George\n", " Washington University, USA), Ala Al‑Fuqaha (HBKU, Qatar), Junaid\n", " Qadir (Qatar University)\n", "Read on Springer\n", "Stars at Qur’an QA 2022: Building Automatic Extractive Question\n", " Answering Systems for the Holy Qur’an with Transformer Models and\n", " Releasing a New Dataset\n", "–\n", "Qur'an QA Shared Task, OSACT Workshop, LREC 2022\n", "Authors: Ahmed Wasfey (Tactful AI), Eman Elrefai (BambooGeeks),\n", " Marwa Muhammad (Freelancer), Haq Nawaz (PUCIT)\n", "Read on ACL Anthology\n", "Sentimental Analysis of Social Media to Find Out Customer\n", " Opinion\n", "Intelligent Technologies and Applications, 2019\n", "Read on Springer\n", "Development of AI-Based System for Teaching Classical Arabic &\n", " Qur’anic Vocabularies\n", "QURANICA – International Journal of Quranic Research, 2018\n", "Read on UM Journal\n", "Data Set Generation for the Attributes of the Words of the Holy\n", " Quran\n", "Taibah University Conference, 2013\n", "Read on IEEE Xplore\n", "View all publications on Google Scholar\n", "🏆 1st Prize – Brainiac Software Competition 2018 (UET Lahore)\n", "Awarded for the development of\n", "Altasreef\n", ", an AI-powered Arabic morphology trainer that generates verb\n", " conjugations across classical patterns along with Urdu translations.\n", "The project was recognized for its\n", "innovation in digitizing classical Arabic linguistics\n", "and its utility for\n", "Classical Arabic, language learners, and NLP researchers\n", ". Altasreef introduced:\n", "Automated صرف (morphology) generation in Arabic\n", "Multilingual output: Arabic, Urdu, and English interface\n", "NLP-inspired pattern recognition and root-based transformation\n", "Downloadable exams for student practice\n", "Your browser does not support the video tag.\n", "This award recognized the project's excellence in applying\n", " cutting-edge technology to traditional Islamic education and\n", " showcased its relevance at the national level.\n", "🏆 NLP Research Award – NaSCon 2019 (FAST-NUCES)\n", "Recognized for groundbreaking personal R&D work in\n", "Natural Language Processing of Qur’anic text\n", ", where\n", " I manually segmented, tagged, and annotated a large-scale dataset of\n", " the Holy Quran for multi-language NLP applications.\n", "The core project involved:\n", "Tagging and annotating\n", "over 80,000+ Quranic words\n", "Marking\n", "23 detailed linguistic attributes per word\n", "including root, tense, gender, case, mood, and more\n", "Multi-language annotation:\n", "Arabic, Urdu, and English\n", "Over\n", "5.4 million total attribute labels\n", "across\n", " the entire corpus\n", "Designed for advanced NLP research, educational tools, and\n", " AI-based Quranic analysis\n", "Your browser does not support the video tag.\n", "This recognition at\n", "NaSCon 2019 (FAST-NUCES)\n", "celebrated my\n", "independent research in the Indo-Pak Uthmani script\n", ", and established a foundation for advanced Qur’anic datasets in\n", " multilingual NLP environments. The annotated dataset continues to\n", " support various AI projects in Arabic linguistics and Quranic\n", " education.\n", "Contact Me\n", "Let's connect! Feel free to reach out.\n", "Email Me\n", "GitHub\n", "LinkedIn\n", "© 2025 Haq Nawaz. All rights reserved.\n" ] } ], "source": [ "print(user_prompt_for(ed))" ] }, { "cell_type": "markdown", "id": "ea211b5f-28e1-4a86-8e52-c0b7677cadcc", "metadata": {}, "source": [ "## Messages\n", "\n", "The API from OpenAI expects to receive messages in a particular structure.\n", "Many of the other APIs share this structure:\n", "\n", "```\n", "[\n", " {\"role\": \"system\", \"content\": \"system message goes here\"},\n", " {\"role\": \"user\", \"content\": \"user message goes here\"}\n", "]\n", "\n", "To give you a preview, the next 2 cells make a rather simple call - we won't stretch the mighty GPT (yet!)" ] }, { "cell_type": "code", "execution_count": 16, "id": "f25dcd35-0cd0-4235-9f64-ac37ed9eaaa5", "metadata": {}, "outputs": [], "source": [ "messages = [\n", " {\"role\": \"system\", \"content\": \"You are a snarky assistant\"},\n", " {\"role\": \"user\", \"content\": \"What is 2 + 2?\"}\n", "]" ] }, { "cell_type": "code", "execution_count": 17, "id": "21ed95c5-7001-47de-a36d-1d6673b403ce", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Oh, we're starting off easy, huh? Well, 2 + 2 equals 4. Shocking, I know! But don't worry, complex math problems are also in my repertoire. Just let me know if you want to level up!\n" ] } ], "source": [ "# To give you a preview -- calling OpenAI with system and user messages:\n", "\n", "response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n", "print(response.choices[0].message.content)" ] }, { "cell_type": "markdown", "id": "d06e8d78-ce4c-4b05-aa8e-17050c82bb47", "metadata": {}, "source": [ "## And now let's build useful messages for GPT-4o-mini, using a function" ] }, { "cell_type": "code", "execution_count": 18, "id": "0134dfa4-8299-48b5-b444-f2a8c3403c88", "metadata": {}, "outputs": [], "source": [ "# See how this function creates exactly the format above\n", "\n", "def messages_for(website):\n", " return [\n", " {\"role\": \"system\", \"content\": system_prompt},\n", " {\"role\": \"user\", \"content\": user_prompt_for(website)}\n", " ]" ] }, { "cell_type": "code", "execution_count": 19, "id": "36478464-39ee-485c-9f3f-6a4e458dbc9c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'role': 'system',\n", " 'content': 'You are an assistant that analyzes the contents of a website and provides a short summary, ignoring text that might be navigation related. Respond in markdown.'},\n", " {'role': 'user',\n", " 'content': 'You are looking at a website titled Haq Nawaz - Bridging AI & Islamic Scholarship\\nThe contents of this website is as follows; please provide a short summary of this website in markdown. If it includes news or announcements, then summarize these too.\\n\\n☰\\nIntroduction\\n🕌 Imams of Haramain\\nImam Masjid-e-Nabawi\\nImam-e-Kaaba Juhany\\nImam Khalid Al-Ghamidi\\nProjects\\nISDP\\nAltasreef\\nEasy Quran\\nMohaddis\\nTanzeem\\nAI & NLP\\nMobile Apps\\nThe Noble Quran\\nTazkeer Ul Quran\\nSeerat Quiz\\nوجود باری تعالیٰ اور توحید\\nPublications\\nAwards\\nBrainiac 2018\\nNaSCon 2019\\nContact\\nHaq Nawaz\\nIslamic Scholar\\n|\\nNLP & AI Specialist\\n|\\nIslamic Digital Solutions Expert\\nAbout Me\\nGet in Touch\\nIntroduction\\nI am\\nHaq Nawaz\\n, a faculty member at\\nJamia Ashrafia Lahore\\n, a\\nPhD Scholar in NLP\\nat\\nCOMSATS University Lahore\\n, and a\\nData Science Consultant at ILI.DIGITAL AG\\n. I specialize in bridging modern artificial intelligence with\\n classical Islamic sciences — leading pioneering efforts in\\nIslamic software development\\n, digitization, and\\nAI-powered Qur\\'anic and Hadith tools\\nfor education,\\n research, and public benefit.\\nAs one of the earliest contributors to\\nUrdu Unicode content digitization\\n, my work has\\n enabled millions of words from classical texts—including the Qur’an,\\n Hadith, and foundational Islamic literature—to become searchable,\\n readable, and interactive across platforms. These efforts laid the\\n groundwork for major portals such as\\nEasy Quran wa Hadees\\nand\\nTanzeem Islami Digital Library\\n.\\nI’ve developed award-winning educational platforms like\\nAltasreef\\n, which automates Arabic verb conjugations with Urdu translations and\\n exam generation, earning 1st Prize at UET Lahore’s Brainiac 2018. At\\n NaSCon 2019 (FAST-NUCES), my personal R&D project in\\nQuranic NLP annotation\\n—involving 5.4+ million\\n attribute labels in three languages—was also recognized nationally.\\nMy mobile applications include the\\nThe Noble Quran\\nand\\nآسان ترجمہ قرآن\\napps, presenting the renowned English and Urdu translations and tafsir\\n by\\nMufti Taqi Usmani\\nfor scholars and general readers\\n alike. I’ve also developed\\nTazkeer-ul-Quran\\n, which offers multilingual Qur’an translations and thematic\\n organization for deep reflection; the\\nSeerat Quiz\\napp, designed to teach Seerah to school-going children through\\n interactive learning; and\\nوجود باري تعالى اور توحید\\n, a digital presentation of Islamic scholarship, continuing my\\n mission of\\ndigitizing authentic Islamic texts\\nfor the\\n digital age.\\nVisit of Imam Masjid-e-Nabawi Dr. Salah Al-Budair – August 15, 2024\\nDuring the visit of\\nImam Masjid-e-Nabawi Dr. Salah Al-Budair\\non\\nAugust 15, 2024\\n, I had the honor of presenting our\\n research and technological contributions in the field of\\nArabic morphology (علم الصرف)\\n. We discussed how\\n Natural Language Processing (NLP) and AI can simplify classical\\n grammar learning for students.\\nYour browser does not support the video tag.\\nVisit of Imam-e-Kaaba Dr. Sheikh Abdullah Awad Al-Juhany – April 16,\\n 2019\\nDuring the visit of\\nImam-e-Kaaba Dr. Sheikh Abdullah Awad Al-Juhany\\non\\nApril 16, 2019\\n, we explored the integration of\\n technology in teaching\\nclassical Arabic\\n. Our\\n discussion focused on how digital tools and platforms can enhance the\\n learning experience, making classical Arabic more accessible to\\n students worldwide.\\nYour browser does not support the video tag.\\nVisit of Imam Khalid Al-Ghamidi – 2015\\nDuring his 2015 visit to\\nJamia Ashrafia\\n, I had\\n the honor of presenting my work in\\nQur\\'anic Natural Language Processing (NLP)\\nand\\nIslamic tools\\nto Sheikh Khalid Al-Ghamidi, Imam\\n of Masjid Al-Haram. Our discussion highlighted the implementation\\n of\\nQur\\'an morphological tagging\\n, emphasizing its role in enhancing students\\' understanding of\\n classical Arabic and deepening their comprehension of the Qur\\'anic\\n text.\\n🎓 Education\\nPhD Scholar in Computer Science (NLP & AI)\\n–\\n COMSATS University Lahore\\nGraduation in Dars-e-Nizami / Classical Arabic\\n–\\n Jamia Ashrafia, Lahore\\nMS in Computer Science\\n– University of Central\\n Punjab, Lahore\\nProjects & Innovations\\nISDP – Intensive Software Development Program\\n– A groundbreaking initiative to empower graduates of Islamic\\n Madrasahs with modern computer science and software engineering\\n skills.\\nTailored curriculum for scholars with no prior tech background\\nPractical training in web development, databases, and Python\\nStudents build real Islamic apps and digital tools for da\\'wah\\nPromoting the digitization of Islamic knowledge through\\n scholar-led innovation\\nGraduates have secured positions in reputable software houses\\n such as InstaCare and E Web Craft, contributing as mobile\\n application and web developers.\\nView success stories here\\n.\\nISDP reflects my passion for integrating sacred knowledge with\\n cutting-edge technology. It aims to equip our ulema with the tools\\n to lead in the digital world — not just follow. The success of our\\n graduates in the tech industry underscores the program\\'s\\n effectiveness in bridging traditional Islamic scholarship with\\n modern technological expertise.\\nAltasreef\\n– An AI-powered Arabic morphology (علم الصرف) learning platform that\\n combines linguistic knowledge with NLP techniques to support\\n students of classical Arabic grammar.\\nGenerates full verb conjugations for ماضی معروف، مضارع معروف،\\n امر، مجہول، منصوب، مجزوم، and more\\nCovers multiple صرف patterns (باب) like باب سمع، باب فتح، باب\\n نصر، باب استفعال، باب انفعال etc.\\nOffers full interface and output in\\nUrdu, English, and Arabic\\nIntegrates rule-based NLP logic to model triliteral verb roots\\n with pattern-based transformations\\nAutomatically generates\\nUrdu translations\\nusing\\n morphology-aware translation patterns\\nIncludes an\\nOnline Exam Generator\\nto create practice worksheets for students with or without\\n answers (ideal for madrassah & school use)\\nExam sheets can be downloaded for offline revision or classroom\\n printing\\nThis project was awarded\\n1st Prize at the Brainiac Software Competition 2018\\n(UET Lahore) for digitizing Islamic linguistic education. The\\n underlying model and linguistic approach were also published as a\\n research paper at\\nAbjadNLP 2025 (COLING)\\n:\\nRead the paper\\n.\\nEasy Quran wa Hadees\\n– A groundbreaking initiative and one of the\\nfirst Urdu Unicode-based Quran and Hadith platforms in\\n Pakistan\\n. As a\\npioneer developer\\n, I led the transformation\\n of classical Islamic texts into a digital, Unicode-compliant\\n format—setting a new benchmark in Islamic digitization.\\nProvides the complete Quran with authentic translations in\\nUrdu, English, and Arabic\\nIncludes key Hadith collections like\\nSahih Bukhari\\n,\\nMuslim\\n,\\nAbu Dawood\\n, and more\\nUses early\\nNLP and intelligent indexing techniques\\nfor\\n fast, root-based and keyword search\\nOffers advanced filters for Hadith search by narrator, topic, or\\n source\\nAudio playback support for Quranic recitation and memorization\\nFeatures bookmarking, note-taking, and tagging capabilities\\nFully localized interface supporting\\nmultilingual access\\n(Urdu, English, Arabic)\\nThis platform played a\\ntransformative role\\nin\\n opening digital Islamic access for Urdu-speaking users. Its\\n underlying data and architecture have been\\nadopted by numerous mobile apps and online platforms\\nacross Pakistan and globally. Easy Quran wa Hadees stands as a\\nmilestone in the history of Islamic digitization\\n.\\nMohaddis.com\\n– A comprehensive Hadith research platform designed for\\n Urdu-speaking audiences, offering easy access to authenticated\\n Hadith books with cutting-edge digital tools for exploration,\\n referencing, and learning.\\nIncludes\\nmajor Hadith books\\n, including Sahih\\n Bukhari, Sahih Muslim, Abu Dawood, Tirmidhi, Nasai, Ibn Majah,\\n and Muwatta\\nEquipped with\\nadvanced full-text search\\nthat\\n works across Arabic and Urdu translations\\nAllows filtering by\\nbook, subject, chapter, narrator, or Hadith number\\nOffers parallel\\nArabic and Urdu rendering\\nfor\\n each Hadith\\nIntegrated with\\nFiqh-based categorization\\nand\\n references to facilitate deeper learning and contextual\\n understanding\\nContinuously updated with\\neditorial corrections and scholarly cross-referencing\\nShareable links to every Hadith and the ability to bookmark for\\n future research\\nMohaddis.com stands out as a\\nreference-grade Hadith resource\\nand a key part of\\n the modern Islamic digital library in Pakistan. Its combination of\\n traditional content and modern UX has made it widely adopted in\\n scholarly circles and educational institutes.\\nTanzeem Islami Digital Library\\n– A pioneering content digitization project that transformed\\n classical Islamic literature—originally authored in Urdu and typeset\\n in InPage—into modern, searchable Unicode format. This initiative\\n laid the foundation for preserving Islamic scholarship through\\n technology.\\nDigitized and indexed a vast collection of books by\\nIslami thinkers, scholars, and reformers\\nUtilized early\\nInPage-to-Unicode conversion pipelines\\nto make\\n printed books digitally searchable\\nEnables\\nfull-text search\\nacross books by\\n keyword, topic, author, or chapter\\nSupported by\\nbackend NLP tools\\nfor content\\n tagging and semantic classification\\nOffers both web-based browsing and categorized downloadable\\n content (PDF + Unicode HTML)\\nPublic access to rare Islamic literature previously locked in\\n print archives\\nAs one of the\\nfirst major Urdu digitization efforts for Islamic books in\\n Pakistan\\n, this project set a trend in religious archiving and inspired\\n many modern Islamic libraries and apps. The platform is now\\n referenced by scholars, students, and researchers worldwide.\\nAdvancing AI, NLP & LLM Solutions\\nI lead the development of intelligent language systems powered by\\nLarge Language Models (LLMs)\\nand advanced retrieval mechanisms, applying state-of-the-art AI research to real-world applications.\\nLarge Language Model (LLM) Solutions\\nFine-tuned GPT-based models for text summarization, generation, and multi-turn conversations\\nImplemented Named Entity Recognition (NER), classification, and topic modeling using transformer architectures\\nDesigned\\nzero-shot and few-shot learning pipelines\\nto support under-resourced languages like Arabic and Urdu\\nRetrieval-Augmented Generation (RAG) & Vector-Based Search\\nBuilt modular RAG systems combining retrieval pipelines with LLMs to deliver accurate, real-time responses\\nIntegrated\\nvector databases\\nfor semantic search and contextual relevance\\nDeveloped NLP solutions for diverse sectors including\\nlaw, education, healthcare, and enterprise services\\nAI System Deployment\\nIntegrated cloud services such as AWS (S3, Lambda, Textract, SageMaker) and Azure ML pipelines\\nLed agile teams of developers and QA for rapid prototyping and production-grade deployment\\nUtilized Docker, FastAPI, and scalable Python architectures for NLP APIs\\nI also apply AI to\\nArabic morphology and morpheme-level analysis\\nto develop tools that assist in classical Arabic understanding, such as pattern-based conjugation, morphological tagging, and root extraction.\\nThese innovations bring together AI research and production-ready NLP systems to solve complex language problems and deliver meaningful impact across industries.\\n📱 Mobile Apps – Qur’anic Tech in Your Pocket\\nBridging the gap between sacred knowledge and modern convenience,\\n these mobile applications are designed to make the Qur\\'an and Islamic\\n studies accessible to everyone, anywhere, anytime.\\nThe Noble Quran\\n– Official app featuring\\nMufti Taqi Usmani’s authoritative English translation\\nof the Qur’an. Designed for students, scholars, and general readers\\n seeking clarity and depth in Qur’anic interpretation.\\nComplete English translation enriched with explanatory footnotes\\n based on classical Tafsir sources\\nRegex-based Arabic search functionality for advanced users to\\n explore verse patterns and linguistic structures\\nStreamlined verse-by-verse navigation and modern reading\\n experience\\nOffline readability, bookmarking, and search history tracking\\nWidely used by scholars, researchers, and institutes as a\\n reliable digital resource\\nTazkeer-ul-Quran (Android App)\\n– A lightweight, modern Qur’anic reflection tool featuring\\n topic-based verse collections, multilingual translations, and a\\n clean user interface.\\nExplore categorized themes and Qur’anic wisdom through\\n handpicked verses\\nMultilingual support: Urdu, English, Sindhi, Pashto, and Hindi\\nSmart search engine allows searching in any language supported\\n in the app\\nBookmark functionality for saving favorite verses\\nDesigned for both general users and advanced learners\\nSeerat Quiz App\\n– A fun and engaging Islamic quiz app focused on the\\nSeerat (biography)\\nof Prophet Muhammad ﷺ, specially\\n designed for\\nkids and school-going learners\\n.\\nBuilt for children and beginners to explore the Seerah in an\\n interactive way\\nMultiple-choice questions to reinforce learning about the life\\n of the Prophet ﷺ\\nChild-friendly interface with easy navigation and visual\\n engagement\\nIdeal for\\nIslamic schools, homeschooling, and weekend\\n madrassahs\\nScore-based system to encourage progress and retention\\nLightweight, responsive, and crafted for mobile-first usage\\nThis app introduces young minds to the noble character and\\n important milestones in the life of the Prophet ﷺ through engaging\\n quizzes. It\\'s a stepping stone toward developing love and\\n connection with Seerah through modern technology.\\nTuheed (توَحید) App\\n– A mobile presentation of the classic Islamic work\\n\"وجود باری تعالیٰ اور توحید\"\\nby\\nProfessor Dr. Malik Ghulam Murtaza (PhD)\\n. This app\\n brings the essential doctrine of\\nTawheed (Monotheism)\\nto readers in a clean, digital\\n experience.\\nCovers the true meaning of Tawheed: the oneness of Allah in His\\n being, attributes, and actions — without partner, peer, or need\\nExplains Allah’s exclusive authority using\\nQur\\'anic verses, rational proofs, and classical\\n definitions\\nIncludes citations like Surah Al-Ikhlas and definitions from\\n scholars such as\\nImam Al-Jurjani\\nBuilt from digitized content developed during my early work in\\nUrdu Islamic content digitization\\nprojects\\nUrdu-language app with smooth navigation and offline readability\\nThis app is part of my broader vision to\\ndigitally preserve and repurpose classical Islamic\\n literature\\n—transitioning it from scanned archives to searchable web\\n libraries, and now to\\ninteractive mobile applications\\n. It invites users\\n to reflect on the foundation of Islamic belief:\\nLa ilaha illAllah\\n— there is no deity but Allah.\\nPublications\\nAutomated Generation of Arabic Verb Conjugations with\\n Multilingual Urdu Translation: An NLP Approach\\n–\\nAbjadNLP 2025 Workshop, COLING\\nAuthors: Haq Nawaz (COMSATS University, Pakistan), Manal Elobaid\\n (Qatar University), Ali al-Laith (Copenhagen University), Saif\\n Ullah (ILI.digital, Pakistan)\\nRead Paper (ACL Anthology)\\nArabic Natural Language Processing for Qur’anic Research: A\\n Systematic Review\\n–\\nArtificial Intelligence Review, 2023\\nAuthors: Muhammad Huzaifa Bashir (Information Technology\\n University, Pakistan), Aqil M. Azmi (King Saud University, Saudi\\n Arabia), Haq Nawaz (Jamia Ashrafia & PUCIT, Pakistan), Wajdi\\n Zaghouani (Hamad Bin Khalifa University, Qatar), Mona Diab (George\\n Washington University, USA), Ala Al‑Fuqaha (HBKU, Qatar), Junaid\\n Qadir (Qatar University)\\nRead on Springer\\nStars at Qur’an QA 2022: Building Automatic Extractive Question\\n Answering Systems for the Holy Qur’an with Transformer Models and\\n Releasing a New Dataset\\n–\\nQur\\'an QA Shared Task, OSACT Workshop, LREC 2022\\nAuthors: Ahmed Wasfey (Tactful AI), Eman Elrefai (BambooGeeks),\\n Marwa Muhammad (Freelancer), Haq Nawaz (PUCIT)\\nRead on ACL Anthology\\nSentimental Analysis of Social Media to Find Out Customer\\n Opinion\\nIntelligent Technologies and Applications, 2019\\nRead on Springer\\nDevelopment of AI-Based System for Teaching Classical Arabic &\\n Qur’anic Vocabularies\\nQURANICA – International Journal of Quranic Research, 2018\\nRead on UM Journal\\nData Set Generation for the Attributes of the Words of the Holy\\n Quran\\nTaibah University Conference, 2013\\nRead on IEEE Xplore\\nView all publications on Google Scholar\\n🏆 1st Prize – Brainiac Software Competition 2018 (UET Lahore)\\nAwarded for the development of\\nAltasreef\\n, an AI-powered Arabic morphology trainer that generates verb\\n conjugations across classical patterns along with Urdu translations.\\nThe project was recognized for its\\ninnovation in digitizing classical Arabic linguistics\\nand its utility for\\nClassical Arabic, language learners, and NLP researchers\\n. Altasreef introduced:\\nAutomated صرف (morphology) generation in Arabic\\nMultilingual output: Arabic, Urdu, and English interface\\nNLP-inspired pattern recognition and root-based transformation\\nDownloadable exams for student practice\\nYour browser does not support the video tag.\\nThis award recognized the project\\'s excellence in applying\\n cutting-edge technology to traditional Islamic education and\\n showcased its relevance at the national level.\\n🏆 NLP Research Award – NaSCon 2019 (FAST-NUCES)\\nRecognized for groundbreaking personal R&D work in\\nNatural Language Processing of Qur’anic text\\n, where\\n I manually segmented, tagged, and annotated a large-scale dataset of\\n the Holy Quran for multi-language NLP applications.\\nThe core project involved:\\nTagging and annotating\\nover 80,000+ Quranic words\\nMarking\\n23 detailed linguistic attributes per word\\nincluding root, tense, gender, case, mood, and more\\nMulti-language annotation:\\nArabic, Urdu, and English\\nOver\\n5.4 million total attribute labels\\nacross\\n the entire corpus\\nDesigned for advanced NLP research, educational tools, and\\n AI-based Quranic analysis\\nYour browser does not support the video tag.\\nThis recognition at\\nNaSCon 2019 (FAST-NUCES)\\ncelebrated my\\nindependent research in the Indo-Pak Uthmani script\\n, and established a foundation for advanced Qur’anic datasets in\\n multilingual NLP environments. The annotated dataset continues to\\n support various AI projects in Arabic linguistics and Quranic\\n education.\\nContact Me\\nLet\\'s connect! Feel free to reach out.\\nEmail Me\\nGitHub\\nLinkedIn\\n© 2025 Haq Nawaz. All rights reserved.'}]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Try this out, and then try for a few more websites\n", "\n", "messages_for(ed)" ] }, { "cell_type": "markdown", "id": "16f49d46-bf55-4c3e-928f-68fc0bf715b0", "metadata": {}, "source": [ "## Time to bring it together - the API for OpenAI is very simple!" ] }, { "cell_type": "code", "execution_count": 20, "id": "905b9919-aba7-45b5-ae65-81b3d1d78e34", "metadata": {}, "outputs": [], "source": [ "# And now: call the OpenAI API. You will get very familiar with this!\n", "\n", "def summarize(url):\n", " website = Website(url)\n", " response = openai.chat.completions.create(\n", " model = \"gpt-4o-mini\",\n", " messages = messages_for(website)\n", " )\n", " return response.choices[0].message.content" ] }, { "cell_type": "code", "execution_count": 21, "id": "05e38d41-dfa4-4b20-9c96-c46ea75d9fb5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"# Haq Nawaz - Bridging AI & Islamic Scholarship\\n\\n**Overview** \\nHaq Nawaz is a faculty member at Jamia Ashrafia Lahore and a PhD Scholar in Natural Language Processing (NLP) at COMSATS University Lahore. He specializes in integrating modern AI technologies with Islamic scholarship, aiming to develop educational tools that digitize and enhance accessibility to classical Islamic texts.\\n\\n**Core Focus Areas**\\n\\n- **Islamic Digital Solutions**: Development of software and applications that facilitate the study and understanding of the Quran and Hadith, such as:\\n - **Altasreef**: An AI-powered Arabic morphology learning platform that automates verb conjugations.\\n - **Easy Quran and Hadith**: A platform providing translations and search functionality for key Islamic texts.\\n - **Mobile Apps**: Including The Noble Quran and Tazkeer Ul Quran, which offer user-friendly access to Quranic content.\\n\\n- **Education Initiatives**: He leads various projects like the Intensive Software Development Program (ISDP), aimed at empowering graduates from Madrasahs with tech skills to develop Islamic digital tools.\\n\\n- **Research and Publications**: Haq Nawaz has contributed to numerous academic publications that focus on applying NLP techniques to Islamic texts, with notable awards for his work in transforming classical Arabic learning through technology.\\n\\n**Recent News & Announcements**\\n- **Visitation Highlights**:\\n - **August 15, 2024**: Presentation to Imam Masjid-e-Nabawi Dr. Salah Al-Budair focusing on the role of NLP in teaching Arabic grammar.\\n - **April 16, 2019**: Discussion with Imam-e-Kaaba Dr. Sheikh Abdullah Awad Al-Juhany on integrating technology in classical Arabic education.\\n - **2015**: Presentation to Imam Khalid Al-Ghamidi on the applications of Qur'anic NLP in enhancing students' learning.\\n\\n**Achievements**\\n- Awarded 1st Prize at Brainiac 2018 for Altasreef.\\n- Received the NLP Research Award at NaSCon 2019 for groundbreaking work in Quranic NLP annotation.\\n\\nThis website emphasizes Haq Nawaz's commitment to advancing Islamic scholarship through technology and innovative educational methodologies, reflecting a unique intersection of traditional knowledge and modern digital resources.\"" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "summarize(\"https://haqnawaz.org\")" ] }, { "cell_type": "code", "execution_count": 22, "id": "3d926d59-450e-4609-92ba-2d6f244f1342", "metadata": {}, "outputs": [], "source": [ "# A function to display this nicely in the Jupyter output, using markdown\n", "\n", "def display_summary(url):\n", " summary = summarize(url)\n", " display(Markdown(summary))" ] }, { "cell_type": "code", "execution_count": 23, "id": "3018853a-445f-41ff-9560-d925d1774b2f", "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "# Haq Nawaz - Bridging AI & Islamic Scholarship\n", "\n", "**Overview** \n", "Haq Nawaz is an accomplished Islamic scholar and NLP (Natural Language Processing) specialist who integrates artificial intelligence with classical Islamic scholarship. He serves as a faculty member at Jamia Ashrafia in Lahore, while also pursuing a PhD in NLP at COMSATS University. His work primarily focuses on the development of digital tools for education and research in Islamic studies, enabling classical texts to become more accessible and interactive.\n", "\n", "**Key Projects and Innovations** \n", "- **ISDP**: An intensive software development program that equips graduates of Islamic Madrasahs with tech skills, enabling them to develop Islamic digital tools.\n", "- **Altasreef**: An AI-powered Arabic morphology learning platform, awarded 1st prize at the Brainiac 2018 competition.\n", "- **Easy Quran wa Hadees**: A pioneering Urdu Unicode-based Quran and Hadith platform providing comprehensive search and access to these texts.\n", "- **Mohaddis.com**: A research platform for authenticated Hadith texts designed for Urdu-speaking audiences.\n", "- **Tanzeem Islami Digital Library**: A project digitizing classical Urdu literature into searchable formats.\n", "- **Mobile Apps**: Includes apps like The Noble Quran, Tazkeer-ul-Quran, Seerat Quiz, and the Tuheed app, bridging sacred knowledge with modern mobile technology.\n", "\n", "**Recognitions and Achievements** \n", "Haq Nawaz has received notable awards such as:\n", "- **1st Prize** at the Brainiac Software Competition 2018 for Altasreef.\n", "- Recognition for his research in NLP at NaSCon 2019 for his work on Qur’anic text annotation.\n", "\n", "**Recent News** \n", "- **Visit of Imam Masjid-e-Nabawi (August 15, 2024)**: Haq Nawaz presented his research in Arabic morphology and discussed using NLP and AI to simplify classical grammar learning.\n", "- **Visit of Imam-e-Kaaba (April 16, 2019)**: Discussed how technology can enhance classical Arabic teaching.\n", "- **Visit of Imam Khalid Al-Ghamidi (2015)**: Presented work on Qur'anic NLP to emphasize understanding classical Arabic through technology.\n", "\n", "Haq Nawaz continues his efforts to digitize Islamic texts and leverage technology for educational purposes, ultimately making Islamic knowledge more accessible to a global audience." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display_summary(\"https://haqnawaz.org\")" ] }, { "cell_type": "code", "execution_count": null, "id": "40020de6", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "b3bcf6f4-adce-45e9-97ad-d9a5d7a3a624", "metadata": {}, "source": [ "# Let's try more websites\n", "\n", "Note that this will only work on websites that can be scraped using this simplistic approach.\n", "\n", "Websites that are rendered with Javascript, like React apps, won't show up. See the community-contributions folder for a Selenium implementation that gets around this. You'll need to read up on installing Selenium (ask ChatGPT!)\n", "\n", "Also Websites protected with CloudFront (and similar) may give 403 errors - many thanks Andy J for pointing this out.\n", "\n", "But many websites will work just fine!" ] }, { "cell_type": "code", "execution_count": null, "id": "45d83403-a24c-44b5-84ac-961449b4008f", "metadata": {}, "outputs": [], "source": [ "display_summary(\"https://cnn.com\")" ] }, { "cell_type": "code", "execution_count": null, "id": "75e9fd40-b354-4341-991e-863ef2e59db7", "metadata": {}, "outputs": [], "source": [ "display_summary(\"https://anthropic.com\")" ] }, { "cell_type": "markdown", "id": "c951be1a-7f1b-448f-af1f-845978e47e2c", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Business applications

\n", " In this exercise, you experienced calling the Cloud API of a Frontier Model (a leading model at the frontier of AI) for the first time. We will be using APIs like OpenAI at many stages in the course, in addition to building our own LLMs.\n", "\n", "More specifically, we've applied this to Summarization - a classic Gen AI use case to make a summary. This can be applied to any business vertical - summarizing the news, summarizing financial performance, summarizing a resume in a cover letter - the applications are limitless. Consider how you could apply Summarization in your business, and try prototyping a solution.\n", "
\n", "\n", "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Before you continue - now try yourself

\n", " Use the cell below to make your own simple commercial example. Stick with the summarization use case for now. Here's an idea: write something that will take the contents of an email, and will suggest an appropriate short subject line for the email. That's the kind of feature that might be built into a commercial email tool.\n", "
" ] }, { "cell_type": "code", "execution_count": null, "id": "00743dac-0e70-45b7-879a-d7293a6f68a6", "metadata": {}, "outputs": [], "source": [ "# Step 1: Create your prompts\n", "\n", "system_prompt = \"something here\"\n", "user_prompt = \"\"\"\n", " Lots of text\n", " Can be pasted here\n", "\"\"\"\n", "\n", "# Step 2: Make the messages list\n", "\n", "messages = [] # fill this in\n", "\n", "# Step 3: Call OpenAI\n", "\n", "response =\n", "\n", "# Step 4: print the result\n", "\n", "print(" ] }, { "cell_type": "markdown", "id": "36ed9f14-b349-40e9-a42c-b367e77f8bda", "metadata": {}, "source": [ "## An extra exercise for those who enjoy web scraping\n", "\n", "You may notice that if you try `display_summary(\"https://openai.com\")` - it doesn't work! That's because OpenAI has a fancy website that uses Javascript. There are many ways around this that some of you might be familiar with. For example, Selenium is a hugely popular framework that runs a browser behind the scenes, renders the page, and allows you to query it. If you have experience with Selenium, Playwright or similar, then feel free to improve the Website class to use them. In the community-contributions folder, you'll find an example Selenium solution from a student (thank you!)" ] }, { "cell_type": "markdown", "id": "eeab24dc-5f90-4570-b542-b0585aca3eb6", "metadata": {}, "source": [ "# Sharing your code\n", "\n", "I'd love it if you share your code afterwards so I can share it with others! You'll notice that some students have already made changes (including a Selenium implementation) which you will find in the community-contributions folder. If you'd like add your changes to that folder, submit a Pull Request with your new versions in that folder and I'll merge your changes.\n", "\n", "If you're not an expert with git (and I am not!) then GPT has given some nice instructions on how to submit a Pull Request. It's a bit of an involved process, but once you've done it once it's pretty clear. As a pro-tip: it's best if you clear the outputs of your Jupyter notebooks (Edit >> Clean outputs of all cells, and then Save) for clean notebooks.\n", "\n", "Here are good instructions courtesy of an AI friend: \n", "https://chatgpt.com/share/677a9cb5-c64c-8012-99e0-e06e88afd293" ] }, { "cell_type": "code", "execution_count": null, "id": "f4484fcf-8b39-4c3f-9674-37970ed71988", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.0" } }, "nbformat": 4, "nbformat_minor": 5 }