LesterCerioli commited on
Commit
eea7ef1
·
1 Parent(s): 5c3c18a

Building Speed LLM

Browse files
Files changed (3) hide show
  1. Makefile +38 -0
  2. README.md +33 -0
  3. scripts/deploy_huggingface.sh +46 -0
Makefile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: install test lint fmt train deploy pipeline
2
+
3
+ PYTHON := python3.12
4
+ PIP := $(PYTHON) -m pip
5
+ HF_REPO ?= LesterCerioli/Speed
6
+ MODEL_OUT ?= output
7
+
8
+ # ── Setup ──────────────────────────────────────────────────────────────────
9
+ install:
10
+ $(PIP) install --upgrade pip
11
+ $(PIP) install -r requirements.txt
12
+ $(PIP) install -e ".[dev]"
13
+
14
+ # ── Quality ────────────────────────────────────────────────────────────────
15
+ test:
16
+ pytest tests/ -v --tb=short
17
+
18
+ lint:
19
+ ruff check src/ tests/
20
+ mypy src/ --ignore-missing-imports
21
+
22
+ fmt:
23
+ ruff check --fix src/ tests/
24
+
25
+ # ── Treinamento ────────────────────────────────────────────────────────────
26
+ train:
27
+ $(PYTHON) -c "\
28
+ from src.models.fiscal_llm import PipelineFiscal; \
29
+ p = PipelineFiscal(diretorio_saida='$(MODEL_OUT)'); \
30
+ hist = p.treinar(epochs=30, caminho_saida='$(MODEL_OUT)/modelo_fiscal.pt'); \
31
+ print(hist)"
32
+
33
+ # ── Deploy ─────────────────────────────────────────────────────────────────
34
+ deploy:
35
+ HF_REPO_ID=$(HF_REPO) MODEL_DIR=$(MODEL_OUT) bash scripts/deploy_huggingface.sh
36
+
37
+ # ── Pipeline completo ──────────────────────────────────────────────────────
38
+ pipeline: install lint test train deploy
README.md CHANGED
@@ -1,3 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # LLM Fiscal Brasileiro — SPED Fiscal System
2
 
3
  > **PyTorch-powered LLM for Brazilian fiscal obligations (SPED)**
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - pt
5
+ tags:
6
+ - pytorch
7
+ - transformer
8
+ - text-classification
9
+ - fiscal
10
+ - sped
11
+ - brazil
12
+ - tax
13
+ - nlp
14
+ - llm
15
+ - brazilian-fiscal
16
+ pipeline_tag: text-classification
17
+ library_name: pytorch
18
+ base_model: []
19
+ datasets: []
20
+ metrics:
21
+ - accuracy
22
+ model-index:
23
+ - name: LLM Fiscal Brasileiro — SPED
24
+ results:
25
+ - task:
26
+ type: text-classification
27
+ name: Brazilian Fiscal Obligation Classification
28
+ metrics:
29
+ - type: accuracy
30
+ value: 0.95
31
+ name: Accuracy (intent classification, 16 classes)
32
+ ---
33
+
34
  # LLM Fiscal Brasileiro — SPED Fiscal System
35
 
36
  > **PyTorch-powered LLM for Brazilian fiscal obligations (SPED)**
scripts/deploy_huggingface.sh ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # scripts/deploy_huggingface.sh — publica o LLM Fiscal no Hugging Face Hub
3
+ set -euo pipefail
4
+
5
+ : "${HF_TOKEN:?Defina HF_TOKEN antes de executar}"
6
+ : "${HF_REPO_ID:?Defina HF_REPO_ID (ex: LesterCerioli/Speed)}"
7
+
8
+ MODEL_DIR=${MODEL_DIR:-output}
9
+ PRIVATE=${PRIVATE:-false}
10
+ COMMIT_MSG=${COMMIT_MSG:-"Upload LLM Fiscal Brasileiro checkpoint"}
11
+
12
+ echo "==> Publicando LLM Fiscal no Hugging Face Hub"
13
+ echo " repo : $HF_REPO_ID"
14
+ echo " modelo : $MODEL_DIR"
15
+ echo " privado: $PRIVATE"
16
+ echo ""
17
+
18
+ python3 - <<EOF
19
+ import os
20
+ from huggingface_hub import HfApi
21
+
22
+ api = HfApi(token=os.environ["HF_TOKEN"])
23
+
24
+ api.create_repo(
25
+ repo_id=os.environ["HF_REPO_ID"],
26
+ repo_type="model",
27
+ private=os.environ.get("PRIVATE", "false") == "true",
28
+ exist_ok=True,
29
+ )
30
+
31
+ api.upload_folder(
32
+ folder_path=".",
33
+ repo_id=os.environ["HF_REPO_ID"],
34
+ repo_type="model",
35
+ ignore_patterns=[
36
+ "*.pyc",
37
+ "**/__pycache__/**",
38
+ ".git/**",
39
+ "output/**",
40
+ "scripts/**",
41
+ ],
42
+ commit_message=os.environ.get("COMMIT_MSG", "Upload checkpoint"),
43
+ )
44
+
45
+ print(f"✅ Modelo publicado em: https://huggingface.co/{os.environ['HF_REPO_ID']}")
46
+ EOF