Ethical-Lens: Curbing Malicious Usages of Open-Source Text-to-Image Models
Paper • 2404.12104 • Published • 1
How to use Ethical-Lens/Text-Scrutiny-LLM with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Ethical-Lens/Text-Scrutiny-LLM", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("Ethical-Lens/Text-Scrutiny-LLM", trust_remote_code=True, dtype="auto")How to use Ethical-Lens/Text-Scrutiny-LLM with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Ethical-Lens/Text-Scrutiny-LLM"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Ethical-Lens/Text-Scrutiny-LLM",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Ethical-Lens/Text-Scrutiny-LLM
How to use Ethical-Lens/Text-Scrutiny-LLM with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Ethical-Lens/Text-Scrutiny-LLM" \
--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": "Ethical-Lens/Text-Scrutiny-LLM",
"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 "Ethical-Lens/Text-Scrutiny-LLM" \
--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": "Ethical-Lens/Text-Scrutiny-LLM",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Ethical-Lens/Text-Scrutiny-LLM with Docker Model Runner:
docker model run hf.co/Ethical-Lens/Text-Scrutiny-LLM
# Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("Ethical-Lens/Text-Scrutiny-LLM", trust_remote_code=True, dtype="auto")If you find our work helpful, please use the following citations.
@misc{cai2024ethicallenscurbingmalicioususages,
title={Ethical-Lens: Curbing Malicious Usages of Open-Source Text-to-Image Models},
author={Yuzhu Cai and Sheng Yin and Yuxi Wei and Chenxin Xu and Weibo Mao and Felix Juefei-Xu and Siheng Chen and Yanfeng Wang},
year={2024},
eprint={2404.12104},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2404.12104},
}
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Ethical-Lens/Text-Scrutiny-LLM", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)