{"id":83420,"date":"2026-07-25T21:49:30","date_gmt":"2026-07-25T13:49:30","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/83420.html"},"modified":"2026-07-25T21:49:30","modified_gmt":"2026-07-25T13:49:30","slug":"gemma-3-12b-it%e5%85%a5%e9%97%a8%e6%95%99%e7%a8%8b%ef%bc%9a120%e4%ba%bf%e5%8f%82%e6%95%b0%e6%a8%a1%e5%9e%8b%e5%9c%a8%e4%bd%8e%e8%b5%84%e6%ba%90%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a%e7%9a%84%e9%83%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/83420.html","title":{"rendered":"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b\uff1a120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7"},"content":{"rendered":"<h2>Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b&#xff1a;120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7<\/h2>\n<h3>1. \u5f00\u7bc7&#xff1a;\u4e3a\u4ec0\u4e48\u9009\u62e9Gemma-3-12B-IT&#xff1f;<\/h3>\n<p>\u5982\u679c\u4f60\u6b63\u5728\u5bfb\u627e\u4e00\u4e2a\u65e2\u5f3a\u5927\u53c8\u80fd\u5728\u666e\u901a\u670d\u52a1\u5668\u4e0a\u6d41\u7545\u8fd0\u884c\u7684\u5927\u8bed\u8a00\u6a21\u578b&#xff0c;\u90a3\u4e48Gemma-3-12B-IT\u5f88\u53ef\u80fd\u5c31\u662f\u4f60\u7684\u7406\u60f3\u9009\u62e9\u3002<\/p>\n<p>\u8ba9\u6211\u5148\u8bf4\u8bf4\u6211\u7684\u4eb2\u8eab\u7ecf\u5386\u3002\u524d\u6bb5\u65f6\u95f4&#xff0c;\u6211\u9700\u8981\u4e3a\u4e00\u4e2a\u5c0f\u578b\u5f00\u53d1\u56e2\u961f\u90e8\u7f72\u4e00\u4e2aAI\u52a9\u624b&#xff0c;\u9884\u7b97\u6709\u9650&#xff0c;\u670d\u52a1\u5668\u914d\u7f6e\u4e5f\u4e0d\u7b97\u9ad8&#xff08;32GB\u5185\u5b58&#xff0c;\u6ca1\u6709\u9ad8\u7aefGPU&#xff09;\u3002\u8bd5\u8fc7\u51e0\u4e2a\u5927\u6a21\u578b&#xff0c;\u8981\u4e48\u8dd1\u4e0d\u8d77\u6765&#xff0c;\u8981\u4e48\u54cd\u5e94\u6162\u5f97\u50cf\u8717\u725b\u3002\u76f4\u5230\u6211\u9047\u5230\u4e86Gemma-3-12B-IT&#xff0c;\u60c5\u51b5\u624d\u5f7b\u5e95\u6539\u53d8\u3002<\/p>\n<p>\u8fd9\u4e2a\u6a21\u578b\u6709\u4ec0\u4e48\u7279\u522b\u4e4b\u5904&#xff1f;\u7b80\u5355\u6765\u8bf4&#xff0c;\u5b83\u662fGoogle\u6700\u65b0\u4e00\u4ee3\u7684\u8f7b\u91cf\u7ea7\u5f00\u6e90\u6a21\u578b&#xff0c;\u62e5\u6709120\u4ebf\u53c2\u6570\u2014\u2014\u8fd9\u4e2a\u89c4\u6a21\u6b63\u597d\u5361\u5728\u201c\u80fd\u529b\u8db3\u591f\u5f3a\u201d\u548c\u201c\u8d44\u6e90\u6d88\u8017\u53ef\u63a5\u53d7\u201d\u7684\u751c\u871c\u70b9\u4e0a\u3002\u76f8\u6bd4\u52a8\u8f84\u51e0\u767e\u4ebf\u53c2\u6570\u7684\u5927\u6a21\u578b&#xff0c;\u5b83\u80fd\u5728\u666e\u901a\u670d\u52a1\u5668\u4e0a\u987a\u7545\u8fd0\u884c&#xff1b;\u76f8\u6bd4\u66f4\u5c0f\u7684\u6a21\u578b&#xff0c;\u5b83\u7684\u7406\u89e3\u80fd\u529b\u548c\u751f\u6210\u8d28\u91cf\u53c8\u660e\u663e\u9ad8\u51fa\u4e00\u622a\u3002<\/p>\n<p>\u66f4\u91cd\u8981\u7684\u662f&#xff0c;\u8fd9\u662f\u201c\u6307\u4ee4\u5fae\u8c03\u201d\u7248\u672c&#xff08;IT\u4ee3\u8868Instruction Tuned&#xff09;\u3002\u8fd9\u610f\u5473\u7740\u5b83\u4e13\u95e8\u9488\u5bf9\u4eba\u7c7b\u5bf9\u8bdd\u8fdb\u884c\u4e86\u4f18\u5316&#xff0c;\u4f60\u95ee\u5b83\u95ee\u9898&#xff0c;\u5b83\u4e0d\u4f1a\u7ed9\u4f60\u4e00\u5806\u6280\u672f\u672f\u8bed&#xff0c;\u800c\u662f\u50cf\u670b\u53cb\u804a\u5929\u4e00\u6837\u7ed9\u51fa\u5b9e\u7528\u7684\u56de\u7b54\u3002\u5199\u4ee3\u7801\u3001\u89e3\u91ca\u6982\u5ff5\u3001\u521b\u4f5c\u5185\u5bb9&#xff0c;\u6837\u6837\u90fd\u80fd\u5e72\u3002<\/p>\n<p>\u4f46\u95ee\u9898\u6765\u4e86&#xff1a;\u600e\u4e48\u5728\u8d44\u6e90\u6709\u9650\u7684\u670d\u52a1\u5668\u4e0a&#xff0c;\u8ba9\u8fd9\u4e2a\u6a21\u578b\u8dd1\u5f97\u53c8\u5feb\u53c8\u7a33&#xff1f;\u8fd9\u5c31\u662f\u6211\u4eca\u5929\u8981\u5206\u4eab\u7684\u6838\u5fc3\u5185\u5bb9\u3002\u6211\u4f1a\u5e26\u4f60\u4e00\u6b65\u6b65\u5b8c\u6210\u90e8\u7f72&#xff0c;\u5e76\u5206\u4eab\u6211\u6478\u7d22\u51fa\u6765\u7684\u4f18\u5316\u6280\u5de7&#xff0c;\u8ba9\u4f60\u7528\u6700\u5c11\u7684\u8d44\u6e90&#xff0c;\u83b7\u5f97\u6700\u597d\u7684\u4f53\u9a8c\u3002<\/p>\n<h3>2. \u90e8\u7f72\u524d\u7684\u51c6\u5907\u5de5\u4f5c&#xff1a;\u522b\u6025\u7740\u52a8\u624b<\/h3>\n<p>\u5728\u5f00\u59cb\u5b89\u88c5\u4e4b\u524d&#xff0c;\u505a\u597d\u51c6\u5907\u5de5\u4f5c\u80fd\u8ba9\u4f60\u5c11\u8d70\u5f88\u591a\u5f2f\u8def\u3002\u5f88\u591a\u4eba\u4e00\u4e0a\u6765\u5c31\u4e0b\u8f7d\u6a21\u578b\u3001\u8fd0\u884c\u547d\u4ee4&#xff0c;\u7ed3\u679c\u9047\u5230\u5404\u79cd\u95ee\u9898&#xff0c;\u6298\u817e\u534a\u5929\u53c8\u5f97\u4ece\u5934\u518d\u6765\u3002<\/p>\n<h4>2.1 \u68c0\u67e5\u4f60\u7684\u670d\u52a1\u5668\u914d\u7f6e<\/h4>\n<p>\u9996\u5148&#xff0c;\u770b\u770b\u4f60\u7684\u670d\u52a1\u5668\u591f\u4e0d\u591f\u683c\u3002Gemma-3-12B-IT\u5bf9\u786c\u4ef6\u7684\u8981\u6c42\u6bd4\u8f83\u53cb\u597d&#xff0c;\u4f46\u4e5f\u4e0d\u662f\u4ec0\u4e48\u673a\u5668\u90fd\u80fd\u8dd1\u3002<\/p>\n<p>\u6700\u4f4e\u914d\u7f6e\u8981\u6c42&#xff1a;<\/p>\n<ul>\n<li>\u5185\u5b58&#xff1a;\u81f3\u5c1124GB&#xff08;\u63a8\u835032GB\u4ee5\u4e0a&#xff09;<\/li>\n<li>\u5b58\u50a8&#xff1a;\u6a21\u578b\u6587\u4ef6\u9700\u8981\u7ea623GB\u7a7a\u95f4&#xff0c;\u52a0\u4e0a\u7cfb\u7edf\u548c\u4f9d\u8d56&#xff0c;\u5efa\u8bae\u9884\u755950GB<\/li>\n<li>CPU&#xff1a;\u73b0\u4ee3\u591a\u6838\u5904\u7406\u5668&#xff08;4\u6838\u4ee5\u4e0a&#xff09;<\/li>\n<li>\u7f51\u7edc&#xff1a;\u7a33\u5b9a\u7684\u7f51\u7edc\u8fde\u63a5&#xff08;\u4e0b\u8f7d\u6a21\u578b\u9700\u8981\u65f6\u95f4&#xff09;<\/li>\n<\/ul>\n<p>\u5982\u679c\u6709GPU\u4f1a\u66f4\u597d&#xff1a;<\/p>\n<ul>\n<li>\u652f\u6301CUDA\u7684NVIDIA\u663e\u5361&#xff08;RTX 3060 12GB\u6216\u4ee5\u4e0a&#xff09;<\/li>\n<li>GPU\u5185\u5b58\u81f3\u5c118GB&#xff08;\u63a8\u835012GB\u4ee5\u4e0a&#xff09;<\/li>\n<li>\u5b89\u88c5\u6b63\u786e\u7684CUDA\u9a71\u52a8\u548cPyTorch GPU\u7248\u672c<\/li>\n<\/ul>\n<p>\u6211\u7528\u7684\u6d4b\u8bd5\u73af\u5883\u662f\u4e00\u53f0\u4e91\u670d\u52a1\u5668&#xff1a;4\u6838CPU&#xff0c;32GB\u5185\u5b58&#xff0c;\u6ca1\u6709\u72ec\u7acbGPU\u3002\u8fd9\u4e2a\u914d\u7f6e\u8dd1\u8d77\u6765\u5b8c\u5168\u6ca1\u95ee\u9898&#xff0c;\u54cd\u5e94\u901f\u5ea6\u5728\u53ef\u63a5\u53d7\u8303\u56f4\u5185&#xff08;\u4e00\u822c\u95ee\u98983-5\u79d2\u5185\u56de\u590d&#xff09;\u3002\u5982\u679c\u4f60\u6709GPU&#xff0c;\u901f\u5ea6\u4f1a\u5feb\u5f88\u591a&#xff0c;\u4f46\u6ca1\u6709GPU\u4e5f\u80fd\u7528\u3002<\/p>\n<h4>2.2 \u7cfb\u7edf\u73af\u5883\u51c6\u5907<\/h4>\n<p>\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u662f\u5e72\u51c0\u7684&#xff0c;\u6216\u8005\u81f3\u5c11\u6ca1\u6709\u51b2\u7a81\u7684Python\u73af\u5883\u3002\u6211\u63a8\u8350\u4f7f\u7528Ubuntu 20.04\u621622.04&#xff0c;\u8fd9\u662f\u6700\u7a33\u5b9a\u7684\u9009\u62e9\u3002<\/p>\n<p># \u66f4\u65b0\u7cfb\u7edf\u5305<br \/>\nsudo apt update<br \/>\nsudo apt upgrade -y<\/p>\n<p># \u5b89\u88c5\u57fa\u7840\u4f9d\u8d56<br \/>\nsudo apt install -y python3-pip python3-venv git curl wget<\/p>\n<p># \u68c0\u67e5Python\u7248\u672c&#xff08;\u9700\u89813.11\u6216\u4ee5\u4e0a&#xff09;<br \/>\npython3 &#8211;version<\/p>\n<p>\u5982\u679cPython\u7248\u672c\u4f4e\u4e8e3.11&#xff0c;\u4f60\u9700\u8981\u5148\u5347\u7ea7\u3002\u4e0d\u8fc7\u5927\u591a\u6570\u73b0\u4ee3Ubuntu\u7cfb\u7edf\u90fd\u81ea\u5e263.10\u62163.11&#xff0c;\u4e00\u822c\u6ca1\u95ee\u9898\u3002<\/p>\n<h4>2.3 \u521b\u5efa\u72ec\u7acb\u73af\u5883<\/h4>\n<p>\u8fd9\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65&#xff01;\u4e0d\u8981\u5728\u7cfb\u7edfPython\u91cc\u76f4\u63a5\u5b89\u88c5&#xff0c;\u4e00\u5b9a\u8981\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u8fd9\u6837\u65e2\u80fd\u907f\u514d\u4f9d\u8d56\u51b2\u7a81&#xff0c;\u4e5f\u65b9\u4fbf\u540e\u7eed\u7ba1\u7406\u3002<\/p>\n<p># \u521b\u5efa\u9879\u76ee\u76ee\u5f55<br \/>\nmkdir -p ~\/gemma-3-webui<br \/>\ncd ~\/gemma-3-webui<\/p>\n<p># \u521b\u5efaPython\u865a\u62df\u73af\u5883<br \/>\npython3 -m venv venv<\/p>\n<p># \u6fc0\u6d3b\u865a\u62df\u73af\u5883<br \/>\nsource venv\/bin\/activate<\/p>\n<p># \u4f60\u4f1a\u770b\u5230\u547d\u4ee4\u884c\u524d\u9762\u51fa\u73b0 (venv)&#xff0c;\u8868\u793a\u6fc0\u6d3b\u6210\u529f<\/p>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e&#xff0c;\u6240\u6709Python\u5305\u7684\u5b89\u88c5\u90fd\u4f1a\u5c40\u9650\u5728\u8fd9\u4e2a\u73af\u5883\u91cc&#xff0c;\u4e0d\u4f1a\u5f71\u54cd\u7cfb\u7edf\u5176\u4ed6\u90e8\u5206\u3002\u9000\u51fa\u65f6\u7528 deactivate \u547d\u4ee4\u3002<\/p>\n<h3>3. \u4e00\u6b65\u6b65\u90e8\u7f72Gemma-3-12B-IT WebUI<\/h3>\n<p>\u73b0\u5728\u8fdb\u5165\u6b63\u9898&#xff0c;\u6211\u4eec\u6765\u5b9e\u9645\u90e8\u7f72\u8fd9\u4e2a\u6a21\u578b\u7684Web\u754c\u9762\u3002\u6211\u63d0\u4f9b\u7684\u8fd9\u4e2a\u65b9\u6cd5\u7ecf\u8fc7\u591a\u6b21\u6d4b\u8bd5&#xff0c;\u662f\u6700\u7a33\u5b9a\u3001\u6700\u7701\u4e8b\u7684\u65b9\u6848\u3002<\/p>\n<h4>3.1 \u83b7\u53d6\u90e8\u7f72\u811a\u672c<\/h4>\n<p>\u6211\u4e3a\u4f60\u51c6\u5907\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u90e8\u7f72\u811a\u672c&#xff0c;\u5305\u542b\u4e86\u6240\u6709\u5fc5\u8981\u7684\u6b65\u9aa4\u3002\u628a\u8fd9\u4e2a\u811a\u672c\u4fdd\u5b58\u5230\u4f60\u7684\u670d\u52a1\u5668\u4e0a&#xff1a;<\/p>\n<p># \u521b\u5efa\u90e8\u7f72\u811a\u672c<br \/>\ncat &gt; deploy_gemma.sh &lt;&lt; &#039;EOF&#039;<br \/>\n#!\/bin\/bash<\/p>\n<p>echo &#034;&#061;&#061;&#061; Gemma-3-12B-IT WebUI \u90e8\u7f72\u811a\u672c &#061;&#061;&#061;&#034;<br \/>\necho &#034;\u5f00\u59cb\u65f6\u95f4: $(date)&#034;<\/p>\n<p># \u68c0\u67e5\u662f\u5426\u5728\u865a\u62df\u73af\u5883\u4e2d<br \/>\nif [ -z &#034;$VIRTUAL_ENV&#034; ]; then<br \/>\n    echo &#034;\u9519\u8bef&#xff1a;\u8bf7\u5148\u6fc0\u6d3bPython\u865a\u62df\u73af\u5883&#034;<br \/>\n    echo &#034;\u6267\u884c: source venv\/bin\/activate&#034;<br \/>\n    exit 1<br \/>\nfi<\/p>\n<p># \u6b65\u9aa41&#xff1a;\u5b89\u88c5PyTorch&#xff08;\u6839\u636e\u662f\u5426\u6709GPU\u9009\u62e9&#xff09;<br \/>\necho &#034;\u6b65\u9aa41&#xff1a;\u5b89\u88c5PyTorch&#8230;&#034;<br \/>\nif command -v nvidia-smi &amp;&gt; \/dev\/null; then<br \/>\n    echo &#034;\u68c0\u6d4b\u5230GPU&#xff0c;\u5b89\u88c5CUDA\u7248\u672c\u7684PyTorch&#034;<br \/>\n    pip3 install torch torchvision torchaudio &#8211;index-url https:\/\/download.pytorch.org\/whl\/cu118<br \/>\nelse<br \/>\n    echo &#034;\u672a\u68c0\u6d4b\u5230GPU&#xff0c;\u5b89\u88c5CPU\u7248\u672c\u7684PyTorch&#034;<br \/>\n    pip3 install torch torchvision torchaudio &#8211;index-url https:\/\/download.pytorch.org\/whl\/cpu<br \/>\nfi<\/p>\n<p># \u6b65\u9aa42&#xff1a;\u5b89\u88c5WebUI\u4f9d\u8d56<br \/>\necho &#034;\u6b65\u9aa42&#xff1a;\u5b89\u88c5WebUI\u4f9d\u8d56&#8230;&#034;<br \/>\npip3 install gradio&#061;&#061;4.19.0<br \/>\npip3 install transformers&#061;&#061;4.36.0<br \/>\npip3 install accelerate&#061;&#061;0.25.0<br \/>\npip3 install sentencepiece&#061;&#061;0.1.99<br \/>\npip3 install protobuf&#061;&#061;3.20.3<\/p>\n<p># \u6b65\u9aa43&#xff1a;\u4e0b\u8f7d\u6a21\u578b&#xff08;\u5982\u679c\u672c\u5730\u6ca1\u6709&#xff09;<br \/>\necho &#034;\u6b65\u9aa43&#xff1a;\u68c0\u67e5\u6a21\u578b\u6587\u4ef6&#8230;&#034;<br \/>\nMODEL_PATH&#061;&#034;\/root\/ai-models\/LLM-Research\/gemma-3-12b-it&#034;<br \/>\nif [ ! -d &#034;$MODEL_PATH&#034; ]; then<br \/>\n    echo &#034;\u6a21\u578b\u76ee\u5f55\u4e0d\u5b58\u5728&#xff0c;\u8bf7\u786e\u4fdd\u6a21\u578b\u5df2\u6b63\u786e\u653e\u7f6e&#034;<br \/>\n    echo &#034;\u6a21\u578b\u5e94\u8be5\u4f4d\u4e8e: $MODEL_PATH&#034;<br \/>\n    echo &#034;\u5982\u679c\u9700\u8981\u4e0b\u8f7d&#xff0c;\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863&#034;<br \/>\n    exit 1<br \/>\nelse<br \/>\n    echo &#034;\u6a21\u578b\u76ee\u5f55\u5b58\u5728: $MODEL_PATH&#034;<br \/>\nfi<\/p>\n<p># \u6b65\u9aa44&#xff1a;\u521b\u5efaWebUI\u5e94\u7528\u6587\u4ef6<br \/>\necho &#034;\u6b65\u9aa44&#xff1a;\u521b\u5efaWebUI\u5e94\u7528&#8230;&#034;<br \/>\ncat &gt; app.py &lt;&lt; &#039;PYEOF&#039;<br \/>\nimport gradio as gr<br \/>\nfrom transformers import AutoTokenizer, AutoModelForCausalLM<br \/>\nimport torch<br \/>\nimport time<\/p>\n<p># \u6a21\u578b\u8def\u5f84<br \/>\nMODEL_PATH &#061; &#034;\/root\/ai-models\/LLM-Research\/gemma-3-12b-it&#034;<\/p>\n<p># \u52a0\u8f7d\u6a21\u578b\u548c\u5206\u8bcd\u5668<br \/>\nprint(&#034;\u6b63\u5728\u52a0\u8f7d\u6a21\u578b&#xff0c;\u8fd9\u53ef\u80fd\u9700\u8981\u51e0\u5206\u949f&#8230;&#034;)<br \/>\nstart_time &#061; time.time()<\/p>\n<p>tokenizer &#061; AutoTokenizer.from_pretrained(MODEL_PATH)<br \/>\nmodel &#061; AutoModelForCausalLM.from_pretrained(<br \/>\n    MODEL_PATH,<br \/>\n    torch_dtype&#061;torch.float16 if torch.cuda.is_available() else torch.float32,<br \/>\n    device_map&#061;&#034;auto&#034;,<br \/>\n    low_cpu_mem_usage&#061;True<br \/>\n)<\/p>\n<p>print(f&#034;\u6a21\u578b\u52a0\u8f7d\u5b8c\u6210&#xff0c;\u8017\u65f6: {time.time() &#8211; start_time:.2f}\u79d2&#034;)<\/p>\n<p>def generate_response(message, history, temperature&#061;0.7, max_tokens&#061;512):<br \/>\n    &#034;&#034;&#034;\u751f\u6210\u56de\u590d&#034;&#034;&#034;<br \/>\n    try:<br \/>\n        # \u6784\u5efa\u5bf9\u8bdd\u5386\u53f2<br \/>\n        prompt &#061; &#034;&#034;<br \/>\n        if history:<br \/>\n            for user_msg, assistant_msg in history:<br \/>\n                prompt &#043;&#061; f&#034;\u7528\u6237: {user_msg}\\\\n\u52a9\u624b: {assistant_msg}\\\\n&#034;<br \/>\n        prompt &#043;&#061; f&#034;\u7528\u6237: {message}\\\\n\u52a9\u624b: &#034;<\/p>\n<p>        # \u7f16\u7801\u8f93\u5165<br \/>\n        inputs &#061; tokenizer(prompt, return_tensors&#061;&#034;pt&#034;, truncation&#061;True, max_length&#061;2048)<\/p>\n<p>        # \u79fb\u52a8\u5230\u6b63\u786e\u7684\u8bbe\u5907<br \/>\n        if torch.cuda.is_available():<br \/>\n            inputs &#061; {k: v.cuda() for k, v in inputs.items()}<\/p>\n<p>        # \u751f\u6210\u56de\u590d<br \/>\n        with torch.no_grad():<br \/>\n            outputs &#061; model.generate(<br \/>\n                **inputs,<br \/>\n                max_new_tokens&#061;max_tokens,<br \/>\n                temperature&#061;temperature,<br \/>\n                top_p&#061;0.9,<br \/>\n                do_sample&#061;True,<br \/>\n                pad_token_id&#061;tokenizer.eos_token_id<br \/>\n            )<\/p>\n<p>        # \u89e3\u7801\u56de\u590d<br \/>\n        response &#061; tokenizer.decode(outputs[0][inputs[&#039;input_ids&#039;].shape[1]:], skip_special_tokens&#061;True)<\/p>\n<p>        return response.strip()<\/p>\n<p>    except Exception as e:<br \/>\n        return f&#034;\u751f\u6210\u56de\u590d\u65f6\u51fa\u9519: {str(e)}&#034;<\/p>\n<p># \u521b\u5efaGradio\u754c\u9762<br \/>\nwith gr.Blocks(title&#061;&#034;Gemma-3-12B-IT \u804a\u5929\u52a9\u624b&#034;, theme&#061;gr.themes.Soft()) as demo:<br \/>\n    gr.Markdown(&#034;# &#x1f916; Gemma-3-12B-IT \u804a\u5929\u52a9\u624b&#034;)<br \/>\n    gr.Markdown(&#034;Google\u6700\u65b0120\u4ebf\u53c2\u6570\u6307\u4ee4\u5fae\u8c03\u6a21\u578b&#xff0c;\u652f\u6301\u4ee3\u7801\u751f\u6210\u3001\u77e5\u8bc6\u95ee\u7b54\u3001\u6587\u672c\u521b\u4f5c\u7b49&#034;)<\/p>\n<p>    # \u804a\u5929\u754c\u9762<br \/>\n    chatbot &#061; gr.Chatbot(height&#061;500, label&#061;&#034;\u5bf9\u8bdd\u5386\u53f2&#034;)<\/p>\n<p>    with gr.Row():<br \/>\n        msg &#061; gr.Textbox(<br \/>\n            label&#061;&#034;\u8f93\u5165\u4f60\u7684\u95ee\u9898&#034;,<br \/>\n            placeholder&#061;&#034;\u4f8b\u5982&#xff1a;\u5199\u4e00\u4e2aPython\u5feb\u901f\u6392\u5e8f\u51fd\u6570&#8230;&#034;,<br \/>\n            scale&#061;4<br \/>\n        )<br \/>\n        submit_btn &#061; gr.Button(&#034;\u53d1\u9001&#034;, variant&#061;&#034;primary&#034;, scale&#061;1)<\/p>\n<p>    with gr.Row():<br \/>\n        clear_btn &#061; gr.Button(&#034;\u6e05\u7a7a\u5bf9\u8bdd&#034;, variant&#061;&#034;secondary&#034;)<\/p>\n<p>    with gr.Accordion(&#034;\u9ad8\u7ea7\u53c2\u6570&#034;, open&#061;False):<br \/>\n        temperature &#061; gr.Slider(<br \/>\n            minimum&#061;0.1,<br \/>\n            maximum&#061;1.5,<br \/>\n            value&#061;0.7,<br \/>\n            step&#061;0.1,<br \/>\n            label&#061;&#034;Temperature&#xff08;\u968f\u673a\u6027&#xff09;&#034;,<br \/>\n            info&#061;&#034;\u503c\u8d8a\u9ad8\u56de\u7b54\u8d8a\u6709\u521b\u610f&#xff0c;\u503c\u8d8a\u4f4e\u56de\u7b54\u8d8a\u4e25\u8c28&#034;<br \/>\n        )<br \/>\n        max_tokens &#061; gr.Slider(<br \/>\n            minimum&#061;64,<br \/>\n            maximum&#061;2048,<br \/>\n            value&#061;512,<br \/>\n            step&#061;64,<br \/>\n            label&#061;&#034;\u6700\u5927\u751f\u6210\u957f\u5ea6&#034;,<br \/>\n            info&#061;&#034;\u63a7\u5236\u56de\u590d\u7684\u6700\u5927\u957f\u5ea6&#034;<br \/>\n        )<\/p>\n<p>    # \u793a\u4f8b\u95ee\u9898<br \/>\n    gr.Examples(<br \/>\n        examples&#061;[<br \/>\n            [&#034;\u7528Python\u5199\u4e00\u4e2a\u5feb\u901f\u6392\u5e8f\u7b97\u6cd5&#034;],<br \/>\n            [&#034;\u89e3\u91ca\u4e00\u4e0b\u4ec0\u4e48\u662f\u673a\u5668\u5b66\u4e60&#034;],<br \/>\n            [&#034;\u5e2e\u6211\u5199\u4e00\u5c01\u5de5\u4f5c\u6c47\u62a5\u90ae\u4ef6&#034;],<br \/>\n            [&#034;JavaScript\u548cPython\u6709\u4ec0\u4e48\u533a\u522b&#xff1f;&#034;],<br \/>\n            [&#034;\u5199\u4e00\u4e2a\u5173\u4e8e\u4eba\u5de5\u667a\u80fd\u7684\u77ed\u6545\u4e8b&#034;]<br \/>\n        ],<br \/>\n        inputs&#061;msg,<br \/>\n        label&#061;&#034;\u8bd5\u8bd5\u8fd9\u4e9b\u95ee\u9898&#034;<br \/>\n    )<\/p>\n<p>    # \u4e8b\u4ef6\u5904\u7406<br \/>\n    def respond(message, chat_history, temp, tokens):<br \/>\n        bot_message &#061; generate_response(message, chat_history, temp, tokens)<br \/>\n        chat_history.append((message, bot_message))<br \/>\n        return &#034;&#034;, chat_history<\/p>\n<p>    msg.submit(respond, [msg, chatbot, temperature, max_tokens], [msg, chatbot])<br \/>\n    submit_btn.click(respond, [msg, chatbot, temperature, max_tokens], [msg, chatbot])<br \/>\n    clear_btn.click(lambda: None, None, chatbot, queue&#061;False)<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    demo.launch(<br \/>\n        server_name&#061;&#034;0.0.0.0&#034;,<br \/>\n        server_port&#061;7860,<br \/>\n        share&#061;False,<br \/>\n        show_error&#061;True<br \/>\n    )<br \/>\nPYEOF<\/p>\n<p>echo &#034;\u6b65\u9aa45&#xff1a;\u521b\u5efa\u7ba1\u7406\u811a\u672c&#8230;&#034;<br \/>\ncat &gt; manage.sh &lt;&lt; &#039;MGEOF&#039;<br \/>\n#!\/bin\/bash<\/p>\n<p>SCRIPT_DIR&#061;&#034;$(cd &#034;$(dirname &#034;${BASH_SOURCE[0]}&#034;)&#034; &amp;&amp; pwd)&#034;<br \/>\nLOG_DIR&#061;&#034;$SCRIPT_DIR\/logs&#034;<br \/>\nPID_FILE&#061;&#034;$SCRIPT_DIR\/app.pid&#034;<\/p>\n<p># \u521b\u5efa\u65e5\u5fd7\u76ee\u5f55<br \/>\nmkdir -p &#034;$LOG_DIR&#034;<\/p>\n<p>start() {<br \/>\n    echo &#034;\u542f\u52a8 Gemma-3 WebUI \u670d\u52a1&#8230;&#034;<br \/>\n    cd &#034;$SCRIPT_DIR&#034;<br \/>\n    source venv\/bin\/activate<br \/>\n    nohup python app.py &gt; &#034;$LOG_DIR\/app.log&#034; 2&gt;&amp;1 &amp;<br \/>\n    echo $! &gt; &#034;$PID_FILE&#034;<br \/>\n    echo &#034;\u670d\u52a1\u5df2\u542f\u52a8&#xff0c;PID: $(cat $PID_FILE)&#034;<br \/>\n    echo &#034;Web\u754c\u9762: http:\/\/$(hostname -I | awk &#039;{print $1}&#039;):7860&#034;<br \/>\n}<\/p>\n<p>stop() {<br \/>\n    if [ -f &#034;$PID_FILE&#034; ]; then<br \/>\n        PID&#061;$(cat &#034;$PID_FILE&#034;)<br \/>\n        echo &#034;\u505c\u6b62\u670d\u52a1 (PID: $PID)&#8230;&#034;<br \/>\n        kill $PID 2&gt;\/dev\/null<br \/>\n        rm -f &#034;$PID_FILE&#034;<br \/>\n        echo &#034;\u670d\u52a1\u5df2\u505c\u6b62&#034;<br \/>\n    else<br \/>\n        echo &#034;\u670d\u52a1\u672a\u8fd0\u884c&#034;<br \/>\n    fi<br \/>\n}<\/p>\n<p>restart() {<br \/>\n    stop<br \/>\n    sleep 2<br \/>\n    start<br \/>\n}<\/p>\n<p>status() {<br \/>\n    if [ -f &#034;$PID_FILE&#034; ]; then<br \/>\n        PID&#061;$(cat &#034;$PID_FILE&#034;)<br \/>\n        if ps -p $PID &gt; \/dev\/null; then<br \/>\n            echo &#034;\u670d\u52a1\u6b63\u5728\u8fd0\u884c (PID: $PID)&#034;<br \/>\n            echo &#034;\u8bbf\u95ee\u5730\u5740: http:\/\/$(hostname -I | awk &#039;{print $1}&#039;):7860&#034;<br \/>\n        else<br \/>\n            echo &#034;PID\u6587\u4ef6\u5b58\u5728\u4f46\u8fdb\u7a0b\u672a\u8fd0\u884c&#034;<br \/>\n            rm -f &#034;$PID_FILE&#034;<br \/>\n        fi<br \/>\n    else<br \/>\n        echo &#034;\u670d\u52a1\u672a\u8fd0\u884c&#034;<br \/>\n    fi<br \/>\n}<\/p>\n<p>logs() {<br \/>\n    if [ -f &#034;$LOG_DIR\/app.log&#034; ]; then<br \/>\n        tail -f &#034;$LOG_DIR\/app.log&#034;<br \/>\n    else<br \/>\n        echo &#034;\u65e5\u5fd7\u6587\u4ef6\u4e0d\u5b58\u5728&#034;<br \/>\n    fi<br \/>\n}<\/p>\n<p>case &#034;$1&#034; in<br \/>\n    start)<br \/>\n        start<br \/>\n        ;;<br \/>\n    stop)<br \/>\n        stop<br \/>\n        ;;<br \/>\n    restart)<br \/>\n        restart<br \/>\n        ;;<br \/>\n    status)<br \/>\n        status<br \/>\n        ;;<br \/>\n    logs)<br \/>\n        logs<br \/>\n        ;;<br \/>\n    *)<br \/>\n        echo &#034;\u4f7f\u7528\u65b9\u6cd5: $0 {start|stop|restart|status|logs}&#034;<br \/>\n        exit 1<br \/>\n        ;;<br \/>\nesac<br \/>\nMGEOF<\/p>\n<p>chmod &#043;x manage.sh<\/p>\n<p>echo &#034;\u6b65\u9aa46&#xff1a;\u521b\u5efaSupervisord\u914d\u7f6e&#xff08;\u53ef\u9009&#xff09;&#8230;&#034;<br \/>\ncat &gt; gemma-webui.conf &lt;&lt; &#039;SUPEOF&#039;<br \/>\n[program:gemma-webui]<br \/>\ndirectory&#061;\/root\/gemma-3-webui<br \/>\ncommand&#061;\/root\/gemma-3-webui\/venv\/bin\/python app.py<br \/>\nautostart&#061;true<br \/>\nautorestart&#061;true<br \/>\nstartretries&#061;3<br \/>\nuser&#061;root<br \/>\nredirect_stderr&#061;true<br \/>\nstdout_logfile&#061;\/root\/gemma-3-webui\/logs\/supervisor.log<br \/>\nstdout_logfile_maxbytes&#061;10MB<br \/>\nstdout_logfile_backups&#061;5<br \/>\nenvironment&#061;PYTHONUNBUFFERED&#061;&#034;1&#034;<br \/>\nSUPEOF<\/p>\n<p>echo &#034;&#061;&#061;&#061; \u90e8\u7f72\u5b8c\u6210 &#061;&#061;&#061;&#034;<br \/>\necho &#034;&#034;<br \/>\necho &#034;\u4e0b\u4e00\u6b65\u64cd\u4f5c&#xff1a;&#034;<br \/>\necho &#034;1. \u542f\u52a8\u670d\u52a1: .\/manage.sh start&#034;<br \/>\necho &#034;2. \u67e5\u770b\u72b6\u6001: .\/manage.sh status&#034;<br \/>\necho &#034;3. \u8bbf\u95eeWeb\u754c\u9762: http:\/\/\u4f60\u7684\u670d\u52a1\u5668IP:7860&#034;<br \/>\necho &#034;&#034;<br \/>\necho &#034;\u5982\u679c\u9700\u8981\u5f00\u673a\u81ea\u542f&#xff0c;\u53ef\u4ee5\u5c06\u4ee5\u4e0b\u547d\u4ee4\u6dfb\u52a0\u5230 \/etc\/rc.local:&#034;<br \/>\necho &#034;cd \/root\/gemma-3-webui &amp;&amp; .\/manage.sh start&#034;<br \/>\nEOF<\/p>\n<p># \u7ed9\u811a\u672c\u6267\u884c\u6743\u9650<br \/>\nchmod &#043;x deploy_gemma.sh<\/p>\n<p>\u8fd9\u4e2a\u811a\u672c\u505a\u4e86\u51e0\u4ef6\u91cd\u8981\u7684\u4e8b\u60c5&#xff1a;<\/p>\n<li>\u68c0\u67e5\u73af\u5883\u5e76\u5b89\u88c5\u6240\u6709\u4f9d\u8d56<\/li>\n<li>\u521b\u5efaWebUI\u5e94\u7528\u6587\u4ef6<\/li>\n<li>\u521b\u5efa\u65b9\u4fbf\u7684\u7ba1\u7406\u811a\u672c<\/li>\n<li>\u53ef\u9009\u5730\u521b\u5efaSupervisord\u914d\u7f6e&#xff08;\u7528\u4e8e\u8fdb\u7a0b\u7ba1\u7406&#xff09;<\/li>\n<h4>3.2 \u6267\u884c\u90e8\u7f72<\/h4>\n<p>\u73b0\u5728\u8fd0\u884c\u90e8\u7f72\u811a\u672c&#xff1a;<\/p>\n<p># \u786e\u4fdd\u5728\u865a\u62df\u73af\u5883\u4e2d<br \/>\nsource venv\/bin\/activate<\/p>\n<p># \u6267\u884c\u90e8\u7f72\u811a\u672c<br \/>\n.\/deploy_gemma.sh<\/p>\n<p>\u811a\u672c\u8fd0\u884c\u8fc7\u7a0b\u4e2d&#xff0c;\u4f60\u4f1a\u770b\u5230\u6bcf\u4e00\u6b65\u7684\u8fdb\u5ea6\u3002\u6700\u8017\u65f6\u7684\u90e8\u5206\u662f\u5b89\u88c5PyTorch\u548c\u52a0\u8f7d\u6a21\u578b&#xff0c;\u53ef\u80fd\u9700\u8981\u51e0\u5206\u949f\u5230\u5341\u51e0\u5206\u949f&#xff0c;\u53d6\u51b3\u4e8e\u4f60\u7684\u7f51\u7edc\u548c\u670d\u52a1\u5668\u6027\u80fd\u3002<\/p>\n<h4>3.3 \u542f\u52a8\u670d\u52a1<\/h4>\n<p>\u90e8\u7f72\u5b8c\u6210\u540e&#xff0c;\u542f\u52a8\u670d\u52a1\u5f88\u7b80\u5355&#xff1a;<\/p>\n<p># \u542f\u52a8\u670d\u52a1<br \/>\n.\/manage.sh start<\/p>\n<p># \u67e5\u770b\u72b6\u6001<br \/>\n.\/manage.sh status<\/p>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38&#xff0c;\u4f60\u4f1a\u770b\u5230\u7c7b\u4f3c\u8fd9\u6837\u7684\u8f93\u51fa&#xff1a;<\/p>\n<p>\u670d\u52a1\u6b63\u5728\u8fd0\u884c (PID: 12345)<br \/>\n\u8bbf\u95ee\u5730\u5740: http:\/\/192.168.1.100:7860<\/p>\n<p>\u73b0\u5728\u6253\u5f00\u6d4f\u89c8\u5668&#xff0c;\u8bbf\u95ee\u663e\u793a\u7684\u5730\u5740&#xff0c;\u5c31\u80fd\u770b\u5230Gemma-3\u7684\u804a\u5929\u754c\u9762\u4e86&#xff01;<\/p>\n<h3>4. \u5173\u952e\u4f18\u5316\u6280\u5de7&#xff1a;\u8ba9\u6a21\u578b\u8dd1\u5f97\u66f4\u5feb\u66f4\u7a33<\/h3>\n<p>\u90e8\u7f72\u53ea\u662f\u7b2c\u4e00\u6b65&#xff0c;\u771f\u6b63\u7684\u6311\u6218\u662f\u8ba9\u6a21\u578b\u5728\u6709\u9650\u8d44\u6e90\u4e0b\u8868\u73b0\u6700\u4f73\u3002\u4e0b\u9762\u662f\u6211\u603b\u7ed3\u7684\u51e0\u4e2a\u5173\u952e\u4f18\u5316\u6280\u5de7\u3002<\/p>\n<h4>4.1 \u5185\u5b58\u4f18\u5316&#xff1a;\u8ba932GB\u5185\u5b58\u591f\u7528<\/h4>\n<p>120\u4ebf\u53c2\u6570\u7684\u6a21\u578b\u542c\u8d77\u6765\u5f88\u5927&#xff0c;\u4f46\u901a\u8fc7\u4e00\u4e9b\u6280\u5de7&#xff0c;\u6211\u4eec\u53ef\u4ee5\u572832GB\u5185\u5b58\u7684\u670d\u52a1\u5668\u4e0a\u6d41\u7545\u8fd0\u884c\u3002<\/p>\n<p>\u6280\u5de71&#xff1a;\u4f7f\u7528\u534a\u7cbe\u5ea6\u6d6e\u70b9\u6570<\/p>\n<p>\u8fd9\u662f\u6700\u91cd\u8981\u7684\u4f18\u5316&#xff01;\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;PyTorch\u4f7f\u7528float32&#xff08;\u5355\u7cbe\u5ea6&#xff09;&#xff0c;\u6bcf\u4e2a\u53c2\u6570\u53604\u5b57\u8282\u3002120\u4ebf\u53c2\u6570\u5c31\u9700\u898148GB\u5185\u5b58&#xff0c;\u8fd9\u663e\u7136\u4e0d\u884c\u3002<\/p>\n<p># \u4f18\u5316\u524d&#xff1a;\u4f7f\u7528float32<br \/>\nmodel &#061; AutoModelForCausalLM.from_pretrained(MODEL_PATH)<\/p>\n<p># \u4f18\u5316\u540e&#xff1a;\u4f7f\u7528float16&#xff08;\u534a\u7cbe\u5ea6&#xff09;<br \/>\nmodel &#061; AutoModelForCausalLM.from_pretrained(<br \/>\n    MODEL_PATH,<br \/>\n    torch_dtype&#061;torch.float16,  # \u5173\u952e\u53c2\u6570&#xff01;<br \/>\n    device_map&#061;&#034;auto&#034;<br \/>\n)<\/p>\n<p>\u4f7f\u7528float16\u540e&#xff0c;\u6bcf\u4e2a\u53c2\u6570\u53ea\u53602\u5b57\u8282&#xff0c;\u5185\u5b58\u9700\u6c42\u76f4\u63a5\u51cf\u534a&#xff0c;\u53d8\u621024GB\u3002\u5982\u679c\u4f60\u7684GPU\u652f\u6301bfloat16&#xff0c;\u6548\u679c\u4f1a\u66f4\u597d\u3002<\/p>\n<p>\u6280\u5de72&#xff1a;\u542f\u7528\u4f4eCPU\u5185\u5b58\u4f7f\u7528\u6a21\u5f0f<\/p>\n<p>model &#061; AutoModelForCausalLM.from_pretrained(<br \/>\n    MODEL_PATH,<br \/>\n    torch_dtype&#061;torch.float16,<br \/>\n    device_map&#061;&#034;auto&#034;,<br \/>\n    low_cpu_mem_usage&#061;True  # \u8fd9\u4e2a\u53c2\u6570\u5f88\u91cd\u8981&#xff01;<br \/>\n)<\/p>\n<p>\u8fd9\u4e2a\u53c2\u6570\u544a\u8bc9transformers\u5e93\u5728\u52a0\u8f7d\u6a21\u578b\u65f6\u5c3d\u91cf\u51cf\u5c11CPU\u5185\u5b58\u7684\u4f7f\u7528&#xff0c;\u7279\u522b\u662f\u5728\u5185\u5b58\u6709\u9650\u7684\u7cfb\u7edf\u4e0a\u3002<\/p>\n<p>\u6280\u5de73&#xff1a;\u5206\u7247\u52a0\u8f7d&#xff08;\u5982\u679c\u5185\u5b58\u771f\u7684\u5f88\u7d27\u5f20&#xff09;<\/p>\n<p>\u5982\u679c\u4f60\u7684\u5185\u5b58\u5c0f\u4e8e24GB&#xff0c;\u53ef\u4ee5\u5c1d\u8bd5\u5206\u7247\u52a0\u8f7d&#xff1a;<\/p>\n<p>from transformers import AutoConfig<\/p>\n<p># \u5148\u52a0\u8f7d\u914d\u7f6e<br \/>\nconfig &#061; AutoConfig.from_pretrained(MODEL_PATH)<\/p>\n<p># \u7136\u540e\u5206\u7247\u52a0\u8f7d\u6a21\u578b<br \/>\nmodel &#061; AutoModelForCausalLM.from_pretrained(<br \/>\n    MODEL_PATH,<br \/>\n    torch_dtype&#061;torch.float16,<br \/>\n    device_map&#061;&#034;auto&#034;,<br \/>\n    low_cpu_mem_usage&#061;True,<br \/>\n    offload_folder&#061;&#034;offload&#034;,  # \u4e34\u65f6\u5378\u8f7d\u6587\u4ef6\u5939<br \/>\n    offload_state_dict&#061;True    # \u5378\u8f7d\u72b6\u6001\u5b57\u5178<br \/>\n)<\/p>\n<h4>4.2 \u901f\u5ea6\u4f18\u5316&#xff1a;\u51cf\u5c11\u7b49\u5f85\u65f6\u95f4<\/h4>\n<p>\u6ca1\u6709\u4eba\u559c\u6b22\u7b49\u5f85&#xff0c;\u7279\u522b\u662f\u5728\u5bf9\u8bdd\u65f6\u3002\u4e0b\u9762\u8fd9\u4e9b\u6280\u5de7\u80fd\u663e\u8457\u63d0\u5347\u54cd\u5e94\u901f\u5ea6\u3002<\/p>\n<p>\u6280\u5de71&#xff1a;\u8c03\u6574\u751f\u6210\u53c2\u6570<\/p>\n<p># \u751f\u6210\u56de\u590d\u65f6\u7684\u4f18\u5316\u53c2\u6570<br \/>\noutputs &#061; model.generate(<br \/>\n    **inputs,<br \/>\n    max_new_tokens&#061;512,      # \u9650\u5236\u751f\u6210\u957f\u5ea6<br \/>\n    temperature&#061;0.7,         # \u5e73\u8861\u521b\u610f\u548c\u51c6\u786e<br \/>\n    top_p&#061;0.9,              # \u6838\u91c7\u6837&#xff0c;\u63d0\u9ad8\u8d28\u91cf<br \/>\n    do_sample&#061;True,          # \u542f\u7528\u91c7\u6837<br \/>\n    pad_token_id&#061;tokenizer.eos_token_id,<\/p>\n<p>    # \u901f\u5ea6\u4f18\u5316\u53c2\u6570<br \/>\n    no_repeat_ngram_size&#061;3,  # \u907f\u514d\u91cd\u590d<br \/>\n    repetition_penalty&#061;1.1,  # \u91cd\u590d\u60e9\u7f5a<br \/>\n    length_penalty&#061;1.0,      # \u957f\u5ea6\u60e9\u7f5a<br \/>\n)<\/p>\n<p>\u6280\u5de72&#xff1a;\u4f7f\u7528KV\u7f13\u5b58&#xff08;\u5982\u679c\u652f\u6301&#xff09;<\/p>\n<p>KV\u7f13\u5b58\u80fd\u663e\u8457\u63d0\u5347\u8fde\u7eed\u5bf9\u8bdd\u7684\u901f\u5ea6&#xff1a;<\/p>\n<p># \u7b2c\u4e00\u6b21\u751f\u6210<br \/>\noutputs &#061; model.generate(**inputs, use_cache&#061;True)<br \/>\npast_key_values &#061; outputs.past_key_values<\/p>\n<p># \u540e\u7eed\u751f\u6210\u65f6\u590d\u7528\u7f13\u5b58<br \/>\nnext_outputs &#061; model.generate(<br \/>\n    next_inputs,<br \/>\n    past_key_values&#061;past_key_values,<br \/>\n    use_cache&#061;True<br \/>\n)<\/p>\n<p>\u6280\u5de73&#xff1a;\u6279\u5904\u7406\u8bf7\u6c42<\/p>\n<p>\u5982\u679c\u4f60\u9700\u8981\u5904\u7406\u591a\u4e2a\u8bf7\u6c42&#xff0c;\u5c3d\u91cf\u6279\u5904\u7406&#xff1a;<\/p>\n<p># \u5355\u4e2a\u8bf7\u6c42<br \/>\nresponse1 &#061; generate_response(&#034;\u95ee\u98981&#034;)<br \/>\nresponse2 &#061; generate_response(&#034;\u95ee\u98982&#034;)<\/p>\n<p># \u6279\u5904\u7406&#xff08;\u5982\u679c\u903b\u8f91\u5141\u8bb8&#xff09;<br \/>\nresponses &#061; batch_generate([&#034;\u95ee\u98981&#034;, &#034;\u95ee\u98982&#034;])<\/p>\n<h4>4.3 \u8d28\u91cf\u4f18\u5316&#xff1a;\u8ba9\u56de\u7b54\u66f4\u51c6\u786e\u6709\u7528<\/h4>\n<p>\u901f\u5ea6\u5f88\u91cd\u8981&#xff0c;\u4f46\u8d28\u91cf\u66f4\u91cd\u8981\u3002\u8fd9\u4e9b\u6280\u5de7\u80fd\u8ba9Gemma-3\u7684\u56de\u7b54\u66f4\u7b26\u5408\u4f60\u7684\u671f\u671b\u3002<\/p>\n<p>\u6280\u5de71&#xff1a;\u6e29\u5ea6\u53c2\u6570\u8c03\u4f18<\/p>\n<p>\u6e29\u5ea6&#xff08;Temperature&#xff09;\u63a7\u5236\u968f\u673a\u6027&#xff0c;\u4e0d\u540c\u4efb\u52a1\u9700\u8981\u4e0d\u540c\u7684\u8bbe\u7f6e&#xff1a;<\/p>\n<p># \u4e0d\u540c\u4efb\u52a1\u7684\u6700\u4f73\u6e29\u5ea6\u8bbe\u7f6e<br \/>\nTASK_SETTINGS &#061; {<br \/>\n    &#034;\u4ee3\u7801\u751f\u6210&#034;: 0.2,      # \u4f4e\u6e29\u5ea6&#xff0c;\u786e\u4fdd\u4ee3\u7801\u51c6\u786e<br \/>\n    &#034;\u77e5\u8bc6\u95ee\u7b54&#034;: 0.7,      # \u4e2d\u7b49\u6e29\u5ea6&#xff0c;\u5e73\u8861\u51c6\u786e\u548c\u6d41\u7545<br \/>\n    &#034;\u521b\u610f\u5199\u4f5c&#034;: 1.0,      # \u9ad8\u6e29\u5ea6&#xff0c;\u66f4\u6709\u521b\u610f<br \/>\n    &#034;\u7ffb\u8bd1\u4efb\u52a1&#034;: 0.5,      # \u4f4e\u6e29\u5ea6&#xff0c;\u4fdd\u6301\u539f\u610f<br \/>\n    &#034;\u603b\u7ed3\u5f52\u7eb3&#034;: 0.6,      # \u4e2d\u7b49\u504f\u4f4e&#xff0c;\u786e\u4fdd\u5173\u952e\u4fe1\u606f<br \/>\n}<\/p>\n<p>def get_optimal_temperature(task_type):<br \/>\n    return TASK_SETTINGS.get(task_type, 0.7)<\/p>\n<p>\u6280\u5de72&#xff1a;\u66f4\u597d\u7684\u63d0\u793a\u8bcd\u5de5\u7a0b<\/p>\n<p>Gemma-3\u5bf9\u63d0\u793a\u8bcd\u5f88\u654f\u611f&#xff0c;\u597d\u7684\u63d0\u793a\u8bcd\u80fd\u5927\u5e45\u63d0\u5347\u56de\u7b54\u8d28\u91cf&#xff1a;<\/p>\n<p># \u4e0d\u597d\u7684\u63d0\u793a\u8bcd<br \/>\nprompt &#061; &#034;\u5199\u4ee3\u7801&#034;<\/p>\n<p># \u597d\u7684\u63d0\u793a\u8bcd<br \/>\ngood_prompt &#061; &#034;&#034;&#034;\u8bf7\u7528Python\u5199\u4e00\u4e2a\u5feb\u901f\u6392\u5e8f\u51fd\u6570&#xff0c;\u8981\u6c42&#xff1a;<br \/>\n1. \u5305\u542b\u8be6\u7ec6\u7684\u6ce8\u91ca<br \/>\n2. \u5904\u7406\u7a7a\u5217\u8868\u548c\u5355\u5143\u7d20\u5217\u8868\u7684\u60c5\u51b5<br \/>\n3. \u6dfb\u52a0\u7c7b\u578b\u63d0\u793a<br \/>\n4. \u5305\u542b\u4f7f\u7528\u793a\u4f8b<\/p>\n<p>\u8bf7\u786e\u4fdd\u4ee3\u7801\u7b26\u5408PEP8\u89c4\u8303\u3002&#034;&#034;&#034;<\/p>\n<p>\u6280\u5de73&#xff1a;\u7cfb\u7edf\u6307\u4ee4\u8bbe\u7f6e<\/p>\n<p>\u867d\u7136Gemma-3\u4e0d\u662f\u804a\u5929\u6a21\u578b&#xff0c;\u4f46\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u6307\u4ee4\u6765\u5f15\u5bfc\u5b83&#xff1a;<\/p>\n<p>system_instruction &#061; &#034;&#034;&#034;\u4f60\u662f\u4e00\u4e2a\u4e13\u4e1a\u7684\u7f16\u7a0b\u52a9\u624b&#xff0c;\u64c5\u957fPython\u3001JavaScript\u548cJava\u3002<br \/>\n\u4f60\u7684\u56de\u7b54\u5e94\u8be5&#xff1a;<br \/>\n1. \u51c6\u786e\u4e14\u5b9e\u7528<br \/>\n2. \u5305\u542b\u4ee3\u7801\u793a\u4f8b<br \/>\n3. \u89e3\u91ca\u5173\u952e\u6982\u5ff5<br \/>\n4. \u7ed9\u51fa\u6700\u4f73\u5b9e\u8df5\u5efa\u8bae<\/p>\n<p>\u5982\u679c\u7528\u6237\u7684\u95ee\u9898\u4e0d\u6e05\u695a&#xff0c;\u8bf7\u793c\u8c8c\u5730\u8bf7\u6c42\u6f84\u6e05\u3002&#034;&#034;&#034;<\/p>\n<p>prompt &#061; f&#034;{system_instruction}\\\\n\\\\n\u7528\u6237: {user_message}\\\\n\u52a9\u624b: &#034;<\/p>\n<h4>4.4 \u7a33\u5b9a\u6027\u4f18\u5316&#xff1a;\u786e\u4fdd7&#215;24\u5c0f\u65f6\u8fd0\u884c<\/h4>\n<p>\u5bf9\u4e8e\u751f\u4ea7\u73af\u5883&#xff0c;\u7a33\u5b9a\u6027\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p>\u6280\u5de71&#xff1a;\u6dfb\u52a0\u8d85\u65f6\u548c\u91cd\u8bd5\u673a\u5236<\/p>\n<p>import signal<br \/>\nfrom functools import wraps<\/p>\n<p>def timeout(seconds&#061;30):<br \/>\n    &#034;&#034;&#034;\u8d85\u65f6\u88c5\u9970\u5668&#034;&#034;&#034;<br \/>\n    def decorator(func):<br \/>\n        &#064;wraps(func)<br \/>\n        def wrapper(*args, **kwargs):<br \/>\n            def handler(signum, frame):<br \/>\n                raise TimeoutError(&#034;\u751f\u6210\u8d85\u65f6&#034;)<\/p>\n<p>            # \u8bbe\u7f6e\u8d85\u65f6<br \/>\n            signal.signal(signal.SIGALRM, handler)<br \/>\n            signal.alarm(seconds)<\/p>\n<p>            try:<br \/>\n                result &#061; func(*args, **kwargs)<br \/>\n            finally:<br \/>\n                signal.alarm(0)  # \u53d6\u6d88\u8d85\u65f6<\/p>\n<p>            return result<br \/>\n        return wrapper<br \/>\n    return decorator<\/p>\n<p>&#064;timeout(30)<br \/>\ndef safe_generate_response(message, history):<br \/>\n    return generate_response(message, history)<\/p>\n<p>\u6280\u5de72&#xff1a;\u5185\u5b58\u76d1\u63a7\u548c\u6e05\u7406<\/p>\n<p>import gc<br \/>\nimport torch<\/p>\n<p>def clean_memory():<br \/>\n    &#034;&#034;&#034;\u6e05\u7406GPU\u548cCPU\u5185\u5b58&#034;&#034;&#034;<br \/>\n    if torch.cuda.is_available():<br \/>\n        torch.cuda.empty_cache()<br \/>\n        torch.cuda.synchronize()<\/p>\n<p>    gc.collect()<\/p>\n<p># \u5728\u957f\u65f6\u95f4\u8fd0\u884c\u540e\u8c03\u7528<br \/>\nclean_memory()<\/p>\n<p>\u6280\u5de73&#xff1a;\u5b9e\u73b0\u5065\u5eb7\u68c0\u67e5\u63a5\u53e3<\/p>\n<p># \u5728app.py\u4e2d\u6dfb\u52a0\u5065\u5eb7\u68c0\u67e5<br \/>\n&#064;app.route(&#039;\/health&#039;)<br \/>\ndef health_check():<br \/>\n    try:<br \/>\n        # \u7b80\u5355\u6d4b\u8bd5\u6a21\u578b\u662f\u5426\u53ef\u7528<br \/>\n        test_input &#061; tokenizer(&#034;test&#034;, return_tensors&#061;&#034;pt&#034;)<br \/>\n        return jsonify({&#034;status&#034;: &#034;healthy&#034;, &#034;model&#034;: &#034;gemma-3-12b-it&#034;})<br \/>\n    except Exception as e:<br \/>\n        return jsonify({&#034;status&#034;: &#034;unhealthy&#034;, &#034;error&#034;: str(e)}), 500<\/p>\n<h3>5. \u5b9e\u9645\u4f7f\u7528\u6848\u4f8b\u548c\u6548\u679c<\/h3>\n<p>\u7406\u8bba\u8bf4\u518d\u591a&#xff0c;\u4e0d\u5982\u770b\u770b\u5b9e\u9645\u6548\u679c\u3002\u4e0b\u9762\u662f\u6211\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\u7684\u51e0\u4e2a\u6848\u4f8b\u3002<\/p>\n<h4>5.1 \u4ee3\u7801\u751f\u6210&#xff1a;\u4ece\u9700\u6c42\u5230\u5b9e\u73b0<\/h4>\n<p>\u6211\u7684\u9700\u6c42&#xff1a;\u9700\u8981\u4e00\u4e2aPython\u51fd\u6570&#xff0c;\u4eceAPI\u83b7\u53d6\u6570\u636e&#xff0c;\u5904\u7406\u5f02\u5e38&#xff0c;\u5e76\u8fd4\u56de\u7ed3\u6784\u5316\u7ed3\u679c\u3002<\/p>\n<p>\u6211\u7ed9Gemma-3\u7684\u63d0\u793a&#xff1a;<\/p>\n<p>\u5199\u4e00\u4e2aPython\u51fd\u6570&#xff0c;\u4ece\u6307\u5b9a\u7684API\u7aef\u70b9\u83b7\u53d6JSON\u6570\u636e\u3002<br \/>\n\u8981\u6c42&#xff1a;<br \/>\n1. \u6dfb\u52a0\u8bf7\u6c42\u8d85\u65f6\u548c\u91cd\u8bd5\u673a\u5236<br \/>\n2. \u5904\u7406HTTP\u9519\u8bef\u548cJSON\u89e3\u6790\u9519\u8bef<br \/>\n3. \u6dfb\u52a0\u7c7b\u578b\u63d0\u793a\u548c\u6587\u6863\u5b57\u7b26\u4e32<br \/>\n4. \u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u72b6\u6001\u548c\u6570\u636e\u7684\u7ed3\u679c\u5b57\u5178<\/p>\n<p>Gemma-3\u751f\u6210\u7684\u4ee3\u7801&#xff1a;<\/p>\n<p>import requests<br \/>\nimport json<br \/>\nfrom typing import Dict, Any, Optional<br \/>\nfrom time import sleep<\/p>\n<p>def fetch_api_data(<br \/>\n    url: str,<br \/>\n    timeout: int &#061; 10,<br \/>\n    max_retries: int &#061; 3,<br \/>\n    retry_delay: int &#061; 2<br \/>\n) -&gt; Dict[str, Any]:<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u4eceAPI\u7aef\u70b9\u83b7\u53d6JSON\u6570\u636e&#xff0c;\u5305\u542b\u9519\u8bef\u5904\u7406\u548c\u91cd\u8bd5\u673a\u5236\u3002<\/p>\n<p>    \u53c2\u6570:<br \/>\n        url: API\u7aef\u70b9URL<br \/>\n        timeout: \u8bf7\u6c42\u8d85\u65f6\u65f6\u95f4&#xff08;\u79d2&#xff09;<br \/>\n        max_retries: \u6700\u5927\u91cd\u8bd5\u6b21\u6570<br \/>\n        retry_delay: \u91cd\u8bd5\u5ef6\u8fdf&#xff08;\u79d2&#xff09;<\/p>\n<p>    \u8fd4\u56de:<br \/>\n        \u5305\u542b\u72b6\u6001\u548c\u6570\u636e\u7684\u7ed3\u679c\u5b57\u5178<br \/>\n        {<br \/>\n            &#034;success&#034;: bool,<br \/>\n            &#034;data&#034;: Optional[Dict],<br \/>\n            &#034;error&#034;: Optional[str],<br \/>\n            &#034;status_code&#034;: Optional[int]<br \/>\n        }<br \/>\n    &#034;&#034;&#034;<br \/>\n    headers &#061; {<br \/>\n        &#034;User-Agent&#034;: &#034;Mozilla\/5.0&#034;,<br \/>\n        &#034;Accept&#034;: &#034;application\/json&#034;<br \/>\n    }<\/p>\n<p>    for attempt in range(max_retries):<br \/>\n        try:<br \/>\n            response &#061; requests.get(<br \/>\n                url,<br \/>\n                headers&#061;headers,<br \/>\n                timeout&#061;timeout<br \/>\n            )<br \/>\n            response.raise_for_status()  # \u68c0\u67e5HTTP\u9519\u8bef<\/p>\n<p>            # \u89e3\u6790JSON<br \/>\n            data &#061; response.json()<\/p>\n<p>            return {<br \/>\n                &#034;success&#034;: True,<br \/>\n                &#034;data&#034;: data,<br \/>\n                &#034;error&#034;: None,<br \/>\n                &#034;status_code&#034;: response.status_code<br \/>\n            }<\/p>\n<p>        except requests.exceptions.Timeout:<br \/>\n            error_msg &#061; f&#034;\u8bf7\u6c42\u8d85\u65f6 (\u5c1d\u8bd5 {attempt &#043; 1}\/{max_retries})&#034;<br \/>\n            if attempt &lt; max_retries &#8211; 1:<br \/>\n                sleep(retry_delay)<br \/>\n                continue<\/p>\n<p>        except requests.exceptions.HTTPError as e:<br \/>\n            return {<br \/>\n                &#034;success&#034;: False,<br \/>\n                &#034;data&#034;: None,<br \/>\n                &#034;error&#034;: f&#034;HTTP\u9519\u8bef: {str(e)}&#034;,<br \/>\n                &#034;status_code&#034;: e.response.status_code if e.response else None<br \/>\n            }<\/p>\n<p>        except json.JSONDecodeError:<br \/>\n            return {<br \/>\n                &#034;success&#034;: False,<br \/>\n                &#034;data&#034;: None,<br \/>\n                &#034;error&#034;: &#034;JSON\u89e3\u6790\u5931\u8d25&#034;,<br \/>\n                &#034;status_code&#034;: response.status_code if &#039;response&#039; in locals() else None<br \/>\n            }<\/p>\n<p>        except Exception as e:<br \/>\n            return {<br \/>\n                &#034;success&#034;: False,<br \/>\n                &#034;data&#034;: None,<br \/>\n                &#034;error&#034;: f&#034;\u672a\u77e5\u9519\u8bef: {str(e)}&#034;,<br \/>\n                &#034;status_code&#034;: None<br \/>\n            }<\/p>\n<p>    return {<br \/>\n        &#034;success&#034;: False,<br \/>\n        &#034;data&#034;: None,<br \/>\n        &#034;error&#034;: &#034;\u8fbe\u5230\u6700\u5927\u91cd\u8bd5\u6b21\u6570&#034;,<br \/>\n        &#034;status_code&#034;: None<br \/>\n    }<\/p>\n<p># \u4f7f\u7528\u793a\u4f8b<br \/>\nif __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    result &#061; fetch_api_data(&#034;https:\/\/api.example.com\/data&#034;)<br \/>\n    if result[&#034;success&#034;]:<br \/>\n        print(&#034;\u83b7\u53d6\u6570\u636e\u6210\u529f:&#034;, result[&#034;data&#034;])<br \/>\n    else:<br \/>\n        print(&#034;\u83b7\u53d6\u6570\u636e\u5931\u8d25:&#034;, result[&#034;error&#034;])<\/p>\n<p>\u6211\u7684\u8bc4\u4ef7&#xff1a;\u4ee3\u7801\u8d28\u91cf\u5f88\u9ad8&#xff01;\u4e0d\u4ec5\u5b9e\u73b0\u4e86\u6240\u6709\u9700\u6c42&#xff0c;\u8fd8\u6dfb\u52a0\u4e86\u6211\u6ca1\u60f3\u5230\u7684\u7ec6\u8282&#xff0c;\u6bd4\u5982User-Agent\u5934\u548c\u5b8c\u6574\u7684\u9519\u8bef\u5904\u7406\u3002\u6211\u76f4\u63a5\u7528\u4e86\u8fd9\u4e2a\u51fd\u6570&#xff0c;\u53ea\u505a\u4e86\u5f88\u5c0f\u7684\u8c03\u6574\u3002<\/p>\n<h4>5.2 \u6280\u672f\u89e3\u91ca&#xff1a;\u8ba9\u590d\u6742\u6982\u5ff5\u53d8\u7b80\u5355<\/h4>\n<p>\u6211\u7684\u9700\u6c42&#xff1a;\u5411\u65b0\u624b\u89e3\u91ca\u4ec0\u4e48\u662f&#034;\u5f02\u6b65\u7f16\u7a0b&#034;\u3002<\/p>\n<p>\u6211\u7ed9Gemma-3\u7684\u63d0\u793a&#xff1a;<\/p>\n<p>\u7528\u7b80\u5355\u7684\u6bd4\u55bb\u5411\u7f16\u7a0b\u65b0\u624b\u89e3\u91ca\u4ec0\u4e48\u662f\u5f02\u6b65\u7f16\u7a0b\u3002<br \/>\n\u8981\u6c42&#xff1a;<br \/>\n1. \u7528\u751f\u6d3b\u4e2d\u7684\u4f8b\u5b50\u505a\u6bd4\u55bb<br \/>\n2. \u5bf9\u6bd4\u540c\u6b65\u7f16\u7a0b<br \/>\n3. \u8bf4\u660e\u4f18\u7f3a\u70b9<br \/>\n4. \u7ed9\u51fa\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801\u793a\u4f8b<\/p>\n<p>Gemma-3\u7684\u56de\u7b54&#xff1a;<\/p>\n<p>\u60f3\u8c61\u4e00\u4e0b\u4f60\u8981\u505a\u4e00\u987f\u996d&#xff0c;\u9700\u8981\u5b8c\u6210\u4e09\u4e2a\u4efb\u52a1&#xff1a;\u716e\u996d&#xff08;20\u5206\u949f&#xff09;\u3001\u7092\u83dc&#xff08;10\u5206\u949f&#xff09;\u3001\u716e\u6c64&#xff08;15\u5206\u949f&#xff09;\u3002<\/p>\n<p>\u540c\u6b65\u7f16\u7a0b&#xff08;\u4f20\u7edf\u65b9\u5f0f&#xff09;&#xff1a; \u5c31\u50cf\u4e00\u4e2a\u4eba\u6309\u987a\u5e8f\u505a&#xff1a;<\/p>\n<li>\u5f00\u59cb\u716e\u996d&#xff0c;\u7ad9\u5728\u9505\u8fb9\u7b4920\u5206\u949f<\/li>\n<li>\u996d\u597d\u4e86&#xff0c;\u5f00\u59cb\u7092\u83dc&#xff0c;\u7b4910\u5206\u949f<\/li>\n<li>\u83dc\u597d\u4e86&#xff0c;\u5f00\u59cb\u716e\u6c64&#xff0c;\u7b4915\u5206\u949f \u603b\u5171\u8017\u65f6&#xff1a;20 &#043; 10 &#043; 15 &#061; 45\u5206\u949f \u5927\u90e8\u5206\u65f6\u95f4\u90fd\u5728\u7b49\u5f85&#xff0c;\u6548\u7387\u5f88\u4f4e\u3002<\/li>\n<p>\u5f02\u6b65\u7f16\u7a0b&#xff08;\u73b0\u4ee3\u65b9\u5f0f&#xff09;&#xff1a; \u5c31\u50cf\u806a\u660e\u7684\u53a8\u5e08&#xff1a;<\/p>\n<li>\u5f00\u59cb\u716e\u996d&#xff08;\u8bbe\u7f6e\u5b9a\u65f6\u566820\u5206\u949f&#xff09;<\/li>\n<li>\u4e0d\u7528\u7b49&#xff0c;\u7acb\u5373\u5f00\u59cb\u7092\u83dc&#xff08;10\u5206\u949f&#xff09;<\/li>\n<li>\u7092\u83dc\u65f6\u6c64\u9505\u52a0\u6c34\u5f00\u706b&#xff08;15\u5206\u949f&#xff09;<\/li>\n<li>\u5728\u7b49\u5f85\u671f\u95f4\u51c6\u5907\u5176\u4ed6\u98df\u6750 \u603b\u5171\u8017\u65f6&#xff1a;\u7ea620\u5206\u949f&#xff08;\u6700\u957f\u7684\u90a3\u4e2a\u4efb\u52a1&#xff09; \u5145\u5206\u5229\u7528\u4e86\u7b49\u5f85\u65f6\u95f4&#xff0c;\u6548\u7387\u5927\u5927\u63d0\u9ad8\u3002<\/li>\n<p>\u4ee3\u7801\u793a\u4f8b\u5bf9\u6bd4&#xff1a;<\/p>\n<p># \u540c\u6b65\u7248\u672c&#xff08;\u4f4e\u6548&#xff09;<br \/>\nimport time<\/p>\n<p>def cook_rice():<br \/>\n    time.sleep(20)  # \u716e\u996d20\u5206\u949f<br \/>\n    print(&#034;\u996d\u597d\u4e86&#034;)<\/p>\n<p>def cook_dish():<br \/>\n    time.sleep(10)  # \u7092\u83dc10\u5206\u949f<br \/>\n    print(&#034;\u83dc\u597d\u4e86&#034;)<\/p>\n<p>def cook_soup():<br \/>\n    time.sleep(15)  # \u716e\u6c6415\u5206\u949f<br \/>\n    print(&#034;\u6c64\u597d\u4e86&#034;)<\/p>\n<p># \u6309\u987a\u5e8f\u6267\u884c&#xff0c;\u603b\u8017\u65f645\u5206\u949f<br \/>\ncook_rice()<br \/>\ncook_dish()<br \/>\ncook_soup()<\/p>\n<p># \u5f02\u6b65\u7248\u672c&#xff08;\u9ad8\u6548&#xff09;<br \/>\nimport asyncio<\/p>\n<p>async def cook_rice():<br \/>\n    await asyncio.sleep(20)<br \/>\n    print(&#034;\u996d\u597d\u4e86&#034;)<\/p>\n<p>async def cook_dish():<br \/>\n    await asyncio.sleep(10)<br \/>\n    print(&#034;\u83dc\u597d\u4e86&#034;)<\/p>\n<p>async def cook_soup():<br \/>\n    await asyncio.sleep(15)<br \/>\n    print(&#034;\u6c64\u597d\u4e86&#034;)<\/p>\n<p># \u540c\u65f6\u5f00\u59cb&#xff0c;\u603b\u8017\u65f6\u7ea620\u5206\u949f<br \/>\nasync def main():<br \/>\n    await asyncio.gather(<br \/>\n        cook_rice(),<br \/>\n        cook_dish(),<br \/>\n        cook_soup()<br \/>\n    )<\/p>\n<p>asyncio.run(main())<\/p>\n<p>\u4f18\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u63d0\u9ad8\u6548\u7387&#xff0c;\u5145\u5206\u5229\u7528\u7b49\u5f85\u65f6\u95f4<\/li>\n<li>\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c&#xff08;\u5e94\u7528\u4e0d\u4f1a\u5361\u4f4f&#xff09;<\/li>\n<li>\u80fd\u5904\u7406\u66f4\u591a\u5e76\u53d1\u8bf7\u6c42<\/li>\n<\/ul>\n<p>\u7f3a\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u4ee3\u7801\u66f4\u590d\u6742&#xff0c;\u9700\u8981\u5904\u7406\u56de\u8c03\u6216async\/await<\/li>\n<li>\u8c03\u8bd5\u56f0\u96be&#xff0c;\u9519\u8bef\u53ef\u80fd\u5728\u4e0d\u9884\u671f\u7684\u65f6\u95f4\u53d1\u751f<\/li>\n<li>\u9700\u8981\u5c0f\u5fc3\u5904\u7406\u5171\u4eab\u8d44\u6e90<\/li>\n<\/ul>\n<p>\u6211\u7684\u8bc4\u4ef7&#xff1a;\u89e3\u91ca\u5f97\u975e\u5e38\u6e05\u695a&#xff01;\u7528\u505a\u996d\u7684\u6bd4\u55bb\u8ba9\u62bd\u8c61\u6982\u5ff5\u53d8\u5f97\u5177\u4f53&#xff0c;\u4ee3\u7801\u793a\u4f8b\u4e5f\u5f88\u8d34\u5207\u3002\u6211\u76f4\u63a5\u628a\u8fd9\u6bb5\u89e3\u91ca\u7528\u5728\u4e86\u56e2\u961f\u57f9\u8bad\u4e2d\u3002<\/p>\n<h4>5.3 \u5185\u5bb9\u521b\u4f5c&#xff1a;\u4ece\u5927\u7eb2\u5230\u5b8c\u6574\u6587\u7ae0<\/h4>\n<p>\u6211\u7684\u9700\u6c42&#xff1a;\u5199\u4e00\u7bc7\u5173\u4e8e&#034;Python\u865a\u62df\u73af\u5883\u6700\u4f73\u5b9e\u8df5&#034;\u7684\u6280\u672f\u535a\u5ba2\u5927\u7eb2\u3002<\/p>\n<p>\u6211\u7ed9Gemma-3\u7684\u63d0\u793a&#xff1a;<\/p>\n<p>\u5e2e\u6211\u5236\u5b9a\u4e00\u7bc7\u6280\u672f\u535a\u5ba2\u7684\u5927\u7eb2&#xff0c;\u4e3b\u9898\u662f&#034;Python\u865a\u62df\u73af\u5883\u6700\u4f73\u5b9e\u8df5&#034;\u3002<br \/>\n\u8981\u6c42&#xff1a;<br \/>\n1. \u9762\u5411\u4e2d\u7ea7Python\u5f00\u53d1\u8005<br \/>\n2. \u5305\u542b\u5b9e\u9645\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6848<br \/>\n3. \u6709\u5177\u4f53\u7684\u547d\u4ee4\u793a\u4f8b<br \/>\n4. \u7ed3\u6784\u6e05\u6670&#xff0c;\u9002\u5408\u5199\u62102000\u5b57\u6587\u7ae0<\/p>\n<p>Gemma-3\u751f\u6210\u7684\u5927\u7eb2&#xff1a;<\/p>\n<p># Python\u865a\u62df\u73af\u5883\u5b8c\u5168\u6307\u5357&#xff1a;\u4ece\u5165\u95e8\u5230\u6700\u4f73\u5b9e\u8df5<\/p>\n<p>## 1. \u4e3a\u4ec0\u4e48\u9700\u8981\u865a\u62df\u73af\u5883&#xff1f;&#xff08;\u75db\u70b9\u5206\u6790&#xff09;<br \/>\n&#8211; \u4f9d\u8d56\u51b2\u7a81\u7684\u771f\u5b9e\u6848\u4f8b<br \/>\n&#8211; \u9879\u76ee\u9694\u79bb\u7684\u91cd\u8981\u6027<br \/>\n&#8211; \u56e2\u961f\u534f\u4f5c\u7684\u4e00\u81f4\u6027\u8981\u6c42<\/p>\n<p>## 2. \u865a\u62df\u73af\u5883\u5de5\u5177\u5bf9\u6bd4<br \/>\n### 2.1 venv&#xff08;Python\u5185\u7f6e&#xff09;<br \/>\n&#8211; \u4f18\u70b9&#xff1a;\u65e0\u9700\u5b89\u88c5\u3001\u7b80\u5355\u53ef\u9760<br \/>\n&#8211; \u7f3a\u70b9&#xff1a;\u529f\u80fd\u76f8\u5bf9\u57fa\u7840<br \/>\n&#8211; \u9002\u7528\u573a\u666f&#xff1a;\u5927\u591a\u6570\u9879\u76ee<\/p>\n<p>### 2.2 virtualenv<br \/>\n&#8211; \u4f18\u70b9&#xff1a;\u66f4\u5feb\u7684\u521b\u5efa\u901f\u5ea6\u3001\u66f4\u591a\u529f\u80fd<br \/>\n&#8211; \u7f3a\u70b9&#xff1a;\u9700\u8981\u989d\u5916\u5b89\u88c5<br \/>\n&#8211; \u9002\u7528\u573a\u666f&#xff1a;\u9700\u8981\u9ad8\u7ea7\u529f\u80fd\u7684\u9879\u76ee<\/p>\n<p>### 2.3 conda<br \/>\n&#8211; \u4f18\u70b9&#xff1a;\u8de8\u8bed\u8a00\u3001\u4e8c\u8fdb\u5236\u5305\u7ba1\u7406<br \/>\n&#8211; \u7f3a\u70b9&#xff1a;\u4f53\u79ef\u8f83\u5927\u3001\u901f\u5ea6\u8f83\u6162<br \/>\n&#8211; \u9002\u7528\u573a\u666f&#xff1a;\u6570\u636e\u79d1\u5b66\u3001\u673a\u5668\u5b66\u4e60\u9879\u76ee<\/p>\n<p>### 2.4 pipenv &amp; poetry<br \/>\n&#8211; \u4f18\u70b9&#xff1a;\u4f9d\u8d56\u9501\u5b9a\u3001\u66f4\u597d\u7684\u5de5\u4f5c\u6d41<br \/>\n&#8211; \u7f3a\u70b9&#xff1a;\u5b66\u4e60\u66f2\u7ebf\u8f83\u9661<br \/>\n&#8211; \u9002\u7528\u573a\u666f&#xff1a;\u751f\u4ea7\u73af\u5883\u3001\u56e2\u961f\u9879\u76ee<\/p>\n<p>## 3. \u624b\u628a\u624b\u5b9e\u6218\u6559\u7a0b<br \/>\n### 3.1 \u4f7f\u7528venv\u521b\u5efa\u548c\u7ba1\u7406\u73af\u5883<br \/>\n&#096;&#096;&#096;bash<br \/>\n# \u521b\u5efa\u73af\u5883<br \/>\npython -m venv myenv<\/p>\n<p># \u6fc0\u6d3b\u73af\u5883&#xff08;Linux\/Mac&#xff09;<br \/>\nsource myenv\/bin\/activate<\/p>\n<p># \u6fc0\u6d3b\u73af\u5883&#xff08;Windows&#xff09;<br \/>\nmyenv\\\\Scripts\\\\activate<\/p>\n<p># \u5b89\u88c5\u5305<br \/>\npip install requests pandas<\/p>\n<p># \u5bfc\u51fa\u4f9d\u8d56<br \/>\npip freeze &gt; requirements.txt<\/p>\n<p># \u9000\u51fa\u73af\u5883<br \/>\ndeactivate<\/p>\n<h4>3.2 \u73af\u5883\u8fc1\u79fb\u548c\u590d\u5236<\/h4>\n<p># \u4ecerequirements.txt\u5b89\u88c5<br \/>\npip install -r requirements.txt<\/p>\n<p># \u7cbe\u786e\u590d\u5236\u73af\u5883<br \/>\npip list &#8211;format&#061;freeze &gt; requirements.txt<\/p>\n<p># \u4f7f\u7528pip-tools\u7ba1\u7406\u4f9d\u8d56<br \/>\npip-compile requirements.in<br \/>\npip-sync requirements.txt<\/p>\n<h3>4. \u5e38\u89c1\u95ee\u9898\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4>4.1 \u73af\u5883\u6fc0\u6d3b\u5931\u8d25<\/h4>\n<ul>\n<li>\u6743\u9650\u95ee\u9898\u89e3\u51b3<\/li>\n<li>\u8def\u5f84\u5305\u542b\u7a7a\u683c\u7684\u5904\u7406<\/li>\n<li>\u4e0d\u540cShell\u7684\u6fc0\u6d3b\u811a\u672c<\/li>\n<\/ul>\n<h4>4.2 \u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3<\/h4>\n<ul>\n<li>\u4f7f\u7528pipdeptree\u5206\u6790\u4f9d\u8d56\u6811<\/li>\n<li>\u7248\u672c\u7ea6\u675f\u7684\u5199\u6cd5<\/li>\n<li>\u51b2\u7a81\u4f9d\u8d56\u7684\u6392\u67e5\u65b9\u6cd5<\/li>\n<\/ul>\n<h4>4.3 \u73af\u5883\u81c3\u80bf\u6e05\u7406<\/h4>\n<ul>\n<li>\u67e5\u627e\u672a\u4f7f\u7528\u7684\u5305<\/li>\n<li>\u5b89\u5168\u5220\u9664\u7f13\u5b58<\/li>\n<li>\u91cd\u5efa\u5e72\u51c0\u73af\u5883<\/li>\n<\/ul>\n<h3>5. \u6700\u4f73\u5b9e\u8df5\u603b\u7ed3<\/h3>\n<h4>5.1 \u4e2a\u4eba\u5f00\u53d1<\/h4>\n<ul>\n<li>\u6bcf\u4e2a\u9879\u76ee\u72ec\u7acb\u73af\u5883<\/li>\n<li>\u4f7f\u7528\u6709\u610f\u4e49\u7684\u540d\u79f0<\/li>\n<li>\u5b9a\u671f\u6e05\u7406\u65e7\u73af\u5883<\/li>\n<\/ul>\n<h4>5.2 \u56e2\u961f\u534f\u4f5c<\/h4>\n<ul>\n<li>\u7edf\u4e00\u5de5\u5177\u548c\u6d41\u7a0b<\/li>\n<li>\u7248\u672c\u9501\u5b9a\u7b56\u7565<\/li>\n<li>CI\/CD\u96c6\u6210<\/li>\n<\/ul>\n<h4>5.3 \u751f\u4ea7\u90e8\u7f72<\/h4>\n<ul>\n<li>\u6700\u5c0f\u5316\u4f9d\u8d56<\/li>\n<li>\u5b89\u5168\u626b\u63cf<\/li>\n<li>\u4f9d\u8d56\u66f4\u65b0\u7b56\u7565<\/li>\n<\/ul>\n<h3>6. \u9ad8\u7ea7\u6280\u5de7<\/h3>\n<ul>\n<li>\u73af\u5883\u914d\u7f6e\u81ea\u52a8\u5316\u811a\u672c<\/li>\n<li>\u591aPython\u7248\u672c\u7ba1\u7406<\/li>\n<li>\u4e0eDocker\u7ed3\u5408\u4f7f\u7528<\/li>\n<li>\u6027\u80fd\u4f18\u5316\u5efa\u8bae<\/li>\n<\/ul>\n<h3>7. \u5de5\u5177\u63a8\u8350<\/h3>\n<ul>\n<li>pyenv&#xff1a;Python\u7248\u672c\u7ba1\u7406<\/li>\n<li>pipx&#xff1a;\u5168\u5c40\u5de5\u5177\u5b89\u88c5<\/li>\n<li>pre-commit&#xff1a;\u4ee3\u7801\u8d28\u91cf\u68c0\u67e5<\/li>\n<li>tox&#xff1a;\u591a\u73af\u5883\u6d4b\u8bd5<\/li>\n<\/ul>\n<p>**\u6211\u7684\u8bc4\u4ef7**&#xff1a;\u5927\u7eb2\u975e\u5e38\u4e13\u4e1a\u548c\u5168\u9762&#xff01;\u4e0d\u4ec5\u6db5\u76d6\u4e86\u6240\u6709\u91cd\u8981\u4e3b\u9898&#xff0c;\u8fd8\u7ed9\u51fa\u4e86\u5177\u4f53\u7684\u547d\u4ee4\u793a\u4f8b\u3002\u6211\u6309\u7167\u8fd9\u4e2a\u5927\u7eb2\u5199\u6587\u7ae0&#xff0c;\u8282\u7701\u4e86\u5927\u91cf\u6784\u601d\u65f6\u95f4\u3002<\/p>\n<p>## 6. \u6027\u80fd\u76d1\u63a7\u548c\u95ee\u9898\u6392\u67e5<\/p>\n<p>\u90e8\u7f72\u4f18\u5316\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u77e5\u9053\u6a21\u578b\u8fd0\u884c\u5f97\u600e\u4e48\u6837\u3002\u8fd9\u91cc\u5206\u4eab\u4e00\u4e9b\u76d1\u63a7\u548c\u6392\u67e5\u7684\u6280\u5de7\u3002<\/p>\n<p>### 6.1 \u76d1\u63a7\u5173\u952e\u6307\u6807<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u76d1\u63a7\u811a\u672c&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\n# monitor.py<br \/>\nimport psutil<br \/>\nimport torch<br \/>\nimport time<br \/>\nfrom datetime import datetime<\/p>\n<p>def monitor_system():<br \/>\n    &#034;&#034;&#034;\u76d1\u63a7\u7cfb\u7edf\u8d44\u6e90&#034;&#034;&#034;<br \/>\n    cpu_percent &#061; psutil.cpu_percent(interval&#061;1)<br \/>\n    memory &#061; psutil.virtual_memory()<\/p>\n<p>    info &#061; {<br \/>\n        &#034;timestamp&#034;: datetime.now().strftime(&#034;%Y-%m-%d %H:%M:%S&#034;),<br \/>\n        &#034;cpu_percent&#034;: cpu_percent,<br \/>\n        &#034;memory_percent&#034;: memory.percent,<br \/>\n        &#034;memory_used_gb&#034;: memory.used \/ (1024**3),<br \/>\n        &#034;memory_available_gb&#034;: memory.available \/ (1024**3),<br \/>\n    }<\/p>\n<p>    if torch.cuda.is_available():<br \/>\n        gpu_memory &#061; torch.cuda.memory_allocated() \/ (1024**3)<br \/>\n        gpu_memory_max &#061; torch.cuda.max_memory_allocated() \/ (1024**3)<br \/>\n        info.update({<br \/>\n            &#034;gpu_memory_used_gb&#034;: gpu_memory,<br \/>\n            &#034;gpu_memory_max_gb&#034;: gpu_memory_max,<br \/>\n        })<\/p>\n<p>    return info<\/p>\n<p>def log_performance(prompt, response, generation_time):<br \/>\n    &#034;&#034;&#034;\u8bb0\u5f55\u751f\u6210\u6027\u80fd&#034;&#034;&#034;<br \/>\n    with open(&#034;performance.log&#034;, &#034;a&#034;) as f:<br \/>\n        log_entry &#061; {<br \/>\n            &#034;time&#034;: datetime.now().isoformat(),<br \/>\n            &#034;prompt_length&#034;: len(prompt),<br \/>\n            &#034;response_length&#034;: len(response),<br \/>\n            &#034;generation_time&#034;: generation_time,<br \/>\n            &#034;tokens_per_second&#034;: len(response.split()) \/ generation_time if generation_time &gt; 0 else 0<br \/>\n        }<br \/>\n        f.write(str(log_entry) &#043; &#034;\\\\n&#034;)<\/p>\n<p># \u5728\u751f\u6210\u51fd\u6570\u4e2d\u6dfb\u52a0\u76d1\u63a7<br \/>\ndef generate_with_monitoring(message, history):<br \/>\n    start_time &#061; time.time()<\/p>\n<p>    # \u751f\u6210\u524d\u7684\u7cfb\u7edf\u72b6\u6001<br \/>\n    before &#061; monitor_system()<\/p>\n<p>    # \u751f\u6210\u56de\u590d<br \/>\n    response &#061; generate_response(message, history)<\/p>\n<p>    # \u751f\u6210\u540e\u7684\u7cfb\u7edf\u72b6\u6001<br \/>\n    after &#061; monitor_system()<br \/>\n    generation_time &#061; time.time() &#8211; start_time<\/p>\n<p>    # \u8bb0\u5f55\u6027\u80fd<br \/>\n    log_performance(message, response, generation_time)<\/p>\n<p>    # \u6253\u5370\u76d1\u63a7\u4fe1\u606f<br \/>\n    print(f&#034;\u751f\u6210\u65f6\u95f4: {generation_time:.2f}\u79d2&#034;)<br \/>\n    print(f&#034;\u5185\u5b58\u53d8\u5316: {after[&#039;memory_used_gb&#039;] &#8211; before[&#039;memory_used_gb&#039;]:.2f} GB&#034;)<\/p>\n<p>    return response<\/p>\n<h4>6.2 \u5e38\u89c1\u95ee\u9898\u6392\u67e5\u6307\u5357<\/h4>\n<p>\u95ee\u98981&#xff1a;\u54cd\u5e94\u901f\u5ea6\u53d8\u6162<\/p>\n<p>\u53ef\u80fd\u539f\u56e0\u548c\u89e3\u51b3\u65b9\u6848&#xff1a;<\/p>\n<p># \u68c0\u67e5\u7cfb\u7edf\u8d1f\u8f7d<br \/>\ntop -c<\/p>\n<p># \u68c0\u67e5\u5185\u5b58\u4f7f\u7528<br \/>\nfree -h<\/p>\n<p># \u68c0\u67e5GPU\u4f7f\u7528&#xff08;\u5982\u679c\u6709&#xff09;<br \/>\nnvidia-smi<\/p>\n<p># \u89e3\u51b3\u65b9\u6848&#xff1a;<br \/>\n# 1. \u91cd\u542f\u670d\u52a1\u91ca\u653e\u5185\u5b58<br \/>\n.\/manage.sh restart<\/p>\n<p># 2. \u51cf\u5c11\u5e76\u53d1\u8bf7\u6c42<br \/>\n# 3. \u8c03\u6574\u751f\u6210\u53c2\u6570&#xff08;\u51cf\u5c11max_tokens&#xff09;<br \/>\n# 4. \u6e05\u7406\u6a21\u578b\u7f13\u5b58<\/p>\n<p>\u95ee\u98982&#xff1a;\u5185\u5b58\u4e0d\u8db3\u9519\u8bef<\/p>\n<p># \u9519\u8bef\u4fe1\u606f&#xff1a;CUDA out of memory \u6216 RuntimeError<\/p>\n<p># \u89e3\u51b3\u65b9\u6848&#xff1a;<br \/>\n# 1. \u4f7f\u7528\u66f4\u5c0f\u7684\u6279\u6b21<br \/>\nmodel.generate(&#8230;, batch_size&#061;1)<\/p>\n<p># 2. \u4f7f\u7528\u68af\u5ea6\u68c0\u67e5\u70b9&#xff08;\u5982\u679c\u8bad\u7ec3&#xff09;<br \/>\nmodel.gradient_checkpointing_enable()<\/p>\n<p># 3. \u4f7f\u7528CPU\u5378\u8f7d<br \/>\nmodel &#061; AutoModelForCausalLM.from_pretrained(<br \/>\n    MODEL_PATH,<br \/>\n    device_map&#061;&#034;auto&#034;,<br \/>\n    offload_folder&#061;&#034;offload&#034;,<br \/>\n    offload_state_dict&#061;True<br \/>\n)<\/p>\n<p># 4. \u4f7f\u7528\u91cf\u5316&#xff08;\u5982\u679c\u652f\u6301&#xff09;<br \/>\nfrom transformers import BitsAndBytesConfig<br \/>\nquantization_config &#061; BitsAndBytesConfig(load_in_8bit&#061;True)<br \/>\nmodel &#061; AutoModelForCausalLM.from_pretrained(<br \/>\n    MODEL_PATH,<br \/>\n    quantization_config&#061;quantization_config<br \/>\n)<\/p>\n<p>\u95ee\u98983&#xff1a;\u751f\u6210\u8d28\u91cf\u4e0b\u964d<\/p>\n<p># \u8c03\u6574\u8fd9\u4e9b\u53c2\u6570\u6539\u5584\u8d28\u91cf&#xff1a;<\/p>\n<p># 1. \u964d\u4f4e\u6e29\u5ea6&#xff0c;\u63d0\u9ad8\u786e\u5b9a\u6027<br \/>\ntemperature&#061;0.3<\/p>\n<p># 2. \u4f7f\u7528top-p\u91c7\u6837\u800c\u4e0d\u662ftop-k<br \/>\ntop_p&#061;0.9<br \/>\ntop_k&#061;0  # \u7981\u7528top-k<\/p>\n<p># 3. \u6dfb\u52a0\u91cd\u590d\u60e9\u7f5a<br \/>\nrepetition_penalty&#061;1.2<\/p>\n<p># 4. \u4f7f\u7528\u66f4\u597d\u7684\u63d0\u793a\u8bcd<br \/>\nprompt &#061; &#034;&#034;&#034;\u8bf7\u4ed4\u7ec6\u601d\u8003\u540e\u56de\u7b54\u4ee5\u4e0b\u95ee\u9898\u3002<br \/>\n\u786e\u4fdd\u56de\u7b54\u51c6\u786e\u3001\u5b8c\u6574\u3001\u6709\u7528\u3002<\/p>\n<p>\u95ee\u9898&#xff1a;{user_question}<\/p>\n<p>\u56de\u7b54&#xff1a;&#034;&#034;&#034;<\/p>\n<h4>6.3 \u6027\u80fd\u4f18\u5316\u68c0\u67e5\u6e05\u5355<\/h4>\n<p>\u5b9a\u671f\u68c0\u67e5\u8fd9\u4e9b\u9879\u76ee&#xff0c;\u786e\u4fdd\u6700\u4f73\u6027\u80fd&#xff1a;<\/p>\n<p># \u6027\u80fd\u68c0\u67e5\u6e05\u5355<br \/>\n\u6bcf\u65e5\u68c0\u67e5:<br \/>\n  &#8211; [ ] \u5185\u5b58\u4f7f\u7528\u662f\u5426\u6b63\u5e38 (&lt;80%)<br \/>\n  &#8211; [ ] \u54cd\u5e94\u65f6\u95f4\u662f\u5426\u7a33\u5b9a (&lt;10\u79d2)<br \/>\n  &#8211; [ ] \u9519\u8bef\u7387\u662f\u5426\u6b63\u5e38 (&lt;1%)<br \/>\n  &#8211; [ ] \u670d\u52a1\u662f\u5426\u53ef\u8bbf\u95ee<\/p>\n<p>\u6bcf\u5468\u68c0\u67e5:<br \/>\n  &#8211; [ ] \u6e05\u7406\u65e5\u5fd7\u6587\u4ef6<br \/>\n  &#8211; [ ] \u66f4\u65b0Python\u5305<br \/>\n  &#8211; [ ] \u5907\u4efd\u6a21\u578b\u548c\u914d\u7f6e<br \/>\n  &#8211; [ ] \u68c0\u67e5\u78c1\u76d8\u7a7a\u95f4<\/p>\n<p>\u6bcf\u6708\u68c0\u67e5:<br \/>\n  &#8211; [ ] \u8bc4\u4f30\u751f\u6210\u8d28\u91cf<br \/>\n  &#8211; [ ] \u4f18\u5316\u63d0\u793a\u8bcd\u6a21\u677f<br \/>\n  &#8211; [ ] \u5ba1\u67e5\u6027\u80fd\u65e5\u5fd7<br \/>\n  &#8211; [ ] \u8003\u8651\u6a21\u578b\u66f4\u65b0<\/p>\n<h3>7. \u603b\u7ed3\u4e0e\u5efa\u8bae<\/h3>\n<p>\u7ecf\u8fc7\u51e0\u4e2a\u6708\u7684\u5b9e\u9645\u4f7f\u7528\u548c\u4f18\u5316&#xff0c;\u6211\u5bf9Gemma-3-12B-IT\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u8868\u73b0\u6709\u4e86\u6df1\u523b\u7684\u7406\u89e3\u3002\u4e0b\u9762\u662f\u6211\u7684\u603b\u7ed3\u548c\u4e00\u4e9b\u5b9e\u7528\u5efa\u8bae\u3002<\/p>\n<h4>7.1 \u6838\u5fc3\u6536\u83b7<\/h4>\n<p>Gemma-3-12B-IT\u7684\u4f18\u52bf&#xff1a;<\/p>\n<li>\u5e73\u8861\u6027\u597d&#xff1a;120\u4ebf\u53c2\u6570\u5728\u80fd\u529b\u548c\u8d44\u6e90\u6d88\u8017\u4e4b\u95f4\u627e\u5230\u4e86\u5f88\u597d\u7684\u5e73\u8861\u70b9<\/li>\n<li>\u5bf9\u8bdd\u80fd\u529b\u5f3a&#xff1a;\u6307\u4ee4\u5fae\u8c03\u8ba9\u5b83\u7279\u522b\u64c5\u957f\u7406\u89e3\u548c\u6267\u884c\u4eba\u7c7b\u6307\u4ee4<\/li>\n<li>\u4ee3\u7801\u751f\u6210\u4f18\u79c0&#xff1a;\u5728\u7f16\u7a0b\u4efb\u52a1\u4e0a\u8868\u73b0\u7a81\u51fa&#xff0c;\u751f\u6210\u7684\u4ee3\u7801\u8d28\u91cf\u5f88\u9ad8<\/li>\n<li>\u8d44\u6e90\u53cb\u597d&#xff1a;\u901a\u8fc7\u4f18\u5316\u53ef\u4ee5\u572832GB\u5185\u5b58\u7684\u670d\u52a1\u5668\u4e0a\u7a33\u5b9a\u8fd0\u884c<\/li>\n<p>\u90e8\u7f72\u4f18\u5316\u7684\u5173\u952e\u70b9&#xff1a;<\/p>\n<li>\u5185\u5b58\u7ba1\u7406\u662f\u6838\u5fc3&#xff1a;\u4f7f\u7528\u534a\u7cbe\u5ea6\u3001\u542f\u7528\u4f4e\u5185\u5b58\u6a21\u5f0f\u3001\u53ca\u65f6\u6e05\u7406\u7f13\u5b58<\/li>\n<li>\u53c2\u6570\u8c03\u4f18\u5f88\u91cd\u8981&#xff1a;\u4e0d\u540c\u7684\u4efb\u52a1\u9700\u8981\u4e0d\u540c\u7684\u6e29\u5ea6\u3001top-p\u7b49\u53c2\u6570<\/li>\n<li>\u63d0\u793a\u8bcd\u51b3\u5b9a\u8d28\u91cf&#xff1a;\u597d\u7684\u63d0\u793a\u8bcd\u80fd\u8ba9\u6a21\u578b\u53d1\u6325\u51fa120%\u7684\u80fd\u529b<\/li>\n<li>\u76d1\u63a7\u4e0d\u80fd\u5c11&#xff1a;\u6ca1\u6709\u76d1\u63a7&#xff0c;\u4f18\u5316\u5c31\u65e0\u4ece\u8c08\u8d77<\/li>\n<h4>7.2 \u7ed9\u4e0d\u540c\u7528\u6237\u7684\u5efa\u8bae<\/h4>\n<p>\u5982\u679c\u4f60\u662f\u5c0f\u56e2\u961f\u6216\u4e2a\u4eba\u5f00\u53d1\u8005&#xff1a;<\/p>\n<ul>\n<li>\u76f4\u63a5\u4ece\u672c\u6587\u7684\u90e8\u7f72\u811a\u672c\u5f00\u59cb&#xff0c;\u8fd9\u662f\u6700\u7701\u4e8b\u7684\u65b9\u6cd5<\/li>\n<li>\u91cd\u70b9\u5173\u6ce8\u5185\u5b58\u4f18\u5316&#xff0c;\u786e\u4fdd\u4f60\u7684\u670d\u52a1\u5668\u80fd\u8dd1\u8d77\u6765<\/li>\n<li>\u4ece\u7b80\u5355\u7684\u5bf9\u8bdd\u5f00\u59cb&#xff0c;\u9010\u6b65\u5c1d\u8bd5\u66f4\u590d\u6742\u7684\u4efb\u52a1<\/li>\n<li>\u4fdd\u5b58\u597d\u7684\u63d0\u793a\u8bcd\u6a21\u677f&#xff0c;\u5efa\u7acb\u81ea\u5df1\u7684\u77e5\u8bc6\u5e93<\/li>\n<\/ul>\n<p>\u5982\u679c\u4f60\u662f\u4f01\u4e1a\u7528\u6237&#xff1a;<\/p>\n<ul>\n<li>\u8003\u8651\u4f7f\u7528GPU\u52a0\u901f&#xff0c;\u63d0\u5347\u54cd\u5e94\u901f\u5ea6<\/li>\n<li>\u5b9e\u73b0\u5b8c\u6574\u7684\u76d1\u63a7\u548c\u544a\u8b66\u7cfb\u7edf<\/li>\n<li>\u5efa\u7acb\u63d0\u793a\u8bcd\u89c4\u8303\u548c\u6700\u4f73\u5b9e\u8df5<\/li>\n<li>\u8003\u8651\u6a21\u578b\u5fae\u8c03&#xff0c;\u8ba9\u6a21\u578b\u66f4\u7b26\u5408\u4e1a\u52a1\u9700\u6c42<\/li>\n<\/ul>\n<p>\u5982\u679c\u4f60\u8d44\u6e90\u975e\u5e38\u6709\u9650&#xff08;\u5185\u5b58&lt;24GB&#xff09;&#xff1a;<\/p>\n<ul>\n<li>\u5c1d\u8bd58\u4f4d\u91cf\u5316&#xff08;\u5982\u679c\u6a21\u578b\u652f\u6301&#xff09;<\/li>\n<li>\u4f7f\u7528CPU\u5378\u8f7d&#xff0c;\u628a\u90e8\u5206\u5c42\u653e\u5230CPU<\/li>\n<li>\u8003\u8651\u66f4\u5c0f\u7684\u6a21\u578b\u7248\u672c&#xff08;\u5982\u679c\u6709&#xff09;<\/li>\n<li>\u4f18\u5316\u63d0\u793a\u8bcd&#xff0c;\u51cf\u5c11\u751f\u6210\u957f\u5ea6<\/li>\n<\/ul>\n<h4>7.3 \u672a\u6765\u4f18\u5316\u65b9\u5411<\/h4>\n<p>\u6280\u672f\u603b\u662f\u5728\u8fdb\u6b65&#xff0c;\u8fd9\u91cc\u6709\u4e00\u4e9b\u53ef\u4ee5\u7ee7\u7eed\u63a2\u7d22\u7684\u65b9\u5411&#xff1a;<\/p>\n<li>\u6a21\u578b\u91cf\u5316&#xff1a;\u5c1d\u8bd54\u4f4d\u62168\u4f4d\u91cf\u5316&#xff0c;\u8fdb\u4e00\u6b65\u51cf\u5c11\u5185\u5b58\u5360\u7528<\/li>\n<li>\u63a8\u7406\u4f18\u5316&#xff1a;\u4f7f\u7528vLLM\u3001TGI\u7b49\u63a8\u7406\u6846\u67b6\u63d0\u5347\u901f\u5ea6<\/li>\n<li>\u7f13\u5b58\u4f18\u5316&#xff1a;\u5b9e\u73b0\u66f4\u667a\u80fd\u7684KV\u7f13\u5b58\u7ba1\u7406<\/li>\n<li>\u6279\u5904\u7406&#xff1a;\u5982\u679c\u6709\u591a\u4e2a\u8bf7\u6c42&#xff0c;\u8003\u8651\u6279\u5904\u7406\u63d0\u5347\u541e\u5410\u91cf<\/li>\n<li>\u6a21\u578b\u84b8\u998f&#xff1a;\u8bad\u7ec3\u66f4\u5c0f\u7684\u5b66\u751f\u6a21\u578b&#xff0c;\u4fdd\u6301\u80fd\u529b\u51cf\u5c11\u8d44\u6e90\u6d88\u8017<\/li>\n<h4>7.4 \u6700\u540e\u7684\u63d0\u9192<\/h4>\n<p>\u90e8\u7f72\u548c\u4f18\u5316\u5927\u8bed\u8a00\u6a21\u578b\u662f\u4e00\u4e2a\u6301\u7eed\u7684\u8fc7\u7a0b&#xff0c;\u4e0d\u662f\u4e00\u52b3\u6c38\u9038\u7684\u3002\u6211\u7684\u5efa\u8bae\u662f&#xff1a;<\/p>\n<li>\u4ece\u5c0f\u5f00\u59cb&#xff1a;\u5148\u8ba9\u6a21\u578b\u8dd1\u8d77\u6765&#xff0c;\u518d\u9010\u6b65\u4f18\u5316<\/li>\n<li>\u76d1\u63a7\u9a71\u52a8&#xff1a;\u6839\u636e\u5b9e\u9645\u76d1\u63a7\u6570\u636e\u505a\u4f18\u5316\u51b3\u7b56<\/li>\n<li>\u7528\u6237\u53cd\u9988&#xff1a;\u5173\u6ce8\u7528\u6237\u7684\u4f7f\u7528\u4f53\u9a8c&#xff0c;\u4ed6\u4eec\u6700\u77e5\u9053\u54ea\u91cc\u9700\u8981\u6539\u8fdb<\/li>\n<li>\u6301\u7eed\u5b66\u4e60&#xff1a;\u5173\u6ce8\u793e\u533a\u7684\u6700\u65b0\u8fdb\u5c55&#xff0c;\u65b0\u7684\u4f18\u5316\u65b9\u6cd5\u4e0d\u65ad\u51fa\u73b0<\/li>\n<p>Gemma-3-12B-IT\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177&#xff0c;\u4f46\u5de5\u5177\u7684\u4ef7\u503c\u5728\u4e8e\u5982\u4f55\u4f7f\u7528\u3002\u901a\u8fc7\u5408\u7406\u7684\u90e8\u7f72\u548c\u4f18\u5316&#xff0c;\u4f60\u5b8c\u5168\u53ef\u4ee5\u5728\u6709\u9650\u7684\u8d44\u6e90\u4e0b&#xff0c;\u83b7\u5f97\u63a5\u8fd1\u9ad8\u7aef\u914d\u7f6e\u7684\u4f7f\u7528\u4f53\u9a8c\u3002<\/p>\n<p>\u8bb0\u4f4f&#xff0c;\u6700\u597d\u7684\u4f18\u5316\u4e0d\u662f\u8ffd\u6c42\u6781\u81f4\u7684\u6027\u80fd&#xff0c;\u800c\u662f\u5728\u8d44\u6e90\u9650\u5236\u548c\u7528\u6237\u4f53\u9a8c\u4e4b\u95f4\u627e\u5230\u6700\u4f73\u7684\u5e73\u8861\u70b9\u3002\u5e0c\u671b\u8fd9\u7bc7\u6559\u7a0b\u80fd\u5e2e\u52a9\u4f60\u987a\u5229\u90e8\u7f72Gemma-3&#xff0c;\u5e76\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u53d1\u6325\u5b83\u7684\u4ef7\u503c\u3002<\/p>\n<hr \/>\n<p>\u83b7\u53d6\u66f4\u591aAI\u955c\u50cf<\/p>\n<p>\u60f3\u63a2\u7d22\u66f4\u591aAI\u955c\u50cf\u548c\u5e94\u7528\u573a\u666f&#xff1f;\u8bbf\u95ee CSDN\u661f\u56fe\u955c\u50cf\u5e7f\u573a&#xff0c;\u63d0\u4f9b\u4e30\u5bcc\u7684\u9884\u7f6e\u955c\u50cf&#xff0c;\u8986\u76d6\u5927\u6a21\u578b\u63a8\u7406\u3001\u56fe\u50cf\u751f\u6210\u3001\u89c6\u9891\u751f\u6210\u3001\u6a21\u578b\u5fae\u8c03\u7b49\u591a\u4e2a\u9886\u57df&#xff0c;\u652f\u6301\u4e00\u952e\u90e8\u7f72\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b&#xff1a;120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7<br \/>\n1. \u5f00\u7bc7&#xff1a;\u4e3a\u4ec0\u4e48\u9009\u62e9Gemma-3-12B-IT&#xff1f;<br \/>\n\u5982\u679c\u4f60\u6b63\u5728\u5bfb\u627e\u4e00\u4e2a\u65e2\u5f3a\u5927\u53c8\u80fd\u5728\u666e\u901a\u670d\u52a1\u5668\u4e0a\u6d41\u7545\u8fd0\u884c\u7684\u5927\u8bed\u8a00\u6a21\u578b&#xff0c;\u90a3\u4e48Gemma-3-12B-IT\u5f88\u53ef\u80fd\u5c31\u662f\u4f60\u7684\u7406\u60f3\u9009\u62e9\u3002<br \/>\n\u8ba9\u6211\u5148\u8bf4\u8bf4\u6211\u7684\u4eb2\u8eab\u7ecf\u5386\u3002\u524d\u6bb5\u65f6\u95f4&#xff0c;\u6211\u9700\u8981\u4e3a\u4e00\u4e2a\u5c0f\u578b\u5f00\u53d1\u56e2\u961f\u90e8\u7f72\u4e00\u4e2aAI\u52a9\u624b&#xff0c;\u9884\u7b97\u6709\u9650&#xff0c;\u670d\u52a1\u5668\u914d\u7f6e\u4e5f\u4e0d\u7b97\u9ad8&amp;#xff<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1871,4817,956,2094],"topic":[],"class_list":["post-83420","post","type-post","status-publish","format-standard","hentry","category-server","tag-ai","tag-4817","tag-956","tag-2094"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b\uff1a120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/83420.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b\uff1a120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b&#xff1a;120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7 1. \u5f00\u7bc7&#xff1a;\u4e3a\u4ec0\u4e48\u9009\u62e9Gemma-3-12B-IT&#xff1f; \u5982\u679c\u4f60\u6b63\u5728\u5bfb\u627e\u4e00\u4e2a\u65e2\u5f3a\u5927\u53c8\u80fd\u5728\u666e\u901a\u670d\u52a1\u5668\u4e0a\u6d41\u7545\u8fd0\u884c\u7684\u5927\u8bed\u8a00\u6a21\u578b&#xff0c;\u90a3\u4e48Gemma-3-12B-IT\u5f88\u53ef\u80fd\u5c31\u662f\u4f60\u7684\u7406\u60f3\u9009\u62e9\u3002 \u8ba9\u6211\u5148\u8bf4\u8bf4\u6211\u7684\u4eb2\u8eab\u7ecf\u5386\u3002\u524d\u6bb5\u65f6\u95f4&#xff0c;\u6211\u9700\u8981\u4e3a\u4e00\u4e2a\u5c0f\u578b\u5f00\u53d1\u56e2\u961f\u90e8\u7f72\u4e00\u4e2aAI\u52a9\u624b&#xff0c;\u9884\u7b97\u6709\u9650&#xff0c;\u670d\u52a1\u5668\u914d\u7f6e\u4e5f\u4e0d\u7b97\u9ad8&amp;#xff\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/83420.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-25T13:49:30+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/83420.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/83420.html\",\"name\":\"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b\uff1a120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-25T13:49:30+00:00\",\"dateModified\":\"2026-07-25T13:49:30+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/83420.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/83420.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/83420.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b\uff1a120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b\uff1a120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/83420.html","og_locale":"zh_CN","og_type":"article","og_title":"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b\uff1a120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b&#xff1a;120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7 1. \u5f00\u7bc7&#xff1a;\u4e3a\u4ec0\u4e48\u9009\u62e9Gemma-3-12B-IT&#xff1f; \u5982\u679c\u4f60\u6b63\u5728\u5bfb\u627e\u4e00\u4e2a\u65e2\u5f3a\u5927\u53c8\u80fd\u5728\u666e\u901a\u670d\u52a1\u5668\u4e0a\u6d41\u7545\u8fd0\u884c\u7684\u5927\u8bed\u8a00\u6a21\u578b&#xff0c;\u90a3\u4e48Gemma-3-12B-IT\u5f88\u53ef\u80fd\u5c31\u662f\u4f60\u7684\u7406\u60f3\u9009\u62e9\u3002 \u8ba9\u6211\u5148\u8bf4\u8bf4\u6211\u7684\u4eb2\u8eab\u7ecf\u5386\u3002\u524d\u6bb5\u65f6\u95f4&#xff0c;\u6211\u9700\u8981\u4e3a\u4e00\u4e2a\u5c0f\u578b\u5f00\u53d1\u56e2\u961f\u90e8\u7f72\u4e00\u4e2aAI\u52a9\u624b&#xff0c;\u9884\u7b97\u6709\u9650&#xff0c;\u670d\u52a1\u5668\u914d\u7f6e\u4e5f\u4e0d\u7b97\u9ad8&amp;#xff","og_url":"https:\/\/www.wsisp.com\/helps\/83420.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-25T13:49:30+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"13 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/83420.html","url":"https:\/\/www.wsisp.com\/helps\/83420.html","name":"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b\uff1a120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-25T13:49:30+00:00","dateModified":"2026-07-25T13:49:30+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/83420.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/83420.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/83420.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Gemma-3-12B-IT\u5165\u95e8\u6559\u7a0b\uff1a120\u4ebf\u53c2\u6570\u6a21\u578b\u5728\u4f4e\u8d44\u6e90\u670d\u52a1\u5668\u4e0a\u7684\u90e8\u7f72\u4f18\u5316\u6280\u5de7"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/83420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=83420"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/83420\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=83420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=83420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=83420"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=83420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}