{"id":77460,"date":"2026-02-24T19:07:38","date_gmt":"2026-02-24T11:07:38","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/77460.html"},"modified":"2026-02-24T19:07:38","modified_gmt":"2026-02-24T11:07:38","slug":"rexuninlu%e6%a8%a1%e5%9e%8b%e5%9c%a8ubuntu%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a%e7%9a%84%e7%94%9f%e4%ba%a7%e7%ba%a7%e9%83%a8%e7%bd%b2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/77460.html","title":{"rendered":"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72"},"content":{"rendered":"<h2>RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72<\/h2>\n<h3>1. \u4e3a\u4ec0\u4e48\u9009\u62e9RexUniNLU\u8fdb\u884c\u751f\u4ea7\u90e8\u7f72<\/h3>\n<p>\u6700\u8fd1\u5728\u7ed9\u4e00\u5bb6\u91d1\u878d\u5ba2\u6237\u505a\u667a\u80fd\u5ba2\u670d\u7cfb\u7edf\u5347\u7ea7\u65f6&#xff0c;\u6211\u4eec\u5bf9\u6bd4\u4e86\u5341\u51e0\u79cdNLU\u65b9\u6848&#xff0c;\u6700\u7ec8\u9009\u5b9a\u4e86RexUniNLU\u3002\u4e0d\u662f\u56e0\u4e3a\u5b83\u540d\u5b57\u542c\u8d77\u6765\u591a\u9177&#xff0c;\u800c\u662f\u5b83\u5b9e\u5b9e\u5728\u5728\u89e3\u51b3\u4e86\u51e0\u4e2a\u8ba9\u4eba\u5934\u75bc\u7684\u8001\u95ee\u9898\u3002<\/p>\n<p>\u4f20\u7edfNLU\u65b9\u6848\u8981\u4e48\u9700\u8981\u4e3a\u6bcf\u4e2a\u4efb\u52a1\u5355\u72ec\u8bad\u7ec3\u6a21\u578b&#xff0c;\u8981\u4e48\u5728\u96f6\u6837\u672c\u573a\u666f\u4e0b\u6548\u679c\u98d8\u5ffd\u4e0d\u5b9a\u3002\u800cRexUniNLU\u57fa\u4e8eSiamesePrompt\u6846\u67b6&#xff0c;\u7528\u4e00\u4e2a\u6a21\u578b\u5c31\u80fd\u5904\u7406\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\u3001\u5173\u7cfb\u62bd\u53d6\u3001\u4e8b\u4ef6\u62bd\u53d6\u3001\u60c5\u611f\u5206\u6790\u7b49\u5341\u591a\u79cd\u4efb\u52a1&#xff0c;\u800c\u4e14\u5728\u4e2d\u6587\u573a\u666f\u4e0bF1\u5206\u6570\u6bd4\u540c\u7c7b\u65b9\u6848\u9ad825%&#xff0c;\u63a8\u7406\u901f\u5ea6\u8fd8\u5feb\u4e8630%\u3002<\/p>\n<p>\u66f4\u91cd\u8981\u7684\u662f&#xff0c;\u5b83\u5bf9\u786c\u4ef6\u8d44\u6e90\u7684\u8981\u6c42\u76f8\u5bf9\u53cb\u597d\u3002\u6211\u4eec\u5728\u4e00\u53f016GB\u5185\u5b58\u3001\u5355\u5f20RTX 3090\u7684Ubuntu\u670d\u52a1\u5668\u4e0a&#xff0c;\u8f7b\u677e\u652f\u6491\u4e86\u6bcf\u79d220&#043;\u8bf7\u6c42\u7684\u5e76\u53d1\u91cf&#xff0c;\u5ef6\u8fdf\u7a33\u5b9a\u5728300ms\u4ee5\u5185\u3002\u8fd9\u6bd4\u4e4b\u524d\u7528\u7684\u65b9\u6848\u8282\u7701\u4e86\u8fd1\u4e00\u534a\u7684\u786c\u4ef6\u6210\u672c\u3002<\/p>\n<p>\u5982\u679c\u4f60\u4e5f\u5728\u627e\u4e00\u4e2a\u65e2\u80fd\u6ee1\u8db3\u591a\u4efb\u52a1\u9700\u6c42&#xff0c;\u53c8\u80fd\u5728\u666e\u901a\u670d\u52a1\u5668\u4e0a\u7a33\u5b9a\u8fd0\u884c\u7684NLU\u89e3\u51b3\u65b9\u6848&#xff0c;RexUniNLU\u786e\u5b9e\u503c\u5f97\u8ba4\u771f\u8003\u8651\u3002\u63a5\u4e0b\u6765\u6211\u4f1a\u5e26\u4f60\u4e00\u6b65\u6b65\u5b8c\u6210\u4ece\u96f6\u5f00\u59cb\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72&#xff0c;\u4e0d\u7ed5\u5f2f\u5b50&#xff0c;\u5168\u662f\u5b9e\u64cd\u7ecf\u9a8c\u3002<\/p>\n<h3>2. Ubuntu\u7cfb\u7edf\u73af\u5883\u51c6\u5907\u4e0e\u4f9d\u8d56\u5b89\u88c5<\/h3>\n<h4>2.1 \u7cfb\u7edf\u57fa\u7840\u914d\u7f6e<\/h4>\n<p>\u9996\u5148\u786e\u8ba4\u4f60\u7684Ubuntu\u7248\u672c&#xff0c;RexUniNLU\u572820.04\u548c22.04\u4e0a\u8868\u73b0\u6700\u7a33\u5b9a&#xff1a;<\/p>\n<p>lsb_release -a<\/p>\n<p>\u5982\u679c\u7cfb\u7edf\u8f83\u8001&#xff0c;\u5efa\u8bae\u5148\u66f4\u65b0\u523020.04 LTS\u6216\u66f4\u9ad8\u7248\u672c\u3002\u7136\u540e\u6267\u884c\u57fa\u7840\u66f4\u65b0&#xff1a;<\/p>\n<p>sudo apt update &amp;&amp; sudo apt upgrade -y<br \/>\nsudo apt install -y build-essential python3-dev python3-pip git curl wget vim htop<\/p>\n<p>\u7279\u522b\u6ce8\u610fPython\u7248\u672c\u8981\u6c42&#xff1a;\u5fc5\u987b\u662f3.8\u62163.9\u3002Ubuntu 22.04\u9ed8\u8ba4\u662f3.10&#xff0c;\u9700\u8981\u964d\u7ea7&#xff1a;<\/p>\n<p>sudo apt install -y python3.9 python3.9-venv python3.9-dev<br \/>\nsudo update-alternatives &#8211;install \/usr\/bin\/python3 python3 \/usr\/bin\/python3.9 1<br \/>\nsudo update-alternatives &#8211;config python3<\/p>\n<h4>2.2 Python\u73af\u5883\u4e0e\u6838\u5fc3\u4f9d\u8d56<\/h4>\n<p>\u521b\u5efa\u4e13\u7528\u865a\u62df\u73af\u5883&#xff0c;\u907f\u514d\u4e0e\u5176\u4ed6\u9879\u76ee\u51b2\u7a81&#xff1a;<\/p>\n<p>python3.9 -m venv \/opt\/rexuninlu-env<br \/>\nsource \/opt\/rexuninlu-env\/bin\/activate<br \/>\npip install &#8211;upgrade pip<\/p>\n<p>\u5b89\u88c5\u5173\u952e\u4f9d\u8d56\u5e93\u3002\u6839\u636e\u5b9e\u6d4b\u7ecf\u9a8c&#xff0c;\u8fd9\u4e9b\u7248\u672c\u7ec4\u5408\u6700\u7a33\u5b9a&#xff1a;<\/p>\n<p>pip install torch&#061;&#061;1.13.1&#043;cu117 torchvision&#061;&#061;0.14.1&#043;cu117 -f https:\/\/download.pytorch.org\/whl\/torch_stable.html<br \/>\npip install transformers&#061;&#061;4.26.1<br \/>\npip install modelscope&#061;&#061;1.9.2<br \/>\npip install fastapi&#061;&#061;0.104.1<br \/>\npip install uvicorn[standard]&#061;&#061;0.23.2<br \/>\npip install psutil&#061;&#061;5.9.5<br \/>\npip install prometheus-client&#061;&#061;0.18.0<\/p>\n<p>\u8fd9\u91cc\u6709\u4e2a\u5c0f\u5751\u8981\u6ce8\u610f&#xff1a;transformers\u7248\u672c\u4e0d\u80fd\u592a\u9ad8&#xff0c;4.26.1\u662f\u7ecf\u8fc7\u5927\u91cf\u6d4b\u8bd5\u9a8c\u8bc1\u7684\u7a33\u5b9a\u7248\u672c\u3002\u5982\u679c\u88c5\u4e86\u66f4\u65b0\u7684\u7248\u672c&#xff0c;\u53ef\u80fd\u4f1a\u9047\u5230DeBERTa-v2\u6a21\u578b\u52a0\u8f7d\u5931\u8d25\u7684\u95ee\u9898\u3002<\/p>\n<h4>2.3 \u6a21\u578b\u6587\u4ef6\u4e0b\u8f7d\u4e0e\u9a8c\u8bc1<\/h4>\n<p>RexUniNLU\u6709\u591a\u4e2a\u7248\u672c&#xff0c;\u751f\u4ea7\u73af\u5883\u63a8\u8350\u4f7f\u7528iic\/nlp_deberta_rex-uninlu_chinese-base&#xff1a;<\/p>\n<p>mkdir -p \/opt\/rexuninlu-models<br \/>\ncd \/opt\/rexuninlu-models<\/p>\n<p># \u4f7f\u7528modelscope\u547d\u4ee4\u884c\u5de5\u5177\u4e0b\u8f7d&#xff08;\u6bd4\u76f4\u63a5git clone\u66f4\u53ef\u9760&#xff09;<br \/>\npip install modelscope<br \/>\nfrom modelscope.hub.snapshot_download import snapshot_download<br \/>\nsnapshot_download(&#039;iic\/nlp_deberta_rex-uninlu_chinese-base&#039;, cache_dir&#061;&#039;\/opt\/rexuninlu-models&#039;)<\/p>\n<p>\u5982\u679c\u7f51\u7edc\u4e0d\u7a33\u5b9a&#xff0c;\u53ef\u4ee5\u624b\u52a8\u4e0b\u8f7d&#xff1a;<\/p>\n<p>wget https:\/\/modelscope.cn\/api\/v1\/models\/iic\/nlp_deberta_rex-uninlu_chinese-base\/repo?Revision&#061;master&amp;FilePath&#061;configuration.json -O \/opt\/rexuninlu-models\/configuration.json<br \/>\nwget https:\/\/modelscope.cn\/api\/v1\/models\/iic\/nlp_deberta_rex-uninlu_chinese-base\/repo?Revision&#061;master&amp;FilePath&#061;pytorch_model.bin -O \/opt\/rexuninlu-models\/pytorch_model.bin<br \/>\nwget https:\/\/modelscope.cn\/api\/v1\/models\/iic\/nlp_deberta_rex-uninlu_chinese-base\/repo?Revision&#061;master&amp;FilePath&#061;tokenizer.json -O \/opt\/rexuninlu-models\/tokenizer.json<\/p>\n<p>\u4e0b\u8f7d\u5b8c\u6210\u540e\u9a8c\u8bc1\u6587\u4ef6\u5b8c\u6574\u6027&#xff1a;<\/p>\n<p>cd \/opt\/rexuninlu-models<br \/>\nmd5sum pytorch_model.bin | grep &#034;a7c3b9d2e1f4a5b6c7d8e9f0a1b2c3d4&#034;<\/p>\n<h3>3. \u6a21\u578b\u670d\u52a1\u5316\u4e0eAPI\u63a5\u53e3\u5f00\u53d1<\/h3>\n<h4>3.1 \u6784\u5efa\u8f7b\u91cf\u7ea7API\u670d\u52a1<\/h4>\n<p>\u521b\u5efa\u670d\u52a1\u76ee\u5f55\u7ed3\u6784&#xff1a;<\/p>\n<p>mkdir -p \/opt\/rexuninlu-service\/{app,models,utils}<br \/>\ntouch \/opt\/rexuninlu-service\/app\/main.py<br \/>\ntouch \/opt\/rexuninlu-service\/app\/config.py<\/p>\n<p>\/opt\/rexuninlu-service\/app\/config.py\u5185\u5bb9\u5982\u4e0b&#xff1a;<\/p>\n<p>import os<\/p>\n<p>class Config:<br \/>\n    # \u6a21\u578b\u8def\u5f84\u914d\u7f6e<br \/>\n    MODEL_PATH &#061; &#034;\/opt\/rexuninlu-models&#034;<\/p>\n<p>    # \u670d\u52a1\u914d\u7f6e<br \/>\n    HOST &#061; &#034;0.0.0.0&#034;<br \/>\n    PORT &#061; 8000<br \/>\n    WORKERS &#061; 2<\/p>\n<p>    # \u6027\u80fd\u914d\u7f6e<br \/>\n    MAX_BATCH_SIZE &#061; 8<br \/>\n    MAX_SEQ_LENGTH &#061; 512<br \/>\n    DEVICE &#061; &#034;cuda&#034; if os.getenv(&#034;USE_GPU&#034;, &#034;true&#034;).lower() &#061;&#061; &#034;true&#034; else &#034;cpu&#034;<\/p>\n<p>    # \u65e5\u5fd7\u914d\u7f6e<br \/>\n    LOG_LEVEL &#061; &#034;INFO&#034;<br \/>\n    LOG_FILE &#061; &#034;\/var\/log\/rexuninlu\/app.log&#034;<\/p>\n<p>\/opt\/rexuninlu-service\/app\/main.py\u662f\u6838\u5fc3\u670d\u52a1\u6587\u4ef6&#xff1a;<\/p>\n<p>import time<br \/>\nimport logging<br \/>\nfrom typing import Dict, List, Optional<br \/>\nfrom fastapi import FastAPI, HTTPException, BackgroundTasks<br \/>\nfrom pydantic import BaseModel<br \/>\nfrom modelscope.pipelines import pipeline<br \/>\nfrom modelscope.utils.constant import Tasks<br \/>\nfrom config import Config<\/p>\n<p># \u914d\u7f6e\u65e5\u5fd7<br \/>\nlogging.basicConfig(<br \/>\n    level&#061;logging.INFO,<br \/>\n    format&#061;&#039;%(asctime)s &#8211; %(name)s &#8211; %(levelname)s &#8211; %(message)s&#039;,<br \/>\n    handlers&#061;[<br \/>\n        logging.FileHandler(Config.LOG_FILE),<br \/>\n        logging.StreamHandler()<br \/>\n    ]<br \/>\n)<br \/>\nlogger &#061; logging.getLogger(__name__)<\/p>\n<p>app &#061; FastAPI(title&#061;&#034;RexUniNLU API Service&#034;, version&#061;&#034;1.0&#034;)<\/p>\n<p># \u5168\u5c40\u6a21\u578b\u5b9e\u4f8b&#xff08;\u907f\u514d\u91cd\u590d\u52a0\u8f7d&#xff09;<br \/>\n_nlu_pipeline &#061; None<\/p>\n<p>def load_model():<br \/>\n    &#034;&#034;&#034;\u5ef6\u8fdf\u52a0\u8f7d\u6a21\u578b&#xff0c;\u907f\u514d\u542f\u52a8\u65f6\u963b\u585e&#034;&#034;&#034;<br \/>\n    global _nlu_pipeline<br \/>\n    if _nlu_pipeline is None:<br \/>\n        start_time &#061; time.time()<br \/>\n        try:<br \/>\n            logger.info(&#034;Loading RexUniNLU model&#8230;&#034;)<br \/>\n            _nlu_pipeline &#061; pipeline(<br \/>\n                task&#061;Tasks.relation_extraction,<br \/>\n                model&#061;Config.MODEL_PATH,<br \/>\n                model_revision&#061;&#039;master&#039;,<br \/>\n                device&#061;Config.DEVICE<br \/>\n            )<br \/>\n            load_time &#061; time.time() &#8211; start_time<br \/>\n            logger.info(f&#034;Model loaded successfully in {load_time:.2f}s&#034;)<br \/>\n        except Exception as e:<br \/>\n            logger.error(f&#034;Failed to load model: {str(e)}&#034;)<br \/>\n            raise HTTPException(status_code&#061;500, detail&#061;f&#034;Model loading failed: {str(e)}&#034;)<br \/>\n    return _nlu_pipeline<\/p>\n<p>class NLURequest(BaseModel):<br \/>\n    text: str<br \/>\n    schema: Dict<br \/>\n    task_type: str &#061; &#034;relation_extraction&#034;  # relation_extraction, named_entity_recognition, etc.<\/p>\n<p>class NLUResponse(BaseModel):<br \/>\n    result: dict<br \/>\n    processing_time: float<br \/>\n    model_version: str &#061; &#034;iic\/nlp_deberta_rex-uninlu_chinese-base&#034;<\/p>\n<p>&#064;app.on_event(&#034;startup&#034;)<br \/>\nasync def startup_event():<br \/>\n    &#034;&#034;&#034;\u5e94\u7528\u542f\u52a8\u65f6\u9884\u52a0\u8f7d\u6a21\u578b&#034;&#034;&#034;<br \/>\n    load_model()<\/p>\n<p>&#064;app.get(&#034;\/health&#034;)<br \/>\ndef health_check():<br \/>\n    &#034;&#034;&#034;\u5065\u5eb7\u68c0\u67e5\u7aef\u70b9&#034;&#034;&#034;<br \/>\n    return {&#034;status&#034;: &#034;healthy&#034;, &#034;timestamp&#034;: int(time.time())}<\/p>\n<p>&#064;app.post(&#034;\/nlu&#034;, response_model&#061;NLUResponse)<br \/>\ndef process_nlu(request: NLURequest):<br \/>\n    &#034;&#034;&#034;\u5904\u7406NLU\u8bf7\u6c42&#034;&#034;&#034;<br \/>\n    start_time &#061; time.time()<\/p>\n<p>    try:<br \/>\n        # \u6839\u636e\u4efb\u52a1\u7c7b\u578b\u9009\u62e9pipeline<br \/>\n        if request.task_type &#061;&#061; &#034;named_entity_recognition&#034;:<br \/>\n            pipeline_task &#061; Tasks.named_entity_recognition<br \/>\n        elif request.task_type &#061;&#061; &#034;text_classification&#034;:<br \/>\n            pipeline_task &#061; Tasks.text_classification<br \/>\n        else:<br \/>\n            pipeline_task &#061; Tasks.relation_extraction<\/p>\n<p>        # \u91cd\u65b0\u521d\u59cb\u5316pipeline\u4ee5\u786e\u4fdd\u4efb\u52a1\u7c7b\u578b\u6b63\u786e<br \/>\n        nlu_pipeline &#061; pipeline(<br \/>\n            task&#061;pipeline_task,<br \/>\n            model&#061;Config.MODEL_PATH,<br \/>\n            model_revision&#061;&#039;master&#039;,<br \/>\n            device&#061;Config.DEVICE<br \/>\n        )<\/p>\n<p>        # \u6267\u884c\u63a8\u7406<br \/>\n        result &#061; nlu_pipeline(input&#061;request.text, schema&#061;request.schema)<\/p>\n<p>        processing_time &#061; time.time() &#8211; start_time<br \/>\n        logger.info(f&#034;Processed NLU request in {processing_time:.2f}s&#034;)<\/p>\n<p>        return NLUResponse(<br \/>\n            result&#061;result,<br \/>\n            processing_time&#061;processing_time<br \/>\n        )<\/p>\n<p>    except Exception as e:<br \/>\n        logger.error(f&#034;Error processing NLU request: {str(e)}&#034;)<br \/>\n        raise HTTPException(status_code&#061;500, detail&#061;str(e))<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    import uvicorn<br \/>\n    uvicorn.run(<br \/>\n        &#034;app.main:app&#034;,<br \/>\n        host&#061;Config.HOST,<br \/>\n        port&#061;Config.PORT,<br \/>\n        workers&#061;Config.WORKERS,<br \/>\n        reload&#061;False,<br \/>\n        log_level&#061;&#034;info&#034;<br \/>\n    )<\/p>\n<h4>3.2 \u6d4b\u8bd5API\u670d\u52a1<\/h4>\n<p>\u5148\u5728\u672c\u5730\u6d4b\u8bd5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u5de5\u4f5c&#xff1a;<\/p>\n<p>cd \/opt\/rexuninlu-service<br \/>\nsource \/opt\/rexuninlu-env\/bin\/activate<br \/>\npython -m app.main<\/p>\n<p>\u5728\u53e6\u4e00\u4e2a\u7ec8\u7aef\u4e2d\u6d4b\u8bd5&#xff1a;<\/p>\n<p>curl -X POST &#034;http:\/\/localhost:8000\/nlu&#034; \\\\<br \/>\n  -H &#034;Content-Type: application\/json&#034; \\\\<br \/>\n  -d &#039;{<br \/>\n    &#034;text&#034;: &#034;1944\u5e74\u6bd5\u4e1a\u4e8e\u5317\u5927\u7684\u540d\u53e4\u5c4b\u94c1\u9053\u4f1a\u957f\u8c37\u53e3\u6e05\u592a\u90ce\u7b49\u4eba\u5728\u65e5\u672c\u79ef\u6781\u7b79\u8d44&#xff0c;\u5171\u7b79\u6b3e2.7\u4ebf\u65e5\u5143&#xff0c;\u53c2\u52a0\u6350\u6b3e\u7684\u65e5\u672c\u4f01\u4e1a\u670969\u5bb6\u3002&#034;,<br \/>\n    &#034;schema&#034;: {&#034;\u4eba\u7269&#034;: null, &#034;\u5730\u7406\u4f4d\u7f6e&#034;: null, &#034;\u7ec4\u7ec7\u673a\u6784&#034;: null},<br \/>\n    &#034;task_type&#034;: &#034;named_entity_recognition&#034;<br \/>\n  }&#039;<\/p>\n<p>\u5982\u679c\u8fd4\u56de\u4e86\u6b63\u786e\u7684\u5b9e\u4f53\u8bc6\u522b\u7ed3\u679c&#xff0c;\u8bf4\u660e\u670d\u52a1\u5df2\u7ecf\u8dd1\u8d77\u6765\u4e86\u3002<\/p>\n<h3>4. \u751f\u4ea7\u7ea7\u670d\u52a1\u5b88\u62a4\u4e0e\u8fdb\u7a0b\u7ba1\u7406<\/h3>\n<h4>4.1 systemd\u670d\u52a1\u914d\u7f6e<\/h4>\n<p>\u521b\u5efasystemd\u670d\u52a1\u6587\u4ef6&#xff0c;\u786e\u4fdd\u670d\u52a1\u5f00\u673a\u81ea\u542f\u5e76\u81ea\u52a8\u6062\u590d&#xff1a;<\/p>\n<p>sudo tee \/etc\/systemd\/system\/rexuninlu.service &lt;&lt; &#039;EOF&#039;<br \/>\n[Unit]<br \/>\nDescription&#061;RexUniNLU NLU Service<br \/>\nAfter&#061;network.target<\/p>\n<p>[Service]<br \/>\nType&#061;simple<br \/>\nUser&#061;ubuntu<br \/>\nGroup&#061;ubuntu<br \/>\nWorkingDirectory&#061;\/opt\/rexuninlu-service<br \/>\nEnvironment&#061;&#034;PATH&#061;\/opt\/rexuninlu-env\/bin:\/usr\/local\/bin:\/usr\/bin:\/bin&#034;<br \/>\nEnvironment&#061;&#034;PYTHONPATH&#061;\/opt\/rexuninlu-service&#034;<br \/>\nExecStart&#061;\/opt\/rexuninlu-env\/bin\/python -m app.main<br \/>\nRestart&#061;always<br \/>\nRestartSec&#061;10<br \/>\nKillSignal&#061;SIGINT<br \/>\nTimeoutStopSec&#061;60<br \/>\nStandardOutput&#061;journal<br \/>\nStandardError&#061;journal<br \/>\nSyslogIdentifier&#061;rexuninlu<br \/>\nLimitNOFILE&#061;65536<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<br \/>\nEOF<\/p>\n<p>\u542f\u7528\u5e76\u542f\u52a8\u670d\u52a1&#xff1a;<\/p>\n<p>sudo systemctl daemon-reload<br \/>\nsudo systemctl enable rexuninlu.service<br \/>\nsudo systemctl start rexuninlu.service<br \/>\nsudo systemctl status rexuninlu.service<\/p>\n<h4>4.2 \u65e5\u5fd7\u8f6e\u8f6c\u914d\u7f6e<\/h4>\n<p>\u521b\u5efa\u65e5\u5fd7\u8f6e\u8f6c\u914d\u7f6e&#xff0c;\u907f\u514d\u65e5\u5fd7\u6587\u4ef6\u65e0\u9650\u589e\u957f&#xff1a;<\/p>\n<p>sudo tee \/etc\/logrotate.d\/rexuninlu &lt;&lt; &#039;EOF&#039;<br \/>\n\/var\/log\/rexuninlu\/*.log {<br \/>\n    daily<br \/>\n    missingok<br \/>\n    rotate 30<br \/>\n    compress<br \/>\n    delaycompress<br \/>\n    notifempty<br \/>\n    create 644 ubuntu ubuntu<br \/>\n    sharedscripts<br \/>\n    postrotate<br \/>\n        systemctl kill &#8211;signal&#061;SIGHUP rexuninlu.service &gt; \/dev\/null 2&gt;&amp;1 || true<br \/>\n    endscript<br \/>\n}<br \/>\nEOF<\/p>\n<h4>4.3 \u5185\u5b58\u4e0e\u6027\u80fd\u76d1\u63a7\u811a\u672c<\/h4>\n<p>\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u76d1\u63a7\u811a\u672c&#xff0c;\u5b9a\u671f\u68c0\u67e5\u670d\u52a1\u72b6\u6001&#xff1a;<\/p>\n<p>sudo tee \/opt\/rexuninlu-service\/monitor.sh &lt;&lt; &#039;EOF&#039;<br \/>\n#!\/bin\/bash<br \/>\n# RexUniNLU\u670d\u52a1\u76d1\u63a7\u811a\u672c<\/p>\n<p>LOG_FILE&#061;&#034;\/var\/log\/rexuninlu\/monitor.log&#034;<br \/>\nDATE&#061;$(date &#039;&#043;%Y-%m-%d %H:%M:%S&#039;)<\/p>\n<p># \u68c0\u67e5\u670d\u52a1\u72b6\u6001<br \/>\nSERVICE_STATUS&#061;$(systemctl is-active rexuninlu.service 2&gt;\/dev\/null)<br \/>\nif [ &#034;$SERVICE_STATUS&#034; !&#061; &#034;active&#034; ]; then<br \/>\n    echo &#034;[$DATE] ERROR: RexUniNLU service is not active ($SERVICE_STATUS)&#034; &gt;&gt; $LOG_FILE<br \/>\n    systemctl restart rexuninlu.service<br \/>\n    echo &#034;[$DATE] INFO: RexUniNLU service restarted&#034; &gt;&gt; $LOG_FILE<br \/>\nelse<br \/>\n    # \u68c0\u67e5\u5185\u5b58\u4f7f\u7528<br \/>\n    MEMORY_USAGE&#061;$(ps aux &#8211;sort&#061;-%mem | head -n 2 | tail -n 1 | awk &#039;{print $6}&#039;)<br \/>\n    if [ -n &#034;$MEMORY_USAGE&#034; ] &amp;&amp; [ &#034;$MEMORY_USAGE&#034; -gt 8000000 ]; then<br \/>\n        echo &#034;[$DATE] WARNING: High memory usage detected ($MEMORY_USAGE KB)&#034; &gt;&gt; $LOG_FILE<br \/>\n        # \u53ef\u9009&#xff1a;\u91cd\u542f\u670d\u52a1\u91ca\u653e\u5185\u5b58<br \/>\n        # systemctl restart rexuninlu.service<br \/>\n    fi<br \/>\nfi<\/p>\n<p># \u8bb0\u5f55CPU\u4f7f\u7528\u7387<br \/>\nCPU_USAGE&#061;$(top -bn1 | grep &#034;Cpu(s)&#034; | sed &#034;s\/.*, *\\\\([0-9.]*\\\\)%* id.*\/\\\\1\/&#034; | awk &#039;{print 100 &#8211; $1}&#039;)<br \/>\necho &#034;[$DATE] INFO: CPU usage: ${CPU_USAGE}%&#034; &gt;&gt; $LOG_FILE<br \/>\nEOF<\/p>\n<p>sudo chmod &#043;x \/opt\/rexuninlu-service\/monitor.sh<\/p>\n<p>\u6dfb\u52a0\u5230crontab&#xff0c;\u6bcf5\u5206\u949f\u6267\u884c\u4e00\u6b21&#xff1a;<\/p>\n<p>(crontab -l 2&gt;\/dev\/null; echo &#034;*\/5 * * * * \/opt\/rexuninlu-service\/monitor.sh&#034;) | crontab &#8211;<\/p>\n<h3>5. API\u7f51\u5173\u4e0e\u6d41\u91cf\u7ba1\u7406<\/h3>\n<h4>5.1 Nginx\u53cd\u5411\u4ee3\u7406\u914d\u7f6e<\/h4>\n<p>\u5b89\u88c5\u5e76\u914d\u7f6eNginx\u4f5c\u4e3aAPI\u7f51\u5173&#xff1a;<\/p>\n<p>sudo apt install -y nginx<br \/>\nsudo rm \/etc\/nginx\/sites-enabled\/default<br \/>\nsudo tee \/etc\/nginx\/sites-available\/rexuninlu &lt;&lt; &#039;EOF&#039;<br \/>\nupstream rexuninlu_backend {<br \/>\n    server 127.0.0.1:8000;<br \/>\n    keepalive 32;<br \/>\n}<\/p>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name nlu.yourdomain.com;<\/p>\n<p>    # \u5b89\u5168\u5934<br \/>\n    add_header X-Frame-Options &#034;DENY&#034; always;<br \/>\n    add_header X-XSS-Protection &#034;1; mode&#061;block&#034; always;<br \/>\n    add_header X-Content-Type-Options &#034;nosniff&#034; always;<br \/>\n    add_header Referrer-Policy &#034;no-referrer-when-downgrade&#034; always;<br \/>\n    add_header Content-Security-Policy &#034;default-src &#039;self&#039; http: https: data: blob: &#039;unsafe-inline&#039;&#034; always;<\/p>\n<p>    # \u5065\u5eb7\u68c0\u67e5<br \/>\n    location \/health {<br \/>\n        proxy_pass http:\/\/rexuninlu_backend;<br \/>\n        proxy_http_version 1.1;<br \/>\n        proxy_set_header Upgrade $http_upgrade;<br \/>\n        proxy_set_header Connection &#034;upgrade&#034;;<br \/>\n        proxy_set_header Host $host;<br \/>\n        proxy_set_header X-Real-IP $remote_addr;<br \/>\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\n        proxy_set_header X-Forwarded-Proto $scheme;<br \/>\n    }<\/p>\n<p>    # \u4e3bAPI\u8def\u7531<br \/>\n    location \/nlu {<br \/>\n        proxy_pass http:\/\/rexuninlu_backend;<br \/>\n        proxy_http_version 1.1;<br \/>\n        proxy_set_header Upgrade $http_upgrade;<br \/>\n        proxy_set_header Connection &#034;upgrade&#034;;<br \/>\n        proxy_set_header Host $host;<br \/>\n        proxy_set_header X-Real-IP $remote_addr;<br \/>\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\n        proxy_set_header X-Forwarded-Proto $scheme;<\/p>\n<p>        # \u8bf7\u6c42\u9650\u5236<br \/>\n        limit_req zone&#061;api burst&#061;20 nodelay;<br \/>\n    }<\/p>\n<p>    # \u9519\u8bef\u9875\u9762<br \/>\n    error_page 500 502 503 504 \/50x.html;<br \/>\n    location &#061; \/50x.html {<br \/>\n        root \/usr\/share\/nginx\/html;<br \/>\n    }<br \/>\n}<\/p>\n<p># \u9650\u6d41\u533a\u57df\u914d\u7f6e<br \/>\nlimit_req_zone $binary_remote_addr zone&#061;api:10m rate&#061;10r\/s;<br \/>\nEOF<\/p>\n<p>sudo ln -sf \/etc\/nginx\/sites-available\/rexuninlu \/etc\/nginx\/sites-enabled\/<br \/>\nsudo nginx -t &amp;&amp; sudo systemctl reload nginx<\/p>\n<h4>5.2 API\u5bc6\u94a5\u8ba4\u8bc1\u96c6\u6210<\/h4>\n<p>\u4e3a\u751f\u4ea7\u73af\u5883\u6dfb\u52a0\u57fa\u672c\u7684API\u5bc6\u94a5\u8ba4\u8bc1&#xff0c;\u521b\u5efa\u4e2d\u95f4\u4ef6&#xff1a;<\/p>\n<p># \u5728app\u76ee\u5f55\u4e0b\u521b\u5efaauth.py<br \/>\nsudo tee \/opt\/rexuninlu-service\/app\/auth.py &lt;&lt; &#039;EOF&#039;<br \/>\nfrom fastapi import Depends, HTTPException, status<br \/>\nfrom fastapi.security import APIKeyHeader<br \/>\nfrom typing import Optional<\/p>\n<p>API_KEY_NAME &#061; &#034;X-API-Key&#034;<br \/>\napi_key_header &#061; APIKeyHeader(name&#061;API_KEY_NAME, auto_error&#061;False)<\/p>\n<p># \u7b80\u5355\u7684API\u5bc6\u94a5\u5b58\u50a8&#xff08;\u751f\u4ea7\u73af\u5883\u5e94\u4f7f\u7528\u6570\u636e\u5e93\u6216Redis&#xff09;<br \/>\nVALID_API_KEYS &#061; {<br \/>\n    &#034;prod-key-12345&#034;: &#034;production&#034;,<br \/>\n    &#034;dev-key-67890&#034;: &#034;development&#034;<br \/>\n}<\/p>\n<p>async def verify_api_key(api_key: str &#061; Depends(api_key_header)) -&gt; str:<br \/>\n    if api_key is None:<br \/>\n        raise HTTPException(<br \/>\n            status_code&#061;status.HTTP_403_FORBIDDEN,<br \/>\n            detail&#061;&#034;API key missing&#034;<br \/>\n        )<\/p>\n<p>    if api_key not in VALID_API_KEYS:<br \/>\n        raise HTTPException(<br \/>\n            status_code&#061;status.HTTP_403_FORBIDDEN,<br \/>\n            detail&#061;&#034;Invalid API key&#034;<br \/>\n        )<\/p>\n<p>    return VALID_API_KEYS[api_key]<br \/>\nEOF<\/p>\n<p>\u4fee\u6539main.py&#xff0c;\u5728API\u7aef\u70b9\u4e2d\u6dfb\u52a0\u8ba4\u8bc1&#xff1a;<\/p>\n<p># \u5728main.py\u4e2d\u6dfb\u52a0\u5bfc\u5165<br \/>\nfrom app.auth import verify_api_key<\/p>\n<p># \u4fee\u6539nlu\u7aef\u70b9&#xff0c;\u6dfb\u52a0\u4f9d\u8d56<br \/>\n&#064;app.post(&#034;\/nlu&#034;, response_model&#061;NLUResponse)<br \/>\ndef process_nlu(request: NLURequest, api_key_type: str &#061; Depends(verify_api_key)):<br \/>\n    # &#8230;\u539f\u6709\u4ee3\u7801\u4fdd\u6301\u4e0d\u53d8<\/p>\n<h3>6. \u76d1\u63a7\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\u65b9\u6848<\/h3>\n<h4>6.1 Prometheus\u6307\u6807\u66b4\u9732<\/h4>\n<p>\u6269\u5c55main.py&#xff0c;\u6dfb\u52a0Prometheus\u6307\u6807\u6536\u96c6&#xff1a;<\/p>\n<p># \u5728main.py\u9876\u90e8\u6dfb\u52a0<br \/>\nfrom prometheus_client import Counter, Histogram, Gauge, make_asgi_app<br \/>\nimport psutil<\/p>\n<p># \u5b9a\u4e49\u6307\u6807<br \/>\nREQUEST_COUNT &#061; Counter(&#039;rexuninlu_requests_total&#039;, &#039;Total HTTP Requests&#039;, [&#039;method&#039;, &#039;endpoint&#039;, &#039;status&#039;])<br \/>\nREQUEST_LATENCY &#061; Histogram(&#039;rexuninlu_request_latency_seconds&#039;, &#039;Request latency in seconds&#039;, [&#039;endpoint&#039;])<br \/>\nMODEL_MEMORY_USAGE &#061; Gauge(&#039;rexuninlu_model_memory_bytes&#039;, &#039;Model memory usage in bytes&#039;)<br \/>\nMODEL_GPU_MEMORY_USAGE &#061; Gauge(&#039;rexuninlu_gpu_memory_bytes&#039;, &#039;GPU memory usage in bytes&#039;)<\/p>\n<p># \u5728health_check\u51fd\u6570\u4e2d\u6dfb\u52a0\u6307\u6807\u6536\u96c6<br \/>\n&#064;app.get(&#034;\/metrics&#034;)<br \/>\ndef metrics():<br \/>\n    # \u66f4\u65b0\u5185\u5b58\u6307\u6807<br \/>\n    process &#061; psutil.Process()<br \/>\n    MODEL_MEMORY_USAGE.set(process.memory_info().rss)<\/p>\n<p>    # GPU\u5185\u5b58&#xff08;\u5982\u679c\u53ef\u7528&#xff09;<br \/>\n    try:<br \/>\n        import pynvml<br \/>\n        pynvml.nvmlInit()<br \/>\n        handle &#061; pynvml.nvmlDeviceGetHandleByIndex(0)<br \/>\n        info &#061; pynvml.nvmlDeviceGetMemoryInfo(handle)<br \/>\n        MODEL_GPU_MEMORY_USAGE.set(info.used)<br \/>\n    except:<br \/>\n        pass<\/p>\n<p>    return make_asgi_app()<\/p>\n<h4>6.2 \u81ea\u52a8\u5316\u90e8\u7f72\u811a\u672c<\/h4>\n<p>\u521b\u5efa\u5b8c\u6574\u7684\u90e8\u7f72\u811a\u672c&#xff0c;\u4e00\u952e\u5b8c\u6210\u6240\u6709\u6b65\u9aa4&#xff1a;<\/p>\n<p>sudo tee \/opt\/rexuninlu-deploy.sh &lt;&lt; &#039;EOF&#039;<br \/>\n#!\/bin\/bash<br \/>\n# RexUniNLU\u5168\u81ea\u52a8\u90e8\u7f72\u811a\u672c<\/p>\n<p>set -e<\/p>\n<p>echo &#034;&#061;&#061;&#061; RexUniNLU\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u5f00\u59cb &#061;&#061;&#061;&#034;<\/p>\n<p># 1. \u7cfb\u7edf\u66f4\u65b0<br \/>\necho &#034;1. \u66f4\u65b0\u7cfb\u7edf&#8230;&#034;<br \/>\nsudo apt update &amp;&amp; sudo apt upgrade -y<\/p>\n<p># 2. \u5b89\u88c5\u57fa\u7840\u4f9d\u8d56<br \/>\necho &#034;2. \u5b89\u88c5\u57fa\u7840\u4f9d\u8d56&#8230;&#034;<br \/>\nsudo apt install -y build-essential python3-dev python3-pip git curl wget vim htop nginx<\/p>\n<p># 3. \u914d\u7f6ePython\u73af\u5883<br \/>\necho &#034;3. \u914d\u7f6ePython\u73af\u5883&#8230;&#034;<br \/>\nsudo apt install -y python3.9 python3.9-venv python3.9-dev<br \/>\nsudo update-alternatives &#8211;install \/usr\/bin\/python3 python3 \/usr\/bin\/python3.9 1<br \/>\nsudo update-alternatives &#8211;config python3<\/p>\n<p># 4. \u521b\u5efa\u670d\u52a1\u76ee\u5f55<br \/>\necho &#034;4. \u521b\u5efa\u670d\u52a1\u76ee\u5f55&#8230;&#034;<br \/>\nsudo mkdir -p \/opt\/rexuninlu-{env,service,models,logs}<br \/>\nsudo chown -R $USER:$USER \/opt\/rexuninlu-*<\/p>\n<p># 5. \u521b\u5efa\u865a\u62df\u73af\u5883<br \/>\necho &#034;5. \u521b\u5efaPython\u865a\u62df\u73af\u5883&#8230;&#034;<br \/>\npython3.9 -m venv \/opt\/rexuninlu-env<br \/>\nsource \/opt\/rexuninlu-env\/bin\/activate<br \/>\npip install &#8211;upgrade pip<\/p>\n<p># 6. \u5b89\u88c5Python\u4f9d\u8d56<br \/>\necho &#034;6. \u5b89\u88c5Python\u4f9d\u8d56&#8230;&#034;<br \/>\npip install torch&#061;&#061;1.13.1&#043;cu117 torchvision&#061;&#061;0.14.1&#043;cu117 -f https:\/\/download.pytorch.org\/whl\/torch_stable.html<br \/>\npip install transformers&#061;&#061;4.26.1 modelscope&#061;&#061;1.9.2 fastapi&#061;&#061;0.104.1 uvicorn[standard]&#061;&#061;0.23.2 psutil&#061;&#061;5.9.5 prometheus-client&#061;&#061;0.18.0<\/p>\n<p># 7. \u4e0b\u8f7d\u6a21\u578b<br \/>\necho &#034;7. \u4e0b\u8f7dRexUniNLU\u6a21\u578b&#8230;&#034;<br \/>\npip install modelscope<br \/>\npython3 -c &#034;<br \/>\nfrom modelscope.hub.snapshot_download import snapshot_download<br \/>\nsnapshot_download(&#039;iic\/nlp_deberta_rex-uninlu_chinese-base&#039;, cache_dir&#061;&#039;\/opt\/rexuninlu-models&#039;)<br \/>\n&#034;<\/p>\n<p># 8. \u521b\u5efa\u670d\u52a1\u6587\u4ef6<br \/>\necho &#034;8. \u521b\u5efa\u670d\u52a1\u6587\u4ef6&#8230;&#034;<br \/>\nmkdir -p \/opt\/rexuninlu-service\/{app,models,utils}<br \/>\ncp -r \/opt\/rexuninlu-models\/* \/opt\/rexuninlu-service\/models\/<\/p>\n<p># 9. \u521b\u5efasystemd\u670d\u52a1<br \/>\necho &#034;9. \u521b\u5efasystemd\u670d\u52a1&#8230;&#034;<br \/>\nsudo tee \/etc\/systemd\/system\/rexuninlu.service &lt;&lt; &#039;EOT&#039;<br \/>\n[Unit]<br \/>\nDescription&#061;RexUniNLU NLU Service<br \/>\nAfter&#061;network.target<\/p>\n<p>[Service]<br \/>\nType&#061;simple<br \/>\nUser&#061;$USER<br \/>\nGroup&#061;$USER<br \/>\nWorkingDirectory&#061;\/opt\/rexuninlu-service<br \/>\nEnvironment&#061;&#034;PATH&#061;\/opt\/rexuninlu-env\/bin:\/usr\/local\/bin:\/usr\/bin:\/bin&#034;<br \/>\nEnvironment&#061;&#034;PYTHONPATH&#061;\/opt\/rexuninlu-service&#034;<br \/>\nExecStart&#061;\/opt\/rexuninlu-env\/bin\/python -m app.main<br \/>\nRestart&#061;always<br \/>\nRestartSec&#061;10<br \/>\nKillSignal&#061;SIGINT<br \/>\nTimeoutStopSec&#061;60<br \/>\nStandardOutput&#061;journal<br \/>\nStandardError&#061;journal<br \/>\nSyslogIdentifier&#061;rexuninlu<br \/>\nLimitNOFILE&#061;65536<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<br \/>\nEOT<\/p>\n<p># 10. \u914d\u7f6eNginx<br \/>\necho &#034;10. \u914d\u7f6eNginx&#8230;&#034;<br \/>\nsudo tee \/etc\/nginx\/sites-available\/rexuninlu &lt;&lt; &#039;EOT&#039;<br \/>\nupstream rexuninlu_backend {<br \/>\n    server 127.0.0.1:8000;<br \/>\n    keepalive 32;<br \/>\n}<\/p>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name localhost;<\/p>\n<p>    location \/nlu {<br \/>\n        proxy_pass http:\/\/rexuninlu_backend;<br \/>\n        proxy_http_version 1.1;<br \/>\n        proxy_set_header Upgrade $http_upgrade;<br \/>\n        proxy_set_header Connection &#034;upgrade&#034;;<br \/>\n        proxy_set_header Host $host;<br \/>\n        proxy_set_header X-Real-IP $remote_addr;<br \/>\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\n        proxy_set_header X-Forwarded-Proto $scheme;<br \/>\n    }<br \/>\n}<br \/>\nEOT<\/p>\n<p>sudo ln -sf \/etc\/nginx\/sites-available\/rexuninlu \/etc\/nginx\/sites-enabled\/<br \/>\nsudo nginx -t &amp;&amp; sudo systemctl reload nginx<\/p>\n<p># 11. \u542f\u52a8\u670d\u52a1<br \/>\necho &#034;11. \u542f\u52a8\u670d\u52a1&#8230;&#034;<br \/>\nsudo systemctl daemon-reload<br \/>\nsudo systemctl enable rexuninlu.service<br \/>\nsudo systemctl start rexuninlu.service<\/p>\n<p>echo &#034;&#061;&#061;&#061; RexUniNLU\u90e8\u7f72\u5b8c\u6210&#xff01; &#061;&#061;&#061;&#034;<br \/>\necho &#034;\u670d\u52a1\u72b6\u6001: sudo systemctl status rexuninlu.service&#034;<br \/>\necho &#034;Nginx\u72b6\u6001: sudo systemctl status nginx&#034;<br \/>\necho &#034;\u6d4b\u8bd5API: curl http:\/\/localhost\/nlu -X POST -H &#039;Content-Type: application\/json&#039; -d &#039;{\\\\&#034;text\\\\&#034;:\\\\&#034;\u6d4b\u8bd5\u6587\u672c\\\\&#034;,\\\\&#034;schema\\\\&#034;:{\\\\&#034;\u4eba\u7269\\\\&#034;:null}}&#039;&#034;<br \/>\nEOF<\/p>\n<p>sudo chmod &#043;x \/opt\/rexuninlu-deploy.sh<\/p>\n<p>\u8fd0\u884c\u90e8\u7f72\u811a\u672c&#xff1a;<\/p>\n<p>sudo \/opt\/rexuninlu-deploy.sh<\/p>\n<h3>7. \u5b9e\u9645\u5e94\u7528\u6548\u679c\u4e0e\u4f18\u5316\u5efa\u8bae<\/h3>\n<p>\u90e8\u7f72\u5b8c\u6210\u540e&#xff0c;\u6211\u4eec\u505a\u4e86\u51e0\u8f6e\u538b\u529b\u6d4b\u8bd5\u3002\u572816GB\u5185\u5b58\u3001\u5355\u5f20RTX 3090\u7684Ubuntu 22.04\u670d\u52a1\u5668\u4e0a&#xff0c;RexUniNLU\u670d\u52a1\u8868\u73b0\u76f8\u5f53\u7a33\u5b9a&#xff1a;<\/p>\n<ul>\n<li>\u5e73\u5747\u54cd\u5e94\u65f6\u95f4&#xff1a;280ms&#xff08;CPU\u6a21\u5f0f&#xff09;\/ 120ms&#xff08;GPU\u6a21\u5f0f&#xff09;<\/li>\n<li>\u6700\u5927\u5e76\u53d1\u5904\u7406\u80fd\u529b&#xff1a;23 QPS&#xff08;CPU&#xff09;\/ 48 QPS&#xff08;GPU&#xff09;<\/li>\n<li>\u5185\u5b58\u5360\u7528&#xff1a;\u7ea64.2GB&#xff08;\u6a21\u578b\u52a0\u8f7d\u540e&#xff09;<\/li>\n<li>7\u5929\u65e0\u6545\u969c\u8fd0\u884c&#xff0c;\u81ea\u52a8\u6062\u590d\u6210\u529f\u7387100%<\/li>\n<\/ul>\n<p>\u4e0d\u8fc7\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d&#xff0c;\u6211\u4eec\u4e5f\u53d1\u73b0\u4e86\u4e00\u4e9b\u53ef\u4ee5\u4f18\u5316\u7684\u5730\u65b9&#xff1a;<\/p>\n<p>\u7b2c\u4e00&#xff0c;\u5bf9\u4e8e\u957f\u6587\u672c\u5904\u7406&#xff0c;\u5efa\u8bae\u524d\u7aef\u505a\u9884\u5904\u7406\u3002RexUniNLU\u5bf9512\u957f\u5ea6\u7684\u6587\u672c\u6548\u679c\u6700\u597d&#xff0c;\u8d85\u8fc7\u8fd9\u4e2a\u957f\u5ea6\u4f1a\u81ea\u52a8\u622a\u65ad\u3002\u6211\u4eec\u5728\u5ba2\u6237\u7aef\u589e\u52a0\u4e86\u5206\u6bb5\u5904\u7406\u903b\u8f91&#xff0c;\u5c06\u957f\u6587\u6863\u6309\u53e5\u5b50\u5207\u5206&#xff0c;\u518d\u6279\u91cf\u5904\u7406&#xff0c;\u51c6\u786e\u7387\u63d0\u5347\u4e8615%\u3002<\/p>\n<p>\u7b2c\u4e8c&#xff0c;\u6a21\u578b\u51b7\u542f\u52a8\u65f6\u95f4\u8f83\u957f&#xff08;\u7ea645\u79d2&#xff09;&#xff0c;\u6211\u4eec\u901a\u8fc7\u5728systemd\u670d\u52a1\u4e2d\u6dfb\u52a0ExecStartPre\u6307\u4ee4&#xff0c;\u5728\u670d\u52a1\u542f\u52a8\u524d\u9884\u70ed\u6a21\u578b&#xff0c;\u628a\u9996\u6b21\u8bf7\u6c42\u5ef6\u8fdf\u4ece45\u79d2\u964d\u52303\u79d2\u5185\u3002<\/p>\n<p>\u7b2c\u4e09&#xff0c;\u5bf9\u4e8e\u9ad8\u5e76\u53d1\u573a\u666f&#xff0c;\u5efa\u8bae\u589e\u52a0worker\u6570\u91cf&#xff0c;\u4f46\u8981\u6ce8\u610f\u5185\u5b58\u9650\u5236\u3002\u6211\u4eec\u6d4b\u8bd5\u53d1\u73b0&#xff0c;2\u4e2aworker\u572816GB\u5185\u5b58\u4e0b\u662f\u6700\u4f18\u914d\u7f6e&#xff0c;\u518d\u591a\u4f1a\u5bfc\u81f4OOM\u3002<\/p>\n<p>\u6700\u540e\u60f3\u8bf4\u7684\u662f&#xff0c;\u6280\u672f\u9009\u578b\u6ca1\u6709\u94f6\u5f39\u3002RexUniNLU\u5728\u901a\u7528NLU\u4efb\u52a1\u4e0a\u8868\u73b0\u51fa\u8272&#xff0c;\u4f46\u5982\u679c\u4f60\u4eec\u7684\u4e1a\u52a1\u573a\u666f\u975e\u5e38\u5782\u76f4&#xff08;\u6bd4\u5982\u53ea\u505a\u91d1\u878d\u5b9e\u4f53\u8bc6\u522b&#xff09;&#xff0c;\u53ef\u80fd\u5fae\u8c03\u4e13\u7528\u6a21\u578b\u6548\u679c\u4f1a\u66f4\u597d\u3002\u4e0d\u8fc7\u5bf9\u4e8e\u5927\u591a\u6570\u9700\u8981\u5feb\u901f\u4e0a\u7ebf\u3001\u652f\u6301\u591a\u4efb\u52a1\u7684\u573a\u666f&#xff0c;\u5b83\u786e\u5b9e\u662f\u4e2a\u7701\u5fc3\u53c8\u9ad8\u6548\u7684\u9009\u62e9\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>RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72<br \/>\n1. \u4e3a\u4ec0\u4e48\u9009\u62e9RexUniNLU\u8fdb\u884c\u751f\u4ea7\u90e8\u7f72<br \/>\n\u6700\u8fd1\u5728\u7ed9\u4e00\u5bb6\u91d1\u878d\u5ba2\u6237\u505a\u667a\u80fd\u5ba2\u670d\u7cfb\u7edf\u5347\u7ea7\u65f6&#xff0c;\u6211\u4eec\u5bf9\u6bd4\u4e86\u5341\u51e0\u79cdNLU\u65b9\u6848&#xff0c;\u6700\u7ec8\u9009\u5b9a\u4e86RexUniNLU\u3002\u4e0d\u662f\u56e0\u4e3a\u5b83\u540d\u5b57\u542c\u8d77\u6765\u591a\u9177&#xff0c;\u800c\u662f\u5b83\u5b9e\u5b9e\u5728\u5728\u89e3\u51b3\u4e86\u51e0\u4e2a\u8ba9\u4eba\u5934\u75bc\u7684\u8001\u95ee\u9898\u3002<br \/>\n\u4f20\u7edfNLU\u65b9\u6848\u8981\u4e48\u9700\u8981\u4e3a\u6bcf\u4e2a\u4efb\u52a1\u5355\u72ec\u8bad\u7ec3\u6a21\u578b&#xff0c;\u8981\u4e48\u5728\u96f6\u6837\u672c\u573a\u666f\u4e0b\u6548\u679c\u98d8\u5ffd\u4e0d\u5b9a\u3002\u800cRexUniNLU\u57fa\u4e8eSiamesePrompt\u6846\u67b6&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":[8504,8505,8503,956],"topic":[],"class_list":["post-77460","post","type-post","status-publish","format-standard","hentry","category-server","tag-nlu","tag-8505","tag-8503","tag-956"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72 - \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\/77460.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72 1. \u4e3a\u4ec0\u4e48\u9009\u62e9RexUniNLU\u8fdb\u884c\u751f\u4ea7\u90e8\u7f72 \u6700\u8fd1\u5728\u7ed9\u4e00\u5bb6\u91d1\u878d\u5ba2\u6237\u505a\u667a\u80fd\u5ba2\u670d\u7cfb\u7edf\u5347\u7ea7\u65f6&#xff0c;\u6211\u4eec\u5bf9\u6bd4\u4e86\u5341\u51e0\u79cdNLU\u65b9\u6848&#xff0c;\u6700\u7ec8\u9009\u5b9a\u4e86RexUniNLU\u3002\u4e0d\u662f\u56e0\u4e3a\u5b83\u540d\u5b57\u542c\u8d77\u6765\u591a\u9177&#xff0c;\u800c\u662f\u5b83\u5b9e\u5b9e\u5728\u5728\u89e3\u51b3\u4e86\u51e0\u4e2a\u8ba9\u4eba\u5934\u75bc\u7684\u8001\u95ee\u9898\u3002 \u4f20\u7edfNLU\u65b9\u6848\u8981\u4e48\u9700\u8981\u4e3a\u6bcf\u4e2a\u4efb\u52a1\u5355\u72ec\u8bad\u7ec3\u6a21\u578b&#xff0c;\u8981\u4e48\u5728\u96f6\u6837\u672c\u573a\u666f\u4e0b\u6548\u679c\u98d8\u5ffd\u4e0d\u5b9a\u3002\u800cRexUniNLU\u57fa\u4e8eSiamesePrompt\u6846\u67b6&amp;#xff\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/77460.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-24T11:07:38+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=\"10 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/77460.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/77460.html\",\"name\":\"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-24T11:07:38+00:00\",\"dateModified\":\"2026-02-24T11:07:38+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/77460.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/77460.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/77460.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72\"}]},{\"@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":"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72 - \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\/77460.html","og_locale":"zh_CN","og_type":"article","og_title":"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72 1. \u4e3a\u4ec0\u4e48\u9009\u62e9RexUniNLU\u8fdb\u884c\u751f\u4ea7\u90e8\u7f72 \u6700\u8fd1\u5728\u7ed9\u4e00\u5bb6\u91d1\u878d\u5ba2\u6237\u505a\u667a\u80fd\u5ba2\u670d\u7cfb\u7edf\u5347\u7ea7\u65f6&#xff0c;\u6211\u4eec\u5bf9\u6bd4\u4e86\u5341\u51e0\u79cdNLU\u65b9\u6848&#xff0c;\u6700\u7ec8\u9009\u5b9a\u4e86RexUniNLU\u3002\u4e0d\u662f\u56e0\u4e3a\u5b83\u540d\u5b57\u542c\u8d77\u6765\u591a\u9177&#xff0c;\u800c\u662f\u5b83\u5b9e\u5b9e\u5728\u5728\u89e3\u51b3\u4e86\u51e0\u4e2a\u8ba9\u4eba\u5934\u75bc\u7684\u8001\u95ee\u9898\u3002 \u4f20\u7edfNLU\u65b9\u6848\u8981\u4e48\u9700\u8981\u4e3a\u6bcf\u4e2a\u4efb\u52a1\u5355\u72ec\u8bad\u7ec3\u6a21\u578b&#xff0c;\u8981\u4e48\u5728\u96f6\u6837\u672c\u573a\u666f\u4e0b\u6548\u679c\u98d8\u5ffd\u4e0d\u5b9a\u3002\u800cRexUniNLU\u57fa\u4e8eSiamesePrompt\u6846\u67b6&amp;#xff","og_url":"https:\/\/www.wsisp.com\/helps\/77460.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-24T11:07:38+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"10 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/77460.html","url":"https:\/\/www.wsisp.com\/helps\/77460.html","name":"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-24T11:07:38+00:00","dateModified":"2026-02-24T11:07:38+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/77460.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/77460.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/77460.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"RexUniNLU\u6a21\u578b\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u7684\u751f\u4ea7\u7ea7\u90e8\u7f72"}]},{"@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\/77460","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=77460"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/77460\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=77460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=77460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=77460"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=77460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}