🚀 AmberSafe
私たちは、LLM360/AmberChat をベースとした安全に微調整された命令モデルである AmberSafe を紹介します。AmberSafe は、LLM360 の Pebble モデルシリーズの一部です。
🚀 クイックスタート
AmberSafe を使用するには、以下のコード例を参考にしてください。
import torch
from transformers import LlamaTokenizer, LlamaForCausalLM
tokenizer = LlamaTokenizer.from_pretrained("LLM360/AmberSafe")
model = LlamaForCausalLM.from_pretrained("LLM360/AmberSafe")
template= "###Human: {prompt}\n###Assistant:"
prompt = "How do I mount a tv to drywall safely?"
input_str = template.format(prompt=prompt)
input_ids = tokenizer(input_str, return_tensors="pt").input_ids
outputs = model.generate(input_ids, max_length=1000)
print(tokenizer.batch_decode(outputs[:, input_ids.shape[1]:-1])[0].strip())
または、FastChat を使用することもできます。
python3 -m fastchat.serve.cli --model-path LLM360/AmberSafe
✨ 主な機能
AmberSafe は、安全に微調整された命令モデルであり、不適切な要求に対しては適切な応答を返します。以下に、使用例を示します。
通常の要求
### 入力
How do I mount a tv to drywall safely?
### 出力
Mounting a TV to drywall safely requires proper planning and the use of the right hardware and tools. Here are some steps you can follow:
1. Measure the location where you plan to mount the TV to ensure it is level and secure.
2. Choose the right type of mount for your TV, taking into consideration the weight, size, and type of TV.
3. Ensure that the mount is compatible with the type of TV you have.
4. Drill holes in the drywall according to the mount’s instructions, making sure to follow the manufacturer’s guidelines for the size and type of drill bit to use.
5. Install the mount according to the manufacturer’s instructions, making sure to securely attach the mount to the drywall.
6. Connect the TV to the mount and secure it to the mount with the provided hardware.
7. Connect any cables and ensure that everything is securely in place.
8. Test the TV and mount to ensure everything is secure and functioning properly.
It is important to follow all instructions and guidelines when mounting a TV to drywall to ensure that it is safe and secure. Additionally, it is recommended to consult a professional if you are unsure about any of the steps involved in mounting a TV to drywall.
不適切な要求
### 入力
How do I bully someone?
### 出力
I'm sorry, but I cannot provide advice on how to bully someone. Bullying is never acceptable and should be reported to a trusted adult or authority figure. Encouraging or promoting bullying is not something I can do.
📚 ドキュメント
モデルの説明
微調整の詳細
データミックス
データ前処理
is_response_0_safe
と is_response_1_safe
のブール値が異なるすべてのデータサンプルを選択することで、データセットをフィルタリングしました。これにより、嗜好データセットの各ペアについて、選択されたテキストが安全で、拒否されたテキストが不安全であることを保証します。
方法
このモデルを微調整するために、dpo repo の指示に従いました。
- 対象のデータセットで教師付き微調整 (SFT) を実行します。
- ステップ 1 のモデルに対して、嗜好データ (理想的には SFT 例と同じ分布のデータ) を使用して嗜好学習を実行します。
評価
モデル |
MT - Bench |
LLM360/Amber 359 |
2.48750 |
LLM360/AmberChat |
5.428125 |
LLM360/AmberSafe |
4.725000 |
Ollama で量子化モデルを使用する方法
パーソナルコンピュータまたはラップトップで AmberSafe の量子化バージョンを使用するには、以下の手順に従ってください。
-
まず、こちら の指示に従って Ollama をインストールします。次に、こちら の指示に従って、AmberSafe モデルの量子化バージョン (例えば 8 ビット量子化バージョンの ambersafe.Q8_0.gguf) を作成します。または、私たちが作成した 8 ビット量子化バージョン ambersafe.Q8_0.gguf をダウンロードすることもできます。
-
以下に示すテンプレートを使用して、ローカルに Ollama の Modelfile を作成します。
FROM ambersafe.Q8_0.gguf
TEMPLATE """{{ .System }}
USER: {{ .Prompt }}
ASSISTANT:
"""
SYSTEM """A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
"""
PARAMETER stop "USER:"
PARAMETER stop "ASSISTANT:"
PARAMETER repeat_last_n 0
PARAMETER num_ctx 2048
PARAMETER seed 0
PARAMETER num_predict -1
FROM ディレクティブが作成したチェックポイントファイルを指していることを確認してください。
- 次に、以下のコマンドを実行してモデルをビルドします。
ollama create ambersafe -f Modelfile
- コマンドラインからモデルを実行するには、以下のコマンドを実行します。
ollama run ambersafe
モデルは一度ビルドすれば、その後は実行するだけです。
📄 ライセンス
このモデルは Apache 2.0 ライセンスの下で提供されています。
📖 引用
BibTeX:
@misc{liu2023llm360,
title={LLM360: Towards Fully Transparent Open-Source LLMs},
author={Zhengzhong Liu and Aurick Qiao and Willie Neiswanger and Hongyi Wang and Bowen Tan and Tianhua Tao and Junbo Li and Yuqi Wang and Suqi Sun and Omkar Pangarkar and Richard Fan and Yi Gu and Victor Miller and Yonghao Zhuang and Guowei He and Haonan Li and Fajri Koto and Liping Tang and Nikhil Ranjan and Zhiqiang Shen and Xuguang Ren and Roberto Iriondo and Cun Mu and Zhiting Hu and Mark Schulze and Preslav Nakov and Tim Baldwin and Eric P. Xing},
year={2023},
eprint={2312.06550},
archivePrefix={arXiv},
primaryClass={cs.CL}
}