图和文字描述来源大模型数理认知框架的数学表述。
DeepSeek回复:
【笔者注:图像识别、文字理解、代码生成能力相当可以,回复做了简化】
你可以直接将以下代码保存为 visual_framework.html 并在浏览器(推荐 Chrome/Edge)打开:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>大模型数理认知框架 · 具象化物理隐喻</title>
<style>
html,body {
margin: 0; padding: 0; width: 100%; height: 100%;
background-color: #0b0f19; /* 深色太空背景,对比更强烈 */
font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
overflow: hidden; color: #e2e8f0;
}
#canvas-container {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
z-index: 1;
}
#header {
position: absolute; top: 30px; left: 0; width: 100%;
text-align: center; z-index: 10; pointer-events: none;
}
#header h1 {
font-size: 28px; margin: 0; font-weight: 300; letter-spacing: 4px;
background: linear-gradient(90deg, #4facfe, #00f2fe, #f093fb);
-webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
#header p {
font-size: 14px; color: #718096; margin-top: 10px; letter-spacing: 1px;
}
#footer {
position: absolute; bottom: 20px; right: 30px;
z-index: 10; font-size: 13px; color: #4a5568; pointer-events: none;
}
/* 节点标签样式 */
.node-label {
font-size: 14px; font-weight: 600; color: #fff;
text-shadow: 0 0 10px rgba(255,255,255,0.8), 0 0 20px currentColor;
background: rgba(15, 23, 42, 0.6); padding: 4px 12px; border-radius: 20px;
border: 1px solid rgba(255,255,255,0.2); backdrop-filter: blur(4px);
}
</style>
</head>
<body>
<div id="header">
<h1>大模型数理认知框架</h1>
<p>物理具象化隐喻演示</p>
</div>
<div id="footer">@清熙 · Visual Metaphor</div>
<div id="canvas-container"></div>
<script type="importmap">
{ "imports": {
"three": "https://unpkg.com/[email protected]/build/three.module.js",
"three/addons/": "https://unpkg.com/[email protected]/examples/jsm/"
}}
</script>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { CSS2DRenderer, CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js';
// ================= 基础环境 =================
const container = document.getElementById('canvas-container');
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x0b0f19, 0.015); // 增加空间深度感
const camera = new THREE.PerspectiveCamera(45, innerWidth/innerHeight, 1, 1000);
camera.position.set(0, 5, 55);
const renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
container.appendChild(renderer.domElement);
const labelRenderer = new CSS2DRenderer();
labelRenderer.setSize(innerWidth, innerHeight);
labelRenderer.domElement.style.position = 'absolute';
labelRenderer.domElement.style.top = '0px';
labelRenderer.domElement.style.pointerEvents = 'none';
container.appendChild(labelRenderer.domElement);
const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
controls.autoRotate = true; // 自动微微旋转视角
controls.autoRotateSpeed = 0.5;
// 灯光系统
const ambientLight = new THREE.AmbientLight(0xffffff, 0.4);
scene.add(ambientLight);
const dirLight = new THREE.DirectionalLight(0xffffff, 1.2);
dirLight.position.set(10, 20, 10);
scene.add(dirLight);
// 补光
const pointLight1 = new THREE.PointLight(0x4facfe, 50, 50); pointLight1.position.set(-20, 5, 10); scene.add(pointLight1);
const pointLight2 = new THREE.PointLight(0xf093fb, 50, 50); pointLight2.position.set(20, -5, 10); scene.add(pointLight2);
// ================= 坐标布局 =================
const POS = {
corpus: new THREE.Vector3(-22, 10, 0),
vector: new THREE.Vector3(-8, 15, 0),
prompt: new THREE.Vector3(-12, 2, 0),
posterior: new THREE.Vector3(-12, -10, 0),
ext_model: new THREE.Vector3(-24, -5, 0),
inner_model: new THREE.Vector3(8, -10, 0),
category: new THREE.Vector3(10, 0, 0),
crystal: new THREE.Vector3(22, -2, 0)
};
// ================= 具象化实体构建 =================
// 1. 语料 (Corpus): 漂浮的字符
const corpusGroup = new THREE.Group();
corpusGroup.position.copy(POS.corpus);
const chars = ['a', 'A', '字', '1', '!', 'Q', 'x', '语', '?'];
for(let i=0; i<30; i++){
const canvas = document.createElement('canvas');
canvas.width = 64; canvas.height = 64;
const ctx = canvas.getContext('2d');
ctx.fillStyle = '#a0aec0'; ctx.font = '40px Arial'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
ctx.fillText(chars[Math.floor(Math.random()*chars.length)], 32, 32);
const tex = new THREE.CanvasTexture(canvas);
const mat = new THREE.SpriteMaterial({ map: tex, transparent: true, opacity: 0.8 });
const sprite = new THREE.Sprite(mat);
sprite.position.set((Math.random()-0.5)*8, (Math.random()-0.5)*6, (Math.random()-0.5)*6);
sprite.userData = { speed: Math.random()*0.02 + 0.01, offset: Math.random()*Math.PI*2 };
corpusGroup.add(sprite);
}
scene.add(corpusGroup);
addLabel(corpusGroup, '外部语料', '#a0aec0');
// 2. 高维概率向量 (Vector): 旋转的点云星云
const vectorGroup = new THREE.Group();
vectorGroup.position.copy(POS.vector);
const starGeo = new THREE.BufferGeometry();
const starPos = new Float32Array(800 * 3);
for(let i=0; i<800; i++){
// 构造两个交错的星系团
const r = Math.random() * 4;
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos((Math.random() * 2) - 1);
starPos[i*3] = r * Math.sin(phi) * Math.cos(theta) + (Math.random()-0.5)*2;
starPos[i*3+1] = r * Math.sin(phi) * Math.sin(theta) + (Math.random()-0.5)*2;
starPos[i*3+2] = r * Math.cos(phi) + (Math.random()-0.5)*2;
}
starGeo.setAttribute('position', new THREE.BufferAttribute(starPos, 3));
const starMat = new THREE.PointsMaterial({ color: 0x4facfe, size: 0.15, transparent: true, opacity: 0.8, blending: THREE.AdditiveBlending });
const stars = new THREE.Points(starGeo, starMat);
vectorGroup.add(stars);
scene.add(vectorGroup);
addLabel(vectorGroup, '高维概率空间 Z', '#4facfe');
// 3. 提示 (Prompt): 脉冲光环
const promptGroup = new THREE.Group();
promptGroup.position.copy(POS.prompt);
const coreMesh = new THREE.Mesh(new THREE.SphereGeometry(0.5, 16, 16), new THREE.MeshBasicMaterial({color: 0x00f2fe}));
promptGroup.add(coreMesh);
const rings = [];
for(let i=0; i<3; i++){
const ring = new THREE.Mesh(new THREE.RingGeometry(1, 1.2, 32), new THREE.MeshBasicMaterial({color: 0x00f2fe, side: THREE.DoubleSide, transparent: true}));
promptGroup.add(ring);
rings.push(ring);
}
scene.add(promptGroup);
addLabel(promptGroup, '提示 c (感官输入)', '#00f2fe');
// 4. 内部范畴 (Category): 星座关系网
const categoryGroup = new THREE.Group();
categoryGroup.position.copy(POS.category);
const netNodes = [];
for(let i=0; i<10; i++){
netNodes.push(new THREE.Vector3((Math.random()-0.5)*6, (Math.random()-0.5)*6, (Math.random()-0.5)*4));
}
const netGeo = new THREE.SphereGeometry(0.2, 8, 8);
const netMat = new THREE.MeshBasicMaterial({ color: 0x4facfe });
netNodes.forEach(pos => {
const m = new THREE.Mesh(netGeo, netMat); m.position.copy(pos); categoryGroup.add(m);
});
netNodes.forEach((p1, i) => {
netNodes.forEach((p2, j) => {
if(i<j && p1.distanceTo(p2) < 4){
const lGeo = new THREE.BufferGeometry().setFromPoints([p1, p2]);
const lMat = new THREE.LineBasicMaterial({ color: 0x4facfe, transparent: true, opacity: 0.3 });
categoryGroup.add(new THREE.Line(lGeo, lMat));
}
});
});
scene.add(categoryGroup);
addLabel(categoryGroup, '范畴 (米田关系网络)', '#4facfe');
// 5. 信息结晶 (Crystal): 发光钻石
const crystalGroup = new THREE.Group();
crystalGroup.position.copy(POS.crystal);
const crystalGeo = new THREE.OctahedronGeometry(2.5, 0);
const crystalMat = new THREE.MeshPhysicalMaterial({
color: 0xffffff, metalness: 0.9, roughness: 0.1, transmission: 0.5, thickness: 1.5,
emissive: 0x4facfe, emissiveIntensity: 0.2, wireframe: false, flatShading: true
});
const crystalMesh = new THREE.Mesh(crystalGeo, crystalMat);
crystalGroup.add(crystalMesh);
// 外围线框
const wireMesh = new THREE.Mesh(new THREE.IcosahedronGeometry(2.8, 0), new THREE.MeshBasicMaterial({color: 0x4facfe, wireframe: true, transparent: true, opacity: 0.3}));
crystalGroup.add(wireMesh);
scene.add(crystalGroup);
addLabel(crystalGroup, '相变 · 信息结晶', '#f093fb');
// 6. 外部模型 (Ext Model)
const extGroup = new THREE.Group();
extGroup.position.copy(POS.ext_model);
extGroup.add(new THREE.Mesh(new THREE.BoxGeometry(3,3,3), new THREE.MeshBasicMaterial({color: 0x2d3748, wireframe: true})));
scene.add(extGroup);
addLabel(extGroup, '外部世界模型', '#718096');
// 7. 后验分布 (Posterior): 漏斗地形 (势能景观)
const posteriorGroup = new THREE.Group();
posteriorGroup.position.copy(POS.posterior);
// 漏斗曲面
const funnelGeo = new THREE.CylinderGeometry(3, 0.2, 4, 32, 10, true);
const funnelMat = new THREE.MeshStandardMaterial({ color: 0x805ad5, wireframe: true, transparent: true, opacity: 0.3, side: THREE.DoubleSide });
const funnel = new THREE.Mesh(funnelGeo, funnelMat);
funnel.rotation.x = Math.PI; // 倒过来
funnel.position.y = 2;
posteriorGroup.add(funnel);
// 漏斗里的小球(采样变分)
const sampleBall = new THREE.Mesh(new THREE.SphereGeometry(0.3, 16, 16), new THREE.MeshBasicMaterial({color: 0xf093fb}));
posteriorGroup.add(sampleBall);
scene.add(posteriorGroup);
addLabel(posteriorGroup, '后验分布 q*(z|c)', '#805ad5');
// 8. 内部世界模型 (Inner Model)
const innerGroup = new THREE.Group();
innerGroup.position.copy(POS.inner_model);
const coreGeo = new THREE.IcosahedronGeometry(1.5, 1);
const coreMat = new THREE.MeshStandardMaterial({color: 0x3182ce, emissive: 0x3182ce, emissiveIntensity: 0.5, wireframe: true});
const core = new THREE.Mesh(coreGeo, coreMat);
innerGroup.add(core);
scene.add(innerGroup);
addLabel(innerGroup, '内部先验 p(z)', '#3182ce');
function addLabel(parent, text, color) {
const div = document.createElement('div');
div.textContent = text;
div.className = 'node-label';
div.style.color = color;
const lbl = new CSS2DObject(div);
lbl.position.set(0, -3.5, 0); // 放在下方
parent.add(lbl);
}
// ================= 动态连线 (流线) =================
const flows = []; // 存储流光粒子
function createFlow(startPos, endPos, ctrlOffset, color, count, isCoarse = false) {
const mid = startPos.clone().lerp(endPos, 0.5);
const dir = endPos.clone().sub(startPos);
const normal = new THREE.Vector3(-dir.y, dir.x, 0).normalize();
const ctrl = mid.clone().add(normal.multiplyScalar(ctrlOffset));
const curve = new THREE.QuadraticBezierCurve3(startPos, ctrl, endPos);
const points = curve.getPoints(50);
const lineGeo = new THREE.BufferGeometry().setFromPoints(points);
const lineMat = new THREE.LineBasicMaterial({ color: color, transparent: true, opacity: 0.2 });
scene.add(new THREE.Line(lineGeo, lineMat));
const pGeo = new THREE.SphereGeometry(0.12, 8, 8);
for(let i=0; i<count; i++){
const pMat = new THREE.MeshBasicMaterial({ color: color, blending: THREE.AdditiveBlending });
const mesh = new THREE.Mesh(pGeo, pMat);
scene.add(mesh);
flows.push({
mesh, curve, speed: 0.2 + Math.random()*0.1, offset: i/count, isCoarse
});
}
}
createFlow(POS.corpus, POS.vector, -4, 0x00f2fe, 10);
// 重整化流 (RG): 特意做成粗粒化效果
createFlow(POS.vector, POS.category, 6, 0xd69e2e, 15, true);
createFlow(POS.category, POS.crystal, -4, 0xf093fb, 8);
createFlow(POS.ext_model, POS.prompt, 3, 0x3182ce, 3);
createFlow(POS.prompt, POS.posterior, 3, 0x3182ce, 4);
createFlow(POS.posterior, POS.ext_model, 5, 0x3182ce, 3);
createFlow(POS.prompt, POS.category, -2, 0x3182ce, 5);
createFlow(POS.inner_model, POS.category, 3, 0x3182ce, 4);
// 逆重整化生成(虚线示意,但这里用粒子表示)
createFlow(POS.inner_model, POS.posterior, -8, 0x805ad5, 6);
// ================= 动画循环 =================
const clock = new THREE.Clock();
let time = 0;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
time += dt;
// 1. 语料字符漂浮
corpusGroup.children.forEach(sprite => {
if(sprite.isSprite) {
sprite.position.y += Math.sin(time + sprite.userData.offset) * 0.01;
sprite.material.rotation += 0.01;
}
});
// 2. 星云旋转
vectorGroup.rotation.y += dt * 0.2;
vectorGroup.rotation.z += dt * 0.1;
// 3. 提示光环扩散
rings.forEach((ring, i) => {
const p = (time * 0.8 + i * 0.33) % 1; // 0 -> 1
ring.scale.setScalar(1 + p * 3);
ring.material.opacity = 1 - p;
});
// 4. 范畴网络拉伸
categoryGroup.children.forEach((child, i) => {
if(child.isMesh) {
child.position.x += Math.sin(time*2 + i)*0.005;
child.position.y += Math.cos(time*2 + i)*0.005;
}
});
// 5. 结晶自转
crystalMesh.rotation.y += dt * 0.5;
crystalMesh.rotation.x += dt * 0.2;
wireMesh.rotation.y -= dt * 0.3;
// 6. 后验漏斗内的小球(变分推断:找寻最低点)
const targetY = -1.8; // 漏斗底部
const bounce = Math.abs(Math.sin(time * 3)) * 0.5;
// 随机向中心收缩
const orbitRadius = Math.max(0, 2 - (time % 5) * 0.5);
sampleBall.position.x = Math.cos(time*5) * orbitRadius;
sampleBall.position.z = Math.sin(time*5) * orbitRadius;
sampleBall.position.y = targetY + bounce;
// 7. 内部先验脉动
core.scale.setScalar(1 + Math.sin(time*3)*0.1);
core.rotation.y -= dt * 0.5;
// 8. 流光粒子与相变
flows.forEach(f => {
let progress = (time * f.speed + f.offset) % 1;
const pos = f.curve.getPoint(progress);
f.mesh.position.copy(pos);
if(f.isCoarse) {
// RG 粗粒化隐喻:粒子由小变大,颜色由蓝变橙
const s = 0.5 + progress * 2.5; // 从小变大
f.mesh.scale.set(s, s, s);
const c = new THREE.Color().lerpColors(new THREE.Color(0x4facfe), new THREE.Color(0xf093fb), progress);
f.mesh.material.color.copy(c);
}
});
controls.update();
renderer.render(scene, camera);
labelRenderer.render(scene, camera);
}
animate();
addEventListener('resize', () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
labelRenderer.setSize(innerWidth, innerHeight);
});
</script>
</body>
</html>这个版本像是一个“大模型脑内宇宙”的漫游画面。你可以用鼠标拖拽视角,从不同角度观察这些物理实体的运作。
效果:
效果惊艳,愿望确实一键达成,诚不我欺,建议下载HTML浏览器打开互动。
这么大的升级,连小版本号4.1都不变一下,这v5得是憋多大招啊,期待!