This project shows how to fine-tune TinyLlama locally on your own machine using LoRA, with 100% offline capability β no cloud, no GPUs required (but supported), no hosted models.
Itβs based on a real journey of debugging and training from scratch using a custom dataset.
data.jsonl.gguf and run offline with llama.cppInstall dependencies:
pip install transformers datasets peft accelerate bitsandbytes
π« Do NOT install
bitsandbytesif you're on Windows or using an AMD GPU
standard-llama-finetune/
βββ data.jsonl β training dataset (editable)
βββ step0_download_base_model.py β download base model from Hugging Face
βββ step1_0_pdf_to_text.py β Convert PDF to text
βββ step1_1_generate_jsonl.py β Generate JSONL file for fine-tuning data
βββ step2_fine_tuning.py β download base model from Hugging Face
βββ step3_merg.py β fine-tune TinyLlama with LoRA
βββ step4_test.py β merge LoRA adapter into base model
python step0_download_base_model.py
This will save the model to ./tinyllama-base/
python step1_0_pdf_to_text.py
This will save the .txt file at the root.
python step1_1_generate_jsonl.py
This will save the .jsonl file at the root.
python step2_fine_tuning.py
data.jsonltinyllama-finetuned/python step3_merg.py
tinyllama-merged/ β ready for conversion or inferencepython step4_test.py
Expected output:
Hassan Habib is a software engineering leader and the author of The Standard.
.gguf for llama.cpp (make sure you install CMake, clone and build llama.cpp)cd llama.cpp/
python3 convert_hf_to_gguf.py ../tinyllama-merged --outfile standard-mini.gguf --outtype f16
Then run with:
./build/bin/llama-cli --model standard-mini.gguf --prompt "Describe Orchestration services"
Paste this prompt:
### Instruction:
Who is Hassan Habib?
### Input:
### Response:
https://www.youtube.com/watch?v=lc6lVCe0XHI&t=3s
https://www.youtube.com/watch?v=FQr7VrK5RRQ&t=1087s
https://www.youtube.com/watch?v=YB9cVyjV9Bo
https://www.youtube.com/watch?v=3jFpLNglWBc&t=293s
Built and tested by Hassan Habib, fine-tuned with β€οΈ and terminal grit.
Want to turn this into a video or GitHub tutorial? Itβs built to teach.
7 commits
Python
100.0%
This project shows how to fine-tune TinyLlama locally on your own machine using LoRA, with 100% offline capability β no cloud, no GPUs required (but supported), no hosted models.
Itβs based on a real journey of debugging and training from scratch using a custom dataset.
data.jsonl.gguf and run offline with llama.cppInstall dependencies:
pip install transformers datasets peft accelerate bitsandbytes
π« Do NOT install
bitsandbytesif you're on Windows or using an AMD GPU
standard-llama-finetune/
βββ data.jsonl β training dataset (editable)
βββ step0_download_base_model.py β download base model from Hugging Face
βββ step1_0_pdf_to_text.py β Convert PDF to text
βββ step1_1_generate_jsonl.py β Generate JSONL file for fine-tuning data
βββ step2_fine_tuning.py β download base model from Hugging Face
βββ step3_merg.py β fine-tune TinyLlama with LoRA
βββ step4_test.py β merge LoRA adapter into base model
python step0_download_base_model.py
This will save the model to ./tinyllama-base/
python step1_0_pdf_to_text.py
This will save the .txt file at the root.
python step1_1_generate_jsonl.py
This will save the .jsonl file at the root.
python step2_fine_tuning.py
data.jsonltinyllama-finetuned/python step3_merg.py
tinyllama-merged/ β ready for conversion or inferencepython step4_test.py
Expected output:
Hassan Habib is a software engineering leader and the author of The Standard.
.gguf for llama.cpp (make sure you install CMake, clone and build llama.cpp)cd llama.cpp/
python3 convert_hf_to_gguf.py ../tinyllama-merged --outfile standard-mini.gguf --outtype f16
Then run with:
./build/bin/llama-cli --model standard-mini.gguf --prompt "Describe Orchestration services"
Paste this prompt:
### Instruction:
Who is Hassan Habib?
### Input:
### Response:
https://www.youtube.com/watch?v=lc6lVCe0XHI&t=3s
https://www.youtube.com/watch?v=FQr7VrK5RRQ&t=1087s
https://www.youtube.com/watch?v=YB9cVyjV9Bo
https://www.youtube.com/watch?v=3jFpLNglWBc&t=293s
Built and tested by Hassan Habib, fine-tuned with β€οΈ and terminal grit.
Want to turn this into a video or GitHub tutorial? Itβs built to teach.
7 commits
Python
100.0%