微信扫码
添加专属顾问
我要投稿
微软开源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-06-20
从提示词工程到循环工程
2026-06-17
用 Claude AI 学会任何东西的 6 个万能提示词
2026-06-17
怎么写一份 Claude 真正能看懂的 DESIGN.md 文件?
2026-06-15
提示词工程已死,Loop Engineering来了!
2026-06-12
教你用 Codex 从 0 到 1 写一个 SKILL
2026-06-12
用Claude Code写PRD,我总结了这几条有用的经验!
2026-06-11
Anthropic 工程师:我不再写 Prompt 了,我写 Loop
2026-06-11
把提示词封装成skill!零成本雇佣一位Excel高手
2026-04-21
2026-04-07
2026-03-26
2026-03-26
2026-04-25
2026-05-02
2026-04-14
2026-04-19
2026-04-20
2026-04-14
2026-06-17
2026-05-23
2026-05-16
2026-04-14
2026-02-28
2026-02-12
2026-02-12
2026-02-08