Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 15, 2025
1 parent be6e5e2 commit 12adbae
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions nlp_span_comparison/nlp_span_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def load_examples():
for block in HAMLET.split("\n\n")
if block
]

return (load_examples,)


Expand All @@ -42,6 +43,7 @@ def model_a_predictor(text: str) -> tuple[int, int]:
start = random.randint(0, len(text) - 2)
end = random.randint(start + 1, len(text) - 1)
return start, end

return (model_a_predictor,)


Expand All @@ -53,6 +55,7 @@ def model_b_predictor(text: str) -> tuple[int, int]:
start = random.randint(0, len(text) - 2)
end = random.randint(start + 1, len(text) - 1)
return start, end

return (model_b_predictor,)


Expand Down Expand Up @@ -121,7 +124,7 @@ def _(CHOICES_PATH, get_choices, index, mo, write_choices):
def _():
preference = get_choices()[index.value]["model"]
mo.stop(preference is None, mo.md("**Choose the better model**.").center())

write_choices(get_choices(), CHOICES_PATH)
return mo.md(f"You prefer **model {preference}**.").center()

Expand Down Expand Up @@ -174,9 +177,7 @@ def _(index, mo, set_choices):
def _(EXAMPLES, annotate, index, model_a_predictor, model_b_predictor):
_example = EXAMPLES[index.value]

model_A_prediction = annotate(
_example, model_a_predictor(_example), color="yellow"
)
model_A_prediction = annotate(_example, model_a_predictor(_example), color="yellow")

model_B_prediction = annotate(
_example, model_b_predictor(_example), color="lightblue"
Expand All @@ -186,9 +187,7 @@ def _(EXAMPLES, annotate, index, model_a_predictor, model_b_predictor):

@app.cell
def _(mo, model_A_prediction, model_B_prediction):
mo.hstack(
[model_A_prediction, model_B_prediction], gap=2, justify="space-around"
)
mo.hstack([model_A_prediction, model_B_prediction], gap=2, justify="space-around")
return


Expand Down Expand Up @@ -218,11 +217,11 @@ def load_choices(path, number_of_examples):
assert len(choices) == number_of_examples
return choices


def write_choices(choices, path):
# Trunacate notes
with open(path, "w") as f:
f.write(json.dumps(choices))

return load_choices, write_choices


Expand All @@ -237,6 +236,7 @@ def annotate(text, span, color):
+ "</mark>"
+ text[span[1] :]
)

return (annotate,)


Expand All @@ -249,6 +249,7 @@ def _(EXAMPLES):
@app.cell
def _():
import marimo as mo

return (mo,)


Expand All @@ -259,6 +260,7 @@ def _():
import random
import textwrap
import urllib

return json, os, random, textwrap, urllib


Expand Down

0 comments on commit 12adbae

Please sign in to comment.