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

wip #50

Open
wants to merge 152 commits into
base: main
Choose a base branch
from
Open

wip #50

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
e84c4d9
Merge pull request #1 from zilliztech/init
alwayslove2013 Jan 20, 2022
d7f307c
[Feature] FederCore - add IndexParser for faiss-ivf-flat
alwayslove2013 Jan 21, 2022
58973d8
add indexHeader type
alwayslove2013 Jan 21, 2022
39b5580
Merge pull request #2 from alwayslove2013/core_faiss_ivf_flat_parser
shanghaikid Jan 23, 2022
8d5b39c
[feature] Add faiss-ivf-flat search function, indexMeta, projector (t…
alwayslove2013 Jan 28, 2022
ad80ebe
fix
alwayslove2013 Jan 28, 2022
0b1d327
improve
alwayslove2013 Jan 28, 2022
12d08b6
improve
alwayslove2013 Jan 28, 2022
9274821
add test data
alwayslove2013 Jan 28, 2022
eaafc6e
Merge pull request #3 from alwayslove2013/core_faiss_ivf_flat_search
shanghaikid Jan 28, 2022
ced233e
add view test
shanghaikid Feb 10, 2022
360c013
Merge pull request #4 from zilliztech/view-test
alwayslove2013 Feb 10, 2022
4d17e72
ivfflat view
alwayslove2013 Feb 10, 2022
20fb70d
parser hnswlib_hnsw
alwayslove2013 Feb 23, 2022
6aaba33
parser hnswlib_hnsw
alwayslove2013 Feb 23, 2022
2c291cf
hnswlib parser deleted mark
alwayslove2013 Feb 24, 2022
0513c65
hnsw overviewData - indexMeta
alwayslove2013 Feb 25, 2022
c6dc9d1
utils - priority queue
alwayslove2013 Feb 25, 2022
69fb2c8
Merge pull request #5 from alwayslove2013/feder_view_ivf_flat
shanghaikid Feb 25, 2022
e2e07f4
Merge branch 'main' into hnswlib_parser
alwayslove2013 Feb 25, 2022
646e7a0
Merge pull request #6 from alwayslove2013/hnswlib_parser
shanghaikid Feb 25, 2022
58f0800
search
alwayslove2013 Mar 4, 2022
2240e5e
hnswlib search
alwayslove2013 Mar 7, 2022
ceda582
Merge branch 'main' of github.com:zilliztech/feder into hnswlib_search
alwayslove2013 Mar 7, 2022
bd7e838
Merge pull request #7 from alwayslove2013/hnswlib_search
shanghaikid Mar 25, 2022
34245d8
hnsw view 1.0
alwayslove2013 Apr 13, 2022
cb67c9d
hnswlib_index_voc
alwayslove2013 Apr 13, 2022
84cf80c
should init the interaction before switching views
alwayslove2013 Apr 13, 2022
86a4438
hover precision
alwayslove2013 Apr 13, 2022
9821541
Merge pull request #8 from zilliztech/hnsw_view
shanghaikid Apr 13, 2022
895795b
add npm release
nameczz Apr 14, 2022
0d2dcca
Merge pull request #9 from zilliztech/add-ci
alwayslove2013 Apr 14, 2022
230dd38
fix npm action
nameczz Apr 14, 2022
0f69bf0
Merge pull request #10 from zilliztech/add-ci
shanghaikid Apr 14, 2022
154dc3e
..
alwayslove2013 Apr 14, 2022
0a78624
..
alwayslove2013 Apr 15, 2022
44132e6
..
alwayslove2013 Apr 15, 2022
fa899d0
remove some older test files
alwayslove2013 Apr 15, 2022
9d2d225
..
alwayslove2013 Apr 15, 2022
8f80cbb
add readme
alwayslove2013 Apr 15, 2022
99485c7
Merge pull request #11 from zilliztech/hsnw_feder_readme
shanghaikid Apr 15, 2022
4b7006c
fix readme
alwayslove2013 Apr 15, 2022
5484705
mereg
alwayslove2013 Apr 15, 2022
6c1ea24
readme - add pipeline
alwayslove2013 Apr 15, 2022
d0c2d1f
fix readme
alwayslove2013 Apr 15, 2022
128cc43
..
alwayslove2013 Apr 15, 2022
67c7769
..
alwayslove2013 Apr 15, 2022
99ba3a6
Merge pull request #12 from zilliztech/hnsw_feder_readme_pipeline
shanghaikid Apr 15, 2022
f11e474
fix readme
alwayslove2013 Apr 15, 2022
0a0cbaa
fix readme
alwayslove2013 Apr 16, 2022
3a83302
Merge pull request #13 from zilliztech/hnsw_feder_readme_pipeline
shanghaikid Apr 17, 2022
b29705e
add federpy
alwayslove2013 Apr 22, 2022
67a9c06
..
alwayslove2013 Apr 22, 2022
87d1323
..
alwayslove2013 Apr 22, 2022
946d703
Merge pull request #14 from zilliztech/feder_py
alwayslove2013 Apr 22, 2022
498ae3f
update version 0.1.0 => 0.1.1
alwayslove2013 Apr 22, 2022
979e2c1
Merge pull request #15 from zilliztech/feder_p_0_1_1
nameczz Apr 22, 2022
64897ca
federpy v0.2.0
alwayslove2013 Apr 22, 2022
81a6a23
fix play/pause icon
alwayslove2013 Apr 22, 2022
eac1335
Merge pull request #16 from zilliztech/hnsw_play_pause_icon
shanghaikid Apr 22, 2022
39b9d6f
remove the data file *.csv and *.index, reduce the size of repo
alwayslove2013 Apr 22, 2022
f3bd0a6
Merge pull request #17 from zilliztech/reduce_size
shanghaikid Apr 22, 2022
cdb976d
show the target image when searching
alwayslove2013 Apr 24, 2022
014ccbb
v0.1.3
alwayslove2013 Apr 24, 2022
2eeac0d
Merge pull request #18 from zilliztech/hnsw_show_target_image
shanghaikid Apr 24, 2022
46a6907
use the cms/vectors.csv
alwayslove2013 Apr 24, 2022
16e098b
readme: add iframe to show the case_html
alwayslove2013 Apr 25, 2022
31f8ca5
..
alwayslove2013 Apr 25, 2022
8c7d889
try, github_pages
alwayslove2013 Apr 25, 2022
1fe822b
Merge pull request #19 from zilliztech/github_pages
shanghaikid Apr 25, 2022
25be0d8
fix bugs: module exports; search params; hover pointer events
alwayslove2013 Apr 28, 2022
f558d10
Merge pull request #20 from zilliztech/fix_search_params
shanghaikid Apr 28, 2022
281186f
fix style
alwayslove2013 Apr 28, 2022
0feb5af
version
alwayslove2013 Apr 28, 2022
3dc9ff6
Merge pull request #21 from zilliztech/fix_search_params
alwayslove2013 Apr 28, 2022
cf4ac1d
federpy: add setSearchParams
alwayslove2013 Apr 29, 2022
b452604
Merge pull request #22 from zilliztech/fix_search_params
shanghaikid Apr 29, 2022
9600068
new federjs
alwayslove2013 May 12, 2022
bb2fe75
..
alwayslove2013 May 12, 2022
af51d88
fix readme; mouse handler
alwayslove2013 May 13, 2022
3fddc33
..
alwayslove2013 May 13, 2022
a55a0f8
Merge pull request #23 from zilliztech/federjs
shanghaikid May 13, 2022
72f8c9a
import error
alwayslove2013 May 13, 2022
f9a8e8a
Merge pull request #24 from zilliztech/federjs
shanghaikid May 13, 2022
440dbb4
fix bugs; federpy;
alwayslove2013 May 17, 2022
f6678c8
..
alwayslove2013 May 17, 2022
8dead85
Merge pull request #25 from zilliztech/ivf_blog
shanghaikid May 17, 2022
b4fbbd1
update version number
alwayslove2013 May 17, 2022
d0ab966
Merge pull request #26 from zilliztech/ivf_blog
shanghaikid May 17, 2022
c6eca65
fix bugs
alwayslove2013 May 17, 2022
8666031
Merge pull request #27 from zilliztech/ivf_blog
shanghaikid May 17, 2022
fbb5513
feature: update federpy
alwayslove2013 May 19, 2022
8fa9c7f
Merge pull request #28 from zilliztech/ivf_blog
shanghaikid May 19, 2022
d958d1a
fix bugs: 29 - searchByVec always return topk8
alwayslove2013 May 26, 2022
2fb131c
Merge pull request #32 from zilliztech/29-bug-searchbyvec-always-retu…
shanghaikid May 26, 2022
71d9aea
fix bugs
alwayslove2013 May 27, 2022
e35cade
Merge pull request #33 from zilliztech/30-bug-lose-a-cluster-when-dis…
shanghaikid May 27, 2022
fdecf22
[feature]: fix ivf_flat voronoi layout
alwayslove2013 May 30, 2022
ae38778
Merge pull request #34 from zilliztech/31-feature-same-cluster-board-…
shanghaikid May 30, 2022
fd7c215
[feature] control the num of hnsw_overview_level
alwayslove2013 May 30, 2022
51dc504
Merge pull request #35 from zilliztech/hnsw_overview_level_num
shanghaikid May 30, 2022
26c3b12
optimize the voronoi layout of ivf_flat when search
alwayslove2013 Jun 6, 2022
9bf1394
optimize the voronoi layout of ivf_flat
alwayslove2013 Jun 6, 2022
760303c
..
alwayslove2013 Jun 6, 2022
f9c3798
get the node of feder (html-element)
alwayslove2013 Jun 6, 2022
e0ffc1a
Merge pull request #36 from zilliztech/optimize_ivf_voronoi
shanghaikid Jun 6, 2022
7f3f113
hnsw force interation
alwayslove2013 Jun 6, 2022
7cdd3ef
each action(overview, search) will return a node
alwayslove2013 Jun 6, 2022
83be4f5
separate failed, different views share one event-handler
alwayslove2013 Jun 7, 2022
ebc1583
update version number
alwayslove2013 Jun 7, 2022
cfa70d1
Merge pull request #37 from zilliztech/fix_hnsw_force_interation
shanghaikid Jun 7, 2022
023e8db
update readme
shanghaikid Jun 7, 2022
6d57ae7
Merge pull request #39 from zilliztech/update-readme
shanghaikid Jun 7, 2022
512a301
..
alwayslove2013 Jun 15, 2022
55a79d2
..
alwayslove2013 Jun 15, 2022
ee94a5c
..
alwayslove2013 Jun 15, 2022
76a0217
Each action generates a new dom node with its own data and interactions
alwayslove2013 Jun 16, 2022
dfe46a9
Merge branch 'main' of github.com:zilliztech/feder into separate_layo…
alwayslove2013 Jun 16, 2022
d45ca05
..
alwayslove2013 Jun 16, 2022
98be92f
..
alwayslove2013 Jun 16, 2022
69ab296
Merge pull request #40 from zilliztech/separate_layout_and_render
shanghaikid Jun 16, 2022
90d5f68
fix bugs
alwayslove2013 Jun 16, 2022
a962c7d
remove lodash
alwayslove2013 Jun 16, 2022
b94d65b
Merge pull request #41 from zilliztech/separate_layout_and_render
shanghaikid Jun 16, 2022
c8a9aca
[feature] support chain functions: feder.setSearchParams().search()
alwayslove2013 Jun 17, 2022
0b80d77
Merge pull request #42 from zilliztech/separate_layout_and_render
shanghaikid Jun 17, 2022
82ebda0
[federpy 0.8.0] Support chain functions: federPy.setSearchParams(para…
alwayslove2013 Jun 17, 2022
c8522bf
update readme
alwayslove2013 Jun 21, 2022
76e2a2d
..
alwayslove2013 Jun 21, 2022
e6bb00f
Merge branch 'main' of github.com:zilliztech/feder into readmeV2
alwayslove2013 Jun 21, 2022
f8420cd
Merge pull request #43 from zilliztech/readmeV2
shanghaikid Jun 21, 2022
4190c79
ivfflat_search_view: info panel shouled be updated before animation
alwayslove2013 Jun 22, 2022
f643fab
..
alwayslove2013 Jun 22, 2022
5db9b06
update version
alwayslove2013 Jun 22, 2022
9f525ec
Merge pull request #44 from zilliztech/readmeV2
shanghaikid Jun 22, 2022
2303a36
Update README.md
shanghaikid Jun 23, 2022
bf38a73
add figure: ivfflat_overview
alwayslove2013 Jun 24, 2022
494a1ca
Merge pull request #45 from zilliztech/readmeV2
shanghaikid Jun 24, 2022
19cbcd3
Update README.md
shanghaikid Jul 12, 2022
d2675cd
Update README.md
shanghaikid Jul 12, 2022
89b5d9f
add node_server for feder-core
alwayslove2013 Jul 18, 2022
38cd59c
seperate node_server from feder lib
alwayslove2013 Jul 19, 2022
6fe08e6
feder 2.0 init
alwayslove2013 Aug 12, 2022
162f743
federview
alwayslove2013 Aug 12, 2022
42dc720
..
alwayslove2013 Aug 12, 2022
4e0eaf6
add federView-type
alwayslove2013 Aug 18, 2022
29b53f0
..
alwayslove2013 Aug 18, 2022
8e5ec3c
..
alwayslove2013 Aug 18, 2022
d82bf5a
..
alwayslove2013 Aug 18, 2022
9585656
wip
rainy-25Ghz Aug 30, 2022
48e19bc
wip
rainy-25Ghz Sep 20, 2022
54266ea
wip
rainy-25Ghz Sep 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Feder release action

on:
release:
types: [released]
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14

- name: Install dependencies
run: npm install

- name: Build app
run: |
npm run build

- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
.DS_Store
.nyc_output
.vscode
.ipynb_checkpoints
*.egg-info
coverage/
node_modules/
# test/data/*
hnswlib_hnsw_random_1M.index
images/
dist
*.csv
*.index
*.pyc
test/bundle.js
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
223 changes: 191 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,209 @@
# feder
# Feder

## What is feder
Feder is built for visualize anns index files, so that we can have a better understanding of anns and high dimensional vectors. so far, we are focusing on Faiss index and HNSW index, we will cover more index types later.

## Quick start
### installation
``` shell
#install
npm install @zilliz/Feder
Feder is an javascript tool that built for understanding your embedding vectors, feder visualizes faiss, hnswlib and other anns index files, so that we can have a better understanding how anns work and what are high dimensional vector embeddings.

So far, we are focusing on the Faiss (only ivf_flat) index file and HNSWlib (hnsw) index file, we will cover more index types later.

Feder is written in **javascript**, and we also provide a python library **federpy**, which is based on federjs.

> **_NOTE:_**

- In IPython environment, it supports users to generate the corresponding visualization directly.
- In other environments, it supports outputting visualizations as html files, which can be opened by the user through the browser with web service enabled.


### Online demos
- [Understanding vector embeddings with Feder by a reverse image search example](https://observablehq.com/@min-tian/reverse-image-search-feder-faiss-ivf_flat-visualizations)
- [Javascript example (Observable)](https://observablehq.com/@min-tian/feder)
- [Jupternotebook example (Colab)](https://colab.research.google.com/drive/12L_oJPR-yFDlORpPondsqGNTPVsSsUwi#scrollTo=N3qqBAYxYcbt)

### How feder works
- [Feder ivf layout](https://observablehq.com/@min-tian/feder-layout-ivf_flat/2)
- [Feder hnsw layout ](https://observablehq.com/@min-tian/feder-layout-hnsw/2)

### Wiki

- [Usage](https://github.com/zilliztech/feder/wiki)

### HNSW visualization screenshots

![image](./fig/hnsw_search.png)

### IVF_Flat visualization screenshots

![image](./fig/ivfflat_coarse.png)
![image](./fig/ivfflat_fine_polar.png)
![image](./fig/ivfflat_fine_project.png)

## Quick Start

### Installation

Use npm or yarn.

```shell
yarn install @zilliz/feder
```

### basic usage
### Material Preparation

Make sure that you have built an index and dumped the index file by Faiss or HNSWlib.

### Init Feder

Specifying the dom container that you want to show the visualizations.

```js
import { Feder } from '@zilliz/Feder';
import { Feder } from '@zilliz/feder';

const feder = new Feder({
file: 'faiss_file', // file path
type: 'faiss', // faiss | hnsw
domContainer, // attach dom to render
filePath: 'faiss_file', // file path
source: 'faiss', // faiss | hnswlib
domSelector: '#container', // attach dom to render
viewParams: {}, // optional
});
```

### Visualize the index structure.

// you can call search to visualize the search process
feder.search(target, params);
// or reset to initialize state
feder.reset();
- HNSW - Feder will show the top-3 levels of the hnsw-tree.
- IVF_Flat - Feder will show all the clusters.

```js
feder.overview();
```
## API
TBD

## Examples
### Use feder with d3
TBD
### Explore the search process.

### Use feder with react
TBD
Set search parameters (optional) and Specify the query vector.

```js
feder
.setSearchParams({
k: 8, // hnsw, ivf_flat
ef: 100, // hnsw (ef_search)
nprobe: 8, // ivf_flat
})
.search(target_vector);
```

## Examples

## How feder works
TBD
We prepare a simple case, which is the visualizations of the `hnsw` and `ivf_flat` with 17,000+ vectors that embedded from [VOC 2012](http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar)).

Only need enable a web service.

## How to contribute
```shell
# install dependencies
npm install
# create build
npm run build
# test
npm run test
git clone [email protected]:zilliztech/feder.git
cd test
python -m http.server
```

Then open http://localhost:8000/

It will show 4 visualizations:
- `hnsw` overview
- `hnsw` search view
- `ivf_flat` overview
- `ivf_flat` search view

## Pipeline - explore a new dataset with feder

### Step 1. Dataset preparation

Put all images to **test/data/images/**. (example dataset [VOC 2012](http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar))

You can also generate random vectors without embedding for index building and skip to **step 3**.

### Step 2. Generate embedding vectors

Recommend to use [towhee](https://github.com/towhee-io/towhee), one line of code to generating embedding vectors!

We have the [encoded vectors](https://assets.zilliz.com/voc_vectors_e8ec5a5eae.csv) ready for you.

### Step 3. Build an index and dump it.

You can use [faiss](https://github.com/facebookresearch/faiss) or [hnswlib](https://github.com/nmslib/hnswlib) to build the index.

(\*Detailed procedures please refer to their tutorials.)

Referring to **test/data/gen_hnswlib_index_\*.py** or **test/data/gen_faiss_index_\*.py**

Or we have the [index file](https://assets.zilliz.com/hnswlib_hnsw_voc_17k_1f1dfd63a9.index) ready for you.

### Step 4. Init Feder.

```js
import { Feder } from '@zilliz/feder';
import * as d3 from 'd3';

const domSelector = '#container';
const filePath = [index_file_path];

const mediaCallback = (rowId) => mediaUrl;

const feder = new Feder({
filePath,
source: 'hnswlib',
domSelector,
viewParams: {
mediaType: 'img',
mediaCallback,
},
});
```

If use the random_data, **no need** to specify the mediaType.

```js
import { Feder } from '@zilliz/feder';
import * as d3 from 'd3';

const domSelector = '#container';
const filePath = [index_file_path];

const feder = new Feder({
filePath,
source: 'hnswlib',
domSelector,
});
```

### Step 5. Explore the index!

Visualize the overview

```js
feder.overview();
```

or visualize the search process.

```js
feder.search(target_vector[, targetMediaUrl]);
```

or randomly select an vector as the target to visualize the search process.

```js
feder.searchRandTestVec();
```

More cases refer to the **test/test.js**

## Blogs

- [Visualize Your Approximate Nearest Neighbor Search with Feder](https://zilliz.com/blog/Visualize-Your-Approximate-Nearest-Neighbor-Search-with-Feder)
- [Visualize Reverse Image Search with Feder](https://zilliz.com/blog/Visualize-Reverse-Image-Search-with-Feder)

## Roadmap

We're still in the early stages, we will support more types of anns index, and more unstructured data viewer, stay tuned.

## Acknowledgments

- [faiss](https://github.com/facebookresearch/faiss)
- [hnswlib](https://github.com/nmslib/hnswlib)
- [d3](https://github.com/d3/d3)
29 changes: 0 additions & 29 deletions cjs/Feder-core.js

This file was deleted.

36 changes: 0 additions & 36 deletions cjs/Feder.js

This file was deleted.

Loading