Batch cos_sim for community_detection?
See original GitHub issueI’ve been experimenting with the community_detection
method but noticed I quickly get OOM errors if I use too large of embeddings.
Seeing how it uses cos_sim
to computed all the embedding distances, do you think it would make sense to have the option for batching? I believe you will find other bottlenecks when iterating over the entries, but at least it will complete on larger embeddings.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Cosine Similarity of Neighborhoods (All Pairs, Batch)
This algorithm computes the same similarity scores as the Cosine similarity of neighborhoods, single source algorithm. Instead of selecting a single source ...
Read more >sentence-transformers/util.py at master - GitHub
Computes the cosine similarity cos_sim(a[i], b[j]) for all i and j. ... if isinstance(batch[key], Tensor): ... Function for Fast Community Detection.
Read more >util — Sentence-Transformers documentation
Function for Fast Community Detection Finds in the embeddings all communities, ... Computes the cosine similarity cos_sim(a[i], b[j]) for all i and j....
Read more >UCoDe: Unified Community Detection with Graph ... - arXiv
We propose UCoDe, a unified method for unsupervised commu- nity detection in attributed graphs. It leverages recent developments in Graph Neural ...
Read more >Community detection and reciprocity in networks by jointly ...
We test the ability of the models to (i) recover the communities, (ii) perform edge prediction tasks and (iii) generate sample networks that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes. When the models return pytorch tensors (
return_tensors=True
) you can move them to CPU like this:Computation will then be done on the CPU
Hi @mmaybeno @yjernite has created this batched version. I sadly did not yet have time to review and test it, but hope I can do it soon and integrate it into sentence transformers.