Skip to content

Add function to get text embedding and similarity - #412

Merged
cthoyt merged 5 commits into
mainfrom
text-embedding
Aug 1, 2025
Merged

Add function to get text embedding and similarity#412
cthoyt merged 5 commits into
mainfrom
text-embedding

Conversation

@cthoyt

@cthoyt cthoyt commented Aug 1, 2025

Copy link
Copy Markdown
Member

motivated by cthoyt/ols-client#9, this adds a function for getting an embedding based on putting an entity's name + description into sentence_transformers. It also adds a quick function for calculating term similarity based on text embeddings

import pyobo

>>> pyobo.get_text_embedding("GO:0000001")
[-5.68335280e-02  7.96175096e-03 -3.36112119e-02  2.34440481e-03 ... ]

>>> pyobo.get_text_embedding_similarity("GO:0000001", "GO:0000004")
0.24702128767967224

future:

  1. batch mode
  2. incorporate synonyms

@cthoyt cthoyt changed the title Add function to get text embedding Add function to get text embedding and similarity Aug 1, 2025
@cthoyt
cthoyt enabled auto-merge (squash) August 1, 2025 08:53
@cthoyt
cthoyt disabled auto-merge August 1, 2025 08:53
@cthoyt
cthoyt enabled auto-merge (squash) August 1, 2025 08:54
@cthoyt
cthoyt merged commit de5ee44 into main Aug 1, 2025
10 checks passed
@cthoyt
cthoyt deleted the text-embedding branch August 1, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant