Instructions to use amogaddy/GenerAI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amogaddy/GenerAI with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="amogaddy/GenerAI")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("amogaddy/GenerAI", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use amogaddy/GenerAI with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "amogaddy/GenerAI" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amogaddy/GenerAI", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/amogaddy/GenerAI
- SGLang
How to use amogaddy/GenerAI with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "amogaddy/GenerAI" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amogaddy/GenerAI", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "amogaddy/GenerAI" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amogaddy/GenerAI", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use amogaddy/GenerAI with Docker Model Runner:
docker model run hf.co/amogaddy/GenerAI
File size: 5,077 Bytes
40cba1f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | """
upload_hf.py
============
Carica su HuggingFace solo i file necessari del progetto GenerAI.
Uso:
python upload_hf.py
python upload_hf.py --repo amogaddy/GenerAI --model-weights
"""
import argparse
import os
import shutil
import tempfile
from pathlib import Path
# Carica .env se presente
if Path(".env").exists():
for line in Path(".env").read_text(encoding="utf-8").splitlines():
if "=" in line and not line.startswith("#"):
k, v = line.split("=", 1)
os.environ.setdefault(k.strip(), v.strip())
# File del codice da includere
SOURCE_FILES = [
"app.py",
"brain.py",
"knowledge_base.py",
"scraper.py",
"errors.py",
"seed_italian.py",
"export_dataset.py",
"finetune.py",
"upload_hf.py",
"requirements.txt",
"requirements-train.txt",
]
DEFAULT_REPO = "amogaddy/GenerAI"
MODEL_DIR = "./generai-finetuned"
def check_deps():
try:
from huggingface_hub import login, upload_folder, HfApi
return login, upload_folder, HfApi
except ImportError:
print("β huggingface_hub non installato.")
print(" pip install huggingface-hub")
exit(1)
def build_model_card(repo_id: str, include_weights: bool) -> str:
return f"""---
license: mit
base_model: Qwen/Qwen2.5-0.5B-Instruct
language:
- it
tags:
- italian
- generai
- fine-tuned
- rag
---
# GenerAI π€
Assistente AI in italiano con memoria locale (ChromaDB) e ricerca web.
## Come usarlo
```bash
pip install -r requirements.txt
python app.py
```
## Fine-tuning
```bash
pip install -r requirements-train.txt
python export_dataset.py
python finetune.py --dataset dataset.jsonl --hf-repo {repo_id}
```
## Licenza
MIT β fai quello che vuoi, basta lasciare il credito.
"""
def main():
parser = argparse.ArgumentParser(description="Carica GenerAI su HuggingFace")
parser.add_argument("--repo", default=DEFAULT_REPO, help=f"repo_id HuggingFace (default: {DEFAULT_REPO})")
parser.add_argument("--model-weights", action="store_true", help="Includi anche i pesi del modello fine-tunato")
parser.add_argument("--no-login", action="store_true", help="Salta il login (usa token giΓ salvato)")
args = parser.parse_args()
login, upload_folder, HfApi = check_deps()
# ββ Login ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
if not args.no_login:
token = os.environ.get("HF_TOKEN", "")
if token:
print("Login HuggingFace con token da .env...")
login(token=token)
else:
print("Login HuggingFace...")
login()
# ββ Crea cartella temporanea con solo i file necessari βββββββββββββββββββββ
with tempfile.TemporaryDirectory() as tmp:
tmp_path = Path(tmp)
copied = []
missing = []
for fname in SOURCE_FILES:
src = Path(fname)
if src.exists():
shutil.copy2(src, tmp_path / src.name)
copied.append(fname)
else:
missing.append(fname)
# Genera README.md / model card
(tmp_path / "README.md").write_text(
build_model_card(args.repo, args.model_weights),
encoding="utf-8",
)
copied.append("README.md (generato)")
print(f"\nFile da caricare ({len(copied)}):")
for f in copied:
print(f" + {f}")
if missing:
print(f"\nFile non trovati (saltati):")
for f in missing:
print(f" - {f}")
# ββ Upload codice ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
print(f"\nUpload codice -> {args.repo} ...")
upload_folder(
folder_path=str(tmp_path),
repo_id=args.repo,
repo_type="model",
commit_message="Upload GenerAI β codice + grammatica italiana",
)
print("Codice caricato.")
# ββ Upload pesi modello (opzionale) ββββββββββββββββββββββββββββββββββββββββ
if args.model_weights:
if not Path(MODEL_DIR).exists():
print(f"\nCartella pesi non trovata: {MODEL_DIR}")
print(" Esegui prima: python finetune.py --dataset dataset.jsonl")
else:
print(f"\nUpload pesi modello -> {args.repo} ...")
upload_folder(
folder_path=MODEL_DIR,
repo_id=args.repo,
repo_type="model",
commit_message="Upload pesi modello fine-tunato GenerAI",
)
print("Pesi modello caricati.")
print(f"\nCompletato! -> https://huggingface.co/{args.repo}")
if __name__ == "__main__":
main()
|