OmniAICreator/Japanese-Roleplay-Dialogues
Viewer • Updated • 28.5k • 216 • 16
How to use Aratako/Oumuamua-7b-instruct-v2-RP with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Aratako/Oumuamua-7b-instruct-v2-RP")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Aratako/Oumuamua-7b-instruct-v2-RP")
model = AutoModelForCausalLM.from_pretrained("Aratako/Oumuamua-7b-instruct-v2-RP", device_map="auto")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use Aratako/Oumuamua-7b-instruct-v2-RP with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Aratako/Oumuamua-7b-instruct-v2-RP"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Aratako/Oumuamua-7b-instruct-v2-RP",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Aratako/Oumuamua-7b-instruct-v2-RP
How to use Aratako/Oumuamua-7b-instruct-v2-RP with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Aratako/Oumuamua-7b-instruct-v2-RP" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Aratako/Oumuamua-7b-instruct-v2-RP",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "Aratako/Oumuamua-7b-instruct-v2-RP" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Aratako/Oumuamua-7b-instruct-v2-RP",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Aratako/Oumuamua-7b-instruct-v2-RP with Docker Model Runner:
docker model run hf.co/Aratako/Oumuamua-7b-instruct-v2-RP
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 "Aratako/Oumuamua-7b-instruct-v2-RP" \
--host 0.0.0.0 \
--port 30000# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Aratako/Oumuamua-7b-instruct-v2-RP",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'nitky/Oumuamua-7b-instruct-v2をロールプレイ用にLoRAでファインチューニングしたモデルです。
以下のようなchat templateを利用してください。(Alpacaの改変版)
{ロールプレイの指示、世界観・あらすじの説明、キャラの設定など}
### 入力:
こんにちは。
### 応答:
こんにちは!</s>
### 入力:
今日はいい天気ですね。
### 応答:
また、マルチターンの対話を行う場合、各ターンのアシスタントの応答の末尾にeos tokenを必ずつけてください。
RunpodでGPUサーバを借り、A6000x4で学習を行いました。学習データをクオリティの高いものと低いものに2分し、2段階に分けて学習しています。
まず、比較的クオリティの低いデータセットで1回学習を行いました。 利用データセットは以下の通りです。
学習パラメータは以下の通りです。
次に、クオリティの高いデータセットで学習を行いました。この2回目の学習は、completion onlyな学習ではなく、instruction部分もloss計算に入れる手法を取り入れています。また、事前学習で使われるようなinstruction形式ではないデータセットも全体の20%程度混ぜています。 利用データセットは以下の通りです。
学習パラメータは以下の通りです。
Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Aratako/Oumuamua-7b-instruct-v2-RP" \ --host 0.0.0.0 \ --port 30000# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aratako/Oumuamua-7b-instruct-v2-RP", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'