Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.6.0 #1184

Merged
merged 75 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
77945d2
chore: update certifi, idna, zipp versions and add extras in poetry.lock
chakravarthik27 Jan 9, 2025
c4c831f
Merge pull request #1162 from JohnSnowLabs/fix/vulnerabilities-and-se…
chakravarthik27 Jan 13, 2025
c79bb3e
feat: add debiasing functionality with initial approach
chakravarthik27 Jan 13, 2025
11fa891
refactor: improve code formatting and readability in debias.py
chakravarthik27 Jan 13, 2025
ad05cc1
feat: enhance debiasing functionality with improved data handling and…
chakravarthik27 Jan 14, 2025
7628f87
feat: enhance DebiasTextProcessing with support for OpenAI and Ollama…
chakravarthik27 Jan 15, 2025
0a67de4
feat: add Ollama package support in poetry.lock and pyproject.toml
chakravarthik27 Jan 15, 2025
02ab09d
refactor: remove commented-out OpenAI client code in interaction_llm …
chakravarthik27 Jan 15, 2025
dfb4440
feat: add ollama-sdk support in poetry.lock
chakravarthik27 Jan 15, 2025
cd32ec8
refactor: rename bias detection classes and update field titles to de…
chakravarthik27 Jan 15, 2025
9de2947
fix: linting issues
chakravarthik27 Jan 15, 2025
a0294a9
refactor: improve formatting of system prompt in DebiasTextProcessing…
chakravarthik27 Jan 16, 2025
13b2615
feat: enhance bias detection response structure and improve debiasing…
chakravarthik27 Jan 16, 2025
46b3714
feat: add standard bias evaluation prompt and improve bias detection …
chakravarthik27 Jan 16, 2025
d93e3e6
feat: add new robustness classes for false confidence, none of the ab…
chakravarthik27 Jan 17, 2025
47d5bf7
fix: correct typos in bias evaluation prompt and update output datase…
chakravarthik27 Jan 17, 2025
c9dbc5e
fix: rename "original text" to "biased_text" in debias_info DataFrame
chakravarthik27 Jan 17, 2025
9a50917
feat: add risk level to bias detection response and update debias_inf…
chakravarthik27 Jan 20, 2025
259ae69
fix: rename "row" to "row_id" in debias_info DataFrame
chakravarthik27 Jan 20, 2025
7bd46d4
feat: enhance model handling with additional info and output schema s…
chakravarthik27 Jan 21, 2025
a011ba0
feat: add output schema support to model initialization and improve m…
chakravarthik27 Jan 21, 2025
6b76e75
feat: enhance QASample result validation to support Custom Output Schema
chakravarthik27 Jan 22, 2025
d82daca
feat: enhance model handler to support dynamic module imports and upd…
chakravarthik27 Jan 24, 2025
e4f8d7e
feat: improve error handling for module imports in PretrainedModelForQA
chakravarthik27 Jan 27, 2025
dcec433
feat: refactor model handling to use unified MODEL_CLASSES structure …
chakravarthik27 Jan 27, 2025
8ebaf6a
feat: extend output schema support in PretrainedModelForQA to include…
chakravarthik27 Jan 27, 2025
51dc1bd
feat: enhance bias evaluation prompt with structured categories and t…
chakravarthik27 Jan 27, 2025
b313395
feat: add FCT class for clinical tests with transformation and run me…
chakravarthik27 Jan 29, 2025
f94da73
NOTA test is implemented in clincial category.
chakravarthik27 Jan 30, 2025
add3d53
refactor: update FCT and NOTA transform methods to improve options ha…
chakravarthik27 Feb 3, 2025
9daebd2
Merge pull request #1164 from JohnSnowLabs/feature/data-augmentation-…
chakravarthik27 Feb 6, 2025
bbfa984
refactor: improve sample transformation in FCT and remove unused robu…
chakravarthik27 Feb 6, 2025
95d0733
feat: add FQT class for clinical tests with transformation and run me…
chakravarthik27 Feb 7, 2025
33db450
feat: add progress bars for bias detection and debiasing processes
chakravarthik27 Feb 9, 2025
e691ee7
change pronouns-> gender-specific bias
ArshaanNazir Feb 10, 2025
2a680ba
add is_pronoun field
ArshaanNazir Feb 10, 2025
2349aa7
updated: is_pronoun conditions moved to detect_bias.
chakravarthik27 Feb 10, 2025
0e66d4c
chore: update openai package to version 1.61.1 and adjust Python vers…
chakravarthik27 Feb 11, 2025
b22bc45
fix: add error handling in debiasing process and improve regex for ge…
chakravarthik27 Feb 11, 2025
f10cbb6
feat: add support for question answering model in JSL model handler
chakravarthik27 Feb 13, 2025
81f69bf
feat: add support for summarization and text generation models in JSL…
chakravarthik27 Feb 14, 2025
ccda1d4
updated: add ExtractiveSummarization support to JSL model handler
chakravarthik27 Feb 14, 2025
d6a108e
Merge pull request #1172 from JohnSnowLabs/feature/data-augmentation-…
chakravarthik27 Feb 18, 2025
2ed0335
Merge branch 'release/2.6.0' of https://github.com/JohnSnowLabs/langt…
chakravarthik27 Feb 18, 2025
213732d
fix: enhance output processing to handle <think> tags in LLM response…
chakravarthik27 Feb 18, 2025
424632d
Merge pull request #1168 from JohnSnowLabs/feature/modelapi-json-sche…
chakravarthik27 Feb 18, 2025
e354f91
Merge pull request #1174 from JohnSnowLabs/update/supports-the-qa-tas…
chakravarthik27 Feb 18, 2025
b280aa0
Merge branch 'release/2.6.0' of https://github.com/JohnSnowLabs/langt…
chakravarthik27 Feb 18, 2025
8841252
fix: improve output handling to support string responses in LLM model…
chakravarthik27 Feb 18, 2025
0cac1c5
fix: enhance model type handling in QA and TextGen processing
chakravarthik27 Feb 21, 2025
54bc5b9
refactor: update model handling in OpenAI and AzureOpenAI configurations
chakravarthik27 Feb 25, 2025
77129e4
Merge pull request #1178 from JohnSnowLabs/fix/error-in-templatic-aug…
chakravarthik27 Feb 25, 2025
82a8b6e
feat: add support for generating templates using Ollama provider
chakravarthik27 Feb 25, 2025
c6c3604
fix: improve error handling in template generation and update default…
chakravarthik27 Feb 25, 2025
bdba91e
fix: enhance error messaging in template generation and update docume…
chakravarthik27 Feb 26, 2025
36472dd
Merge pull request #1176 from JohnSnowLabs/feature/add-integration-to…
chakravarthik27 Feb 26, 2025
9365ace
Merge pull request #1170 from JohnSnowLabs/feature/implement-med-halt…
chakravarthik27 Feb 26, 2025
4be9c0e
Merge pull request #1180 from JohnSnowLabs/feature/templatic-augmenta…
chakravarthik27 Feb 26, 2025
6d77f1e
fix: handle potential None value in additional_info during model para…
chakravarthik27 Feb 27, 2025
e8a036d
fix: return None for unsupported model types in text generation check
chakravarthik27 Feb 28, 2025
e1bfb01
fix: correctly assign model_type and annotator in QA model initializa…
chakravarthik27 Feb 28, 2025
690d270
Default model_type for OpenAI and Azure-OpenAI to ensure backward com…
chakravarthik27 Mar 3, 2025
105150e
fix: update conditional check for model_type in PretrainedModelForQA
chakravarthik27 Mar 3, 2025
2fb3969
Merge pull request #1182 from JohnSnowLabs/fix/issues-found-while-tes…
chakravarthik27 Mar 3, 2025
9109db2
fix: improve handling of additional model parameters in Harness class
chakravarthik27 Mar 4, 2025
be442eb
fix: add handling for additional model information in Harness class
chakravarthik27 Mar 4, 2025
d39e8bf
Notebook: evaluation with structured outputs
chakravarthik27 Mar 5, 2025
2b8dfb0
feat: add enhance_text method for debiasing text based on bias tolera…
chakravarthik27 Mar 5, 2025
5843350
fix: format enhance_text method for improved readability
chakravarthik27 Mar 5, 2025
4aeaf7c
fix: update langchain-openai to 0.3.7 and update the fqt and nota tests.
chakravarthik27 Mar 7, 2025
8c369bd
Notebook: Added for Med Halt Tests
chakravarthik27 Mar 7, 2025
6f3ea4c
Notebook: JSL Medical LLM QA and Sum
chakravarthik27 Mar 7, 2025
817b917
Merge pull request #1183 from JohnSnowLabs/fix/issues-found-while-tes…
chakravarthik27 Mar 7, 2025
41e9dc7
chore: update version to 2.6.0 and enhance tutorial documentation wit…
chakravarthik27 Mar 10, 2025
05e51d6
Merge pull request #1185 from JohnSnowLabs/chore/final_website_updates
chakravarthik27 Mar 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,940 changes: 1,940 additions & 0 deletions demo/tutorials/llm_notebooks/Med_Halt_Tests.ipynb

Large diffs are not rendered by default.

1,455 changes: 1,455 additions & 0 deletions demo/tutorials/llm_notebooks/dataset-notebooks/JSL_Medical_LLM.ipynb

Large diffs are not rendered by default.

683 changes: 683 additions & 0 deletions demo/tutorials/misc/Dataset_Debiasing.ipynb

Large diffs are not rendered by default.

674 changes: 674 additions & 0 deletions demo/tutorials/misc/Evaluation_with_Structured_Outputs.ipynb

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions langtest/augmentation/debias.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,16 @@ def get_ollama(
return output_schema.model_validate_json(
response.get("message", {}).get("content")
)

def enhance_text(
self, text: str, bias_tolerance_level: Literal[1, 2, 3, 4, 5] = 2
) -> str:
"""Enhance the text by debiasing it."""
category, sub_category, rationale, rating, steps = self.detect_bias(text)
if rating and rating >= bias_tolerance_level:
debiased_text = self.debias_text(
text, category, sub_category, rationale, steps
)
else:
debiased_text = ""
return debiased_text
27 changes: 21 additions & 6 deletions langtest/langtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def __init__(
self.hub = hub
self._actual_model = model
else:
additional_info = {}
hub = None
model_type = None

Expand Down Expand Up @@ -215,26 +216,40 @@ def __init__(
if self.__prompt_config:
self.prompt_manager = PromptManager.from_prompt_configs(self.__prompt_config)

# additional model info
additional_info = {
**(additional_info or {}),
**self._config.get("model_parameters", {}),
}

# model section
if isinstance(model, list):
model_dict = {}
for i in model:
model = i["model"]
hub = i["hub"]

# additional info for each model
additional_info = (
{k: v for k, v in i.items() if k not in {"hub", "model", "type"}}
if i
else {}
)

# get config from model_parameters
model_params = self._config.get("model_parameters", {})
if isinstance(model_params, dict) and model in model_params:
# additional info for each model
additional_info = {**model_params[model], **additional_info}
else:
# same additional info for all models
additional_info = {**additional_info, **model_params}

model_dict[model] = self.task.model(
model, hub, model_type, **additional_info
)

self.model = model_dict

else:
additional_info = {
**(additional_info or {}),
**self._config.get("model_parameters", {}),
}
self.model = self.task.model(model, hub, model_type, **additional_info)
# end model selection
formatted_config = json.dumps(self._config, indent=1)
Expand Down
20 changes: 18 additions & 2 deletions langtest/transform/clinical.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ def __drug_swap(self, result: str, text: str) -> str:
class FCT(BaseClincial):
"""
FCT class for the clinical tests
False Confidence Test
"""

alias_name = "fct"
Expand Down Expand Up @@ -697,6 +698,7 @@ def transform(sample_list: List[Sample], *args, **kwargs):
):
# split by any letter. or number. or ) by re
options = re.sub(rf"{true_answer[3:]}", "None of the above", options)

elif (
true_answer in options
and isinstance(options, list)
Expand All @@ -708,7 +710,16 @@ def transform(sample_list: List[Sample], *args, **kwargs):
]
sample.options = options

sample.expected_results = "None of the above"
# extract the [*]. from the true answer one character and .
option_pos = re.search(r"\b(?:[A-Za-z]|[0-9]|[IVXLCDM]+)[\.\)]", true_answer)
option_pos.end()
if option_pos:
option_pos = option_pos.end()
expected_results = f"{true_answer[:option_pos]} None of the above"
else:
expected_results = "None of the above"

sample.expected_results = expected_results
sample.perturbed_context = ""
sample.perturbed_question = ""
transformed_samples.append(sample)
Expand Down Expand Up @@ -759,6 +770,7 @@ def transform(sample_list: List[Sample], *args, **kwargs):

for sample in sample_list:
sample.category = "clinical"
sample.test_type = "fqt"
if (
sample.original_question is None
or sample.original_context is None
Expand All @@ -767,8 +779,12 @@ def transform(sample_list: List[Sample], *args, **kwargs):
continue
if isinstance(sample, QASample):
selected = random.choice(questions)
if selected == sample.original_question:
selected = random.choice(questions)
sample.original_question = selected
sample.expected_results = "None of the above"
sample.expected_results = kwargs.get(
"expected_results", "None of the above"
)
sample.perturbed_context = ""
sample.perturbed_question = ""

Expand Down
18 changes: 9 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ matplotlib = {version = "^3.7.2", optional = true}
tenacity = {version = "^8.2.2", optional = true}
langchain = {version = "^0.3.15", optional = true}
typing-extensions = "^4.10.0"
langchain-openai = {version = "0.2.5", optional = true}
langchain-openai = {version = "^0.3.7", optional = true}
boto3 = {version = "^1.34.93", optional = true}
importlib-resources = "^6.4.0"
click = ">=8.1.7"
Expand Down