farhan98ahzan commited on
Commit
6d7f659
·
verified ·
1 Parent(s): e39749c

Add model card with usage instructions and training details

Browse files
Files changed (1) hide show
  1. README.md +165 -164
README.md CHANGED
@@ -2,208 +2,209 @@
2
  base_model: Qwen/Qwen2.5-Coder-7B-Instruct
3
  library_name: peft
4
  pipeline_tag: text-generation
 
 
 
5
  tags:
6
  - base_model:adapter:Qwen/Qwen2.5-Coder-7B-Instruct
7
  - lora
8
  - sft
9
  - transformers
10
  - trl
 
 
 
 
11
  ---
12
 
13
- # Model Card for Model ID
14
 
15
- <!-- Provide a quick summary of what the model is/does. -->
16
 
 
17
 
 
18
 
19
- ## Model Details
20
-
21
- ### Model Description
22
-
23
- <!-- Provide a longer summary of what this model is. -->
24
-
25
-
26
-
27
- - **Developed by:** [More Information Needed]
28
- - **Funded by [optional]:** [More Information Needed]
29
- - **Shared by [optional]:** [More Information Needed]
30
- - **Model type:** [More Information Needed]
31
- - **Language(s) (NLP):** [More Information Needed]
32
- - **License:** [More Information Needed]
33
- - **Finetuned from model [optional]:** [More Information Needed]
34
-
35
- ### Model Sources [optional]
36
-
37
- <!-- Provide the basic links for the model. -->
38
-
39
- - **Repository:** [More Information Needed]
40
- - **Paper [optional]:** [More Information Needed]
41
- - **Demo [optional]:** [More Information Needed]
42
-
43
- ## Uses
44
-
45
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
46
-
47
- ### Direct Use
48
-
49
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
50
-
51
- [More Information Needed]
52
-
53
- ### Downstream Use [optional]
54
-
55
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
56
-
57
- [More Information Needed]
58
-
59
- ### Out-of-Scope Use
60
 
61
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
 
 
 
 
62
 
63
- [More Information Needed]
 
64
 
65
- ## Bias, Risks, and Limitations
 
 
 
 
 
66
 
67
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
68
-
69
- [More Information Needed]
70
-
71
- ### Recommendations
72
-
73
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
74
-
75
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
76
-
77
- ## How to Get Started with the Model
78
-
79
- Use the code below to get started with the model.
80
 
81
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  ## Training Details
84
 
85
  ### Training Data
86
 
87
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
88
-
89
- [More Information Needed]
90
-
91
- ### Training Procedure
92
-
93
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
94
-
95
- #### Preprocessing [optional]
96
-
97
- [More Information Needed]
98
-
99
 
100
- #### Training Hyperparameters
 
 
 
 
 
101
 
102
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
103
 
104
- #### Speeds, Sizes, Times [optional]
105
-
106
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
107
-
108
- [More Information Needed]
109
-
110
- ## Evaluation
111
 
112
- <!-- This section describes the evaluation protocols and provides the results. -->
 
 
 
 
 
113
 
114
- ### Testing Data, Factors & Metrics
115
-
116
- #### Testing Data
117
-
118
- <!-- This should link to a Dataset Card if possible. -->
119
-
120
- [More Information Needed]
121
-
122
- #### Factors
123
-
124
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
125
-
126
- [More Information Needed]
127
-
128
- #### Metrics
129
-
130
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
131
-
132
- [More Information Needed]
133
-
134
- ### Results
135
-
136
- [More Information Needed]
137
-
138
- #### Summary
139
-
140
-
141
-
142
- ## Model Examination [optional]
143
-
144
- <!-- Relevant interpretability work for the model goes here -->
145
-
146
- [More Information Needed]
147
-
148
- ## Environmental Impact
149
-
150
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
151
-
152
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
153
-
154
- - **Hardware Type:** [More Information Needed]
155
- - **Hours used:** [More Information Needed]
156
- - **Cloud Provider:** [More Information Needed]
157
- - **Compute Region:** [More Information Needed]
158
- - **Carbon Emitted:** [More Information Needed]
159
-
160
- ## Technical Specifications [optional]
161
-
162
- ### Model Architecture and Objective
163
 
164
- [More Information Needed]
 
 
 
 
 
 
 
 
165
 
166
  ### Compute Infrastructure
167
 
168
- [More Information Needed]
169
-
170
- #### Hardware
171
-
172
- [More Information Needed]
173
-
174
- #### Software
175
 
176
- [More Information Needed]
177
-
178
- ## Citation [optional]
179
-
180
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
181
-
182
- **BibTeX:**
183
-
184
- [More Information Needed]
185
-
186
- **APA:**
187
-
188
- [More Information Needed]
189
-
190
- ## Glossary [optional]
191
 
192
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
193
 
194
- [More Information Needed]
 
 
 
 
195
 
196
- ## More Information [optional]
197
 
198
- [More Information Needed]
199
 
200
- ## Model Card Authors [optional]
 
 
 
201
 
202
- [More Information Needed]
203
 
204
- ## Model Card Contact
 
 
 
 
 
 
 
 
205
 
206
- [More Information Needed]
207
- ### Framework versions
208
 
209
- - PEFT 0.18.1
 
 
 
 
 
2
  base_model: Qwen/Qwen2.5-Coder-7B-Instruct
3
  library_name: peft
4
  pipeline_tag: text-generation
5
+ license: apache-2.0
6
+ language:
7
+ - en
8
  tags:
9
  - base_model:adapter:Qwen/Qwen2.5-Coder-7B-Instruct
10
  - lora
11
  - sft
12
  - transformers
13
  - trl
14
+ - jac
15
+ - jaclang
16
+ - code-generation
17
+ - data-spatial-programming
18
  ---
19
 
20
+ # Jac Coder 7B LoRA
21
 
22
+ A LoRA adapter fine-tuned on the [Jac programming language](https://www.jac-lang.org/) for code generation, built on top of [Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct).
23
 
24
+ Jac is a data-spatial programming language featuring walkers, nodes, edges, and graph-based computation. This adapter teaches the base model to generate idiomatic Jac backend code including node/edge definitions, walker APIs, graph traversals, and ability implementations.
25
 
26
+ ## Example Outputs
27
 
28
+ **Prompt:** "Write a Jac node for a User with name, email, and age fields"
29
+ ```jac
30
+ node User {
31
+ has name: str;
32
+ has email: str;
33
+ has age: int = 0;
34
+ }
35
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ **Prompt:** "Write a Jac walker for a REST API endpoint that creates a new todo item"
38
+ ```jac
39
+ node Todo {
40
+ has title: str;
41
+ has done: bool = False;
42
+ }
43
 
44
+ walker CreateTodo {
45
+ has title: str;
46
 
47
+ can create with Root entry {
48
+ here ++> Todo(title=self.title);
49
+ report [-->];
50
+ }
51
+ }
52
+ ```
53
 
54
+ ## Model Details
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
+ - **Base model:** Qwen/Qwen2.5-Coder-7B-Instruct
57
+ - **Adapter type:** LoRA (rank 64, alpha 128)
58
+ - **Trainable params:** 161,480,704 / 7,777,097,216 (2.08%)
59
+ - **Target modules:** q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
60
+ - **Developed by:** [farhan98ahzan](https://huggingface.co/farhan98ahzan)
61
+ - **License:** Apache 2.0
62
+
63
+ ## How to Use
64
+
65
+ ### With PEFT (recommended)
66
+
67
+ ```python
68
+ import torch
69
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
70
+ from peft import PeftModel
71
+
72
+ BASE_MODEL = "Qwen/Qwen2.5-Coder-7B-Instruct"
73
+ ADAPTER = "farhan98ahzan/jac-coder-7b-lora"
74
+
75
+ tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL, trust_remote_code=True)
76
+
77
+ # Load base model in 4-bit (for low VRAM)
78
+ bnb_config = BitsAndBytesConfig(
79
+ load_in_4bit=True,
80
+ bnb_4bit_quant_type="nf4",
81
+ bnb_4bit_compute_dtype=torch.bfloat16,
82
+ )
83
+ model = AutoModelForCausalLM.from_pretrained(
84
+ BASE_MODEL,
85
+ quantization_config=bnb_config,
86
+ device_map="auto",
87
+ trust_remote_code=True,
88
+ )
89
+
90
+ # Apply LoRA adapter
91
+ model = PeftModel.from_pretrained(model, ADAPTER)
92
+ model.eval()
93
+
94
+ # Generate
95
+ messages = [
96
+ {"role": "system", "content": "You are an expert Jac programming language assistant."},
97
+ {"role": "user", "content": "Write a Jac walker that lists all users"},
98
+ ]
99
+ text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
100
+ inputs = tokenizer(text, return_tensors="pt").to(model.device)
101
+
102
+ with torch.no_grad():
103
+ outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, top_p=0.9, do_sample=True)
104
+
105
+ generated = outputs[0][inputs["input_ids"].shape[1]:]
106
+ print(tokenizer.decode(generated, skip_special_tokens=True))
107
+ ```
108
+
109
+ ### Merging the adapter (for full model export)
110
+
111
+ To merge LoRA weights into the base model, load the base model in **bf16 (not 4-bit)** to avoid rounding errors:
112
+
113
+ ```python
114
+ from transformers import AutoModelForCausalLM
115
+ from peft import PeftModel
116
+
117
+ base = AutoModelForCausalLM.from_pretrained(
118
+ "Qwen/Qwen2.5-Coder-7B-Instruct",
119
+ torch_dtype=torch.bfloat16,
120
+ device_map="auto",
121
+ trust_remote_code=True,
122
+ )
123
+ model = PeftModel.from_pretrained(base, "farhan98ahzan/jac-coder-7b-lora")
124
+ merged = model.merge_and_unload()
125
+ merged.save_pretrained("jac-coder-7b-merged")
126
+ ```
127
+
128
+ > **Warning:** Do not merge into a 4-bit quantized base model -- this produces corrupted weights and gibberish output.
129
 
130
  ## Training Details
131
 
132
  ### Training Data
133
 
134
+ The adapter was trained on 3,200 curated Jac code samples sourced from:
 
 
 
 
 
 
 
 
 
 
 
135
 
136
+ | Source | Description |
137
+ |---|---|
138
+ | jaseci/jaseci | Core Jac compiler repo -- examples, tests, reference implementations |
139
+ | BeaconLens | Full-stack Jac application (review analysis platform) |
140
+ | jac-visual-builder | Visual graph schema builder in Jac |
141
+ | Jac documentation | 936 code examples extracted from official docs |
142
 
143
+ All source files were validated with `jac check --parse_only` for syntactic correctness. Only backend Jac code was included (frontend/UI files filtered out).
144
 
145
+ **Dataset composition:**
 
 
 
 
 
 
146
 
147
+ | Type | Count | Description |
148
+ |---|---|---|
149
+ | full_file | 800 | Complete valid Jac source files |
150
+ | construct_completion | 800 | Walker/node/ability signature to body completion |
151
+ | completion | 800 | Import + partial code to complete the rest |
152
+ | doc_example | 800 | Documentation description to Jac code |
153
 
154
+ ### Training Procedure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
 
156
+ - **Method:** QLoRA (4-bit NF4 quantization + LoRA)
157
+ - **Framework:** Hugging Face TRL (SFTTrainer)
158
+ - **Epochs:** 1
159
+ - **Batch size:** 2 per device, gradient accumulation 4 (effective batch 8)
160
+ - **Learning rate:** 2e-4 with cosine schedule
161
+ - **Max sequence length:** 512 tokens
162
+ - **Precision:** bf16
163
+ - **Gradient checkpointing:** enabled
164
+ - **Packing:** disabled (required for correctness without flash attention)
165
 
166
  ### Compute Infrastructure
167
 
168
+ - **Hardware:** 2x NVIDIA Tesla T4 (15.6 GB VRAM each)
169
+ - **Platform:** Kaggle Notebooks (free tier)
170
+ - **Training time:** ~5.5 hours
171
+ - **Total steps:** 380
 
 
 
172
 
173
+ ## Evaluation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
+ Qualitative evaluation on held-out prompts:
176
 
177
+ | Prompt | Result |
178
+ |---|---|
179
+ | Node definition with typed fields | Correct `node` with `has` fields and defaults |
180
+ | Walker with graph traversal | Correct `walker` with `[-->]` traversal and `report` |
181
+ | REST API endpoint walker | Correct walker with `Root entry`, node creation (`++>`), and response |
182
 
183
+ The model generates syntactically valid Jac code with proper use of language-specific constructs: `node`, `walker`, `has`, `can`, `with ... entry`, `++>`, `[-->]`, `report`, and `disengage`.
184
 
185
+ ## Limitations
186
 
187
+ - Trained on 1 epoch of 3,200 samples -- may not cover all Jac patterns
188
+ - Max training sequence length was 512 tokens -- longer code may be truncated
189
+ - Backend-only -- does not generate Jac frontend/UI code (`.cl.jac`)
190
+ - Based on Jac language version 0.13.5 -- syntax may differ in newer versions
191
 
192
+ ## Citation
193
 
194
+ ```bibtex
195
+ @misc{jac-coder-7b-lora,
196
+ title={Jac Coder 7B LoRA},
197
+ author={Farhan Ahzan},
198
+ year={2026},
199
+ publisher={HuggingFace},
200
+ url={https://huggingface.co/farhan98ahzan/jac-coder-7b-lora}
201
+ }
202
+ ```
203
 
204
+ ### Framework Versions
 
205
 
206
+ - PEFT 0.18.1
207
+ - Transformers 4.51.3
208
+ - TRL 0.18.1
209
+ - PyTorch 2.6.0
210
+ - BitsAndBytes 0.45.5