# ๐Ÿš€ Running PALADIM Demos from Hugging Face You can run PALADIM demos **without cloning this repository**! Everything loads directly from Hugging Face Hub. ## ๐ŸŽฏ Quick Options ### Option 1: Python Script (Fastest) ```powershell # Install packages pip install transformers peft torch # Run demo python demo_from_huggingface.py ``` This loads the model from https://huggingface.co/nickagge/paladim-sentiment and runs inference. --- ### Option 2: Google Colab (No Installation) 1. **Open this notebook**: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/nickagge/paladim/blob/main/PALADIM_Demo.ipynb) 2. **Enable GPU** (optional but faster): - Click: `Runtime` โ†’ `Change runtime type` โ†’ `T4 GPU` 3. **Run all cells** (`Ctrl+F9` or `Runtime` โ†’ `Run all`) That's it! The model loads from Hugging Face automatically. --- ### Option 3: Jupyter Notebook (Local) ```powershell # Install Jupyter pip install jupyter transformers peft torch # Start Jupyter jupyter notebook # Open: PALADIM_Demo.ipynb ``` Then run all cells in the notebook. --- ### Option 4: Copy-Paste Code (Any Python Environment) ```python # Install: pip install transformers peft torch import torch from transformers import AutoTokenizer, AutoModelForSequenceClassification from peft import PeftModel # Load model from Hugging Face model = AutoModelForSequenceClassification.from_pretrained( "distilbert-base-uncased", num_labels=2 ) tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased") model = PeftModel.from_pretrained(model, "nickagge/paladim-sentiment") # Test it text = "This is amazing!" inputs = tokenizer(text, return_tensors="pt", truncation=True) with torch.no_grad(): outputs = model(**inputs) prediction = torch.argmax(outputs.logits, dim=-1).item() print("Sentiment:", "Positive" if prediction == 1 else "Negative") ``` --- ## ๐Ÿ“ฆ What Gets Downloaded? When you run any demo, these files automatically download from Hugging Face: - **Base model**: `distilbert-base-uncased` (~250 MB) - **PALADIM adapters**: `nickagge/paladim-sentiment` (~3.5 MB) - **Tokenizer**: Vocabulary and config files (~1 MB) **Total**: ~255 MB (cached after first run) --- ## ๐ŸŒ Where Does It Run? | Environment | Setup | GPU | Cost | |------------|-------|-----|------| | **Google Colab** | Click notebook link | โœ… Free T4 | $0 | | **Local PC** | `pip install ...` | Optional | $0 | | **Jupyter** | `jupyter notebook` | Optional | $0 | | **Kaggle** | Upload notebook | โœ… Free GPU | $0 | | **Any Python** | Copy-paste code | Optional | $0 | --- ## ๐Ÿ’ป System Requirements ### Minimum (CPU) - Python 3.8+ - 4GB RAM - 500 MB disk space - Works on any laptop ### Recommended (GPU) - NVIDIA GPU with CUDA - 8GB VRAM - Faster inference (~10x) --- ## ๐ŸŽฏ Available Demos | Demo | Description | File | How to Run | |------|-------------|------|------------| | **From HF** | Load model from cloud | `demo_from_huggingface.py` | `python demo_from_huggingface.py` | | **Basic Usage** | Simple inference | `demo_usage.py` | `python demo_usage.py` | | **Continual Learning** | Full PALADIM pipeline | `demo_continual_learning.py` | `python demo_continual_learning.py` | | **Training** | Train from scratch | `train.py` | `python train.py` | | **Benchmark** | Test performance | `train.py` | `python train.py --run_benchmark` | | **Jupyter Notebook** | Interactive demo | `PALADIM_Demo.ipynb` | Open in Colab/Jupyter | --- ## ๐Ÿ”ง Troubleshooting ### "No module named 'transformers'" ```powershell pip install transformers peft torch ``` ### "Connection error" or "Model not found" - Check internet connection - Verify model exists: https://huggingface.co/nickagge/paladim-sentiment ### "CUDA out of memory" ```python # Use CPU instead device = "cpu" model.to(device) ``` ### Model predicts all one class - This is a demo model trained on limited data - For production, train on more diverse data - See `train.py` for training examples --- ## ๐Ÿ“š Next Steps 1. โœ… **Run a demo** - Try `demo_from_huggingface.py` first 2. ๐Ÿ“– **Read the docs** - See `GETTING_STARTED.md` for full guide 3. ๐Ÿงช **Train your own** - Use `train.py` with your data 4. ๐Ÿš€ **Deploy** - Use the model in your applications 5. ๐Ÿ“ค **Share** - Upload your trained models to Hugging Face --- ## ๐Ÿ”— Resources - **Model on Hugging Face**: https://huggingface.co/nickagge/paladim-sentiment - **GitHub Repository**: https://github.com/nickagge/paladim - **Issues/Support**: https://github.com/nickagge/paladim/issues --- ## ๐Ÿ’ก Example Use Cases ### 1. Sentiment Analysis API ```python from flask import Flask, request # ... load PALADIM model ... @app.route('/analyze', methods=['POST']) def analyze(): text = request.json['text'] sentiment = predict_sentiment(text) return {'sentiment': sentiment} ``` ### 2. Batch Processing ```python texts = ["text1", "text2", "text3", ...] results = [analyze_sentiment(t) for t in texts] ``` ### 3. Real-time Analysis ```python import streamlit as st text = st.text_area("Enter text:") if text: sentiment = analyze_sentiment(text) st.write(f"Sentiment: {sentiment}") ``` --- **๐ŸŽ‰ Happy experimenting with PALADIM!**