kiel2 commited on
Commit
1902c0c
·
verified ·
1 Parent(s): 56117ac

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -43
README.md CHANGED
@@ -3,9 +3,12 @@ license: mit
3
  language:
4
  - en
5
  tags:
 
6
  - vision-language
7
- - gguf
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 official GGUF-formatted weights, compiled in both full-precision FP16 and optimized 4-bit (`Q4_K_M`) formats for fast, low-memory local deployment using `llama.cpp` or compatible runtimes.
19
 
20
  ---
21
 
22
- ## 📁 Available Model Files
23
 
24
- | Filename | Format / Quantization | Size | Description |
25
- | :--- | :--- | :--- | :--- |
26
- | `KielGen-Codex.safetensors` | SafeTensors (FP16) | ~7.67 GB | Original merged full-precision model weights in SafeTensors format. |
27
- | `KielGen-Codex_f16.gguf` | GGUF (FP16) | ~7.67 GB | Full-precision unquantized GGUF export preserving maximum native fidelity. |
28
- | `KielGen-Codex_q4_k_m.gguf` | GGUF (Q4_K_M) | ~2.38 GB | Optimized 4-bit medium quantization (~4.95 BPW), ideal for consumer hardware and edge setups. |
 
29
 
30
  ---
31
 
32
  ## 🛠️ Model Architecture & Technical Specs
33
 
34
- * **Base Architecture**: Qwen3-VL (Vision-Language)
35
- * **Transformer Layers**: 36 blocks (`blk.0` through `blk.35`)
36
- * **Embedding / Hidden Dimension**: 2560
37
- * **Supported Modalties**: Text & Vision
38
 
39
  ---
40
 
41
  ## 🚀 Quickstart Usage
42
 
43
- You can run this model directly using `llama.cpp` or compatible UI clients/backends.
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
- # Clone llama.cpp if you haven't already
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
- 2. Python Integration
62
- ```python
63
- If you are loading the GGUF model using Python bindings (such as llama-cpp-python):
64
 
65
  Python
66
- from llama_cpp import Llama
 
 
 
 
 
 
 
 
 
 
67
 
68
- # Initialize the model with the Q4_K_M GGUF file
69
- llm = Llama(
70
- model_path="KielGen-Codex-Q4_K_M.gguf",
71
- n_ctx=4096, # Context window size
72
- n_gpu_layers=-1, # Offload all layers to GPU if available
 
 
 
 
 
73
  )
74
 
75
- # Generate a response
76
- output = llm("Analyze the workflow in this code snippet:", max_tokens=256)
77
- print(output["choices"][0]["text"])
78
- ⚙️ Conversion & Quantization Details
79
- The model was exported from PyTorch (torch.float16) to GGUF format utilizing llama.cpp's conversion script, followed by medium-range mixed 4-bit Q4_K_M compression to optimize memory footprints without sacrificing task performance.
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.