一、大模型推理

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

相关推荐
Tadas-Gao5 小时前
从“驯马”到“驭队”:Harness Engineering 如何重构 AI 产品化的底层逻辑
人工智能·语言模型·架构·大模型·llm·harness
guslegend8 小时前
第6节:OCR文本错漏频发?结合LLM纠错,让图像文本也能精确使用
人工智能·大模型·ocr·rag
Wenweno0o9 小时前
Eino - 从0到1跑通大模型调用
golang·大模型·智能体·eino
华农DrLai10 小时前
怎么用大模型生成推荐的训练数据?Data Augmentation怎么做?
数据库·人工智能·大模型·nlp·prompt
guslegend12 小时前
4月11日(Codex使用)
人工智能·大模型
CoderJia程序员甲13 小时前
GitHub 热榜项目 - 日榜(2026-04-11)
人工智能·ai·大模型·github·ai教程
见合八方13 小时前
AI大模型入门教程:从零开始理解ChatGPT背后的技术
ai·chatgpt·大模型·llm·入门教程
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-04-09)
人工智能·ai·大模型·github·ai教程
前端摸鱼匠1 天前
【AI大模型春招面试题18】 L1、L2正则化、Dropout、早停(Early Stopping)的原理与适用场景?
人工智能·ai·语言模型·面试·大模型
前端摸鱼匠2 天前
【AI大模型春招面试题17】 过拟合、欠拟合在大模型中的表现与解决策略?
人工智能·ai·语言模型·面试·大模型