Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I make it require significantly less memory and start up faster? #1664

Open
ErfolgreichCharismatisch opened this issue Aug 10, 2022 · 0 comments

Comments

@ErfolgreichCharismatisch
Copy link

ErfolgreichCharismatisch commented Aug 10, 2022

This is how I use sentence-transformers on Windows 10 home

pkl = 'path/to/some.pkl'
query = 'some query'
from sentence_transformers import SentenceTransformer, util
model = SentenceTransformer('path/to/sentence-transformers_msmarco-distilbert-multilingual-en-de-v2-tmp-trained-scratch', device='cuda')

with open(pkl, "rb") as fIn:
  stored_data = pickle.load(fIn)
  doc_emb = stored_data['doc_emb']
  docs = stored_data['docs']


query_emb = model.encode(query.replace("\"",""), batch_size=6)
scores = util.dot_score(query_emb, doc_emb)[0].cpu().tolist()
del query_emb
//use results

The pkl is 1 GB in size, and when running the script, nothing else can run due to the amount of RAM and swapfile occupation.

The first run is also time consuming, then each query comes quickly.

How can I make it require significantly less memory and start up faster?

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

No branches or pull requests

1 participant