salakash commited on
Commit
8b59c57
·
verified ·
1 Parent(s): ded6772

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. LICENSE-THIRD-PARTY.md +116 -0
  2. MODEL_CARD.md +166 -0
  3. README.md +213 -0
  4. USAGE.md +38 -0
  5. adapter_config.json +9 -0
  6. adapters.safetensors +3 -0
  7. run_meta.json +7 -0
LICENSE-THIRD-PARTY.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Third-Party Licenses and Attribution
2
+
3
+ This project uses and builds upon the following third-party components:
4
+
5
+ ## Base Model
6
+
7
+ **Qwen/Qwen2.5-Coder-0.5B-Instruct**
8
+ - Source: https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct
9
+ - License: Apache License 2.0
10
+ - Copyright: Qwen Team, Alibaba Cloud
11
+ - Description: Base language model for code generation
12
+
13
+ ### Apache License 2.0 Summary
14
+ Licensed under the Apache License, Version 2.0 (the "License");
15
+ you may not use this file except in compliance with the License.
16
+ You may obtain a copy of the License at
17
+
18
+ http://www.apache.org/licenses/LICENSE-2.0
19
+
20
+ Unless required by applicable law or agreed to in writing, software
21
+ distributed under the License is distributed on an "AS IS" BASIS,
22
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ See the License for the specific language governing permissions and
24
+ limitations under the License.
25
+
26
+ ## MLX Model Weights
27
+
28
+ **mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit**
29
+ - Source: https://huggingface.co/mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit
30
+ - License: Apache License 2.0 (inherited from base model)
31
+ - Description: MLX-optimized 4-bit quantized version of Qwen2.5-Coder-0.5B-Instruct
32
+ - Conversion: Community contribution for Apple Silicon optimization
33
+
34
+ ## Training Dataset
35
+
36
+ **flwrlabs/code-alpaca-20k**
37
+ - Source: https://huggingface.co/datasets/flwrlabs/code-alpaca-20k
38
+ - License: Apache License 2.0
39
+ - Description: Code instruction dataset based on Stanford Alpaca methodology
40
+ - Size: 20,000 code instruction-following examples
41
+
42
+ ## Python Dependencies
43
+
44
+ ### MLX-LM
45
+ - License: MIT License
46
+ - Description: MLX language model utilities
47
+ - Source: https://github.com/ml-explore/mlx-lm
48
+
49
+ ### Hugging Face Datasets
50
+ - License: Apache License 2.0
51
+ - Description: Dataset loading and processing library
52
+ - Source: https://github.com/huggingface/datasets
53
+
54
+ ### Hugging Face Hub
55
+ - License: Apache License 2.0
56
+ - Description: Hugging Face Hub client library
57
+ - Source: https://github.com/huggingface/huggingface_hub
58
+
59
+ ### PyYAML
60
+ - License: MIT License
61
+ - Description: YAML parser and emitter
62
+ - Source: https://github.com/yaml/pyyaml
63
+
64
+ ## Disclaimers
65
+
66
+ ### No Endorsement
67
+ This project is not endorsed by, affiliated with, or sponsored by:
68
+ - Qwen Team or Alibaba Cloud
69
+ - The MLX community
70
+ - flwrlabs or the code-alpaca-20k dataset authors
71
+ - Hugging Face
72
+
73
+ ### Attribution Requirements
74
+ When using this model or its derivatives:
75
+ 1. Maintain attribution to the base model (Qwen2.5-Coder-0.5B-Instruct)
76
+ 2. Maintain attribution to the training dataset (code-alpaca-20k)
77
+ 3. Include this license file or equivalent attribution
78
+ 4. Do not imply endorsement by original authors
79
+
80
+ ### Modifications
81
+ This project provides:
82
+ - LoRA adapter weights (fine-tuning on top of base model)
83
+ - Training and serving infrastructure
84
+ - Documentation and usage examples
85
+
86
+ This project does NOT redistribute:
87
+ - Base model weights (users download from original source)
88
+ - Complete fine-tuned model weights
89
+ - Training dataset (users download from original source)
90
+
91
+ ## License Compliance
92
+
93
+ All components used in this project are licensed under permissive open-source licenses (Apache-2.0, MIT) that allow:
94
+ - Commercial use
95
+ - Modification
96
+ - Distribution
97
+ - Private use
98
+
99
+ Users must:
100
+ - Include copyright notices
101
+ - Include license text
102
+ - State changes made
103
+ - Not use trademarks without permission
104
+
105
+ ## Full License Texts
106
+
107
+ ### Apache License 2.0
108
+ Full text available at: http://www.apache.org/licenses/LICENSE-2.0
109
+
110
+ ### MIT License
111
+ Full text available at: https://opensource.org/licenses/MIT
112
+
113
+ ## Questions
114
+
115
+ For questions about licensing or attribution, please open an issue at:
116
+ https://github.com/salakash/AskBuddyX/issues
MODEL_CARD.md ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-Coder-0.5B-Instruct
4
+ tags:
5
+ - code
6
+ - coding-assistant
7
+ - mlx
8
+ - lora
9
+ - qwen2.5
10
+ language:
11
+ - en
12
+ pipeline_tag: text-generation
13
+ ---
14
+
15
+ # AskBuddyX
16
+
17
+ AskBuddyX is a practical coding assistant fine-tuned with LoRA on the code-alpaca-20k dataset. It provides runnable-first responses with structured sections for Solution, Usage, and Sanity Tests.
18
+
19
+ ## Model Details
20
+
21
+ - **Base Model**: [Qwen/Qwen2.5-Coder-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct)
22
+ - **MLX Weights**: [mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit](https://huggingface.co/mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit)
23
+ - **Training Dataset**: [flwrlabs/code-alpaca-20k](https://huggingface.co/datasets/flwrlabs/code-alpaca-20k)
24
+ - **Training Method**: LoRA (Low-Rank Adaptation)
25
+ - **Framework**: MLX (Apple Silicon optimized)
26
+ - **License**: Apache-2.0
27
+
28
+ ## Intended Use
29
+
30
+ AskBuddyX is designed for:
31
+ - Code generation and completion
32
+ - Programming assistance and tutoring
33
+ - Quick prototyping and examples
34
+ - Learning programming concepts
35
+
36
+ ### Response Format
37
+
38
+ When asked for code, AskBuddyX structures responses with:
39
+
40
+ 1. **Solution**: The main implementation
41
+ 2. **Usage**: A minimal runnable example
42
+ 3. **Sanity test**: A tiny test snippet (when appropriate)
43
+
44
+ This format ensures responses are immediately actionable and testable.
45
+
46
+ ## Training Details
47
+
48
+ - **Dataset Size**: 2,000 examples (configurable)
49
+ - **Training Iterations**: 50 (configurable)
50
+ - **LoRA Rank**: 8
51
+ - **LoRA Alpha**: 16
52
+ - **Learning Rate**: 2e-5
53
+ - **Hardware**: Apple Silicon M1 with 32GB RAM
54
+
55
+ ### Data Processing
56
+
57
+ The training data underwent:
58
+ 1. Secret redaction (API keys, private keys, tokens)
59
+ 2. Deduplication by content hash
60
+ 3. Train/validation split (98/2)
61
+ 4. Deterministic truncation for efficiency
62
+
63
+ ## Usage
64
+
65
+ ### Installation
66
+
67
+ ```bash
68
+ pip install mlx-lm
69
+ ```
70
+
71
+ ### Running the Server
72
+
73
+ ```bash
74
+ python -m mlx_lm.server \
75
+ --model mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit \
76
+ --adapter-path salakash/AskBuddyX \
77
+ --host 127.0.0.1 \
78
+ --port 8080
79
+ ```
80
+
81
+ ### API Example
82
+
83
+ ```bash
84
+ curl http://127.0.0.1:8080/v1/chat/completions \
85
+ -H 'Content-Type: application/json' \
86
+ -d '{
87
+ "model": "AskBuddyX",
88
+ "messages": [
89
+ {"role": "user", "content": "Write a Python function to add two numbers"}
90
+ ],
91
+ "max_tokens": 256
92
+ }'
93
+ ```
94
+
95
+ ### Python Example
96
+
97
+ ```python
98
+ from mlx_lm import load, generate
99
+
100
+ # Load model with adapter
101
+ model, tokenizer = load(
102
+ "mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit",
103
+ adapter_path="salakash/AskBuddyX"
104
+ )
105
+
106
+ # Generate response
107
+ prompt = "Write a Python function to reverse a string"
108
+ response = generate(model, tokenizer, prompt=prompt, max_tokens=256)
109
+ print(response)
110
+ ```
111
+
112
+ ## Limitations
113
+
114
+ - **Model Size**: 0.5B parameters - suitable for quick tasks but not complex reasoning
115
+ - **Context Length**: Limited by base model's context window
116
+ - **Domain**: Primarily trained on Python code examples
117
+ - **Hardware**: Optimized for Apple Silicon; may not perform optimally on other platforms
118
+ - **Accuracy**: May generate incorrect or insecure code; always review outputs
119
+
120
+ ## Ethical Considerations
121
+
122
+ - **Code Review**: Always review generated code before use in production
123
+ - **Security**: Do not use for security-critical applications without thorough review
124
+ - **Bias**: May reflect biases present in training data
125
+ - **Attribution**: Generated code should be reviewed for licensing implications
126
+
127
+ ## Attribution
128
+
129
+ This model is built upon:
130
+
131
+ 1. **Base Model**: Qwen/Qwen2.5-Coder-0.5B-Instruct
132
+ - License: Apache-2.0
133
+ - Authors: Qwen Team, Alibaba Cloud
134
+ - No endorsement by original authors is implied
135
+
136
+ 2. **MLX Conversion**: mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit
137
+ - Converted for Apple Silicon optimization
138
+ - Community contribution
139
+
140
+ 3. **Training Dataset**: flwrlabs/code-alpaca-20k
141
+ - License: Apache-2.0
142
+ - Based on Stanford Alpaca methodology
143
+ - No endorsement by dataset authors is implied
144
+
145
+ ## Citation
146
+
147
+ If you use AskBuddyX in your research or applications, please cite:
148
+
149
+ ```bibtex
150
+ @misc{askbuddyx2024,
151
+ title={AskBuddyX: A Practical Coding Assistant},
152
+ author={Kashif Salahuddin},
153
+ year={2024},
154
+ publisher={Hugging Face},
155
+ howpublished={\url{https://huggingface.co/salakash/AskBuddyX}}
156
+ }
157
+ ```
158
+
159
+ ## Contact
160
+
161
+ - Repository: [github.com/salakash/AskBuddyX](https://github.com/salakash/AskBuddyX)
162
+ - Issues: [github.com/salakash/AskBuddyX/issues](https://github.com/salakash/AskBuddyX/issues)
163
+
164
+ ## Disclaimer
165
+
166
+ This adapter is provided "as is" without warranty. The authors are not responsible for any damages or issues arising from its use. Always review and test generated code before deployment.
README.md ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AskBuddyX
2
+
3
+ A practical coding assistant based on Qwen2.5-Coder with runnable-first responses.
4
+
5
+ ## Features
6
+
7
+ - **Runnable-First Responses**: Structured answers with Solution, Usage, and Sanity Test sections
8
+ - **LoRA Fine-Tuned**: Efficient adapter-based training on code-alpaca-20k dataset
9
+ - **MLX Optimized**: Built for Apple Silicon (M1/M2/M3) using MLX framework
10
+ - **OpenAI Compatible**: Serves via standard `/v1/chat/completions` endpoint
11
+
12
+ ## Quick Start
13
+
14
+ ### Prerequisites
15
+
16
+ - macOS with Apple Silicon (M1/M2/M3)
17
+ - Python 3.9+
18
+ - Active Python virtual environment
19
+
20
+ ### Installation
21
+
22
+ ```bash
23
+ # Clone the repository
24
+ git clone https://github.com/salakash/AskBuddyX.git
25
+ cd AskBuddyX
26
+
27
+ # Install dependencies
28
+ make deps
29
+ ```
30
+
31
+ ### Training
32
+
33
+ Run the complete training pipeline:
34
+
35
+ ```bash
36
+ make all
37
+ ```
38
+
39
+ This will:
40
+ 1. Install dependencies
41
+ 2. Fetch the code-alpaca-20k dataset
42
+ 3. Preprocess and prepare the data
43
+ 4. Train the LoRA adapter (50 iterations by default)
44
+ 5. Run evaluation tests
45
+
46
+ ### Serving
47
+
48
+ Start the OpenAI-compatible server:
49
+
50
+ ```bash
51
+ make serve
52
+ ```
53
+
54
+ The server will start on `http://127.0.0.1:8080` by default.
55
+
56
+ ### Testing the Server
57
+
58
+ ```bash
59
+ curl http://127.0.0.1:8080/v1/chat/completions \
60
+ -H 'Content-Type: application/json' \
61
+ -d '{
62
+ "model": "AskBuddyX",
63
+ "messages": [
64
+ {"role": "user", "content": "Write a Python function to add two numbers"}
65
+ ],
66
+ "max_tokens": 256
67
+ }'
68
+ ```
69
+
70
+ ### Publishing
71
+
72
+ Publish the adapter to Hugging Face:
73
+
74
+ ```bash
75
+ make publish
76
+ ```
77
+
78
+ This will upload the adapter bundle to `salakash/AskBuddyX` on Hugging Face.
79
+
80
+ ## Response Format
81
+
82
+ AskBuddyX provides structured, runnable-first responses:
83
+
84
+ ### Solution
85
+ The main implementation code
86
+
87
+ ### Usage
88
+ A minimal runnable example showing how to use the solution
89
+
90
+ ### Sanity test
91
+ A tiny test snippet (included when appropriate)
92
+
93
+ ## Configuration
94
+
95
+ Environment variables can be used to customize behavior:
96
+
97
+ ```bash
98
+ # Model configuration
99
+ export MODEL_ID="mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit"
100
+
101
+ # Training configuration
102
+ export DATA_LIMIT=2000
103
+ export TRAIN_ITERS=50
104
+
105
+ # Server configuration
106
+ export HOST="127.0.0.1"
107
+ export PORT=8080
108
+ ```
109
+
110
+ See `.env.example` for all available options.
111
+
112
+ ## Project Structure
113
+
114
+ ```
115
+ askbuddyx/
116
+ ├── config.py # Configuration and defaults
117
+ ├── prompting.py # Prompt formatting and system prompt
118
+ ├── train/ # Training pipeline
119
+ │ ├── fetch_codealpaca.py
120
+ │ ├── prepare_dataset.py
121
+ │ ├── build_training_text.py
122
+ │ └── run_lora.py
123
+ ├── eval/ # Evaluation scripts
124
+ │ ├── run_sanity_prompts.py
125
+ │ └── run_codegen_smoke.py
126
+ ├── serve/ # Serving utilities
127
+ │ └── serve.sh
128
+ └── publish/ # Publishing utilities
129
+ ├── make_bundle.py
130
+ └── publish.py
131
+ ```
132
+
133
+ ## Makefile Targets
134
+
135
+ - `make all` - Run complete pipeline (deps, fetch, prep, train, eval)
136
+ - `make deps` - Install dependencies
137
+ - `make fetch-data` - Fetch dataset
138
+ - `make prep-data` - Prepare dataset
139
+ - `make train` - Train LoRA adapter
140
+ - `make eval` - Run evaluation
141
+ - `make serve` - Start server
142
+ - `make bundle` - Create HF bundle
143
+ - `make publish` - Publish to Hugging Face
144
+ - `make clean` - Remove generated files
145
+ - `make help` - Show all targets
146
+
147
+ ## Base Model & Dataset
148
+
149
+ - **Base Model**: [Qwen/Qwen2.5-Coder-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct)
150
+ - **MLX Weights**: [mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit](https://huggingface.co/mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit)
151
+ - **Dataset**: [flwrlabs/code-alpaca-20k](https://huggingface.co/datasets/flwrlabs/code-alpaca-20k)
152
+
153
+ ## License
154
+
155
+ This project publishes only adapter artifacts and configuration. The base model and dataset have their own licenses:
156
+
157
+ - Base Model: Apache-2.0 (Qwen/Qwen2.5-Coder-0.5B-Instruct)
158
+ - Dataset: Apache-2.0 (flwrlabs/code-alpaca-20k)
159
+
160
+ See `LICENSE-THIRD-PARTY.md` for complete attribution.
161
+
162
+ ## Development
163
+
164
+ ```bash
165
+ # Run linter
166
+ make lint
167
+
168
+ # Run tests
169
+ make test
170
+
171
+ # Clean generated files
172
+ make clean
173
+ ```
174
+
175
+ ## Hardware Requirements
176
+
177
+ - macOS with Apple Silicon (M1/M2/M3)
178
+ - 32GB RAM recommended
179
+ - ~5GB disk space for model and data
180
+
181
+ ## Troubleshooting
182
+
183
+ ### Server won't start
184
+ Ensure `mlx-lm` is installed:
185
+ ```bash
186
+ pip install mlx-lm
187
+ ```
188
+
189
+ ### Training fails
190
+ Check that you have enough disk space and RAM. Reduce `DATA_LIMIT` or `TRAIN_ITERS` if needed:
191
+ ```bash
192
+ export DATA_LIMIT=1000
193
+ export TRAIN_ITERS=25
194
+ make train
195
+ ```
196
+
197
+ ### Publishing fails
198
+ Ensure you're authenticated with Hugging Face:
199
+ ```bash
200
+ huggingface-cli login
201
+ # or
202
+ export HF_TOKEN=your_token_here
203
+ ```
204
+
205
+ ## Contributing
206
+
207
+ Contributions are welcome! Please ensure code passes linting and tests before submitting PRs.
208
+
209
+ ## Acknowledgments
210
+
211
+ - Qwen team for the excellent base model
212
+ - MLX community for the Apple Silicon optimizations
213
+ - flwrlabs for the code-alpaca-20k dataset
USAGE.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AskBuddyX Usage
2
+
3
+ ## Quick Start
4
+
5
+ ### 1. Install dependencies
6
+ ```bash
7
+ pip install mlx-lm
8
+ ```
9
+
10
+ ### 2. Start the server
11
+ ```bash
12
+ # Using the base model with this adapter
13
+ python -m mlx_lm.server \
14
+ --model mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit \
15
+ --adapter-path . \
16
+ --host 127.0.0.1 \
17
+ --port 8080
18
+ ```
19
+
20
+ ### 3. Test with curl
21
+ ```bash
22
+ curl http://127.0.0.1:8080/v1/chat/completions \
23
+ -H 'Content-Type: application/json' \
24
+ -d '{
25
+ "model": "AskBuddyX",
26
+ "messages": [
27
+ {"role": "user", "content": "Write a Python function to add two numbers"}
28
+ ],
29
+ "max_tokens": 256
30
+ }'
31
+ ```
32
+
33
+ ## Response Format
34
+
35
+ AskBuddyX provides runnable-first responses with these sections:
36
+ - **Solution**: Main implementation
37
+ - **Usage**: Smallest runnable example
38
+ - **Sanity test**: Tiny test snippet (when appropriate)
adapter_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "adapter_type": "lora",
3
+ "r": 8,
4
+ "lora_alpha": 16,
5
+ "lora_dropout": 0.05,
6
+ "target_modules": ["q_proj", "v_proj"],
7
+ "bias": "none",
8
+ "task_type": "CAUSAL_LM"
9
+ }
adapters.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56421d99cdab1e975e5171e525e90c80e7e2c6dbea4f18cf265dae481f228d7b
3
+ size 211
run_meta.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_id": "mlx-community/Qwen2.5-Coder-0.5B-Instruct-4bit",
3
+ "dataset_id": "flwrlabs/code-alpaca-20k",
4
+ "train_iters": 50,
5
+ "timestamp": "2025-12-29T16:58:00Z",
6
+ "note": "Mock adapter for testing publishing workflow"
7
+ }