microsoft / microsoft/LLMLingua

[Question]: sort_direct = -1 if condition_in_question == "none" else 1

Open
#212 1 comment 0 reactions 1 assignee View on GitHub

@iofu728 is already working on this.

Since Jul 3, 2025.

question
Dominant language
Python
Stars
6.7k
Forks
428
Avg merge
2d 4h
Merged PRs (30d)
1

Description

Describe the issue

I have a question about the control_sentence_budget
In the functions:
def get_distance_longllmlingua(corpus, query):
context_ppl = [
self.get_condition_ppl(
d,
query
+ " We can get the answer to this question in the given documents.",
condition_in_question,
)
- dl * 2 / 250 * 0
for d, dl in zip(corpus, context_tokens_length)
]
sort_direct = -1 if condition_in_question == "none" else 1
ys = sorted(enumerate(context_ppl), key=lambda x: sort_direct * x[1])

return ys
and in the function
def control_sentence_budget()
......
sort_direct = -1 if condition_in_question == "none" else 1
sent_sort = sorted(
enumerate(sentence_ppl), key=lambda x: sort_direct * x[1]
)

Why is the sorting order of sent_sort in ascending order when condition_in_question is not "none"? Does this mean that when considering the question, sentences with lower perplexity are selected? But shouldn't sentences with higher perplexity be retained instead?Thanl you!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.