Upload README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,151 @@
|
|
1 |
---
|
|
|
|
|
|
|
2 |
library_name: transformers
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
|
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
9 |
|
|
|
10 |
|
|
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
19 |
|
20 |
-
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
45 |
|
46 |
-
|
47 |
|
48 |
-
|
|
|
|
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
|
54 |
-
|
55 |
|
56 |
-
[
|
57 |
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
|
61 |
|
62 |
-
|
|
|
|
|
63 |
|
64 |
-
|
|
|
|
|
65 |
|
66 |
-
|
|
|
67 |
|
68 |
-
|
|
|
69 |
|
70 |
-
|
71 |
|
72 |
-
|
73 |
|
74 |
-
|
|
|
75 |
|
76 |
-
## Training Details
|
77 |
|
78 |
-
|
79 |
|
80 |
-
|
81 |
|
82 |
-
|
83 |
|
84 |
-
|
85 |
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
|
88 |
-
|
89 |
|
90 |
-
|
91 |
|
|
|
92 |
|
93 |
-
|
94 |
|
95 |
-
|
96 |
|
97 |
-
|
98 |
|
99 |
-
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- multilingual
|
4 |
+
license: apache-2.0
|
5 |
library_name: transformers
|
6 |
+
datasets:
|
7 |
+
- lamm-mit/Cephalo-Bioinspired-Mechanics-Materials
|
8 |
+
- lamm-mit/Cephalo-Wikipedia-Materials
|
9 |
+
tags:
|
10 |
+
- nlp
|
11 |
+
- code
|
12 |
+
- vision
|
13 |
+
- chemistry
|
14 |
+
- engineering
|
15 |
+
- biology
|
16 |
+
- bio-inspired
|
17 |
+
- text-generation-inference
|
18 |
+
- materials science
|
19 |
+
pipeline_tag: image-text-to-text
|
20 |
+
inference:
|
21 |
+
parameters:
|
22 |
+
temperature: 0.3
|
23 |
+
widget:
|
24 |
+
- messages:
|
25 |
+
- role: user
|
26 |
+
content: <|image_1|>Can you describe what you see in the image?
|
27 |
---
|
28 |
+
## Model Summary
|
29 |
|
30 |
+
Cephalo is a series of multimodal materials science focused vision large language models (V-LLMs) designed to integrate visual and linguistic data for advanced understanding and interaction in human-AI or multi-agent AI frameworks.
|
31 |
|
32 |
+
A novel aspect of Cephalo's development is the innovative dataset generation method. The extraction process employs advanced algorithms to accurately detect and separate images and their corresponding textual descriptions from complex PDF documents. It involves extracting images and captions from PDFs to create well-reasoned image-text pairs, utilizing large language models (LLMs) for natural language processing. These image-text pairs are then refined and validated through LLM-based NLP processing, ensuring high-quality and contextually relevant data for training.
|
33 |
|
34 |
+
Cephalo can interpret complex visual scenes and generating contextually accurate language descriptions and answer queries.
|
35 |
|
36 |
+
The model is developed to process diverse inputs, including images and text, facilitating a broad range of applications such as image captioning, visual question answering, and multimodal content generation. The architecture combines a vision encoder model and an autoregressive transformer to process complex natural language understanding.
|
37 |
|
38 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/623ce1c6b66fedf374859fe7/kl5GWBP9WS0D4uwd1t3S7.png)
|
39 |
|
40 |
+
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.
|
41 |
|
42 |
+
This version of Cephalo, lamm-mit/Cephalo-Phi-3-vision-128k-4b-beta, is based on the Phi-3-Vision-128K-Instruct model. The model was trained on a combination of scientific text-image and text-only data. The model has a context length of 128,000 tokens. Further details, see: https://huggingface.co/microsoft/Phi-3-vision-128k-instruct.
|
43 |
|
44 |
+
### Chat Format
|
45 |
|
46 |
+
Given the nature of the training data, the Cephalo-Phi-3-vision-128k-4b-beta model is best suited for a single image input wih prompts using the chat format as follows.
|
47 |
+
You can provide the prompt as a single image with a generic template as follow:
|
48 |
+
```markdown
|
49 |
+
<|user|>\n<|image_1|>\n{prompt}<|end|>\n<|assistant|>\n
|
50 |
+
```
|
|
|
|
|
51 |
|
52 |
+
where the model generates the text after `<|assistant|>` . For multi-turn conversations, the prompt should be formatted as follows:
|
53 |
|
54 |
+
```markdown
|
55 |
+
<|user|>\n<|image_1|>\n{prompt_1}<|end|>\n<|assistant|>\n{response_1}<|end|>\n<|user|>\n{prompt_2}<|end|>\n<|assistant|>\n
|
56 |
+
```
|
57 |
|
58 |
+
### Sample inference code
|
|
|
|
|
59 |
|
60 |
+
This code snippets show how to get quickly started on a GPU:
|
61 |
|
62 |
+
```python
|
63 |
+
from PIL import Image
|
64 |
+
import requests
|
65 |
+
from transformers import AutoModelForCausalLM
|
66 |
+
from transformers import AutoProcessor
|
67 |
|
68 |
+
model_id = "lamm-mit/Cephalo-Phi-3-vision-128k-4b-beta"
|
69 |
|
70 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="cuda", trust_remote_code=True, torch_dtype="auto")
|
71 |
|
72 |
+
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
73 |
|
74 |
+
question = "What is shown in this image, and what is the relevance for materials design? Include a discussion of multi-agent AI."
|
75 |
|
76 |
+
messages = [
|
77 |
+
{"role": "user", "content": f"<|image_1|>\n{question}"},
|
78 |
+
]
|
79 |
|
80 |
+
url = "https://d2r55xnwy6nx47.cloudfront.net/uploads/2018/02/Ants_Lede1300.jpg"
|
81 |
|
82 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
83 |
|
84 |
+
prompt = processor.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
85 |
|
86 |
+
inputs = processor(prompt, [image], return_tensors="pt").to("cuda:0")
|
87 |
|
88 |
+
generation_args = {
|
89 |
+
"max_new_tokens": 512,
|
90 |
+
"temperature": 0.1,
|
91 |
+
"do_sample": True,
|
92 |
+
"stop_strings": ['<|end|>',
|
93 |
+
'<|endoftext|>'],
|
94 |
+
"tokenizer": processor.tokenizer,
|
95 |
+
}
|
96 |
|
97 |
+
generate_ids = model.generate(**inputs, eos_token_id=processor.tokenizer.eos_token_id, **generation_args)
|
98 |
|
99 |
+
# remove input tokens
|
100 |
+
generate_ids = generate_ids[:, inputs['input_ids'].shape[1]:]
|
101 |
+
response = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
102 |
|
103 |
+
print(response)
|
104 |
+
```
|
105 |
+
Sample output:
|
106 |
|
107 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/623ce1c6b66fedf374859fe7/5n6oRNHrfwHkBX0QertZp.png)
|
108 |
+
<small>Image by [Vaishakh Manohar](https://www.quantamagazine.org/the-simple-algorithm-that-ants-use-to-build-bridges-20180226/)</small>
|
109 |
|
110 |
+
<pre style="white-space: pre-wrap;">
|
111 |
+
The image shows a group of red ants (Solenopsis invicta) climbing over a vertical wooden post. The ants are using their long legs and antennae to navigate the rough surface of the wood, demonstrating their ability to adapt to different materials and environments. This behavior is relevant for materials design because it highlights the importance of considering the interactions between materials and living organisms, such as ants, when designing new materials.
|
112 |
|
113 |
+
Multi-agent AI (Artificial Intelligence) is a field of study that focuses on the development of AI systems that can work together with other AI systems to achieve a common goal. In the context of this image, multi-agent AI could be used to design materials that are more compatible with the natural behaviors of living organisms, such as ants, and that can adapt to different environments and conditions.
|
114 |
|
115 |
+
By studying the behavior of ants and other living organisms, researchers can gain insights into how materials can be designed to better interact with these organisms and to better mimic their natural behaviors. This can lead to the development of new materials that are more sustainable, efficient, and effective in a variety of applications.
|
116 |
|
117 |
+
In summary, the image of red ants climbing over a wooden post highlights the importance of considering the interactions between materials and living organisms when designing new materials, and the potential of multi-agent AI to help achieve this goal.
|
118 |
+
</pre>
|
119 |
|
|
|
120 |
|
121 |
+
## Dataset generation
|
122 |
|
123 |
+
The schematic below shows a visualization of the approach to generate datasets for training the vision model. The extraction process employs advanced algorithms to accurately detect and separate images and their corresponding textual descriptions from complex PDF documents. It involves extracting images and captions from PDFs to create well-reasoned image-text pairs, utilizing large language models (LLMs) for natural language processing. These image-text pairs are then refined and validated through LLM-based NLP processing, ensuring high-quality and contextually relevant data for training.
|
124 |
|
125 |
+
The image below shows reproductions of two representative pages of the scientific article (here, Spivak, Buehler, et al., 2011), and how they are used to extract visual scientific data for training the Cephalo model.
|
126 |
|
127 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/623ce1c6b66fedf374859fe7/qHURSBRWEDgHy4o56escN.png)
|
128 |
|
|
|
129 |
|
130 |
+
## Example applications
|
131 |
|
132 |
+
The paper provides detailed examples and use cases. Here is a visual of a pipeline that consists of 1) analysis of an image provided to Cephalo-Phi-3-vision-128k-4b-beta, 2) generation of an image generation fromt, and 3) generation of a new image using Stable Diffusion XL Turbo.
|
133 |
|
134 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/623ce1c6b66fedf374859fe7/3VvHK_c9eJolQvfOrhiBw.png)
|
135 |
|
136 |
+
A similar mechanism can be employed to generate 3D models:
|
137 |
|
138 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/623ce1c6b66fedf374859fe7/6ZsvCZ3x3TGvugly44MMI.png)
|
139 |
|
140 |
+
## Citation
|
141 |
|
142 |
+
Please cite as:
|
143 |
|
144 |
+
```bibtex
|
145 |
+
@article{Buehler_Cephalo_2024,
|
146 |
+
title={Cephalo: Multi-Modal Vision-Language Models for Bio-Inspired Materials Analysis and Design},
|
147 |
+
author={Markus J. Buehler},
|
148 |
+
journal={arXiv preprint arXiv:2405.19076},
|
149 |
+
year={2024}
|
150 |
+
}
|
151 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|