🚀 LLMLingua-2-Bert-base-Multilingual-Cased-MeetingBank
该模型出自论文 LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compression (Pan et al, 2024)。它是在 XLM-RoBERTa(大型模型) 基础上微调而来,用于执行与任务无关的提示压缩的标记分类任务。每个标记 $x_i$ 的保留概率 $p_{preserve}$ 被用作压缩指标。此模型在 提取式文本压缩数据集 上进行训练,该数据集是根据 LLMLingua-2 中提出的方法构建的,使用 MeetingBank (Hu et al, 2023) 中的训练示例作为种子数据。
你可以使用 此数据集 在下游任务(如问答(QA)和压缩会议记录的摘要)上评估该模型。
更多详细信息,请查看 LLMLingua-2 和 LLMLingua 系列 的主页。
🚀 快速开始
本模型可用于执行与任务无关的提示压缩的标记分类任务,能够有效提升下游任务(如问答和摘要)的效率。
✨ 主要特性
- 基于 XLM - RoBERTa 大型模型微调,用于任务无关的提示压缩。
- 使用标记保留概率作为压缩指标。
- 在特定构建的提取式文本压缩数据集上训练。
💻 使用示例
基础用法
from llmlingua import PromptCompressor
compressor = PromptCompressor(
model_name="microsoft/llmlingua-2-xlm-roberta-large-meetingbank",
use_llmlingua2=True
)
original_prompt = """John: So, um, I've been thinking about the project, you know, and I believe we need to, uh, make some changes. I mean, we want the project to succeed, right? So, like, I think we should consider maybe revising the timeline.
Sarah: I totally agree, John. I mean, we have to be realistic, you know. The timeline is, like, too tight. You know what I mean? We should definitely extend it.
"""
results = compressor.compress_prompt_llmlingua2(
original_prompt,
rate=0.6,
force_tokens=['\n', '.', '!', '?', ','],
chunk_end_tokens=['.', '\n'],
return_word_label=True,
drop_consecutive=True
)
print(results.keys())
print(f"Compressed prompt: {results['compressed_prompt']}")
print(f"Original tokens: {results['origin_tokens']}")
print(f"Compressed tokens: {results['compressed_tokens']}")
print(f"Compression rate: {results['rate']}")
word_sep = "\t\t|\t\t"
label_sep = " "
lines = results["fn_labeled_original_prompt"].split(word_sep)
annotated_results = []
for line in lines:
word, label = line.split(label_sep)
annotated_results.append((word, '+') if label == '1' else (word, '-'))
print("Annotated results:")
for word, label in annotated_results[:10]:
print(f"{word} {label}")
📄 许可证
本项目采用 MIT 许可证。
📚 引用
@article{wu2024llmlingua2,
title = "{LLML}ingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compression",
author = "Zhuoshi Pan and Qianhui Wu and Huiqiang Jiang and Menglin Xia and Xufang Luo and Jue Zhang and Qingwei Lin and Victor Ruhle and Yuqing Yang and Chin-Yew Lin and H. Vicky Zhao and Lili Qiu and Dongmei Zhang",
url = "https://arxiv.org/abs/2403.12968",
journal = "ArXiv preprint",
volume = "abs/2403.12968",
year = "2024",
}