📈 FinCode-Reasoning-3B (Full Weights)

License Unsloth

FinCode-Reasoning-3B is an experimental, fine-tuned language model based on Qwen/Qwen2.5-3B-Instruct. Fine-tuned using Unsloth, it is engineered to generate executable Python code for quantitative financial modeling, accounting boundary checks, and algorithmic calculations.

ℹ️ Project Context: This is an open-source research initiative by coslinedev exploring domain-specific SFT for local LLMs. The model architecture delegates exact arithmetic logic to an isolated Python execution sandbox through structured code generation, bypassing direct LLM mental arithmetic hallucinations.


📁 Repository Structure

This repository contains the full merged model weights (~6.18 GB), ready for direct inference without requiring extra LoRA adapter layers:

  • model-00001-of-00002.safetensors & model-00002-of-00002.safetensors: Full model weight shards.
  • model.safetensors.index.json: Index mapping for sharded weight loading.
  • chat_template.jinja: Jinja chat formatting template for system/user prompt alignment.
  • tokenizer.json & tokenizer_config.json: Tokenizer assets inherited from Qwen2.5.
  • config.json & generation_config.json: Model architecture and generation configuration parameters.

🛠️ Usage Example

You can load and run this model locally or on Google Colab using Hugging Face transformers:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

MODEL_ID = "coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full"

tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    MODEL_ID,
    torch_dtype=torch.float16,
    device_map="auto"
)

prompt = "Write a Python function to calculate Double Declining Balance (DDB) depreciation with a salvage floor constraint."

messages = [
    {"role": "system", "content": "You are a financial engineering assistant. Output clean, executable Python code with explicit boundary constraint handling."},
    {"role": "user", "content": prompt}
]

formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([formatted_prompt], return_tensors="pt").to(model.device)

outputs = model.generate(**inputs, max_new_tokens=1024, temperature=0.2)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
⚙️ Key Design PrinciplesExecution Sandbox First: Direct numerical output is delegated to the Python interpreter executing the generated script, eliminating calculation hallucinations.Boundary Constraint Enforcer: Fine-tuned to enforce strict business limits within code logic (e.g., depreciation = min(book_value * ddb_rate, max(book_value - salvage, 0.0))).Hardware-Friendly Deployment: Compact 3B parameter footprint requires ~68 GB VRAM in float16, running smoothly on free-tier GPUs like Google Colab T4.📊 Preliminary Benchmark ($n=100$)Evaluated on 100 synthetic quantitative financial tasks (DDB depreciation schedules, Black-Scholes pricing, WACC calculations, Tax Shield bounds, DCF models).Both models were benchmarked under the exact same setup: output code was passed through an isolated Python execution sandbox to verify execution and mathematical correctness.ModelSetupCode Pass Rate (Pass@1)Valid Syntax RateAvg Generation Latency*FinCode-Reasoning-3B (Ours)Local + Python Sandbox98.0%99.5%0.85sQwen2.5-3B-Instruct (Base)Local + Python Sandbox82.0%85.0%0.82s*Inference latency measured on a free-tier Google Colab T4 GPU (float16 precision). Does not include sandbox execution overhead.⚠️ Known Limitations & DisclaimersSample Size Noise: Evaluated on $n=100$ tasks, carrying an estimated statistical error margin of $\pm 4\%$.Interpreter Dependency: The model generates code logic; guaranteed mathematical execution requires an active Python sandbox environment.Out-of-Distribution (OOD) Testing: Test tasks share parametric generator logic with the training set. A fully independent, held-out evaluation dataset is planned for future iterations.📬 Feedback & ContactIf you spot technical inaccuracies, unexpected code generation logic, or have ideas for improvement, feel free to contribute!Hugging Face Discussions: Open a thread in the Community tab of this repository.Pull Requests: PRs improving configuration files, documentation, or evaluation scripts are always welcome.📜 LicenseLicensed under the Apache 2.0 License, aligning with base Qwen2.5 model licensing.
Downloads last month
885
Safetensors
Model size
3B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full

Base model

Qwen/Qwen2.5-3B
Finetuned
(1509)
this model