gbyuvd commited on
Commit
3a31377
·
verified ·
1 Parent(s): 3f72633

Upload 2 files

Browse files
Files changed (2) hide show
  1. examples/directusage.ipynb +68 -0
  2. examples/faiss.ipynb +0 -0
examples/directusage.ipynb ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "e7caa8ad",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stdout",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "(4, 320)\n",
14
+ "tensor([[ 1.0000, 0.1580, -0.4305, -0.5529],\n",
15
+ " [ 0.1580, 1.0000, 0.6916, 0.6522],\n",
16
+ " [-0.4305, 0.6916, 1.0000, 0.9836],\n",
17
+ " [-0.5529, 0.6522, 0.9836, 1.0000]])\n"
18
+ ]
19
+ }
20
+ ],
21
+ "source": [
22
+ "from sentence_transformers import SentenceTransformer\n",
23
+ "\n",
24
+ "# Download from the 🤗 Hub\n",
25
+ "model = SentenceTransformer(\"gbyuvd/miniChembed-prototype\")\n",
26
+ "# Run inference\n",
27
+ "sentences = [\n",
28
+ " 'O=C1/C=C\\\\C=C2/N1C[C@@H]3CNC[C@H]2C3', # Cytisine\n",
29
+ " \"n1c2cc3c(cc2ncc1)[C@@H]4CNC[C@H]3C4\", # Varenicline\n",
30
+ " \"c1ncccc1[C@@H]2CCCN2C\", # Nicotine\n",
31
+ " 'Nc1nc2cncc-2co1', # CID: 162789184 \n",
32
+ "]\n",
33
+ "embeddings = model.encode(sentences)\n",
34
+ "print(embeddings.shape)\n",
35
+ "# (4, 768)\n",
36
+ "\n",
37
+ "# Get the similarity scores for the embeddings\n",
38
+ "similarities = model.similarity(embeddings, embeddings)\n",
39
+ "print(similarities)\n",
40
+ "# tensor([[1.0000, 0.4397, 0.3172, 0.0382],\n",
41
+ "# [0.4397, 1.0000, 0.2543, 0.1725],\n",
42
+ "# [0.3172, 0.2543, 1.0000, 0.2371],\n",
43
+ "# [0.0382, 0.1725, 0.2371, 1.0000]])\n"
44
+ ]
45
+ }
46
+ ],
47
+ "metadata": {
48
+ "kernelspec": {
49
+ "display_name": "base",
50
+ "language": "python",
51
+ "name": "python3"
52
+ },
53
+ "language_info": {
54
+ "codemirror_mode": {
55
+ "name": "ipython",
56
+ "version": 3
57
+ },
58
+ "file_extension": ".py",
59
+ "mimetype": "text/x-python",
60
+ "name": "python",
61
+ "nbconvert_exporter": "python",
62
+ "pygments_lexer": "ipython3",
63
+ "version": "3.13.0"
64
+ }
65
+ },
66
+ "nbformat": 4,
67
+ "nbformat_minor": 5
68
+ }
examples/faiss.ipynb ADDED
The diff for this file is too large to render. See raw diff