Safetensors
llama
h-j-han commited on
Commit
c7ec017
·
1 Parent(s): 35b5fa4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -0
README.md CHANGED
@@ -1,3 +1,65 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ datasets:
4
+ - allenai/MADLAD-400
5
+ language:
6
+ - en
7
+ - sw
8
+ - id
9
+ - et
10
+ - ht
11
+ base_model:
12
+ - meta-llama/Llama-2-7b-hf
13
  ---
14
+ 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.
15
+ VocADT offers a flexible and scalable solution without requiring external resources or language constraints.
16
+
17
+ ## New Vocabulary Adapted Models
18
+ Only the input/output embeddings are replaced, while all other original weights of base model remain fixed.
19
+ These are the merged version: after training the adapters, we merge the original embeddings with the adapter to generate the new embeddings.
20
+ | Name | Adapted Model | Base Model | New Vocab Size | Focused Languages |
21
+ |---|---|---|---|---|
22
+ | 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)|
23
+ | 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) |
24
+ | 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) |
25
+ |||||
26
+ | 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)|
27
+ | 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) |
28
+ | 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) |
29
+
30
+
31
+ ## Quick Start
32
+ ```python
33
+ from transformers import AutoModelForCausalLM, AutoTokenizer
34
+
35
+ # model_name = "meta-llama/Llama-2-7b-hf" # Base Model
36
+ model_name = "h-j-han/Llama2-7B-VocADT-50k-Latin" # Vocabulary Adapted Model
37
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
38
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
39
+
40
+ prefix = "\nEnglish: Hello!\nSwahili: Habari!\nEnglish: What's your name?\nSwahili: Jina lako ni nani?\nEnglish: "
41
+ line = "My name is Amani."
42
+ suffix = f"\nSwahili:"
43
+ prompt = prefix + line + suffix
44
+
45
+ inputs = tokenizer(prompt, return_tensors="pt")
46
+ for item in inputs:
47
+ inputs[item] = inputs[item].cuda()
48
+ outputs = model.generate(**inputs, max_new_tokens=5)
49
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
50
+ ```
51
+
52
+ ## Reference
53
+ We provide code in Github repo : https://github.com/h-j-han/VocADT
54
+ Also, please find details in this paper :
55
+ ```
56
+ @misc{han2024vocadt,
57
+ title={Adapters for Altering LLM Vocabularies: What Languages Benefit the Most?},
58
+ author={HyoJung Han and Akiko Eriguchi and Haoran Xu and Hieu Hoang and Marine Carpuat and Huda Khayrallah},
59
+ year={2024},
60
+ eprint={2410.09644},
61
+ archivePrefix={arXiv},
62
+ primaryClass={cs.CL},
63
+ url={https://arxiv.org/abs/2410.09644},
64
+ }
65
+ ```