微信扫码
添加专属顾问
我要投稿
微软开源LLMLingua,解决大模型提示词过长问题,20倍压缩比显著降低成本与延迟! 核心内容: 1. LLMLingua的三层压缩框架与20倍压缩比技术原理 2. 针对长文档优化的LongLLMLingua动态压缩策略 3. LLMLingua-2突破性采用机器学习分类器实现智能压缩
什么是 LLMLingua
LLMLingua系列技术演进
使用方法及效果
pip install llmlingua
from llmlingua import PromptCompressor# Initialize the compressorllm_lingua = PromptCompressor()# Compress the promptprompt = "Sam bought a dozen boxes, each with 30 highlighter pens inside, for $10 each box..."compressed_prompt = llm_lingua.compress_prompt(prompt, instruction="", question="", target_token=200)print(compressed_prompt)
{ 'compressed_prompt': 'Question: Sam bought a dozen boxes each with 30 highlighter pens...', 'origin_tokens': 2365, 'compressed_tokens': 211, 'ratio': '11.2x', 'saving': 'Saving $0.1 in GPT-4.'}# Use a more powerful compression modelllm_lingua = PromptCompressor("microsoft/phi-2")# Or use a quantized model for GPUs with limited memory# Requires: pip install optimum auto-gptqllm_lingua = PromptCompressor("TheBloke/Llama-2-7b-Chat-GPTQ", model_config={"revision": "main"})小结
END
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2026-04-14
AI 工程化实战:如何像设计函数参数一样设计 System Prompt?
2026-04-14
Karpathy 的 CLAUDE.md,到底解决了什么问题
2026-04-09
如何让生成式AI更懂你?全新交互模型IAI,重塑人机协同范式
2026-04-07
不再触发Claude使用限制,大幅降低Token的10个有效习惯!
2026-03-31
Harness 不是加一行规则那么简单——我从三家顶级公司学到了什么
2026-03-27
别再死磕 PMF 了!AgaaS 时代,中国 To B 创业者的最后一张船票
2026-03-26
7 个 Karpathy 式提示词,让 Claude 变成你的研究员、工程师和思考搭档
2026-03-26
Claude Code终极指令速查表
2026-01-29
2026-02-26
2026-01-18
2026-01-30
2026-01-17
2026-02-24
2026-02-04
2026-01-18
2026-03-18
2026-03-07
2026-04-14
2026-02-28
2026-02-12
2026-02-12
2026-02-08
2026-02-05
2026-02-05
2026-01-23