一、大模型推理

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 小时前
【多模态】天池AFAC赛道四-智能体赋能的金融多模态报告自动化生成part2-报告输出
大模型·agent·多模态·智能体
精致先生4 小时前
RAG(检索增强生成)
人工智能·大模型·rag
威化饼的一隅10 小时前
【多模态】天池AFAC赛道四-智能体赋能的金融多模态报告自动化生成part1-数据获取
大模型·agent·多模态·智能体
美林数据Tempodata13 小时前
美林数据用大模型重构电能质量评估,让隐蔽合规问题无所遁形
重构·大模型
胡耀超1 天前
我们如何写好提示词、发挥LLM能力、写作指南:从认知分析到动态构建的思维方法
人工智能·python·学习·大模型·llm·提示词·八要素思维
文浩(楠搏万)2 天前
XTTS实现语音克隆:精确控制音频格式与生成流程【TTS的实战指南】
大模型·tts·克隆·语音·声音克隆·音色·xtts
您的通讯录好友2 天前
TechGPT2部署
linux·人工智能·python·大模型·techgpt
之之为知知2 天前
Chromadb 1.0.15 索引全解析:从原理到实战的向量检索优化指南
人工智能·深度学习·机器学习·大模型·索引·向量数据库·chromadb
想躺平的咸鱼干3 天前
大模型开发
ai·大模型·ai应用开发技术架构
ATM0063 天前
MetaGPT源码剖析(三):多智能体系统的 “智能角色“ 核心实现——Role类
人工智能·大模型·agent·源码剖析·metagpt