haoranxu commited on
Commit
05cdb52
•
1 Parent(s): 49c01fb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -15
README.md CHANGED
@@ -1,7 +1,21 @@
1
  ---
2
  license: mit
3
  ---
4
- **[ALMA-R](https://arxiv.org/abs/2401.08417)** builds upon [ALMA models](https://arxiv.org/abs/2309.11674), with further LoRA fine-tuning with our proposed **Contrastive Preference Optimization (CPO)** as opposed to the Supervised Fine-tuning used in ALMA. CPO fine-tuning requires our [triplet preference data](https://huggingface.co/datasets/haoranxu/ALMA-R-Preference) for preference learning. ALMA-R now can matches or even exceeds GPT-4 or WMT winners!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  ```
6
  @misc{xu2024contrastive,
7
  title={Contrastive Preference Optimization: Pushing the Boundaries of LLM Performance in Machine Translation},
@@ -12,15 +26,13 @@ license: mit
12
  primaryClass={cs.CL}
13
  }
14
  ```
15
- # Download ALMA(-R) Models and Dataset 🚀
16
-
17
  We release six translation models presented in the paper:
18
- - ALMA-7B
19
- - ALMA-7B-LoRA
20
  - **ALMA-7B-R (NEW!)**: Further LoRA fine-tuning upon ALMA-7B-LoRA with contrastive preference optimization.
21
- - ALMA-13B
22
- - ALMA-13B-LoRA
23
- - **ALMA-13B-R (NEW!)**: Further LoRA fine-tuning upon ALMA-13B-LoRA with contrastive preference optimization (BEST MODEL!).
24
 
25
  Model checkpoints are released at huggingface:
26
  | Models | Base Model Link | LoRA Link |
@@ -40,18 +52,19 @@ Datasets used by ALMA and ALMA-R are also released at huggingface now (NEW!)
40
  | Human-Written Parallel Data (ALMA) | [train and validation](https://huggingface.co/datasets/haoranxu/ALMA-Human-Parallel) | [WMT'22](https://huggingface.co/datasets/haoranxu/WMT22-Test) |
41
  | Triplet Preference Data | [train](https://huggingface.co/datasets/haoranxu/ALMA-R-Preference) | [WMT'22](https://huggingface.co/datasets/haoranxu/WMT22-Test) and [WMT'23](https://huggingface.co/datasets/haoranxu/WMT23-Test) |
42
 
43
-
44
- A quick start to use our best system (ALMA-13B-R) for translation. An example of translating "我爱机器翻译。" into English:
45
  ```
46
  import torch
 
47
  from transformers import AutoModelForCausalLM
48
- from transformers import AutoTokenizer
49
 
50
  # Load base model and LoRA weights
51
- model = AutoModelForCausalLM.from_pretrained("haoranxu/ALMA-13B-R", torch_dtype=torch.float16, device_map="auto")
52
- tokenizer = AutoTokenizer.from_pretrained("haoranxu/ALMA-13B-R", padding_side='left')
 
53
 
54
- # Add the source sentence into the prompt template
55
  prompt="Translate this from Chinese to English:\nChinese: 我爱机器翻译。\nEnglish:"
56
  input_ids = tokenizer(prompt, return_tensors="pt", padding=True, max_length=40, truncation=True).input_ids.cuda()
57
 
@@ -60,4 +73,6 @@ with torch.no_grad():
60
  generated_ids = model.generate(input_ids=input_ids, num_beams=5, max_new_tokens=20, do_sample=True, temperature=0.6, top_p=0.9)
61
  outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
62
  print(outputs)
63
- ```
 
 
 
1
  ---
2
  license: mit
3
  ---
4
+ **ALMA** (**A**dvanced **L**anguage **M**odel-based tr**A**nslator) is an LLM-based translation model, which adopts a new translation model paradigm: it begins with fine-tuning on monolingual data and is further optimized using high-quality parallel data. This two-step fine-tuning process ensures strong translation performance.
5
+ Please find more details in our [paper](https://arxiv.org/abs/2309.11674).
6
+ ```
7
+ @misc{xu2023paradigm,
8
+ title={A Paradigm Shift in Machine Translation: Boosting Translation Performance of Large Language Models},
9
+ author={Haoran Xu and Young Jin Kim and Amr Sharaf and Hany Hassan Awadalla},
10
+ year={2023},
11
+ eprint={2309.11674},
12
+ archivePrefix={arXiv},
13
+ primaryClass={cs.CL}
14
+ }
15
+ ```
16
+ **[ALMA-R](https://arxiv.org/abs/2401.08417) (NEW!) is released now!** ALMA-R builds upon ALMA models, with further LoRA fine-tuning with our proposed **Contrastive Preference Optimization (CPO)** as opposed to the Supervised Fine-tuning used in ALMA. CPO fine-tuning requires our [triplet preference data](https://huggingface.co/datasets/haoranxu/ALMA-R-Preference) for preference learning. ALMA-R now can matches or even exceeds GPT-4 or WMT winners!
17
+
18
+
19
  ```
20
  @misc{xu2024contrastive,
21
  title={Contrastive Preference Optimization: Pushing the Boundaries of LLM Performance in Machine Translation},
 
26
  primaryClass={cs.CL}
27
  }
28
  ```
 
 
29
  We release six translation models presented in the paper:
30
+ - **ALMA-7B**: Full-weight Fine-tune LLaMA-2-7B on 20B monolingual tokens and then **Full-weight** fine-tune on human-written parallel data
31
+ - **ALMA-7B-LoRA**: Full-weight Fine-tune LLaMA-2-7B on 20B monolingual tokens and then **LoRA** fine-tune on human-written parallel data
32
  - **ALMA-7B-R (NEW!)**: Further LoRA fine-tuning upon ALMA-7B-LoRA with contrastive preference optimization.
33
+ - **ALMA-13B**: Full-weight Fine-tune LLaMA-2-7B on 12B monolingual tokens and then **Full-weight** fine-tune on human-written parallel data
34
+ - **ALMA-13B-LoRA** (Our best system): Full-weight Fine-tune LLaMA-2-7B on 12B monolingual tokens and then **LoRA** fine-tune on human-written parallel data
35
+ - **ALMA-13B-R (NEW!)**: Further LoRA fine-tuning upon ALMA-13B-LoRA with contrastive preference optimization.
36
 
37
  Model checkpoints are released at huggingface:
38
  | Models | Base Model Link | LoRA Link |
 
52
  | Human-Written Parallel Data (ALMA) | [train and validation](https://huggingface.co/datasets/haoranxu/ALMA-Human-Parallel) | [WMT'22](https://huggingface.co/datasets/haoranxu/WMT22-Test) |
53
  | Triplet Preference Data | [train](https://huggingface.co/datasets/haoranxu/ALMA-R-Preference) | [WMT'22](https://huggingface.co/datasets/haoranxu/WMT22-Test) and [WMT'23](https://huggingface.co/datasets/haoranxu/WMT23-Test) |
54
 
55
+ A quick start to use system ALMA-13B-LoRA for translation. An example of translating "我爱机器翻译。" into English:
 
56
  ```
57
  import torch
58
+ from peft import PeftModel
59
  from transformers import AutoModelForCausalLM
60
+ from transformers import LlamaTokenizer
61
 
62
  # Load base model and LoRA weights
63
+ model = AutoModelForCausalLM.from_pretrained("haoranxu/ALMA-13B-Pretrain", torch_dtype=torch.float16, device_map="auto")
64
+ model = PeftModel.from_pretrained(model, "haoranxu/ALMA-13B-Pretrain-LoRA")
65
+ tokenizer = LlamaTokenizer.from_pretrained("haoranxu/ALMA-13B-Pretrain", padding_side='left')
66
 
67
+ # Add the source setence into the prompt template
68
  prompt="Translate this from Chinese to English:\nChinese: 我爱机器翻译。\nEnglish:"
69
  input_ids = tokenizer(prompt, return_tensors="pt", padding=True, max_length=40, truncation=True).input_ids.cuda()
70
 
 
73
  generated_ids = model.generate(input_ids=input_ids, num_beams=5, max_new_tokens=20, do_sample=True, temperature=0.6, top_p=0.9)
74
  outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
75
  print(outputs)
76
+ ```
77
+
78
+ Please find more details in our [GitHub repository](https://github.com/fe1ixxu/ALMA)