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

Training PET on a personalised task #78

Open
xruifan opened this issue Feb 7, 2022 · 1 comment
Open

Training PET on a personalised task #78

xruifan opened this issue Feb 7, 2022 · 1 comment

Comments

@xruifan
Copy link

xruifan commented Feb 7, 2022

Hi, I am trying to train PET on a new task. I have edited custom_task_processor.py and custom_task_pvp.py in /examples for my use. So my question is how could I use them to make the program run them before I call cli.py with --task_name my-task. I have seen people saying copying the classes directly to the respective files but is it a formal way to do that?

Thanks.

@chris-aeviator
Copy link

chris-aeviator commented Feb 17, 2022

I have in the past also copied it into the tasks.py file and approached (yday) to make it better.

When importing the class from the examples dir, rather than adding it directly to tasks.py, I'm facing a circular import error, to be expected, since custom_task_processor.py itself also imports tasks.py. Will share my findings here but also happy if s.o. could just provide a better instruction

Update - posting some git diffs that seem to get me further

--- a/examples/custom_task_processor.py
-from pet.tasks import DataProcessor, PROCESSORS, TASK_HELPERS

-class MyTaskDataProcessor(DataProcessor):
+class MyTaskDataProcessor():

-PROCESSORS[MyTaskDataProcessor.TASK_NAME] = MyTaskDataProcessor
+#  PROCESSORS[MyTaskDataProcessor.TASK_NAME] = MyTaskDataProcessor

++ b/pet/tasks.py
@@ -25,6 +25,7 @@ from typing import List, Dict, Callable
 import log
 from pet import task_helpers
 from pet.utils import InputExample
+from examples.custom_task_processor import MyTaskDataProcessor

 logger = log.get_logger('root')

@@ -782,6 +783,7 @@ PROCESSORS = {
     "record": RecordProcessor,
     "ax-g": AxGProcessor,
     "ax-b": AxBProcessor,
+    "my-task": MyTaskDataProcessor
 }  # type: Dict[str,Callable[[],DataProcessor]]

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

No branches or pull requests

2 participants