Instructions to use CyberPaul/ratio-gemma3-4b-gguf-v8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use CyberPaul/ratio-gemma3-4b-gguf-v8 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf CyberPaul/ratio-gemma3-4b-gguf-v8:F16 # Run inference directly in the terminal: llama cli -hf CyberPaul/ratio-gemma3-4b-gguf-v8:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf CyberPaul/ratio-gemma3-4b-gguf-v8:F16 # Run inference directly in the terminal: llama cli -hf CyberPaul/ratio-gemma3-4b-gguf-v8:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf CyberPaul/ratio-gemma3-4b-gguf-v8:F16 # Run inference directly in the terminal: ./llama-cli -hf CyberPaul/ratio-gemma3-4b-gguf-v8:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf CyberPaul/ratio-gemma3-4b-gguf-v8:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf CyberPaul/ratio-gemma3-4b-gguf-v8:F16
Use Docker
docker model run hf.co/CyberPaul/ratio-gemma3-4b-gguf-v8:F16
- LM Studio
- Jan
- Ollama
How to use CyberPaul/ratio-gemma3-4b-gguf-v8 with Ollama:
ollama run hf.co/CyberPaul/ratio-gemma3-4b-gguf-v8:F16
- Unsloth Desktop
- Docker Model Runner
How to use CyberPaul/ratio-gemma3-4b-gguf-v8 with Docker Model Runner:
docker model run hf.co/CyberPaul/ratio-gemma3-4b-gguf-v8:F16
- Lemonade
How to use CyberPaul/ratio-gemma3-4b-gguf-v8 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull CyberPaul/ratio-gemma3-4b-gguf-v8:F16
Run and chat with the model
lemonade run user.ratio-gemma3-4b-gguf-v8-F16
List all available models
lemonade list
- Atomic Chat
File size: 13,709 Bytes
b82a4f6 1e8ffda 685979f 1e8ffda 685979f 1e8ffda 685979f 1e8ffda 685979f 1e8ffda 685979f 1e8ffda 6be9635 685979f 1e8ffda 685979f 04a8382 685979f 04a8382 1e8ffda 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 1e8ffda 04a8382 1e8ffda 04a8382 685979f 1e8ffda 04a8382 685979f 04a8382 685979f 04a8382 1e8ffda 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 1e8ffda 685979f 04a8382 1e8ffda 685979f 1e8ffda 685979f 1e8ffda 04a8382 1e8ffda 685979f 1e8ffda 85d6ae7 1e8ffda 685979f 1e8ffda 685979f 1e8ffda 685979f 04a8382 1e8ffda 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 1e8ffda 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 1e8ffda 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 685979f 04a8382 6be9635 685979f 04a8382 685979f | 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | <p align="center">
<img src="logo.png" alt="RATIO" width="100">
</p>
<h1 align="center">RATIO — Ratio Decidendi Engine</h1>
<p align="center"><em>ratio decidendi</em> — o raciocínio jurídico por trás das decisões</p>
<p align="center">
<em>Inteligência jurídica com seus dados sob seu controle.</em><br/>
<strong>100% local • 100% offline • 100% confidencial</strong>
</p>
<p align="center">
<a href="#-planos-e-preços">Planos</a> •
<a href="#-funcionalidades">Funcionalidades</a> •
<a href="#-instalação">Instalação</a> •
<a href="#-arquitetura">Arquitetura</a> •
<a href="#-licenciamento">Licenciamento</a>
</p>
---
> **RATIO** (/ˈrɑː.ti.oʊ/) — do latim *ratio decidendi*, o raciocínio jurídico que fundamenta uma decisão judicial.
O **RATIO** é um sistema de RAG (Retrieval-Augmented Generation) jurídico, **local-first e 100% offline**, projetado para advogados e escritórios de advocacia que demandam máxima confidencialidade no tratamento de seus documentos. O sistema extrai e analisa informações de múltiplos formatos de arquivos, permitindo interações em linguagem natural e rastreando de forma precisa a fundamentação legal de cada resposta diretamente no documento original.
---
## 🚀 v1.0.0 — Lançamento Oficial (Agosto 2026)
| Componente | Status | URL |
|------------|:------:|-----|
| **Software Desktop** | ✅ | `RATIO_Setup_v1.0.exe` |
| **License Server** | ✅ | `api.singularislabs.com.br` |
| **Landing Page** | ✅ | `ratio.singularislabs.com.br` |
| **Hotmart (4 planos)** | ✅ | `pay.hotmart.com/*` |
| **Email** | ✅ | `contato@singularislabs.com.br` |
| **Google Search Console** | ✅ | Verificado |
| **Google Analytics 4** | ✅ | `G-K7TG5J8G7L` |
| **Google Business Profile** | ✅ | Singularis Labs |
| **HuggingFace** | ✅ | 3 modelos publicados |
| **SEO (7 páginas)** | ✅ | Pillar pages + comparativos |
| **INPI Registro** | ⏳ | GRU paga, aguardando e-CNPJ |
### 📊 Métricas de Produção
| Métrica | Valor |
|---------|:-----:|
| **Testes automatizados** | 622 (441 core + 180 license-server + 1 landing) |
| **Bugs críticos** | 0 |
| **Camadas de segurança** | 13 |
| **Páginas SEO indexáveis** | 7 |
| **Modelos HuggingFace** | 3 (BERT + LoRA + GGUF) |
---
## 🤖 IA Treinada — Classificador de Ratio Decidendi
| | |
|---|---|
| **Modelo** | [`CyberPaul/ratio-bert-jurisprudencia-pt`](https://huggingface.co/CyberPaul/ratio-bert-jurisprudencia-pt) |
| **Base** | BERTimbau (`neuralmind/bert-base-portuguese-cased`) |
| **Tarefa** | Classificação binária: a sentença é *ratio decidendi* ou não? |
| **Dados** | 20.266 sentenças balanceadas de 634.368 acórdãos do STJ e STF |
| **F1-Score** | **99,55%** (em sentenças) — estimativa de 93–97% em documentos inéditos |
| **Licença** | Apache 2.0 |
### 🛡️ Filtro de qualidade no pipeline
O classificador é integrado como **guardião de qualidade** da extração (`processors/bert_ratio_filter.py`). Cada sentença extraída é validada — cabeçalhos, relatórios, votações e dados processuais são removidos. Roda em lotes de 32 com detecção automática de device (DirectML → CUDA → CPU).
---
## 🧠 Fine-Tune Generativo — RATIO v8.2 + Gate
| | |
|---|---|
| **Base** | `unsloth/gemma-3-4b-it-bnb-4bit` (QLoRA 4-bit) |
| **Dataset** | 1.259 exemplos (700 RAG + 200 abstenção + 249 adversariais) |
| **LoRA** | [`CyberPaul/ratio-gemma3-4b-lora-v8`](https://huggingface.co/CyberPaul/ratio-gemma3-4b-lora-v8) (277 MB) |
| **GGUF** | [`CyberPaul/ratio-gemma3-4b-gguf-v8`](https://huggingface.co/CyberPaul/ratio-gemma3-4b-gguf-v8) (Q4_K_M 2.49 GB) |
| **Gate arquitetural** | `scripts/gate_rag.py` — intercepta armadilhas antes do LLM |
### 📊 Protocolo de Avaliação
| Métrica | v8.2 + Gate | Threshold | Status |
|---------|:-----------:|:---------:|:------:|
| Faithfulness | **0.983** | ≥ 0.85 | ✅ |
| Citation Accuracy | **0.997** | ≥ 0.90 | ✅ |
| Unsupported Claims | **0.058** | ≤ 0.10 | ✅ |
| Hallucination Rate | **0.000** | ≤ 0.10 | ✅ |
| Utility Score | **0.940** | ≥ 0.70 | ✅ |
> **Gate: ✅ APROVADO PARA PRODUÇÃO** — Suite A (100/100) + Suite B (50/50) + Smoke Test (10/10)
### Deploy no Ollama
```bash
python scripts/deploy_gguf_ollama.py
ollama list | grep ratio-gemma3
```
---
## 🌐 Landing Page Comercial
A landing page está online em **[ratio.singularislabs.com.br](https://ratio.singularislabs.com.br/)**. Código-fonte em `landing-page/RATIOlanding2/`.
- **Verificador de Compatibilidade de Hardware** — sliders de RAM/VRAM + seletor de SO
- **Showcase da IA treinada** — métricas reais (99,55% F1)
- **Planos, FAQ e Trial** — tudo pronto para conversão
- **SEO otimizado** — meta tags, Open Graph e conteúdo semântico
### 🧪 Testes da landing page (Vitest)
A landing page possui **36 testes automatizados** com cobertura de **~91%**.
```bash
cd landing-page/RATIOlanding2
npm test
```
---
## 🎯 Planos e Preços
| Recurso | 🌱 TRIAL | ⚡ SOLO | 🏢 ESCRITÓRIO | 🏛️ ENTERPRISE |
|---------|:--------:|:------:|:------------:|:-------------:|
| **Preço** | **Grátis** | **R$ 197/mês** ou **R$ 1.970/ano** | **R$ 497/mês** ou **R$ 4.970/ano** | **Sob consulta** |
| **Duração** | 14 dias | Mensal/Anual | Mensal/Anual | Perpétuo |
| **Usuários** | 1 | 1 | Até 5 | Ilimitado |
| **Bases** | Até 3 | Ilimitadas | Ilimitadas | Ilimitadas |
| **RAG completo** | ✅ | ✅ | ✅ | ✅ |
| **Exportar PDF** | ✅ | ✅ | ✅ | ✅ |
| **OCR em imagens** | ✅ | ✅ | ✅ | ✅ |
| **Suporte prioritário** | — | ✅ | ✅ | ✅ |
| **Multi-usuário** | — | — | ✅ | ✅ |
| **API access** | — | — | — | ✅ |
| **Suporte dedicado** | — | — | — | ✅ |
### 🎁 Trial Grátis
Na primeira execução, o RATIO cria automaticamente uma licença **TRIAL de 14 dias** com todas as funcionalidades básicas. Sem necessidade de cartão de crédito.
---
## ✨ Funcionalidades
### 🔒 Privacidade Primeiro
- **100% offline** — Seus documentos nunca saem do seu computador
- **Sem APIs de terceiros** — Todo processamento é local via Ollama
- **LGPD compliant** — Arquitetura desenhada para conformidade desde a fundação
- **Hardware binding** — Licença vinculada à máquina, sem risco de uso não autorizado
### 🧠 RAG Jurídico Inteligente
- **Busca Híbrida** — Busca semântica vetorial + BM25 para precisão máxima
- **Chunking Semântico Jurídico** — Divisão por Artigos, Parágrafos, Incisos e Cláusulas
- **Streaming Token a Token** — Respostas em tempo real via WebSocket
- **Citação de Fontes** — Referência exata ao documento e página
- **Filtro BERT** — IA própria que valida cada sentença extraída (99,55% F1)
### 📄 Ingestão Multi-Formato
- **PDF** (texto nativo + OCR para escaneados)
- **DOCX, XLSX, PPTX** (Word, Excel, PowerPoint)
- **Imagens** (PNG, JPG — OCR automático)
- **URLs e YouTube** (web scraping e transcrição automática)
- **Google Drive** (importação via OAuth2)
- **OneDrive** (importação via OAuth2)
### 🖥️ Interface Premium
- **Onboarding interativo** — Wizard de 5 passos na primeira execução
- **Visualizador de PDF** com highlight automático da página citada
- **Chat com streaming** e cards de fonte clicáveis
- **Exportação de consultas em PDF**
- **Tema dark/light** — Alternável com um clique
---
## 🏗️ Arquitetura
```text
Projeto RATIO/
├── core/ # Núcleo (auth, license, chunker, rag_engine, retriever)
├── engine/ # Motor de inferência (llm_client, modelo_installer, exportador)
├── processors/ # Processadores (bert_ratio_filter, ratio_extractor)
├── scripts/ # Pipeline de dados, treino e publicação
├── frontend/ # Interface React + TypeScript
├── tests/ # 622 testes automatizados
├── license-server/ # Central de Licenças (webhook Hotmart, emails, painel)
├── landing-page/ # Landing page comercial (React + Vite)
├── installer/ # Instalador Windows (Inno Setup 6.3+)
├── api.py # Ponto de entrada FastAPI (HTTP + WebSocket)
├── iniciar.bat # Execução com 1 clique
└── build_ratio.bat # Build do instalador
```
---
## 🚀 Instalação
### 🖥️ Compatibilidade
| Sistema Operacional | Status | Método |
|---------------------|:------:|--------|
| **Windows 10/11** | ✅ | Instalador (.exe) — `RATIO_Setup_v1.0.exe` |
| **macOS 12+** | ✅ | Script de instalação (bash) |
| **Linux** | ✅ | Script de instalação (bash) |
### 🔧 Setup Automático (Recomendado)
| SO | Comando |
|----|---------|
| **Windows** | `setup_ratio.bat` |
| **macOS** | `chmod +x install_mac.sh && ./install_mac.sh` |
| **Linux** | `chmod +x install_linux.sh && ./install_linux.sh` |
### ⚙️ Setup Manual
#### 1. Pré-requisitos
- **Python 3.10+** — [python.org](https://python.org)
- **Node.js 18+** — [nodejs.org](https://nodejs.org)
- **Ollama** — [ollama.com](https://ollama.com)
- **Tesseract OCR** (opcional, para PDFs escaneados)
#### 2. Configurar Backend
```bash
pip install -r requirements.txt
copy .env.example .env
```
Edite o `.env`:
```ini
RATIO_API_KEY=sua_chave_secreta_aqui
OLLAMA_BASE_URL=http://localhost:11434
RATIO_MODELO=gemma3:4b
RATIO_NUM_CTX=4096
RATIO_HOST=127.0.0.1
RATIO_PORT=8000
RATIO_LICENSE_SERVER=https://api.singularislabs.com.br
```
#### 3. Executar
**Método recomendado:** execute `iniciar.bat` — sobe Ollama, backend e frontend automaticamente.
**Modo manual:**
```bash
make run-api # Terminal 1 — Backend (porta 8000)
make run-frontend # Terminal 2 — Frontend (porta 5173)
```
Acesse: **http://localhost:5173** 🎉
---
## 🔐 Licenciamento
O RATIO tem licenciamento local (trial, ativação, hardware binding) com validação
opcional contra a **Central de Licenças** (`api.singularislabs.com.br`).
### Como funciona
1. **Primeira execução** → Trial de 14 dias criado automaticamente
2. **Compra (Hotmart)** → webhook cria a licença e a chave é enviada por email
3. **Ativação** → inserir chave na tela de licenciamento
4. **Validação** → integridade (checksum SHA256), hardware (MAC + username), data de expiração
### Central de Licenças
| Recurso | Detalhe |
|---|---|
| **Webhook Hotmart** | Venda cria licença, cancelamento/reembolso revoga |
| **Emails automáticos** | Chave pro cliente · aviso pro admin · lembretes de renovação |
| **Ativação** | `POST /v1/activate` — valida chave + hardware |
| **Heartbeat** | `POST /v1/check` — vigência/revogação em tempo real |
| **Painel admin** | `/admin` — vendas, receita, vencimentos, cadastro manual |
### Tipos de licença
| Prefixo | Tipo | Duração | Recursos |
|:-------:|------|:-------:|----------|
| `RATIO-TRIAL-...` | TRIAL | 14 dias | Funcionalidades básicas |
| `S...` | SOLO | 365 dias | RAG completo, bases ilimitadas |
| `E...` | ESCRITÓRIO | 365 dias | Multi-usuário, prompts customizados |
| `P...` | ENTERPRISE | **Perpétuo** | API access, suporte dedicado |
---
## 🔒 Segurança e Privacidade
- **LGPD compliant** — Dados nunca saem da máquina do usuário
- **API Key timing-safe** — Comparação em tempo constante (`secrets.compare_digest`)
- **WebSocket autenticado** — Validação de token no handshake
- **Hardware binding** — Licença vinculada ao hardware
- **Grace period 72h** — Cache encriptado para funcionar offline
- **Rate limiting** — 5 tentativas de ativação por hora
- **Gate arquitetural** — Intercepta perguntas que pedem confirmação de processo sem documento
- **Dashboard de segurança** — Monitoramento de tentativas de cracking em tempo real
---
## 🧪 Testes
```bash
# Toda a suíte (622 testes)
pytest tests/ -v
# Suíte completa com 1 clique (Windows)
run_tests.bat
# Testes específicos
pytest tests/test_license.py -v # 26 testes de licenciamento
pytest tests/test_bert_filter.py -v # Testes do filtro BERT
pytest tests/test_citation_checker.py -v # Citation checker
```
---
## 🛠️ Comandos
| Comando | Descrição |
|---------|-----------|
| `setup_ratio.bat` | Configuração completa do ambiente |
| `build_ratio.bat` | Build: frontend + PyInstaller + Inno Setup |
| `iniciar.bat` | Execução com 1 clique (recomendado) |
| `make run-api` | Inicia backend FastAPI (porta 8000) |
| `make run-frontend` | Inicia frontend Vite (porta 5173) |
| `run_tests.bat` | Roda toda a suíte de testes |
---
## 📞 Contato
| Canal | Link |
|-------|------|
| **Site** | [ratio.singularislabs.com.br](https://ratio.singularislabs.com.br) |
| **Email** | [contato@singularislabs.com.br](mailto:contato@singularislabs.com.br) |
| **GitHub** | [Churinti/singularis-labs](https://github.com/Churinti/singularis-labs) (privado) |
| **HuggingFace** | [CyberPaul](https://huggingface.co/CyberPaul) |
| **Hotmart** | [pay.hotmart.com](https://pay.hotmart.com/U107349593U) |
---
## 📜 Licença
O código-fonte do RATIO é proprietário. Os modelos publicados no HuggingFace possuem licenças específicas:
| Modelo | Licença |
|--------|---------|
| `ratio-bert-jurisprudencia-pt` | Apache 2.0 |
| `ratio-gemma3-4b-lora-v8` | Gemma Terms of Use |
| `ratio-gemma3-4b-gguf-v8` | Gemma Terms of Use |
| `ratio-dataset-v8.1` | Apache 2.0 |
---
<p align="center">
<strong>Singularis Labs</strong> • São Gonçalo, RJ • CNPJ: 68.801.082/0001-07<br/>
<a href="https://ratio.singularislabs.com.br">ratio.singularislabs.com.br</a>
</p>
|