MD Ayaan Siddiqui

Apr 08, 2026 • 10 min read

How I Fine-tuned My First AI Model on a Free GPU

How I Fine-tuned My First AI Model on a Free GPU

By MD Ayaan Siddiqui (moayaan.eth)

What is ImanVibes?

Before I talk about the AI model, I need to give some context. A few days ago, I launched a small Islamic web app called ImanVibes. The idea is simple: open the Quran by how you feel right now. Anxious? There is an ayah for that. Hopeless? There is an ayah for that. Grieving? There is an ayah for that.

ImanVibes is completely free, no ads, no sign up, no backend. Just a calm, mobile-first Progressive Web App with Quran by mood, Hadith, and the 99 Names of Allah. I also built it as a PWA and I am currently working on a native Android build so it works offline and feels like a real app on Android devices.

The app is live at imanvibes.vercel.app and the GitHub is at github.com/moayaan1911/imanvibes.

After launching ImanVibes, I kept thinking: what if there was an AI inside this app that could actually talk to you about Islam? Not hallucinate random hadiths. Not mix up ayah numbers. Not give you some generic spiritual advice. A real Islamic AI that cites its sources, speaks with warmth, and knows the difference between authentic scholarship and cultural myths.

That idea became Alif-1.0.


Why Alif?

The name Alif is intentional. Alif is the first letter of the Arabic alphabet. It is the first letter of Allah. It is the first letter of Al-Quran. Just as Alif marks the beginning of Arabic script, Alif-1.0 marks the beginning of authentic Islamic AI. The model family is called the Alif family. This is version 1.0. Future versions will be Alif-1.5, Alif-2.0, and beyond.


Fine-tuning vs Training from Scratch

The first thing people get confused about is what fine-tuning actually means.

Training a model from scratch means you start with nothing. Random weights, trillions of tokens of training data, hundreds of GPUs, and months of compute time. This is what Alibaba did to build Qwen. This is what OpenAI did to build GPT. This costs millions of dollars and requires a full research team.

Fine-tuning is completely different. You take a model that already exists and already knows how to read, write, reason, and understand language. Then you train it further on your specific data so it learns your domain deeply.

Think of it like this. Imagine hiring a brilliant university graduate who has read thousands of books and is generally very smart. Now you put them through a specialized training program focused entirely on Islamic knowledge. They do not forget everything they knew before. They just get really good at your specific subject.

That is fine-tuning. And that is what I did with Alif-1.0.

I chose Qwen3.5–2B by Alibaba as my base model. It is 2 billion parameters, supports over 201 languages including Arabic and Urdu, is released under the Apache 2.0 license which means I can use it commercially, and most importantly it is small enough to fine-tune on a free GPU. It punches way above its weight class for its size.


Building the Dataset

The dataset is honestly the most important part of fine-tuning. Garbage in, garbage out. This is even more critical for Islamic content because wrong ayah numbers or fabricated hadiths are not just technical errors, they are a serious matter of responsibility.

I built a dataset of 1,042 instruction-response pairs. Every single pair follows the same format: a question or instruction, and a detailed accurate response citing real sources.

I used Zai, an AI assistant by Zhipu AI (a Chinese AI company), to help me generate the dataset. I wrote very detailed prompts specifying exact sources, formatting requirements, and quality standards. I also used Claude by Anthropic throughout the entire project for guidance, planning, and technical help.

The dataset has three categories.

The first is the Quran dataset with approximately 338 pairs. These cover mood-based ayah guidance, Tawheed, Salah, Sabr, hope, grief, anxiety, death, Jannah, Jahannam, Tawbah, and more. Every ayah is cited with the Surah name, Surah number, and ayah number. I only used Sahih International and Pickthall translations.

The second is the Hadith dataset with approximately 300 pairs. I only used hadith from Sahih Bukhari, Sahih Muslim, Sunan Abu Dawud, Jami at-Tirmidhi, Sunan an-Nasai, Sunan Ibn Majah, Muwatta Malik, and Musnad Ahmad. Every single hadith includes the collection name, book number, and hadith number. No guessing. No paraphrasing from memory.

The third is the Islamic History and Geopolitics dataset with approximately 400 pairs. Sources used were exclusively classical Islamic scholars: Ibn Kathir from Al-Bidaya wan-Nihaya, Ibn Khaldun from the Muqaddimah, Al-Tabari, and Ibn Hisham from the Sirah an-Nabawiyyah. Zero Western or orientalist sources. Topics covered include the life of Prophet Muhammad PBUH, the major battles, the Rightly Guided Caliphs, the tragedy of Karbala, the Crusades from a Muslim perspective, the Mongol invasion, the Ottoman Empire, the Mughal Empire, Al-Andalus, and modern Islamic geopolitics.

One important quality check I did was comparing outputs from two different AI systems when generating the dataset. ChatGPT produced a dataset that repeated the same hadith and same paragraph three or four times in a single entry, and recycled the same five hadiths across hundreds of entries. This would have been catastrophic for training. Zai produced genuinely diverse, detailed, properly sourced pairs. I chose Zai and discarded the ChatGPT output entirely.

After generating all three datasets separately, I merged them into a single master file called imanvibes_master_dataset_cleaned.json with 1,042 total pairs, zero duplicates, zero empty entries, and a consistent structure throughout.


The Training Setup

For fine-tuning I used Unsloth, an open source library that makes training 2x faster and uses 70% less VRAM compared to standard approaches. This is what made free GPU training actually possible.

The fine-tuning method is called LoRA, which stands for Low-Rank Adaptation. Instead of updating all 2 billion parameters of the base model, LoRA inserts small trainable matrices into specific layers and only trains those. The result is a tiny adapter file that captures the Islamic knowledge, while the original model weights stay untouched. When you load the final model, both work together seamlessly.

My training configuration was:

Base model: unsloth/Qwen3.5–2B Maximum sequence length: 2,048 tokens Batch size: 1 per device Gradient accumulation steps: 4 Learning rate: 2e-4 Epochs: 3 Total steps: 783 Optimizer: adamw_8bit

I used Google Colab free tier with a T4 GPU for most of the training. The training took approximately 3 hours. The loss started at 1.84 and ended at 0.30, which represents an 83% improvement. Lower loss means the model is making fewer mistakes and learning the patterns in the data more accurately.


The Safety System

One thing I was very serious about from the beginning was building a proper safety system into Alif-1.0.

Islamic AI is uniquely sensitive. If someone asks about terrorism or jihad, the model must respond clearly that these groups have no basis in authentic Islam, citing Quran 5:32 which states that killing one innocent soul is like killing all of humanity. If someone brings up controversial topics like Aisha RA’s age at marriage, the model must respond with scholarly context rather than getting defensive or making things worse. If someone tries to use Islamic texts to justify oppressing women, the model must push back with facts about what Islam actually says about women’s rights.

The safety system is embedded in a detailed system prompt that Alif-1.0 uses for every conversation. It covers Islamophobia handling, extremism responses, women’s rights in Islam, interfaith respect, political neutrality, and a prohibition on fabricating Islamic rulings.

Every single response from Alif-1.0 also ends with a mandatory disclaimer stating that it is a beta model fine-tuned on a small dataset, that responses may be inaccurate, and that users should always verify with a qualified Islamic scholar. This is not just legal protection. It is the honest thing to do.


The Challenges (This Part Was a Mess)

Let me be completely honest about how chaotic this process was.

The first challenge was that I had never written Python or worked with machine learning before. I am a JavaScript and Solidity developer. Everything from setting up the environment to understanding what LoRA even means was completely new to me.

The second challenge was the GPU limits on Google Colab free tier. After training completed successfully and the model was saved in memory, I tried to merge the LoRA adapters with the base model to create a single deployable file. But the T4 GPU only has 15GB of VRAM and the merge operation requires more than that. I hit the GPU usage limit at the worst possible moment, at 11 PM after hours of work, right when I needed to save the model.

I switched to Kaggle which offers a free P100 GPU with 16GB VRAM. But the P100 turned out to be incompatible with the current version of PyTorch. So I switched to Kaggle’s T4 x2 configuration which gives two T4 GPUs for a combined 30GB, and that finally worked.

The third challenge was figuring out the correct way to do the merge. LoRA merge from a 4-bit quantized model does not work the same way as a standard merge. I went through several failed attempts and error messages before finding the right approach.

In the end the merged model is 4.49GB and is fully published on HuggingFace.


Results

Alif-1.0 is now live and open source.

The model is published at huggingface.co/mdayaan1911/alif-1.0 under the Apache 2.0 license. It is a 4.49GB safetensors model that anyone can download, use, or build on top of.

The landing page is live at imanvibes.vercel.app/alif with full documentation about how the model was trained, what data it was trained on, the safety system, and a clear disclaimer.

The post announcing the launch on X received genuine interest from the Muslim tech community within hours.


What is Coming Next

Alif-1.0 is just the beginning. Here is what I am working on.

Alif-1.5 will have a significantly larger dataset, probably 5,000 or more pairs, better Arabic coverage, and proper benchmark evaluations. The dataset quality will also be higher with manual review of every pair.

The API for Alif-1.0 is coming soon. Once deployed, developers will be able to integrate Alif into their own apps, Islamic education platforms, dawah tools, and more through a simple REST API. This is also one of the planned monetization paths for ImanVibes.

The chat feature is coming to ImanVibes. Once the API is live, users will be able to open a chat with Alif directly inside the ImanVibes app. The Coming Soon button on the app will become real.

I am also building the Android native version of ImanVibes so it works properly on Android devices with offline support and a true app experience beyond just the PWA.


Final Thoughts

I am not an ML engineer. I am not a researcher. I am a Full Stack Blockchain Developer who wanted to build something for the Ummah and figured it out step by step.

The tools available today, Unsloth, free GPUs on Colab and Kaggle, open source models from Alibaba, Hugging Face for hosting, are genuinely powerful enough for an individual developer to build a specialized AI model. You do not need a PhD. You do not need a team. You need patience, curiosity, and a willingness to debug at 2 AM when things break.

If this inspires even one Muslim developer to build something for the Ummah, Alhamdulillah.


References and Links

ImanVibes App: https://imanvibes.vercel.app

Alif-1.0 Page: https://imanvibes.vercel.app/alif

Alif-1.0 on HuggingFace: https://huggingface.co/mdayaan1911/alif-1.0

Developer Website: https://moayaan.com

GitHub: https://github.com/moayaan1911

LinkedIn: https://linkedin.com/in/ayaaneth

X: https://x.com/moayaan1911

Unsloth: https://unsloth.ai

Qwen3.5 by Alibaba: https://huggingface.co/Qwen


Disclaimer

This blog was written with the assistance of Claude by Anthropic. The author has reviewed and verified the technical details to the best of his ability, but takes no responsibility for any inaccuracies. All Islamic information referenced in this blog and in Alif-1.0 itself should be verified with a qualified Islamic scholar. The author is a developer, not an Islamic scholar, and this project is a technical exercise in AI fine-tuning, not a religious authority.

Join MD Ayaan on Peerlist!

Join amazing folks like MD Ayaan and thousands of other builders on Peerlist.

peerlist.io/

It’s available... this username is available! 😃

Claim your username before it's too late!

This username is already taken, you’re a little late.😐

0

6

0