What is Slot Filling
Slot Filling is the task to extract specific pieces of information (slots) from a sentence. For instance, given the sentence
I want to fly from Boston at 8:38 am and arrive in Denver at 11:10 in the morning
and the slots departure_city, arrival_city, departure_time and arrival_time, a Slot Filling model would return the following output
{
"departure_city": "Boston",
"departure_time": "8:38 am",
"arrival_city": "Denver",
"arrival_time": "11:10 am"
}
What needs to be done
Implement a Slot Filling model that exposes the following public methods:
.train() method:
.train(slots: list[str], output_path: Optional[str] = None, num_samples: int = config.DEFAULT_SYNTHEX_DATAPOINT_NUM, num_epochs: int = 3)`
where the slots argument accepts a list of strings with the following constraints:
- Maximum 20 characters
- No spaces
The method should then train the model to identify the provided slots in any kind of sentence. The BaseModel._generate_synthetic_data() method should be used to generate synthetic training data.
.__call__(text: Union[str, list[str])
-
If a str is provided, the model should
- Extract the slots it was trained for from the string
- Return a dictionary, where the keys are the slot names and the values are the extracted pieces of text. If a given slot is not found in the string, its value in the dictionary should be
None.
-
If a list[str] is provided, the model should return a list of dictionaries, one per sentence.
.load(model_path: str)
Loads a pre-trained Slot Filling model from the specified path.
What is Slot Filling
Slot Filling is the task to extract specific pieces of information (slots) from a sentence. For instance, given the sentence
and the slots
departure_city,arrival_city,departure_timeandarrival_time, a Slot Filling model would return the following output{ "departure_city": "Boston", "departure_time": "8:38 am", "arrival_city": "Denver", "arrival_time": "11:10 am" }What needs to be done
Implement a Slot Filling model that exposes the following public methods:
.train()method:where the
slotsargument accepts a list of strings with the following constraints:The method should then train the model to identify the provided slots in any kind of sentence. The
BaseModel._generate_synthetic_data()method should be used to generate synthetic training data..__call__(text: Union[str, list[str])If a
stris provided, the model shouldNone.If a
list[str]is provided, the model should return a list of dictionaries, one per sentence..load(model_path: str)Loads a pre-trained Slot Filling model from the specified path.