Instructions to use watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron") model = AutoModelForMultimodalLM.from_pretrained("watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron
- SGLang
How to use watashiha/Watashiha-Llama-2-13B-Ogiri-sft-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 "watashiha/Watashiha-Llama-2-13B-Ogiri-sft-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": "watashiha/Watashiha-Llama-2-13B-Ogiri-sft-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 "watashiha/Watashiha-Llama-2-13B-Ogiri-sft-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": "watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron with Docker Model Runner:
docker model run hf.co/watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron
The English document is here
モデル概要
Watashiha-Llama-2-13B-Ogiri-sftをAWSのinf2インスタンスで動作するようにコンパイルされたモデルです。
コンパイルは以下の記事を参考に行いました。
https://huggingface.co/docs/optimum-neuron/tutorials/llama2-13b-chatbot
- License: LLAMA 2 COMMUNITY LICENSE
使用方法
AWS EC2でinf2.xlargeのインスタンスを立てる。
モデルのダウンロードで50GBほど必要になるので、ストレージのサイズは256GB以上に設定しておくのをおすすめします。
AMIは以下のものを使用してください。
Deep Learning AMI Neuron PyTorch 1.13 (Ubuntu 20.04) 20240102以下のコマンドを実行し、用意されているpython環境を有効にする。
source /opt/aws_neuron_venv_pytorch/bin/activate
- optimumをインストールする。
pip install optimum[neuronx]
- 上記の手順を終えたら、以下のソースコードを実行。
from optimum.neuron import NeuronModelForCausalLM
from transformers import AutoTokenizer
model_name = "watashiha/Watashiha-Llama-2-13B-Ogiri-sft-neuron"
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)
model = NeuronModelForCausalLM.from_pretrained(model_name)
odai = "マジシャンのショーでアシスタントが消えたまま戻ってこない時の一言。"
text = f"""
以下は、タスクを説明する指示と、文脈のある入力の組み合わせです。要求を適切に満たす応答を書きなさい。
### 指示:
入力の文は大喜利のお題です。お題に沿った面白いボケを生成してください。
### 入力:
{odai}
### 応答:
"""
text = text.lstrip()
token_ids = tokenizer.encode(text, return_tensors="pt")
input_len = token_ids.shape[1]
output_ids = model.generate(
token_ids,
max_length=input_len + 64,
do_sample=True,
top_p=0.9,
top_k=50,
temperature=0.8,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
)
output = tokenizer.decode(output_ids.tolist()[0], skip_special_tokens=True)
print(output)
"""
以下は、タスクを説明する指示と、文脈のある入力の組み合わせです。要求を適切に満たす応答を書きなさい。
### 指示:
入力の文は大喜利のお題です。お題に沿った面白いボケを生成してください。
### 入力:
マジシャンのショーでアシスタントが消えたまま戻ってこない時の一言。
### 応答:
もうアシスタントいらなくない?
"""
コンパイルのパラメータ
input_shapes
{
"batch_size": 1,
"sequence_length": 1024,
}
compiler_args
{
"num_cores": 2,
"auto_cast_type": 'bf16',
}
- Downloads last month
- 4