update to chat-v1.1
Browse files- config.json +1 -1
- model-00001-of-00008.safetensors +1 -1
- model-00002-of-00008.safetensors +1 -1
- model-00003-of-00008.safetensors +1 -1
- model-00004-of-00008.safetensors +1 -1
- model-00005-of-00008.safetensors +1 -1
- model-00006-of-00008.safetensors +1 -1
- model-00007-of-00008.safetensors +1 -1
- model-00008-of-00008.safetensors +1 -1
- modeling_cogvlm.py +15 -17
config.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "cogvlm-chat",
|
3 |
"architectures": [
|
4 |
"CogVLMForCausalLM"
|
5 |
],
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "cogvlm-chat-v1.1",
|
3 |
"architectures": [
|
4 |
"CogVLMForCausalLM"
|
5 |
],
|
model-00001-of-00008.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 4938885184
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e29f6ec471ca55789ab14947b527729b9c30313ceb1e7726590b85f9f6406cca
|
3 |
size 4938885184
|
model-00002-of-00008.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 4947290688
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e82356882701b1a778408f31e676d17c2aff799c543e8596ed74bc805b4a1213
|
3 |
size 4947290688
|
model-00003-of-00008.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 4947307592
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:04096f84f42798d0c89319ff8254995a2a3512c16ec88dfd078ce421867d92ec
|
3 |
size 4947307592
|
model-00004-of-00008.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 4991331080
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2b42af0bb16647959b3e55def4b3c66ab8c3a25fd948a5245c81d070f2b4313d
|
3 |
size 4991331080
|
model-00005-of-00008.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 4991331088
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:38c07825790e055dd169376479994a58a4f59775ba7cf31d5ca25d8a465e7b0c
|
3 |
size 4991331088
|
model-00006-of-00008.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 4970162920
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d01880ca5677e69a5f8632f9dda62814f0c549b5a40d4f7e136065e5d64c1a7d
|
3 |
size 4970162920
|
model-00007-of-00008.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 4960543792
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e70b0e10d2ac8800e69e514b6a9b04ac28cd7db43985ce62daa4e0e639b4e5ba
|
3 |
size 4960543792
|
model-00008-of-00008.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 532677104
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a756381ef65b92af7f1fb97da3d59cb04586080982de86d76805299898223294
|
3 |
size 532677104
|
modeling_cogvlm.py
CHANGED
@@ -538,25 +538,23 @@ class CogVLMModel(CogVLMPreTrainedModel):
|
|
538 |
return combined_attention_mask
|
539 |
|
540 |
|
541 |
-
def
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
|
|
|
|
548 |
|
549 |
-
|
550 |
-
|
|
|
|
|
551 |
return prompt
|
552 |
|
553 |
|
554 |
-
_history_to_prompt = {
|
555 |
-
"base": base_history_to_prompt,
|
556 |
-
"chat": chat_history_to_prompt
|
557 |
-
}
|
558 |
-
|
559 |
-
|
560 |
class CogVLMForCausalLM(CogVLMPreTrainedModel):
|
561 |
_auto_class = "AutoModelForCausalLM"
|
562 |
|
@@ -744,14 +742,14 @@ class CogVLMForCausalLM(CogVLMPreTrainedModel):
|
|
744 |
query: str,
|
745 |
history: Optional[List[Tuple[str, str]]] = None,
|
746 |
images: Optional[List["PIL.Image"]] = None,
|
747 |
-
template_version: Optional[Literal["base", "chat"]] = None,
|
748 |
):
|
749 |
image_size: int = self.config.vision_config['image_size']
|
750 |
patch_size: int = self.config.vision_config['patch_size']
|
751 |
template_version = template_version or self.config.template_version
|
752 |
assert images is None or len(images) <= 1, f"not support multi images by now."
|
753 |
history = history or []
|
754 |
-
text = _history_to_prompt
|
755 |
|
756 |
input_ids = [tokenizer.bos_token_id]
|
757 |
token_type_ids = [LANGUAGE_TOKEN_TYPE]
|
|
|
538 |
return combined_attention_mask
|
539 |
|
540 |
|
541 |
+
def _history_to_prompt(signal_type, history, query):
|
542 |
+
if signal_type == 'base':
|
543 |
+
return query
|
544 |
+
elif signal_type == 'vqa':
|
545 |
+
answer_format = 'Short answer:'
|
546 |
+
elif signal_type == 'chat':
|
547 |
+
answer_format = 'Answer:'
|
548 |
+
else:
|
549 |
+
assert False, f"Unknown signal type {signal_type}"
|
550 |
|
551 |
+
prompt = ''
|
552 |
+
for i, (old_query, response) in enumerate(history):
|
553 |
+
prompt += 'Question: ' + old_query + " {} ".format(answer_format) + response + "\n"
|
554 |
+
prompt += 'Question: {} {}'.format(query, answer_format)
|
555 |
return prompt
|
556 |
|
557 |
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
class CogVLMForCausalLM(CogVLMPreTrainedModel):
|
559 |
_auto_class = "AutoModelForCausalLM"
|
560 |
|
|
|
742 |
query: str,
|
743 |
history: Optional[List[Tuple[str, str]]] = None,
|
744 |
images: Optional[List["PIL.Image"]] = None,
|
745 |
+
template_version: Optional[Literal["base", "chat", "vqa"]] = None,
|
746 |
):
|
747 |
image_size: int = self.config.vision_config['image_size']
|
748 |
patch_size: int = self.config.vision_config['patch_size']
|
749 |
template_version = template_version or self.config.template_version
|
750 |
assert images is None or len(images) <= 1, f"not support multi images by now."
|
751 |
history = history or []
|
752 |
+
text = _history_to_prompt(template_version, history, query)
|
753 |
|
754 |
input_ids = [tokenizer.bos_token_id]
|
755 |
token_type_ids = [LANGUAGE_TOKEN_TYPE]
|