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

Add support for sequence labeling #2718

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jogonba2
Copy link

@jogonba2 jogonba2 commented Feb 20, 2025

This PR adds support for sequence labeling tasks: chunking through IOB scheme and tagging. This is something mentioned in #1675, and could be useful for the community.

The main issue is that there is no widespread agreement about how to prompt language models to perform these tasks. In an attempt of standardizing all those, it seems that just wrapping chunks/words with <>-delimited tags is a common choice in the literature (some references at the end). That is how the code of this PR handles sequence labeling. Basically, a dataset should be prepared accordingly, out of lm-evaluation-harness, to contain input texts and in-text annotated outputs, like this:

Input text: Moncada is a city near Valencia in Spain
Output text: <response> <location> Moncada </location> is a city near <location> Valencia </location> in <location> Spain </location> </response>

Then the language model is prompted to write an output text given the input text and few-shot examples to elicit the expected format. From the outputs, the IOB/tagging labels are extracted to run seqeval and get metrics for sequence labeling evaluation (currently just overall_f1).

I created a guide in docs/sequence_labeling.md to illustrate how to prepare the datasets (moving from IOB/tagging annotation format to in-text annotated outputs) and how to create new sequence labeling tasks, all the details are there.

References about prompting for sequence labeling:

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.

1 participant