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

Swappable parsing #242

Merged
merged 70 commits into from
Aug 18, 2023
Merged

Swappable parsing #242

merged 70 commits into from
Aug 18, 2023

Conversation

rmitsch
Copy link
Collaborator

@rmitsch rmitsch commented Aug 3, 2023

Description

Make parsing a swappable, configurable attribute to allow modify parsing behaviour without retiring the entire task class.

Corresponding documentation PR

todo

Types of change

New feature.

Checklist

  • I confirm that I have the right to submit this contribution under the project's MIT license.
  • I ran all tests in tests and usage_examples/tests, and all new and existing tests passed. This includes
    • all external tests (i. e. pytest ran with --external)
    • all tests requiring a GPU (i. e. pytest ran with --gpu)
  • My changes don't require a change to the documentation, or if they do, I've added all required information.

@rmitsch rmitsch added feat/new New feature feat/task Feature: tasks labels Aug 3, 2023
@rmitsch rmitsch self-assigned this Aug 3, 2023
@rmitsch rmitsch changed the base branch from main to develop August 3, 2023 16:41
spacy_llm/tasks/lemma.py Outdated Show resolved Hide resolved
spacy_llm/ty.py Outdated Show resolved Hide resolved
@rmitsch
Copy link
Collaborator Author

rmitsch commented Aug 4, 2023

It might make sense to move each task into their own module and split the actual task implementation from the factory methods and utils (such as the parsing methods). Over time this will become unwieldy otherwise.

@rmitsch
Copy link
Collaborator Author

rmitsch commented Aug 4, 2023

Making parsing swappable is a bit more complicated for tasks inheriting from SpanTask, as there other class methods are invoked. There isn't a strong reason for that though, this setup works fine with moving all parsing-related functions out of the class and registering them (which is what this PR aims for, ultimately).

Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a promising approach to me to allow more flexibility both for users, as well as for our own builtin functionality.

As discussed internally, we'd also need to make the _create_prompt_example functionality swappable.

@svlandeg
Copy link
Member

svlandeg commented Aug 9, 2023

It might make sense to move each task into their own module and split the actual task implementation from the factory methods and utils (such as the parsing methods). Over time this will become unwieldy otherwise.

We can definitely do that, yep.

Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this direction! Leaving some first comments.

spacy_llm/tasks/lemma/registry.py Outdated Show resolved Hide resolved
spacy_llm/tasks/lemma/registry.py Outdated Show resolved Hide resolved
spacy_llm/tasks/lemma/task.py Outdated Show resolved Hide resolved
spacy_llm/tasks/lemma/task.py Outdated Show resolved Hide resolved
spacy_llm/tasks/lemma/task.py Show resolved Hide resolved
spacy_llm/tasks/lemma/task.py Outdated Show resolved Hide resolved
rmitsch and others added 6 commits August 14, 2023 20:27
* Refactor tasks.

* Update spacy_llm/tasks/builtin_task.py

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>

* Update spacy_llm/tasks/builtin_task.py

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>

* Update spacy_llm/tasks/builtin_task.py

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>

* Fix imports.

* Make scorer configurable.

---------

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
# Conflicts:
#	spacy_llm/tasks/rel.py
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
spacy_llm/ty.py Outdated Show resolved Hide resolved
@rmitsch
Copy link
Collaborator Author

rmitsch commented Aug 16, 2023

Ready for a final review round. We should decide whether we want to keep the file structure for tasks as-is - we could also merge parser.py, example.py, scorer.py into a single file?

@rmitsch
Copy link
Collaborator Author

rmitsch commented Aug 16, 2023

scorer currently runs on **kwargs as well - we should update that to a generic protocol in a follow-up PR. Added an internal ticket.

Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good! Left a few final comments & fixes, nothing major.
Feel free to merge afterwards so we can move on to the CoT to put this in practice 🎉

spacy_llm/tasks/builtin_task.py Outdated Show resolved Hide resolved
spacy_llm/tasks/builtin_task.py Outdated Show resolved Hide resolved
spacy_llm/tasks/builtin_task.py Outdated Show resolved Hide resolved
spacy_llm/tasks/builtin_task.py Outdated Show resolved Hide resolved
spacy_llm/tasks/builtin_task.py Outdated Show resolved Hide resolved
spacy_llm/tasks/summarization/parser.py Outdated Show resolved Hide resolved
spacy_llm/tasks/textcat/parser.py Outdated Show resolved Hide resolved
spacy_llm/ty.py Outdated Show resolved Hide resolved
spacy_llm/ty.py Outdated Show resolved Hide resolved
spacy_llm/tasks/builtin_task.py Outdated Show resolved Hide resolved
@svlandeg
Copy link
Member

And maybe to be sure, run the GPU & external tests at the end before merging.

@rmitsch rmitsch added Test external Run external tests Test GPU Run GPU tests labels Aug 17, 2023
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@rmitsch rmitsch merged commit 2572b0f into develop Aug 18, 2023
11 checks passed
@svlandeg svlandeg mentioned this pull request Aug 21, 2023
3 tasks
@svlandeg svlandeg deleted the feat/swappable-parsing branch August 24, 2023 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat/new New feature feat/task Feature: tasks Test external Run external tests Test GPU Run GPU tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants