seawolf2357 commited on
Commit
76e2b69
·
verified ·
1 Parent(s): cc66f4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -14
app.py CHANGED
@@ -1,6 +1,6 @@
1
  """
2
- 🔮 PHOENIX Retention Research Platform - PRODUCTION VERSION v1.4.1
3
- State Dict Direct Loading + Structure-Aware Burning + HuggingFace Hub
4
 
5
  ✅ State Dict Direct Loading
6
  ✅ Model Structure Pre-Analysis
@@ -11,7 +11,8 @@ State Dict Direct Loading + Structure-Aware Burning + HuggingFace Hub
11
  ✅ HuggingFace Hub Integration with Custom Code
12
  ✅ Comprehensive Evaluation
13
  ✅ Pre-upload Verification
14
- ✅ FIX: modeling_phoenix.py head_dim calculation
 
15
 
16
  VIDraft AI Research Lab
17
  """
@@ -63,7 +64,7 @@ Path(STORAGE_PATH).mkdir(parents=True, exist_ok=True)
63
  Path(VECTOR_DB_PATH).mkdir(parents=True, exist_ok=True)
64
  Path(MODELS_PATH).mkdir(parents=True, exist_ok=True)
65
 
66
- print(f"🚀 PHOENIX Platform v1.4.1 initialized on {DEVICE}")
67
  print(f"💾 Storage: {STORAGE_PATH}")
68
  print(f"🎯 Default Base Model: {DEFAULT_MODEL}")
69
  if HF_TOKEN:
@@ -1234,6 +1235,16 @@ class PhoenixModelForCausalLM(PhoenixPreTrainedModel):
1234
  if unexpected:
1235
  print(f" Unexpected (first 5): {unexpected[:5]}")
1236
 
 
 
 
 
 
 
 
 
 
 
1237
  # Retention 가중치 확인
1238
  retention_keys = [k for k in state_dict.keys() if 'retention' in k.lower()]
1239
  if retention_keys:
@@ -1293,6 +1304,16 @@ def save_phoenix_model_with_code(model, tokenizer, output_path, original_model_u
1293
 
1294
  print(f"\n💾 Saving PHOENIX model with custom code...")
1295
 
 
 
 
 
 
 
 
 
 
 
1296
  # 1. 모델과 토크나이저 저장
1297
  model.save_pretrained(output_path)
1298
  tokenizer.save_pretrained(output_path)
@@ -2534,18 +2555,19 @@ db = ExperimentDatabase(DB_PATH)
2534
  # =====================================================
2535
 
2536
  with gr.Blocks(
2537
- title="🔮 PHOENIX v1.4.1 - State Dict Direct Loading",
2538
  theme=gr.themes.Soft(),
2539
  ) as demo:
2540
 
2541
  gr.Markdown("""
2542
- # 🔮 PHOENIX Retention Platform v1.4.1
2543
 
2544
- **State Dict Direct Loading + Structure-Aware Burning**
2545
 
2546
- ✅ **NEW!** State Dict 직접 로드로 Retention 보존
 
2547
  ✅ Model Structure Pre-Analysis
2548
- ✅ Qwen3 Model Support
2549
  ✅ Zero-shot Conversion (No Dataset Required)
2550
  ✅ Optional Fine-tuning
2551
  ✅ GQA Support
@@ -2558,9 +2580,10 @@ with gr.Blocks(
2558
  with gr.Tabs():
2559
  with gr.Tab("🔥 Model Burning"):
2560
  gr.Markdown("""
2561
- ### 🔥 PHOENIX Model Burning v1.4.1
2562
 
2563
  **모델 구조를 먼저 분석한 후 변환합니다!**
 
2564
  **Hub 로드 시 State Dict 직접 로드로 Retention 보존!**
2565
  """)
2566
 
@@ -2671,18 +2694,22 @@ with gr.Blocks(
2671
  gr.Markdown(f"""
2672
  ---
2673
 
2674
- ## 🔥 PHOENIX Model Burning Platform v1.4.1
 
 
 
 
 
2675
 
2676
- ### What's New in v1.4.1
2677
  - ✅ **FIX: head_dim calculation** - Config 우선 사용
2678
  - ✅ **State Dict Direct Loading** - Hub 로드 시 Retention 가중치 보존
2679
  - ✅ **Model Structure Pre-Analysis** - 변환 전 구조 파악
2680
- - ✅ **Qwen3 Support** - Qwen3 모델 완벽 지원
2681
 
2682
  **HuggingFace Token**: {'✅ Connected' if HF_TOKEN else '❌ Not Found'}
2683
  **Default Model**: {DEFAULT_MODEL}
2684
 
2685
- **VIDraft AI Research Lab** | PHOENIX v1.4.1
2686
  """)
2687
 
2688
  if __name__ == "__main__":
 
1
  """
2
+ 🔮 PHOENIX Retention Research Platform - PRODUCTION VERSION v1.4.2
3
+ State Dict Direct Loading + Structure-Aware Burning + Embedding Tying Fix
4
 
5
  ✅ State Dict Direct Loading
6
  ✅ Model Structure Pre-Analysis
 
11
  ✅ HuggingFace Hub Integration with Custom Code
12
  ✅ Comprehensive Evaluation
13
  ✅ Pre-upload Verification
14
+ ✅ FIX: modeling_phoenix.py head_dim calculation (v1.4.1)
15
+ ✅ FIX: Embedding Tying (lm_head.weight) (v1.4.2)
16
 
17
  VIDraft AI Research Lab
18
  """
 
64
  Path(VECTOR_DB_PATH).mkdir(parents=True, exist_ok=True)
65
  Path(MODELS_PATH).mkdir(parents=True, exist_ok=True)
66
 
67
+ print(f"🚀 PHOENIX Platform v1.4.2 initialized on {DEVICE}")
68
  print(f"💾 Storage: {STORAGE_PATH}")
69
  print(f"🎯 Default Base Model: {DEFAULT_MODEL}")
70
  if HF_TOKEN:
 
1235
  if unexpected:
1236
  print(f" Unexpected (first 5): {unexpected[:5]}")
1237
 
1238
+ # ✅ FIX v1.4.2: lm_head.weight 처리 (Embedding Tying)
1239
+ if 'lm_head.weight' in missing:
1240
+ if hasattr(base_model.config, 'tie_word_embeddings') and base_model.config.tie_word_embeddings:
1241
+ print(f" ✅ Handling tied embeddings for lm_head")
1242
+ if hasattr(base_model, 'lm_head') and hasattr(base_model, 'model'):
1243
+ if hasattr(base_model.model, 'embed_tokens'):
1244
+ # lm_head.weight를 embed_tokens.weight로 설정
1245
+ base_model.lm_head.weight = base_model.model.embed_tokens.weight
1246
+ print(f" ✅ Tied lm_head.weight to embed_tokens.weight")
1247
+
1248
  # Retention 가중치 확인
1249
  retention_keys = [k for k in state_dict.keys() if 'retention' in k.lower()]
1250
  if retention_keys:
 
1304
 
1305
  print(f"\n💾 Saving PHOENIX model with custom code...")
1306
 
1307
+ # ✅ FIX v1.4.2: Embedding Tying 확인 및 처리
1308
+ if hasattr(model.config, 'tie_word_embeddings'):
1309
+ tie_embeddings = model.config.tie_word_embeddings
1310
+ print(f" 🔗 Embedding Tying: {tie_embeddings}")
1311
+
1312
+ if tie_embeddings and hasattr(model, 'lm_head') and hasattr(model, 'model'):
1313
+ # lm_head가 embed_tokens와 tied인지 확인
1314
+ if hasattr(model.model, 'embed_tokens'):
1315
+ print(f" ✅ Detected tied embeddings - will be handled by save_pretrained")
1316
+
1317
  # 1. 모델과 토크나이저 저장
1318
  model.save_pretrained(output_path)
1319
  tokenizer.save_pretrained(output_path)
 
2555
  # =====================================================
2556
 
2557
  with gr.Blocks(
2558
+ title="🔮 PHOENIX v1.4.2 - Embedding Tying Fix",
2559
  theme=gr.themes.Soft(),
2560
  ) as demo:
2561
 
2562
  gr.Markdown("""
2563
+ # 🔮 PHOENIX Retention Platform v1.4.2
2564
 
2565
+ **State Dict Direct Loading + Embedding Tying Fix**
2566
 
2567
+ ✅ **NEW v1.4.2!** Embedding Tying (lm_head) 자동 처리
2568
+ ✅ State Dict 직접 로드로 Retention 보존
2569
  ✅ Model Structure Pre-Analysis
2570
+ ✅ Qwen3 Model Support (완전 수정!)
2571
  ✅ Zero-shot Conversion (No Dataset Required)
2572
  ✅ Optional Fine-tuning
2573
  ✅ GQA Support
 
2580
  with gr.Tabs():
2581
  with gr.Tab("🔥 Model Burning"):
2582
  gr.Markdown("""
2583
+ ### 🔥 PHOENIX Model Burning v1.4.2
2584
 
2585
  **모델 구조를 먼저 분석한 후 변환합니다!**
2586
+ **Embedding Tying 자동 처리로 Qwen3 완벽 지원!**
2587
  **Hub 로드 시 State Dict 직접 로드로 Retention 보존!**
2588
  """)
2589
 
 
2694
  gr.Markdown(f"""
2695
  ---
2696
 
2697
+ ## 🔥 PHOENIX Model Burning Platform v1.4.2
2698
+
2699
+ ### What's New in v1.4.2
2700
+ - ✅ **FIX: Embedding Tying** - lm_head.weight 누락 문제 해결
2701
+ - ✅ **Qwen3-0.6B Generation Fixed** - 정상적인 텍스트 생성
2702
+ - ✅ **tie_word_embeddings 자동 처리** - 작은 모델 지원 개선
2703
 
2704
+ ### Previous (v1.4.1)
2705
  - ✅ **FIX: head_dim calculation** - Config 우선 사용
2706
  - ✅ **State Dict Direct Loading** - Hub 로드 시 Retention 가중치 보존
2707
  - ✅ **Model Structure Pre-Analysis** - 변환 전 구조 파악
 
2708
 
2709
  **HuggingFace Token**: {'✅ Connected' if HF_TOKEN else '❌ Not Found'}
2710
  **Default Model**: {DEFAULT_MODEL}
2711
 
2712
+ **VIDraft AI Research Lab** | PHOENIX v1.4.2
2713
  """)
2714
 
2715
  if __name__ == "__main__":