Instructions to use kiel2/kiel-2-codex with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use kiel2/kiel-2-codex with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("kiel2/kiel-2-codex") model = PeftModel.from_pretrained(base_model, "kiel2/kiel-2-codex") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Desktop
Update README.md
Browse files
README.md
CHANGED
|
@@ -3,9 +3,12 @@ license: mit
|
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
tags:
|
|
|
|
| 6 |
- vision-language
|
| 7 |
-
-
|
| 8 |
- quantization
|
|
|
|
|
|
|
| 9 |
- multimodal
|
| 10 |
- kielgen-codex
|
| 11 |
- image-understanding
|
|
@@ -13,68 +16,88 @@ tags:
|
|
| 13 |
base_model: Qwen/Qwen3-VL-4B
|
| 14 |
---
|
| 15 |
|
| 16 |
-
# KielGen-Codex
|
| 17 |
|
| 18 |
-
`KielGen-Codex` is a fine-tuned multimodal vision-language model (`Qwen3VLForConditionalGeneration`) optimized for advanced visual understanding and generation pipelines. This repository contains the
|
| 19 |
|
| 20 |
---
|
| 21 |
|
| 22 |
-
## 📁
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
| 27 |
-
|
|
| 28 |
-
| `
|
|
|
|
| 29 |
|
| 30 |
---
|
| 31 |
|
| 32 |
## 🛠️ Model Architecture & Technical Specs
|
| 33 |
|
| 34 |
-
* **Base Architecture**: Qwen3-VL (
|
| 35 |
-
* **
|
| 36 |
-
* **
|
| 37 |
-
* **Supported Modalties**: Text & Vision
|
| 38 |
|
| 39 |
---
|
| 40 |
|
| 41 |
## 🚀 Quickstart Usage
|
| 42 |
|
| 43 |
-
You can run this model directly using `
|
| 44 |
-
|
| 45 |
-
### 1. Running with `llama.cpp` (CLI)
|
| 46 |
-
Clone and build `llama.cpp`, then run inference with the quantized GGUF model:
|
| 47 |
|
|
|
|
|
|
|
| 48 |
```bash
|
| 49 |
-
|
| 50 |
-
git clone [https://github.com/ggerganov/llama.cpp.git](https://github.com/ggerganov/llama.cpp.git)
|
| 51 |
-
cd llama.cpp
|
| 52 |
-
cmake -B build -S . && cmake --build build --config Release -j$(nproc)
|
| 53 |
-
|
| 54 |
-
# Run interactive inference (adjust paths as needed)
|
| 55 |
-
./build/bin/llama-cli -m ../KielGen-Codex-Q4_K_M.gguf \
|
| 56 |
-
--prompt "Describe the uploaded image:" \
|
| 57 |
-
--image path_to_image.jpg \
|
| 58 |
-
-n 512
|
| 59 |
-
```
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
If you are loading the GGUF model using Python bindings (such as llama-cpp-python):
|
| 64 |
|
| 65 |
Python
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
#
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
)
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
tags:
|
| 6 |
+
- qwen3-vl
|
| 7 |
- vision-language
|
| 8 |
+
- safetensors
|
| 9 |
- quantization
|
| 10 |
+
- 4-bit
|
| 11 |
+
- bitsandbytes
|
| 12 |
- multimodal
|
| 13 |
- kielgen-codex
|
| 14 |
- image-understanding
|
|
|
|
| 16 |
base_model: Qwen/Qwen3-VL-4B
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# KielGen-Codex (4-Bit Unified)
|
| 20 |
|
| 21 |
+
`KielGen-Codex` is a fine-tuned multimodal vision-language model (`Qwen3VLForConditionalGeneration`) optimized for advanced visual understanding, spatial perception, and text generation pipelines. This repository contains the unified 4-bit quantized SafeTensors weights, compressed using `bitsandbytes` to provide efficient local and cloud deployment without sacrificing performance.
|
| 22 |
|
| 23 |
---
|
| 24 |
|
| 25 |
+
## 📁 Model Overview & Files
|
| 26 |
|
| 27 |
+
This repository uses a single unified folder structure containing standard SafeTensors weights configured for native 4-bit execution. Both text generation and vision encoding capabilities are fully integrated into the weight files.
|
| 28 |
+
|
| 29 |
+
| Component / Format | Quantization | Description |
|
| 30 |
+
| :--- | :--- | :--- |
|
| 31 |
+
| `model.safetensors` (Sharded/Unified) | 4-bit (`nf4`) | Combined text backbone and vision encoder compressed via `bitsandbytes`. |
|
| 32 |
+
| `config.json` / Processor files | FP16 / Config | Native configuration and processor files for Hugging Face `transformers`. |
|
| 33 |
|
| 34 |
---
|
| 35 |
|
| 36 |
## 🛠️ Model Architecture & Technical Specs
|
| 37 |
|
| 38 |
+
* **Base Architecture**: Qwen3-VL (`Qwen3VLForConditionalGeneration`)
|
| 39 |
+
* **Quantization Type**: 4-bit Normalized Float (`nf4`) with double quantization via `bitsandbytes`
|
| 40 |
+
* **Supported Modalities**: Unified Text & Vision (Image Understanding + Text Generation)
|
|
|
|
| 41 |
|
| 42 |
---
|
| 43 |
|
| 44 |
## 🚀 Quickstart Usage
|
| 45 |
|
| 46 |
+
You can load and run this model directly in Python using Hugging Face `transformers` and `bitsandbytes`.
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
### Prerequisites
|
| 49 |
+
Make sure you have the required libraries installed:
|
| 50 |
```bash
|
| 51 |
+
pip install -U transformers accelerate bitsandbytes torchvision
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
Python Integration Code
|
| 54 |
+
Here is how to load the model in 4-bit and perform both text generation and image understanding:
|
|
|
|
| 55 |
|
| 56 |
Python
|
| 57 |
+
import torch
|
| 58 |
+
from transformers import Qwen3VLForConditionalGeneration, AutoProcessor, BitsAndBytesConfig
|
| 59 |
+
|
| 60 |
+
# 1. Configure 4-bit quantization settings for both text and vision backbones
|
| 61 |
+
bnb_config = BitsAndBytesConfig(
|
| 62 |
+
load_in_4bit=True,
|
| 63 |
+
bnb_4bit_compute_dtype=torch.float16,
|
| 64 |
+
bnb_4bit_quant_type="nf4",
|
| 65 |
+
bnb_4bit_use_double_quant=True
|
| 66 |
+
)
|
| 67 |
+
```
|
| 68 |
|
| 69 |
+
# 2. Load the unified 4-bit model directly from your repository
|
| 70 |
+
```python
|
| 71 |
+
repo_id = "kiel2/KielGen-Codex"
|
| 72 |
+
|
| 73 |
+
print("Loading KielGen-Codex in 4-bit...")
|
| 74 |
+
model = Qwen3VLForConditionalGeneration.from_pretrained(
|
| 75 |
+
repo_id,
|
| 76 |
+
quantization_config=bnb_config,
|
| 77 |
+
device_map="auto",
|
| 78 |
+
trust_remote_code=True
|
| 79 |
)
|
| 80 |
|
| 81 |
+
processor = AutoProcessor.from_pretrained(repo_id, trust_remote_code=True)
|
| 82 |
+
|
| 83 |
+
# ==========================================
|
| 84 |
+
# TEST 1: Pure Text Generation
|
| 85 |
+
# ==========================================
|
| 86 |
+
text_messages = [
|
| 87 |
+
{"role": "system", "content": "You are a helpful AI engineering assistant."},
|
| 88 |
+
{"role": "user", "content": "Write a python function to reverse a string."}
|
| 89 |
+
]
|
| 90 |
+
|
| 91 |
+
text_input = processor.apply_chat_template(
|
| 92 |
+
text_messages,
|
| 93 |
+
tokenize=True,
|
| 94 |
+
add_generation_prompt=True,
|
| 95 |
+
return_tensors="pt"
|
| 96 |
+
).to("cuda")
|
| 97 |
+
|
| 98 |
+
generated_ids = model.generate(**text_input, max_new_tokens=150)
|
| 99 |
+
print("--- Text Generation Output ---")
|
| 100 |
+
print(processor.batch_decode(generated_ids, skip_special_tokens=True)[0])
|
| 101 |
+
```
|
| 102 |
+
⚙️ Optimization Details
|
| 103 |
+
The model weights were processed from the unquantized directory using bitsandbytes 4-bit nf4 compression. This maps both the vision transformer encoder layers and the primary language transformer blocks into a memory-efficient footprint while retaining full multimodal capability inside a standard SafeTensors ecosystem.
|