一、大模型推理

https://github.com/hiyouga/LLaMA-Factory/blob/main/README_zh.md
https://github.com/hiyouga/LLaMA-Factory/blob/main/examples/README_zh.md

  • 安装 v7.1

https://github.com/hiyouga/LLaMA-Factory/releases/tag/v0.7.1

python 复制代码
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
cd LLaMA-Factory
pip install -e .[torch,metrics]
  • 推理
    • 以 Llama-3-8B-Instruct 为例,这里全部用 vllm 作为后端,不写就是 transformers 后端
  • 使用命令行接口
    • llama3_vllm.yaml
python 复制代码
model_name_or_path: eta-Llama-3-8B-Instruct
template: llama3
infer_backend: vllm
vllm_enforce_eager: true
python 复制代码
CUDA_VISIBLE_DEVICES=0 llamafactory-cli chat examples/inference/llama3_vllm.yaml
  • 使用浏览器界面
python 复制代码
CUDA_VISIBLE_DEVICES=0 llamafactory-cli webchat examples/inference/llama3_vllm.yaml
  • 启动 OpenAI 风格 API
python 复制代码
CUDA_VISIBLE_DEVICES=0 llamafactory-cli api examples/inference/llama3_vllm.yaml
  • 模拟发起请求
python 复制代码
curl http://0.0.0.0:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer " \
  -d '{
    "model": "Meta-Llama-3-8B-Instruct",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Who won the world series in 2020?"
      },
      {
        "role": "assistant",
        "content": "The Los Angeles Dodgers won the World Series in 2020."
      },
      {
        "role": "user",
        "content": "Where was it played?"
      }
    ]
  }'

相关推荐
楚国的小隐士1 天前
“你用AI,那我也会用AI,我还要你干什么?”
ai·大模型·编程·ai编程·哲学·氛围编程·辩证唯物主义·马列主义·唯物论
大龄码农有梦想1 天前
Spring AI Alibaba Skills与 Claude Skills 深度对比分析:概念、机制与应用场景
人工智能·大模型·智能体·大模型应用·spring ai·claude skills
twc8291 天前
写好提示词
人工智能·大模型·llm·提示词工程
twc8291 天前
RAG加Text2SQL:自动生成接口测试脚本的完整流水线
大模型·接口测试·rag
何政@1 天前
通过python 快速完成ai 构建
人工智能·python·ai·大模型·love l
小马过河R1 天前
小白沉浸式本地Mac小龙虾OpenClaw部署安装教程
人工智能·macos·大模型·nlp·agent·openclaw·龙虾
竹之却1 天前
国内外主流大模型全面解析(2026版)
服务器·大模型·国内外主流大模型·openclaw·云养虾
twc8291 天前
MCP赋能测试:Tools、Resources、Prompts三种能力的开发与应用
软件测试·大模型·mcp
twc8291 天前
MCP协议核心解析:标准化AI工具调用的设计与实践
人工智能·大模型·mcp·ai工具调用
twc8291 天前
大模型评估指标简要说明
算法·大模型·bleu