Image-Text-to-Text
Transformers
Safetensors
English
safe_llava_llama
text-generation
vision
multimodal
safety
content-moderation
llava
image-classification
vision-language
custom_code
Instructions to use etri-vilab/SafeLLaVA-13B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use etri-vilab/SafeLLaVA-13B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="etri-vilab/SafeLLaVA-13B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("etri-vilab/SafeLLaVA-13B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use etri-vilab/SafeLLaVA-13B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "etri-vilab/SafeLLaVA-13B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "etri-vilab/SafeLLaVA-13B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/etri-vilab/SafeLLaVA-13B
- SGLang
How to use etri-vilab/SafeLLaVA-13B 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 "etri-vilab/SafeLLaVA-13B" \ --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": "etri-vilab/SafeLLaVA-13B", "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 "etri-vilab/SafeLLaVA-13B" \ --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": "etri-vilab/SafeLLaVA-13B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use etri-vilab/SafeLLaVA-13B with Docker Model Runner:
docker model run hf.co/etri-vilab/SafeLLaVA-13B
Upload folder using huggingface_hub
Browse files
safellava/model/language_model/safe_llava_llama.py
CHANGED
|
@@ -5,15 +5,15 @@ import torch.nn as nn
|
|
| 5 |
from transformers import AutoConfig, AutoModelForCausalLM
|
| 6 |
from transformers.modeling_outputs import CausalLMOutputWithPast
|
| 7 |
|
| 8 |
-
from
|
| 9 |
LlavaConfig, LlavaLlamaModel, LlavaLlamaForCausalLM
|
| 10 |
)
|
| 11 |
-
from
|
| 12 |
|
| 13 |
from dataclasses import dataclass
|
| 14 |
|
| 15 |
import logging
|
| 16 |
-
from
|
| 17 |
|
| 18 |
setup_simple_logging()
|
| 19 |
|
|
|
|
| 5 |
from transformers import AutoConfig, AutoModelForCausalLM
|
| 6 |
from transformers.modeling_outputs import CausalLMOutputWithPast
|
| 7 |
|
| 8 |
+
from safellava.model.language_model.llava_llama import (
|
| 9 |
LlavaConfig, LlavaLlamaModel, LlavaLlamaForCausalLM
|
| 10 |
)
|
| 11 |
+
from safellava.constants import IMAGE_TOKEN_INDEX
|
| 12 |
|
| 13 |
from dataclasses import dataclass
|
| 14 |
|
| 15 |
import logging
|
| 16 |
+
from safellava.utils import setup_simple_logging
|
| 17 |
|
| 18 |
setup_simple_logging()
|
| 19 |
|