Instructions to use felipecmarins/gemma3-4b-algebra4-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use felipecmarins/gemma3-4b-algebra4-gguf with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="felipecmarins/gemma3-4b-algebra4-gguf", filename="algebra4-q4_0.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use felipecmarins/gemma3-4b-algebra4-gguf with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf felipecmarins/gemma3-4b-algebra4-gguf:Q4_0 # Run inference directly in the terminal: llama-cli -hf felipecmarins/gemma3-4b-algebra4-gguf:Q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf felipecmarins/gemma3-4b-algebra4-gguf:Q4_0 # Run inference directly in the terminal: llama-cli -hf felipecmarins/gemma3-4b-algebra4-gguf:Q4_0
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 felipecmarins/gemma3-4b-algebra4-gguf:Q4_0 # Run inference directly in the terminal: ./llama-cli -hf felipecmarins/gemma3-4b-algebra4-gguf:Q4_0
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 felipecmarins/gemma3-4b-algebra4-gguf:Q4_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf felipecmarins/gemma3-4b-algebra4-gguf:Q4_0
Use Docker
docker model run hf.co/felipecmarins/gemma3-4b-algebra4-gguf:Q4_0
- LM Studio
- Jan
- vLLM
How to use felipecmarins/gemma3-4b-algebra4-gguf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "felipecmarins/gemma3-4b-algebra4-gguf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "felipecmarins/gemma3-4b-algebra4-gguf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/felipecmarins/gemma3-4b-algebra4-gguf:Q4_0
- Ollama
How to use felipecmarins/gemma3-4b-algebra4-gguf with Ollama:
ollama run hf.co/felipecmarins/gemma3-4b-algebra4-gguf:Q4_0
- Unsloth Studio
How to use felipecmarins/gemma3-4b-algebra4-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for felipecmarins/gemma3-4b-algebra4-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for felipecmarins/gemma3-4b-algebra4-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for felipecmarins/gemma3-4b-algebra4-gguf to start chatting
- Docker Model Runner
How to use felipecmarins/gemma3-4b-algebra4-gguf with Docker Model Runner:
docker model run hf.co/felipecmarins/gemma3-4b-algebra4-gguf:Q4_0
- Lemonade
How to use felipecmarins/gemma3-4b-algebra4-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull felipecmarins/gemma3-4b-algebra4-gguf:Q4_0
Run and chat with the model
lemonade run user.gemma3-4b-algebra4-gguf-Q4_0
List all available models
lemonade list
gemma3-4b-algebra4-gguf — Q4_0 quantizado para celular
TL;DR — Gemma 3 4B Instruct fine-tunado em datasets de matemática (com foco em Álgebra Linear) e quantizado para 2.3 GB em GGUF Q4_0, pronto para rodar 100% offline em celular Android via PocketPal AI, MLC Chat, llama.cpp ou MediaPipe.
O que é este modelo
Modelo de raciocínio matemático em português e inglês, otimizado para resolver exercícios de Álgebra Linear IV (autovalores, autovetores, decomposições, espaços vetoriais, transformações lineares) diretamente no celular, sem internet.
- Base:
google/gemma-3-4b-it(4.3 B params, multimodal texto+imagem) - Quantização: GGUF Q4_0 com
imatrixcalibrado em ~300 exemplos do mix de math - Tamanho: 2.3 GB (era 8.6 GB em BF16 — compressão 3.7×)
- Footprint em RAM: ~3 GB ativo (cabe em A56, A36, Pixel 8a, qualquer Android com ≥ 6 GB)
- Performance (medida em CPU 12 vCPU L4 da GCP): prompt 38.6 t/s · decode 8.9 t/s
Como rodar — 3 caminhos
Caminho 1 · PocketPal AI (mais simples, recomendado)
- Instalar PocketPal AI da Play Store
- Abrir o app → "Models" → "+" → "Add from Hugging Face"
- Colar:
felipecmarins/gemma3-4b-algebra4-gguf - Aguardar download (~2.3 GB via WiFi · uma única vez)
- Selecionar o modelo, abrir um chat e mandar a foto/texto do exercício
Caminho 2 · llama.cpp (linha de comando)
# 1. Build
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp && cmake -B build -DLLAMA_CURL=OFF && cmake --build build -j
# 2. Download
hf download felipecmarins/gemma3-4b-algebra4-gguf algebra4-q4_0.gguf --local-dir ./
# 3. Rodar
./build/bin/llama-cli -m algebra4-q4_0.gguf \
-p "Encontre os autovalores de A = [[2,1],[1,2]]." \
-n 300 -t 8 -no-cnv
Caminho 3 · MediaPipe LLM Inference (Android Studio / app custom)
Pré-converter para LiteRT (.task) via ai-edge-torch ou usar uma das bibliotecas Android compatíveis com GGUF.
Como foi treinado
| Etapa | Detalhe |
|---|---|
| Base | google/gemma-3-4b-it (BF16, 8.6 GB) |
| Método | QLoRA — base quantizada em NF4 + LoRA rank 16 (α=32) |
| Target modules | q,k,v,o,gate,up,down (todos os lineares dos blocos) |
| Dataset | algebra4-mix (495 k train + 26 k eval — subset de 50 k usado) |
| Composição do mix | NuminaMath-CoT (35 %) · MetaMathQA (20 %) · MathWriting (15 %) · GSM8K (5 %) · im2latex (5 %) · curadoria pt-BR (3 %) · Geometry3K (2 %) |
| Hardware | NVIDIA L4 24 GB · g2-standard-12 · Google Cloud · Mumbai (asia-south1-b) |
| Duração | ~14 h · 1 epoch · batch efetivo 32 |
| Loss final | train_loss = 0.74 |
Como foi quantizado
- Merge do adapter LoRA na base BF16 → 8.1 GB safetensors
- Convert HF → GGUF F16 via
convert_hf_to_gguf.py→ 7.3 GB - Calibração imatrix com 300 chunks pt-BR de math → preserva qualidade nos pesos críticos
llama-quantize --imatrix … Q4_0→ 2.3 GB final (BPW 4.87)- Perplexity de validação: 2.04 (referência do base BF16: ~1.95)
Restrições e cuidados
- Não é um modelo de propósito geral. Otimizado para matemática (especialmente álgebra linear). Outras tarefas funcionam com qualidade menor.
- Multimodal sem mmproj: o vision encoder do Gemma 3 (SigLIP) não está embutido neste GGUF — para usar a entrada de imagem direto no celular, é preciso o arquivo
mmprojseparado (a publicar) ou o.taskLiteRT (em produção). - Não usar em produção médica/financeira/jurídica — é um projeto acadêmico de disciplina, ainda em avaliação.
Conjuntos relacionados
| Repo | Conteúdo |
|---|---|
felipecmarins/gemma3-4b-algebra4-merged |
Modelo merged BF16 (para fine-tune adicional) |
felipecmarins/gemma3-4b-algebra4-lora |
Apenas os adapters LoRA (65 MB) |
felipecmarins/gemma3-4b-algebra4-gguf |
Este repo — Q4_0 pronto para mobile |
Citação
Projeto acadêmico de Felipe Marins · Álgebra Linear IV · Maio/2026.
Licença
Gemma Terms of Use — herda da licença do modelo base.
- Downloads last month
- 269
4-bit