Skip to content

Commit

Permalink
Support few shot for large label taxonomy (#917)
Browse files Browse the repository at this point in the history
Support few shot for attribute extraction
  • Loading branch information
rajasbansal authored Oct 14, 2024
1 parent c03b05c commit 447b799
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/autolabel/tasks/attribute_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ def construct_prompt(
) -> Tuple[str, str]:
fmt_task_guidelines = self.task_guidelines

# add additional labels to the selected_labels_map for attributes
# if they are present in the few shot examples
if self._is_few_shot_mode() and selected_labels_map:
for eg in examples:
for attribute_name in selected_labels_map:
if (
attribute_name in eg
and eg.get(attribute_name)
and eg.get(attribute_name)
not in selected_labels_map[attribute_name]
):
selected_labels_map[attribute_name].append(
eg.get(attribute_name)
)

attribute_json, output_schema = self._construct_attribute_json(
selected_labels_map=selected_labels_map
)
Expand Down

0 comments on commit 447b799

Please sign in to comment.