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

Support few shot for large label taxonomy #917

Merged
merged 1 commit into from
Oct 14, 2024
Merged
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
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
Loading