当前位置: 首页 > news >正文

【vLLM 学习】CPU 离线处理

vLLM 是一款专为大语言模型推理加速而设计的框架,实现了 KV 缓存内存几乎零浪费,解决了内存管理瓶颈问题。

更多 vLLM 中文文档及教程可访问 →https://vllm.hyper.ai/

源代码:vllm-project/vllm

from vllm import LLM, SamplingParams# Sample prompts.
# 提示示例prompts = ["Hello, my name is","The president of the United States is","The capital of France is","The future of AI is",
]
# Create a sampling params object.
# 创建 sampling params 对象
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)# Create an LLM.
# 创建一个 LLM
llm = LLM(model="meta-llama/Llama-2-13b-chat-hf", cpu_offload_gb=10)
# Generate texts from the prompts. The output is a list of RequestOutput objects
# that contain the prompt, generated text, and other information.
# 从提示中生成文本。输出是一个 RequestOutput 列表,包含提示、生成文本和其他信息outputs = llm.generate(prompts, sampling_params)
# Print the outputs.
# 打印输出
for output in outputs:prompt = output.promptgenerated_text = output.outputs[0].textprint(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
http://www.dtcms.com/a/160672.html

相关文章:

  • Alibaba Druid 完整配置与 Keepalive 优化指南
  • 《全球反空间能力》报告翻译——部分1
  • Mysql中隐式内连接和显式内连接的区别
  • 自然语言to SQL的评估
  • 二叉树遍历(C语言版)
  • 小白学习python第四天
  • 跨专业自学AI人工智能学习路线图(2025版)
  • Linux日志处理命令多管道实战应用
  • 【Redis】Redis Zset实现原理:跳表+哈希表的精妙设计
  • 使用PHP对接印度股票市场数据
  • 基于c++的LCA倍增法实现
  • 【博客系统】博客系统第二弹:实现博客列表接口(在 Service 层重新封装 Mapper 层返回结果,避免实体类所有字段都向前端返回)、SimpleDateFormat 类的使用方法
  • 【RabbitMQ消息队列】详解(一)
  • Linux系统类型及常用操作命令总结
  • 第三方软件检测报告:热门办公软件评估及功能表现如何?
  • 电力系统失步解列与振荡解析
  • Java 内存泄漏 详解
  • 【AI提示词】领导力教练
  • 4.2.1 MYSQL语句,索引,视图,存储过程,触发器
  • 第十三步:vue
  • 【PVR】《Adaptive Palm Vein Recognition Method》
  • React Testing Library
  • Java学习手册:开发 Web 网站要知道的知识
  • T检验、F检验及样本容量计算学习总结
  • 2025第16届蓝桥杯省赛之研究生组D题最大数字求解
  • 学习spark总结
  • 常见锁策略
  • 关系型数据库PostgreSQL vs MySQL 深度对比:专业术语+白话解析+实战案例
  • Customizing Materials Management with SAP ERP Operations
  • AI日报 - 2025年04月28日