Spaces:
Sleeping
Sleeping
leaderboard
Browse files- app.py +27 -5
- leaderboard.json +1 -1
app.py
CHANGED
|
@@ -12,6 +12,7 @@ from spellchecker import SpellChecker
|
|
| 12 |
import difflib
|
| 13 |
import torch
|
| 14 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
|
| 15 |
|
| 16 |
# ======================== 新增:WAC-GEC导入 ========================
|
| 17 |
try:
|
|
@@ -423,6 +424,13 @@ def load_leaderboard_data():
|
|
| 423 |
try:
|
| 424 |
with open(json_path, 'r', encoding='utf-8') as f:
|
| 425 |
data = json.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
return pd.DataFrame(data)
|
| 427 |
except Exception as e:
|
| 428 |
print(f"Error loading leaderboard: {e}")
|
|
@@ -774,8 +782,8 @@ with demo:
|
|
| 774 |
gr.Markdown("## BD-toolkit轻量化Demo展示")
|
| 775 |
|
| 776 |
# 模型可用性提示
|
| 777 |
-
model_status = "✅
|
| 778 |
-
model_status += " | ✅
|
| 779 |
gr.Markdown(f"**模型状态**: {model_status}")
|
| 780 |
|
| 781 |
with gr.Row():
|
|
@@ -792,8 +800,8 @@ with demo:
|
|
| 792 |
)
|
| 793 |
|
| 794 |
model_choice = gr.Dropdown(
|
| 795 |
-
choices=["deepseek-r1-distill-llama-8b"
|
| 796 |
-
value="
|
| 797 |
label="🤖 选择模型",
|
| 798 |
info="DeepSeek: 全面纠错 | WAC-GEC: 语法+空白符纠正(本地模型)"
|
| 799 |
)
|
|
@@ -804,7 +812,8 @@ with demo:
|
|
| 804 |
value=0.1,
|
| 805 |
step=0.1,
|
| 806 |
label="🌡️ Temperature",
|
| 807 |
-
info="仅对DeepSeek生效"
|
|
|
|
| 808 |
)
|
| 809 |
|
| 810 |
max_samples = gr.Slider(
|
|
@@ -826,6 +835,19 @@ with demo:
|
|
| 826 |
|
| 827 |
download_file = gr.File(label="📥 下载去噪后的数据集")
|
| 828 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 829 |
# 颜色对比预览区域
|
| 830 |
gr.Markdown("### 🎨 去噪效果对比预览")
|
| 831 |
gr.Markdown("""
|
|
|
|
| 12 |
import difflib
|
| 13 |
import torch
|
| 14 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 15 |
+
import hashlib
|
| 16 |
|
| 17 |
# ======================== 新增:WAC-GEC导入 ========================
|
| 18 |
try:
|
|
|
|
| 424 |
try:
|
| 425 |
with open(json_path, 'r', encoding='utf-8') as f:
|
| 426 |
data = json.load(f)
|
| 427 |
+
|
| 428 |
+
# Replace ID with hash based on Benchmark
|
| 429 |
+
for item in data:
|
| 430 |
+
benchmark = item['Benchmark']
|
| 431 |
+
hash_object = hashlib.md5(benchmark.encode())
|
| 432 |
+
item['ID'] = hash_object.hexdigest()[:8] # Use first 8 hex digits for brevity
|
| 433 |
+
|
| 434 |
return pd.DataFrame(data)
|
| 435 |
except Exception as e:
|
| 436 |
print(f"Error loading leaderboard: {e}")
|
|
|
|
| 782 |
gr.Markdown("## BD-toolkit轻量化Demo展示")
|
| 783 |
|
| 784 |
# 模型可用性提示
|
| 785 |
+
model_status = "✅ WAC-GEC: " + ("可用" if WAC_GEC_AVAILABLE else "未安装")
|
| 786 |
+
model_status += " | ✅ DeepSeek-R1: " + ("已配置" if DEEPSEEK_API_KEY else "未配置API密钥")
|
| 787 |
gr.Markdown(f"**模型状态**: {model_status}")
|
| 788 |
|
| 789 |
with gr.Row():
|
|
|
|
| 800 |
)
|
| 801 |
|
| 802 |
model_choice = gr.Dropdown(
|
| 803 |
+
choices=["WAC-GEC", "deepseek-r1-distill-llama-8b"],
|
| 804 |
+
value="WAC-GEC",
|
| 805 |
label="🤖 选择模型",
|
| 806 |
info="DeepSeek: 全面纠错 | WAC-GEC: 语法+空白符纠正(本地模型)"
|
| 807 |
)
|
|
|
|
| 812 |
value=0.1,
|
| 813 |
step=0.1,
|
| 814 |
label="🌡️ Temperature",
|
| 815 |
+
info="仅对DeepSeek生效",
|
| 816 |
+
interactive=False # 默认不可交互(因为默认选择WAC-GEC)
|
| 817 |
)
|
| 818 |
|
| 819 |
max_samples = gr.Slider(
|
|
|
|
| 835 |
|
| 836 |
download_file = gr.File(label="📥 下载去噪后的数据集")
|
| 837 |
|
| 838 |
+
# 添加交互逻辑:根据模型选择动态启用/禁用temperature滑块
|
| 839 |
+
def update_temperature_interactive(model):
|
| 840 |
+
if model == "deepseek-r1-distill-llama-8b":
|
| 841 |
+
return gr.update(interactive=True, info="调整生成的随机性")
|
| 842 |
+
else:
|
| 843 |
+
return gr.update(interactive=False, info="WAC-GEC模型不支持temperature参数")
|
| 844 |
+
|
| 845 |
+
model_choice.change(
|
| 846 |
+
fn=update_temperature_interactive,
|
| 847 |
+
inputs=[model_choice],
|
| 848 |
+
outputs=[temperature]
|
| 849 |
+
)
|
| 850 |
+
|
| 851 |
# 颜色对比预览区域
|
| 852 |
gr.Markdown("### 🎨 去噪效果对比预览")
|
| 853 |
gr.Markdown("""
|
leaderboard.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
"ID": 1,
|
| 4 |
"Category": "RA",
|
| 5 |
"Benchmark": "ARC_deepseek_r1_denoising",
|
| 6 |
-
"WAR": 0.
|
| 7 |
"SED": 0.67,
|
| 8 |
"Download": "[下载](https://huggingface.co/datasets/lllouo/BD-benchmarks/tree/main/ARC/arc_deepseek_r1_denoising)"
|
| 9 |
},
|
|
|
|
| 3 |
"ID": 1,
|
| 4 |
"Category": "RA",
|
| 5 |
"Benchmark": "ARC_deepseek_r1_denoising",
|
| 6 |
+
"WAR": 0.00,
|
| 7 |
"SED": 0.67,
|
| 8 |
"Download": "[下载](https://huggingface.co/datasets/lllouo/BD-benchmarks/tree/main/ARC/arc_deepseek_r1_denoising)"
|
| 9 |
},
|