Keeby-smilyai commited on
Commit
0516e88
·
verified ·
1 Parent(s): 80eb187

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -225,8 +225,8 @@ from transformers import AutoTokenizer
225
 
226
  hf_tokenizer = AutoTokenizer.from_pretrained("gpt2")
227
 
228
- # Add custom tokens
229
- custom_tokens = ["<|im_start|>", "<|im_end|>"]
230
  hf_tokenizer.add_special_tokens({"additional_special_tokens": custom_tokens})
231
 
232
  # Save and reload as tokenizers format
@@ -235,7 +235,13 @@ hf_tokenizer.save_pretrained("./temp_tokenizer")
235
  tokenizer = Tokenizer.from_file("./temp_tokenizer/tokenizer.json")
236
 
237
  print(f"✅ Tokenizer created with vocab size: {tokenizer.get_vocab_size()}")
238
- print(f" Custom tokens: {custom_tokens}")
 
 
 
 
 
 
239
 
240
  eos_token_id = config.get('eos_token_id', 50256)
241
 
@@ -681,8 +687,10 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
681
  **Speed:** ⚡ Optimized with TF Functions
682
 
683
  **Twin Model:**
684
- - **SAM-X-1**: Reasoning model (with thinking)
685
- - **SAM-Z-1**: Fast model (YOU ARE HERE! 🎉)
 
 
686
 
687
  **Architecture:**
688
  - RoPE positional encoding
@@ -706,8 +714,10 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
706
  **Vocab:** {config['vocab_size']}
707
 
708
  **Twin Models:**
709
- - SAM-X-1: Reasoning model
710
- - SAM-Z-1: Direct response model
 
 
711
 
712
  **Features:**
713
  - RoPE positional encoding
 
225
 
226
  hf_tokenizer = AutoTokenizer.from_pretrained("gpt2")
227
 
228
+ # Add custom tokens to match model's vocab size
229
+ custom_tokens = ["<|im_start|>", "<|im_end|>", "<think>", "<think/>"]
230
  hf_tokenizer.add_special_tokens({"additional_special_tokens": custom_tokens})
231
 
232
  # Save and reload as tokenizers format
 
235
  tokenizer = Tokenizer.from_file("./temp_tokenizer/tokenizer.json")
236
 
237
  print(f"✅ Tokenizer created with vocab size: {tokenizer.get_vocab_size()}")
238
+ print(f" Custom tokens added: {custom_tokens}")
239
+ print(f" Model vocab size: {config.get('vocab_size', 'unknown')}")
240
+
241
+ # Verify vocab sizes match
242
+ if tokenizer.get_vocab_size() != config.get('vocab_size'):
243
+ print(f"⚠️ WARNING: Tokenizer vocab ({tokenizer.get_vocab_size()}) != Model vocab ({config.get('vocab_size')})")
244
+ print(f" Model was trained with these tokens, but SAM-Z-1 doesn't use <think> tags in generation")
245
 
246
  eos_token_id = config.get('eos_token_id', 50256)
247
 
 
687
  **Speed:** ⚡ Optimized with TF Functions
688
 
689
  **Twin Model:**
690
+ - **SAM-X-1**: Reasoning model (uses `<think>` tags)
691
+ - **SAM-Z-1**: Fast model (no thinking, direct answers! 🎉)
692
+
693
+ **Note:** Model includes `<think>` tokens in vocab but doesn't use them. Training used same tokenizer as SAM-X-1.
694
 
695
  **Architecture:**
696
  - RoPE positional encoding
 
714
  **Vocab:** {config['vocab_size']}
715
 
716
  **Twin Models:**
717
+ - SAM-X-1: Reasoning model (uses `<think>` tags)
718
+ - SAM-Z-1: Direct response model (no thinking)
719
+
720
+ **Note:** Vocab includes `<think>` tokens but model doesn't use them in generation.
721
 
722
  **Features:**
723
  - RoPE positional encoding