Upload agro_all-MiniLM-L6-v2_cross_attention_gcn_h512_o64_cosine_e1024_early model created with on2vec
Browse files- .gitattributes +1 -0
- 1_TokenOntologyFusionModule/config.json +8 -0
- 1_TokenOntologyFusionModule/ontology_data.json +3 -0
- 1_TokenOntologyFusionModule/pytorch_model.bin +3 -0
- 2_Pooling/config.json +10 -0
- README.md +122 -0
- config.json +25 -0
- config_sentence_transformers.json +14 -0
- model.safetensors +3 -0
- modules.json +20 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +37 -0
- tokenizer.json +0 -0
- tokenizer_config.json +65 -0
- vocab.txt +0 -0
.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 |
+
1_TokenOntologyFusionModule/ontology_data.json filter=lfs diff=lfs merge=lfs -text
|
1_TokenOntologyFusionModule/config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"base_model_dim": 384,
|
| 3 |
+
"top_k_concepts": 5,
|
| 4 |
+
"fusion_method": "cross_attention",
|
| 5 |
+
"concept_weight": 0.2,
|
| 6 |
+
"relevance_threshold": 0.3,
|
| 7 |
+
"max_concepts_per_batch": 100
|
| 8 |
+
}
|
1_TokenOntologyFusionModule/ontology_data.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c2fe699e5b734dd7c4a1e776fc8bdb9507e80fb6cf6254a550f2c8f36b6d9283
|
| 3 |
+
size 34497895
|
1_TokenOntologyFusionModule/pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a3169aa4697ed1e620c4b2c7c223179ec13c16c88fa24f99c26db8fd56ebb07a
|
| 3 |
+
size 3553160
|
2_Pooling/config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"word_embedding_dimension": 384,
|
| 3 |
+
"pooling_mode_cls_token": false,
|
| 4 |
+
"pooling_mode_mean_tokens": true,
|
| 5 |
+
"pooling_mode_max_tokens": false,
|
| 6 |
+
"pooling_mode_mean_sqrt_len_tokens": false,
|
| 7 |
+
"pooling_mode_weightedmean_tokens": false,
|
| 8 |
+
"pooling_mode_lasttoken": false,
|
| 9 |
+
"include_prompt": true
|
| 10 |
+
}
|
README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: all-MiniLM-L6-v2
|
| 3 |
+
library_name: sentence-transformers
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
pipeline_tag: sentence-similarity
|
| 6 |
+
tags:
|
| 7 |
+
- sentence-transformers
|
| 8 |
+
- sentence-similarity
|
| 9 |
+
- feature-extraction
|
| 10 |
+
- ontology
|
| 11 |
+
- on2vec
|
| 12 |
+
- graph-neural-networks
|
| 13 |
+
- base-all-MiniLM-L6-v2
|
| 14 |
+
- general
|
| 15 |
+
- general-ontology
|
| 16 |
+
- fusion-cross_attention
|
| 17 |
+
- gnn-gcn
|
| 18 |
+
- medium-ontology
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# agro_all-MiniLM-L6-v2_cross_attention_gcn_h512_o64_cosine_e1024_early
|
| 22 |
+
|
| 23 |
+
This is a sentence-transformers model created with [on2vec](https://github.com/david4096/on2vec), which augments text embeddings with ontological knowledge using Graph Neural Networks.
|
| 24 |
+
|
| 25 |
+
## Model Details
|
| 26 |
+
|
| 27 |
+
- **Base Text Model**: all-MiniLM-L6-v2
|
| 28 |
+
- Text Embedding Dimension: 384
|
| 29 |
+
- **Ontology**: agro.owl
|
| 30 |
+
- **Domain**: general
|
| 31 |
+
- **Ontology Concepts**: 4,162
|
| 32 |
+
- **Concept Alignment**: 4,162/4,162 (100.0%)
|
| 33 |
+
- **Fusion Method**: cross_attention
|
| 34 |
+
- **GNN Architecture**: GCN
|
| 35 |
+
- **Structural Embedding Dimension**: 4162
|
| 36 |
+
- **Output Embedding Dimension**: 64
|
| 37 |
+
- **Hidden Dimensions**: 512
|
| 38 |
+
- **Dropout**: 0.0
|
| 39 |
+
- **Training Date**: 2025-09-19
|
| 40 |
+
- **on2vec Version**: 0.1.0
|
| 41 |
+
- **Source Ontology Size**: 7.2 MB
|
| 42 |
+
- **Model Size**: 123.8 MB
|
| 43 |
+
- **Library**: on2vec + sentence-transformers
|
| 44 |
+
|
| 45 |
+
## Technical Architecture
|
| 46 |
+
|
| 47 |
+
This model uses a multi-stage architecture:
|
| 48 |
+
|
| 49 |
+
1. **Text Encoding**: Input text is encoded using the base sentence-transformer model
|
| 50 |
+
2. **Ontological Embedding**: Pre-trained GNN embeddings capture structural relationships
|
| 51 |
+
3. **Fusion Layer**: Simple concatenation of text and ontological embeddings
|
| 52 |
+
|
| 53 |
+
**Embedding Flow:**
|
| 54 |
+
- Text: 384 dimensions → 512 hidden → 64 output
|
| 55 |
+
- Structure: 4162 concepts → GNN → 64 output
|
| 56 |
+
- Fusion: cross_attention → Final embedding
|
| 57 |
+
|
| 58 |
+
## How It Works
|
| 59 |
+
|
| 60 |
+
This model combines:
|
| 61 |
+
1. **Text Embeddings**: Generated using the base sentence-transformer model
|
| 62 |
+
2. **Ontological Embeddings**: Created by training Graph Neural Networks on OWL ontology structure
|
| 63 |
+
3. **Fusion Layer**: Combines both embedding types using the specified fusion method
|
| 64 |
+
|
| 65 |
+
The ontological knowledge helps the model better understand domain-specific relationships and concepts.
|
| 66 |
+
|
| 67 |
+
## Usage
|
| 68 |
+
|
| 69 |
+
```python
|
| 70 |
+
from sentence_transformers import SentenceTransformer
|
| 71 |
+
|
| 72 |
+
# Load the model
|
| 73 |
+
model = SentenceTransformer('agro_all-MiniLM-L6-v2_cross_attention_gcn_h512_o64_cosine_e1024_early')
|
| 74 |
+
|
| 75 |
+
# Generate embeddings
|
| 76 |
+
sentences = ['Example sentence 1', 'Example sentence 2']
|
| 77 |
+
embeddings = model.encode(sentences)
|
| 78 |
+
|
| 79 |
+
# Compute similarity
|
| 80 |
+
from sentence_transformers.util import cos_sim
|
| 81 |
+
similarity = cos_sim(embeddings[0], embeddings[1])
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## Training Process
|
| 85 |
+
|
| 86 |
+
This model was created using the on2vec pipeline:
|
| 87 |
+
|
| 88 |
+
1. **Ontology Processing**: The OWL ontology was converted to a graph structure
|
| 89 |
+
2. **GNN Training**: Graph Neural Networks were trained to learn ontological relationships
|
| 90 |
+
3. **Text Integration**: Base model text embeddings were combined with ontological embeddings
|
| 91 |
+
4. **Fusion Training**: The fusion layer was trained to optimally combine both embedding types
|
| 92 |
+
|
| 93 |
+
## Intended Use
|
| 94 |
+
|
| 95 |
+
This model is particularly effective for:
|
| 96 |
+
- General domain text processing
|
| 97 |
+
- Tasks requiring understanding of domain-specific relationships
|
| 98 |
+
- Semantic similarity in specialized domains
|
| 99 |
+
- Classification tasks with domain knowledge requirements
|
| 100 |
+
|
| 101 |
+
## Limitations
|
| 102 |
+
|
| 103 |
+
- Performance may vary on domains different from the training ontology
|
| 104 |
+
- Ontological knowledge is limited to concepts present in the source OWL file
|
| 105 |
+
- May have higher computational requirements than vanilla text models
|
| 106 |
+
|
| 107 |
+
## Citation
|
| 108 |
+
|
| 109 |
+
If you use this model, please cite the on2vec framework:
|
| 110 |
+
|
| 111 |
+
```bibtex
|
| 112 |
+
@software{on2vec,
|
| 113 |
+
title={on2vec: Ontology Embeddings with Graph Neural Networks},
|
| 114 |
+
author={David Steinberg},
|
| 115 |
+
url={https://github.com/david4096/on2vec},
|
| 116 |
+
year={2024}
|
| 117 |
+
}
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
---
|
| 121 |
+
|
| 122 |
+
Created with [on2vec](https://github.com/david4096/on2vec) 🧬→🤖
|
config.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"BertModel"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.1,
|
| 6 |
+
"classifier_dropout": null,
|
| 7 |
+
"dtype": "float32",
|
| 8 |
+
"gradient_checkpointing": false,
|
| 9 |
+
"hidden_act": "gelu",
|
| 10 |
+
"hidden_dropout_prob": 0.1,
|
| 11 |
+
"hidden_size": 384,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 1536,
|
| 14 |
+
"layer_norm_eps": 1e-12,
|
| 15 |
+
"max_position_embeddings": 512,
|
| 16 |
+
"model_type": "bert",
|
| 17 |
+
"num_attention_heads": 12,
|
| 18 |
+
"num_hidden_layers": 6,
|
| 19 |
+
"pad_token_id": 0,
|
| 20 |
+
"position_embedding_type": "absolute",
|
| 21 |
+
"transformers_version": "4.56.1",
|
| 22 |
+
"type_vocab_size": 2,
|
| 23 |
+
"use_cache": true,
|
| 24 |
+
"vocab_size": 30522
|
| 25 |
+
}
|
config_sentence_transformers.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "SentenceTransformer",
|
| 3 |
+
"__version__": {
|
| 4 |
+
"sentence_transformers": "5.1.0",
|
| 5 |
+
"transformers": "4.56.1",
|
| 6 |
+
"pytorch": "2.6.0"
|
| 7 |
+
},
|
| 8 |
+
"prompts": {
|
| 9 |
+
"query": "",
|
| 10 |
+
"document": ""
|
| 11 |
+
},
|
| 12 |
+
"default_prompt_name": null,
|
| 13 |
+
"similarity_fn_name": "cosine"
|
| 14 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1377e9af0ca0b016a9f2aa584d6fc71ab3ea6804fae21ef9fb1416e2944057ac
|
| 3 |
+
size 90864192
|
modules.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"idx": 0,
|
| 4 |
+
"name": "0",
|
| 5 |
+
"path": "",
|
| 6 |
+
"type": "sentence_transformers.models.Transformer"
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"idx": 1,
|
| 10 |
+
"name": "1",
|
| 11 |
+
"path": "1_TokenOntologyFusionModule",
|
| 12 |
+
"type": "on2vec.sentence_transformer_hub.TokenOntologyFusionModule"
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"idx": 2,
|
| 16 |
+
"name": "2",
|
| 17 |
+
"path": "2_Pooling",
|
| 18 |
+
"type": "sentence_transformers.models.Pooling"
|
| 19 |
+
}
|
| 20 |
+
]
|
sentence_bert_config.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"max_seq_length": 256,
|
| 3 |
+
"do_lower_case": false
|
| 4 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": {
|
| 3 |
+
"content": "[CLS]",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"mask_token": {
|
| 10 |
+
"content": "[MASK]",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "[PAD]",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"sep_token": {
|
| 24 |
+
"content": "[SEP]",
|
| 25 |
+
"lstrip": false,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
},
|
| 30 |
+
"unk_token": {
|
| 31 |
+
"content": "[UNK]",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": false,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
}
|
| 37 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": false,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_basic_tokenize": true,
|
| 47 |
+
"do_lower_case": true,
|
| 48 |
+
"extra_special_tokens": {},
|
| 49 |
+
"mask_token": "[MASK]",
|
| 50 |
+
"max_length": 128,
|
| 51 |
+
"model_max_length": 256,
|
| 52 |
+
"never_split": null,
|
| 53 |
+
"pad_to_multiple_of": null,
|
| 54 |
+
"pad_token": "[PAD]",
|
| 55 |
+
"pad_token_type_id": 0,
|
| 56 |
+
"padding_side": "right",
|
| 57 |
+
"sep_token": "[SEP]",
|
| 58 |
+
"stride": 0,
|
| 59 |
+
"strip_accents": null,
|
| 60 |
+
"tokenize_chinese_chars": true,
|
| 61 |
+
"tokenizer_class": "BertTokenizer",
|
| 62 |
+
"truncation_side": "right",
|
| 63 |
+
"truncation_strategy": "longest_first",
|
| 64 |
+
"unk_token": "[UNK]"
|
| 65 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|