oneryalcin commited on
Commit
5fb9b35
·
verified ·
1 Parent(s): 489fb79

Push model using huggingface_hub.

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "embedding_dimension": 1024,
3
+ "pooling_mode": "mean",
4
+ "include_prompt": true
5
+ }
2_Normalize/config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "module_input_name": "sentence_embedding",
3
+ "module_output_name": "sentence_embedding"
4
+ }
README.md ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - setfit
4
+ - sentence-transformers
5
+ - text-classification
6
+ - generated_from_setfit_trainer
7
+ widget: []
8
+ metrics:
9
+ - accuracy
10
+ pipeline_tag: text-classification
11
+ library_name: setfit
12
+ inference: true
13
+ base_model: Hcompany/NeoMME-260M-Retriever-ST-dense
14
+ ---
15
+
16
+ # SetFit with Hcompany/NeoMME-260M-Retriever-ST-dense
17
+
18
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [Hcompany/NeoMME-260M-Retriever-ST-dense](https://huggingface.co/Hcompany/NeoMME-260M-Retriever-ST-dense) as the Sentence Transformer embedding model. A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.
19
+
20
+ The model has been trained using an efficient few-shot learning technique that involves:
21
+
22
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
23
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
24
+
25
+ ## Model Details
26
+
27
+ ### Model Description
28
+ - **Model Type:** SetFit
29
+ - **Sentence Transformer body:** [Hcompany/NeoMME-260M-Retriever-ST-dense](https://huggingface.co/Hcompany/NeoMME-260M-Retriever-ST-dense)
30
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
31
+ - **Maximum Sequence Length:** 16384 tokens
32
+ - **Number of Classes:** 6 classes
33
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
34
+ <!-- - **Language:** Unknown -->
35
+ <!-- - **License:** Unknown -->
36
+
37
+ ### Model Sources
38
+
39
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
40
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
41
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
42
+
43
+ ### Model Labels
44
+ | Label | Examples |
45
+ |:----------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
46
+ | instruction_reference | <ul><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091E4B0></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091F620></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091F620></li></ul> |
47
+ | news_promotion | <ul><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091FB90></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=800x566 at 0x2ADC0091CE90></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=570x800 at 0x2ADC0091E630></li></ul> |
48
+ | exercise_assessment | <ul><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=566x800 at 0x2ADC0091E180></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091FB90></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=566x800 at 0x2ADC0091E630></li></ul> |
49
+ | administration_policy | <ul><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091E750></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=566x800 at 0x2ADC0091F7D0></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091E4B0></li></ul> |
50
+ | research_analysis | <ul><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091CCE0></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091F7D0></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=608x800 at 0x2ADC0091CCE0></li></ul> |
51
+ | other | <ul><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091E630></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091D5E0></li><li><PIL.PngImagePlugin.PngImageFile image mode=RGB size=619x800 at 0x2ADC0091D5E0></li></ul> |
52
+
53
+ ## Uses
54
+
55
+ ### Direct Use for Inference
56
+
57
+ First install the SetFit library:
58
+
59
+ ```bash
60
+ pip install setfit
61
+ ```
62
+
63
+ Then you can load this model and run inference.
64
+
65
+ ```python
66
+ from PIL import Image
67
+
68
+ from setfit import SetFitModel
69
+
70
+ # Download from the 🤗 Hub
71
+ model = SetFitModel.from_pretrained("oneryalcin/finepdfs-purpose-setfit-neomme-v2")
72
+ # Run inference on images
73
+ preds = model([Image.open("example.png")])
74
+ ```
75
+
76
+ <!--
77
+ ### Downstream Use
78
+
79
+ *List how someone could finetune this model on their own dataset.*
80
+ -->
81
+
82
+ <!--
83
+ ### Out-of-Scope Use
84
+
85
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
86
+ -->
87
+
88
+ <!--
89
+ ## Bias, Risks and Limitations
90
+
91
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
92
+ -->
93
+
94
+ <!--
95
+ ### Recommendations
96
+
97
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
98
+ -->
99
+
100
+ ## Training Details
101
+
102
+ ### Training Hyperparameters
103
+ - batch_size: (32, 32)
104
+ - num_epochs: (1, 1)
105
+ - max_steps: -1
106
+ - sampling_strategy: oversampling
107
+ - num_iterations: 3
108
+ - body_learning_rate: (2e-05, 1e-05)
109
+ - head_learning_rate: 0.01
110
+ - loss: CosineSimilarityLoss
111
+ - distance_metric: cosine_distance
112
+ - margin: 0.25
113
+ - end_to_end: False
114
+ - use_amp: False
115
+ - warmup_proportion: 0.1
116
+ - l2_weight: 0.01
117
+ - seed: 42
118
+ - eval_max_steps: -1
119
+ - load_best_model_at_end: False
120
+
121
+ ### Training Results
122
+ | Epoch | Step | Training Loss | Validation Loss |
123
+ |:------:|:----:|:-------------:|:---------------:|
124
+ | 0.0014 | 1 | 0.2760 | - |
125
+ | 0.0686 | 50 | 0.2481 | - |
126
+ | 0.1372 | 100 | 0.2100 | - |
127
+ | 0.2058 | 150 | 0.1900 | - |
128
+ | 0.2743 | 200 | 0.1748 | - |
129
+ | 0.3429 | 250 | 0.1622 | - |
130
+ | 0.4115 | 300 | 0.1531 | - |
131
+ | 0.4801 | 350 | 0.1388 | - |
132
+ | 0.5487 | 400 | 0.1345 | - |
133
+ | 0.6173 | 450 | 0.1241 | - |
134
+ | 0.6859 | 500 | 0.1158 | - |
135
+ | 0.7545 | 550 | 0.1059 | - |
136
+ | 0.8230 | 600 | 0.0968 | - |
137
+ | 0.8916 | 650 | 0.0840 | - |
138
+ | 0.9602 | 700 | 0.0874 | - |
139
+
140
+ ### Framework Versions
141
+ - Python: 3.12.10
142
+ - SetFit: 1.3.0.dev0
143
+ - Sentence Transformers: 6.0.1
144
+ - Transformers: 5.17.0
145
+ - PyTorch: 2.14.0+cu130
146
+ - Datasets: 5.0.1
147
+ - Tokenizers: 0.23.2
148
+
149
+ ## Citation
150
+
151
+ ### BibTeX
152
+ ```bibtex
153
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
154
+ doi = {10.48550/ARXIV.2209.11055},
155
+ url = {https://arxiv.org/abs/2209.11055},
156
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
157
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
158
+ title = {Efficient Few-Shot Learning Without Prompts},
159
+ publisher = {arXiv},
160
+ year = {2022},
161
+ copyright = {Creative Commons Attribution 4.0 International}
162
+ }
163
+ ```
164
+
165
+ <!--
166
+ ## Glossary
167
+
168
+ *Clearly define terms in order to be accessible across audiences.*
169
+ -->
170
+
171
+ <!--
172
+ ## Model Card Authors
173
+
174
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
175
+ -->
176
+
177
+ <!--
178
+ ## Model Card Contact
179
+
180
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
181
+ -->
chat_template.jinja ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#-
2
+ NeoMME retrieval prompt template. Not a conversation format: NeoMME is an encoder and has no chat turns.
3
+
4
+ `task` selects the retrieval side. A sentence-transformers v6 `MultiVectorEncoder` routes
5
+ `task="query"` / `task="document"` here when the template declares the variable.
6
+
7
+ task="query" -> <query> … N x <mask> ColBERT-style learned query expansion. <mask> is the
8
+ masked-diffusion fill token. The exporter sets N from the
9
+ checkpoint.
10
+ task="document" -> <doc> … Text passages. Image pages take the same <doc> prefix
11
+ followed by one image token placeholder, which the processor
12
+ expands after it knows the patch grid.
13
+ -#}
14
+ {%- if task is not defined -%}
15
+ {{- raise_exception("NeoMME chat templates require task='query' or task='document'.") -}}
16
+ {%- endif -%}
17
+ {%- if task not in ['query', 'document'] -%}
18
+ {{- raise_exception("task=" ~ task ~ " is not supported: expected 'query' or 'document'.") -}}
19
+ {%- endif -%}
20
+ {%- if messages is not defined or not messages -%}
21
+ {{- raise_exception("NeoMME chat conversations must contain at least one message.") -}}
22
+ {%- endif -%}
23
+
24
+ {# Collect content and validate one retrieval item without imposing batch-level policy. #}
25
+ {%- set state = namespace(text='', has_text=false, image_count=0) -%}
26
+ {%- for message in messages -%}
27
+ {%- set content = message.content -%}
28
+ {%- set items = [{'type': 'text', 'text': content}] if content is string else content -%}
29
+ {%- for item in items -%}
30
+ {%- if item.type == 'text' -%}
31
+ {%- if image_token in item.text -%}
32
+ {{- raise_exception(image_token ~ " is reserved for image documents.") -}}
33
+ {%- endif -%}
34
+ {%- set state.has_text = true -%}
35
+ {%- set state.text = state.text + item.text -%}
36
+ {%- elif item.type == 'image' -%}
37
+ {%- if item.image is not defined or item.image is none or item.image == '' -%}
38
+ {{- raise_exception("NeoMME image content must provide an image source.") -}}
39
+ {%- endif -%}
40
+ {%- set state.image_count = state.image_count + 1 -%}
41
+ {%- elif item.type == 'image_url' -%}
42
+ {%- if item.image_url is not defined or not item.image_url -%}
43
+ {{- raise_exception("NeoMME image_url content must provide an image source.") -}}
44
+ {%- endif -%}
45
+ {%- set state.image_count = state.image_count + 1 -%}
46
+ {%- else -%}
47
+ {{- raise_exception("NeoMME chat templates do not support content type " ~ item.type ~ ".") -}}
48
+ {%- endif -%}
49
+ {%- endfor -%}
50
+ {%- endfor -%}
51
+
52
+ {%- if state.image_count and state.has_text -%}
53
+ {{- raise_exception("NeoMME cannot encode text and images in the same conversation.") -}}
54
+ {%- endif -%}
55
+ {%- if state.image_count > 1 -%}
56
+ {{- raise_exception("NeoMME accepts one image document per conversation.") -}}
57
+ {%- endif -%}
58
+ {%- if state.image_count and task != 'document' -%}
59
+ {{- raise_exception("NeoMME image content must use task='document'.") -}}
60
+ {%- endif -%}
61
+
62
+ {%- set content = image_token if state.image_count else state.text -%}
63
+ {%- if task == 'query' -%}
64
+ {{- query_token + content + mask_token * 10 -}}
65
+ {%- else -%}
66
+ {{- document_token + content -}}
67
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "NeoMMEModel"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "document_token_id": 5,
8
+ "dtype": "float32",
9
+ "embedding_dim": 128,
10
+ "embedding_rank": 256,
11
+ "eos_token_id": 2,
12
+ "head_dim": 64,
13
+ "hidden_act": "relu2",
14
+ "hidden_size": 1024,
15
+ "image_token_id": 6,
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 3584,
18
+ "layer_types": [
19
+ "sliding_attention",
20
+ "sliding_attention",
21
+ "sliding_attention",
22
+ "sliding_attention",
23
+ "sliding_attention",
24
+ "full_attention",
25
+ "sliding_attention",
26
+ "sliding_attention",
27
+ "sliding_attention",
28
+ "sliding_attention",
29
+ "sliding_attention",
30
+ "full_attention",
31
+ "sliding_attention",
32
+ "sliding_attention",
33
+ "sliding_attention",
34
+ "sliding_attention",
35
+ "full_attention"
36
+ ],
37
+ "max_position_embeddings": 16384,
38
+ "mlp_bias": false,
39
+ "model_type": "neomme",
40
+ "norm_eps": 1e-06,
41
+ "num_attention_heads": 16,
42
+ "num_hidden_layers": 17,
43
+ "num_key_value_heads": 4,
44
+ "pad_token_id": 0,
45
+ "patch_size": 32,
46
+ "per_layer_config": {
47
+ "01": {
48
+ "sliding_window": 1024
49
+ },
50
+ "03": {
51
+ "sliding_window": 1024
52
+ },
53
+ "05": {
54
+ "sliding_window": null
55
+ },
56
+ "06": {
57
+ "sliding_window": 1024
58
+ },
59
+ "08": {
60
+ "sliding_window": 1024
61
+ },
62
+ "10": {
63
+ "sliding_window": 1024
64
+ },
65
+ "11": {
66
+ "sliding_window": null
67
+ },
68
+ "13": {
69
+ "sliding_window": 1024
70
+ },
71
+ "15": {
72
+ "sliding_window": 1024
73
+ },
74
+ "16": {
75
+ "sliding_window": null
76
+ }
77
+ },
78
+ "residual_multiplier": 0.17149858514250885,
79
+ "rope_parameters": {
80
+ "full_attention": {
81
+ "partial_rotary_factor": 0.25,
82
+ "rope_theta": 1000000.0,
83
+ "rope_type": "default"
84
+ },
85
+ "sliding_attention": {
86
+ "partial_rotary_factor": 1.0,
87
+ "rope_theta": 10000.0,
88
+ "rope_type": "default"
89
+ }
90
+ },
91
+ "sliding_window": 256,
92
+ "tie_word_embeddings": true,
93
+ "transformers_version": "5.17.0",
94
+ "use_cache": false,
95
+ "vocab_size": 131072
96
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "pytorch": "2.14.0+cu130",
4
+ "sentence_transformers": "6.0.1",
5
+ "transformers": "5.17.0"
6
+ },
7
+ "default_prompt_name": null,
8
+ "model_type": "SentenceTransformer",
9
+ "prompts": {
10
+ "document": "",
11
+ "query": ""
12
+ },
13
+ "similarity_fn_name": "cosine"
14
+ }
config_setfit.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ "administration_policy",
4
+ "exercise_assessment",
5
+ "instruction_reference",
6
+ "news_promotion",
7
+ "research_analysis",
8
+ "other"
9
+ ],
10
+ "task": "document",
11
+ "normalize_embeddings": false
12
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0fa4931791ea2f35cde3e1a39187695a64e705af1775908ecd6a6d3082b0a3d
3
+ size 1051769336
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67b38e87b10d6fca6baa4b212112c8e39df9663a0a13f3f36bbac15632593566
3
+ size 25503
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.base.modules.transformer.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.base.modules.normalize.Normalize"
19
+ }
20
+ ]
processor_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
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": "NeoMMEImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "max_side": 2048,
19
+ "patch_size": 32,
20
+ "resample": 2,
21
+ "rescale_factor": 0.00392156862745098
22
+ },
23
+ "processor_class": "NeoMMEProcessor"
24
+ }
sentence_bert_config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformer_task": "feature-extraction",
3
+ "modality_config": {
4
+ "text": {
5
+ "method": "forward",
6
+ "method_output_name": "last_hidden_state"
7
+ },
8
+ "image": {
9
+ "method": "forward",
10
+ "method_output_name": "last_hidden_state"
11
+ },
12
+ "message": {
13
+ "method": "forward",
14
+ "method_output_name": "last_hidden_state",
15
+ "format": "structured"
16
+ }
17
+ },
18
+ "module_output_name": "token_embeddings",
19
+ "unpad_inputs": false
20
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "clean_up_tokenization_spaces": false,
4
+ "document_token": "<doc>",
5
+ "eos_token": "<eos>",
6
+ "extra_special_tokens": [],
7
+ "image_token": "<img>",
8
+ "is_local": false,
9
+ "local_files_only": false,
10
+ "mask_token": "<mask>",
11
+ "model_input_names": [
12
+ "input_ids",
13
+ "attention_mask"
14
+ ],
15
+ "model_max_length": 16384,
16
+ "model_specific_special_tokens": {
17
+ "document_token": "<doc>",
18
+ "image_token": "<img>",
19
+ "query_token": "<query>",
20
+ "row_token": "<row>"
21
+ },
22
+ "pad_token": "<pad>",
23
+ "processor_class": "NeoMMEProcessor",
24
+ "query_token": "<query>",
25
+ "row_token": "<row>",
26
+ "tokenizer_class": "TokenizersBackend",
27
+ "truncation_side": "right",
28
+ "unk_token": "<unk>"
29
+ }