Skip to content

Commit

Permalink
ruff format and removed excesss changes to mnimize PR
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruviyer committed Jan 14, 2025
1 parent 2d7df7a commit 13d0161
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion examples/op_examples/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
lm = LM(model="gpt-4o-mini")

lotus.settings.configure(lm=lm)

data = {
"Course Name": [
"Probability and Random Processes",
Expand Down
1 change: 0 additions & 1 deletion examples/op_examples/filter_cascade.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
gpt_4o = LM("gpt-4o")

lotus.settings.configure(lm=gpt_4o, helper_lm=gpt_4o_mini)

data = {
"Course Name": [
"Probability and Random Processes",
Expand Down
10 changes: 8 additions & 2 deletions lotus/sem_ops/sem_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def sem_filter(
safe_mode: bool = False,
show_progress_bar: bool = True,
progress_bar_desc: str = "Filtering",
additional_cot_instructions: str = ""
additional_cot_instructions: str = "",
) -> SemanticFilterOutput:
"""
Filters a list of documents based on a given user instruction using a language model.
Expand All @@ -49,7 +49,13 @@ def sem_filter(
inputs = []
for doc in docs:
prompt = lotus.templates.task_instructions.filter_formatter(
doc, user_instruction, examples_multimodal_data, examples_answers, cot_reasoning, strategy, reasoning_instructions=additional_cot_instructions
doc,
user_instruction,
examples_multimodal_data,
examples_answers,
cot_reasoning,
strategy,
reasoning_instructions=additional_cot_instructions,
)
lotus.logger.debug(f"input to model: {prompt}")
inputs.append(prompt)
Expand Down
8 changes: 4 additions & 4 deletions lotus/templates/task_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ def filter_formatter(
assert examples_answer is not None
assert isinstance(examples_multimodal_data, list) and isinstance(examples_answer, list)
assert len(examples_multimodal_data) == len(examples_answer)

if cot_reasoning:
# users don't have to provide cot reasoning examples
# but if they do, the number of examples must match
# users don't have to provide cot reasoning examples
# but if they do, the number of examples must match
assert isinstance(cot_reasoning, list)
assert len(examples_multimodal_data) == len(examples_answer) == len(cot_reasoning)

Expand All @@ -128,7 +128,7 @@ def filter_formatter(
content = cot_formatter("Reasoning omitted", str(ex_ans))
else:
content = answer_only_formatter(str(ex_ans))

messages.extend(
[
user_message_formatter(ex_multimodal_data, f"Claim: {user_instruction}"),
Expand Down

0 comments on commit 13d0161

Please sign in to comment.