3ntropyZer0/DataForge

Python

0

0 commits

updated Jan 31, 2026

See the code

README

πŸ”¨ TagForge

Small Model Fine-tuning Toolkit

A complete toolkit for fine-tuning small language models (< 4B parameters) and deploying them anywhere - phones, edge devices, or desktop.

License Python 3.10+

✨ Why TagForge?

  • πŸš€ 2x Faster Training - Powered by Unsloth for optimized LoRA fine-tuning
  • πŸ“± Phone Deployment - Export to ExecuTorch for iOS/Android (~50 tokens/s)
  • πŸ’» Desktop Deployment - Export to GGUF for llama.cpp
  • πŸ“Š Auto Dataset Generation - Use LLMs to generate training data from raw text
  • πŸ“š Built-in Data Sources - 120+ classic books from Project Gutenberg
  • 🎯 Task Agnostic - Fine-tune for any task: tagging, classification, generation, etc.

πŸ“¦ Supported Models

ModelSizePhone ReadyBest For
Qwen3-0.6B472MBβœ…General use (recommended)
Gemma3-270M550MBβœ…Fastest inference
FunctionGemma-270M550MBβœ…Function calling
Qwen2.5-0.5B400MBβœ…Smallest size
Qwen2.5-1.5B1.2GBβœ…Better quality
Qwen3-4B3.2GB⚠️High quality (larger devices)

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/yourusername/tagforge
cd tagforge

# Install dependencies
pip install -e .

# Or use the setup command
tagforge setup

Train Your First Model (5 minutes)

# Full pipeline: generate data β†’ train β†’ test
tagforge all --model qwen3-0.6b --num-samples 1000 --epochs 3

Custom Training

# 1. Prepare your data (JSON with text-label pairs)
tagforge prepare --input my_data.json --output data/train.json

# 2. Train
tagforge train --model qwen3-0.6b --dataset data/train.json --epochs 3

# 3. Test
tagforge test --model-path models/trained_model

# 4. Export
tagforge export gguf --model-path models/trained_model

πŸ“š Training Data

Option 1: Use Your Own Data

Prepare a JSON file with your training examples:

[
  {
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is the capital of France?"},
      {"role": "assistant", "content": "The capital of France is Paris."}
    ]
  }
]

Option 2: Generate Data with LLM

Use a larger LLM to generate training data from raw text:

# Download classic books from Project Gutenberg
tagforge download-gutenberg --num-books 50

# Generate training data using Ollama (local)
tagforge llm-generate \
  --input data/gutenberg/gutenberg_chunks.jsonl \
  --provider ollama \
  --model qwen2.5:7b

# Or use OpenAI/Anthropic
tagforge llm-generate \
  --input my_texts.txt \
  --provider openai \
  --model gpt-4o-mini

Option 3: Built-in Datasets

# Generate from built-in samples
tagforge generate --num-samples 1000

# Include public datasets (AG News, IMDB)
tagforge generate --num-samples 2000 --include-public

πŸ› οΈ Commands

CommandDescription
setupInstall dependencies
models listList available models
models info <model>Show model details
download-gutenbergDownload books from Project Gutenberg
llm-generateGenerate training data using LLM
generateGenerate training dataset (built-in)
prepareConvert custom data to training format
trainFine-tune a model
testTest the fine-tuned model
runInteractive inference
export ggufExport to GGUF (llama.cpp)
export phoneExport for phone (ExecuTorch)
allRun full pipeline

πŸ”§ Training Options

Standard LoRA Training

tagforge train \
    --model qwen3-0.6b \
    --dataset data/train.json \
    --epochs 3 \
    --lora-r 16 \
    --lora-alpha 32

Memory-Efficient Training (4-bit)

tagforge train \
    --model qwen3-0.6b \
    --load-4bit \
    --batch-size 2

Phone Deployment Training (QAT)

tagforge train \
    --model qwen3-0.6b \
    --phone-deployment \
    --epochs 3

πŸ“± Deployment

Desktop (llama.cpp)

# Export to GGUF
tagforge export gguf --model-path models/trained_model

# With specific quantization
tagforge export gguf --model-path models/trained_model --quantization q4_k_m

# List quantization options
tagforge export gguf --list-quantizations

Phone (iOS/Android)

# Export for phone
tagforge export phone \
    --model-path models/trained_model \
    --model-family qwen3 \
    --max-context-length 1024

Performance:

DeviceModelTokens/sec
Pixel 8Qwen3-0.6B~50
iPhone 15 ProQwen3-0.6B~50
Pixel 8Gemma3-270M~60

πŸ“ Project Structure

tagforge/
β”œβ”€β”€ main.py                 # Main CLI
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── registry.py     # Model registry
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   └── tagging_dataset_generator.py
β”‚   └── export/
β”‚       β”œβ”€β”€ gguf_exporter.py
β”‚       └── phone_exporter.py
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ download_gutenberg.py   # Gutenberg downloader
β”‚   β”œβ”€β”€ generate_with_llm.py    # LLM data generation
β”‚   └── ...
└── docs/
    β”œβ”€β”€ PHONE_DEPLOYMENT.md
    β”œβ”€β”€ FINETUNING.md
    └── DEPLOYMENT.md

πŸ“‹ Requirements

  • Python 3.10-3.12
  • CUDA-capable GPU (recommended)
  • 8GB+ VRAM for training
  • 16GB+ RAM

Core Dependencies

torch>=2.1.0
transformers>=4.40.0
unsloth>=2024.8
trl>=0.8.0
peft>=0.10.0

Phone Deployment (Optional)

torchao>=0.14.0
executorch
pytorch_tokenizers

🎯 Use Cases

  • Text Classification - Sentiment, topic, intent classification
  • Entity Extraction - Named entities, keywords, tags
  • Text Generation - Summaries, completions, rewrites
  • Function Calling - Tool use, API calls
  • Custom Tasks - Any text-to-text task

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

πŸ™ Acknowledgments

3ntropyZer0/DataForge

Python

0

0 commits

updated Jan 31, 2026

See the code

README

πŸ”¨ TagForge

Small Model Fine-tuning Toolkit

A complete toolkit for fine-tuning small language models (< 4B parameters) and deploying them anywhere - phones, edge devices, or desktop.

License Python 3.10+

✨ Why TagForge?

  • πŸš€ 2x Faster Training - Powered by Unsloth for optimized LoRA fine-tuning
  • πŸ“± Phone Deployment - Export to ExecuTorch for iOS/Android (~50 tokens/s)
  • πŸ’» Desktop Deployment - Export to GGUF for llama.cpp
  • πŸ“Š Auto Dataset Generation - Use LLMs to generate training data from raw text
  • πŸ“š Built-in Data Sources - 120+ classic books from Project Gutenberg
  • 🎯 Task Agnostic - Fine-tune for any task: tagging, classification, generation, etc.

πŸ“¦ Supported Models

ModelSizePhone ReadyBest For
Qwen3-0.6B472MBβœ…General use (recommended)
Gemma3-270M550MBβœ…Fastest inference
FunctionGemma-270M550MBβœ…Function calling
Qwen2.5-0.5B400MBβœ…Smallest size
Qwen2.5-1.5B1.2GBβœ…Better quality
Qwen3-4B3.2GB⚠️High quality (larger devices)

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/yourusername/tagforge
cd tagforge

# Install dependencies
pip install -e .

# Or use the setup command
tagforge setup

Train Your First Model (5 minutes)

# Full pipeline: generate data β†’ train β†’ test
tagforge all --model qwen3-0.6b --num-samples 1000 --epochs 3

Custom Training

# 1. Prepare your data (JSON with text-label pairs)
tagforge prepare --input my_data.json --output data/train.json

# 2. Train
tagforge train --model qwen3-0.6b --dataset data/train.json --epochs 3

# 3. Test
tagforge test --model-path models/trained_model

# 4. Export
tagforge export gguf --model-path models/trained_model

πŸ“š Training Data

Option 1: Use Your Own Data

Prepare a JSON file with your training examples:

[
  {
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is the capital of France?"},
      {"role": "assistant", "content": "The capital of France is Paris."}
    ]
  }
]

Option 2: Generate Data with LLM

Use a larger LLM to generate training data from raw text:

# Download classic books from Project Gutenberg
tagforge download-gutenberg --num-books 50

# Generate training data using Ollama (local)
tagforge llm-generate \
  --input data/gutenberg/gutenberg_chunks.jsonl \
  --provider ollama \
  --model qwen2.5:7b

# Or use OpenAI/Anthropic
tagforge llm-generate \
  --input my_texts.txt \
  --provider openai \
  --model gpt-4o-mini

Option 3: Built-in Datasets

# Generate from built-in samples
tagforge generate --num-samples 1000

# Include public datasets (AG News, IMDB)
tagforge generate --num-samples 2000 --include-public

πŸ› οΈ Commands

CommandDescription
setupInstall dependencies
models listList available models
models info <model>Show model details
download-gutenbergDownload books from Project Gutenberg
llm-generateGenerate training data using LLM
generateGenerate training dataset (built-in)
prepareConvert custom data to training format
trainFine-tune a model
testTest the fine-tuned model
runInteractive inference
export ggufExport to GGUF (llama.cpp)
export phoneExport for phone (ExecuTorch)
allRun full pipeline

πŸ”§ Training Options

Standard LoRA Training

tagforge train \
    --model qwen3-0.6b \
    --dataset data/train.json \
    --epochs 3 \
    --lora-r 16 \
    --lora-alpha 32

Memory-Efficient Training (4-bit)

tagforge train \
    --model qwen3-0.6b \
    --load-4bit \
    --batch-size 2

Phone Deployment Training (QAT)

tagforge train \
    --model qwen3-0.6b \
    --phone-deployment \
    --epochs 3

πŸ“± Deployment

Desktop (llama.cpp)

# Export to GGUF
tagforge export gguf --model-path models/trained_model

# With specific quantization
tagforge export gguf --model-path models/trained_model --quantization q4_k_m

# List quantization options
tagforge export gguf --list-quantizations

Phone (iOS/Android)

# Export for phone
tagforge export phone \
    --model-path models/trained_model \
    --model-family qwen3 \
    --max-context-length 1024

Performance:

DeviceModelTokens/sec
Pixel 8Qwen3-0.6B~50
iPhone 15 ProQwen3-0.6B~50
Pixel 8Gemma3-270M~60

πŸ“ Project Structure

tagforge/
β”œβ”€β”€ main.py                 # Main CLI
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── registry.py     # Model registry
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   └── tagging_dataset_generator.py
β”‚   └── export/
β”‚       β”œβ”€β”€ gguf_exporter.py
β”‚       └── phone_exporter.py
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ download_gutenberg.py   # Gutenberg downloader
β”‚   β”œβ”€β”€ generate_with_llm.py    # LLM data generation
β”‚   └── ...
└── docs/
    β”œβ”€β”€ PHONE_DEPLOYMENT.md
    β”œβ”€β”€ FINETUNING.md
    └── DEPLOYMENT.md

πŸ“‹ Requirements

  • Python 3.10-3.12
  • CUDA-capable GPU (recommended)
  • 8GB+ VRAM for training
  • 16GB+ RAM

Core Dependencies

torch>=2.1.0
transformers>=4.40.0
unsloth>=2024.8
trl>=0.8.0
peft>=0.10.0

Phone Deployment (Optional)

torchao>=0.14.0
executorch
pytorch_tokenizers

🎯 Use Cases

  • Text Classification - Sentiment, topic, intent classification
  • Entity Extraction - Named entities, keywords, tags
  • Text Generation - Summaries, completions, rewrites
  • Function Calling - Tool use, API calls
  • Custom Tasks - Any text-to-text task

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

πŸ™ Acknowledgments