Text Generation
Transformers
Safetensors
English
qwen2
finops
aws
terraform
cdk
cloudformation
iac
qlora
unsloth
conversational
text-generation-inference
Instructions to use ccortezb/FinoCode-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ccortezb/FinoCode-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ccortezb/FinoCode-7B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ccortezb/FinoCode-7B") model = AutoModelForCausalLM.from_pretrained("ccortezb/FinoCode-7B", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ccortezb/FinoCode-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ccortezb/FinoCode-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ccortezb/FinoCode-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ccortezb/FinoCode-7B
- SGLang
How to use ccortezb/FinoCode-7B 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 "ccortezb/FinoCode-7B" \ --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": "ccortezb/FinoCode-7B", "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 "ccortezb/FinoCode-7B" \ --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": "ccortezb/FinoCode-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use ccortezb/FinoCode-7B with Docker Model Runner:
docker model run hf.co/ccortezb/FinoCode-7B
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
|
| 4 |
+
tags:
|
| 5 |
+
- finops
|
| 6 |
+
- aws
|
| 7 |
+
- terraform
|
| 8 |
+
- cdk
|
| 9 |
+
- cloudformation
|
| 10 |
+
- iac
|
| 11 |
+
- qlora
|
| 12 |
+
- unsloth
|
| 13 |
+
language:
|
| 14 |
+
- en
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
library_name: transformers
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# FinoCode-7B β The IaC Specialist of the FinOptix family
|
| 20 |
+
|
| 21 |
+
**FinoCode-7B** is the infrastructure-as-code specialist of the [FinOptix model family](https://huggingface.co/ccortezb). Fine-tuned on **Qwen 2.5 Coder 7B**, it audits and generates **Terraform, AWS CDK (TypeScript & Python), and CloudFormation** with FinOps best practices baked in β rightsizing, mandatory tags, Graviton, lifecycle policies, encryption.
|
| 22 |
+
|
| 23 |
+
Where **[FinOptix-14B](https://huggingface.co/ccortezb/FinOptix-14B-v2)** is the full FinOps architect (cost analysis, architecture graph, dbt, incident triage), **FinoCode-7B writes and fixes the actual IaC code** β it's built on a *Coder* base precisely for that.
|
| 24 |
+
|
| 25 |
+
- **16-bit model:** `ccortezb/FinoCode-7B` (this repo)
|
| 26 |
+
- **GGUF (Ollama / llama.cpp):** [`ccortezb/FinoCode-7B-GGUF`](https://huggingface.co/ccortezb/FinoCode-7B-GGUF) β Q4_K_M (~4.7GB) and Q6_K (~6.3GB)
|
| 27 |
+
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
## What it does
|
| 31 |
+
|
| 32 |
+
| Capability | Detail |
|
| 33 |
+
|-----------|--------|
|
| 34 |
+
| **Terraform** | Audit + refactor + generation (rightsizing, Graviton, gp2βgp3, S3 lifecycle, RDS, tags) |
|
| 35 |
+
| **AWS CDK (TypeScript)** | Audit constructs + generate cost-optimal ones (ARM64, log retention, PAY_PER_REQUEST) |
|
| 36 |
+
| **AWS CDK (Python)** | Same, Python-native (EC2 Graviton, S3 lifecycle, tags) |
|
| 37 |
+
| **CloudFormation** | YAML audit + corrected templates (EC2, S3, Lambda, RDS, ECS Fargate, SQS DLQ) |
|
| 38 |
+
|
| 39 |
+
Every recommendation follows the FinOps framework (Inform β Optimize β Operate) and outputs valid, properly-indented code.
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## Training
|
| 44 |
+
|
| 45 |
+
| Parameter | Value |
|
| 46 |
+
|-----------|-------|
|
| 47 |
+
| Base model | `Qwen/Qwen2.5-Coder-7B-Instruct` (4-bit via Unsloth) |
|
| 48 |
+
| Method | QLoRA (r=16, Ξ±=32, dropout=0.05) |
|
| 49 |
+
| Framework | Unsloth + TRL (SFTTrainer) |
|
| 50 |
+
| Dataset | **400 examples** IaC-heavy (200 Terraform + 100 CloudFormation + 60 CDK TS + 40 CDK Python) |
|
| 51 |
+
| Hardware | Modal A100-80GB |
|
| 52 |
+
| Duration | ~3 minutes, 3 epochs, 75 steps |
|
| 53 |
+
| Final train loss | 0.47 |
|
| 54 |
+
| Cost | ~$0.30 |
|
| 55 |
+
|
| 56 |
+
The dataset was built with deterministic generators faithful to real-world IaC patterns β 100% of examples contain valid code blocks.
|
| 57 |
+
|
| 58 |
+
---
|
| 59 |
+
|
| 60 |
+
## Usage
|
| 61 |
+
|
| 62 |
+
### Transformers
|
| 63 |
+
|
| 64 |
+
```python
|
| 65 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 66 |
+
|
| 67 |
+
model = AutoModelForCausalLM.from_pretrained("ccortezb/FinoCode-7B", device_map="auto")
|
| 68 |
+
tok = AutoTokenizer.from_pretrained("ccortezb/FinoCode-7B")
|
| 69 |
+
|
| 70 |
+
messages = [
|
| 71 |
+
{"role": "system", "content": "You are FinoCode-7B, the IaC specialist of the FinOptix family. Output valid code."},
|
| 72 |
+
{"role": "user", "content": "Generate a cost-optimal AWS CDK (TypeScript) DynamoDB table with on-demand billing and encryption."},
|
| 73 |
+
]
|
| 74 |
+
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
| 75 |
+
out = model.generate(inputs, max_new_tokens=350, do_sample=False, repetition_penalty=1.1)
|
| 76 |
+
print(tok.decode(out[0][inputs.shape[1]:], skip_special_tokens=True))
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
### Ollama (GGUF)
|
| 80 |
+
|
| 81 |
+
```bash
|
| 82 |
+
ollama run hf.co/ccortezb/FinoCode-7B-GGUF:Q4_K_M
|
| 83 |
+
# higher fidelity:
|
| 84 |
+
ollama run hf.co/ccortezb/FinoCode-7B-GGUF:Q6_K
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
Requires ~5GB RAM/VRAM (Q4_K_M) or ~7GB (Q6_K) β runs comfortably on a laptop.
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## Example tasks
|
| 92 |
+
|
| 93 |
+
**CDK Python audit** β flags a `m5.4xlarge` with no tags, returns corrected Python with Graviton (`m6g`) + `Tags.of(...)`.
|
| 94 |
+
|
| 95 |
+
**CloudFormation audit** β flags missing tags + x86 instance, returns corrected YAML with Graviton (`m6g.large`) and a `Tags` block.
|
| 96 |
+
|
| 97 |
+
**Generation** β produces cost-optimal constructs: DynamoDB `PAY_PER_REQUEST`, S3 lifecycle (IA β Glacier β expire), Lambda on ARM64 with 2-week log retention, SQS with a dead-letter queue.
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
## The FinOptix family
|
| 102 |
+
|
| 103 |
+
| Model | Base | Specialty |
|
| 104 |
+
|-------|------|-----------|
|
| 105 |
+
| [FinOptix-14B v2](https://huggingface.co/ccortezb/FinOptix-14B-v2) | Qwen 2.5 14B | Full FinOps architect (cost, graph, dbt, incidents) |
|
| 106 |
+
| **FinoCode-7B** (this) | Qwen 2.5 Coder 7B | **IaC audit + generation** |
|
| 107 |
+
|
| 108 |
+
Use case: IDE copilot for IaC, PR review bot, CI pipeline IaC optimizer.
|
| 109 |
+
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
## Limitations
|
| 113 |
+
|
| 114 |
+
- Trained on synthetic data modeled after real patterns β no customer data.
|
| 115 |
+
- Generates and audits IaC; does not deploy or call live AWS APIs.
|
| 116 |
+
- Cost figures are illustrative unless real metrics are provided.
|
| 117 |
+
- v0.1 β Terraform + CDK (TS/Py) + CloudFormation. Pulumi / Terraform CDK / multi-cloud are future work.
|
| 118 |
+
|
| 119 |
+
## License
|
| 120 |
+
|
| 121 |
+
Apache-2.0. Built by **Carlos Cortez** β AWS Community Hero.
|
| 122 |
+
[LinkedIn](https://www.linkedin.com/in/carloscortezcloud) Β· [X](https://x.com/ccortezb) Β· [GitHub](https://github.com/ccortezb)
|