Skip to content

Commit

Permalink
Make NLP tasks available from AutoML.fit() (microsoft#210)
Browse files Browse the repository at this point in the history
Sequence classification and regression: "seq-classification" and "seq-regression"

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
  • Loading branch information
liususan091219 and sonichi authored Nov 16, 2021
1 parent 59083fb commit 42de307
Show file tree
Hide file tree
Showing 31 changed files with 2,613 additions and 432 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Project
# Project
/.vs
.vscode

Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,36 @@ automl.fit(
)
```

* Fine tuning language model

```python
from flaml import AutoML
from datasets import load_dataset

train_dataset = load_dataset("glue", "mrpc", split="train").to_pandas()
dev_dataset = load_dataset("glue", "mrpc", split="validation").to_pandas()
test_dataset = load_dataset("glue", "mrpc", split="test").to_pandas()

custom_sent_keys = ["sentence1", "sentence2"]
label_key = "label"

X_train, y_train = train_dataset[custom_sent_keys], train_dataset[label_key]
X_val, y_val = dev_dataset[custom_sent_keys], dev_dataset[label_key]
X_test = test_dataset[custom_sent_keys]

automl = AutoML()
automl_settings = {
"max_iter": 3,
"time_budget": 100,
"model_history": True,
"task": "seq-classification"
}
automl_settings["custom_hpo_args"] = {
"output_dir": "data/output/",
}
automl.fit(X_train=X_train, y_train=y_train, X_val=X_val, y_val=y_val, **automl_settings)
```

More examples can be found in [notebooks](https://github.com/microsoft/FLAML/tree/main/notebook/).

## Documentation
Expand Down
5 changes: 5 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ Online AutoML
.. autoclass:: flaml.AutoVW
:members:

NLP
---

.. autoclass:: flaml.nlp.HPOArgs
:members:

.. Indices and tables
.. ==================
Expand Down
Loading

0 comments on commit 42de307

Please sign in to comment.