Spaces:
Build error
Build error
Download TwitterChatBot/utils.py from zinoubm/ChatBotInterface: direct link, hf CLI and curl.
- Browser
- Download file 337 Bytes
-
https://huggingface.co/spaces/zinoubm/ChatBotInterface/resolve/main/TwitterChatBot/utils.py
- Command line
-
hf download hf://spaces/zinoubm/ChatBotInterface/TwitterChatBot/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/zinoubm/ChatBotInterface/resolve/main/TwitterChatBot/utils.py
337 Bytes
| import numpy as np | |
| def load_prompt(path): | |
| with open(path) as f: | |
| lines = f.readlines() | |
| return "".join(lines) | |
| def cosine_similarity(emb1, emb2): | |
| return np.dot(emb1, emb2) / ( | |
| (np.dot(emb1, emb1) ** 0.5) * (np.dot(emb2, emb2) ** 0.5) | |
| ) | |
| def dot_similarity(emb1, emb2): | |
| return np.dot(emb1, emb2) | |