AIC-MCIT commited on
Commit
3537b67
·
verified ·
1 Parent(s): 7e7723f

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +171 -0
README.md ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - ar
5
+ - en
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - text-generation
9
+ - pytorch
10
+ - transformers
11
+ - vllm
12
+ - causal-lm
13
+ - depth-extension
14
+ - arabic
15
+ - english
16
+ - Karnak-6B-v1.0
17
+ - qwen
18
+ base_model: Qwen/Qwen3-4B-Instruct-2507
19
+ model_name: Karnak-6B-v1.0
20
+ parameters: 6B
21
+ inference: false
22
+ ---
23
+
24
+ # Karnak-6B-v1.0 : Enhanced Arabic–English Large Language Model
25
+ Karnak-6B-v1.0 is a powerful AI model that works in both Arabic and English, with extra improvements that make it especially strong in Arabic and more natural in the way it writes and responds. It was built by taking an existing model and improving it through more training, so it can understand instructions better, handle longer text, and give more reliable answers. This makes it useful for everyday tasks like answering questions, explaining topics, writing content, or helping with work and research. It can also process long pieces of text, which is helpful for documents and extended conversations. A big advantage is that it is not locked to an online service only, since you can download it, run it locally on your own machine or servers, and even fine-tune it for your own specific use case.
26
+
27
+ ## Model Summary
28
+
29
+ **Karnak-6B-v1.0 ** is a depth-extended causal language model optimized for **Arabic and English** generation. It is built on top of **Qwen/Qwen3-4B-Instruct-2507**, featuring architectural depth extension and a tokenizer specifically optimized for Arabic to improve fluency and efficiency.
30
+
31
+ Karnak-6B-v1.0 was trained using **high-quality, filtered data** through a rigorous pipeline to enhance overall instruction-following capabilities, factuality, and robustness.
32
+
33
+ ## Key Features
34
+
35
+ - **Depth Extension (~6B):** Expanded depth to increase reasoning capacity and improve long-range dependency modeling.
36
+ - **Arabic-Optimized Tokenizer:** Improved Arabic tokenization efficiency, resulting in reduced token fragmentation and higher-quality generation.
37
+ - **Multi-Stage Training:** The model evolved through: Pre-trained weights → Depth Extension → Continued Pre-training → SFT (Supervised Fine-Tuning).
38
+ - **Extended Context Window:** Designed for long-context usage with a **safe context range up to 20K tokens** (recommended to stay within this limit for optimal stability).
39
+
40
+ ## Model Details
41
+
42
+ - **Model Name:** Karnak-6B-v1.0
43
+ - **Base Model:** Qwen/Qwen3-4B-Instruct-2507
44
+ - **Parameter Count:** ~6B (Depth-Extended)
45
+ - **Languages:** Arabic, English
46
+ - **Training:** High-quality filtered data + Multi-stage pipeline (Continued pre-training + SFT)
47
+ - **Safe Context Range:** Up to **20,000 tokens**
48
+
49
+ ---
50
+
51
+ ## Usage
52
+
53
+ ### 1) Hugging Face Transformers
54
+
55
+ To use Karnak-6B-v1.0 with the standard Transformers library, ensure you have the latest version installed.
56
+
57
+ ```bash
58
+ pip install -U "transformers>=4.40.0" torch accelerate
59
+ ```
60
+
61
+ Python Code Example (Chat Template):
62
+
63
+ ```python
64
+ import torch
65
+ from transformers import AutoModelForCausalLM, AutoTokenizer
66
+
67
+ model_id = "Applied-Innovation-Center/Karnak-6B-v1.0 "
68
+
69
+ # Load tokenizer and model
70
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
71
+ model = AutoModelForCausalLM.from_pretrained(
72
+ model_id,
73
+ device_map="auto",
74
+ torch_dtype=torch.bfloat16,
75
+ trust_remote_code=True,
76
+ )
77
+
78
+ # Prepare Input
79
+ prompt = "اشرح لي نظرية النسبية بشكل مبسط."
80
+ messages = [
81
+ {"role": "system", "content": "You are a helpful assistant."},
82
+ {"role": "user", "content": prompt},
83
+ ]
84
+
85
+ # Apply chat template
86
+ text = tokenizer.apply_chat_template(
87
+ messages,
88
+ tokenize=False,
89
+ add_generation_prompt=True,
90
+ )
91
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
92
+
93
+ # Generate
94
+ generated_ids = model.generate(
95
+ **model_inputs,
96
+ max_new_tokens=512,
97
+ temperature=0.7,
98
+ top_p=0.9,
99
+ )
100
+
101
+ # Decode output (removing the prompt tokens)
102
+ generated_ids = generated_ids[:, model_inputs.input_ids.shape[1]:]
103
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
104
+ print(response)
105
+ ```
106
+
107
+ 2) vLLM (Recommended for Production)
108
+ Karnak-6B-v1.0 is compatible with vLLM for high-throughput inference.
109
+
110
+ Installation:
111
+
112
+ ```bash
113
+
114
+ pip install -U vllm
115
+ ```
116
+
117
+ Offline Inference:
118
+
119
+ ```python
120
+
121
+ from vllm import LLM, SamplingParams
122
+
123
+ model_id = "Applied-Innovation-Center/Karnak-6B-v1.0 "
124
+
125
+ # Initialize the model
126
+ llm = LLM(
127
+ model=model_id,
128
+ trust_remote_code=True,
129
+ max_model_len=20000, # Safe context range
130
+ tensor_parallel_size=1, # Adjust based on available GPUs
131
+ )
132
+
133
+ # Set sampling parameters
134
+ sampling_params = SamplingParams(
135
+ temperature=0.7,
136
+ top_p=0.9,
137
+ max_tokens=512,
138
+ )
139
+
140
+ # Generate
141
+ prompts = ["ما هي عاصمة مصر؟"]
142
+ outputs = llm.generate(prompts, sampling_params)
143
+
144
+ for o in outputs:
145
+ print(f"Prompt: {o.prompt}")
146
+ print(f"Generated: {o.outputs[0].text}")
147
+ ```
148
+
149
+ Server Mode (OpenAI-Compatible API):
150
+
151
+ You can serve the model as an API compatible with OpenAI clients:
152
+
153
+ ```bash
154
+
155
+ vllm serve "Applied-Innovation-Center/Karnak-6B-v1.0 " \
156
+ --trust-remote-code \
157
+ --dtype bfloat16 \
158
+ --port 8000
159
+ ```
160
+
161
+ Citation
162
+ If you use this model in your research or application, please cite it as follows:
163
+
164
+ ```bibtex
165
+ @misc{Karnak-6B-v1.0 -6B,
166
+ title={Karnak-6B-v1.0 : A Depth-Extended Arabic-English LLM},
167
+ year={2026},
168
+ publisher={Applied Innovation Center},
169
+ howpublished={\url{[https://huggingface.co/Applied-Innovation-Center/Karnak-6B-v1.0 ](https://huggingface.co/Applied-Innovation-Center/Karnak-6B-v1.0 )}}
170
+ }
171
+ ```