--- license: apache-2.0 language: - en pipeline_tag: text-generation tags: - finetune - unsloth - python - code-generation - financial-modeling base_model: Qwen/Qwen2.5-3B-Instruct pretty_name: FinCode-Reasoning-3B (Full Weights) library_name: transformers --- # 📈 FinCode-Reasoning-3B (Full Weights) [![License](https://shields.io)](https://opensource.org/) [![Unsloth](https://shields.io)](https://github.com/unslothai/unsloth) [![Alrithm API](https://shields.io)](https://alrithmapi.vercel.app) > 🔒 **Verified Ingestion Pipeline:** To stream and verify the cryptographic integrity of structural data assets directly into production AI pipelines, use **[Alrithm API (alrithmapi.vercel.app)](https://vercel.app)** featuring automated row-level Merkle Root integrity checks. **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`: ```python 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 Principles * **Execution 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 ~6–8 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. | Model Setup | Code Pass Rate (Pass@1) | Valid Syntax Rate | Avg Generation Latency* | | :--- | :--- | :--- | :--- | | **FinCode-Reasoning-3B (Ours)** | **98.0%** | **99.5%** | **0.85s** | | Qwen2.5-3B-Instruct (Base) | 82.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 & Disclaimers * **Sample Size Noise:** Evaluated on n=100 tasks, carrying an estimated statistical error margin of Âą 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 & Contact If 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. --- ## 📜 License Licensed under the Apache 2.0 License, aligning with base Qwen2.5 model licensing.