kforth/IfcSpace2SpaceTypes
0102
1---2pipeline_tag: sentence-similarity3tags:4- sentence-transformers5- feature-extraction6- sentence-similarity7- transformers8base_model:9- google-bert/bert-base-german-cased10---11 12# {MODEL_NAME}13 14This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.15 16<!--- Describe your model here -->17 18## Usage (Sentence-Transformers)19 20Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:21 22```23pip install -U sentence-transformers24```25 26Then you can use the model like this:27 28```python29from sentence_transformers import SentenceTransformer30sentences = ["This is an example sentence", "Each sentence is converted"]31 32model = SentenceTransformer('{MODEL_NAME}')33embeddings = model.encode(sentences)34print(embeddings)35```36 37 38 39## Usage (HuggingFace Transformers)40Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.41 42```python43from transformers import AutoTokenizer, AutoModel44import torch45 46 47#Mean Pooling - Take attention mask into account for correct averaging48def mean_pooling(model_output, attention_mask):49 token_embeddings = model_output[0] #First element of model_output contains all token embeddings50 input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()51 return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)52 53 54# Sentences we want sentence embeddings for55sentences = ['This is an example sentence', 'Each sentence is converted']56 57# Load model from HuggingFace Hub58tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')59model = AutoModel.from_pretrained('{MODEL_NAME}')60 61# Tokenize sentences62encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')63 64# Compute token embeddings65with torch.no_grad():66 model_output = model(**encoded_input)67 68# Perform pooling. In this case, mean pooling.69sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])70 71print("Sentence embeddings:")72print(sentence_embeddings)73```74 75 76 77## Evaluation Results78 79<!--- Describe how your model was evaluated -->80 81For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})82 83 84## Training85The model was trained with the parameters:86 87**DataLoader**:88 89`sentence_transformers.datasets.NoDuplicatesDataLoader.NoDuplicatesDataLoader` of length 12 with parameters:90```91{'batch_size': 16}92```93 94**Loss**:95 96`sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss` with parameters:97 ```98 {'scale': 20.0, 'similarity_fct': 'cos_sim'}99 ```100 101Parameters of the fit()-Method:102```103{104 "epochs": 15,105 "evaluation_steps": 0,106 "evaluator": "NoneType",107 "max_grad_norm": 1,108 "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",109 "optimizer_params": {110 "lr": 2e-05111 },112 "scheduler": "WarmupLinear",113 "steps_per_epoch": null,114 "warmup_steps": 18,115 "weight_decay": 0.01116}117```118 119 120## Full Model Architecture121```122SentenceTransformer(123 (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel 124 (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})125)126```127 128## Citing & Authors129 130@article{FORTH2024110312,131title = {Semantic enrichment for BIM-based building energy performance simulations using semantic textual similarity and fine-tuning multilingual LLM},132journal = {Journal of Building Engineering},133volume = {95},134pages = {110312},135year = {2024},136issn = {2352-7102},137doi = {https://doi.org/10.1016/j.jobe.2024.110312},138url = {https://www.sciencedirect.com/science/article/pii/S2352710224018801},139author = {Kasimir Forth and André Borrmann},140keywords = {BIM to BEM, BEPS, Semantic enrichment, Semantic textual similarity, Fine tuning LLM}141}142<!--- Describe where people can find more information -->