Skip to content

Commit 1cea119

Browse files
authored
Merge pull request #321 from stochasticai/issue-135-simplify-notebook-examples
Simplify notebook examples with task-based workflows
2 parents 468fe60 + 6b3135a commit 1cea119

17 files changed

Lines changed: 277 additions & 95 deletions

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,11 @@ Playground().launch() ## launches localhost UI
210210

211211
## 📚 Tutorials
212212
- [Preparing your dataset](examples/datasets/preparing_your_dataset.py)
213-
- [Cerebras-GPT fine-tuning with LoRA and INT8](examples/models/cerebras/cerebras_lora_int8.ipynb)   [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1eKq3oF7dnK8KuIfsTE70Gvvniwr1O9D0?usp=sharing)
214-
- [Cerebras-GPT fine-tuning with LoRA](examples/models/cerebras/cerebras_lora.ipynb)   [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1VjqQhstm5pT4EjPjx4Je7b3W2X1V3vDo?usp=sharing)
215-
- [LLaMA fine-tuning with LoRA and INT8](examples/models/llama/llama_lora_int8.py)   [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1SQUXq1AMZPSLD4mk3A3swUIc6Y2dclme?usp=sharing)
216-
- [LLaMA fine-tuning with LoRA](examples/models/llama/llama_lora.py)
217-
- [LLaMA fine-tuning](examples/models/llama/llama.py)
218-
- [GPT-J fine-tuning with LoRA and INT8](examples/models/gptj/gptj_lora_int8.py)   [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hB_8s1V9K4IzifmlmN2AovGEJzTB1c7e?usp=sharing)
219-
- [GPT-J fine-tuning with LoRA](examples/models/gptj/gptj_lora.py)
220-
- [GPT-2 fine-tuning with LoRA](examples/models/gpt2/gpt2_lora.py)   [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://drive.google.com/file/d/1Sh-ocNpKn9pS7jv6oBb_Q8DitFyj1avL/view?usp=sharing)
213+
- [Task notebook: fine-tune with LoRA](examples/notebooks/finetune_lora.ipynb)
214+
- [Task notebook: fine-tune with LoRA + INT8](examples/notebooks/finetune_lora_int8.ipynb)
215+
- [Task notebook: evaluate model perplexity](examples/notebooks/evaluate_perplexity.ipynb)
216+
- [Qwen3 LoRA runnable script](examples/models/qwen3/qwen3_lora_finetune.py)
217+
- [Model key and variant reference](https://xturing.stochastic.ai/overview/supported_models)
221218

222219
<br>
223220

docs/docs/overview/intro.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,17 @@ So, if you're ready to add a personal touch to AI, welcome to xTuring. It's a jo
4949

5050
To get started with xTuring, check out the [Quickstart](/overview/quickstart) guide or try some of the examples below.
5151

52-
## Model examples
53-
54-
| Model | Examples |
55-
| --- | --- |
56-
| Bloom | [Bloom fine-tuning on Alpaca dataset with/without LoRA and with/without INT8](https://github.com/stochasticai/xturing/tree/main/examples/models/bloom) |
57-
| Cerebras-GPT | [Cerebras-GPT fine-tuning on Alpaca dataset with/without LoRA and with/without INT8](https://github.com/stochasticai/xturing/tree/main/examples/models/cerebras) |
58-
| Falcon | [Falcon 7B fine-tuning on Alpaca dataset with/without LoRA and with/without INT8](https://github.com/stochasticai/xturing/tree/main/examples/models/falcon) |
59-
| Galactica | [Galactica fine-tuning on Alpaca dataset with/without LoRA and with/without INT8](https://github.com/stochasticai/xturing/tree/main/examples/models/galactica) |
60-
| Generic Wrapper | [Any large language model fine-tuning on Alpaca dataset with/without LoRA and with/without INT8](https://github.com/stochasticai/xturing/tree/main/examples/models/generic) |
61-
| GPT-J | [GPT-J 6B LoRA fine-tuning with/without INT8 ](https://github.com/stochasticai/xturing/tree/main/examples/models/gptj) |
62-
| GPT-2 | [GPT-2 fine-tuning on Alpaca dataset with/without LoRA and with/without INT8](https://github.com/stochasticai/xturing/tree/main/examples/models/gpt2) |
63-
| LLaMA | [LLaMA 7B fine-tuning on Alpaca dataset with/without LoRA and with/without INT8](https://github.com/stochasticai/xturing/tree/main/examples/models/llama) |
64-
| LLaMA 2 | [LLaMA 2 7B fine-tuning on Alpaca dataset with/without LoRA and with/without INT8](https://github.com/stochasticai/xturing/tree/main/examples/models/llama2) |
65-
| OPT | [OPT fine-tuning on Alpaca dataset with/without LoRA and with/without INT8](https://github.com/stochasticai/xturing/tree/main/examples/models/opt) |
52+
## Example notebooks
53+
54+
Examples are organized by task, not by model family. Start with one of these:
55+
56+
| Task | Notebook |
57+
| --- | --- |
58+
| Fine-tune with LoRA | [examples/notebooks/finetune_lora.ipynb](https://github.com/stochasticai/xturing/blob/main/examples/notebooks/finetune_lora.ipynb) |
59+
| Fine-tune with LoRA + INT8 | [examples/notebooks/finetune_lora_int8.ipynb](https://github.com/stochasticai/xturing/blob/main/examples/notebooks/finetune_lora_int8.ipynb) |
60+
| Evaluate perplexity | [examples/notebooks/evaluate_perplexity.ipynb](https://github.com/stochasticai/xturing/blob/main/examples/notebooks/evaluate_perplexity.ipynb) |
61+
62+
For model options and naming variants, see [Supported models and variants](/overview/supported_models).
6663

6764
xTuring is licensed under [Apache 2.0](https://github.com/stochasticai/xturing/blob/main/LICENSE)
6865

docs/docs/overview/quickstart/finetune_guide.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ Start by loading the instruction dataset and initializing the model of your choi
4242

4343
<Test instruction={'Instruction'}/>
4444

45-
A list of all the supported models can be found [here](/overview/supported_models).
45+
A list of all model keys and variant templates can be found [here](/overview/supported_models).
46+
47+
If you prefer notebooks, start from the task-based examples:
48+
- `examples/notebooks/finetune_lora.ipynb`
49+
- `examples/notebooks/finetune_lora_int8.ipynb`
4650

4751

4852

docs/docs/overview/supported_models.md

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,48 @@
11
---
22
sidebar_position: 4
3-
title: 🦾 Supported models
4-
description: Models Supported by xTuring
3+
title: 🦾 Supported models and variants
4+
description: Choose model keys and variant templates for task-based notebooks
55
---
66

7-
<!-- # Models supported by xTuring -->
8-
## Base versions
9-
| Model | Model Key | LoRA | INT8 | LoRA + INT8 | LoRA + INT4 |
10-
| ------ | --- | :---: | :---: | :---: | :---: |
11-
| BLOOM 1.1B| bloom |||||
12-
| Cerebras 1.3B| cerebras |||||
13-
| DistilGPT-2 | distilgpt2 |||||
14-
| Falcon 7B | falcon |||||
15-
| Galactica 6.7B| galactica |||||
16-
| GPT-J 6B | gptj |||||
17-
| GPT-2 | gpt2 |||||
18-
| LLaMA 7B | llama |||||
19-
| LLaMA2 | llama2 |||||
20-
| MiniMaxM2 | minimax_m2 |||||
21-
| Qwen3 0.6B | qwen3_0_6b |||||
22-
| OPT 1.3B | opt |||||
23-
24-
### Memory-efficient versions
25-
> The above mentioned are the base variants of the LLMs. Below are the templates to get their `LoRA`, `INT8`, `INT8 + LoRA` and `INT4 + LoRA` versions.
26-
27-
| Version | Template |
28-
| -- | -- |
29-
| LoRA | <model_key>_lora|
30-
| INT8 | <model_key>_int8|
31-
| INT8 + LoRA | <model_key>_lora_int8|
32-
33-
### INT4 Precision model versions
34-
> In order to load any model's __`INT4+LoRA`__ version, you will need to make use of `GenericLoraKbitModel` class from `xturing.models`. Below is how to use it:
7+
Use one task notebook from `examples/notebooks/`, then choose a model key from this page.
8+
9+
## Naming templates
10+
11+
| Variant | Key template |
12+
| --- | --- |
13+
| Base | `<model_key>` |
14+
| LoRA | `<model_key>_lora` |
15+
| INT8 | `<model_key>_int8` |
16+
| LoRA + INT8 | `<model_key>_lora_int8` |
17+
| LoRA + K-bit (INT4 flow) | `<model_key>_lora_kbit` |
18+
19+
## Model keys
20+
21+
| Model | Base key | Available variants |
22+
| --- | --- | --- |
23+
| BLOOM 1.1B | `bloom` | `base`, `lora`, `int8`, `lora_int8` |
24+
| Cerebras 1.3B | `cerebras` | `base`, `lora`, `int8`, `lora_int8` |
25+
| DistilGPT-2 | `distilgpt2` | `base`, `lora` |
26+
| Falcon 7B | `falcon` | `base`, `lora`, `int8`, `lora_int8`, `lora_kbit` |
27+
| Galactica 6.7B | `galactica` | `base`, `lora`, `int8`, `lora_int8` |
28+
| Generic wrapper | `generic` | `base`, `lora`, `int8`, `lora_int8`, `lora_kbit` |
29+
| GPT-J 6B | `gptj` | `base`, `lora`, `int8`, `lora_int8` |
30+
| GPT-2 | `gpt2` | `base`, `lora`, `int8`, `lora_int8` |
31+
| GPT-OSS 20B | `gpt_oss_20b` | `base`, `lora`, `int8`, `lora_int8`, `lora_kbit` |
32+
| GPT-OSS 120B | `gpt_oss_120b` | `base`, `lora`, `int8`, `lora_int8`, `lora_kbit` |
33+
| LLaMA | `llama` | `base`, `lora`, `int8`, `lora_int8`, `lora_kbit` |
34+
| LLaMA 2 | `llama2` | `base`, `lora`, `int8`, `lora_int8`, `lora_kbit` |
35+
| Mamba | `mamba` | `base` |
36+
| MiniMaxM2 | `minimax_m2` | `base`, `lora`, `int8`, `lora_int8`, `lora_kbit` |
37+
| OPT 1.3B | `opt` | `base`, `lora`, `int8`, `lora_int8` |
38+
| Qwen3 0.6B | `qwen3_0_6b` | `base`, `lora`, `int8`, `lora_int8`, `lora_kbit` |
39+
| Stable Diffusion | `stable_diffusion` | `base` |
40+
41+
## INT4-style workflow
42+
43+
For models that expose `*_lora_kbit`, you can still use the generic K-bit API directly:
44+
3545
```python
3646
from xturing.models import GenericLoraKbitModel
37-
model = GenericLoraKbitModel('/path/to/model')
47+
model = GenericLoraKbitModel("/path/to/model")
3848
```
39-
The `/path/to/model` can be replaced with you local directory or any HuggingFace library model like `facebook/opt-1.3b`.

examples/README.md

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,53 @@
1-
# Navigating through examples
2-
Here, is a brief about how to navigate through examples quick and efficiently, and get your hands dirty with `xTuring`.
1+
# Navigating examples
2+
3+
This folder is organized by task first, so you can pick a workflow quickly and then
4+
switch model keys as needed.
35

46
## Directory structure
5-
```
7+
8+
```text
69
examples/
7-
| datasets
10+
| datasets/
811
| features/
9-
| dataset_generation/
10-
| evaluation/
11-
| generic/
12-
| int4_finetuning/
1312
| models/
13+
| notebooks/
1414
| playground_ui/
1515
```
1616

17-
### datsets/
18-
This directory consists of multiple ways to generate your custom dataset from a given set of examples.
17+
## Start here: task-based notebooks
1918

20-
### features/
21-
This directory consists of files with exapmles highlighting speific major features of the library, which can be replicated to any LLM you want.
22-
For example, in `dataset_generation/`, you will find an example on how to generate your custom dataset from a .jsonl file. In `evaluation/`, you will find a specific exapmle on how to evaluate your finetuned model, which can then be extended to any LLM and any dataset.
19+
Use the notebooks in `examples/notebooks/` as the primary entry point:
2320

24-
### models/
25-
This directory consists of examples specific to each model mentioned.
21+
| Notebook | Purpose |
22+
| --- | --- |
23+
| `notebooks/finetune_lora.ipynb` | Fine-tune with LoRA |
24+
| `notebooks/finetune_lora_int8.ipynb` | Fine-tune with LoRA + INT8 |
25+
| `notebooks/evaluate_perplexity.ipynb` | Evaluate with perplexity |
2626

27-
### playground_ui/
28-
This directory consists of an example which demonstrates how you can play around with your LLM through a web interface.
27+
## Model variants
2928

30-
## Models
31-
Below is a list of all the supported models via `BaseModel` class of `xTuring` and their corresponding keys to load them.
29+
Instead of maintaining one notebook per model, use one task notebook and choose a model key.
3230

33-
| Model | Key |
34-
| -- | -- |
35-
|Bloom | bloom|
36-
|Cerebras | cerebras|
37-
|DistilGPT-2 | distilgpt2|
38-
|Falcon-7B | falcon|
39-
|Galactica | galactica|
40-
|GPT-J | gptj|
41-
|GPT-2 | gpt2|
42-
|LlaMA | llama|
43-
|LlaMA2 | llama2|
44-
|OPT-1.3B | opt|
31+
| Version | Template |
32+
| --- | --- |
33+
| Base | `<model_key>` |
34+
| LoRA | `<model_key>_lora` |
35+
| INT8 | `<model_key>_int8` |
36+
| LoRA + INT8 | `<model_key>_lora_int8` |
4537

46-
The above mentioned are the base variants of the LLMs. Below are the templates to get their `LoRA`, `INT8`, `INT8 + LoRA` and `INT4 + LoRA` versions.
38+
For the full model-key list, see `https://xturing.stochastic.ai/overview/supported_models` in the docs.
4739

48-
| Version | Template |
49-
| -- | -- |
50-
| LoRA| <model_key>_lora|
51-
| INT8| <model_key>_int8|
52-
| INT8 + LoRA| <model_key>_lora_int8|
40+
For INT4 + LoRA:
5341

54-
** In order to load any model's __`INT4+LoRA`__ version, you will need to make use of `GenericLoraKbitModel` class from `xturing.models`. Below is how to use it:
5542
```python
56-
model = GenericLoraKbitModel('<model_path>')
43+
from xturing.models import GenericLoraKbitModel
44+
model = GenericLoraKbitModel("<model_path>")
5745
```
58-
The `model_path` can be replaced with you local directory or any HuggingFace library model like `facebook/opt-1.3b`.
46+
47+
`<model_path>` can be a local directory or a Hugging Face model path.
48+
49+
## Legacy model folders
50+
51+
Legacy model-specific notebooks are archived in `examples/legacy/model_notebooks/`.
52+
The `examples/models/` folders remain for scripts and dataset references.
53+
New examples should prefer task-based notebooks and keep model differences in docs.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Archived model-specific notebooks
2+
3+
These notebooks are archived from `examples/models/` as part of issue `#135`.
4+
5+
Use task-based notebooks in `examples/notebooks/` for active workflows.
6+
Keep this folder only for historical reference and migration support.
File renamed without changes.

examples/models/cerebras/cerebras_lora_int8.ipynb renamed to examples/legacy/model_notebooks/cerebras/cerebras_lora_int8.ipynb

File renamed without changes.

examples/models/distilgpt2/distilgpt2_lora.ipynb renamed to examples/legacy/model_notebooks/distilgpt2/distilgpt2_lora.ipynb

File renamed without changes.

examples/models/distilgpt2/distilgpt2_lora_custom_params.ipynb renamed to examples/legacy/model_notebooks/distilgpt2/distilgpt2_lora_custom_params.ipynb

File renamed without changes.

0 commit comments

Comments
 (0)