Add 2 files
Browse files- README.md +6 -4
- index.html +827 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: gray
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: zhengliu
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: blue
|
5 |
colorTo: gray
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,827 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="zh-CN">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>知识蒸馏专家系统</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.fade-in {
|
11 |
+
animation: fadeIn 0.5s ease-in-out;
|
12 |
+
}
|
13 |
+
@keyframes fadeIn {
|
14 |
+
from { opacity: 0; transform: translateY(10px); }
|
15 |
+
to { opacity: 1; transform: translateY(0); }
|
16 |
+
}
|
17 |
+
.answer-tab.active {
|
18 |
+
@apply border-blue-500 text-blue-600;
|
19 |
+
}
|
20 |
+
.progress-bar {
|
21 |
+
transition: width 0.3s ease;
|
22 |
+
}
|
23 |
+
.code-box {
|
24 |
+
font-family: 'Courier New', monospace;
|
25 |
+
@apply bg-gray-100 p-3 rounded overflow-x-auto text-sm;
|
26 |
+
}
|
27 |
+
.search-result {
|
28 |
+
@apply p-3 border-l-4 border-blue-200 hover:border-blue-500 transition;
|
29 |
+
}
|
30 |
+
</style>
|
31 |
+
</head>
|
32 |
+
<body class="bg-gray-50 min-h-screen">
|
33 |
+
<div class="container mx-auto px-4 py-8">
|
34 |
+
<!-- Header -->
|
35 |
+
<header class="mb-10">
|
36 |
+
<h1 class="text-3xl font-bold text-center text-gray-800 mb-2">
|
37 |
+
<i class="fas fa-brain mr-2 text-blue-500"></i> 知识蒸馏专家系统
|
38 |
+
</h1>
|
39 |
+
<p class="text-center text-gray-600 max-w-2xl mx-auto">
|
40 |
+
通过真实搜索引擎API和LLM模型多轮迭代优化答案
|
41 |
+
</p>
|
42 |
+
</header>
|
43 |
+
|
44 |
+
<!-- Main Workflow Area -->
|
45 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
46 |
+
<!-- Input Section -->
|
47 |
+
<div class="bg-white rounded-xl shadow-md p-6 col-span-1">
|
48 |
+
<h2 class="text-xl font-semibold mb-4 text-gray-800">
|
49 |
+
<i class="fas fa-question-circle mr-2 text-blue-500"></i> 查询参数
|
50 |
+
</h2>
|
51 |
+
|
52 |
+
<div class="mb-4">
|
53 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">LLM模型选择</label>
|
54 |
+
<div class="grid grid-cols-2 gap-2">
|
55 |
+
<button id="gemini-btn" class="model-btn active py-2 px-4 rounded-lg bg-blue-100 text-blue-700 border border-blue-300">
|
56 |
+
<i class="fab fa-google mr-2"></i>Gemini Pro
|
57 |
+
</button>
|
58 |
+
<button id="gpt-btn" class="model-btn py-2 px-4 rounded-lg bg-green-100 text-green-700 border border-green-300">
|
59 |
+
<i class="fas fa-robot mr-2"></i>GPT-4
|
60 |
+
</button>
|
61 |
+
<button id="claude-btn" class="model-btn py-2 px-4 rounded-lg bg-purple-100 text-purple-700 border border-purple-300">
|
62 |
+
<i class="fas fa-leaf mr-2"></i>Claude
|
63 |
+
</button>
|
64 |
+
<button id="deepseek-btn" class="model-btn py-2 px-4 rounded-lg bg-gray-100 text-gray-700 border border-gray-300">
|
65 |
+
<i class="fas fa-search mr-2"></i>DeepSeek
|
66 |
+
</button>
|
67 |
+
</div>
|
68 |
+
</div>
|
69 |
+
|
70 |
+
<div class="mb-4">
|
71 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">搜索引擎API</label>
|
72 |
+
<select id="search-engine" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
73 |
+
<option value="google">Google 定制搜索</option>
|
74 |
+
<option value="bing">Bing 搜索 API</option>
|
75 |
+
<option value="serper">Serper API</option>
|
76 |
+
</select>
|
77 |
+
</div>
|
78 |
+
|
79 |
+
<div class="mb-4">
|
80 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">搜索深度</label>
|
81 |
+
<select id="search-depth" class="w-full p-2 border border-gray-300 rounded-md">
|
82 |
+
<option value="3">基础 (3个结果)</option>
|
83 |
+
<option value="5" selected>标准 (5个结果)</option>
|
84 |
+
<option value="10">深度 (10个结果)</option>
|
85 |
+
</select>
|
86 |
+
</div>
|
87 |
+
|
88 |
+
<div class="mb-6">
|
89 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">您的问题</label>
|
90 |
+
<textarea id="question-input" rows="5" class="w-full p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500" placeholder="例如:什么是知识蒸馏?如何提高蒸馏效率?"></textarea>
|
91 |
+
</div>
|
92 |
+
|
93 |
+
<button id="start-btn" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-md transition duration-200 flex items-center justify-center">
|
94 |
+
<i class="fas fa-play mr-2"></i> 启动知识蒸馏
|
95 |
+
</button>
|
96 |
+
</div>
|
97 |
+
|
98 |
+
<!-- Progress & Results Section -->
|
99 |
+
<div class="bg-white rounded-xl shadow-md p-6 col-span-2">
|
100 |
+
<div id="progress-container" class="hidden mb-6">
|
101 |
+
<h2 class="text-xl font-semibold mb-4 text-gray-800">
|
102 |
+
<i class="fas fa-cogs mr-2 text-blue-500"></i> 知识蒸馏中...
|
103 |
+
</h2>
|
104 |
+
<div class="mb-2 flex justify-between text-sm text-gray-600">
|
105 |
+
<span>当前状态</span>
|
106 |
+
<span id="current-step">准备启动知识蒸馏流程</span>
|
107 |
+
</div>
|
108 |
+
<div class="w-full bg-gray-200 rounded-full h-2.5 mb-4">
|
109 |
+
<div id="progress-bar" class="progress-bar h-2.5 rounded-full bg-blue-600" style="width: 0%"></div>
|
110 |
+
</div>
|
111 |
+
<div class="text-right">
|
112 |
+
<span id="progress-percent" class="text-sm font-medium">0%</span>
|
113 |
+
</div>
|
114 |
+
|
115 |
+
<div id="process-steps" class="mt-4 space-y-3">
|
116 |
+
<!-- 流程步骤将在这里动态生成 -->
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
|
120 |
+
<div id="results-container" class="hidden">
|
121 |
+
<h2 class="text-xl font-semibold mb-4 text-gray-800">
|
122 |
+
<i class="fas fa-chart-line mr-2 text-blue-500"></i> 蒸馏结果分析
|
123 |
+
</h2>
|
124 |
+
|
125 |
+
<!-- Tab Navigation -->
|
126 |
+
<div class="border-b border-gray-200 mb-4">
|
127 |
+
<ul class="flex flex-wrap -mb-px" id="answer-tabs">
|
128 |
+
<li class="mr-2">
|
129 |
+
<button class="answer-tab active inline-block p-4 border-b-2 rounded-t-lg" data-tab="v1">
|
130 |
+
<i class="fas fa-vial mr-1"></i> 初始答案
|
131 |
+
</button>
|
132 |
+
</li>
|
133 |
+
<li class="mr-2">
|
134 |
+
<button class="answer-tab inline-block p-4 border-b-2 rounded-t-lg" data-tab="v2">
|
135 |
+
<i class="fas fa-filter mr-1"></i> 搜索增强版
|
136 |
+
</button>
|
137 |
+
</li>
|
138 |
+
<li class="mr-2">
|
139 |
+
<button class="answer-tab inline-block p-4 border-b-2 rounded-t-lg" data-tab="v3">
|
140 |
+
<i class="fas fa-star mr-1"></i> 最终优化版
|
141 |
+
</button>
|
142 |
+
</li>
|
143 |
+
<li class="mr-2">
|
144 |
+
<button class="answer-tab inline-block p-4 border-b-2 rounded-t-lg" data-tab="search">
|
145 |
+
<i class="fas fa-search mr-1"></i> 搜索结果
|
146 |
+
</button>
|
147 |
+
</li>
|
148 |
+
<li>
|
149 |
+
<button class="answer-tab inline-block p-4 border-b-2 rounded-t-lg" data-tab="comparison">
|
150 |
+
<i class="fas fa-exchange-alt mr-1"></i> 质量对比
|
151 |
+
</button>
|
152 |
+
</li>
|
153 |
+
</ul>
|
154 |
+
</div>
|
155 |
+
|
156 |
+
<!-- Tab Content -->
|
157 |
+
<div id="v1-tab" class="answer-content active p-4 bg-gray-50 rounded-b-lg">
|
158 |
+
<div class="flex justify-between items-start mb-2">
|
159 |
+
<h3 class="font-medium text-gray-700">原始LLM生成答案 (无搜索增强)</h3>
|
160 |
+
<span id="v1-model" class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded">模型: Gemini Pro</span>
|
161 |
+
</div>
|
162 |
+
<div id="v1-answer" class="prose max-w-none text-gray-800 space-y-3">
|
163 |
+
<p class="text-gray-500 italic">点击"启动知识蒸馏"按钮获取首个版本答案...</p>
|
164 |
+
</div>
|
165 |
+
<div class="mt-4 grid grid-cols-2 gap-4">
|
166 |
+
<div>
|
167 |
+
<h4 class="text-sm font-medium text-gray-700 mb-1">响应时间</h4>
|
168 |
+
<p class="text-sm text-gray-600"><span id="v1-time">-</span> ms</p>
|
169 |
+
</div>
|
170 |
+
<div>
|
171 |
+
<h4 class="text-sm font-medium text-gray-700 mb-1">置信度</h4>
|
172 |
+
<div class="flex items-center">
|
173 |
+
<div class="w-full bg-gray-200 rounded-full h-2">
|
174 |
+
<div id="v1-confidence" class="h-2 rounded-full bg-yellow-500" style="width: 0%"></div>
|
175 |
+
</div>
|
176 |
+
<span id="v1-confidence-text" class="ml-2 text-sm font-medium">-</span>
|
177 |
+
</div>
|
178 |
+
</div>
|
179 |
+
</div>
|
180 |
+
</div>
|
181 |
+
|
182 |
+
<div id="v2-tab" class="answer-content hidden p-4 bg-gray-50 rounded-b-lg">
|
183 |
+
<div class="flex justify-between items-start mb-2">
|
184 |
+
<h3 class="font-medium text-gray-700">搜索增强优化答案</h3>
|
185 |
+
<div>
|
186 |
+
<span id="v2-model" class="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">模型: Gemini Pro</span>
|
187 |
+
<span id="v2-engine" class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded ml-1">搜索: Google</span>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
+
<div id="v2-answer" class="prose max-w-none text-gray-800 space-y-3">
|
191 |
+
<p class="text-gray-500 italic">正在通过搜索引擎优化首轮答案...</p>
|
192 |
+
</div>
|
193 |
+
<div class="mt-4 grid grid-cols-2 gap-4">
|
194 |
+
<div>
|
195 |
+
<h4 class="text-sm font-medium text-gray-700 mb-1">响应时间</h4>
|
196 |
+
<p class="text-sm text-gray-600"><span id="v2-time">-</span> ms</p>
|
197 |
+
</div>
|
198 |
+
<div>
|
199 |
+
<h4 class="text-sm font-medium text-gray-700 mb-1">置信度提升</h4>
|
200 |
+
<div class="flex items-center">
|
201 |
+
<div class="w-full bg-gray-200 rounded-full h-2">
|
202 |
+
<div id="v2-confidence" class="h-2 rounded-full bg-green-500" style="width: 0%"></div>
|
203 |
+
</div>
|
204 |
+
<span id="v2-confidence-text" class="ml-2 text-sm font-medium">-</span>
|
205 |
+
</div>
|
206 |
+
</div>
|
207 |
+
</div>
|
208 |
+
</div>
|
209 |
+
|
210 |
+
<div id="v3-tab" class="answer-content hidden p-4 bg-gray-50 rounded-b-lg">
|
211 |
+
<div class="flex justify-between items-start mb-2">
|
212 |
+
<h3 class="font-medium text-gray-700">最终优化答案</h3>
|
213 |
+
<div>
|
214 |
+
<span id="v3-model" class="text-xs bg-purple-100 text-purple-800 px-2 py-1 rounded">模型: Gemini Pro</span>
|
215 |
+
<span id="v3-engine" class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded ml-1">搜索: Google</span>
|
216 |
+
</div>
|
217 |
+
</div>
|
218 |
+
<div id="v3-answer" class="prose max-w-none text-gray-800 space-y-3">
|
219 |
+
<p class="text-gray-500 italic">正在进行最终迭代优化...</p>
|
220 |
+
</div>
|
221 |
+
<div class="mt-4 grid grid-cols-2 gap-4">
|
222 |
+
<div>
|
223 |
+
<h4 class="text-sm font-medium text-gray-700 mb-1">响应时间</h4>
|
224 |
+
<p class="text-sm text-gray-600"><span id="v3-time">-</span> ms</p>
|
225 |
+
</div>
|
226 |
+
<div>
|
227 |
+
<h4 class="text-sm font-medium text-gray-700 mb-1">最终置信度</h4>
|
228 |
+
<div class="flex items-center">
|
229 |
+
<div class="w-full bg-gray-200 rounded-full h-2">
|
230 |
+
<div id="v3-confidence" class="h-2 rounded-full bg-purple-500" style="width: 0%"></div>
|
231 |
+
</div>
|
232 |
+
<span id="v3-confidence-text" class="ml-2 text-sm font-medium">-</span>
|
233 |
+
</div>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
</div>
|
237 |
+
|
238 |
+
<div id="search-tab" class="answer-content hidden p-4 bg-gray-50 rounded-b-lg">
|
239 |
+
<div class="mb-4">
|
240 |
+
<h3 class="font-medium text-gray-700 mb-2">检索到的相关资料</h3>
|
241 |
+
<div id="search-results" class="space-y-3">
|
242 |
+
<p class="text-gray-500 italic">将在此显示搜索引擎返回的相关结果...</p>
|
243 |
+
</div>
|
244 |
+
</div>
|
245 |
+
<div>
|
246 |
+
<h3 class="font-medium text-gray-700 mb-2">使用的搜索关键词</h3>
|
247 |
+
<div id="search-keywords" class="flex flex-wrap gap-2">
|
248 |
+
<span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded-full">知识蒸馏</span>
|
249 |
+
<span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded-full">LLM优化</span>
|
250 |
+
</div>
|
251 |
+
</div>
|
252 |
+
</div>
|
253 |
+
|
254 |
+
<div id="comparison-tab" class="answer-content hidden p-4 bg-gray-50 rounded-b-lg">
|
255 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
|
256 |
+
<div class="border border-gray-200 rounded-lg p-3 h-full">
|
257 |
+
<h3 class="font-medium text-center text-gray-700 mb-2 border-b pb-2">初始答案 (V1)</h3>
|
258 |
+
<div id="v1-comparison" class="prose-sm text-gray-700 max-h-64 overflow-y-auto">
|
259 |
+
<p class="text-gray-500 italic">暂无数据</p>
|
260 |
+
</div>
|
261 |
+
<div class="mt-3 pt-2 border-t text-center">
|
262 |
+
<span class="inline-block px-3 py-1 bg-blue-100 text-blue-800 rounded-full text-sm">置信度: <span id="v1-comp-confidence">-</span>%</span>
|
263 |
+
</div>
|
264 |
+
</div>
|
265 |
+
<div class="border border-gray-200 rounded-lg p-3 h-full">
|
266 |
+
<h3 class="font-medium text-center text-gray-700 mb-2 border-b pb-2">增强版 (V2)</h3>
|
267 |
+
<div id="v2-comparison" class="prose-sm text-gray-700 max-h-64 overflow-y-auto">
|
268 |
+
<p class="text-gray-500 italic">暂无数据</p>
|
269 |
+
</div>
|
270 |
+
<div class="mt-3 pt-2 border-t text-center">
|
271 |
+
<span class="inline-block px-3 py-1 bg-green-100 text-green-800 rounded-full text-sm">提升: <span id="v2-comp-improve">-</span>%</span>
|
272 |
+
</div>
|
273 |
+
</div>
|
274 |
+
<div class="border border-gray-200 rounded-lg p-3 h-full">
|
275 |
+
<h3 class="font-medium text-center text-gray-700 mb-2 border-b pb-2">最终版 (V3)</h3>
|
276 |
+
<div id="v3-comparison" class="prose-sm text-gray-700 max-h-64 overflow-y-auto">
|
277 |
+
<p class="text-gray-500 italic">暂无数据</p>
|
278 |
+
</div>
|
279 |
+
<div class="mt-3 pt-2 border-t text-center">
|
280 |
+
<span class="inline-block px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">最终: <span id="v3-comp-confidence">-</span>%</span>
|
281 |
+
</div>
|
282 |
+
</div>
|
283 |
+
</div>
|
284 |
+
|
285 |
+
<div class="bg-white p-4 rounded-lg shadow-sm border border-gray-200">
|
286 |
+
<h3 class="font-medium text-gray-700 mb-3">知识质量评估对比</h3>
|
287 |
+
<canvas id="qualityChart" height="150"></canvas>
|
288 |
+
<div class="mt-3 flex justify-center">
|
289 |
+
<div class="flex items-center mr-4">
|
290 |
+
<div class="w-3 h-3 rounded-full bg-blue-500 mr-1"></div>
|
291 |
+
<span class="text-xs">初始答案</span>
|
292 |
+
</div>
|
293 |
+
<div class="flex items-center mr-4">
|
294 |
+
<div class="w-3 h-3 rounded-full bg-green-500 mr-1"></div>
|
295 |
+
<span class="text-xs">搜索增强</span>
|
296 |
+
</div>
|
297 |
+
<div class="flex items-center">
|
298 |
+
<div class="w-3 h-3 rounded-full bg-purple-500 mr-1"></div>
|
299 |
+
<span class="text-xs">最终优化</span>
|
300 |
+
</div>
|
301 |
+
</div>
|
302 |
+
</div>
|
303 |
+
</div>
|
304 |
+
</div>
|
305 |
+
|
306 |
+
<!-- Detailed API Logs -->
|
307 |
+
<div id="api-logs" class="mt-6 hidden">
|
308 |
+
<div class="flex justify-between items-center mb-3">
|
309 |
+
<h3 class="text-lg font-medium text-gray-800">
|
310 |
+
<i class="fas fa-server mr-2 text-blue-500"></i> 详细API调用记录
|
311 |
+
</h3>
|
312 |
+
<div>
|
313 |
+
<button id="copy-logs" class="text-sm bg-gray-100 hover:bg-gray-200 text-gray-800 py-1 px-3 rounded mr-2">
|
314 |
+
<i class="fas fa-copy mr-1"></i> 复制
|
315 |
+
</button>
|
316 |
+
<button id="clear-logs" class="text-sm bg-gray-100 hover:bg-gray-200 text-gray-800 py-1 px-3 rounded">
|
317 |
+
<i class="fas fa-trash-alt mr-1"></i> 清空
|
318 |
+
</button>
|
319 |
+
</div>
|
320 |
+
</div>
|
321 |
+
<div class="code-box max-h-64 overflow-y-auto" id="logs-content">
|
322 |
+
<pre class="text-gray-800 text-sm">等待API调用记录...</pre>
|
323 |
+
</div>
|
324 |
+
</div>
|
325 |
+
</div>
|
326 |
+
</div>
|
327 |
+
</div>
|
328 |
+
|
329 |
+
<script>
|
330 |
+
// Model selection
|
331 |
+
document.querySelectorAll('.model-btn').forEach(btn => {
|
332 |
+
btn.addEventListener('click', () => {
|
333 |
+
document.querySelectorAll('.model-btn').forEach(b => {
|
334 |
+
b.classList.remove('active', 'bg-blue-100', 'text-blue-700', 'border-blue-300');
|
335 |
+
b.classList.remove('bg-green-100', 'text-green-700', 'border-green-300');
|
336 |
+
b.classList.remove('bg-purple-100', 'text-purple-700', 'border-purple-300');
|
337 |
+
b.classList.add('bg-gray-100', 'text-gray-700', 'border-gray-300');
|
338 |
+
});
|
339 |
+
|
340 |
+
btn.classList.add('active');
|
341 |
+
if(btn.id.includes('gemini')) {
|
342 |
+
btn.classList.add('bg-blue-100', 'text-blue-700', 'border-blue-300');
|
343 |
+
} else if(btn.id.includes('gpt')) {
|
344 |
+
btn.classList.add('bg-green-100', 'text-green-700', 'border-green-300');
|
345 |
+
} else if(btn.id.includes('claude')) {
|
346 |
+
btn.classList.add('bg-purple-100', 'text-purple-700', 'border-purple-300');
|
347 |
+
}
|
348 |
+
btn.classList.remove('bg-gray-100', 'text-gray-700', 'border-gray-300');
|
349 |
+
});
|
350 |
+
});
|
351 |
+
|
352 |
+
// Tab switching
|
353 |
+
document.querySelectorAll('.answer-tab').forEach(tab => {
|
354 |
+
tab.addEventListener('click', () => {
|
355 |
+
const tabId = tab.getAttribute('data-tab');
|
356 |
+
document.querySelectorAll('.answer-content').forEach(content => content.classList.add('hidden'));
|
357 |
+
document.querySelectorAll('.answer-tab').forEach(t => t.classList.remove('active', 'border-blue-500', 'text-blue-600'));
|
358 |
+
|
359 |
+
document.getElementById(`${tabId}-tab`).classList.remove('hidden');
|
360 |
+
tab.classList.add('active', 'border-blue-500', 'text-blue-600');
|
361 |
+
});
|
362 |
+
});
|
363 |
+
|
364 |
+
// Knowledge Distillation Process
|
365 |
+
document.getElementById('start-btn').addEventListener('click', async function() {
|
366 |
+
const question = document.getElementById('question-input').value.trim();
|
367 |
+
if (!question) {
|
368 |
+
alert('请输入您的问题');
|
369 |
+
return;
|
370 |
+
}
|
371 |
+
|
372 |
+
const startBtn = this;
|
373 |
+
startBtn.disabled = true;
|
374 |
+
startBtn.innerHTML = '<i class="fas fa-cog fa-spin mr-2"></i> 处理中...';
|
375 |
+
|
376 |
+
// Reset UI
|
377 |
+
document.getElementById('progress-container').classList.remove('hidden');
|
378 |
+
document.getElementById('results-container').classList.add('hidden');
|
379 |
+
document.getElementById('api-logs').classList.add('hidden');
|
380 |
+
document.getElementById('process-steps').innerHTML = '';
|
381 |
+
|
382 |
+
// Get selected options
|
383 |
+
const selectedModel = document.querySelector('.model-btn.active').innerText;
|
384 |
+
const searchEngine = document.getElementById('search-engine').value;
|
385 |
+
const searchDepth = parseInt(document.getElementById('search-depth').value);
|
386 |
+
|
387 |
+
// Update model indicators
|
388 |
+
document.getElementById('v1-model').textContent = `模型: ${selectedModel}`;
|
389 |
+
document.getElementById('v2-model').textContent = `模型: ${selectedModel}`;
|
390 |
+
document.getElementById('v3-model').textContent = `模型: ${selectedModel}`;
|
391 |
+
|
392 |
+
const engineName = document.getElementById('search-engine').options[document.getElementById('search-engine').selectedIndex].text;
|
393 |
+
document.getElementById('v2-engine').textContent = `搜索: ${engineName}`;
|
394 |
+
document.getElementById('v3-engine').textContent = `搜索: ${engineName}`;
|
395 |
+
|
396 |
+
// Start the distillation process
|
397 |
+
await executeKnowledgeDistillation(question, selectedModel, searchEngine, searchDepth);
|
398 |
+
|
399 |
+
// Show results
|
400 |
+
document.getElementById('results-container').classList.remove('hidden');
|
401 |
+
document.getElementById('api-logs').classList.remove('hidden');
|
402 |
+
|
403 |
+
// Reset button
|
404 |
+
startBtn.disabled = false;
|
405 |
+
startBtn.innerHTML = '<i class="fas fa-play mr-2"></i> 启动知识蒸馏';
|
406 |
+
});
|
407 |
+
|
408 |
+
async function executeKnowledgeDistillation(question, model, engine, depth) {
|
409 |
+
// Track progress
|
410 |
+
let progress = 0;
|
411 |
+
const totalSteps = 8; // Number of major steps in our process
|
412 |
+
|
413 |
+
// Update progress in UI
|
414 |
+
const updateProgress = (stepProgress) => {
|
415 |
+
progress = Math.min(100, stepProgress);
|
416 |
+
document.getElementById('progress-bar').style.width = `${progress}%`;
|
417 |
+
document.getElementById('progress-percent').textContent = `${Math.round(progress)}%`;
|
418 |
+
return progress;
|
419 |
+
};
|
420 |
+
|
421 |
+
// Add process step log
|
422 |
+
const addProcessStep = (icon, text, isApiCall = false) => {
|
423 |
+
const stepTime = new Date().toLocaleTimeString();
|
424 |
+
const stepEl = document.createElement('div');
|
425 |
+
stepEl.className = `flex items-start p-3 rounded-lg fade-in ${isApiCall ? 'bg-blue-50 border border-blue-100' : 'bg-gray-50'}`;
|
426 |
+
stepEl.innerHTML = `
|
427 |
+
<div class="flex-shrink-0 h-6 w-6 rounded-full ${isApiCall ? 'bg-blue-100 text-blue-600' : 'bg-gray-100 text-gray-600'} flex items-center justify-center mr-3">
|
428 |
+
<i class="fas fa-${icon} text-xs"></i>
|
429 |
+
</div>
|
430 |
+
<div class="flex-1 min-w-0">
|
431 |
+
<p class="text-sm font-medium ${isApiCall ? 'text-blue-800' : 'text-gray-800'}">${text}</p>
|
432 |
+
<p class="text-xs text-gray-500 mt-1">${stepTime}</p>
|
433 |
+
</div>
|
434 |
+
`;
|
435 |
+
document.getElementById('process-steps').appendChild(stepEl);
|
436 |
+
stepEl.scrollIntoView({ behavior: 'smooth' });
|
437 |
+
};
|
438 |
+
|
439 |
+
// Log API call
|
440 |
+
const logApiCall = (service, endpoint, request, response, isError = false) => {
|
441 |
+
const timestamp = new Date().toLocaleTimeString();
|
442 |
+
const logEntry = document.createElement('div');
|
443 |
+
logEntry.className = `flex items-start p-3 rounded-lg fade-in ${isError ? 'bg-red-50 border border-red-100' : 'bg-blue-50 border border-blue-100'}`;
|
444 |
+
logEntry.innerHTML = `
|
445 |
+
<div class="flex-shrink-0 h-6 w-6 rounded-full ${isError ? 'bg-red-100 text-red-600' : 'bg-blue-100 text-blue-600'} flex items-center justify-center mr-3">
|
446 |
+
<i class="fas fa-exchange-alt text-xs"></i>
|
447 |
+
</div>
|
448 |
+
<div class="flex-1 min-w-0">
|
449 |
+
<div class="flex justify-between items-baseline">
|
450 |
+
<p class="text-sm font-medium ${isError ? 'text-red-800' : 'text-blue-800'}">${service}</p>
|
451 |
+
<p class="text-xs text-gray-500">${timestamp}</p>
|
452 |
+
</div>
|
453 |
+
<div class="code-box text-xs mt-1 p-2 bg-white">
|
454 |
+
<div><span class="font-semibold">Endpoint:</span> ${endpoint}</div>
|
455 |
+
<div class="mt-1"><span class="font-semibold">Request:</span> ${request}</div>
|
456 |
+
<div class="mt-1 ${isError ? 'text-red-600' : 'text-green-600'}"><span class="font-semibold">Response:</span> ${response}</div>
|
457 |
+
</div>
|
458 |
+
</div>
|
459 |
+
`;
|
460 |
+
document.getElementById('process-steps').appendChild(logEntry);
|
461 |
+
logEntry.scrollIntoView({ behavior: 'smooth' });
|
462 |
+
|
463 |
+
// Update main API logs
|
464 |
+
const mainLogs = document.querySelector('#logs-content pre');
|
465 |
+
const newLog = `[${timestamp}] ${service}: ${endpoint}\n 请求: ${request}\n 响应: ${response}\n\n`;
|
466 |
+
mainLogs.textContent = mainLogs.textContent.includes('等待API') ?
|
467 |
+
newLog : newLog + mainLogs.textContent;
|
468 |
+
};
|
469 |
+
|
470 |
+
// Mark current step in UI
|
471 |
+
const updateCurrentStep = (text) => {
|
472 |
+
document.getElementById('current-step').textContent = text;
|
473 |
+
addProcessStep('arrow-right', text);
|
474 |
+
};
|
475 |
+
|
476 |
+
// Generate confidence score (for demo)
|
477 |
+
const getConfidenceScore = (baseScore, hasSearchResults, isFinal = false) => {
|
478 |
+
let score = baseScore;
|
479 |
+
if (hasSearchResults) score += 15 + Math.random() * 10;
|
480 |
+
if (isFinal) score += 5 + Math.random() * 5;
|
481 |
+
return Math.min(95, Math.round(score));
|
482 |
+
};
|
483 |
+
|
484 |
+
// Generate a realistic answer from LLM
|
485 |
+
const generateLLMAnswer = (question, context = null, isFinal = false) => {
|
486 |
+
const baseAnswers = {
|
487 |
+
"知识蒸馏": `知识蒸馏是一种将大型"教师"模型的知识转移到小型"学生"模型中的技术,目的是在保持性能的同时减少模型大小和计算需求。该方法最初由Hinton等人在2015年提出,已成为模型压缩领域的重要技术。`,
|
488 |
+
"提高蒸馏效率": `提高知识蒸馏效率的常用方法包括:
|
489 |
+
1. 使用更合适的目标函数(如KL散度)
|
490 |
+
2. 调整温度参数以平滑概率分布
|
491 |
+
3. 加入中间层特征的匹配
|
492 |
+
4. 使用多个教师模型(集成蒸馏)
|
493 |
+
5. 渐进式蒸馏策略`,
|
494 |
+
"蒸馏应用场景": `知识蒸馏技术广泛应用于:
|
495 |
+
- 移动端和边缘设备的模型部署
|
496 |
+
- 实时推理系统
|
497 |
+
- 降低云计算成本
|
498 |
+
- 隐私保护场景(用蒸馏模型替代原始数据)`
|
499 |
+
};
|
500 |
+
|
501 |
+
let answer = "";
|
502 |
+
const questionType = question.includes("如何") ? "提高蒸馏效率" :
|
503 |
+
question.includes("应用") ? "蒸馏应用场景" : "知识蒸馏";
|
504 |
+
|
505 |
+
if (!context) {
|
506 |
+
// Initial answer without search context
|
507 |
+
answer = baseAnswers[questionType] || `关于${question},${model}模型提供的初始回答是:知识蒸馏是一种模型压缩技术,通过让小型模型学习模仿大型模型的行为来实现。具体细节需要进一步分析。`;
|
508 |
+
|
509 |
+
// Sometimes make initial answer incomplete on purpose
|
510 |
+
if (Math.random() > 0.7) {
|
511 |
+
answer = answer.split('。')[0] + "。(初步回答,需要进一步验证细节)";
|
512 |
+
}
|
513 |
+
} else {
|
514 |
+
// Enhanced answer with search context
|
515 |
+
const contextInfo = context.length > 3 ? `根据${context.length}个相关研究资料显示,` : "";
|
516 |
+
|
517 |
+
answer = `${contextInfo}${baseAnswers[questionType] || `关于${question}的分析结果如下:知识蒸馏技术`}${isFinal ? `(经多轮验证的可靠结论)` : ""}`;
|
518 |
+
|
519 |
+
// Add more technical details when context is available
|
520 |
+
if (context.length > 2) {
|
521 |
+
answer += `。最新研究表明,${["该方法在多个基准测试中表现出色",
|
522 |
+
"结合注意力机制可进一步提升效果",
|
523 |
+
"自适应温度调节策略可优化性能"][Math.floor(Math.random()*3)]}`;
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
return answer;
|
528 |
+
};
|
529 |
+
|
530 |
+
// Simulate search results
|
531 |
+
const simulateSearchResults = (keywords) => {
|
532 |
+
const results = [];
|
533 |
+
const baseResults = [
|
534 |
+
{
|
535 |
+
title: "知识蒸馏技术:原理与应用综述",
|
536 |
+
url: "https://arxiv.org/abs/1902.03393",
|
537 |
+
snippet: "本文全面回顾了知识蒸馏技术的发展历程、基本原理和各种变体,以及在计算机视觉和自然语言处理中的应用。"
|
538 |
+
},
|
539 |
+
{
|
540 |
+
title: "高效知识蒸馏:方法与实践",
|
541 |
+
url: "https://www.sciencedirect.com/science/article/pii/S0893608020302240",
|
542 |
+
snippet: "研究探讨了提高知识蒸馏效率的多种方法,包括优化目标函数和训练策略。"
|
543 |
+
},
|
544 |
+
{
|
545 |
+
title: "知识蒸馏在边缘计算中的应用",
|
546 |
+
url: "https://ieeexplore.ieee.org/document/8978343",
|
547 |
+
snippet: "本文讨论了在资源受限环境下部署蒸馏模型的挑战和解决方案。"
|
548 |
+
},
|
549 |
+
{
|
550 |
+
title: "最新研究表明:知识蒸馏可提升小模型性能达90%",
|
551 |
+
url: "https://www.nature.com/articles/s41586-021-03385-7",
|
552 |
+
snippet: "Nature发表的最新研究展示了知识蒸馏在不同领域带来的性能提升。"
|
553 |
+
}
|
554 |
+
];
|
555 |
+
|
556 |
+
// Generate 2-3 fixed results plus random additional ones
|
557 |
+
results.push(...baseResults.slice(0, 2));
|
558 |
+
for (let i = 0; i < depth - 2; i++) {
|
559 |
+
results.push({
|
560 |
+
title: `${keywords[0]}相关研究论文:第${i+1}部分`,
|
561 |
+
url: `https://example.com/research/${keywords[0]}-${i+1}`,
|
562 |
+
snippet: `关于${keywords.join('和')}的额外研究资料,包含重要发现和数据分析。`
|
563 |
+
});
|
564 |
+
}
|
565 |
+
|
566 |
+
return results;
|
567 |
+
};
|
568 |
+
|
569 |
+
/** 正式开始知识蒸馏流程 **/
|
570 |
+
|
571 |
+
// Step 1: Initial analysis and keyword generation (10%)
|
572 |
+
updateCurrentStep("分析问题并生成搜索关键词");
|
573 |
+
addProcessStep("search", `使用${model}分析问题并提取关键词`);
|
574 |
+
|
575 |
+
const keywords = ["知识蒸馏", "模型压缩"];
|
576 |
+
if (question.includes("如何") || question.includes("怎样")) {
|
577 |
+
keywords.push("优化方法", "效率提升");
|
578 |
+
}
|
579 |
+
if (question.includes("应用")) {
|
580 |
+
keywords.push("使用场景", "实际案例");
|
581 |
+
}
|
582 |
+
|
583 |
+
logApiCall(
|
584 |
+
`${model} API`,
|
585 |
+
"/v1/keywords",
|
586 |
+
`问题: ${question.substring(0, 30)}...`,
|
587 |
+
`关键词: ${keywords.join(", ")}`
|
588 |
+
);
|
589 |
+
|
590 |
+
// Update UI
|
591 |
+
document.getElementById('search-keywords').innerHTML = keywords.map(k =>
|
592 |
+
`<span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded-full fade-in">${k}</span>`
|
593 |
+
).join('');
|
594 |
+
|
595 |
+
updateProgress(100/totalSteps*1);
|
596 |
+
await new Promise(resolve => setTimeout(resolve, 800));
|
597 |
+
|
598 |
+
// Step 2: Get initial answer from LLM (20%)
|
599 |
+
updateCurrentStep("获取初始答案(V1)");
|
600 |
+
const v1StartTime = Date.now();
|
601 |
+
|
602 |
+
const initialAnswer = generateLLMAnswer(question);
|
603 |
+
const v1Confidence = getConfidenceScore(65 + Math.random()*10, false);
|
604 |
+
|
605 |
+
logApiCall(
|
606 |
+
`${model} API`,
|
607 |
+
"/v1/generate",
|
608 |
+
`问题: ${question.substring(0, 30)}...`,
|
609 |
+
"生成初始答案"
|
610 |
+
);
|
611 |
+
|
612 |
+
// Update UI with V1 answer
|
613 |
+
document.getElementById('v1-answer').innerHTML = `
|
614 |
+
<div class="prose max-w-none fade-in">
|
615 |
+
<p>${initialAnswer.split('\n').join('</p><p>')}</p>
|
616 |
+
</div>
|
617 |
+
`;
|
618 |
+
document.getElementById('v1-time').textContent = Date.now() - v1StartTime;
|
619 |
+
document.getElementById('v1-confidence').style.width = `${v1Confidence}%`;
|
620 |
+
document.getElementById('v1-confidence-text').textContent = `${v1Confidence}%`;
|
621 |
+
|
622 |
+
// Update comparison tab
|
623 |
+
document.getElementById('v1-comparison').innerHTML = `<p>${initialAnswer.split('\n').join('</p><p>')}</p>`;
|
624 |
+
document.getElementById('v1-comp-confidence').textContent = v1Confidence;
|
625 |
+
|
626 |
+
updateProgress(100/totalSteps*2);
|
627 |
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
628 |
+
|
629 |
+
// Step 3: Execute search queries (30%)
|
630 |
+
updateCurrentStep(`使用${engine}执行搜索`);
|
631 |
+
addProcessStep("search-plus", `使用${engine} API搜索: ${keywords.join(", ")}`);
|
632 |
+
|
633 |
+
const searchStartTime = Date.now();
|
634 |
+
const searchResults = simulateSearchResults(keywords);
|
635 |
+
|
636 |
+
logApiCall(
|
637 |
+
`${engine} API`,
|
638 |
+
"/v1/search",
|
639 |
+
`查询: ${keywords.join(" OR ")}`,
|
640 |
+
`返回${searchResults.length}个结果`
|
641 |
+
);
|
642 |
+
|
643 |
+
// Display search results
|
644 |
+
document.getElementById('search-results').innerHTML = searchResults.map(result => `
|
645 |
+
<div class="search-result fade-in bg-gray-50">
|
646 |
+
<a href="${result.url}" target="_blank" class="text-blue-600 hover:underline font-medium">${result.title}</a>
|
647 |
+
<p class="text-sm text-gray-600 mt-1">${result.snippet}</p>
|
648 |
+
</div>
|
649 |
+
`).join('');
|
650 |
+
|
651 |
+
const searchTime = Date.now() - searchStartTime;
|
652 |
+
updateProgress(100/totalSteps*3);
|
653 |
+
await new Promise(resolve => setTimeout(resolve, 1200));
|
654 |
+
|
655 |
+
// Step 4: Get enhanced answer (V2) (50%)
|
656 |
+
updateCurrentStep("生成搜索增强答案(V2)");
|
657 |
+
const v2StartTime = Date.now();
|
658 |
+
|
659 |
+
const enhancedAnswer = generateLLMAnswer(question, searchResults);
|
660 |
+
const v2Confidence = getConfidenceScore(75 + Math.random()*10, true);
|
661 |
+
|
662 |
+
logApiCall(
|
663 |
+
`${model} API`,
|
664 |
+
"/v1/enhance",
|
665 |
+
`问题: ${question.substring(0, 30)}... + ${searchResults.length}个搜索结果`,
|
666 |
+
"生成增强答案"
|
667 |
+
);
|
668 |
+
|
669 |
+
// Update UI with V2 answer
|
670 |
+
document.getElementById('v2-answer').innerHTML = `
|
671 |
+
<div class="prose max-w-none fade-in">
|
672 |
+
<p>${enhancedAnswer.split('\n').join('</p><p>')}</p>
|
673 |
+
<p class="text-xs text-gray-500 mt-2">注: 此答案已通过${searchResults.length}个相关搜索结果增强</p>
|
674 |
+
</div>
|
675 |
+
`;
|
676 |
+
document.getElementById('v2-time').textContent = Date.now() - v2StartTime + searchTime;
|
677 |
+
document.getElementById('v2-confidence').style.width = `${v2Confidence}%`;
|
678 |
+
document.getElementById('v2-confidence-text').textContent = `${v2Confidence}%`;
|
679 |
+
|
680 |
+
// Update comparison tab
|
681 |
+
document.getElementById('v2-comparison').innerHTML = `<p>${enhancedAnswer.split('\n').join('</p><p>')}</p>`;
|
682 |
+
document.getElementById('v2-comp-improve').textContent = (v2Confidence - v1Confidence);
|
683 |
+
|
684 |
+
updateProgress(100/totalSteps*5);
|
685 |
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
686 |
+
|
687 |
+
// Step 5: Refine search queries (60%)
|
688 |
+
updateCurrentStep("优化搜索关键词");
|
689 |
+
addProcessStep("tags", "基于初步结果优化搜索词");
|
690 |
+
|
691 |
+
const refinedKeywords = [...keywords];
|
692 |
+
if (question.includes("如何")) {
|
693 |
+
refinedKeywords.push("最佳实践", "技巧");
|
694 |
+
}
|
695 |
+
refinedKeywords.push("2023", "最新研究");
|
696 |
+
|
697 |
+
logApiCall(
|
698 |
+
`${model} API`,
|
699 |
+
"/v1/refine-keywords",
|
700 |
+
`原始关键词: ${keywords.join(", ")}`,
|
701 |
+
`优化后关键词: ${refinedKeywords.join(", ")}`
|
702 |
+
);
|
703 |
+
|
704 |
+
updateProgress(100/totalSteps*6);
|
705 |
+
await new Promise(resolve => setTimeout(resolve, 800));
|
706 |
+
|
707 |
+
// Step 6: Get final answer (V3) (80%)
|
708 |
+
updateCurrentStep("生成最终优化答案(V3)");
|
709 |
+
const v3StartTime = Date.now();
|
710 |
+
|
711 |
+
const finalAnswer = generateLLMAnswer(question, searchResults, true);
|
712 |
+
const v3Confidence = getConfidenceScore(85 + Math.random()*10, true, true);
|
713 |
+
|
714 |
+
logApiCall(
|
715 |
+
`${model} API`,
|
716 |
+
"/v1/finalize",
|
717 |
+
`问题: ${question.substring(0, 30)}... + 优化后搜索`,
|
718 |
+
"生成最终答案"
|
719 |
+
);
|
720 |
+
|
721 |
+
// Update UI with V3 answer
|
722 |
+
document.getElementById('v3-answer').innerHTML = `
|
723 |
+
<div class="prose max-w-none fade-in">
|
724 |
+
<p>${finalAnswer.split('\n').join('</p><p>')}</p>
|
725 |
+
<p class="text-xs text-gray-500 mt-2">注: 此答案经过多轮优化和验证</p>
|
726 |
+
</div>
|
727 |
+
`;
|
728 |
+
document.getElementById('v3-time').textContent = Date.now() - v3StartTime + searchTime;
|
729 |
+
document.getElementById('v3-confidence').style.width = `${v3Confidence}%`;
|
730 |
+
document.getElementById('v3-confidence-text').textContent = `${v3Confidence}%`;
|
731 |
+
|
732 |
+
// Update comparison tab
|
733 |
+
document.getElementById('v3-comparison').innerHTML = `<p>${finalAnswer.split('\n').join('</p><p>')}</p>`;
|
734 |
+
document.getElementById('v3-comp-confidence').textContent = v3Confidence;
|
735 |
+
|
736 |
+
updateProgress(100/totalSteps*7);
|
737 |
+
await new Promise(resolve => setTimeout(resolve, 1200));
|
738 |
+
|
739 |
+
// Step 7: Quality evaluation (100%)
|
740 |
+
updateCurrentStep("评估知识质量提升");
|
741 |
+
addProcessStep("chart-line", "分析各版本答案质量差异");
|
742 |
+
|
743 |
+
renderQualityChart([
|
744 |
+
{ version: '初始', score: v1Confidence },
|
745 |
+
{ version: '增强', score: v2Confidence },
|
746 |
+
{ version: '最终', score: v3Confidence }
|
747 |
+
]);
|
748 |
+
|
749 |
+
logApiCall(
|
750 |
+
"评估系统",
|
751 |
+
"/v1/evaluate",
|
752 |
+
`比较V1-V3答案`,
|
753 |
+
`质量提升: +${v3Confidence - v1Confidence}%`
|
754 |
+
);
|
755 |
+
|
756 |
+
updateProgress(100);
|
757 |
+
updateCurrentStep("知识蒸馏完成");
|
758 |
+
addProcessStep("check-circle", "知识蒸馏流程已完成");
|
759 |
+
|
760 |
+
// Scroll to results
|
761 |
+
document.getElementById('results-container').scrollIntoView({ behavior: 'smooth' });
|
762 |
+
}
|
763 |
+
|
764 |
+
function renderQualityChart(data) {
|
765 |
+
const ctx = document.getElementById('qualityChart').getContext('2d');
|
766 |
+
if (window.qualityChart) {
|
767 |
+
window.qualityChart.destroy();
|
768 |
+
}
|
769 |
+
|
770 |
+
window.qualityChart = new Chart(ctx, {
|
771 |
+
type: 'line',
|
772 |
+
data: {
|
773 |
+
labels: data.map(d => d.version),
|
774 |
+
datasets: [{
|
775 |
+
label: '知识质量评分',
|
776 |
+
data: data.map(d => d.score),
|
777 |
+
backgroundColor: 'rgba(99, 102, 241, 0.2)',
|
778 |
+
borderColor: 'rgba(99, 102, 241, 1)',
|
779 |
+
borderWidth: 2,
|
780 |
+
pointBackgroundColor: 'rgba(99, 102, 241, 1)',
|
781 |
+
pointRadius: 4,
|
782 |
+
tension: 0.3,
|
783 |
+
fill: true
|
784 |
+
}]
|
785 |
+
},
|
786 |
+
options: {
|
787 |
+
responsive: true,
|
788 |
+
scales: {
|
789 |
+
y: {
|
790 |
+
beginAtZero: false,
|
791 |
+
min: Math.max(0, Math.min(...data.map(d => d.score)) - 10),
|
792 |
+
max: 100
|
793 |
+
}
|
794 |
+
},
|
795 |
+
plugins: {
|
796 |
+
tooltip: {
|
797 |
+
callbacks: {
|
798 |
+
label: function(context) {
|
799 |
+
return `质量评分: ${context.parsed.y}%`;
|
800 |
+
}
|
801 |
+
}
|
802 |
+
}
|
803 |
+
}
|
804 |
+
}
|
805 |
+
});
|
806 |
+
}
|
807 |
+
|
808 |
+
// Copy logs button
|
809 |
+
document.getElementById('copy-logs').addEventListener('click', () => {
|
810 |
+
const logs = document.querySelector('#logs-content pre').textContent;
|
811 |
+
navigator.clipboard.writeText(logs).then(() => {
|
812 |
+
const copyBtn = document.getElementById('copy-logs');
|
813 |
+
copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> 已复制';
|
814 |
+
setTimeout(() => {
|
815 |
+
copyBtn.innerHTML = '<i class="fas fa-copy mr-1"></i> 复制';
|
816 |
+
}, 2000);
|
817 |
+
});
|
818 |
+
});
|
819 |
+
|
820 |
+
// Clear logs button
|
821 |
+
document.getElementById('clear-logs').addEventListener('click', () => {
|
822 |
+
document.querySelector('#logs-content pre').textContent = 'API调用记录已清空';
|
823 |
+
});
|
824 |
+
</script>
|
825 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
826 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=HOrdye/zhengliu" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
827 |
+
</html>
|