一、大模型推理

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

相关推荐
+wacyltd大模型备案算法备案1 分钟前
大模型评估测试题库怎么建?风险分类、测试样本的完整方法
人工智能·算法·安全·分类·大模型·大模型备案·大模型上线登记
小折耳猫_3 小时前
AI 智能体可观测性
大模型·agent·智能体
zzzll11113 小时前
如何学习AI Agent?
java·人工智能·学习·程序员·大模型
Tbisnic1 天前
从链式法则到ReLU:梯度消失的数学本质与工程解决方案
python·深度学习·大模型·激活函数·梯度消失
GPUStack1 天前
你的 GPU 算力,到底被谁、用在了哪儿?GPUStack 用量统计上线,一张图说清楚
ai·大模型·llm·gpu集群·gpustack
SLD_Allen1 天前
上下文腐化:当大模型的长窗口变成“认知负担”
大模型·上下文
七牛云行业应用1 天前
云厂商大模型推理平台对比选型(2026 版):七牛云、阿里百炼、火山方舟、百度千帆、硅基流动、腾讯混元横评
大模型
wumingxiaoyao2 天前
从 0 开始学 AI:第 2 课,AI、机器学习、深度学习和大模型是什么关系?
人工智能·深度学习·机器学习·ai·大模型·llm
带娃的IT创业者2 天前
深度解析:当 AI 代理拥有人格——重构软件开发协作模式
人工智能·重构·大模型·软件开发·人机协作·ai代理·多代理协作
100个铜锣烧3 天前
高级提示技术:Chain-of-Thought与ReAct——让大模型学会“思考”和“行动”
人工智能·大模型·提示词工程