Skip to content

Commit c614304

Browse files
Merge pull request #242 from stochasticai/dev
Dev
2 parents a2adc9d + d113990 commit c614304

File tree

66 files changed

+444
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+444
-20
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ outputs = model.generate(dataset = dataset, batch_size=10)
9797

9898
```
9999

100-
An exploration of the [Llama LoRA INT4 working example](examples/int4_finetuning/LLaMA_lora_int4.ipynb) is recommended for an understanding of its application.
100+
An exploration of the [Llama LoRA INT4 working example](examples/features/int4_finetuning/LLaMA_lora_int4.ipynb) is recommended for an understanding of its application.
101101

102-
For an extended insight, consider examining the [GenericModel working example](examples/generic/generic_model.py) available in the repository.
102+
For an extended insight, consider examining the [GenericModel working example](examples/features/generic/generic_model.py) available in the repository.
103103

104104
<br>
105105

@@ -111,6 +111,7 @@ pip install xturing
111111
<br>
112112

113113
## 🚀 Quickstart
114+
114115
```python
115116
from xturing.datasets import InstructionDataset
116117
from xturing.models import BaseModel
@@ -130,7 +131,7 @@ output = model.generate(texts=["Why LLM models are becoming so important?"])
130131
print("Generated output by the model: {}".format(output))
131132
```
132133

133-
You can find the data folder [here](examples/llama/alpaca_data).
134+
You can find the data folder [here](examples/models/llama/alpaca_data).
134135

135136
<br>
136137

@@ -164,21 +165,21 @@ Playground().launch() ## launches localhost UI
164165
<br>
165166

166167
## 📚 Tutorials
167-
- [Preparing your dataset](examples/llama/preparing_your_dataset.py)
168-
- [Cerebras-GPT fine-tuning with LoRA and INT8](examples/cerebras/cerebras_lora_int8.ipynb) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1eKq3oF7dnK8KuIfsTE70Gvvniwr1O9D0?usp=sharing)
169-
- [Cerebras-GPT fine-tuning with LoRA](examples/cerebras/cerebras_lora.ipynb) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1VjqQhstm5pT4EjPjx4Je7b3W2X1V3vDo?usp=sharing)
170-
- [LLaMA fine-tuning with LoRA and INT8](examples/llama/llama_lora_int8.py) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1SQUXq1AMZPSLD4mk3A3swUIc6Y2dclme?usp=sharing)
171-
- [LLaMA fine-tuning with LoRA](examples/llama/llama_lora.py)
172-
- [LLaMA fine-tuning](examples/llama/llama.py)
173-
- [GPT-J fine-tuning with LoRA and INT8](examples/gptj/gptj_lora_int8.py) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hB_8s1V9K4IzifmlmN2AovGEJzTB1c7e?usp=sharing)
174-
- [GPT-J fine-tuning with LoRA](examples/gptj/gptj_lora.py)
175-
- [GPT-2 fine-tuning with LoRA](examples/gpt2/gpt2_lora.py) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://drive.google.com/file/d/1Sh-ocNpKn9pS7jv6oBb_Q8DitFyj1avL/view?usp=sharing)
168+
- [Preparing your dataset](examples/datasets/preparing_your_dataset.py)
169+
- [Cerebras-GPT fine-tuning with LoRA and INT8](examples/models/cerebras/cerebras_lora_int8.ipynb) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1eKq3oF7dnK8KuIfsTE70Gvvniwr1O9D0?usp=sharing)
170+
- [Cerebras-GPT fine-tuning with LoRA](examples/models/cerebras/cerebras_lora.ipynb) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1VjqQhstm5pT4EjPjx4Je7b3W2X1V3vDo?usp=sharing)
171+
- [LLaMA fine-tuning with LoRA and INT8](examples/models/llama/llama_lora_int8.py) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1SQUXq1AMZPSLD4mk3A3swUIc6Y2dclme?usp=sharing)
172+
- [LLaMA fine-tuning with LoRA](examples/models/llama/llama_lora.py)
173+
- [LLaMA fine-tuning](examples/models/llama/llama.py)
174+
- [GPT-J fine-tuning with LoRA and INT8](examples/models/gptj/gptj_lora_int8.py) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hB_8s1V9K4IzifmlmN2AovGEJzTB1c7e?usp=sharing)
175+
- [GPT-J fine-tuning with LoRA](examples/models/gptj/gptj_lora.py)
176+
- [GPT-2 fine-tuning with LoRA](examples/models/gpt2/gpt2_lora.py) &ensp; [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://drive.google.com/file/d/1Sh-ocNpKn9pS7jv6oBb_Q8DitFyj1avL/view?usp=sharing)
176177

177178
<br>
178179

179180
## 📊 Performance
180181

181-
Here is a comparison for the performance of different fine-tuning techniques on the LLaMA 7B model. We use the [Alpaca dataset](examples/llama/alpaca_data/) for fine-tuning. The dataset contains 52K instructions.
182+
Here is a comparison for the performance of different fine-tuning techniques on the LLaMA 7B model. We use the [Alpaca dataset](examples/models/llama/alpaca_data/) for fine-tuning. The dataset contains 52K instructions.
182183

183184
Hardware:
184185

docs/docs/finetune/guide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ title: Guide
33
description: Fine-tuning with xTuring
44
sidebar_position: 1
55
---
6-
6+
import Test from './test';
77
# Fine-tuning guide
8+
<Test />
89

910
## 1. Prepare dataset
1011

docs/docs/finetune/test.jsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React, { useState } from 'react'
2+
import clsx from 'clsx'
3+
import styles from './styles.module.css'
4+
import MDXContent from '@theme/MDXContent'
5+
import CodeBlock from '@theme/CodeBlock'
6+
7+
export default function Test() {
8+
const [model, setModel] = useState('LLaMa')
9+
const [version, setVersion] = useState('LLaMa')
10+
11+
console.log(model, version)
12+
13+
return (
14+
<div className={clsx('col')}>
15+
<label htmlFor='model'>Choose a model:</label>
16+
17+
<select
18+
name='model'
19+
id='model'
20+
onChange={(e) => console.log(e.target.value)}
21+
>
22+
<option value='LLaMa'>LLaMa</option>
23+
<option value='GPT-J'>GPT-J</option>
24+
<option value='GPT-3'>GPT-3</option>
25+
<option value='GPT-4'>GPT-4</option>
26+
</select>
27+
28+
<label htmlFor='model-version'>Choose a version:</label>
29+
30+
<select
31+
name='model-version'
32+
id='model-version'
33+
onChange={(e) => console.log(e.target.value)}
34+
>
35+
<option value='v1'>V1</option>
36+
<option value='v2'>V2</option>
37+
<option value='v3'>V3</option>
38+
<option value='v4'>V4</option>
39+
</select>
40+
41+
<CodeBlock
42+
className='row'
43+
showLineNumbers={false}
44+
language='python'
45+
children={`import json from datasets
46+
import Dataset, DatasetDict
47+
48+
alpaca_data = json.load(open(alpaca_dataset_path))
49+
50+
instructions = []
51+
inputs = []
52+
outputs = []
53+
54+
for data in alpaca_data:
55+
instructions.append(data["instruction"]) inputs.append(data["input"])
56+
outputs.append(data["output"])
57+
58+
data_dict = {
59+
"train": {"instruction": instructions, "text": inputs, "target": outputs}
60+
}
61+
62+
dataset = DatasetDict()
63+
64+
for k, v in data_dict.items():
65+
dataset[k] =
66+
Dataset.from_dict(v) dataset.save_to_disk(str("./alpaca_data"))
67+
`}
68+
/>
69+
</div>
70+
)
71+
}

examples/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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`.
3+
4+
## Directory structure
5+
```
6+
examples/
7+
| datasets
8+
| features/
9+
| dataset_generation/
10+
| evaluation/
11+
| generic/
12+
| int4_finetuning/
13+
| models/
14+
| playground_ui/
15+
```
16+
17+
### datsets/
18+
This directory consists of multiple ways to generate your custom dataset from a given set of examples.
19+
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.
23+
24+
### models/
25+
This directory consists of examples specific to each model mentioned.
26+
27+
### playground_ui/
28+
This directory consists of an example which demonstrates how you can play around with your LLM through a web interface.
29+
30+
## Models
31+
Below is a list of all the supported models via `BaseModel` class of `xTuring` and their corresponding keys to load them.
32+
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|
45+
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.
47+
48+
| Version | Template |
49+
| -- | -- |
50+
| LoRA| <model_key>_lora|
51+
| INT8| <model_key>_int8|
52+
| INT8 + LoRA| <model_key>_lora_int8|
53+
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:
55+
```python
56+
model = GenericLoraKbitModel('<model_path>')
57+
```
58+
The `model_path` can be replaced with you local directory or any HuggingFace library model like `facebook/opt-1.3b`.

0 commit comments

Comments
 (0)