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 = {}
|