h-j-han commited on
Commit
1058cb8
·
verified ·
1 Parent(s): f35dbfc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -68
README.md CHANGED
@@ -1,69 +1,70 @@
1
- ---
2
- license: mit
3
- ---
4
- ---
5
- license: mit
6
- datasets:
7
- - allenai/MADLAD-400
8
- language:
9
- - en
10
- - ru
11
- - bg
12
- - uk
13
- - kk
14
- base_model:
15
- - meta-llama/Llama-2-7b-hf
16
- ---
17
- VocADT is a solution for vocabulary adaptation using adapter modules that are trained to learn the optimal linear combination of existing embeddings while keeping the model’s weights fixed.
18
- VocADT offers a flexible and scalable solution without requiring external resources or language constraints.
19
-
20
-
21
- ## New Vocabulary Adapted Models
22
- Only the input/output embeddings are replaced, while all other original weights of base model remain fixed.
23
- These are the merged version: after training the adapters, we merge the original embeddings with the adapter to generate the new embeddings.
24
- | Name | Adapted Model | Base Model | New Vocab Size | Focused Languages |
25
- |---|---|---|---|---|
26
- | VocADT-Latin-Mistral | [h-j-han/Mistral-7B-VocADT-50k-Latin](https://huggingface.co/h-j-han/Mistral-7B-VocADT-50k-Latin) | [Mistral](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 50k | Swahili (sw), Indonesian (id), Estonian (et), Haitian Creole (ht), English (en)|
27
- | VocADT-Mixed-Mistral | [h-j-han/Mistral-7B-VocADT-50k-Mixed](https://huggingface.co/h-j-han/Mistral-7B-VocADT-50k-Mixed) | [Mistral](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 50k | Korean (ko), Greek (el), Russian (ru), Bulgarian (bg), English (en) |
28
- | VocADT-Cyrillic-Mistral | [h-j-han/Mistral-7B-VocADT-50k-Cyrillic](https://huggingface.co/h-j-han/Mistral-7B-VocADT-50k-Cyrillic) | [Mistral](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 50k | Russian (ru), Bulgarian (bg), Ukrainian (uk), Kazakh (kk), English (en) |
29
- |||||
30
- | VocADT-Latin-LLama | [h-j-han/Llama2-7B-VocADT-50k-Latin](https://huggingface.co/h-j-han/Llama2-7B-VocADT-50k-Latin) | [Llama](https://huggingface.co/meta-llama/Llama-2-7b-hf) | 50k | Swahili (sw), Indonesian (id), Estonian (et), Haitian Creole (ht), English (en)|
31
- | VocADT-Mixed-LLama | [h-j-han/Llama2-7B-VocADT-50k-Mixed](https://huggingface.co/h-j-han/Llama2-7B-VocADT-50k-Mixed) | [Llama](https://huggingface.co/meta-llama/Llama-2-7b-hf) | 50k | Korean (ko), Greek (el), Russian (ru), Bulgarian (bg), English (en) |
32
- | VocADT-Cyrillic-LLama | [h-j-han/Llama2-7B-VocADT-50k-Cyrillic](https://huggingface.co/h-j-han/Llama2-7B-VocADT-50k-Cyrillic) | [Llama](https://huggingface.co/meta-llama/Llama-2-7b-hf) | 50k | Russian (ru), Bulgarian (bg), Ukrainian (uk), Kazakh (kk), English (en) |
33
-
34
-
35
- ## Quick Start
36
- ```python
37
- from transformers import AutoModelForCausalLM, AutoTokenizer
38
-
39
- # model_name = "meta-llama/Llama-2-7b-hf" # Base Model
40
- model_name = "h-j-han/Llama2-7B-VocADT-50k-Cyrillic" # Vocabulary Adapted Model
41
- tokenizer = AutoTokenizer.from_pretrained(model_name)
42
- model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
43
-
44
- prefix = "\nEnglish: Hello!\nUkrainian: Добрий день!\nEnglish: How are you?\nUkrainian: Як справи?\nEnglish: "
45
- line = "Do you speak English?"
46
- suffix = f"\nUkrainian:"
47
- prompt = prefix + line + suffix
48
-
49
- inputs = tokenizer(prompt, return_tensors="pt")
50
- for item in inputs:
51
- inputs[item] = inputs[item].cuda()
52
- outputs = model.generate(**inputs, max_new_tokens=6)
53
- print(tokenizer.decode(outputs[0], skip_special_tokens=True))
54
- ```
55
-
56
- ## Reference
57
- We provide code in Github repo: https://github.com/h-j-han/VocADT
58
- Also, please find details in this paper:
59
- ```
60
- @misc{han2024vocadt,
61
- title={Adapters for Altering LLM Vocabularies: What Languages Benefit the Most?},
62
- author={HyoJung Han and Akiko Eriguchi and Haoran Xu and Hieu Hoang and Marine Carpuat and Huda Khayrallah},
63
- year={2024},
64
- eprint={2410.09644},
65
- archivePrefix={arXiv},
66
- primaryClass={cs.CL},
67
- url={https://arxiv.org/abs/2410.09644},
68
- }
 
69
  ```
 
1
+ ---
2
+ license: mit
3
+ ---
4
+ ---
5
+ license: mit
6
+ datasets:
7
+ - allenai/MADLAD-400
8
+ language:
9
+ - en
10
+ - ru
11
+ - bg
12
+ - uk
13
+ - kk
14
+ base_model:
15
+ - meta-llama/Llama-2-7b-hf
16
+ ---
17
+ VocADT is a solution for vocabulary adaptation using adapter modules that are trained to learn the optimal linear combination of existing embeddings while keeping the model’s weights fixed.
18
+ VocADT offers a flexible and scalable solution without requiring external resources or language constraints.
19
+
20
+
21
+ ## New Vocabulary Adapted Models
22
+ Only the input/output embeddings are replaced, while all other original weights of base model remain fixed.
23
+ These are the merged version: after training the adapters, we merge the original embeddings with the adapter to generate the new embeddings.
24
+ | Name | Adapted Model | Base Model | New Vocab Size | Focused Languages |
25
+ |---|---|---|---|---|
26
+ | VocADT-Latin-Mistral | [h-j-han/Mistral-7B-VocADT-50k-Latin](https://huggingface.co/h-j-han/Mistral-7B-VocADT-50k-Latin) | [Mistral](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 50k | Swahili (sw), Indonesian (id), Estonian (et), Haitian Creole (ht), English (en)|
27
+ | VocADT-Mixed-Mistral | [h-j-han/Mistral-7B-VocADT-50k-Mixed](https://huggingface.co/h-j-han/Mistral-7B-VocADT-50k-Mixed) | [Mistral](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 50k | Korean (ko), Greek (el), Russian (ru), Bulgarian (bg), English (en) |
28
+ | VocADT-Cyrillic-Mistral | [h-j-han/Mistral-7B-VocADT-50k-Cyrillic](https://huggingface.co/h-j-han/Mistral-7B-VocADT-50k-Cyrillic) | [Mistral](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 50k | Russian (ru), Bulgarian (bg), Ukrainian (uk), Kazakh (kk), English (en) |
29
+ | VocADT-All-Mistral | [h-j-han/Mistral-7B-VocADT-50k-All](https://huggingface.co/h-j-han/Mistral-7B-VocADT-50k-All) | [Mistral](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 50k | Swahili (sw), Indonesian (id), Estonian (et), Haitian Creole (ht), Korean (ko), Greek (el), Russian (ru), Bulgarian (bg), Ukrainian (uk), Kazakh (kk), English (en) |
30
+ |||||
31
+ | VocADT-Latin-LLama | [h-j-han/Llama2-7B-VocADT-50k-Latin](https://huggingface.co/h-j-han/Llama2-7B-VocADT-50k-Latin) | [Llama](https://huggingface.co/meta-llama/Llama-2-7b-hf) | 50k | Swahili (sw), Indonesian (id), Estonian (et), Haitian Creole (ht), English (en)|
32
+ | VocADT-Mixed-LLama | [h-j-han/Llama2-7B-VocADT-50k-Mixed](https://huggingface.co/h-j-han/Llama2-7B-VocADT-50k-Mixed) | [Llama](https://huggingface.co/meta-llama/Llama-2-7b-hf) | 50k | Korean (ko), Greek (el), Russian (ru), Bulgarian (bg), English (en) |
33
+ | VocADT-Cyrillic-LLama | [h-j-han/Llama2-7B-VocADT-50k-Cyrillic](https://huggingface.co/h-j-han/Llama2-7B-VocADT-50k-Cyrillic) | [Llama](https://huggingface.co/meta-llama/Llama-2-7b-hf) | 50k | Russian (ru), Bulgarian (bg), Ukrainian (uk), Kazakh (kk), English (en) |
34
+
35
+
36
+ ## Quick Start
37
+ ```python
38
+ from transformers import AutoModelForCausalLM, AutoTokenizer
39
+
40
+ # model_name = "meta-llama/Llama-2-7b-hf" # Base Model
41
+ model_name = "h-j-han/Llama2-7B-VocADT-50k-Cyrillic" # Vocabulary Adapted Model
42
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
43
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
44
+
45
+ prefix = "\nEnglish: Hello!\nUkrainian: Добрий день!\nEnglish: How are you?\nUkrainian: Як справи?\nEnglish: "
46
+ line = "Do you speak English?"
47
+ suffix = f"\nUkrainian:"
48
+ prompt = prefix + line + suffix
49
+
50
+ inputs = tokenizer(prompt, return_tensors="pt")
51
+ for item in inputs:
52
+ inputs[item] = inputs[item].cuda()
53
+ outputs = model.generate(**inputs, max_new_tokens=6)
54
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
55
+ ```
56
+
57
+ ## Reference
58
+ We provide code in Github repo: https://github.com/h-j-han/VocADT
59
+ Also, please find details in this paper:
60
+ ```
61
+ @misc{han2024vocadt,
62
+ title={Adapters for Altering LLM Vocabularies: What Languages Benefit the Most?},
63
+ author={HyoJung Han and Akiko Eriguchi and Haoran Xu and Hieu Hoang and Marine Carpuat and Huda Khayrallah},
64
+ year={2024},
65
+ eprint={2410.09644},
66
+ archivePrefix={arXiv},
67
+ primaryClass={cs.CL},
68
+ url={https://arxiv.org/abs/2410.09644},
69
+ }
70
  ```