Skip to main content
Allows you to set parameters when registering a sentence-transformers object.
Sentence transformer embeddings are normalized by default. It is recommended to use normalized embeddings for similarity search.
The trust_remote_code parameter defaults to True, which allows models to execute arbitrary code from their Hugging Face repository during loading. If you are loading untrusted models, set trust_remote_code=False to prevent remote code execution.
ParameterTypeDefault ValueDescription
namestrall-MiniLM-L6-v2The name of the model
devicestrcpuThe device to run the model on (can be cpu or gpu)
normalizeboolTrueWhether to normalize the input text before feeding it to the model
trust_remote_codeboolTrueWhether to trust and execute remote code from the model’s Huggingface repository
You can also load many other model architectures from the library. For example models from sources such as BAAI, Nomic, Salesforce Research, etc. See this HF hub page for all supported models.
Here is an example that uses the BAAI embedding model from the Hugging Face Hub supported models.
Visit sentence-transformers HuggingFace HUB page for more information on the available models.