LabSmart commited on
Commit
f76360e
·
verified ·
1 Parent(s): ea1b8fe

Uploads model weight

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,113 +1,58 @@
1
  ---
2
- license: gemma
3
  base_model: google/gemma-3-4b-it
 
 
4
  tags:
5
- - vision-language-model
6
- - TEM
7
- - microscopy
8
- - materials-science
9
- - gemma
10
- - scientific-VLM
11
- language:
12
- - en
13
- pipeline_tag: image-text-to-text
14
  ---
15
 
16
- # ATOMIC-Gemma
17
 
18
- ATOMIC-Gemma is a domain-specific Vision-Language Model for Transmission Electron Microscopy (TEM), fine-tuned from Gemma3-4B-IT using Stage 2 instruction tuning on TEM conversation data.
 
19
 
20
- > **Note:** ATOMIC-Gemma is developed after the ECCV 2026 submission deadline and is **not part of the published paper**. It is released here to demonstrate the generalizability of the ATOMIC training pipeline across different base model architectures.
21
 
22
- For the published paper and full pipeline, please refer to our GitHub repository:
23
- 👉 [https://github.com/SemiMIRTLab/ATOMIC](https://github.com/SemiMIRTLab/ATOMIC)
24
 
25
- ---
 
 
 
 
26
 
27
- ## Model Details
28
 
29
- | | |
30
- |---|---|
31
- | **Base Model** | Gemma3-4B-IT (`google/gemma-3-4b-it`) |
32
- | **Training Stage** | Stage 2 (instruction tuning) only |
33
- | **Training Data** | 60K Stage 2 conversations |
34
- | **Domain** | Transmission Electron Microscopy (TEM) |
35
- | **Modalities** | CTEM, HR-TEM, STEM, Diffraction |
36
 
37
- ---
38
 
39
- ## Inference
40
 
41
- ATOMIC-Gemma can be loaded directly via `transformers`:
42
-
43
- ```python
44
- from transformers import AutoProcessor, Gemma3ForConditionalGeneration
45
- from PIL import Image
46
- import torch
47
-
48
- model_id = "LabSmart/ATOMIC-Gemma"
49
-
50
- model = Gemma3ForConditionalGeneration.from_pretrained(
51
- model_id,
52
- device_map="auto",
53
- torch_dtype=torch.bfloat16
54
- ).eval()
55
- processor = AutoProcessor.from_pretrained(model_id)
56
-
57
- image = Image.open("your_TEM_image.png").convert("RGB")
58
-
59
- messages = [
60
- {
61
- "role": "user",
62
- "content": [
63
- {"type": "image", "image": image},
64
- {"type": "text", "text": "What type of TEM image is this?"}
65
- ]
66
- }
67
- ]
68
-
69
- inputs = processor.apply_chat_template(
70
- messages,
71
- add_generation_prompt=True,
72
- tokenize=True,
73
- return_dict=True,
74
- return_tensors="pt"
75
- ).to(model.device, dtype=torch.bfloat16)
76
-
77
- input_len = inputs["input_ids"].shape[-1]
78
-
79
- with torch.inference_mode():
80
- generation = model.generate(**inputs, max_new_tokens=256, do_sample=False)
81
-
82
- generation = generation[0][input_len:]
83
- response = processor.decode(generation, skip_special_tokens=True)
84
- print(response)
85
- ```
86
 
87
- ---
88
 
89
- ## Training Data
 
 
 
 
90
 
91
- Training data is available on HuggingFace:
92
- 👉 [https://huggingface.co/datasets/LabSmart/ATOMIC_dataset](https://huggingface.co/datasets/LabSmart/ATOMIC_dataset)
93
 
94
- ---
95
 
96
- ## Citation
97
 
 
 
98
  ```bibtex
99
- @inproceedings{atomic2026eccv,
100
- title = {ATOMIC: A Domain-Specific Vision-Language Model
101
- for Transmission Electron Microscopy},
102
- author = {Tu, C. and Hsu, Shu-han and others},
103
- booktitle = {Proceedings of ECCV 2026},
104
- year = {2026},
105
- note = {BibTeX will be updated upon publication}
106
  }
107
- ```
108
-
109
- ---
110
-
111
- ## License
112
-
113
- This model is released under the [Gemma Terms of Use](https://ai.google.dev/gemma/terms). It is intended for academic research purposes only.
 
1
  ---
 
2
  base_model: google/gemma-3-4b-it
3
+ library_name: transformers
4
+ model_name: checkpoints
5
  tags:
6
+ - generated_from_trainer
7
+ - trl
8
+ - sft
9
+ licence: license
 
 
 
 
 
10
  ---
11
 
12
+ # Model Card for checkpoints
13
 
14
+ This model is a fine-tuned version of [google/gemma-3-4b-it](https://huggingface.co/google/gemma-3-4b-it).
15
+ It has been trained using [TRL](https://github.com/huggingface/trl).
16
 
17
+ ## Quick start
18
 
19
+ ```python
20
+ from transformers import pipeline
21
 
22
+ question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
23
+ generator = pipeline("text-generation", model="None", device="cuda")
24
+ output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
25
+ print(output["generated_text"])
26
+ ```
27
 
28
+ ## Training procedure
29
 
30
+
 
 
 
 
 
 
31
 
 
32
 
 
33
 
34
+ This model was trained with SFT.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ ### Framework versions
37
 
38
+ - TRL: 1.4.0
39
+ - Transformers: 5.9.0
40
+ - Pytorch: 2.12.0.dev20260407+cu128
41
+ - Datasets: 4.8.5
42
+ - Tokenizers: 0.22.2
43
 
44
+ ## Citations
 
45
 
 
46
 
 
47
 
48
+ Cite TRL as:
49
+
50
  ```bibtex
51
+ @software{vonwerra2020trl,
52
+ title = {{TRL: Transformers Reinforcement Learning}},
53
+ author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
54
+ license = {Apache-2.0},
55
+ url = {https://github.com/huggingface/trl},
56
+ year = {2020}
 
57
  }
58
+ ```
 
 
 
 
 
 
chat_template.jinja ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{ bos_token }}
2
+ {%- if messages[0]['role'] == 'system' -%}
3
+ {%- if messages[0]['content'] is string -%}
4
+ {%- set first_user_prefix = messages[0]['content'] + '
5
+
6
+ ' -%}
7
+ {%- else -%}
8
+ {%- set first_user_prefix = messages[0]['content'][0]['text'] + '
9
+
10
+ ' -%}
11
+ {%- endif -%}
12
+ {%- set loop_messages = messages[1:] -%}
13
+ {%- else -%}
14
+ {%- set first_user_prefix = "" -%}
15
+ {%- set loop_messages = messages -%}
16
+ {%- endif -%}
17
+ {%- for message in loop_messages -%}
18
+ {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
19
+ {{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
20
+ {%- endif -%}
21
+ {%- if (message['role'] == 'assistant') -%}
22
+ {%- set role = "model" -%}
23
+ {%- else -%}
24
+ {%- set role = message['role'] -%}
25
+ {%- endif -%}
26
+ {{ '<start_of_turn>' + role + '
27
+ ' + (first_user_prefix if loop.first else "") }}
28
+ {%- if message['content'] is string -%}
29
+ {{ message['content'] | trim }}
30
+ {%- elif message['content'] is iterable -%}
31
+ {%- for item in message['content'] -%}
32
+ {%- if item['type'] == 'image' -%}
33
+ {{ '<start_of_image>' }}
34
+ {%- elif item['type'] == 'text' -%}
35
+ {{ item['text'] | trim }}
36
+ {%- endif -%}
37
+ {%- endfor -%}
38
+ {%- else -%}
39
+ {{ raise_exception("Invalid content type") }}
40
+ {%- endif -%}
41
+ {{ '<end_of_turn>
42
+ ' }}
43
+ {%- endfor -%}
44
+ {%- if add_generation_prompt -%}
45
+ {{'<start_of_turn>model
46
+ '}}
47
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Gemma3ForConditionalGeneration"
4
+ ],
5
+ "boi_token_index": 255999,
6
+ "bos_token_id": 2,
7
+ "dtype": "bfloat16",
8
+ "eoi_token_index": 256000,
9
+ "eos_token_id": 1,
10
+ "image_token_index": 262144,
11
+ "initializer_range": 0.02,
12
+ "mm_tokens_per_image": 256,
13
+ "model_type": "gemma3",
14
+ "pad_token_id": 0,
15
+ "text_config": {
16
+ "_sliding_window_pattern": 6,
17
+ "attention_bias": false,
18
+ "attention_dropout": 0.0,
19
+ "attn_logit_softcapping": null,
20
+ "bos_token_id": 2,
21
+ "dtype": "bfloat16",
22
+ "eos_token_id": 1,
23
+ "final_logit_softcapping": null,
24
+ "head_dim": 256,
25
+ "hidden_activation": "gelu_pytorch_tanh",
26
+ "hidden_size": 2560,
27
+ "initializer_range": 0.02,
28
+ "intermediate_size": 10240,
29
+ "layer_types": [
30
+ "sliding_attention",
31
+ "sliding_attention",
32
+ "sliding_attention",
33
+ "sliding_attention",
34
+ "sliding_attention",
35
+ "full_attention",
36
+ "sliding_attention",
37
+ "sliding_attention",
38
+ "sliding_attention",
39
+ "sliding_attention",
40
+ "sliding_attention",
41
+ "full_attention",
42
+ "sliding_attention",
43
+ "sliding_attention",
44
+ "sliding_attention",
45
+ "sliding_attention",
46
+ "sliding_attention",
47
+ "full_attention",
48
+ "sliding_attention",
49
+ "sliding_attention",
50
+ "sliding_attention",
51
+ "sliding_attention",
52
+ "sliding_attention",
53
+ "full_attention",
54
+ "sliding_attention",
55
+ "sliding_attention",
56
+ "sliding_attention",
57
+ "sliding_attention",
58
+ "sliding_attention",
59
+ "full_attention",
60
+ "sliding_attention",
61
+ "sliding_attention",
62
+ "sliding_attention",
63
+ "sliding_attention"
64
+ ],
65
+ "max_position_embeddings": 131072,
66
+ "model_type": "gemma3_text",
67
+ "num_attention_heads": 8,
68
+ "num_hidden_layers": 34,
69
+ "num_key_value_heads": 4,
70
+ "pad_token_id": 0,
71
+ "query_pre_attn_scalar": 256,
72
+ "rms_norm_eps": 1e-06,
73
+ "rope_parameters": {
74
+ "full_attention": {
75
+ "factor": 8.0,
76
+ "rope_theta": 1000000.0,
77
+ "rope_type": "linear"
78
+ },
79
+ "sliding_attention": {
80
+ "rope_theta": 10000.0,
81
+ "rope_type": "default"
82
+ }
83
+ },
84
+ "sliding_window": 1024,
85
+ "tie_word_embeddings": true,
86
+ "use_bidirectional_attention": false,
87
+ "use_cache": true,
88
+ "vocab_size": 262208
89
+ },
90
+ "tie_word_embeddings": true,
91
+ "transformers_version": "5.9.0",
92
+ "use_cache": false,
93
+ "vision_config": {
94
+ "attention_dropout": 0.0,
95
+ "dtype": "bfloat16",
96
+ "hidden_act": "gelu_pytorch_tanh",
97
+ "hidden_size": 1152,
98
+ "image_size": 896,
99
+ "intermediate_size": 4304,
100
+ "layer_norm_eps": 1e-06,
101
+ "model_type": "siglip_vision_model",
102
+ "num_attention_heads": 16,
103
+ "num_channels": 3,
104
+ "num_hidden_layers": 27,
105
+ "patch_size": 14,
106
+ "vision_use_head": false
107
+ }
108
+ }
generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 2,
3
+ "cache_implementation": "hybrid",
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 1,
7
+ 1,
8
+ 106
9
+ ],
10
+ "pad_token_id": 0,
11
+ "top_k": 64,
12
+ "top_p": 0.95,
13
+ "transformers_version": "5.9.0"
14
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:801ead1729fe11287a922b5c8b442cdb6030280a644513d8e5eef0b34fb6ae29
3
+ size 8600278008
processor_config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": null,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Gemma3ImageProcessor",
13
+ "image_seq_length": 256,
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "resample": 2,
20
+ "rescale_factor": 0.00392156862745098,
21
+ "size": {
22
+ "height": 896,
23
+ "width": 896
24
+ }
25
+ },
26
+ "image_seq_length": 256,
27
+ "processor_class": "Gemma3Processor"
28
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:daab2354f8a74e70d70b4d1f804939b68a8c9624dd06cb7858e52dd8970e9726
3
+ size 33384567
tokenizer_config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "boi_token": "<start_of_image>",
4
+ "bos_token": "<bos>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "eoi_token": "<end_of_image>",
7
+ "eos_token": "<eos>",
8
+ "image_token": "<image_soft_token>",
9
+ "is_local": false,
10
+ "local_files_only": false,
11
+ "mask_token": "<mask>",
12
+ "model_max_length": 1000000000000000019884624838656,
13
+ "model_specific_special_tokens": {
14
+ "boi_token": "<start_of_image>",
15
+ "eoi_token": "<end_of_image>",
16
+ "image_token": "<image_soft_token>"
17
+ },
18
+ "pad_token": "<pad>",
19
+ "processor_class": "Gemma3Processor",
20
+ "sp_model_kwargs": null,
21
+ "spaces_between_special_tokens": false,
22
+ "tokenizer_class": "GemmaTokenizer",
23
+ "unk_token": "<unk>",
24
+ "use_default_system_prompt": false
25
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dca77093269b732bf6f843b669faee618964eccea5247e816a3b8bc79831ed73
3
+ size 5777