seawolf2357 commited on
Commit
bd3bb90
·
verified ·
1 Parent(s): b1fafe7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +154 -3
app.py CHANGED
@@ -1908,10 +1908,161 @@ def burn_model_zero_shot(
1908
  db = ExperimentDatabase(DB_PATH)
1909
 
1910
  # =====================================================
1911
- # Gradio UI (기존 코드와 동일)
1912
  # =====================================================
1913
 
1914
- # (이전과 동일한 Gradio 코드)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1915
 
1916
  if __name__ == "__main__":
1917
- print("PHOENIX v1.4.1 Ready!")
 
 
1908
  db = ExperimentDatabase(DB_PATH)
1909
 
1910
  # =====================================================
1911
+ # Gradio UI
1912
  # =====================================================
1913
 
1914
+ with gr.Blocks(
1915
+ title="🔮 PHOENIX v1.4 - State Dict Direct Loading",
1916
+ theme=gr.themes.Soft(),
1917
+ ) as demo:
1918
+
1919
+ gr.Markdown("""
1920
+ # 🔮 PHOENIX Retention Platform v1.4
1921
+
1922
+ **State Dict Direct Loading + Structure-Aware Burning**
1923
+
1924
+ ✅ **NEW!** State Dict 직접 로드로 Retention 보존
1925
+ ✅ Model Structure Pre-Analysis
1926
+ ✅ Qwen3 Model Support
1927
+ ✅ Zero-shot Conversion (No Dataset Required)
1928
+ ✅ Optional Fine-tuning
1929
+ ✅ GQA Support
1930
+ ✅ O(n) Complexity
1931
+ ✅ Auto Upload to HuggingFace Hub
1932
+
1933
+ ---
1934
+ """)
1935
+
1936
+ with gr.Tabs():
1937
+ with gr.Tab("🔥 Model Burning"):
1938
+ gr.Markdown("""
1939
+ ### 🔥 PHOENIX Model Burning v1.4
1940
+
1941
+ **모델 구조를 먼저 분석한 후 변환합니다!**
1942
+ **Hub 로드 시 State Dict 직접 로드로 Retention 보존!**
1943
+ """)
1944
+
1945
+ with gr.Row():
1946
+ with gr.Column(scale=1):
1947
+ burn_model_url = gr.Textbox(
1948
+ label="🔗 Model URL",
1949
+ value=DEFAULT_MODEL,
1950
+ placeholder="Qwen/Qwen3-0.6B"
1951
+ )
1952
+ burn_hierarchical = gr.Checkbox(value=True, label="Hierarchical Retention")
1953
+
1954
+ burn_output_name = gr.Textbox(
1955
+ label="💾 Output Name",
1956
+ placeholder="phoenix_my_model"
1957
+ )
1958
+
1959
+ gr.Markdown("---")
1960
+ gr.Markdown("### 🌐 HuggingFace Hub Upload")
1961
+
1962
+ burn_upload_hub = gr.Checkbox(value=True, label="📤 Upload to Hub")
1963
+ burn_hub_repo = gr.Textbox(label="📦 Repo Name (optional)")
1964
+ burn_hub_private = gr.Checkbox(value=True, label="🔒 Private")
1965
+
1966
+ gr.Markdown("---")
1967
+ gr.Markdown("### 📊 Dataset (Optional)")
1968
+
1969
+ burn_dataset = gr.Textbox(label="📁 Dataset Path")
1970
+ burn_use_finetuning = gr.Checkbox(value=False, label="🚀 Enable Fine-tuning")
1971
+
1972
+ with gr.Accordion("⚙️ Fine-tuning Config", open=False):
1973
+ burn_epochs = gr.Slider(1, 5, 1, step=1, label="Epochs")
1974
+ burn_batch = gr.Slider(1, 16, 4, step=1, label="Batch Size")
1975
+ burn_lr = gr.Number(value=5e-5, label="Learning Rate")
1976
+ burn_max_steps = gr.Slider(10, 500, 100, step=10, label="Max Steps")
1977
+
1978
+ burn_btn = gr.Button("🔥 Burn Model", variant="primary", size="lg")
1979
+
1980
+ with gr.Column(scale=2):
1981
+ burn_output = gr.Markdown()
1982
+ burn_plot = gr.Plot()
1983
+
1984
+ burn_btn.click(
1985
+ burn_phoenix_model_ui,
1986
+ [
1987
+ burn_model_url, burn_hierarchical, burn_dataset, burn_output_name,
1988
+ burn_use_finetuning, burn_epochs, burn_batch, burn_lr, burn_max_steps,
1989
+ burn_upload_hub, burn_hub_repo, burn_hub_private,
1990
+ ],
1991
+ [burn_output, burn_plot]
1992
+ )
1993
+
1994
+ with gr.Tab("📊 Burning History"):
1995
+ gr.Markdown("### 📊 Model Burning History")
1996
+
1997
+ with gr.Row():
1998
+ with gr.Column(scale=1):
1999
+ hist_btn = gr.Button("📊 Load History", variant="primary")
2000
+
2001
+ with gr.Column(scale=2):
2002
+ hist_output = gr.Markdown()
2003
+ hist_plot = gr.Plot()
2004
+
2005
+ hist_btn.click(view_burning_history, outputs=[hist_output, hist_plot])
2006
+
2007
+ with gr.Tab("🧪 Model Validation"):
2008
+ gr.Markdown("### 🧪 PHOENIX 모델 검증")
2009
+
2010
+ with gr.Row():
2011
+ with gr.Column(scale=1):
2012
+ val_source = gr.Radio(
2013
+ choices=["hub", "local"],
2014
+ value="hub",
2015
+ label="📍 Model Source"
2016
+ )
2017
+
2018
+ val_path = gr.Textbox(
2019
+ label="🔗 Model Path/URL",
2020
+ value="seawolf2357/phoenix-Qwen3-0.6B",
2021
+ placeholder="seawolf2357/phoenix-model"
2022
+ )
2023
+
2024
+ val_prompts = gr.Textbox(
2025
+ label="📝 Test Prompts (one per line)",
2026
+ lines=5,
2027
+ value="The future of AI is\nOnce upon a time\nIn machine learning,",
2028
+ )
2029
+
2030
+ with gr.Row():
2031
+ val_max_tokens = gr.Slider(16, 256, 64, step=16, label="Max Tokens")
2032
+ val_temp = gr.Slider(0.1, 2.0, 0.7, step=0.1, label="Temperature")
2033
+
2034
+ val_verify_retention = gr.Checkbox(value=True, label="🔍 Verify Retention")
2035
+
2036
+ val_btn = gr.Button("🧪 Validate Model", variant="primary", size="lg")
2037
+
2038
+ with gr.Column(scale=2):
2039
+ val_output = gr.Markdown()
2040
+ val_plot = gr.Plot()
2041
+
2042
+ val_btn.click(
2043
+ validate_phoenix_model,
2044
+ [val_source, val_path, val_prompts, val_max_tokens,
2045
+ val_temp, val_verify_retention],
2046
+ [val_output, val_plot]
2047
+ )
2048
+
2049
+ gr.Markdown(f"""
2050
+ ---
2051
+
2052
+ ## 🔥 PHOENIX Model Burning Platform v1.4
2053
+
2054
+ ### What's New in v1.4
2055
+ - ✅ **State Dict Direct Loading** - Hub 로드 시 Retention 가중치 보존
2056
+ - ✅ **Fixed Hub Loading** - Custom Code에서 올바른 가중치 로드
2057
+ - ✅ **Model Structure Pre-Analysis** - 변환 전 구조 파악
2058
+ - ✅ **Qwen3 Support** - Qwen3 모델 완벽 지원
2059
+
2060
+ **HuggingFace Token**: {'✅ Connected' if HF_TOKEN else '❌ Not Found'}
2061
+ **Default Model**: {DEFAULT_MODEL}
2062
+
2063
+ **VIDraft AI Research Lab** | PHOENIX v1.4
2064
+ """)
2065
 
2066
  if __name__ == "__main__":
2067
+ demo.queue(max_size=20)
2068
+ demo.launch(server_name="0.0.0.0", server_port=7860, share=False)