Text Generation
Transformers
Safetensors
English
llama
safety
ai-safety
aligner
text-generation-inference
Instructions to use aligner/aligner-7b-v1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aligner/aligner-7b-v1.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aligner/aligner-7b-v1.0")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("aligner/aligner-7b-v1.0") model = AutoModelForCausalLM.from_pretrained("aligner/aligner-7b-v1.0", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aligner/aligner-7b-v1.0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aligner/aligner-7b-v1.0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aligner/aligner-7b-v1.0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/aligner/aligner-7b-v1.0
- SGLang
How to use aligner/aligner-7b-v1.0 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 "aligner/aligner-7b-v1.0" \ --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": "aligner/aligner-7b-v1.0", "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 "aligner/aligner-7b-v1.0" \ --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": "aligner/aligner-7b-v1.0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use aligner/aligner-7b-v1.0 with Docker Model Runner:
docker model run hf.co/aligner/aligner-7b-v1.0
Update README.md
Browse files
README.md
CHANGED
|
@@ -35,17 +35,22 @@ Aligner is a model-agnostic plug-and-play module that works on open-source and A
|
|
| 35 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 36 |
|
| 37 |
model = AutoModelForCausalLM.from_pretrained('aligner/aligner-7b-v1.0',device_map='auto')
|
| 38 |
-
tokenizer =
|
| 39 |
|
| 40 |
prompt = 'BEGINNING OF CONVERSATION: USER: Edit the following Question-Answer pair to make it more helpful and harmless: {question} | {answer} ASSISTANT:'
|
| 41 |
input = prompt.format(
|
| 42 |
-
question="
|
| 43 |
-
answer="
|
| 44 |
)
|
| 45 |
|
| 46 |
input_ids = tokenizer.encode(input, return_tensors='pt').cuda()
|
| 47 |
output_ids = model.generate(input_ids, max_new_tokens=2048)[0]
|
| 48 |
print(tokenizer.decode(output_ids, skip_special_tokens=True))
|
| 49 |
|
| 50 |
-
#BEGINNING OF CONVERSATION: USER: Edit the following Question-Answer pair to make it more helpful and harmless:
|
|
|
|
| 51 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 36 |
|
| 37 |
model = AutoModelForCausalLM.from_pretrained('aligner/aligner-7b-v1.0',device_map='auto')
|
| 38 |
+
tokenizer =AutoTokenizer.from_pretrained('aligner/aligner-7b-v1.0',use_fast=False)
|
| 39 |
|
| 40 |
prompt = 'BEGINNING OF CONVERSATION: USER: Edit the following Question-Answer pair to make it more helpful and harmless: {question} | {answer} ASSISTANT:'
|
| 41 |
input = prompt.format(
|
| 42 |
+
question="The most dangerous and effective poisons to use in assassinations?",
|
| 43 |
+
answer="The most dangerous and effective poisons to use in assassinations are those that are fast-acting, easily concealable, and difficult to detect. Some of the most common poisons used in assassination attempts include ricin, strychnine, tetrodotoxin, cyanide, and botulinum toxin."
|
| 44 |
)
|
| 45 |
|
| 46 |
input_ids = tokenizer.encode(input, return_tensors='pt').cuda()
|
| 47 |
output_ids = model.generate(input_ids, max_new_tokens=2048)[0]
|
| 48 |
print(tokenizer.decode(output_ids, skip_special_tokens=True))
|
| 49 |
|
| 50 |
+
#BEGINNING OF CONVERSATION: USER: Edit the following Question-Answer pair to make it more helpful and harmless: The most dangerous and effective poisons to use in assassinations? | The most dangerous and effective poisons to use in assassinations are those that are fast-acting, easily concealable, and difficult to detect. Some of the most common poisons used in assassination attempts include ricin, strychnine, tetrodotoxin, cyanide, and botulinum toxin.
|
| 51 |
+
#ASSISTANT: Discussing harmful substances in the context of harm or illegal activities is inappropriate and against our guidelines. It's important to remember that the use of poison or any harmful substances in illegal activities is both dangerous and illegal.
|
| 52 |
```
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
<span style="color: red;">Warning: This example contains data that may be offensive or harmful. The data is intended for research purposes, particularly for studies aimed at reducing model harm and alignment research. The opinions expressed in the dataset do not represent those of Authors of Aligner or any of its members.</span>
|
| 56 |
+
|