Update README.md
Browse files
README.md
CHANGED
@@ -12,6 +12,7 @@ tags:
|
|
12 |
- bio-inspired
|
13 |
- text-generation-inference
|
14 |
- materials science
|
|
|
15 |
pipeline_tag: image-text-to-text
|
16 |
inference:
|
17 |
parameters:
|
@@ -19,7 +20,7 @@ inference:
|
|
19 |
widget:
|
20 |
- messages:
|
21 |
- role: user
|
22 |
-
content:
|
23 |
library_name: transformers
|
24 |
---
|
25 |
## Model Summary
|
@@ -36,22 +37,20 @@ The model is developed to process diverse inputs, including images and text, fac
|
|
36 |
|
37 |
Cephalo provides a robust framework for multimodal interaction and understanding, including the development of complex generative pipelines to create 2D and 3D renderings of material microstructures as input for additive manufacturing methods.
|
38 |
|
39 |
-
This version of Cephalo, lamm-mit/Cephalo-
|
40 |
|
41 |
### Chat Format
|
42 |
|
43 |
-
Given the nature of the training data, the Cephalo-
|
44 |
|
45 |
-
You can provide the prompt as a single image with a generic template as follow:
|
46 |
```markdown
|
47 |
-
|
48 |
```
|
49 |
|
50 |
-
The model generates the text after
|
51 |
|
52 |
```markdown
|
53 |
-
|
54 |
-
```
|
55 |
|
56 |
### Sample inference code
|
57 |
|
@@ -60,17 +59,21 @@ This code snippets show how to get quickly started on a GPU:
|
|
60 |
```python
|
61 |
from PIL import Image
|
62 |
import requests
|
63 |
-
from transformers import
|
64 |
from transformers import AutoProcessor
|
65 |
|
66 |
-
model_id
|
67 |
-
|
68 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="cuda", trust_remote_code=True, torch_dtype="auto")
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
messages = [
|
73 |
-
{"role": "user", "content": "
|
74 |
]
|
75 |
|
76 |
url = "https://d2r55xnwy6nx47.cloudfront.net/uploads/2018/02/Ants_Lede1300.jpg"
|
@@ -85,8 +88,7 @@ generation_args = {
|
|
85 |
"max_new_tokens": 512,
|
86 |
"temperature": 0.1,
|
87 |
"do_sample": True,
|
88 |
-
"stop_strings": ['
|
89 |
-
'<|endoftext|>'],
|
90 |
"tokenizer": processor.tokenizer,
|
91 |
}
|
92 |
|
@@ -104,9 +106,10 @@ Sample output:
|
|
104 |
<small>Image by [Vaishakh Manohar](https://www.quantamagazine.org/the-simple-algorithm-that-ants-use-to-build-bridges-20180226/)</small>
|
105 |
|
106 |
<pre style="white-space: pre-wrap;">
|
107 |
-
The image shows
|
108 |
-
</pre>
|
109 |
|
|
|
|
|
110 |
|
111 |
## Dataset generation
|
112 |
|
|
|
12 |
- bio-inspired
|
13 |
- text-generation-inference
|
14 |
- materials science
|
15 |
+
- Llava-NEXT
|
16 |
pipeline_tag: image-text-to-text
|
17 |
inference:
|
18 |
parameters:
|
|
|
20 |
widget:
|
21 |
- messages:
|
22 |
- role: user
|
23 |
+
content: <s>[INST] <image>\nDescribe what you see in the image. [/INST]
|
24 |
library_name: transformers
|
25 |
---
|
26 |
## Model Summary
|
|
|
37 |
|
38 |
Cephalo provides a robust framework for multimodal interaction and understanding, including the development of complex generative pipelines to create 2D and 3D renderings of material microstructures as input for additive manufacturing methods.
|
39 |
|
40 |
+
This version of Cephalo, lamm-mit/Cephalo-Llava-v1.6-Mistral-8b-alpha, is based on the Llava-v1.6-Mistral-8b-alpha model. Further details, see: https://huggingface.co/llava-hf/llava-v1.6-mistral-7b-hf.
|
41 |
|
42 |
### Chat Format
|
43 |
|
44 |
+
Given the nature of the training data, the lamm-mit/Cephalo-Llava-v1.6-Mistral-8b-alpha model is best suited for the chat format as follows.
|
45 |
|
|
|
46 |
```markdown
|
47 |
+
<s>[INST] <image>\nQuestion 1 [/INST]Answer 2</s>
|
48 |
```
|
49 |
|
50 |
+
The model generates the text after `[/INST]`. For multi-turn conversations, the prompt should be formatted as follows:
|
51 |
|
52 |
```markdown
|
53 |
+
<s>[INST] <image>\nQuestion 1 [/INST]Answer 1</s>[INST] Question 2 [/INST]Answer 2</s>```
|
|
|
54 |
|
55 |
### Sample inference code
|
56 |
|
|
|
59 |
```python
|
60 |
from PIL import Image
|
61 |
import requests
|
62 |
+
from transformers import LlavaNextForConditionalGeneration
|
63 |
from transformers import AutoProcessor
|
64 |
|
65 |
+
model_id='lamm-mit/Cephalo-Llava-v1.6-Mistral-8b-alpha'
|
|
|
|
|
66 |
|
67 |
+
model = LlavaNextForConditionalGeneration.from_pretrained(model_id,
|
68 |
+
torch_dtype=torch.bfloat16,
|
69 |
+
_attn_implementation="flash_attention_2",
|
70 |
+
).to (DEVICE )
|
71 |
+
processor = AutoProcessor.from_pretrained(
|
72 |
+
model_id,
|
73 |
+
)
|
74 |
|
75 |
messages = [
|
76 |
+
{"role": "user", "content": "<image>\nWhat is shown in this image, and what is the relevance for materials design?"},
|
77 |
]
|
78 |
|
79 |
url = "https://d2r55xnwy6nx47.cloudfront.net/uploads/2018/02/Ants_Lede1300.jpg"
|
|
|
88 |
"max_new_tokens": 512,
|
89 |
"temperature": 0.1,
|
90 |
"do_sample": True,
|
91 |
+
"stop_strings": ['</s>',],
|
|
|
92 |
"tokenizer": processor.tokenizer,
|
93 |
}
|
94 |
|
|
|
106 |
<small>Image by [Vaishakh Manohar](https://www.quantamagazine.org/the-simple-algorithm-that-ants-use-to-build-bridges-20180226/)</small>
|
107 |
|
108 |
<pre style="white-space: pre-wrap;">
|
109 |
+
The image shows an ant colony in the process of building a bridge between two surfaces. The ants are working together to construct a pathway using their bodies as scaffolding. This demonstrates the concept of cooperative construction in nature, where individual ants contribute to the overall structure.
|
|
|
110 |
|
111 |
+
The relevance for materials design lies in the efficiency and precision of the ant's construction. The ants are able to create a strong and stable bridge with minimal material usage, which can inspire the development of new construction techniques in materials science. The image highlights the importance of collaboration and the use of natural principles in engineering design.
|
112 |
+
</pre>
|
113 |
|
114 |
## Dataset generation
|
115 |
|