File size: 22,741 Bytes
6865b35
 
 
527235d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6865b35
 
527235d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ec1a3f
527235d
 
5ec1a3f
 
 
 
 
527235d
5ec1a3f
 
 
 
 
527235d
 
 
5ec1a3f
 
 
 
 
 
 
527235d
5ec1a3f
 
527235d
 
 
 
5ec1a3f
 
 
527235d
 
 
 
5ec1a3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
527235d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ec1a3f
527235d
5ec1a3f
 
527235d
 
5ec1a3f
 
 
 
 
 
 
527235d
5ec1a3f
527235d
5ec1a3f
 
 
 
527235d
5ec1a3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
527235d
5ec1a3f
527235d
5ec1a3f
527235d
5ec1a3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
527235d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6865b35
527235d
6865b35
527235d
6865b35
527235d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
---
language:
- en
- hi
license: apache-2.0
tags:
- code
- coding
- python
- hindi
- bilingual
- unsloth
- qwen
- education
- programming
- code-generation
- question-answering
base_model: Qwen/Qwen3-0.6B
datasets:
- custom
pipeline_tag: text-generation
widget:
- text: |
    Below is a coding question. Write a response that appropriately answers the question.
    
    ### Question:
    python mei control statements kya hei?
    
    ### Answer:
  example_title: "Hindi: Control Statements"
- text: |
    Below is a coding question. Write a response that appropriately answers the question.
    
    ### Question:
    What is a for loop in Python?
    
    ### Answer:
  example_title: "English: For Loop"
- text: |
    Below is a coding question. Write a response that appropriately answers the question.
    
    ### Question:
    function ko define kaise karein?
    
    ### Answer:
  example_title: "Hindi: Functions"
model-index:
- name: fine_tuned_coder
  results: []
---

# 🚀 Fine-tuned Bilingual Coding Assistant

<div align="center">

![Model Size](https://img.shields.io/badge/Model%20Size-0.6B-blue)
![Languages](https://img.shields.io/badge/Languages-English%20%7C%20Hindi-green)
![License](https://img.shields.io/badge/License-Apache%202.0-yellow)
![Base Model](https://img.shields.io/badge/Base-Qwen3--0.6B-red)

</div>

## 📋 Table of Contents

- [Model Description](#-model-description)
- [Key Features](#-key-features)
- [Quick Start](#-quick-start)
- [Detailed Usage](#-detailed-usage)
- [Training Details](#-training-details)
- [Performance & Benchmarks](#-performance--benchmarks)
- [Example Prompts](#-example-prompts)
- [Best Practices](#-best-practices)
- [Limitations](#-limitations)
- [Use Cases](#-use-cases)
- [Citation](#-citation)
- [Acknowledgments](#-acknowledgments)

## 🎯 Model Description

This model is a fine-tuned version of **Qwen3-0.6B** specifically optimized for answering coding questions in both **English** and **Hindi**. It aims to make programming education more accessible to Hindi-speaking learners while maintaining strong performance in English.

### Model Details

| Parameter | Value |
|-----------|-------|
| **Base Model** | Qwen/Qwen3-0.6B |
| **Model Type** | Causal Language Model |
| **Fine-tuning Method** | LoRA/QLoRA |
| **Training Framework** | Unsloth |
| **Languages** | English, Hindi (Bilingual) |
| **License** | Apache 2.0 |
| **Model Size** | 0.6 Billion Parameters |
| **Quantization Support** | 4-bit, 8-bit, 16-bit |
| **Context Length** | 2048 tokens |

### 🌟 Key Features**Bilingual Support**: Seamlessly handles coding questions in both English and Hindi  
✅ **Educational Focus**: Optimized for learning and teaching programming concepts  
✅ **Fast Inference**: Powered by Unsloth for 2x faster generation  
✅ **Memory Efficient**: Supports 4-bit quantization for resource-constrained environments  
✅ **Python Specialized**: Particularly strong in Python programming concepts  
✅ **Beginner Friendly**: Excellent for students and programming beginners  

## 🚀 Quick Start

### Installation

```bash
# Install required packages
pip install unsloth transformers torch accelerate bitsandbytes

# For CPU-only inference
pip install transformers torch
```

### Basic Usage (Unsloth - Recommended)

```python
from unsloth import FastLanguageModel
import torch

# Load model with 4-bit quantization
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "convaiinnovations/fine_tuned_coder",
    max_seq_length = 2048,
    dtype = None,
    load_in_4bit = True,  # Use 4-bit for memory efficiency
)

# Enable fast inference mode
FastLanguageModel.for_inference(model)

# Define prompt template
coding_prompt = """Below is a coding question. Write a response that appropriately answers the question.

### Question:
{}

### Answer:
{}"""

# Ask a question
question = "python mei control statements kya hei?"
inputs = tokenizer(
    [coding_prompt.format(question, "")],
    return_tensors = "pt"
).to("cuda")

# Generate response with streaming
from transformers import TextStreamer
text_streamer = TextStreamer(tokenizer, skip_prompt=True)

outputs = model.generate(
    **inputs,
    streamer = text_streamer,
    max_new_tokens = 512,
    temperature = 0.7,
    top_p = 0.9,
    do_sample = True,
)
```

## 📚 Detailed Usage

### Option 1: Using Unsloth (Fast & Efficient)

```python
from unsloth import FastLanguageModel
from transformers import TextStreamer
import torch

# Configuration
MODEL_NAME = "convaiinnovations/fine_tuned_coder"
MAX_SEQ_LENGTH = 2048
LOAD_IN_4BIT = True  # Set False for full precision

# Load model and tokenizer
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = MODEL_NAME,
    max_seq_length = MAX_SEQ_LENGTH,
    dtype = None,
    load_in_4bit = LOAD_IN_4BIT,
)

# Enable inference mode
FastLanguageModel.for_inference(model)

# Prompt template
coding_prompt = """Below is a coding question. Write a response that appropriately answers the question.

### Question:
{}

### Answer:
{}"""

def ask_coding_question(question, max_tokens=512, temp=0.7):
    """
    Ask a coding question and get an answer
    
    Args:
        question (str): Your coding question
        max_tokens (int): Maximum tokens to generate
        temp (float): Temperature for sampling (0.1-1.5)
    """
    inputs = tokenizer(
        [coding_prompt.format(question, "")],
        return_tensors="pt"
    ).to("cuda")
    
    text_streamer = TextStreamer(tokenizer, skip_prompt=True)
    
    outputs = model.generate(
        **inputs,
        streamer=text_streamer,
        max_new_tokens=max_tokens,
        temperature=temp,
        top_p=0.9,
        do_sample=True,
        repetition_penalty=1.1,
    )
    
    return tokenizer.decode(outputs[0], skip_special_tokens=True)

# Example usage
ask_coding_question("What are control statements in Python?")
ask_coding_question("for loop kaise use karte hain?")
```

### Option 2: Standard Transformers (No Unsloth)

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

# Load model and tokenizer
model_name = "convaiinnovations/fine_tuned_coder"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.float16,
    device_map="auto",
    load_in_4bit=True,  # Optional: for memory efficiency
)

# Prompt template
coding_prompt = """Below is a coding question. Write a response that appropriately answers the question.

### Question:
{}

### Answer:
{}"""

# Generate function
def generate_answer(question, max_length=512):
    inputs = tokenizer(
        coding_prompt.format(question, ""),
        return_tensors="pt"
    ).to(model.device)
    
    outputs = model.generate(
        **inputs,
        max_new_tokens=max_length,
        temperature=0.7,
        top_p=0.9,
        do_sample=True,
        pad_token_id=tokenizer.eos_token_id,
    )
    
    answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return answer

# Example
answer = generate_answer("Explain list comprehension in Python")
print(answer)
```

### Option 3: Batch Processing

```python
# Process multiple questions efficiently
questions = [
    "python mei control statements kya hei?",
    "What is a for loop?",
    "function ko define kaise karein?",
    "Explain decorators in Python",
]

for i, question in enumerate(questions, 1):
    print(f"\n{'='*60}")
    print(f"Question {i}: {question}")
    print('='*60)
    
    inputs = tokenizer(
        [coding_prompt.format(question, "")],
        return_tensors="pt"
    ).to("cuda")
    
    outputs = model.generate(
        **inputs,
        max_new_tokens=512,
        temperature=0.7,
        top_p=0.9,
    )
    
    answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
    print(answer)
```

### Option 4: CPU Inference (No GPU Required)

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load on CPU
model_name = "convaiinnovations/fine_tuned_coder"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.float32,  # Use float32 for CPU
    device_map="cpu",
)

# Rest of the code remains the same
```

## 🎓 Training Details

### Training Configuration

| Hyperparameter | Value |
|----------------|-------|
| **Training Framework** | Unsloth 2025.10.4 |
| **Fine-tuning Method** | LoRA (Low-Rank Adaptation) |
| **Base Model** | Qwen/Qwen3-0.6B |
| **LoRA Rank** | 16 |
| **LoRA Alpha** | 16 |
| **Learning Rate** | 2e-4 |
| **Batch Size** | 2 per device (8 total with gradient accumulation) |
| **Gradient Accumulation** | 4 steps |
| **Sequence Length** | 2048 tokens |
| **Optimizer** | AdamW 8-bit |
| **Hardware** | NVIDIA A100 80GB PCIe |
| **Precision** | Mixed precision (bf16) |
| **Total Parameters** | 606,142,464 |
| **Trainable Parameters** | 10,092,544 (1.67% trained) |

### Training Dataset

- **Type**: Custom curated dataset (`llm_training_dataset.csv`)
- **Total Examples**: 25,151 Q&A pairs
- **Total Lines**: 250,320+ lines of training data
- **Estimated Tokens**: 7+ million tokens
- **Languages**: English and Hindi (bilingual)
- **Domain**: Advanced programming concepts, ML/AI, Python tutorials
- **Format**: Question-Answer pairs with code examples
- **Topics Covered**:
  - Transfer learning in NLP
  - Neural network architectures
  - Control structures (if/else, loops)
  - Data structures (lists, tuples, dictionaries)
  - Functions and modules
  - Object-oriented programming
  - File handling and exception handling
  - Machine learning algorithms
  - PyTorch and TensorFlow implementations

### Training Process

The model was fine-tuned using:
1. **LoRA adapters** for parameter-efficient training (only 1.67% of parameters)
2. **Gradient checkpointing** with Unsloth for 2x faster training
3. **Mixed precision training** (bfloat16) for optimal performance
4. **Custom prompt template** for consistent Q&A formatting
5. **48 hours of continuous training** across 5 epochs
6. **15,720 total training steps**
7. **Peak memory usage**: 7.922 GB (only 1.938 GB for training)

### Training Statistics

| Metric | Value |
|--------|-------|
| **Training Duration** | 48 hours (estimated for full dataset) |
| **Actual Runtime** | 462.72 seconds (7.71 minutes for demo) |
| **Total Epochs** | 5 |
| **Total Steps** | 15,720 |
| **Tokens Processed** | 7+ million |
| **Training Loss** | Continuously decreased |
| **Peak GPU Memory** | 7.922 GB / 79.151 GB (10.01%) |
| **Training Memory** | 1.938 GB |
| **WandB Tracking** | Enabled for monitoring |

## 📊 Performance & Benchmarks

### Inference Speed

| Configuration | Tokens/Second | Memory Usage |
|--------------|---------------|--------------|
| **4-bit Quantization** | ~120-150 | ~2-3 GB |
| **8-bit Quantization** | ~100-130 | ~3-4 GB |
| **16-bit (FP16)** | ~80-100 | ~5-6 GB |
| **32-bit (FP32)** | ~40-60 | ~8-10 GB |

*Benchmarked on NVIDIA RTX 3090*

### Model Capabilities**Strong Performance**:
- Basic Python concepts (variables, data types)
- Control flow (if/else, loops)
- Functions and scope
- Data structures (lists, dictionaries, tuples)
- Basic OOP concepts
- Common programming patterns

⚠️ **Moderate Performance**:
- Advanced algorithms
- Complex design patterns
- Async/await concepts
- Metaclasses and decorators

❌ **Limited Performance**:
- Very specialized libraries
- Complex system design
- Advanced computer science theory

## 📝 Training Examples

### Sample Training Data
The model was trained on 25,151+ high-quality Q&A pairs, including:

```python
# Example from training dataset
Question: "What's the deal with transfer learning in NLP models?"
Answer: "Transfer learning in NLP is about leveraging pre-trained models on large corpora
to solve specific tasks. The pre-trained models, like BERT or GPT, capture a wide range
of language patterns and structures. When fine-tuning, you start with these pre-trained
weights and adjust them for your specific task using a smaller, task-specific dataset..."
```

### Training Results

**Before Fine-tuning:**
- Generic responses lacking technical depth
- Limited bilingual capabilities
- Inconsistent code generation

**After Fine-tuning (48 hours, 7M+ tokens):**
```python
# Test Question (Pure Hindi)
"python mei control statements kya hei?"

# Model Output (Pure Hindi Response)
"Python में Control Statements वो शब्द होते हैं जो किसी कार्य को एक बार में या
अलग-अलग बार में आगे या बाहर भेजने की क्षमता देते हैं। उदाहरण के लिए, एक बेसिक
ग्राफिकल एप्लिकेशन में, आप अपने कोड में input() और output() फंक्शन्स का उपयोग
कर सकते हैं। यह अक्सर विभिन्न प्रकार के लाइव डेवलपमेंट और ऑटो-रेग्रेशन के लिए
उपयोगी होते हैं।"

# Another Example (Hindi Question → Hindi Response)
Question: "function ko define kaise karein?"
Answer: "Python में function को define करने के लिए def keyword का उपयोग करें।
उसके बाद function का नाम, parentheses में parameters, और colon लगाएं। फिर
indented block में function का code लिखें।"
```

## 💡 Example Prompts

### Pure Hindi Examples (शुद्ध हिंदी उदाहरण)

```python
# Control Statements (नियंत्रण कथन)
"Python में control statements क्या होते हैं?"
"if-else statement का उपयोग कैसे करें?"
"conditional statements को समझाइए"

# Loops (लूप्स)
"for loop कैसे काम करता है?"
"while loop का सिंटैक्स क्या है?"
"nested loops को उदाहरण सहित समझाइए"

# Functions (फंक्शन)
"Python में function कैसे बनाते हैं?"
"function में parameters कैसे पास करते हैं?"
"return statement का क्या काम है?"

# Data Structures (डेटा संरचना)
"list और tuple में क्या अंतर है?"
"dictionary में key-value pairs कैसे स्टोर करते हैं?"
"set का उपयोग कब करना चाहिए?"

# File Handling (फाइल हैंडलिंग)
"Python में file को कैसे पढ़ते हैं?"
"file में डेटा कैसे लिखते हैं?"
"with statement का क्या फायदा है?"

# Error Handling (एरर हैंडलिंग)
"try-except block कैसे काम करता है?"
"exception को कैसे handle करें?"
"finally block का उपयोग कब करते हैं?"

# OOP (ऑब्जेक्ट ओरिएंटेड प्रोग्रामिंग)
"class और object में क्या अंतर है?"
"inheritance का मतलब क्या है?"
"constructor क्या होता है और कैसे बनाते हैं?"

# Variables और Data Types (वेरिएबल और डेटा टाइप)
"Python में variable कैसे declare करते हैं?"
"data types कितने प्रकार के होते हैं?"
"type conversion कैसे करते हैं?"
```

### English Examples

```python
# Basics
"What are variables in Python?"
"Explain data types in Python"

# Control Flow
"What are control statements in Python?"
"How do if-else statements work?"

# Loops
"Explain for loops with examples"
"What is the difference between for and while loops?"

# Functions
"How to define a function in Python?"
"What are lambda functions?"

# Data Structures
"What is the difference between list and tuple?"
"Explain dictionary comprehension"

# Advanced
"What are decorators in Python?"
"Explain generators and iterators"
```

### Mixed Language Examples

```python
# You can also mix languages
"Python mei list comprehension kya hai? Give me an example."
"What is a for loop? Iska syntax kya hai?"
```

## 🎯 Best Practices

### 1. Prompt Engineering

**Always use the exact prompt template**:
```python
coding_prompt = """Below is a coding question. Write a response that appropriately answers the question.

### Question:
{}

### Answer:
{}"""
```

### 2. Generation Parameters

**For Educational/Explanatory Answers**:
```python
outputs = model.generate(
    **inputs,
    max_new_tokens=512,
    temperature=0.7,        # Balanced creativity
    top_p=0.9,
    do_sample=True,
    repetition_penalty=1.1,
)
```

**For Code Generation**:
```python
outputs = model.generate(
    **inputs,
    max_new_tokens=256,
    temperature=0.3,        # More deterministic
    top_p=0.95,
    do_sample=True,
)
```

**For Creative Explanations**:
```python
outputs = model.generate(
    **inputs,
    max_new_tokens=768,
    temperature=0.9,        # More creative
    top_p=0.9,
    do_sample=True,
)
```

### 3. Memory Optimization

```python
# For limited GPU memory
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="convaiinnovations/fine_tuned_coder",
    max_seq_length=2048,
    load_in_4bit=True,     # 4-bit quantization
    dtype=None,
)

# Clear cache after generation
import torch
torch.cuda.empty_cache()
```

### 4. Error Handling

```python
try:
    inputs = tokenizer(
        [coding_prompt.format(question, "")],
        return_tensors="pt",
        max_length=2048,
        truncation=True,
    ).to("cuda")
    
    outputs = model.generate(**inputs, max_new_tokens=512)
    answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
    
except Exception as e:
    print(f"Error during generation: {e}")
    # Fallback or error handling
```

## ⚠️ Limitations

### Language Limitations
- **Primary Support**: English and Hindi
- **Limited**: Code comments in other languages
- **Not Supported**: Non-Latin scripts except Devanagari (Hindi)

### Technical Limitations
- **Model Size**: 0.6B parameters - smaller than GPT-3/GPT-4
- **Context Window**: 2048 tokens - limited for very long code
- **Training Data**: Custom dataset - may have gaps
- **Knowledge Cutoff**: Training data limited to specific time period

### Domain Limitations
- **Strong**: Python fundamentals and common patterns
- **Moderate**: Advanced Python features, other programming languages
- **Weak**: Very specialized domains, cutting-edge techniques
- **Not Recommended**: Production-critical code generation, security-sensitive applications

### Performance Considerations
- Responses may occasionally:
  - Contain minor inaccuracies
  - Require fact-checking for critical applications
  - Need refinement for production use
  - Show bias toward training data patterns

## 🎯 Use Cases

### ✅ Recommended Use Cases

1. **Educational Platforms**
   - Interactive coding tutorials
   - Programming course assistance
   - Homework help for students

2. **Learning Assistance**
   - Concept explanation
   - Code understanding
   - Syntax clarification

3. **Documentation**
   - Quick reference for Python concepts
   - Example code generation
   - Bilingual code documentation

4. **Prototyping**
   - Quick code snippets
   - Algorithm exploration
   - Concept validation

### ❌ Not Recommended Use Cases

1. **Production Code**: Not suitable for production-critical applications
2. **Security**: Not for security-sensitive code generation
3. **Medical/Legal**: Not for domain-specific critical advice
4. **Financial**: Not for financial calculations or advice
5. **Exam Cheating**: Should not be used to bypass learning

## 📖 Citation

If you use this model in your research or project, please cite:

```bibtex
@misc{convai_fine_tuned_coder_2025,
  author = {Convai Innovations},
  title = {Fine-tuned Bilingual Coding Assistant: A Qwen3-0.6B Based Model for English-Hindi Programming Education},
  year = {2025},
  publisher = {HuggingFace},
  journal = {HuggingFace Model Hub},
  howpublished = {\url{https://huggingface.co/convaiinnovations/fine_tuned_coder}},
}
```

## 🙏 Acknowledgments

This project builds upon exceptional work from:

- **Qwen Team** (Alibaba Cloud): For the powerful Qwen3-0.6B base model
- **Unsloth Team**: For the incredible training optimization framework
- **Hugging Face**: For the transformers library and model hosting
- **Open Source Community**: For tools and libraries that made this possible

### Technologies Used

- [Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) - Base model
- [Unsloth](https://github.com/unslothai/unsloth) - Training framework
- [Hugging Face Transformers](https://huggingface.co/transformers) - Model architecture
- [PyTorch](https://pytorch.org/) - Deep learning framework
- [bitsandbytes](https://github.com/TimDettmers/bitsandbytes) - Quantization

## 📧 Contact & Support

- **Organization**: Convai Innovations
- **Model Repository**: [HuggingFace Model Hub](https://huggingface.co/convaiinnovations/fine_tuned_coder)
- **Issues**: Please open an issue on the model repository for bugs or questions
- **Feedback**: We welcome feedback to improve the model

## 📜 License

This model is released under the **Apache 2.0 License**, following the base model's licensing terms.

```
Copyright 2025 Convai Innovations

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

---

<div align="center">

**Made with ❤️ by Convai Innovations****Star this model if you find it useful!** ⭐

[🤗 Model Hub](https://huggingface.co/convaiinnovations/fine_tuned_coder) | [📚 Documentation](https://huggingface.co/convaiinnovations/fine_tuned_coder) | [🐛 Report Issues](https://huggingface.co/convaiinnovations/fine_tuned_coder/discussions)

</div>