CoolFace
Datasetpublic

model-metadata/code_python_files

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes13kdownloads
DatologyAI_luxical-one_0.py79 linesDownload Raw Back to root
1# /// script2# requires-python = ">=3.12"3# dependencies = [4#     "numpy",5#     "einops",6#     "pandas",7#     "matplotlib",8#     "protobuf",9#     "torch",10#     "sentencepiece",11#     "torchvision",12#     "transformers",13#     "timm",14#     "diffusers",15#     "sentence-transformers",16#     "accelerate",17#     "peft",18#     "slack-sdk",19# ]20# ///21 22try:23    from sentence_transformers import SentenceTransformer24    25    model = SentenceTransformer("DatologyAI/luxical-one", trust_remote_code=True)26    27    sentences = [28        "The weather is lovely today.",29        "It's so sunny outside!",30        "He drove to the stadium."31    ]32    embeddings = model.encode(sentences)33    34    similarities = model.similarity(embeddings, embeddings)35    print(similarities.shape)36    # [3, 3]37    with open('DatologyAI_luxical-one_0.txt', 'w', encoding='utf-8') as f:38        f.write('Everything was good in DatologyAI_luxical-one_0.txt')39except Exception as e:40    import os41    from slack_sdk import WebClient42    client = WebClient(token=os.environ['SLACK_TOKEN'])43    client.chat_postMessage(44        channel='#hub-model-metadata-snippets-sprint',45        text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/DatologyAI_luxical-one_0.txt|DatologyAI_luxical-one_0.txt>',46    )47 48    with open('DatologyAI_luxical-one_0.txt', 'a', encoding='utf-8') as f:49        import traceback50        f.write('''```CODE: 51from sentence_transformers import SentenceTransformer52 53model = SentenceTransformer("DatologyAI/luxical-one", trust_remote_code=True)54 55sentences = [56    "The weather is lovely today.",57    "It's so sunny outside!",58    "He drove to the stadium."59]60embeddings = model.encode(sentences)61 62similarities = model.similarity(embeddings, embeddings)63print(similarities.shape)64# [3, 3]65```66 67ERROR: 68''')69        traceback.print_exc(file=f)70    71finally:72    from huggingface_hub import upload_file73    upload_file(74        path_or_fileobj='DatologyAI_luxical-one_0.txt',75        repo_id='model-metadata/code_execution_files',76        path_in_repo='DatologyAI_luxical-one_0.txt',77        repo_type='dataset',78    )79