Instructions to use naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B
- SGLang
How to use naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B 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 "naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B" \ --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": "naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B" \ --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": "naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B with Docker Model Runner:
docker model run hf.co/naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B
dong.hyun commited on
Commit ·
db17193
1
Parent(s): 82f2e21
Update README & remove redundant code
Browse files- README.md +4 -4
- processing_hyperclovax.py +1 -15
README.md
CHANGED
|
@@ -85,7 +85,7 @@ from transformers import AutoModelForCausalLM, AutoProcessor, AutoTokenizer
|
|
| 85 |
|
| 86 |
model_name = "naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B"
|
| 87 |
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True).to(device="cuda")
|
| 88 |
-
|
| 89 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 90 |
|
| 91 |
# LLM Example
|
|
@@ -106,7 +106,7 @@ llm_chat = [
|
|
| 106 |
model_inputs = processor.apply_chat_template(
|
| 107 |
llm_chat, tokenize=True, return_dict=True, return_tensors="pt", add_generation_prompt=True
|
| 108 |
)
|
| 109 |
-
model_inputs = model_inputs.to(device=
|
| 110 |
|
| 111 |
# Please adjust parameters like top_p appropriately for your use case.
|
| 112 |
output_ids = model.generate(
|
|
@@ -165,8 +165,8 @@ vlm_chat = [
|
|
| 165 |
model_inputs = processor.apply_chat_template(
|
| 166 |
vlm_chat, tokenize=True, return_dict=True, return_tensors="pt", add_generation_prompt=True,
|
| 167 |
)
|
| 168 |
-
model_inputs = model_inputs.to(device=
|
| 169 |
-
|
| 170 |
**model_inputs,
|
| 171 |
max_new_tokens=64,
|
| 172 |
do_sample=True,
|
|
|
|
| 85 |
|
| 86 |
model_name = "naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B"
|
| 87 |
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True).to(device="cuda")
|
| 88 |
+
processor = AutoProcessor.from_pretrained(model_name, trust_remote_code=True)
|
| 89 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 90 |
|
| 91 |
# LLM Example
|
|
|
|
| 106 |
model_inputs = processor.apply_chat_template(
|
| 107 |
llm_chat, tokenize=True, return_dict=True, return_tensors="pt", add_generation_prompt=True
|
| 108 |
)
|
| 109 |
+
model_inputs = model_inputs.to(device="cuda")
|
| 110 |
|
| 111 |
# Please adjust parameters like top_p appropriately for your use case.
|
| 112 |
output_ids = model.generate(
|
|
|
|
| 165 |
model_inputs = processor.apply_chat_template(
|
| 166 |
vlm_chat, tokenize=True, return_dict=True, return_tensors="pt", add_generation_prompt=True,
|
| 167 |
)
|
| 168 |
+
model_inputs = model_inputs.to(device="cuda")
|
| 169 |
+
output_ids = model.generate(
|
| 170 |
**model_inputs,
|
| 171 |
max_new_tokens=64,
|
| 172 |
do_sample=True,
|
processing_hyperclovax.py
CHANGED
|
@@ -136,17 +136,6 @@ class HCXProcessor(ProcessorMixin):
|
|
| 136 |
# vllm needs vision_query_lengths, but we don't need it
|
| 137 |
del model_inputs["vision_query_lengths_images"]
|
| 138 |
del model_inputs["vision_query_lengths_videos"]
|
| 139 |
-
|
| 140 |
-
# # vllm 호환성을 위해 이곳에서 token 을 vision_query_length만큼 늘리기 처리
|
| 141 |
-
# if "input_ids" in model_inputs:
|
| 142 |
-
# # self.image_token 모두 찾기
|
| 143 |
-
# input_ids = self.repeat_dummy_tokens(
|
| 144 |
-
# model_inputs["input_ids"], self.image_token_id, model_inputs["vision_query_lengths_images"]
|
| 145 |
-
# )
|
| 146 |
-
# input_ids = self.repeat_dummy_tokens(
|
| 147 |
-
# input_ids, self.video_token_id, model_inputs["vision_query_lengths_videos"]
|
| 148 |
-
# )
|
| 149 |
-
# model_inputs["input_ids"] = input_ids
|
| 150 |
|
| 151 |
return model_inputs
|
| 152 |
|
|
@@ -439,10 +428,7 @@ class HCXProcessor(ProcessorMixin):
|
|
| 439 |
def _replacer(match_obj):
|
| 440 |
# return self.image_token
|
| 441 |
num_query_tokens = next(_iterator)
|
| 442 |
-
return "".join(
|
| 443 |
-
[_target_token for _ in range(num_query_tokens)]
|
| 444 |
-
) # vision_query_legnth 만큼 image token 을 복제
|
| 445 |
-
|
| 446 |
return _replacer
|
| 447 |
|
| 448 |
text_inputs = {}
|
|
|
|
| 136 |
# vllm needs vision_query_lengths, but we don't need it
|
| 137 |
del model_inputs["vision_query_lengths_images"]
|
| 138 |
del model_inputs["vision_query_lengths_videos"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
return model_inputs
|
| 141 |
|
|
|
|
| 428 |
def _replacer(match_obj):
|
| 429 |
# return self.image_token
|
| 430 |
num_query_tokens = next(_iterator)
|
| 431 |
+
return "".join([_target_token for _ in range(num_query_tokens)])
|
|
|
|
|
|
|
|
|
|
| 432 |
return _replacer
|
| 433 |
|
| 434 |
text_inputs = {}
|