Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Add HFTrainer documentation

davidmezzettif0eb46b85dca
diff --git a/docs/pipelines/trainer.md b/docs/pipelines/trainer.md
new file mode 100644
index 00000000..03ac7ef7
--- /dev/null
+++ b/docs/pipelines/trainer.md
@@ -0,0 +1,34 @@
+# HFTrainer
+
+Trains a new Hugging Face Transformer model using the Trainer API.
+
+Examples on how to use the trainer below.
+
+```python
+import pandas as pd
+
+from datasets import load_dataset
+
+from txtai.pipeline import HFTrainer
+
+trainer = HFTrainer()
+
+# Pandas DataFrame
+df = pd.read_csv("training.csv")
+model, tokenizer = trainer("bert-base-uncased", df)
+
+# Hugging Face dataset
+ds = load_dataset("glue", "sst2")
+model, tokenizer = trainer("bert-base-uncased", ds["train"])
+
+# List of dicts
+dt = [{"text": "sentence 1", "label": 0}, {"text": "sentence 2", "label": 1}]]
+model, tokenizer = trainer("bert-base-uncased", dt)
+
+# Support additional TrainingArguments
+model, tokenizer = trainer("bert-base-uncased", dt,
+ learning_rate=3e-5, num_train_epochs=5)
+```
+
+::: txtai.pipeline.HFTrainer.__init__
+::: txtai.pipeline.HFTrainer.__call__
diff --git a/mkdocs.yml b/mkdocs.yml
index cc5f8e96..62a24b49 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -40,6 +40,7 @@ nav:
- Similarity: pipelines/similarity.md
- Summary: pipelines/summary.md
- Textractor: pipelines/textractor.md
+ - Trainer: pipelines/trainer.md
- Transcription: pipelines/transcription.md
- Translation: pipelines/translation.md
- Workflows: workflows.md