-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
232 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
pip install -e . | ||
|
||
gpu_state="$(nvidia-smi --query-gpu=name --format=csv,noheader)" | ||
if [[ "${gpu_state}" == *"A100"* || "${gpu_state}" == *"A40"* ]]; then | ||
pip install flash-attn==2.0.2 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Position Interpolation | ||
Now LMFlow supports the latest Linear & NTK (Neural Kernel theory) scaling techniques for LLaMA models. \ | ||
For more details of these techniques, you can checkout the links below: | ||
* Linear scaling: \ | ||
https://arxiv.org/abs/2306.15595 | ||
* NTK scaling: \ | ||
https://www.reddit.com/r/LocalLLaMA/comments/14lz7j5/ntkaware_scaled_rope_allows_llama_models_to_have/ | ||
## Usage | ||
To use the Position Interpolation Techniques, you need to set the following options: | ||
``` | ||
--truncate_to_model_max_length False | ||
--do_rope_scaling True | ||
``` | ||
For linear scaling, set the extending ratio by: | ||
``` | ||
--rope_pi_ratio 4 | ||
``` | ||
For NTK scaling, set the extending ratio by: | ||
``` | ||
--rope_ntk_ratio 4 | ||
``` | ||
Here is an example of evaluation bash code: | ||
``` | ||
#!/bin/bash | ||
CUDA_VISIBLE_DEVICES=0 \ | ||
deepspeed examples/evaluation.py \ | ||
--answer_type text \ | ||
--model_name_or_path pinkmanlove/llama-7b-hf \ | ||
--dataset_path data/wiki_en_eval \ | ||
--deepspeed examples/ds_config.json \ | ||
--inference_batch_size_per_device 1 \ | ||
--truncate_to_model_max_length False \ | ||
--block_size 4096 \ | ||
--use_flash_attention True \ | ||
--do_rope_scaling True \ | ||
--rope_pi_ratio 2 \ | ||
--rope_ntk_ratio 4 \ | ||
--metric ppl | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Flash Attention 2.0 | ||
We're thrilled to announce that LMFlow now supports training and inference using **FlashAttention-2**! This cutting-edge feature will take your language modeling to the next level. To use it, simply add ``` --use_flash_attention True ``` to the corresponding bash script. | ||
Here is an example of how to use it: | ||
``` | ||
#!/bin/bash | ||
pip install flash_attn==2.0.2 | ||
deepspeed --master_port=11000 \ | ||
examples/chatbot.py \ | ||
--deepspeed configs/ds_config_chatbot.json \ | ||
--model_name_or_path LMFlow/Full-Robin-7b-v2 \ | ||
--max_new_tokens 1024 \ | ||
--prompt_structure "###Human: {input_text}###Assistant:" \ | ||
--end_string "#" \ | ||
--use_flash_attention True | ||
``` | ||
|
||
Upgrade to LMFlow now and experience the future of language modeling! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Vocab Extension | ||
## Train & Merge Tokenizer | ||
To automatically convert data, train a SentencePiece tokenizer, and merge the tokenizer, you can run the following script: | ||
``` | ||
bash scripts/vocab_extension/train_merge_tokenizer.sh | ||
``` | ||
Alternatively, you can run each of the three steps separately: | ||
|
||
## Convert JSON Data to TXT | ||
To convert JSON data to TXT for sentencepiece tokenizer training, run: | ||
``` | ||
bash scripts/vocab_extension/convert_json_to_txt.sh | ||
``` | ||
## Train SentencePiece Tokenizer | ||
To train a SentencePiece tokenizer, run: | ||
``` | ||
bash scripts/vocab_extension/train_tokenizer.sh | ||
``` | ||
## Merge New Tokenizer with the Origin One | ||
To merge a new tokenizer with the original one, run: | ||
``` | ||
bash scripts/vocab_extension/merge_tokenizer.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
mkdir -p ./output_models/new_tokenizer | ||
python utils/merge_tokenizer.py --tokenizer_dir pinkmanlove/llama-7b-hf \ | ||
python utils/merge_tokenizer.py --tokenizer_dir openlm-research/open_llama_3b \ | ||
--chinese_sp_model_file ./output_models/new_tokenizer/example.model \ | ||
--output_dir ./output_models/merged_tokenizer \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.