microsoft / LLMLingua

[EMNLP'23, ACL'24] To speed up LLMs' inference and enhance LLM's perceive of key information, compress the prompt and KV-Cache, which achieves up to 20x compression with minimal performance loss.
https://llmlingua.com/
MIT License
4.63k stars 256 forks source link

[Question]: 在生成摘要的任务,是如何进行压缩的? #190

Open dongziyu1016 opened 1 month ago

dongziyu1016 commented 1 month ago

Describe the issue

作者您好,请问在使用LongLLMLingua生成摘要时,instruction、document、question应该怎么设置?问题感知粗粒度压缩、问题感知细粒度压缩、分别是怎么执行的呢?

期待您的回复!

iofu728 commented 3 weeks ago

Hi @dongziyu1016, thanks for your question. In summarization tasks, we split the instruction, document, and question based on their positions in the prompt. The text before the document serves as the instruction, and the text after the document is treated as the question.

You can refer to the examples in LongBench for more details.

INSTRUCTIONS = {
    "narrativeqa": "You are given a story, which can be either a novel or a movie script, and a question. Answer the question asconcisely as you can, using a single phrase if possible. Do not provide any explanation.\n\nStory: {context}\n\n",
    "qasper": "You are given a scientific article and a question. Answer the question as concisely as you can, using a single phrase or sentence if possible. If the question cannot be answered based on the information in the article, write \"unanswerable\". If the question is a yes/no question, answer \"yes\", \"no\", or \"unanswerable\". Do not provide any explanation.\n\nArticle: {context}\n\n",
    "multifieldqa_en": "Read the following text and answer briefly.\n\n{context}\n\n",
    "hotpotqa": "Answer the question based on the given passages. Only give me the answer and do not output any other words.\n\nThe following are given passages.\n{context}\n\n",
    "2wikimqa": "Answer the question based on the given passages. Only give me the answer and do not output any other words.\n\nThe following are given passages.\n{context}\n\n",
    "musique": "Answer the question based on the given passages. Only give me the answer and do not output any other words.\n\nThe following are given passages.\n{context}\n\n",
    "gov_report": "You are given a report by a government agency. Write a one-page summary of the report.\n\nReport:\n{context}\n\n",
    "qmsum": "You are given a meeting transcript and a query containing a question or instruction. Answer the query in one or more sentences.\n\nTranscript:\n{context}\n\n",
    "multi_news": "You are given several news passages. Write a one-page summary of all news. \n\nNews:\n{context}\n\n",
    "trec": "Please determine the type of the question below. Here are some examples of questions.\n\n{context}\n",
    "triviaqa": "Answer the question based on the given passage. Only give me the answer and do not output any other words. The following are some examples.\n\n{context}\n\n",
    "samsum": "Summarize the dialogue into a few short sentences. The following are some examples.\n\n{context}\n\n",
    "passage_count": "There are some paragraphs below sourced from Wikipedia. Some of them may be duplicates. Please carefully read these paragraphs and determine how many unique paragraphs there are after removing duplicates. In other words, how many non-repeating paragraphs are there in total?\n\n{context}\n\n",
    "passage_retrieval_en": "Here are 30 paragraphs from Wikipedia, along with an abstract. Please determine which paragraph the abstract is from.\n\n{context}\n\n",
    "lcc": "Please complete the code given below. \n{context}",
    "repobench-p": "Please complete the code given below. \n{context}"
}
QUESTIONS = {
    "narrativeqa": "Now, answer the question based on the story asconcisely as you can, using a single phrase if possible. Do not provide any explanation.\n\nQuestion: {input}\n\nAnswer:",
    "qasper": "Answer the question based on the above article as concisely as you can, using a single phrase or sentence if possible. If the question cannot be answered based on the information in the article, write \"unanswerable\". If the question is a yes/no question, answer \"yes\", \"no\", or \"unanswerable\". Do not provide any explanation.\n\nQuestion: {input}\n\nAnswer:",
    "multifieldqa_en": "Now, answer the following question based on the above text, only give me the answer and do not output any other words.\n\nQuestion: {input}\nAnswer:",
    "hotpotqa": "Answer the question based on the given passages. Only give me the answer and do not output any other words.\n\nQuestion: {input}\nAnswer:",
    "2wikimqa": "Answer the question based on the given passages. Only give me the answer and do not output any other words.\n\nQuestion: {input}\nAnswer:",
    "musique": "Answer the question based on the given passages. Only give me the answer and do not output any other words.\n\nQuestion: {input}\nAnswer:",
    "gov_report": "Now, write a one-page summary of the report.\n\nSummary:",
    "qmsum": "Now, answer the query based on the above meeting transcript in one or more sentences.\n\nQuery: {input}\nAnswer:",
    "multi_news": "Now, write a one-page summary of all the news.\n\nSummary:",
    "trec": "{input}",
    "triviaqa": "{input}",
    "samsum": "{input}",
    "passage_count": "Please enter the final count of unique paragraphs after removing duplicates. The output format should only contain the number, such as 1, 2, 3, and so on.\n\nThe final answer is: ",
    "passage_retrieval_en": "The following is an abstract.\n\n{input}\n\nPlease enter the number of the paragraph that the abstract is from. The answer format must be like \"Paragraph 1\", \"Paragraph 2\", etc.\n\nThe answer is: ",
    "lcc": "Next line of code:\n",
    "repobench-p": "{input}Next line of code:\n"
}
dongziyu1016 commented 3 weeks ago

感谢您的回复! 我有一个疑问, 在"gov_report这个数据集中, Instruction是"You are given a report by a government agency. Write a one-page summary of the report.“ question是:“Now, write a one-page summary of the report.\n\nSummary”, 以这个question为条件计算困惑度的话,好像不同部分的文本之间的区别并不大。 请问这应该怎么理解呢? 期待您的回复!