Safetensors
mistral
h-j-han commited on
Commit
c798dd1
ยท
verified ยท
1 Parent(s): 7642acc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +71 -3
README.md CHANGED
@@ -1,3 +1,71 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - allenai/MADLAD-400
5
+ language:
6
+ - en
7
+ - sw
8
+ - id
9
+ - ht
10
+ - ko
11
+ - el
12
+ - ru
13
+ - bg
14
+ - uk
15
+ - kk
16
+ base_model:
17
+ - mistralai/Mistral-7B-v0.1
18
+ ---
19
+ 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.
20
+ VocADT offers a flexible and scalable solution without requiring external resources or language constraints.
21
+
22
+
23
+ ## New Vocabulary Adapted Models
24
+ Only the input/output embeddings are replaced, while all other original weights of base model remain fixed.
25
+ These are the merged version: after training the adapters, we merge the original embeddings with the adapter to generate the new embeddings.
26
+ | Name | Adapted Model | Base Model | New Vocab Size | Focused Languages |
27
+ |---|---|---|---|---|
28
+ | 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)|
29
+ | 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) |
30
+ | 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) |
31
+ | 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) |
32
+ |||||
33
+ | 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)|
34
+ | 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) |
35
+ | 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) |
36
+
37
+
38
+ ## Quick Start
39
+ ```python
40
+ from transformers import AutoModelForCausalLM, AutoTokenizer
41
+ # model_name = "mistralai/Mistral-7B-v0.1" # Base Model
42
+ model_name = "h-j-han/Mistral-7B-VocADT-50k-Mixed" # Vocabulary Adapted Model
43
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
44
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
45
+ prefix = "\nEnglish: Hello \nKorean: ์•ˆ๋…•ํ•˜์„ธ์š” \nEnglish: Thank you\nKorean: ๊ณ ๋ง™์Šต๋‹ˆ๋‹ค\nEnglish: "
46
+ line = "I'm a student."
47
+ suffix = f"\nKorean:"
48
+ prompt = prefix + line + suffix
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=88)
53
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
54
+ # Base Model Output: "๋‚˜๋Š” ํ•™" # This short incomplete phrase in Korean is 5 tokens for the base model.
55
+ # VocADT Output: "์ €๋Š” ํ•™์ƒ์ž…๋‹ˆ๋‹ค." # Complete and good output within 5 tokens
56
+ ```
57
+
58
+ ## Reference
59
+ We provide code in Github repo : https://github.com/h-j-han/VocADT
60
+ Also, please find details in this paper :
61
+ ```
62
+ @misc{han2024vocadt,
63
+ title={Adapters for Altering LLM Vocabularies: What Languages Benefit the Most?},
64
+ author={HyoJung Han and Akiko Eriguchi and Haoran Xu and Hieu Hoang and Marine Carpuat and Huda Khayrallah},
65
+ year={2024},
66
+ eprint={2410.09644},
67
+ archivePrefix={arXiv},
68
+ primaryClass={cs.CL},
69
+ url={https://arxiv.org/abs/2410.09644},
70
+ }
71
+ ```