Instructions to use haoranxu/ALMA-13B-Pretrain with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use haoranxu/ALMA-13B-Pretrain with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="haoranxu/ALMA-13B-Pretrain")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("haoranxu/ALMA-13B-Pretrain") model = AutoModelForCausalLM.from_pretrained("haoranxu/ALMA-13B-Pretrain", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use haoranxu/ALMA-13B-Pretrain with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "haoranxu/ALMA-13B-Pretrain" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "haoranxu/ALMA-13B-Pretrain", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/haoranxu/ALMA-13B-Pretrain
- SGLang
How to use haoranxu/ALMA-13B-Pretrain with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "haoranxu/ALMA-13B-Pretrain" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "haoranxu/ALMA-13B-Pretrain", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "haoranxu/ALMA-13B-Pretrain" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "haoranxu/ALMA-13B-Pretrain", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use haoranxu/ALMA-13B-Pretrain with Docker Model Runner:
docker model run hf.co/haoranxu/ALMA-13B-Pretrain
Update README.md
Browse files
README.md
CHANGED
|
@@ -3,9 +3,6 @@ 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 |
-
**[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!
|
| 8 |
-
|
| 9 |
```
|
| 10 |
@misc{xu2023paradigm,
|
| 11 |
title={A Paradigm Shift in Machine Translation: Boosting Translation Performance of Large Language Models},
|
|
@@ -16,6 +13,19 @@ Please find more details in our [paper](https://arxiv.org/abs/2309.11674).
|
|
| 16 |
primaryClass={cs.CL}
|
| 17 |
}
|
| 18 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
We release six translation models presented in the paper:
|
| 20 |
- **ALMA-7B**: Full-weight Fine-tune LLaMA-2-7B on 20B monolingual tokens and then **Full-weight** fine-tune on human-written parallel data
|
| 21 |
- **ALMA-7B-LoRA**: Full-weight Fine-tune LLaMA-2-7B on 20B monolingual tokens and then **LoRA** fine-tune on human-written parallel data
|
|
@@ -29,10 +39,10 @@ Model checkpoints are released at huggingface:
|
|
| 29 |
|:-------------:|:---------------:|:---------:|
|
| 30 |
| ALMA-7B | [haoranxu/ALMA-7B](https://huggingface.co/haoranxu/ALMA-7B) | - |
|
| 31 |
| ALMA-7B-LoRA | [haoranxu/ALMA-7B-Pretrain](https://huggingface.co/haoranxu/ALMA-7B-Pretrain) | [haoranxu/ALMA-7B-Pretrain-LoRA](https://huggingface.co/haoranxu/ALMA-7B-Pretrain-LoRA) |
|
| 32 |
-
| **ALMA-7B-R (NEW!)** | [haoranxu/ALMA-7B-
|
| 33 |
| ALMA-13B | [haoranxu/ALMA-13B](https://huggingface.co/haoranxu/ALMA-13B) | - |
|
| 34 |
| ALMA-13B-LoRA | [haoranxu/ALMA-13B-Pretrain](https://huggingface.co/haoranxu/ALMA-13B-Pretrain) | [haoranxu/ALMA-13B-Pretrain-LoRA](https://huggingface.co/haoranxu/ALMA-13B-Pretrain-LoRA) |
|
| 35 |
-
| **ALMA-13B-R (NEW!)** | [haoranxu/ALMA-13B-
|
| 36 |
|
| 37 |
**Note that `ALMA-7B-Pretrain` and `ALMA-13B-Pretrain` are NOT translation models. They only experience stage 1 monolingual fine-tuning (20B tokens for the 7B model and 12B tokens for the 13B model), and should be utilized in conjunction with their LoRA models.**
|
| 38 |
|
|
@@ -42,7 +52,7 @@ Datasets used by ALMA and ALMA-R are also released at huggingface now (NEW!)
|
|
| 42 |
| 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) |
|
| 43 |
| 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) |
|
| 44 |
|
| 45 |
-
A quick start to use
|
| 46 |
```
|
| 47 |
import torch
|
| 48 |
from peft import PeftModel
|
|
|
|
| 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},
|
|
|
|
| 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},
|
| 22 |
+
author={Haoran Xu and Amr Sharaf and Yunmo Chen and Weiting Tan and Lingfeng Shen and Benjamin Van Durme and Kenton Murray and Young Jin Kim},
|
| 23 |
+
year={2024},
|
| 24 |
+
eprint={2401.08417},
|
| 25 |
+
archivePrefix={arXiv},
|
| 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
|
|
|
|
| 39 |
|:-------------:|:---------------:|:---------:|
|
| 40 |
| ALMA-7B | [haoranxu/ALMA-7B](https://huggingface.co/haoranxu/ALMA-7B) | - |
|
| 41 |
| ALMA-7B-LoRA | [haoranxu/ALMA-7B-Pretrain](https://huggingface.co/haoranxu/ALMA-7B-Pretrain) | [haoranxu/ALMA-7B-Pretrain-LoRA](https://huggingface.co/haoranxu/ALMA-7B-Pretrain-LoRA) |
|
| 42 |
+
| **ALMA-7B-R (NEW!)** | [haoranxu/ALMA-7B-R (LoRA merged)](https://huggingface.co/haoranxu/ALMA-7B-R) | - |
|
| 43 |
| ALMA-13B | [haoranxu/ALMA-13B](https://huggingface.co/haoranxu/ALMA-13B) | - |
|
| 44 |
| ALMA-13B-LoRA | [haoranxu/ALMA-13B-Pretrain](https://huggingface.co/haoranxu/ALMA-13B-Pretrain) | [haoranxu/ALMA-13B-Pretrain-LoRA](https://huggingface.co/haoranxu/ALMA-13B-Pretrain-LoRA) |
|
| 45 |
+
| **ALMA-13B-R (NEW!)** | [haoranxu/ALMA-13B-R (LoRA merged)](https://huggingface.co/haoranxu/ALMA-13B-R) | - |
|
| 46 |
|
| 47 |
**Note that `ALMA-7B-Pretrain` and `ALMA-13B-Pretrain` are NOT translation models. They only experience stage 1 monolingual fine-tuning (20B tokens for the 7B model and 12B tokens for the 13B model), and should be utilized in conjunction with their LoRA models.**
|
| 48 |
|
|
|
|
| 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
|