myownskyW7
commited on
Commit
•
e447636
1
Parent(s):
61a07f5
Update README.md
Browse files
README.md
CHANGED
@@ -20,6 +20,43 @@ pipeline_tag: visual-question-answering
|
|
20 |
|
21 |
**InternLM-XComposer2.5-OL**, a specialized generalist multimodal system for streaming video and audio interactions.
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
|
25 |
## Quickstart
|
|
|
20 |
|
21 |
**InternLM-XComposer2.5-OL**, a specialized generalist multimodal system for streaming video and audio interactions.
|
22 |
|
23 |
+
### Import from Transformers
|
24 |
+
To load the base LLM model using Transformers, use the following code:
|
25 |
+
```python
|
26 |
+
import torch
|
27 |
+
from transformers import AutoModel, AutoTokenizer
|
28 |
+
|
29 |
+
torch.set_grad_enabled(False)
|
30 |
+
|
31 |
+
# init model and tokenizer
|
32 |
+
model = AutoModel.from_pretrained('internlm/internlm-xcomposer2d5-ol-7b', model_dir='base', torch_dtype=torch.bfloat16, trust_remote_code=True).cuda().eval().half()
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained('internlm/internlm-xcomposer2d5-ol-7b', model_dir='base', trust_remote_code=True)
|
34 |
+
model.tokenizer = tokenizer
|
35 |
+
```
|
36 |
+
|
37 |
+
To load the base audio model using MS-Swift, use the following code:
|
38 |
+
```python
|
39 |
+
import os
|
40 |
+
os.environ['USE_HF'] = 'True'
|
41 |
+
|
42 |
+
import torch
|
43 |
+
from swift.llm import (
|
44 |
+
get_model_tokenizer, get_template, ModelType,
|
45 |
+
get_default_template_type, inference
|
46 |
+
)
|
47 |
+
from swift.utils import seed_everything
|
48 |
+
|
49 |
+
model_type = ModelType.qwen2_audio_7b_instruct
|
50 |
+
model_id_or_path = 'internlm/internlm-xcomposer2d5-ol-7b'
|
51 |
+
template_type = get_default_template_type(model_type)
|
52 |
+
print(f'template_type: {template_type}')
|
53 |
+
|
54 |
+
model, tokenizer = get_model_tokenizer(model_type, torch.float16, model_id_or_path=model_id_or_path, model_dir='audio',
|
55 |
+
model_kwargs={'device_map': 'cuda:0'})
|
56 |
+
model.generation_config.max_new_tokens = 256
|
57 |
+
template = get_template(template_type, tokenizer)
|
58 |
+
seed_everything(42)
|
59 |
+
```
|
60 |
|
61 |
|
62 |
## Quickstart
|