Instructions to use jburtoft/TencentARC-LLaMA-Pro-8B-Neuron with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jburtoft/TencentARC-LLaMA-Pro-8B-Neuron with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jburtoft/TencentARC-LLaMA-Pro-8B-Neuron")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jburtoft/TencentARC-LLaMA-Pro-8B-Neuron") model = AutoModelForCausalLM.from_pretrained("jburtoft/TencentARC-LLaMA-Pro-8B-Neuron", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jburtoft/TencentARC-LLaMA-Pro-8B-Neuron with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jburtoft/TencentARC-LLaMA-Pro-8B-Neuron" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jburtoft/TencentARC-LLaMA-Pro-8B-Neuron", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/jburtoft/TencentARC-LLaMA-Pro-8B-Neuron
- SGLang
How to use jburtoft/TencentARC-LLaMA-Pro-8B-Neuron 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 "jburtoft/TencentARC-LLaMA-Pro-8B-Neuron" \ --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": "jburtoft/TencentARC-LLaMA-Pro-8B-Neuron", "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 "jburtoft/TencentARC-LLaMA-Pro-8B-Neuron" \ --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": "jburtoft/TencentARC-LLaMA-Pro-8B-Neuron", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use jburtoft/TencentARC-LLaMA-Pro-8B-Neuron with Docker Model Runner:
docker model run hf.co/jburtoft/TencentARC-LLaMA-Pro-8B-Neuron
Update README.md
Browse filesInitial commit with just notes
README.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
| 1 |
---
|
| 2 |
license: llama2
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: llama2
|
| 3 |
---
|
| 4 |
+
Quick notes--what I did to get to this point
|
| 5 |
+
|
| 6 |
+
```
|
| 7 |
+
from optimum.neuron import NeuronModelForCausalLM
|
| 8 |
+
from transformers import AutoTokenizer
|
| 9 |
+
model_id = "TencentARC/LLaMA-Pro-8B"
|
| 10 |
+
compiler_args = {"num_cores": 2, "auto_cast_type": "fp16"}
|
| 11 |
+
input_shapes = {"sequence_length": 2048, "batch_size": 2 }
|
| 12 |
+
llm = NeuronModelForCausalLM.from_pretrained(model_id, export=True, **input_shapes, **compiler_args)
|
| 13 |
+
save_directory = "Tencent_neuron"
|
| 14 |
+
|
| 15 |
+
llm.save_pretrained(save_directory)
|
| 16 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 17 |
+
|
| 18 |
+
tokenizer.save_pretrained(save_directory)
|
| 19 |
+
|
| 20 |
+
quit()
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
```
|
| 24 |
+
from optimum.neuron import pipeline
|
| 25 |
+
|
| 26 |
+
# Load pipeline from Hugging Face repository
|
| 27 |
+
save_directory = "Tencent_neuron"
|
| 28 |
+
|
| 29 |
+
pipe = pipeline("text-generation", save_directory)
|
| 30 |
+
|
| 31 |
+
# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
|
| 32 |
+
messages = [
|
| 33 |
+
{"role": "user", "content": "What is 2+2?"},
|
| 34 |
+
]
|
| 35 |
+
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 36 |
+
# Run generation
|
| 37 |
+
outputs = pipe(prompt, max_new_tokens=2048, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
| 38 |
+
print(outputs[0]["generated_text"])
|
| 39 |
+
|
| 40 |
+
```
|
| 41 |
+
```
|
| 42 |
+
from huggingface_hub import login
|
| 43 |
+
from huggingface_hub import HfApi
|
| 44 |
+
api = HfApi()
|
| 45 |
+
login()
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
save_directory = "Tencent_neuron"
|
| 49 |
+
|
| 50 |
+
api.upload_folder(
|
| 51 |
+
folder_path=save_directory,
|
| 52 |
+
repo_id="jburtoft/TencentARC-LLaMA-Pro-8B-Neuron",
|
| 53 |
+
repo_type="model",
|
| 54 |
+
multi_commits=True,
|
| 55 |
+
multi_commits_verbose=True,
|
| 56 |
+
)
|
| 57 |
+
```
|