Update model card with YAML metadata and detailed information
Browse files
README.md
CHANGED
@@ -1,23 +1,169 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
-
|
7 |
-
-
|
8 |
-
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
license: mit
|
5 |
+
tags:
|
6 |
+
- phi-3
|
7 |
+
- distillation
|
8 |
+
- knowledge-distillation
|
9 |
+
- lora
|
10 |
+
- code-generation
|
11 |
+
- python
|
12 |
+
datasets:
|
13 |
+
- Shuu12121/python-codesearch-dataset-open
|
14 |
+
model-index:
|
15 |
+
- name: FStudent
|
16 |
+
results:
|
17 |
+
- task:
|
18 |
+
type: text-generation
|
19 |
+
name: Text Generation
|
20 |
+
dataset:
|
21 |
+
type: custom
|
22 |
+
name: Distillation Evaluation
|
23 |
+
metrics:
|
24 |
+
- name: Speedup Factor
|
25 |
+
type: speedup
|
26 |
+
value: 2.5x
|
27 |
+
verified: false
|
28 |
+
---
|
29 |
+
|
30 |
+
# FStudent: Distilled Phi-3 Model
|
31 |
+
|
32 |
+
FStudent is a knowledge-distilled version of Microsoft's Phi-3-mini-4k-instruct model, trained through a comprehensive distillation pipeline that combines teacher-student learning with self-study mechanisms.
|
33 |
+
|
34 |
+
## Model Description
|
35 |
+
|
36 |
+
FStudent was created using a multi-stage distillation pipeline that transfers knowledge from a larger teacher model (Phi-4) to the smaller Phi-3-mini-4k-instruct model. The model was trained using LoRA adapters, which were then merged with the base model to create this standalone version.
|
37 |
+
|
38 |
+
### Training Data
|
39 |
+
|
40 |
+
The model was trained on a diverse set of data sources:
|
41 |
+
|
42 |
+
1. **PDF Documents**: Technical documentation and domain-specific knowledge
|
43 |
+
2. **Python Code Dataset**: Code examples from the [Shuu12121/python-codesearch-dataset-open](https://huggingface.co/datasets/Shuu12121/python-codesearch-dataset-open) dataset
|
44 |
+
3. **Teacher-Generated Examples**: High-quality examples generated by the Phi-4 teacher model
|
45 |
+
|
46 |
+
### Training Process
|
47 |
+
|
48 |
+
The distillation pipeline consisted of six sequential steps:
|
49 |
+
|
50 |
+
1. **Content Extraction & Enrichment**: PDF files were processed to extract and enrich text data
|
51 |
+
2. **Teacher Pair Generation**: Training pairs were generated using the Phi-4 teacher model
|
52 |
+
3. **Distillation Training**: The student model (Phi-3) was trained using LoRA adapters with the following parameters:
|
53 |
+
- Learning rate: 1e-4
|
54 |
+
- Batch size: 4
|
55 |
+
- Gradient accumulation steps: 8
|
56 |
+
- Mixed precision training
|
57 |
+
- 4-bit quantization during training
|
58 |
+
4. **Model Merging**: The trained LoRA adapters were merged with the base Phi-3 model
|
59 |
+
5. **Student Self-Study**: The model performed self-directed learning on domain-specific content
|
60 |
+
6. **Model Evaluation**: The model was evaluated against the teacher model for performance
|
61 |
+
|
62 |
+
### Model Architecture
|
63 |
+
|
64 |
+
- **Base Model**: microsoft/Phi-3-mini-4k-instruct
|
65 |
+
- **Parameter-Efficient Fine-Tuning**: LoRA adapters (merged into this model)
|
66 |
+
- **Context Length**: 4K tokens
|
67 |
+
- **Architecture**: Transformer-based language model
|
68 |
+
|
69 |
+
## Intended Uses
|
70 |
+
|
71 |
+
This model is designed for:
|
72 |
+
|
73 |
+
- General text generation tasks
|
74 |
+
- Python code understanding and generation
|
75 |
+
- Technical documentation analysis
|
76 |
+
- Question answering on domain-specific topics
|
77 |
+
|
78 |
+
## Performance and Limitations
|
79 |
+
|
80 |
+
### Strengths
|
81 |
+
|
82 |
+
- Faster inference compared to larger models (approximately 2.5x speedup)
|
83 |
+
- Maintains much of the capability of the teacher model
|
84 |
+
- Enhanced code understanding due to training on Python code datasets
|
85 |
+
- Good performance on technical documentation analysis
|
86 |
+
|
87 |
+
### Limitations
|
88 |
+
|
89 |
+
- May not match the full capabilities of larger models on complex reasoning tasks
|
90 |
+
- Limited context window compared to some larger models
|
91 |
+
- Performance on specialized domains not covered in training data may be reduced
|
92 |
+
|
93 |
+
## Usage
|
94 |
+
|
95 |
+
```python
|
96 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
97 |
+
|
98 |
+
# Load the model and tokenizer
|
99 |
+
model = AutoModelForCausalLM.from_pretrained("forge1825/FStudent")
|
100 |
+
tokenizer = AutoTokenizer.from_pretrained("forge1825/FStudent")
|
101 |
+
|
102 |
+
# Generate text
|
103 |
+
input_text = "Write a Python function to calculate the Fibonacci sequence:"
|
104 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
105 |
+
outputs = model.generate(**inputs, max_length=512)
|
106 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
107 |
+
```
|
108 |
+
|
109 |
+
### Quantized Usage
|
110 |
+
|
111 |
+
For more efficient inference, you can load the model with quantization:
|
112 |
+
|
113 |
+
```python
|
114 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
115 |
+
import torch
|
116 |
+
|
117 |
+
# 4-bit quantization configuration
|
118 |
+
quantization_config = BitsAndBytesConfig(
|
119 |
+
load_in_4bit=True,
|
120 |
+
bnb_4bit_compute_dtype=torch.float16
|
121 |
+
)
|
122 |
+
|
123 |
+
# Load the model with quantization
|
124 |
+
model = AutoModelForCausalLM.from_pretrained(
|
125 |
+
"forge1825/FStudent",
|
126 |
+
device_map="auto",
|
127 |
+
quantization_config=quantization_config
|
128 |
+
)
|
129 |
+
tokenizer = AutoTokenizer.from_pretrained("forge1825/FStudent")
|
130 |
+
```
|
131 |
+
|
132 |
+
## Training Details
|
133 |
+
|
134 |
+
- **Training Framework**: Hugging Face Transformers with PEFT
|
135 |
+
- **Optimizer**: AdamW
|
136 |
+
- **Learning Rate Schedule**: Linear warmup followed by linear decay
|
137 |
+
- **Training Hardware**: NVIDIA GPUs
|
138 |
+
- **Distillation Method**: Knowledge distillation with teacher-student architecture
|
139 |
+
- **Self-Study Mechanism**: Curiosity-driven exploration with hierarchical context
|
140 |
+
|
141 |
+
## Ethical Considerations
|
142 |
+
|
143 |
+
This model inherits the capabilities and limitations of its base model (Phi-3-mini-4k-instruct). While efforts have been made to ensure responsible behavior, the model may still:
|
144 |
+
|
145 |
+
- Generate incorrect or misleading information
|
146 |
+
- Produce biased content reflecting biases in the training data
|
147 |
+
- Create code that contains bugs or security vulnerabilities
|
148 |
+
|
149 |
+
Users should validate and review the model's outputs, especially for sensitive applications.
|
150 |
+
|
151 |
+
## Citation and Attribution
|
152 |
+
|
153 |
+
If you use this model in your research or applications, please cite:
|
154 |
+
|
155 |
+
```
|
156 |
+
@misc{forge1825_fstudent,
|
157 |
+
author = {Forge1825},
|
158 |
+
title = {FStudent: Distilled Phi-3 Model},
|
159 |
+
year = {2025},
|
160 |
+
publisher = {Hugging Face},
|
161 |
+
howpublished = {\url{https://huggingface.co/forge1825/FStudent}}
|
162 |
+
}
|
163 |
+
```
|
164 |
+
|
165 |
+
## Acknowledgements
|
166 |
+
|
167 |
+
- Microsoft for the Phi-3-mini-4k-instruct base model
|
168 |
+
- Hugging Face for the infrastructure and tools
|
169 |
+
- The creators of the Python code dataset used in training
|