一、大模型推理

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

相关推荐
安逸sgr8 小时前
循环神经网络 RNN、LSTM、GRU 是什么?为什么能处理序列?
人工智能·ai·大模型·agent·智能体
安逸sgr10 小时前
卷积神经网络 CNN 是什么?为什么适合处理图像?
人工智能·ai·大模型·agent·智能体
CoderJia程序员甲11 小时前
GitHub 热榜项目 - 周榜(2026-08-16)
ai·大模型·llm·github
thesky12345611 小时前
27届大模型面试准备(三十六):注意力机制演进与 KV Cache 优化——从 MHA 到 MLA 的显存之战
大模型·注意力机制·mha·gqa·mqa·kv cache·mla
微学AI11 小时前
把时间序列真正用起来:TimechoAI 使用与时序分析实战
数据库·人工智能·大模型
tachibana212 小时前
怎么让大模型同时给意图节点打分
大数据·人工智能·ai·大模型·llm·prompt
小白跃升坊15 小时前
阿里云通义千问正式开源 Qwen3.8-27B:性能与成本的黄金平衡点
开源·大模型·通义千问·qwen·qwen3.8-27b
小田学Python20 小时前
上下文工程:Agent 的“工作台”收拾好没
大模型·ai agent·上下文工程
暗黑小白1 天前
参数从哪来、何时来 —— 提取时机与平台化 Slot 管理
人工智能·后端·大模型·ai agent
TonyLee0171 天前
关于大模型LLM的应用技术栈简记
大模型·agent·提示词工程