Skip to content

Commit fad7971

Browse files
committed
docs: Improve readability (#2378)
Summary: Signed-off-by: Ryan Russell <[email protected]> Various readability fixes focused on `.md` files: - Grammar - Fix some incorrect command references to `distributed_kmeans.py` - Styling the markdown bash code snippets sections so they format Attempted to put a lot of little things into one PR and commit; let me know if any mods are needed! Best, Ryan Pull Request resolved: facebookresearch/faiss#2378 Reviewed By: alexanderguzhva Differential Revision: D37717671 Pulled By: mdouze fbshipit-source-id: 0039192901d98a083cd992e37f6b692d0572103a
1 parent 2f6d001 commit fad7971

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

benchs/bench_all_ivf/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The code is organized as:
1111
- `bench_all_ivf.py`: evaluate one type of inverted file
1212

1313
- `run_on_cluster_generic.bash`: call `bench_all_ivf.py` for all tested types of indices.
14-
Since the number of experiments is quite large the script is structued so that the benchmark can be run on a cluster.
14+
Since the number of experiments is quite large the script is structured so that the benchmark can be run on a cluster.
1515

1616
- `parse_bench_all_ivf.py`: make nice tradeoff plots from all the results.
1717

benchs/distributed_ondisk/README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ Hopefully, changing to another type of scheduler should be quite straightforward
1010

1111
## Distributed k-means
1212

13-
To cluster 500M vectors to 10M centroids, it is useful to have a distriubuted k-means implementation.
13+
To cluster 500M vectors to 10M centroids, it is useful to have a distributed k-means implementation.
1414
The distribution simply consists in splitting the training vectors across machines (servers) and have them do the assignment.
1515
The master/client then synthesizes the results and updates the centroids.
1616

1717
The distributed k-means implementation here is based on 3 files:
1818

1919
- [`distributed_kmeans.py`](distributed_kmeans.py) contains the k-means implementation.
2020
The main loop of k-means is re-implemented in python but follows closely the Faiss C++ implementation, and should not be significantly less efficient.
21-
It relies on a `DatasetAssign` object that does the assignement to centrtoids, which is the bulk of the computation.
21+
It relies on a `DatasetAssign` object that does the assignment to centroids, which is the bulk of the computation.
2222
The object can be a Faiss CPU index, a GPU index or a set of remote GPU or CPU indexes.
2323

2424
- [`run_on_cluster.bash`](run_on_cluster.bash) contains the shell code to run the distributed k-means on a cluster.
@@ -30,7 +30,7 @@ The file is also assumed to be accessible from all server machines with eg. a di
3030

3131
### Local tests
3232

33-
Edit `distibuted_kmeans.py` to point `testdata` to your local copy of the dataset.
33+
Edit `distributed_kmeans.py` to point `testdata` to your local copy of the dataset.
3434

3535
Then, 4 levels of sanity check can be run:
3636
```bash
@@ -47,7 +47,7 @@ The output should look like [This gist](https://gist.github.com/mdouze/ffa01fe66
4747

4848
### Distributed sanity check
4949

50-
To run the distributed k-means, `distibuted_kmeans.py` has to be run both on the servers (`--server` option) and client sides (`--client` option).
50+
To run the distributed k-means, `distributed_kmeans.py` has to be run both on the servers (`--server` option) and client sides (`--client` option).
5151
Edit the top of `run_on_cluster.bash` to set the path of the data to cluster.
5252

5353
Sanity checks can be run with
@@ -56,7 +56,7 @@ Sanity checks can be run with
5656
bash run_on_cluster.bash test_kmeans_0
5757
# using all the machine's GPUs
5858
bash run_on_cluster.bash test_kmeans_1
59-
# distrbuted run, with one local server per GPU
59+
# distributed run, with one local server per GPU
6060
bash run_on_cluster.bash test_kmeans_2
6161
```
6262
The test `test_kmeans_2` simulates a distributed run on a single machine by starting one server process per GPU and connecting to the servers via the rpc protocol.
@@ -67,10 +67,10 @@ The output should look like [this gist](https://gist.github.com/mdouze/5b2dc69b7
6767
### Distributed run
6868

6969
The way the script can be distributed depends on the cluster's scheduling system.
70-
Here we use Slurm, but it should be relatively easy to adapt to any scheduler that can allocate a set of matchines and start the same exectuable on all of them.
70+
Here we use Slurm, but it should be relatively easy to adapt to any scheduler that can allocate a set of machines and start the same executable on all of them.
7171

7272
The command
73-
```
73+
```bash
7474
bash run_on_cluster.bash slurm_distributed_kmeans
7575
```
7676
asks SLURM for 5 machines with 4 GPUs each with the `srun` command.
@@ -90,12 +90,12 @@ The output should look like [this gist](https://gist.github.com/mdouze/8d25e89fb
9090
For the real run, we run the clustering on 50M vectors to 1M centroids.
9191
This is just a matter of using as many machines / GPUs as possible in setting the output centroids with the `--out filename` option.
9292
Then run
93-
```
93+
```bash
9494
bash run_on_cluster.bash deep1b_clustering
9595
```
9696

9797
The last lines of output read like:
98-
```
98+
```bash
9999
Iteration 19 (898.92 s, search 875.71 s): objective=1.33601e+07 imbalance=1.303 nsplit=0
100100
0: writing centroids to /checkpoint/matthijs/ondisk_distributed/1M_centroids.npy
101101
```
@@ -121,25 +121,25 @@ This is performed by the script [`make_trained_index.py`](make_trained_index.py)
121121

122122
## Building the index by slices
123123

124-
We call the slices "vslices" as they are vertical slices of the big matrix, see explanation in the wiki section [Split across datanbase partitions](https://github.com/facebookresearch/faiss/wiki/Indexing-1T-vectors#split-across-database-partitions).
124+
We call the slices "vslices" as they are vertical slices of the big matrix, see explanation in the wiki section [Split across database partitions](https://github.com/facebookresearch/faiss/wiki/Indexing-1T-vectors#split-across-database-partitions).
125125

126126
The script [make_index_vslice.py](make_index_vslice.py) makes an index for a subset of the vectors of the input data and stores it as an independent index.
127127
There are 200 slices of 5M vectors each for Deep1B.
128128
It can be run in a brute-force parallel fashion, there is no constraint on ordering.
129129
To run the script in parallel on a slurm cluster, use:
130-
```
130+
```bash
131131
bash run_on_cluster.bash make_index_vslices
132132
```
133133
For a real dataset, the data would be read from a DBMS.
134134
In that case, reading the data and indexing it in parallel is worthwhile because reading is very slow.
135135

136-
## Splitting accross inverted lists
136+
## Splitting across inverted lists
137137

138138
The 200 slices need to be merged together.
139139
This is done with the script [merge_to_ondisk.py](merge_to_ondisk.py), that memory maps the 200 vertical slice indexes, extracts a subset of the inverted lists and writes them to a contiguous horizontal slice.
140140
We slice the inverted lists into 50 horizontal slices.
141141
This is run with
142-
```
142+
```bash
143143
bash run_on_cluster.bash make_index_hslices
144144
```
145145

@@ -150,11 +150,11 @@ The horizontal slices need to be loaded in the right order and combined into an
150150
This is done in the [combined_index.py](combined_index.py) script.
151151
It provides a `CombinedIndexDeep1B` object that contains an index object that can be searched.
152152
To test, run:
153-
```
153+
```bash
154154
python combined_index.py
155155
```
156156
The output should look like:
157-
```
157+
```bash
158158
(faiss_1.5.2) matthijs@devfair0144:~/faiss_versions/faiss_1Tcode/faiss/benchs/distributed_ondisk$ python combined_index.py
159159
reading /checkpoint/matthijs/ondisk_distributed//hslices/slice49.faissindex
160160
loading empty index /checkpoint/matthijs/ondisk_distributed/trained.faissindex
@@ -169,14 +169,14 @@ ie. searching is a lot slower than from RAM.
169169

170170
## Distributed query
171171

172-
To reduce the bandwidth required from the machine that does the queries, it is possible to split the search accross several search servers.
172+
To reduce the bandwidth required from the machine that does the queries, it is possible to split the search across several search servers.
173173
This way, only the effective results are returned to the main machine.
174174

175175
The search client and server are implemented in [`search_server.py`](search_server.py).
176176
It can be used as a script to start a search server for `CombinedIndexDeep1B` or as a module to load the clients.
177177

178178
The search servers can be started with
179-
```
179+
```bash
180180
bash run_on_cluster.bash run_search_servers
181181
```
182182
(adjust to the number of servers that can be used).

benchs/link_and_code/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The test runs with 3 files:
3030

3131
- `datasets.py`: code to load the datasets. The example code runs on the
3232
deep1b and bigann datasets. See the [toplevel README](../README.md)
33-
on how to downlod them. They should be put in a directory, edit
33+
on how to download them. They should be put in a directory, edit
3434
datasets.py to set the path.
3535

3636
- `neighbor_codec.py`: this is where the representation is trained.
@@ -46,7 +46,7 @@ Reproducing Table 2 in the paper
4646
The results of table 2 (accuracy on deep100M) in the paper can be
4747
obtained with:
4848

49-
```
49+
```bash
5050
python bench_link_and_code.py \
5151
--db deep100M \
5252
--M0 6 \
@@ -84,7 +84,7 @@ Explanation of the flags:
8484
- `--neigh_recons_codes $bdir/deep1M_PQ36_M6_nsq4_codes.npy`: filename
8585
for the encoded weights (beta) of the combination
8686

87-
- `--k_reorder 0,5`: number of restults to reorder. 0 = baseline
87+
- `--k_reorder 0,5`: number of results to reorder. 0 = baseline
8888
without reordering, 5 = value used throughout the paper
8989

9090
- `--efSearch 1,1024`: number of nodes to visit (T in the paper)
@@ -98,7 +98,7 @@ ground-truth file is not provided)
9898

9999
2. build the index and store it
100100

101-
3. compute the residuals and train the beta vocabulary to do the reconstuction
101+
3. compute the residuals and train the beta vocabulary to do the reconstruction
102102

103103
4. encode the vertices
104104

@@ -108,7 +108,7 @@ With option `--exhaustive` the results of the exhaustive column can be
108108
obtained.
109109

110110
The run above should output:
111-
```
111+
```bash
112112
...
113113
setting k_reorder=5
114114
...
@@ -117,7 +117,7 @@ efSearch=1024 0.3132 ms per query, R@1: 0.4283 R@10: 0.6337 R@100: 0.6520
117117
```
118118
which matches the paper's table 2.
119119

120-
Note that in multi-threaded mode, the building of the HNSW strcuture
120+
Note that in multi-threaded mode, the building of the HNSW structure
121121
is not deterministic. Therefore, the results across runs may not be exactly the same.
122122

123123
Reproducing Figure 5 in the paper
@@ -126,7 +126,7 @@ Reproducing Figure 5 in the paper
126126
Figure 5 just evaluates the combination of HNSW and PQ. For example,
127127
the operating point L6&OPQ40 can be obtained with
128128

129-
```
129+
```bash
130130
python bench_link_and_code.py \
131131
--db deep1M \
132132
--M0 6 \
@@ -144,7 +144,7 @@ reproduction value).
144144

145145
The output should look like:
146146

147-
```
147+
```bash
148148
setting k_reorder=0
149149
efSearch=16 0.0147 ms per query, R@1: 0.3409 R@10: 0.4388 R@100: 0.4394 ndis 2629735 nreorder 0
150150
efSearch=64 0.0122 ms per query, R@1: 0.4836 R@10: 0.6490 R@100: 0.6509 ndis 4623221 nreorder 0

c_api/INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ and cuBLAS.
7575
Using the GPU with the C API
7676
----------------------------
7777

78-
A standard GPU resurces object can be obtained by the name `FaissStandardGpuResources`:
78+
A standard GPU resources object can be obtained by the name `FaissStandardGpuResources`:
7979

8080
```c
8181
FaissStandardGpuResources* gpu_res = NULL;

contrib/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ A very simple Remote Procedure Call library, where function parameters and resul
1919
### client_server.py
2020

2121
The server handles requests to a Faiss index. The client calls the remote index.
22-
This is mainly to shard datasets over several machines, see [Distributd index](https://github.com/facebookresearch/faiss/wiki/Indexes-that-do-not-fit-in-RAM#distributed-index)
22+
This is mainly to shard datasets over several machines, see [Distributed index](https://github.com/facebookresearch/faiss/wiki/Indexes-that-do-not-fit-in-RAM#distributed-index)
2323

2424
### ondisk.py
2525

@@ -52,7 +52,7 @@ A few functions to override the coarse quantizer in IVF, providing additional fl
5252

5353
(may require h5py)
5454

55-
Defintion of how to access data for some standard datsets.
55+
Definition of how to access data for some standard datasets.
5656

5757
### factory_tools.py
5858

0 commit comments

Comments
 (0)