Instructions to use coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full") model = AutoModelForCausalLM.from_pretrained("coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full
- SGLang
How to use coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full 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 coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full 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 coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full", max_seq_length=2048, ) - Docker Model Runner
How to use coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full with Docker Model Runner:
docker model run hf.co/coslinedev/Qwen2.5-3B-FinCode-Reasoning-Full
📈 FinCode-Reasoning-3B (Full Weights)
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 ~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.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