Instructions to use LLaMAX/LLaMAX2-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LLaMAX/LLaMAX2-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="LLaMAX/LLaMAX2-7B")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("LLaMAX/LLaMAX2-7B") model = AutoModelForCausalLM.from_pretrained("LLaMAX/LLaMAX2-7B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use LLaMAX/LLaMAX2-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LLaMAX/LLaMAX2-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LLaMAX/LLaMAX2-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/LLaMAX/LLaMAX2-7B
- SGLang
How to use LLaMAX/LLaMAX2-7B 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 "LLaMAX/LLaMAX2-7B" \ --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": "LLaMAX/LLaMAX2-7B", "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 "LLaMAX/LLaMAX2-7B" \ --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": "LLaMAX/LLaMAX2-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use LLaMAX/LLaMAX2-7B with Docker Model Runner:
docker model run hf.co/LLaMAX/LLaMAX2-7B
update readme
Browse files
README.md
CHANGED
|
@@ -12,38 +12,6 @@ LLaMAX is a multilingual language model, developed through continued pre-trainin
|
|
| 12 |
Its translation capabilities far exceed general models of the same scale, and it can serve as a base model to support downstream multilingual tasks.
|
| 13 |
|
| 14 |
|
| 15 |
-
### 🔥 Effortless Multilingual Translation with a Simple Prompt
|
| 16 |
-
|
| 17 |
-
LLaMAX supports translation between more than 100 languages, surpassing the performance of similarly scaled LLMs.
|
| 18 |
-
|
| 19 |
-
```angular2html
|
| 20 |
-
def Prompt_template(query, src_language, trg_language):
|
| 21 |
-
instruction = f'Translate the following sentences from {src_language} to {trg_language}.'
|
| 22 |
-
prompt = (
|
| 23 |
-
'Below is an instruction that describes a task, paired with an input that provides further context. '
|
| 24 |
-
'Write a response that appropriately completes the request.\n'
|
| 25 |
-
f'### Instruction:\n{instruction}\n'
|
| 26 |
-
f'### Input:\n{query}\n### Response:'
|
| 27 |
-
)
|
| 28 |
-
return prompt
|
| 29 |
-
```
|
| 30 |
-
|
| 31 |
-
And then run the following codes to execute translation:
|
| 32 |
-
```angular2html
|
| 33 |
-
from transformers import AutoTokenizer, LlamaForCausalLM
|
| 34 |
-
|
| 35 |
-
model = LlamaForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
|
| 36 |
-
tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
|
| 37 |
-
|
| 38 |
-
query = "你好,今天是个好日子"
|
| 39 |
-
prompt = Prompt_template(query, 'Chinese', 'English')
|
| 40 |
-
inputs = tokenizer(prompt, return_tensors="pt")
|
| 41 |
-
|
| 42 |
-
generate_ids = model.generate(inputs.input_ids, max_length=30)
|
| 43 |
-
tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 44 |
-
# => "Hello, today is a good day"
|
| 45 |
-
```
|
| 46 |
-
|
| 47 |
### 🔥 Effective Base Model for Multilingual Task
|
| 48 |
|
| 49 |
LLaMAX preserves its efficacy in general tasks and improves the performance on multilingual tasks.
|
|
|
|
| 12 |
Its translation capabilities far exceed general models of the same scale, and it can serve as a base model to support downstream multilingual tasks.
|
| 13 |
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
### 🔥 Effective Base Model for Multilingual Task
|
| 16 |
|
| 17 |
LLaMAX preserves its efficacy in general tasks and improves the performance on multilingual tasks.
|