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

Optimizations when building a dense index #1910

Open
ftvalentini opened this issue Jun 5, 2024 · 0 comments
Open

Optimizations when building a dense index #1910

ftvalentini opened this issue Jun 5, 2024 · 0 comments

Comments

@ftvalentini
Copy link

In the main class for building dense indexes:

class AutoDocumentEncoder(DocumentEncoder):

the arg fp16 does not seem to be used anywhere (it is kwargs in this line:

def encode(self, texts, titles=None, max_length=256, add_sep=False, **kwargs):
). It could be included in the __init__ as:

self.model = AutoModel.from_pretrained(model_name, torch_dtype=torch.float16)

Moreover, the encode() method coulde use inference_mode(), like:

with torch.inference_mode():
    outputs = self.model(**inputs)

which would significantly reduce the memory footprint of inference.

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