Update with README
Browse files
README.md
CHANGED
@@ -1,199 +1,147 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
|
|
9 |
|
|
|
|
|
10 |
|
|
|
|
|
11 |
|
12 |
-
##
|
|
|
13 |
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
|
|
|
|
29 |
|
30 |
-
|
|
|
31 |
|
32 |
-
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
|
37 |
|
38 |
-
|
|
|
|
|
39 |
|
40 |
-
###
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
|
|
|
|
45 |
|
46 |
-
|
|
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
###
|
53 |
|
54 |
-
|
55 |
|
56 |
-
[More Information Needed]
|
57 |
|
58 |
-
|
59 |
|
60 |
-
|
61 |
|
62 |
-
[More Information Needed]
|
63 |
|
64 |
-
|
|
|
65 |
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
## How to Get Started with the Model
|
71 |
-
|
72 |
-
Use the code below to get started with the model.
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
-
|
78 |
-
### Training Data
|
79 |
-
|
80 |
-
<!-- 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. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
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).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- gpt
|
5 |
+
- distillation
|
6 |
+
- mobile
|
7 |
+
- embedded
|
8 |
+
- onnx
|
9 |
+
license: cc-by-nc-4.0
|
10 |
+
datasets:
|
11 |
+
- custom
|
12 |
+
- web
|
13 |
+
language: en
|
14 |
+
widget:
|
15 |
+
- text: "In order to make pancakes, you need to"
|
16 |
+
- text: "Once upon a time"
|
17 |
---
|
18 |
|
19 |
+
<p align="center">
|
20 |
+
<img src="logo.png" alt="IJK Technology" width="150">
|
21 |
+
</p>
|
22 |
+
|
23 |
+
<h1 align="center">IJK Technology – ByteGPT-r1</h1>
|
24 |
+
|
25 |
+
|
26 |
+
**ByteGPT-r1** is a distilled version of DeepSeek's QWEN 1.5B model, optimized specifically for mobile and edge computing environments. It maintains impressive language capabilities while being designed for compute- and memory-constrained devices.
|
27 |
+
|
28 |
+
## 🚀 Overview
|
29 |
+
- **Model Type:** Distilled GPT-style causal language model
|
30 |
+
- **Base Model:** DeepSeek's QWEN 1.5B
|
31 |
+
- **Intended Use:** Edge devices, mobile phones, embedded systems
|
32 |
+
- **Size:** Optimized for mobile deployment
|
33 |
+
- **Training:** Knowledge distillation from QWEN 1.5B
|
34 |
+
|
35 |
+
## 🧠 Why ByteGPT-r1?
|
36 |
+
ByteGPT-r1 offers several advantages for mobile and edge deployment:
|
37 |
|
38 |
+
1. **Efficient Knowledge Distillation:**
|
39 |
+
Carefully distilled from DeepSeek's QWEN 1.5B model to preserve capabilities while reducing computational requirements.
|
40 |
|
41 |
+
2. **Mobile-First Design:**
|
42 |
+
Architected specifically for the constraints of mobile devices, with optimizations for both inference speed and memory usage.
|
43 |
|
44 |
+
3. **Balanced Performance:**
|
45 |
+
Maintains a good balance between model size and language generation capabilities, making it practical for real-world mobile applications.
|
46 |
|
47 |
+
## 💡 Future Plans
|
48 |
+
This model is part of our ongoing effort to bring powerful language models to edge devices. Upcoming releases will include:
|
49 |
|
50 |
+
- **Specialized Variants:** Domain-specific versions optimized for particular use cases
|
51 |
+
- **Further Optimizations:** Continued improvements in efficiency and performance
|
52 |
+
- **Benchmark Results:** Comparative performance on various mobile devices
|
53 |
+
- **Integration Examples:** More code samples for popular mobile frameworks
|
54 |
|
55 |
+
## 💻 Usage
|
56 |
|
57 |
+
### **Quick Start (with `transformers`):**
|
58 |
+
```python
|
59 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
60 |
|
61 |
+
model = AutoModelForCausalLM.from_pretrained("ijktech/ByteGPT-r1", trust_remote_code=True)
|
62 |
+
tokenizer = AutoTokenizer.from_pretrained("ijktech/ByteGPT-r1")
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
+
input_text = "What is the capital of France?"
|
65 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
66 |
+
outputs = model.generate(**inputs, max_new_tokens=100)
|
67 |
|
68 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
69 |
+
```
|
70 |
|
71 |
+
### Tokenizer
|
|
|
|
|
72 |
|
73 |
+
The tokenizer is compatible with AutoTokenizer from Hugging Face:
|
74 |
|
75 |
+
```python
|
76 |
+
tokenizer = AutoTokenizer.from_pretrained("ijktech/ByteGPT-r1")
|
77 |
+
```
|
78 |
|
79 |
+
### ONNX
|
80 |
|
81 |
+
The model is also available in ONNX format, and can be used with the ONNX Runtime:
|
82 |
|
83 |
+
```python
|
84 |
+
import onnxruntime as ort
|
85 |
+
import numpy as np
|
86 |
|
87 |
+
# Create ONNX Runtime session
|
88 |
+
ort_session = ort.InferenceSession("model.onnx")
|
89 |
|
90 |
+
# Helper function to generate text using the ONNX model
|
91 |
+
def generate_with_onnx(prompt_ids, max_new_tokens=50, temperature=1.0):
|
92 |
+
input_ids = prompt_ids.clone()
|
93 |
+
|
94 |
+
for _ in range(max_new_tokens):
|
95 |
+
# Get the last block_size tokens if input is too long
|
96 |
+
if input_ids.shape[1] > model.block_size:
|
97 |
+
input_ids = input_ids[:, -model.block_size:]
|
98 |
+
|
99 |
+
# Run inference
|
100 |
+
ort_inputs = {
|
101 |
+
'input': input_ids.cpu().numpy()
|
102 |
+
}
|
103 |
+
logits = ort_session.run(None, ort_inputs)[0]
|
104 |
+
|
105 |
+
# Get predictions for the next token
|
106 |
+
logits = torch.from_numpy(logits)
|
107 |
+
logits = logits[:, -1, :] # Only take the last token's predictions
|
108 |
+
|
109 |
+
# Apply temperature
|
110 |
+
if temperature != 1.0:
|
111 |
+
logits = logits / temperature
|
112 |
+
|
113 |
+
# Sample from the distribution
|
114 |
+
probs = torch.nn.functional.softmax(logits, dim=-1)
|
115 |
+
next_token = torch.multinomial(probs, num_samples=1)
|
116 |
+
|
117 |
+
# Append the new token
|
118 |
+
input_ids = torch.cat([input_ids, next_token], dim=1)
|
119 |
+
|
120 |
+
return input_ids
|
121 |
|
122 |
+
# Test the generation
|
123 |
+
prompt = "Hello"
|
124 |
+
prompt_ids = tok(prompt, return_tensors="pt")["input_ids"]
|
125 |
+
generated_ids = generate_with_onnx(prompt_ids)
|
126 |
+
generated_text = tok.decode(generated_ids[0], skip_special_tokens=True)
|
127 |
+
print(f"Generated text: {generated_text}")
|
128 |
+
#Generated text: Hello there! How can I assist you today? I'm a helpful AI assistant trained to provide information and answer questions on a wide range of topics.
|
129 |
+
```
|
130 |
|
131 |
+
### Android Usage
|
132 |
|
133 |
+
Coming Soon!
|
134 |
|
|
|
135 |
|
136 |
+
### iOS Usage
|
137 |
|
138 |
+
Coming Soon!
|
139 |
|
|
|
140 |
|
141 |
+
## 📜 License
|
142 |
+
📍 **CC-BY-NC-4.0**: Free for non-commercial use.
|
143 |
|
144 |
+
💼 **Commercial Use**: Contact IJK Technology Ltd for licensing at [james@ijktech.com](mailto:[email protected]).
|
145 |
|
146 |
+
## 🛠️ About IJK Technology Ltd
|
147 |
+
IJK Technology Ltd (IJKTech) develops innovative machine learning models optimized for on-device inference. Our focus is on efficiency, privacy, and usability across mobile and embedded platforms.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|