zhanjun commited on
Commit
c899962
1 Parent(s): 1e5ceb1

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +145 -0
README.md ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - fnlp/AnyInstruct
5
+ language:
6
+ - en
7
+ ---
8
+ # Chat model for paper "AnyGPT: Unified Multimodal LLM with Discrete Sequence Modeling"
9
+
10
+ ## Introduction
11
+ We introduce AnyGPT, an any-to-any multimodal language model that utilizes discrete representations for the unified processing of various modalities, including speech, text, images, and music. The [base model](https://huggingface.co/fnlp/AnyGPT-base) aligns the four modalities, allowing for intermodal conversions between different modalities and text. Furthermore, we constructed the [AnyInstruct](https://huggingface.co/datasets/fnlp/AnyInstruct) dataset based on various generative models, which contains instructions for arbitrary modal interconversion. Trained on this dataset, our [chat model](https://huggingface.co/fnlp/AnyGPT-chat) can engage in free multimodal conversations, where multimodal data can be inserted at will.
12
+
13
+ AnyGPT proposes a generative training scheme that converts all modal data into a unified discrete representation, using the Next Token Prediction task for unified training on a Large Language Model (LLM). From the perspective of 'compression is intelligence': when the quality of the Tokenizer is high enough, and the perplexity (PPL) of the LLM is low enough, it is possible to compress the vast amount of multimodal data on the internet into the same model, thereby emerging capabilities not present in a pure text-based LLM.
14
+ Demos are shown in [project page](https://junzhan2000.github.io/AnyGPT.github.io).
15
+
16
+ ## Example Demonstrations
17
+ [![视频标题](http://img.youtube.com/vi/oW3E3pIsaRg/0.jpg)](https://www.youtube.com/watch?v=oW3E3pIsaRg)
18
+
19
+
20
+ ## Inference
21
+
22
+ ### Installation
23
+
24
+ ```bash
25
+ git clone https://github.com/OpenMOSS/AnyGPT.git
26
+ cd AnyGPT
27
+ conda create --name AnyGPT python=3.9
28
+ conda activate AnyGPT
29
+ pip install -r requirements.txt
30
+ ```
31
+
32
+ ### Model Weights
33
+ * Check the AnyGPT-base weights in [fnlp/AnyGPT-base](https://huggingface.co/fnlp/AnyGPT-base)
34
+ * Check the AnyGPT-chat weights in [fnlp/AnyGPT-chat](https://huggingface.co/fnlp/AnyGPT-chat)
35
+ * Check the SpeechTokenizer and Soundstorm weights in [fnlp/AnyGPT-speech-modules](https://huggingface.co/fnlp/AnyGPT-speech-modules)
36
+ * Check the SEED tokenizer weights in [AILab-CVC/seed-tokenizer-2](https://huggingface.co/AILab-CVC/seed-tokenizer-2)
37
+
38
+
39
+ The SpeechTokenizer is used for tokenizing and reconstructing speech, Soundstorm is responsible for completing paralinguistic information, and SEED-tokenizer is used for tokenizing images.
40
+
41
+ The model weights of unCLIP SD-UNet which are used to reconstruct the image, and Encodec-32k which are used to tokenize and reconstruct music will be downloaded automatically.
42
+
43
+ ### Base model CLI Inference
44
+ ```bash
45
+ python anygpt/src/infer/cli_infer_base_model.py \
46
+ --model-name-or-path "path/to/AnyGPT-7B-base" \
47
+ --image-tokenizer-path models/seed-tokenizer-2/seed_quantizer.pt \
48
+ --speech-tokenizer-path "path/to/model" \
49
+ --speech-tokenizer-config "path/to/config" \
50
+ --soundstorm-path "path/to/model" \
51
+ --output-dir "infer_output/base"
52
+ ```
53
+
54
+ for example
55
+ ```bash
56
+ python anygpt/src/infer/cli_infer_base_model.py \
57
+ --model-name-or-path models/anygpt/base \
58
+ --image-tokenizer-path models/seed-tokenizer-2/seed_quantizer.pt \
59
+ --speech-tokenizer-path models/speechtokenizer/ckpt.dev \
60
+ --speech-tokenizer-config models/speechtokenizer/config.json \
61
+ --soundstorm-path models/soundstorm/speechtokenizer_soundstorm_mls.pt \
62
+ --output-dir "infer_output/base"
63
+ ```
64
+
65
+ #### Interaction
66
+ The Base Model can perform various tasks, including text-to-image, image caption, Automatic Speech Recognition (ASR), Zero-shot Text-to-Speech (TTS), Text-to-Music, and Music Captioning.
67
+
68
+ We can perform inference following a specific instruction format.
69
+
70
+ * Text-to-Image
71
+ * ```text|image|{caption}```
72
+ * example:
73
+ ```text|image|A bustling medieval market scene with vendors selling exotic goods under colorful tents```
74
+ * Image Caption
75
+ * ```image|text|{caption}```
76
+ * example:
77
+ ```image|text|static/infer/image/cat.jpg```
78
+ * TTS(random voice)
79
+ * ```text|speech|{speech content}```
80
+ * example:
81
+ ```text|speech|I could be bounded in a nutshell and count myself a king of infinite space.```
82
+ * Zero-shot TTS
83
+ * ```text|speech|{speech content}|{voice prompt}```
84
+ * example:
85
+ ```text|speech|I could be bounded in a nutshell and count myself a king of infinite space.|static/infer/speech/voice_prompt1.wav/voice_prompt3.wav```
86
+ * ASR
87
+ * ```speech|text|{speech file path}```
88
+ * example: ```speech|text|AnyGPT/static/infer/speech/voice_prompt2.wav```
89
+ * Text-to-Music
90
+ * ```text|music|{caption}```
91
+ * example:
92
+ ```text|music|features an indie rock sound with distinct elements that evoke a dreamy, soothing atmosphere```
93
+ * Music Caption
94
+ * ```music|text|{music file path}```
95
+ * example: ```music|text|static/infer/music/features an indie rock sound with distinct element.wav```
96
+
97
+ **Notes**
98
+
99
+ For different tasks, we used different language model decoding strategies. The decoding configuration files for image, speech, and music generation are located in ```config/image_generate_config.json```, ```config/speech_generate_config.json```, and ```config/music_generate_config.json```, respectively. The decoding configuration files for other modalities to text are in ```config/text_generate_config.json```. You can directly modify or add parameters to change the decoding strategy.
100
+
101
+ Due to limitations in data and training resources, the model's generation may still be unstable. You can generate multiple times or try different decoding strategies.
102
+
103
+ The speech and music response will be saved to ```.wav``` files, and the image response will be saved to a ```jpg```. The filename will be a concatenation of the prompt and the time. The paths to these files will be indicated in the response.
104
+
105
+ ### Training
106
+ #### Pretraining
107
+
108
+ * Install dependency
109
+ ``` bash
110
+ cd FastChat
111
+ pip3 install -e ".[train]"
112
+ ```
113
+ * run
114
+ ```
115
+ srun --partition=llm_h --job-name=pretrain --gres=gpu:8 --quotatype=spot --ntasks=1 --ntasks-per-node=1 --cpus-per-task 100 --kill-on-bad-exit=1 bash scripts/stage1_pretrain.sh
116
+ ```
117
+
118
+ We have provided some sample data in the "data" folder. To download the complete dataset, please refer to the following:
119
+
120
+ * Image data: https://huggingface.co/datasets/zhanjun/AnyGPT-data-image
121
+ * The two datasets in the t2i folder are high-quality image datasets, used for fine-tuning text-to-image generation.
122
+ * Speech data: https://huggingface.co/datasets/zhanjun/AnyGPT-data-speech
123
+ * Music data: None
124
+ * Insruction data: https://huggingface.co/datasets/zhanjun/Anygpt_data_instruction
125
+
126
+ These data are preprocessed by multimodal tokeniziers.
127
+
128
+
129
+ ## Acknowledgements
130
+ - [SpeechGPT](https://github.com/0nutation/SpeechGPT/tree/main/speechgpt), [Vicuna](https://github.com/lm-sys/FastChat): The codebase we built upon.
131
+ - We thank the great work from [SpeechTokenizer](https://github.com/ZhangXInFD/SpeechTokenizer),[soundstorm-speechtokenizer](https://github.com/ZhangXInFD/soundstorm-speechtokenizer), [SEED-tokenizer](https://github.com/AILab-CVC/SEED),
132
+
133
+ ## Lincese
134
+ `AnyGPT` is released under the original [License](https://ai.meta.com/resources/models-and-libraries/llama-downloads/) of [LLaMA2](https://huggingface.co/meta-llama/Llama-2-13b-chat-hf).
135
+
136
+ ## Citation
137
+ If you find AnyGPT and AnyInstruct useful in your research or applications, please kindly cite:
138
+ ```
139
+ @article{zhan2024anygpt,
140
+ title={AnyGPT: Unified Multimodal LLM with Discrete Sequence Modeling},
141
+ author={Zhan, Jun and Dai, Junqi and Ye, Jiasheng and Zhou, Yunhua and Zhang, Dong and Liu, Zhigeng and Zhang, Xin and Yuan, Ruibin and Zhang, Ge and Li, Linyang and others},
142
+ journal={arXiv preprint arXiv:2402.12226},
143
+ year={2024}
144
+ }
145
+ ```