FlameF0X commited on
Commit
341d41e
·
verified ·
1 Parent(s): 859ab86

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -0
README.md CHANGED
@@ -7,6 +7,7 @@ datasets:
7
  language:
8
  - en
9
  library_name: transformers
 
10
  ---
11
 
12
  # Snowflake-G1-Tiny
@@ -178,6 +179,77 @@ None. Yet
178
  - Trained on FlameF0X/Mixture-of-Thoughts-2048T dataset
179
  - Inspired by GPT architecture with custom optimizations
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  ---
182
 
183
  *Model trained with PyTorch and mixed precision for optimal performance. For technical support or questions, please open an issue in the repository.*
 
7
  language:
8
  - en
9
  library_name: transformers
10
+ pipeline_tag: text-generation
11
  ---
12
 
13
  # Snowflake-G1-Tiny
 
179
  - Trained on FlameF0X/Mixture-of-Thoughts-2048T dataset
180
  - Inspired by GPT architecture with custom optimizations
181
 
182
+ ## Loading and Using the Model
183
+
184
+ You can load the SnowflakeCore-G1-Tiny model and generate text using the provided script or directly in your Python code.
185
+
186
+ ### Using the Provided Script
187
+
188
+ Run the following command from the project root:
189
+
190
+ ```bash
191
+ python GPT/generate_text.py
192
+ ```
193
+
194
+ You will be prompted to enter a prompt, and the model will generate text in response.
195
+
196
+ ### Loading the Model in Python
197
+
198
+ You can also load the model and tokenizer in your own Python scripts as follows:
199
+
200
+ ```python
201
+ from transformers import AutoModelForCausalLM, AutoTokenizer
202
+ import torch
203
+
204
+ # Load model and tokenizer
205
+ model = AutoModelForCausalLM.from_pretrained(
206
+ "FlameF0X/SnowflakeCore-G1-Tiny",
207
+ trust_remote_code=True,
208
+ force_download=True,
209
+ use_safetensors=True,
210
+ )
211
+ tokenizer = AutoTokenizer.from_pretrained(
212
+ "FlameF0X/SnowflakeCore-G1-Tiny",
213
+ trust_remote_code=True,
214
+ force_download=True,
215
+ use_safetensors=True,
216
+ )
217
+
218
+ def custom_greedy_generate(prompt, max_length=50):
219
+ model.eval()
220
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids
221
+ generated = input_ids
222
+ with torch.no_grad():
223
+ for _ in range(max_length):
224
+ outputs = model(input_ids=generated)
225
+ next_token_logits = outputs["logits"][:, -1, :]
226
+ next_token_id = torch.argmax(next_token_logits, dim=-1).unsqueeze(-1)
227
+ generated = torch.cat((generated, next_token_id), dim=1)
228
+ if next_token_id.item() == tokenizer.eos_token_id:
229
+ break
230
+ return tokenizer.decode(generated[0], skip_special_tokens=True)
231
+
232
+ # Example usage
233
+ prompt = "Once upon a time"
234
+ print(custom_greedy_generate(prompt))
235
+ ```
236
+
237
+ ## Demo
238
+
239
+ Example usage with the provided script:
240
+
241
+ ```
242
+ Enter a prompt: Hello, I am Alex and
243
+
244
+ Generated text: Hello, I am Alex andbourg Chip Chip Chip Chip Chip Chip Chip ChipCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCosCos
245
+ ```
246
+
247
+ **Explanation:**
248
+ - When you run the script, you will be prompted to enter a text prompt (e.g., `Hello, I am Alex and`).
249
+ - The model will then generate a continuation of your prompt, printing the result under "Generated text:".
250
+ - The output shown above is a sample from the model. The actual output may vary depending on the model's training, prompt, and generation settings.
251
+ - This demo demonstrates how the model can extend a given prompt with its learned language patterns. The repetitive or unusual output is typical for small or early-stage models and can be improved with further training or tuning.
252
+
253
  ---
254
 
255
  *Model trained with PyTorch and mixed precision for optimal performance. For technical support or questions, please open an issue in the repository.*