Skip to main content

Lightweight CPU-friendly framework for domain-specific AI

Project description

NAPLY v1.0 - Lightweight Domain AI Framework

A simple, CPU-friendly framework for fine-tuning and deploying domain-specific language models.

Status: Early-stage project | Focus: Domain AI on CPU | Goal: Simple fine-tuning


⚠️ Important: What NAPLY Is and Isn't

✅ NAPLY Is Good For:

  • Fine-tuning small models on domain data (medical, legal, code)
  • CPU-based training (4-8GB RAM)
  • Quick prototyping and deployment
  • Domain-specific chatbots and assistants

❌ NAPLY Is NOT:

  • A replacement for PyTorch (use PyTorch for research)
  • For training GPT-4 scale models
  • Better than TensorFlow for Google-scale systems
  • A full ecosystem like HuggingFace

🎯 Realistic Use Cases

Perfect for:

  1. Medical Q&A bot (fine-tuned on medical texts)
  2. Legal document analyzer
  3. Code completion assistant
  4. Customer support automation
  5. Educational tutoring system

Not suitable for:

  • Training from scratch (use PyTorch)
  • Large-scale GPU clusters (use TensorFlow)
  • Research experiments (use PyTorch)

🚀 Quick Start

import naply

# 1. Load a pre-trained model
model = naply.load("naply/gpt-small")

# 2. Enable efficient fine-tuning
model.enable_lora(rank=8)

# 3. Train on your domain data
model.finetune("medical_data.txt", epochs=3)

# 4. Generate text
response = model.generate("What are diabetes symptoms?")
print(response)

# 5. Save for later
model.save("medical_bot/")

# 6. Deploy as API (optional)
model.serve(port=8000)

📦 Available Models

Model Parameters Size Min RAM Best For
naply/gpt-tiny 10M 40MB 2GB Testing, debugging
naply/gpt-small 50M 200MB 4GB Most use cases
naply/gpt-medium 100M 400MB 8GB Better quality

Note: These models don't exist yet. You would need to train them first.


💻 System Requirements

Minimum:

  • Python 3.8+
  • 4GB RAM
  • CPU (no GPU required)

Recommended:

  • Python 3.10+
  • 8GB RAM
  • Multi-core CPU

📊 Realistic Benchmarks

Expected performance on CPU (4-core Intel i5):

Model Training Speed Inference Speed Memory
gpt-tiny ~5 min/epoch 20 tokens/sec 2GB
gpt-small ~20 min/epoch 10 tokens/sec 4GB
gpt-medium ~60 min/epoch 5 tokens/sec 8GB

Note: These are estimates. Actual performance varies by hardware.


🛠️ Installation

pip install naply

Optional Dependencies:

For model serving:

pip install flask

For GPU support (if available):

pip install cupy

📚 API Reference

Loading Models

import naply

# From hub (when available)
model = naply.load("naply/gpt-small")

# From local path
model = naply.load("my_model/")

# Create new
model = naply.create("small")

Fine-tuning

# Enable LoRA (recommended)
model.enable_lora(rank=8)

# Train
model.finetune(
    data_path="data.txt",  # Text file, one sample per line
    epochs=3,
    batch_size=4,
    learning_rate=1e-4
)

Generation

response = model.generate(
    prompt="What is diabetes?",
    max_length=100,
    temperature=0.8
)

Serving

# Start API server
model.serve(port=8000)

# Then use:
# POST http://localhost:8000/generate
# {"prompt": "Hello!"}

🎓 Example Projects

1. Medical Assistant

import naply

# Load model
model = naply.load("naply/gpt-small")

# Prepare medical data
# Create a file 'medical.txt' with medical Q&A pairs:
# Q: What is diabetes?
# A: Diabetes is a chronic condition...

# Fine-tune
model.enable_lora(rank=8)
model.finetune("medical.txt", epochs=3)

# Test
response = model.generate("What are diabetes symptoms?")
print(response)

# Save
model.save("medical_assistant/")

2. Code Helper

import naply

model = naply.load("naply/gpt-small")
model.enable_lora(rank=8)
model.finetune("code_docs.txt", epochs=3)

# Ask coding questions
response = model.generate("How do I sort a list in Python?")

⚠️ Limitations

Please read these carefully:

  1. Small ecosystem: Not as many pre-trained models as HuggingFace
  2. CPU-focused: GPU support is basic
  3. Not for research: Use PyTorch for novel architectures
  4. Limited models: Only GPT-style transformers currently
  5. Early stage: May have bugs and missing features
  6. Training from scratch: Not recommended (use pre-trained + fine-tune)

🔍 Comparison with Other Frameworks

Feature NAPLY PyTorch HuggingFace TensorFlow
Ease of Use ⭐⭐⭐⭐⭐ ⭐⭐ ⭐⭐⭐⭐ ⭐⭐
Ecosystem ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐
CPU Training ⭐⭐⭐⭐⭐
Research ⭐⭐⭐⭐⭐ ⭐⭐⭐ ⭐⭐⭐
Production ⭐⭐⭐ ⭐⭐⭐ ⭐⭐ ⭐⭐⭐⭐⭐
Model Variety ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐

Choose based on your needs:

  • NAPLY: Quick domain AI on CPU
  • PyTorch: Research and custom models
  • HuggingFace: Use existing NLP models
  • TensorFlow: Production at scale

🐛 Troubleshooting

Out of Memory

  • Use naply/gpt-tiny instead of larger models
  • Reduce batch_size to 1 or 2
  • Enable LoRA (saves 50% memory)

Slow Training

  • Use smaller model
  • Reduce sequence length in data
  • Ensure data is clean (no duplicates)

Poor Results

  • Train for more epochs (4-5)
  • Clean your training data
  • Add more training examples
  • Try larger model if RAM allows

🤝 Contributing

This is an early-stage project. Contributions welcome:

  • Bug reports
  • Documentation improvements
  • Example projects
  • Pre-trained models
  • Performance optimizations

📄 License

MIT License


🙏 Acknowledgments

NAPLY is inspired by:

  • PyTorch (dynamic graphs)
  • HuggingFace Transformers (ease of use)
  • LoRA paper (efficient fine-tuning)

This is not a replacement for these frameworks, but a simpler alternative for specific use cases.


Status: Early development | Use at your own risk | Feedback welcome

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

naply_ai-1.0.0.tar.gz (158.2 kB view details)

Uploaded Source

File details

Details for the file naply_ai-1.0.0.tar.gz.

File metadata

  • Download URL: naply_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 158.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for naply_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6d4e621bbe63fa1b0539ec30788f638fbc3a54a1a85f349e5e1fe7204842fcd6
MD5 7c7fdb4e398239e42ccf37063d85c3b1
BLAKE2b-256 46980c729c16a96d40a430483eeb63b9145a0de4beb3270b4869c25ab4f6aeed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page