Skip to content

Commit 3934a40

Browse files
committed
Merge PR #288: fix absolufy-imports typo in requirements-dev.txt
2 parents a733f36 + 9dbd181 commit 3934a40

File tree

12 files changed

+99
-39
lines changed

12 files changed

+99
-39
lines changed

.github/pull_request_template.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### Summary
2+
<!-- Briefly describe what changes this PR introduces, including any relevant context or motivation. -->
3+
4+
5+
### Checklist
6+
<!-- List any steps or commands that reviewers can follow to validate this change. -->
7+
8+
- [ ] Tested
9+
- [ ] Documented
10+
11+
### Additional Information
12+
13+
<!-- Include any additional notes or context that you think would be helpful for reviewers. -->

README.md

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src=".github/stochastic_logo_light.svg#gh-light-mode-only" width="250" alt="Stochastic.ai"/>
33
<img src=".github/stochastic_logo_dark.svg#gh-dark-mode-only" width="250" alt="Stochastic.ai"/>
44
</p>
5-
<h3 align="center">Build, customize and control your own personal LLMs</h3>
5+
<h3 align="center">Build, modify, and control your own personalized LLMs</h3>
66

77
<p align="center">
88
<a href="https://pypi.org/project/xturing/">
@@ -15,13 +15,14 @@
1515
<img src="https://img.shields.io/badge/Chat-FFFFFF?logo=discord&style=for-the-badge"/>
1616
</a>
1717
</p>
18+
1819
<br>
1920

2021
___
2122

22-
`xTuring` provides fast, efficient and simple fine-tuning of LLMs, such as LLaMA, GPT-J, Galactica, and more.
23+
`xTuring` provides fast, efficient and simple fine-tuning of open-source LLMs, such as Mistral, LLaMA, GPT-J, and more.
2324
By providing an easy-to-use interface for fine-tuning LLMs to your own data and application, xTuring makes it
24-
simple to build, customize and control LLMs. The entire process can be done inside your computer or in your
25+
simple to build, modify, and control LLMs. The entire process can be done inside your computer or in your
2526
private cloud, ensuring data privacy and security.
2627

2728
With `xTuring` you can,
@@ -33,6 +34,38 @@ With `xTuring` you can,
3334

3435
<br>
3536

37+
## ⚙️ Installation
38+
```bash
39+
pip install xturing
40+
```
41+
42+
<br>
43+
44+
## 🚀 Quickstart
45+
46+
```python
47+
from xturing.datasets import InstructionDataset
48+
from xturing.models import BaseModel
49+
50+
# Load the dataset
51+
instruction_dataset = InstructionDataset("./examples/models/llama/alpaca_data")
52+
53+
# Initialize the model
54+
model = BaseModel.create("llama_lora")
55+
56+
# Finetune the model
57+
model.finetune(dataset=instruction_dataset)
58+
59+
# Perform inference
60+
output = model.generate(texts=["Why LLM models are becoming so important?"])
61+
62+
print("Generated output by the model: {}".format(output))
63+
```
64+
65+
You can find the data folder [here](examples/models/llama/alpaca_data).
66+
67+
<br>
68+
3669
## 🌟 What's new?
3770
We are excited to announce the latest enhancements to our `xTuring` library:
3871
1. __`LLaMA 2` integration__ - You can use and fine-tune the _`LLaMA 2`_ model in different configurations: _off-the-shelf_, _off-the-shelf with INT8 precision_, _LoRA fine-tuning_, _LoRA fine-tuning with INT8 precision_ and _LoRA fine-tuning with INT4 precision_ using the `GenericModel` wrapper and/or you can use the `Llama2` class from `xturing.models` to test and finetune the model.
@@ -45,7 +78,7 @@ from xturing.models import BaseModel
4578
model = BaseModel.create('llama2')
4679

4780
```
48-
2. __`Evaluation`__ - Now you can evaluate any `Causal Language Model` on any dataset. The metrics currently supported is [`perplexity`](https://towardsdatascience.com/perplexity-in-language-models-87a196019a94).
81+
2. __`Evaluation`__ - Now you can evaluate any `Causal Language Model` on any dataset. The metrics currently supported is [`perplexity`](https://en.wikipedia.org/wiki/Perplexity).
4982
```python
5083
# Make the necessary imports
5184
from xturing.datasets import InstructionDataset
@@ -118,38 +151,6 @@ For an extended insight, consider examining the [GenericModel working example](e
118151

119152
<br>
120153

121-
## ⚙️ Installation
122-
```bash
123-
pip install xturing
124-
```
125-
126-
<br>
127-
128-
## 🚀 Quickstart
129-
130-
```python
131-
from xturing.datasets import InstructionDataset
132-
from xturing.models import BaseModel
133-
134-
# Load the dataset
135-
instruction_dataset = InstructionDataset("./alpaca_data")
136-
137-
# Initialize the model
138-
model = BaseModel.create("llama_lora")
139-
140-
# Finetune the model
141-
model.finetune(dataset=instruction_dataset)
142-
143-
# Perform inference
144-
output = model.generate(texts=["Why LLM models are becoming so important?"])
145-
146-
print("Generated output by the model: {}".format(output))
147-
```
148-
149-
You can find the data folder [here](examples/models/llama/alpaca_data).
150-
151-
<br>
152-
153154
## CLI playground
154155
<img src=".github/cli-playground.gif" width="80%" style="margin: 0 1%;"/>
155156

docs/docs/advanced/api_server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: FastAPI inference server
44
sidebar_position: 3
55
---
66

7-
# ⚡️ Running model inference with FastAPI Ssrver
7+
# ⚡️ Running model inference with FastAPI Server
88

99
<!-- Once you have fine-tuned your model, you can run the inference using a FastAPI server. -->
1010
After successfully fine-tuning your model, you can perform inference using a FastAPI server. The following steps guide you through launching and utilizing the API server for your fine-tuned model.

docs/docs/overview/supported_models.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ description: Models Supported by xTuring
3131
### INT4 Precision model versions
3232
> 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:
3333
```python
34+
from xturing.models import GenericLoraKbitModel
3435
model = GenericLoraKbitModel('/path/to/model')
3536
```
3637
The `/path/to/model` can be replaced with you local directory or any HuggingFace library model like `facebook/opt-1.3b`.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ keywords = [
4343
dependencies = [
4444
"torch >= 1.9.0",
4545
"pytorch-lightning",
46-
"transformers==4.31.0",
46+
"transformers==4.39.3",
4747
"datasets==2.14.5",
4848
"evaluate==0.4.0",
4949
"bitsandbytes==0.41.1",

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pre-commit
22
pytest
33
autoflake
4-
absoulify-imports
4+
absolufy-imports

src/xturing/config/finetuning_config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ llama2_lora_kbit:
298298
num_train_epochs: 3
299299
optimizer_name: cpu_adam
300300

301+
mamba:
302+
learning_rate: 5e-5
303+
weight_decay: 0.01
304+
301305
opt:
302306
learning_rate: 5e-5
303307
weight_decay: 0.01

src/xturing/config/generation_config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ llama2_lora_kbit:
252252
max_new_tokens: 256
253253
do_sample: false
254254

255+
# Greedy search
256+
mamba:
257+
do_sample: false
258+
255259
# Contrastive search
256260
opt:
257261
penalty_alpha: 0.6

src/xturing/engines/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
LlamaLoraInt8Engine,
5959
LlamaLoraKbitEngine,
6060
)
61+
from xturing.engines.mamba_engine import MambaEngine
6162
from xturing.engines.opt_engine import (
6263
OPTEngine,
6364
OPTInt8Engine,
@@ -107,6 +108,7 @@
107108
BaseEngine.add_to_registry(LLama2LoraEngine.config_name, LLama2LoraEngine)
108109
BaseEngine.add_to_registry(LLama2LoraInt8Engine.config_name, LLama2LoraInt8Engine)
109110
BaseEngine.add_to_registry(LLama2LoraKbitEngine.config_name, LLama2LoraKbitEngine)
111+
BaseEngine.add_to_registry(MambaEngine.config_name, MambaEngine)
110112
BaseEngine.add_to_registry(OPTEngine.config_name, OPTEngine)
111113
BaseEngine.add_to_registry(OPTInt8Engine.config_name, OPTInt8Engine)
112114
BaseEngine.add_to_registry(OPTLoraEngine.config_name, OPTLoraEngine)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
from pathlib import Path
3+
from typing import Optional, Union
4+
5+
from transformers import AutoTokenizer, MambaForCausalLM
6+
7+
from xturing.engines.causal import CausalEngine
8+
9+
class MambaEngine(CausalEngine):
10+
config_name: str = "mamba_engine"
11+
12+
def __init__(self, weights_path: Optional[Union[str, Path]] = None):
13+
model_name = "state-spaces/mamba-2.8b-hf"
14+
model = MambaForCausalLM.from_pretrained(model_name)
15+
tokenizer = AutoTokenizer.from_pretrained(model_name)
16+
17+
super().__init__(weights_path=weights_path, model=model, tokenizer=tokenizer)
18+
19+
20+
def save(self, saving_path: Union[str, Path]):
21+
self.model.save_pretrained(saving_path)
22+
self.tokenizer.save_pretrained(saving_path)

0 commit comments

Comments
 (0)