Skip to content

add benchmark.py module#56

Open
mouayadkarimeh wants to merge 5 commits into
caretech-owl:mainfrom
mouayadkarimeh:gerd/benchmark.py
Open

add benchmark.py module#56
mouayadkarimeh wants to merge 5 commits into
caretech-owl:mainfrom
mouayadkarimeh:gerd/benchmark.py

Conversation

@mouayadkarimeh

Copy link
Copy Markdown
Contributor

Features
Model Comparison: Benchmarks reasoning models vs. non-reasoning models
No-Think Option Support: Integrates with the /no_think parameter to test different model behaviors
RAG Integration: Supports benchmarking with and without RAG (Retrieval-Augmented Generation) concept

Work in Progress
Answer Comparison: Implementation for comparing generated answers and calculating accuracy percentages
Profile Function: Optimization of the profile() function for more reliable result demonstration and output formatting

@mouayadkarimeh mouayadkarimeh left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest commit contains both pre-commit fixes and the increased ruff complexity limit simultaneously. It's not just the complexity increase — the entire benchmark.py file has been prepared and is ready for review.

Comment thread gerd/benchmark.py Outdated
Comment on lines +158 to +168
def remove_think_tags(text: str) -> str:
"""Remove think-tags from text.

Parameter:
text (str): The input text containing think-tags.

Returns:
str: The text with think-tags removed.
"""
think_tag_re = re.compile(r"</?\s*think\s*>", re.IGNORECASE)
return think_tag_re.sub("", text)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about removing the full think block instead of just the tags?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now its removed

Comment thread gerd/benchmark.py Outdated
re.IGNORECASE,
)

RELEASE_DATE_RE = re.compile(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those not the same as recording date?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combining RECORDING_DATE_RE and RELEASING_DATE_RE IN RECORDING_RELEASING_DATE_RE
in funktion extract_date_from_text based on the qwustion wheter "Wann hat der Patient bei uns aufgenommen" or "Wann wurde der Patient bei uns entlassen"

Comment thread gerd/benchmark.py Outdated
)


def extract_release_date_from_text(text: str) -> str:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also similar to extract_record_data. whatabout putting both together in one function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combined in extract_recording_releasing_date_from_text()

Comment thread gerd/benchmark.py
_LOGGER.info("Ergebnisse gespeichert in: %s", RESULT_CSV_WITHOUT_RAG_ONE_FILE)


def profile(file_path: Path, use_rag: bool, no_think: bool) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it doing the same as run_bmk?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove run_bmk_onefile(). because profile() does the same work and returned the clean answers

aktuel:
run_bmk(): run benchmark for a number of files.
profile(): run benchmark for one file and demonstrate the clean answers.

Comment thread gerd/benchmark.py Outdated
# run_bmk(max_files = 5, use_rag=True, no_think_option= True)
# run_bmk_one_file(file_path=RAW_TEXT_DIR / "Cajal.txt"
# , use_rag=True, no_think_option=False)
profile(file_path=RAW_TEXT_DIR / "Cajal.txt", use_rag=True, no_think=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Instead of using a global variable you could parse those arguments from the command line (with useful defaults)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add Argumentparse in CLI. diffrent examples how to run profil() in the CLI are provided as comments in main section.

Examples

  1. run uv benchmark.py --file-path RAW/Cajal.txt --use-rag --no-think =
    run benchmark Cajal.txt, use-rag = True, no-think = True

  2. run uv benchmark.py --file-path RAW/Cajal.txt --use-rag =
    run benchmark for Cajal.txt, use-rag = True, no-think = False

  3. run uv benchmark.py --file-path RAW/Cajal.txt --no-think =
    run benchmark for Cajal.txt, use-rag = False, no-think = True

  4. run uv benchmark.py --file-path RAW/Cajal.txt =
    run benchmark Cajal.txt, use-rag = False, no-think = False

@costrau

costrau commented May 15, 2026

Copy link
Copy Markdown
Member

@mouayadkarimeh thanks for updating the pr. There are still some linting issues (besides my comments above).

…run ruff check- run test- There are some history errors that has nothing to do with benchmark.py.
Comment thread gerd/benchmark.py
p.add_argument(
"--file-path",
dest="file_path",
help=f"Path to input text file (default: {RAW / 'Cajal.txt'})",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you set this default (and why not here?)

Comment thread gerd/benchmark.py
# run uv benchmark.py --file-path RAW/Cajal.txt --use-rag
# run uv benchmark.py --file-path RAW/Cajal.txt --no-think
# run uv benchmark.py --file-path RAW/Cajal.txt
profile(file_path=fp, use_rag=bool(args.use_rag), no_think=bool(args.no_think))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to call profile if file_path is a single file and run_bmk if it is a folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants