installation.md 3.51 KB
Newer Older
Rayyyyy's avatar
Rayyyyy committed
1
2
# Installation

Rayyyyy's avatar
Rayyyyy committed
3
4
5
6
We recommend **Python 3.8+**, **[PyTorch 1.11.0+](https://pytorch.org/get-started/locally/)**, and **[transformers v4.34.0+](https://github.com/huggingface/transformers)**. There are three options to install Sentence Transformers:
* **Default:** This allows for loading, saving, and inference (i.e., getting embeddings) of models.
* **Default and Training**: All of the above plus training.
* **Development**: All of the above plus some dependencies for developing Sentence Transformers, see [Editable Install](#editable-install).
Rayyyyy's avatar
Rayyyyy committed
7

Rayyyyy's avatar
Rayyyyy committed
8
## Install with pip
Rayyyyy's avatar
Rayyyyy committed
9

Rayyyyy's avatar
Rayyyyy committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
```eval_rst

.. tab:: Default

    ::

        pip install -U sentence-transformers

.. tab:: Default and Training

    ::

        pip install -U "sentence-transformers[train]"

    To use `Weights and Biases <https://wandb.ai/>`_ to track your training logs, you should also install ``wandb`` **(recommended)**::

        pip install wandb
    
    And to track your Carbon Emissions while training and have this information automatically included in your model cards, also install ``codecarbon`` **(recommended)**::

        pip install codecarbon

.. tab:: Development

    ::

        pip install -U "sentence-transformers[dev]"
Rayyyyy's avatar
Rayyyyy committed
37
38
39

```

Rayyyyy's avatar
Rayyyyy committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
## Install with Conda

```eval_rst

.. tab:: Default

    ::

        conda install -c conda-forge sentence-transformers

.. tab:: Default and Training

    ::

        conda install -c conda-forge sentence-transformers accelerate datasets

    To use `Weights and Biases <https://wandb.ai/>`_ to track your training logs, you should also install ``wandb`` **(recommended)**::

        pip install wandb
    
    And to track your Carbon Emissions while training and have this information automatically included in your model cards, also install ``codecarbon`` **(recommended)**::

        pip install codecarbon

.. tab:: Development

    ::

        conda install -c conda-forge sentence-transformers accelerate datasets pre-commit pytest ruff
Rayyyyy's avatar
Rayyyyy committed
69
70

```
Rayyyyy's avatar
Rayyyyy committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

## Install from Source

You can install ``sentence-transformers`` directly from source to take advantage of the bleeding edge `master` branch rather than the latest stable release:

```eval_rst

.. tab:: Default

    ::

        pip install git+https://github.com/UKPLab/sentence-transformers.git

.. tab:: Default and Training

    ::

        pip install -U "sentence-transformers[train] @ git+https://github.com/UKPLab/sentence-transformers.git"

    To use `Weights and Biases <https://wandb.ai/>`_ to track your training logs, you should also install ``wandb`` **(recommended)**::

        pip install wandb
    
    And to track your carbon emissions while training and have this information automatically included in your model cards, also install ``codecarbon`` **(recommended)**::

        pip install codecarbon

.. tab:: Development

    ::

        pip install -U "sentence-transformers[dev] @ git+https://github.com/UKPLab/sentence-transformers.git"

Rayyyyy's avatar
Rayyyyy committed
104
105
```

Rayyyyy's avatar
Rayyyyy committed
106
107
108
109
110
111
112
113
## Editable Install

If you want to make changes to ``sentence-transformers``, you will need an editable install. Clone the repository and install it with these commands:
```
git clone https://github.com/UKPLab/sentence-transformers
cd sentence-transformers
pip install -e ".[train,dev]"
```
Rayyyyy's avatar
Rayyyyy committed
114

Rayyyyy's avatar
Rayyyyy committed
115
These commands will link the new `sentence-transformers` folder and your Python library paths, such that this folder will be used when importing `sentence-transformers`.
Rayyyyy's avatar
Rayyyyy committed
116
117
118

## Install PyTorch with CUDA support

Rayyyyy's avatar
Rayyyyy committed
119
To use a GPU/CUDA, you must install PyTorch with CUDA support. Follow [PyTorch - Get Started](https://pytorch.org/get-started/locally/) for installation steps.