一、大模型推理

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

相关推荐
致Great40 分钟前
DeepSeek-V3.2技术报告解读:开源大模型的逆袭之战——如何用10%算力追平GPT-5
人工智能·gpt·开源·大模型·agent·智能体
飞火流星020272 小时前
大模型Temperature 参数说明及配置建议
ai·大模型·temperature
Study9962 小时前
【电子书】大语言模型综述(391页)
人工智能·语言模型·自然语言处理·大模型·llm·gpt-3·大模型综述
程序员柒叔3 小时前
Dify知识库- Word文档处理
大模型·word·workflow·知识库·工作流·dify
Peter_Monster21 小时前
LangChain到底是什么?
人工智能·langchain·大模型
Sindy_he21 小时前
2025最新版微软GraphRAG 2.0.0本地部署教程:基于Ollama快速构建知识图谱
python·microsoft·大模型·知识图谱·rag
愤怒的可乐1 天前
从零构建大模型智能体:实现可扩展工具系统
人工智能·大模型·智能体框架
看今朝·1 天前
【软件工程3.0】智能时代企业新型生产关系:人机协同的系统性变革
人工智能·大模型·软件工程·多模型协同·目标优化
我很哇塞耶1 天前
从 “检索知识” 到 “会用知识”:西安交大 + 华为 2025 EMNLP 新方案RAG+
人工智能·ai·大模型·rag·检索增强生成
ekoeko1 天前
当你和大模型对话时,模型在做什么
ai·大模型·transformer