Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
textmonkey_pytorch
Commits
b3abac2e
Unverified
Commit
b3abac2e
authored
Feb 02, 2024
by
echo840
Committed by
GitHub
Feb 02, 2024
Browse files
Update README_cn.md
parent
70401ea6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
README_cn.md
README_cn.md
+36
-0
No files found.
README_cn.md
View file @
b3abac2e
...
...
@@ -154,6 +154,42 @@ Monkey训练使用的json文件可以在[链接](https://drive.google.com/file/d
-
添加LoRA:需要将
```model_qwen.py```
的内容替换为
```model_qwen_nvdia3090.py```
的内容
-
冻结LLM:需要在
```finetune_multitask.py```
中冻结除LoRA和Resampler模块的其他模块
## 推理
```
python
from
transformers
import
AutoModelForCausalLM
,
AutoTokenizer
checkpoint
=
"echo840/Monkey"
model
=
AutoModelForCausalLM
.
from_pretrained
(
checkpoint
,
device_map
=
'cuda'
,
trust_remote_code
=
True
).
eval
()
tokenizer
=
AutoTokenizer
.
from_pretrained
(
checkpoint
,
trust_remote_code
=
True
)
tokenizer
.
padding_side
=
'left'
tokenizer
.
pad_token_id
=
tokenizer
.
eod_id
img_path
=
""
question
=
""
query
=
f
'<img>
{
img_path
}
</img>
{
question
}
Answer: '
#VQA
# query = f'<img>{img_path}</img> Generate the detailed caption in English: ' #detailed caption
input_ids
=
tokenizer
(
query
,
return_tensors
=
'pt'
,
padding
=
'longest'
)
attention_mask
=
input_ids
.
attention_mask
input_ids
=
input_ids
.
input_ids
pred
=
model
.
generate
(
input_ids
=
input_ids
.
cuda
(),
attention_mask
=
attention_mask
.
cuda
(),
do_sample
=
False
,
num_beams
=
1
,
max_new_tokens
=
512
,
min_new_tokens
=
1
,
length_penalty
=
1
,
num_return_sequences
=
1
,
output_hidden_states
=
True
,
use_cache
=
True
,
pad_token_id
=
tokenizer
.
eod_id
,
eos_token_id
=
tokenizer
.
eod_id
,
)
response
=
tokenizer
.
decode
(
pred
[
0
][
input_ids
.
size
(
1
):].
cpu
(),
skip_special_tokens
=
True
).
strip
()
print
(
response
)
```
## 性能
<br>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment