Text Generation
MLX
Safetensors
English
gemma4
gemma
finance
financial-reasoning
crypto
grpo
fin-r1
reasoning
conversational
Eval Results (legacy)
Instructions to use z0n3x/gemma-4-12b-fin-grpo-v4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use z0n3x/gemma-4-12b-fin-grpo-v4 with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("z0n3x/gemma-4-12b-fin-grpo-v4") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use z0n3x/gemma-4-12b-fin-grpo-v4 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "z0n3x/gemma-4-12b-fin-grpo-v4"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "z0n3x/gemma-4-12b-fin-grpo-v4" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use z0n3x/gemma-4-12b-fin-grpo-v4 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "z0n3x/gemma-4-12b-fin-grpo-v4"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "z0n3x/gemma-4-12b-fin-grpo-v4" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "z0n3x/gemma-4-12b-fin-grpo-v4", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use z0n3x/gemma-4-12b-fin-grpo-v4 with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "z0n3x/gemma-4-12b-fin-grpo-v4"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default z0n3x/gemma-4-12b-fin-grpo-v4
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use z0n3x/gemma-4-12b-fin-grpo-v4 with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "z0n3x/gemma-4-12b-fin-grpo-v4"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "z0n3x/gemma-4-12b-fin-grpo-v4" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
| license: gemma | |
| base_model: mlx-community/gemma-4-12B-it-bf16 | |
| base_model_relation: finetune | |
| library_name: mlx | |
| pipeline_tag: text-generation | |
| inference: false | |
| language: | |
| - en | |
| metrics: | |
| - accuracy | |
| tags: | |
| - mlx | |
| - gemma | |
| - gemma4 | |
| - finance | |
| - financial-reasoning | |
| - crypto | |
| - grpo | |
| - fin-r1 | |
| - reasoning | |
| model-index: | |
| - name: gemma-4-12b-fin-grpo-v4 | |
| results: | |
| - task: | |
| type: text-generation | |
| name: Financial Reasoning (FinQA) | |
| dataset: | |
| type: ChanceFocus/flare-finqa | |
| name: FinQA — FLARE test (N=100) | |
| metrics: | |
| - type: accuracy | |
| value: 64.0 | |
| name: accuracy | |
| - task: | |
| type: text-generation | |
| name: Conversational Financial Reasoning (ConvFinQA) | |
| dataset: | |
| type: ChanceFocus/flare-convfinqa | |
| name: ConvFinQA — FLARE test (N=100) | |
| metrics: | |
| - type: accuracy | |
| value: 60.0 | |
| name: accuracy | |
| # gemma-4-12b-fin-grpo-v4 | |
| A **financial-reasoning + crypto** model that reproduces the **Fin-R1** recipe | |
| (*[Fin-R1](https://arxiv.org/abs/2503.16252)*: SFT → GRPO on financial chain-of-thought data) | |
| on a **larger base** — **Gemma 4 12B-it** — trained **locally on Apple Silicon** with | |
| [`mlx-lm-lora`](https://github.com/Goekdeniz-Guelmez/mlx-lm-lora). | |
| It reasons step-by-step inside `<think> </think>` tags, then gives a clear final answer. | |
| Coverage spans the whole investment sector — fiat markets, equities, derivatives, macro, | |
| accounting, and **crypto / DeFi / trading (SMC, ICT, FVG, etc.)**. | |
| - **Base model:** [`mlx-community/gemma-4-12B-it-bf16`](https://huggingface.co/mlx-community/gemma-4-12B-it-bf16) (← `google/gemma-4-12b-it`) | |
| - **Method:** LoRA SFT (rank 16) → GRPO (Fin-R1 stage 2), then fused to full bf16 weights | |
| - **Params / dtype:** ~12B, bf16 (~22 GB) | |
| - **Framework:** MLX (`mlx-lm`). `model_type: gemma4`. | |
| ## Training recipe | |
| | Stage | Data | Notes | | |
| |-------|------|-------| | |
| | **SFT (v4)** | ~30k examples: financial CoT (Fino1 FinQA+CoT, fin-alpaca-r1, Finance-Instruct, TAT-QA CoT), crypto trading, an industry/security corpus, and FalseReject de-refusal | broad + balanced | | |
| | **GRPO** | 12k verifiable items (FinQA-style numerics + crypto BUY/HOLD/SELL labels) | rewards: `think_format` + `numeric_or_label_accuracy`, 200 iters | | |
| ## Evaluation | |
| FinQA / ConvFinQA accuracy (N=100, FLARE test split): | |
| | Model | FinQA | ConvFinQA | | |
| |-------|:-----:|:---------:| | |
| | base `gemma-4-12B-it` | 27.5% | — (often refuses) | | |
| | SFT v4 | 61% | 59% | | |
| | **this model (SFT→GRPO v4)** | **64%** | **60%** | | |
| | *Fin-R1 (paper reference)* | *76%* | *85%* | | |
| GRPO added **+3 / +1** over SFT, matching the paper's reported lift. De-refusal eval: | |
| 100% of legitimate finance/investment questions answered, illegitimate ones still refused. | |
| > The model is intentionally **broad** rather than benchmark-maximized: it trades a few | |
| > FinQA points versus a narrow FinQA-tuned model (Fin-R1) for crypto/trading coverage that | |
| > Fin-R1 does not have (e.g. Fin-R1 does not know SMC/ICT terms like *Fair Value Gap*). | |
| ## Usage (MLX) | |
| ```python | |
| from mlx_lm import load, generate | |
| model, tokenizer = load("z0n3x/gemma-4-12b-fin-grpo-v4") | |
| system = ("You are a financial reasoning assistant covering the whole investment " | |
| "sector — fiat markets, equities, derivatives, macro, accounting, and " | |
| "crypto/DeFi. Reason step by step inside <think> </think> tags, then give " | |
| "a clear, correct final answer.") | |
| messages = [ | |
| {"role": "system", "content": system}, | |
| {"role": "user", "content": "What is a Fair Value Gap (FVG) and how do traders use it?"}, | |
| ] | |
| prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True) | |
| print(generate(model, tokenizer, prompt=prompt, max_tokens=800)) | |
| ``` | |
| ### Thinking / reasoning | |
| The chat template **defaults to a reasoning system prompt**, so the model produces | |
| `<think> … </think>` then the answer **out of the box** — you don't need to pass a system | |
| message (pass your own to override it). The reasoning markers are `<think>` / `</think>` | |
| (this model was trained on those tags, not Gemma's native `<|channel>thought` format). | |
| - **LM Studio:** set the reasoning / "thinking" section tags to `<think>` (start) and | |
| `</think>` (end) to fold the chain-of-thought into a collapsible block. | |
| - **Text-only:** the base Gemma 4 vision/audio weights were dropped during fine-tuning, so | |
| this checkpoint is **not multimodal** — by design (Fin-R1 is a text recipe). | |
| > **Note on loading:** these are brand-new Gemma 4 "unified" weights. With some `mlx-lm` | |
| > versions you may need a small load-time shim that (a) resolves `model_type: gemma4` and | |
| > (b) drops unused multimodal tensors. This is a **text-only** checkpoint. | |
| ## Limitations & disclosures | |
| - **Not financial advice.** Outputs are model-generated and can be wrong; verify numbers | |
| and do your own research before acting on any market view. | |
| - **De-refusal calibration.** Trained (with the FalseReject dataset) to answer legitimate | |
| finance/investment questions candidly instead of over-refusing. The boundary kept during | |
| training was **not** optimizing for fraud, money-laundering, or market-manipulation use. | |
| - **Includes a private corpus.** Part of the SFT mix is the author's own industry/security | |
| ("OAK") corpus; outputs may reflect its style/content. | |
| - **MLX checkpoint.** Built and tested with `mlx-lm`; not validated under `transformers`. | |
| ## License | |
| This is a derivative of Google **Gemma** and is distributed under the | |
| [**Gemma Terms of Use**](https://ai.google.dev/gemma/terms). By using these weights you | |
| agree to those terms and to Google's | |
| [Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy). | |
| ## Citation | |
| Built following the Fin-R1 recipe: | |
| ```bibtex | |
| @article{liu2025finr1, | |
| title={Fin-R1: A Large Language Model for Financial Reasoning through Reinforcement Learning}, | |
| author={Liu, Zhaowei and others}, | |
| journal={arXiv preprint arXiv:2503.16252}, | |
| year={2025} | |
| } | |
| ``` | |