Skip to content

Conversation

@chakravarthik27
Copy link
Collaborator

@chakravarthik27 chakravarthik27 commented Mar 25, 2025

Harness Setup:

from langtest import Harness 

harness = Harness(
    task="question-answering",
    model={
        "model": "llama3.1",
        "hub": "ollama",
        "type": "chat",
    },
    data={
        "data_source": "MedQA",
        "split": "test-tiny",
    },
    config={
        "tests": {
            "defaults": {
                "min_pass_rate": 0.5,
            },
            "clinical": {
                "medfuzz": {
                    "min_pass_rate": 0.1,
                    "attacker_llm": {
                        "model": "gpt-4o-mini",
                        "hub": "openai",
                        "type": "chat",
                    },                   
                }
            }
        }
    }
)
harness.generate().run().report()

image

image

@chakravarthik27 chakravarthik27 self-assigned this Mar 25, 2025
@chakravarthik27 chakravarthik27 requested a review from Copilot March 25, 2025 15:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements fuzz tests for robustness by introducing the MedFuzz feature. Key changes include:

  • Refactoring CSV loading in utils.py to download remote files.
  • Creating new LLM interaction classes (TargetLLM, AttackerLLM) and a MedFuzz class in clinical.py for processing clinical samples.
  • Extending sample data types with HTML highlighting to display differences for MedFuzz samples.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
langtest/transform/utils.py Refactored load_csv to download files; added TargetLLM and AttackerLLM classes.
langtest/transform/clinical.py Introduced MedFuzz class and integrated LLM interactions for fuzz testing.
langtest/utils/custom_types/helpers.py Added highlight_differences_both function for generating HTML diff highlights.
langtest/utils/custom_types/sample.py Added MedFuzzSample subclass that overrides to_dict to incorporate HTML diff highlighting.
Comments suppressed due to low confidence (3)

langtest/transform/utils.py:574

  • The new CSV downloading mechanism uses requests.get on the 'filepath' variable assuming it is a URL. Consider validating the input or adding error handling to ensure that non-URL file paths are managed appropriately.
# save the csv file into `~/.langtest/` directory

langtest/transform/utils.py:1052

  • The error message here is unclear. Consider rephrasing it to clearly indicate the unsupported configuration in the LLM client.
raise TypeError("Unsupported hub and model and Only LLM")

langtest/transform/clinical.py:981

  • Slicing the joined expected_results with [:1] might unintentionally truncate the value. Verify that this behavior is intended, or adjust to preserve the full expected result as needed.
med_sample.expected_results = "".join(map(str, med_sample.expected_results))[:1]

@chakravarthik27 chakravarthik27 linked an issue Apr 4, 2025 that may be closed by this pull request
@chakravarthik27 chakravarthik27 merged commit 034d18d into release/2.7.0 Apr 8, 2025
3 checks passed
@chakravarthik27 chakravarthik27 deleted the feature/implement-the-fuzz-tests-in-robustness branch September 11, 2025 11:02
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.

Implement the Fuzz Tests in Robustness

3 participants