一、大模型推理

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?"
      }
    ]
  }'

相关推荐
会思想的苇草i36 分钟前
oMLX 部署本地大模型
大模型·ai编程·开发·本地部署·omlx
梦想三三8 小时前
LangChain模型调用与多轮对话完整实战
阿里云·langchain·大模型·api
程序员三明治8 小时前
【AI】RAG 生成阶段的最后一公里:Prompt 设计、幻觉抑制与引用对齐
java·人工智能·ai·大模型·llm·prompt·rag
kishu_iOS&AI9 小时前
【02】Context Engineering:Prompt不再是核心
ai·大模型·loop·rag·harness·agent 架构
thesky12345621 小时前
27届大模型岗面试准备(三):位置编码全景——从绝对编码到 RoPE/ALiBi 的演进与手推
人工智能·ai·大模型
山林竹笋1 天前
人工智能领域开源TOP20(2026.06.22-2026.06.28)
人工智能·开源·大模型·智能体·技术趋势
DogDaoDao1 天前
OpenBrowser 深度解析:让 AI 真正「用上」浏览器的自主代理框架
人工智能·程序员·大模型·github·web·ai工具·openbrowser
CoderJia程序员甲1 天前
GitHub 热榜项目 - 周榜(2026-07-26)
ai·大模型·llm·github·ai教程
OpenCSG2 天前
Hugging Face遭遇AI Agent攻击:AI资产管理正在进入新阶段
人工智能·大模型