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

changed doc_text into contents in related files #663

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 7 additions & 6 deletions transforms/universal/hap/python/output/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"job name": "hap",
"job type": "pure python",
"job id": "job_id",
"start_time": "2024-09-25 00:47:58",
"end_time": "2024-09-25 00:48:06",
"start_time": "2024-10-03 21:38:20",
"end_time": "2024-10-03 21:38:29",
"status": "success"
},
"code": {
Expand All @@ -17,7 +17,7 @@
"job_input_params": {
"model_name_or_path": "ibm-granite/granite-guardian-hap-38m",
"annotation_column": "hap_score",
"doc_text_column": "doc_text",
"doc_text_column": "contents",
"inference_engine": "CPU",
"max_length": 512,
"batch_size": 128,
Expand All @@ -30,11 +30,12 @@
"num_processors": 0
},
"job_output_stats": {
"source_files": 1,
"source_size": 109303,
"source_files": 2,
"source_size": 12124594,
"transform execution exception": 1,
"result_files": 1,
"result_size": 79822,
"processing_time": 6.543,
"processing_time": 6.932,
"source_doc_count": 50,
"result_doc_count": 50
},
Expand Down
Binary file modified transforms/universal/hap/python/output/test1.parquet
Binary file not shown.
2 changes: 1 addition & 1 deletion transforms/universal/hap/python/src/hap_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
hap_params = {
"model_name_or_path": 'ibm-granite/granite-guardian-hap-38m',
"annotation_column": "hap_score",
"doc_text_column": "doc_text",
"doc_text_column": "contents",
"inference_engine": "CPU",
"max_length": 512,
"batch_size": 128,
Expand Down
2 changes: 1 addition & 1 deletion transforms/universal/hap/python/src/hap_local_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
hap_params = {
"model_name_or_path": 'ibm-granite/granite-guardian-hap-38m',
"annotation_column": "hap_score",
"doc_text_column": "doc_text",
"doc_text_column": "contents",
"inference_engine": "CPU",
"max_length": 512,
"batch_size": 128,
Expand Down
12 changes: 6 additions & 6 deletions transforms/universal/hap/python/src/hap_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class HAPTransform(AbstractTableTransform):

def __init__(self, config: dict[str, Any]):
super().__init__(config)
self.model_name_or_path = config.get("model_name_or_path")
self.annotation_column = config.get("annotation_column")
self.doc_text_column = config.get("doc_text_column")
self.max_length = config.get("max_length")
self.batch_size = config.get("batch_size")
self.model_name_or_path = config.get("model_name_or_path", "ibm-granite/granite-guardian-hap-38m")
self.annotation_column = config.get("annotation_column", "hap_score")
self.doc_text_column = config.get("doc_text_column", "contents")
self.max_length = config.get("max_length", 512)
self.batch_size = config.get("batch_size", 128)
self.tokenizer = AutoTokenizer.from_pretrained(self.model_name_or_path)
self.model = AutoModelForSequenceClassification.from_pretrained(self.model_name_or_path)

Expand Down Expand Up @@ -70,7 +70,7 @@ def transform(self, table: pa.Table, file_name: str = None) -> tuple[list[pa.Tab
:param table: Pyarrow table
:return: a table with an additional hap_score column
"""
# make sure that the table contains "doc_text" column
# make sure that the table contains "contents" column
TransformUtils.validate_columns(table=table, required=[self.doc_text_column])
self.df = table.to_pandas()
df_doc_list = []
Expand Down
13 changes: 7 additions & 6 deletions transforms/universal/hap/python/test-data/expected/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"job name": "hap",
"job type": "pure python",
"job id": "job_id",
"start_time": "2024-09-26 20:56:49",
"end_time": "2024-09-26 20:56:56",
"start_time": "2024-10-03 21:38:20",
"end_time": "2024-10-03 21:38:29",
"status": "success"
},
"code": {
Expand All @@ -17,7 +17,7 @@
"job_input_params": {
"model_name_or_path": "ibm-granite/granite-guardian-hap-38m",
"annotation_column": "hap_score",
"doc_text_column": "doc_text",
"doc_text_column": "contents",
"inference_engine": "CPU",
"max_length": 512,
"batch_size": 128,
Expand All @@ -30,11 +30,12 @@
"num_processors": 0
},
"job_output_stats": {
"source_files": 1,
"source_size": 109303,
"source_files": 2,
"source_size": 12124594,
"transform execution exception": 1,
"result_files": 1,
"result_size": 79822,
"processing_time": 6.501,
"processing_time": 6.932,
"source_doc_count": 50,
"result_doc_count": 50
},
Expand Down
Binary file modified transforms/universal/hap/python/test-data/expected/test1.parquet
Binary file not shown.
Binary file modified transforms/universal/hap/python/test-data/input/test1.parquet
Binary file not shown.
2 changes: 1 addition & 1 deletion transforms/universal/hap/python/test/test_hap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
hap_params = {
"model_name_or_path": 'ibm-granite/granite-guardian-hap-38m',
"annotation_column": "hap_score",
"doc_text_column": "doc_text",
"doc_text_column": "contents",
"inference_engine": "CPU",
"max_length": 512,
"batch_size": 128,
Expand Down