一、大模型推理

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

相关推荐
少林码僧1 天前
2.9 字段分箱技术详解:连续变量离散化,提升模型效果的关键步骤
人工智能·ai·数据分析·大模型
AI情报挖掘日志1 天前
AGI-Next前沿峰会「沉思报告」——中国AGI背后的产业逻辑与战略分野
大模型·aminer·大模型研究
程序员黄老师1 天前
主流向量数据库全面解析
数据库·大模型·向量·rag
何中应1 天前
快速上架第一个智能体
ai·大模型·智能体开发
victory04311 天前
大模型学习阶段总结和下一阶段展望
深度学习·学习·大模型
谷哥的小弟1 天前
Brave Search MCP服务器安装以及客户端连接配置
搜索引擎·大模型·spring ai·mcp·brave search
星云数灵1 天前
大模型高级工程师考试练习题7
数据库·大模型·阿里云acp·大模型工程师·大模型考试题库·阿里云aca·大模型工程师acp
星云数灵2 天前
大模型高级工程师考试练习题6
人工智能·大模型·大模型工程师·阿里云大模型aca·阿里云大模型工程师acp·大模型acp考试题库·acp认证
索木木2 天前
强化学习与思维链
大模型·sft·强化学习·思维链
KAI智习2 天前
大模型榜单周报(2026/01/10)
人工智能·大模型