一、大模型推理

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

相关推荐
山顶夕景11 小时前
【RL】DAPO的后续:VAPO算法
大模型·强化学习·dapo·vapo
viperrrrrrrrrr719 小时前
Agent向量存储中的记忆衰退与记忆过载解决方案
langchain·大模型·agent·rag
CoderJia程序员甲20 小时前
GitHub 热榜项目 - 日榜(2025-10-18)
ai·开源·大模型·github·ai教程
测试开发技术1 天前
什么样的 prompt 是好的 prompt?
人工智能·ai·大模型·prompt
小新学习屋1 天前
大模型-智能体-【篇一:单智能体框架】
大模型·智能体
小新学习屋1 天前
大模型-智能体-【篇二:多智能体框架】
大模型·多智能体
居7然1 天前
DeepSeek-7B-chat 4bits量化 QLora 微调
人工智能·分布式·架构·大模型·transformer
OpenCSG2 天前
【活动预告】2025斗拱开发者大会,共探支付与AI未来
人工智能·ai·开源·大模型·支付安全
万俟淋曦2 天前
【论文速递】2025年第28周(Jul-06-12)(Robotics/Embodied AI/LLM)
人工智能·ai·机器人·大模型·论文·robotics·具身智能
梵得儿SHI2 天前
Prompt Engineering 核心知识:从基础模式到思维链,掌握大模型高效交互秘籍
大模型·prompt·交互·提示词·对话·大模型提问艺术·极简指令