You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5b0b768
Browse filesBrowse the repository at this point in the historyBrowse files
docs: add Tinker fine-tuning section to README and deduplicate poem example
- Add Fine-Tuning with Tinker section covering basic usage, checkpoint
resume, and custom data formats
- Add poem fine-tuning example to the examples table
- Replace inline duplicate in poem example with call to convert_to_chat_format()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,7 @@ pip install bespokelabs-curator
61
61
|**Product feature extraction**| <atarget="_blank"href="https://colab.research.google.com/drive/1YoA23-cBcWpaSErULzBI2bo2LPGo37GQ"><imgsrc="https://colab.research.google.com/assets/colab-badge.svg"alt="Open In Colab"/></a> | Finetuning a model to identify features of a product |
62
62
|**Sentiment analysis**| <ahref="https://colab.research.google.com/drive/1Zfl3g7POsqqYQqkzXdyhYRSAymLhZugn?usp=sharing"target="_blank"><imgsrc="https://colab.research.google.com/assets/colab-badge.svg"alt="Open In Colab"/></a> | Aspect-based sentiment analysis of restaurant reviews and finetuning using Together.ai |
63
63
|**RAFT for domain-specific RAG**| <ahref="https://github.com/bespokelabsai/curator/tree/main/examples/blocks/raft"target="_blank">Code</a> | Implement Retrieval Augmented Fine-Tuning (RAFT) that processes domain-specific documents, generates questions, and prepares data for fine-tuning LLMs. |
64
+
|**Poem generation & LoRA fine-tuning**| <ahref="https://github.com/bespokelabsai/curator/blob/main/examples/poem_finetuning_example.py"target="_blank">Code</a> | End-to-end pipeline: curate poem data with Curator, then LoRA fine-tune with TinkerTrainer |
Curator integrates with the [Tinker SDK](https://github.com/thinking-machines-lab/tinker-cookbook) so you can go from curated data to a LoRA fine-tuned model in a few lines of Python.
302
+
303
+
```bash
304
+
pip install bespokelabs-curator tinker
305
+
export TINKER_API_KEY="your-tinker-key"
306
+
```
307
+
308
+
```python
309
+
from bespokelabs.curator import TinkerTrainer, TinkerTrainerConfig
# Training data is a list of chat-format dicts (or a HuggingFace Dataset)
321
+
training_data = [
322
+
{"messages": [
323
+
{"role": "user", "content": "What is Python?"},
324
+
{"role": "assistant", "content": "Python is a programming language."},
325
+
]},
326
+
# ...
327
+
]
328
+
329
+
# Train
330
+
trainer = TinkerTrainer(config)
331
+
result = trainer.train(training_data)
332
+
print(f"Final loss: {result.final_loss:.4f}")
333
+
334
+
# Sample from the fine-tuned model
335
+
response = trainer.sample("Explain recursion in Python")
336
+
print(response)
337
+
```
338
+
339
+
### Checkpoint Resume
340
+
341
+
Training can be resumed from any saved checkpoint. The trainer restores both model weights and optimizer state, then continues from where it left off — no data is replayed.
342
+
343
+
```python
344
+
# Resume from an earlier run's checkpoint
345
+
checkpoints = result.checkpoints # list of CheckpointInfo
346
+
trainer = TinkerTrainer(config)
347
+
trainer.load_checkpoint(checkpoints[-1])
348
+
result = trainer.train(training_data) # continues from the checkpoint
349
+
```
350
+
351
+
### Custom Data Formats
352
+
353
+
Subclass `TinkerTrainer` to handle non-standard data layouts:
354
+
355
+
```python
356
+
classMyTrainer(TinkerTrainer):
357
+
defformat_example(self, row):
358
+
return TrainingExample.from_dict_messages([
359
+
{"role": "user", "content": row["question"]},
360
+
{"role": "assistant", "content": row["answer"]},
361
+
])
362
+
363
+
trainer = MyTrainer(config)
364
+
result = trainer.train([{"question": "What is 2+2?", "answer": "4"}, ...])
365
+
```
366
+
367
+
See the full [poem fine-tuning example](examples/poem_finetuning_example.py) for an end-to-end pipeline that curates data with `curator.LLM` and then fine-tunes with `TinkerTrainer`.
368
+
298
369
## Bespoke Curator Viewer
299
370
The hosted curator viewer is a rich interface to visualize data -- and makes visually inspecting the data much easier.
0 commit comments