AkimfromParis
commited on
Commit
•
427f576
1
Parent(s):
197aba7
Delete sidebar for easy read
Browse files
app.py
CHANGED
@@ -1,249 +1,248 @@
|
|
1 |
-
import os, sys
|
2 |
-
import streamlit as st
|
3 |
-
|
4 |
-
st.set_page_config(page_title="Pricing for scalar and binary embeddings", page_icon=":floppy-disk:", layout="wide",
|
5 |
-
|
6 |
-
#
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
st.
|
11 |
-
|
12 |
-
st.
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
st.
|
20 |
-
|
21 |
-
|
22 |
-
st.
|
23 |
-
|
24 |
-
st.write("
|
25 |
-
|
26 |
-
st.write(
|
27 |
-
|
28 |
-
|
29 |
-
with
|
30 |
-
st.write("***
|
31 |
-
|
32 |
-
st.write("***
|
33 |
-
|
34 |
-
st.write("***
|
35 |
-
|
36 |
-
st.write("***
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
st.write("***
|
42 |
-
st.
|
43 |
-
|
44 |
-
st.write(
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
r = st.write(str(round(
|
54 |
-
|
55 |
-
|
56 |
-
r = st.write(str(round(
|
57 |
-
|
58 |
-
|
59 |
-
r = st.write(str(round(
|
60 |
-
|
61 |
-
|
62 |
-
r = st.write(str(round(
|
63 |
-
|
64 |
-
|
65 |
-
r = st.write(str(round(
|
66 |
-
|
67 |
-
|
68 |
-
st.write(
|
69 |
-
|
70 |
-
|
71 |
-
st.write(str(round(
|
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 |
-
st.
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
int8_mem_1 = dim_1 / 4
|
125 |
-
st.write(str(round(int8_mem_1, 2)) + " GB")
|
126 |
-
|
127 |
-
int8_mem_2 = dim_2 / 4
|
128 |
-
st.write(str(round(int8_mem_2, 2)) + " GB")
|
129 |
-
|
130 |
-
int8_mem_3 = dim_3 / 4
|
131 |
-
st.write(str(round(int8_mem_3, 2)) + " GB")
|
132 |
-
|
133 |
-
int8_mem_4 = dim_4 / 4
|
134 |
-
st.write(str(round(int8_mem_4, 2)) + " GB")
|
135 |
-
|
136 |
-
int8_mem_5 = dim_5 / 4
|
137 |
-
st.write(str(round(int8_mem_5, 2)) + " GB")
|
138 |
-
|
139 |
-
int8_mem_6 = dim_6 / 4
|
140 |
-
st.write(str(round(int8_mem_6, 2)) + " GB")
|
141 |
-
|
142 |
-
int8_mem_7 = dim_7 / 4
|
143 |
-
st.write(str(round(int8_mem_7, 2)) + " GB")
|
144 |
-
|
145 |
-
int8_mem_8 = dim_8 / 4
|
146 |
-
st.write(str(round(int8_mem_8, 2)) + " GB")
|
147 |
-
with
|
148 |
-
|
149 |
-
st.
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
st.write(str(round(
|
200 |
-
|
201 |
-
|
202 |
-
st.write(
|
203 |
-
|
204 |
-
|
205 |
-
st.write(str(round(
|
206 |
-
|
207 |
-
|
208 |
-
st.write(str(round(
|
209 |
-
|
210 |
-
|
211 |
-
st.write(str(round(
|
212 |
-
|
213 |
-
|
214 |
-
st.write(str(round(
|
215 |
-
|
216 |
-
|
217 |
-
st.write(str(round(
|
218 |
-
|
219 |
-
|
220 |
-
st.write(str(round(
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
st.write("
|
229 |
-
|
230 |
-
|
231 |
-
st.write("- [
|
232 |
-
st.write("- [
|
233 |
-
|
234 |
-
st.write("- [
|
235 |
-
st.write("- [
|
236 |
-
|
237 |
-
st.write("- [
|
238 |
-
st.write("- [
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
st.
|
243 |
-
st.write("
|
244 |
-
|
245 |
-
st.write("- [
|
246 |
-
st.write("- [
|
247 |
-
st.
|
248 |
-
st.write("
|
249 |
-
st.write("- [Binary Embedding-based Retrieval at Tencent](https://arxiv.org/abs/2302.08714)")
|
|
|
1 |
+
import os, sys
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
st.set_page_config(page_title="Pricing for scalar and binary embeddings", page_icon=":floppy-disk:", layout="wide", menu_items={'Report a bug': "mailto:[email protected]"})
|
5 |
+
|
6 |
+
kb2gb = 1024**3 #Conversion memory
|
7 |
+
|
8 |
+
# MAIN
|
9 |
+
st.title("***Pricing model with scalar and binary embeddings***")
|
10 |
+
st.write("***Akim Mousterou*** (April 2024) *[LinkedIn](https://www.linkedin.com/in/akim-mousterou/), [HuggingFace](https://huggingface.co/Akimfromparis), and [GitHub](https://github.com/AkimParis)*")
|
11 |
+
|
12 |
+
st.write("*The real democratization of AI can only be achieved by a powerful open-source ecosystem and low prices for memory/GPU usage. Thanks to quantization, we can say bye to float32, and hello binary! Compression-friendly embedding models implemented in int8 and binary can save up to x4 and x32 of memory, storage, and, costs. To achieve X32 compute efficiency and retain ∼96% of retrieval performance, the binary quantization is powered by the normalization of embedding values (either 0 or 1), the calculation of Hamming Distance with only 2 CPU runtimes, and the application of ReRank step of [Yamada et al (2021)](https://arxiv.org/abs/2106.00882). Scalar and binary embeddings revealed great retrieval efficiency with just a minimal degradation of performance, perfect for NLP downstream tasks, semantic search, recommendation systems, and retrieval-augmented generation solutions.*")
|
13 |
+
st.divider() ###
|
14 |
+
col1, col2 = st.columns([1,1])
|
15 |
+
with col1:
|
16 |
+
cloud_price = st.slider("Price of the instance: *From 0 to 20 (default $3.8 per GB/mo estimated on x2gd instances on AWS)* ", 0.0,20.00,3.8)
|
17 |
+
with col2:
|
18 |
+
docs = st.slider("Number of vector embeddings: *From 100M to 1 Billion (default 250M)*", 100000000,1000000000,250000000, step=10000000) #Defaul 250M
|
19 |
+
st.divider() ###
|
20 |
+
col3, col4, col5, col6, col7, col8, col9, col10 = st.columns([1,1,1,1,1,1,1,1])
|
21 |
+
with col3:
|
22 |
+
st.write("***Embedding dimension***")
|
23 |
+
with col4:
|
24 |
+
st.write("***Memory usage in Gb***")
|
25 |
+
with col5:
|
26 |
+
st.write("***Price on a monthly basis***")
|
27 |
+
with col6:
|
28 |
+
st.write("***Price on a yearly basis***")
|
29 |
+
with col7:
|
30 |
+
st.write("***Int8 memory*** (div. by 4)")
|
31 |
+
with col8:
|
32 |
+
st.write("***Int8 price*** (div. by 4)")
|
33 |
+
with col9:
|
34 |
+
st.write("***Binary memory*** (div. by 32)")
|
35 |
+
with col10:
|
36 |
+
st.write("***Binary price*** (div. by 32)")
|
37 |
+
|
38 |
+
col11, col12, col13, col14, col15, col16, col17, col18 = st.columns([1,1,1,1,1,1,1,1])
|
39 |
+
with col11:
|
40 |
+
st.write("***384***")
|
41 |
+
st.write("***512***")
|
42 |
+
st.write("***768***")
|
43 |
+
st.write("***1024***")
|
44 |
+
st.write("***1536***")
|
45 |
+
st.write("***2048***")
|
46 |
+
st.write("***3072***")
|
47 |
+
st.write("***4096***")
|
48 |
+
with col12:
|
49 |
+
dim_1 = ((384 * 4) * docs) / kb2gb
|
50 |
+
st.write(str(round(dim_1, 2)) + " GB")
|
51 |
+
|
52 |
+
dim_2 = ((512 * 4) * docs) / kb2gb
|
53 |
+
r = st.write(str(round(dim_2, 2)) + " GB")
|
54 |
+
|
55 |
+
dim_3 = ((768 * 4) * docs) / kb2gb
|
56 |
+
r = st.write(str(round(dim_3, 2)) + " GB")
|
57 |
+
|
58 |
+
dim_4 = ((1024 * 4) * docs) / kb2gb
|
59 |
+
r = st.write(str(round(dim_4, 2)) + " GB")
|
60 |
+
|
61 |
+
dim_5 = ((1536 * 4) * docs) / kb2gb
|
62 |
+
r = st.write(str(round(dim_5, 2)) + " GB")
|
63 |
+
|
64 |
+
dim_6 = ((2048 * 4) * docs) / kb2gb
|
65 |
+
r = st.write(str(round(dim_6, 2)) + " GB")
|
66 |
+
|
67 |
+
dim_7 = ((3072 * 4) * docs) / kb2gb
|
68 |
+
r = st.write(str(round(dim_7, 2)) + " GB")
|
69 |
+
|
70 |
+
dim_8 = ((4096 * 4) * docs) / kb2gb
|
71 |
+
r = st.write(str(round(dim_8, 2)) + " GB")
|
72 |
+
|
73 |
+
with col13:
|
74 |
+
price_month_1 = dim_1 * cloud_price
|
75 |
+
st.write(str(round(price_month_1, 2)) + " $")
|
76 |
+
|
77 |
+
price_month_2 = dim_2 * cloud_price
|
78 |
+
st.write(str(round(price_month_2, 2)) + " $")
|
79 |
+
|
80 |
+
price_month_3 = dim_3 * cloud_price
|
81 |
+
st.write(str(round(price_month_3, 2)) + " $")
|
82 |
+
|
83 |
+
price_month_4 = dim_4 * cloud_price
|
84 |
+
st.write(str(round(price_month_4, 2)) + " $")
|
85 |
+
|
86 |
+
price_month_5 = dim_5 * cloud_price
|
87 |
+
st.write(str(round(price_month_5, 2)) + " $")
|
88 |
+
|
89 |
+
price_month_6 = dim_6 * cloud_price
|
90 |
+
st.write(str(round(price_month_6, 2)) + " $")
|
91 |
+
|
92 |
+
price_month_7 = dim_7 * cloud_price
|
93 |
+
st.write(str(round(price_month_7, 2)) + " $")
|
94 |
+
|
95 |
+
price_month_8 = dim_8 * cloud_price
|
96 |
+
st.write(str(round(price_month_8, 2)) + " $")
|
97 |
+
|
98 |
+
with col14:
|
99 |
+
price_year_1 = price_month_1 * 12
|
100 |
+
st.write(str(round(price_year_1, 2)) + " $")
|
101 |
+
|
102 |
+
price_year_2 = price_month_2 * 12
|
103 |
+
st.write(str(round(price_year_2, 2)) + " $")
|
104 |
+
|
105 |
+
price_year_3 = price_month_3 * 12
|
106 |
+
st.write(str(round(price_year_3, 2)) + " $")
|
107 |
+
|
108 |
+
price_year_4 = price_month_4 * 12
|
109 |
+
st.write(str(round(price_year_4, 2)) + " $")
|
110 |
+
|
111 |
+
price_year_5 = price_month_5 * 12
|
112 |
+
st.write(str(round(price_year_5, 2)) + " $")
|
113 |
+
|
114 |
+
price_year_6 = price_month_6 * 12
|
115 |
+
st.write(str(round(price_year_6, 2)) + " $")
|
116 |
+
|
117 |
+
price_year_7 = price_month_7 * 12
|
118 |
+
st.write(str(round(price_year_7, 2)) + " $")
|
119 |
+
|
120 |
+
price_year_8 = price_month_8 * 12
|
121 |
+
st.write(str(round(price_year_8, 2)) + " $")
|
122 |
+
|
123 |
+
with col15:
|
124 |
+
int8_mem_1 = dim_1 / 4
|
125 |
+
st.write(str(round(int8_mem_1, 2)) + " GB")
|
126 |
+
|
127 |
+
int8_mem_2 = dim_2 / 4
|
128 |
+
st.write(str(round(int8_mem_2, 2)) + " GB")
|
129 |
+
|
130 |
+
int8_mem_3 = dim_3 / 4
|
131 |
+
st.write(str(round(int8_mem_3, 2)) + " GB")
|
132 |
+
|
133 |
+
int8_mem_4 = dim_4 / 4
|
134 |
+
st.write(str(round(int8_mem_4, 2)) + " GB")
|
135 |
+
|
136 |
+
int8_mem_5 = dim_5 / 4
|
137 |
+
st.write(str(round(int8_mem_5, 2)) + " GB")
|
138 |
+
|
139 |
+
int8_mem_6 = dim_6 / 4
|
140 |
+
st.write(str(round(int8_mem_6, 2)) + " GB")
|
141 |
+
|
142 |
+
int8_mem_7 = dim_7 / 4
|
143 |
+
st.write(str(round(int8_mem_7, 2)) + " GB")
|
144 |
+
|
145 |
+
int8_mem_8 = dim_8 / 4
|
146 |
+
st.write(str(round(int8_mem_8, 2)) + " GB")
|
147 |
+
with col16:
|
148 |
+
int8_price_1 = price_month_1 / 4
|
149 |
+
st.write(str(round(int8_price_1, 2)) + " $")
|
150 |
+
|
151 |
+
int8_price_2 = price_month_2 / 4
|
152 |
+
st.write(str(round(int8_price_2, 2)) + " $")
|
153 |
+
|
154 |
+
int8_price_3 = price_month_3 / 4
|
155 |
+
st.write(str(round(int8_price_3, 2)) + " $")
|
156 |
+
|
157 |
+
int8_price_4 = price_month_4 / 4
|
158 |
+
st.write(str(round(int8_price_4, 2)) + " $")
|
159 |
+
|
160 |
+
int8_price_5 = price_month_5 / 4
|
161 |
+
st.write(str(round(int8_price_5, 2)) + " $")
|
162 |
+
|
163 |
+
int8_price_6 = price_month_6 / 4
|
164 |
+
st.write(str(round(int8_price_6, 2)) + " $")
|
165 |
+
|
166 |
+
int8_price_7 = price_month_7 / 4
|
167 |
+
st.write(str(round(int8_price_7, 2)) + " $")
|
168 |
+
|
169 |
+
int8_price_8 = price_month_8 / 4
|
170 |
+
st.write(str(round(int8_price_8, 2)) + " $")
|
171 |
+
|
172 |
+
with col17:
|
173 |
+
binary_mem_1 = dim_1 / 32
|
174 |
+
st.write(str(round(binary_mem_1, 2)) + " GB")
|
175 |
+
|
176 |
+
binary_mem_2 = dim_2 / 32
|
177 |
+
st.write(str(round(binary_mem_2, 2)) + " GB")
|
178 |
+
|
179 |
+
binary_mem_3 = dim_3 / 32
|
180 |
+
st.write(str(round(binary_mem_3, 2)) + " GB")
|
181 |
+
|
182 |
+
binary_mem_4 = dim_4 / 32
|
183 |
+
st.write(str(round(binary_mem_4, 2)) + " GB")
|
184 |
+
|
185 |
+
binary_mem_5 = dim_5 / 32
|
186 |
+
st.write(str(round(binary_mem_5, 2)) + " GB")
|
187 |
+
|
188 |
+
binary_mem_6 = dim_6 / 32
|
189 |
+
st.write(str(round(binary_mem_6, 2)) + " GB")
|
190 |
+
|
191 |
+
binary_mem_7 = dim_7 / 32
|
192 |
+
st.write(str(round(binary_mem_7, 2)) + " GB")
|
193 |
+
|
194 |
+
binary_mem_8 = dim_8 / 32
|
195 |
+
st.write(str(round(binary_mem_8, 2)) + " GB")
|
196 |
+
|
197 |
+
with col18:
|
198 |
+
binary_price_1 = price_month_1 / 32
|
199 |
+
st.write(str(round(binary_price_1, 2)) + " $")
|
200 |
+
|
201 |
+
binary_price_2 = price_month_2 / 32
|
202 |
+
st.write(str(round(binary_price_2, 2)) + " $")
|
203 |
+
|
204 |
+
binary_price_3 = price_month_3 / 32
|
205 |
+
st.write(str(round(binary_price_3, 2)) + " $")
|
206 |
+
|
207 |
+
binary_price_4 = price_month_4 / 32
|
208 |
+
st.write(str(round(binary_price_4, 2)) + " $")
|
209 |
+
|
210 |
+
binary_price_5 = price_month_5 / 32
|
211 |
+
st.write(str(round(binary_price_5, 2)) + " $")
|
212 |
+
|
213 |
+
binary_price_6 = price_month_6 / 32
|
214 |
+
st.write(str(round(binary_price_6, 2)) + " $")
|
215 |
+
|
216 |
+
binary_price_7 = price_month_7 / 32
|
217 |
+
st.write(str(round(binary_price_7, 2)) + " $")
|
218 |
+
|
219 |
+
binary_price_8 = price_month_8 / 32
|
220 |
+
st.write(str(round(binary_price_8, 2)) + " $")
|
221 |
+
|
222 |
+
st.write('***Disclaimer:*** *The financial projections below are based on ["Cohere int8 & binary Embeddings - Scale Your Vector Database to Large Datasets"](https://cohere.com/blog/int8-binary-embeddings) by Nils Reimers of [Cohere](https://cohere.com/). The cost of the index and the metadata might not have been factored in the calculus.*')
|
223 |
+
|
224 |
+
st.divider() ###
|
225 |
+
st.write("***- Open-source vector databases for Scalar and binary quantization:***")
|
226 |
+
col19, col20 = st.columns([1,1])
|
227 |
+
with col19:
|
228 |
+
st.write("- [FAISS](https://github.com/facebookresearch/faiss) from :flag-us:")
|
229 |
+
st.write("- [VESPA AI](https://github.com/vespa-engine/vespa) from :flag-no:")
|
230 |
+
st.write("- [Pgvector](https://github.com/pgvector/pgvector) from :flag-us:")
|
231 |
+
st.write("- [Milvus](https://github.com/milvus-io/milvus) from :flag-cn:")
|
232 |
+
st.write("- [Usearch](https://github.com/unum-cloud/usearch) from :flag-us:")
|
233 |
+
with col20:
|
234 |
+
st.write("- [Qdrant](https://github.com/qdrant) from :flag-de:")
|
235 |
+
st.write("- [pgvecto.rs](https://github.com/tensorchord/pgvecto.rs) from :flag-cn:")
|
236 |
+
st.write("- [TencentVectorDB](https://github.com/Tencent/vectordatabase-sdk-python) from :flag-cn:")
|
237 |
+
st.write("- [BinaryVectorDB](https://github.com/cohere-ai/BinaryVectorDB) from :flag-ca:")
|
238 |
+
st.write("- [Weaviate](https://github.com/weaviate/weaviate) from :flag-de:")
|
239 |
+
st.divider() ###
|
240 |
+
st.write("***- For further readings:***")
|
241 |
+
|
242 |
+
st.write("- [Billion-scale similarity search with GPUs](https://arxiv.org/abs/1702.08734)")
|
243 |
+
st.write("- [Efficient Passage Retrieval with Hashing for Open-domain Question Answering](https://arxiv.org/abs/2106.00882)")
|
244 |
+
st.write("- [Matryoshka Representation Learning](https://arxiv.org/abs/2205.13147)")
|
245 |
+
st.write("- [Incorporating Relevance Feedback for Information-Seeking Retrieval using Few-Shot Document Re-Ranking](https://arxiv.org/abs/2210.10695)")
|
246 |
+
st.write("- [Binary Embedding-based Retrieval at Tencent](https://arxiv.org/abs/2302.08714)")
|
247 |
+
st.divider() ###
|
248 |
+
st.write("***Akim Mousterou*** (April 2024) *[LinkedIn](https://www.linkedin.com/in/akim-mousterou/), [HuggingFace](https://huggingface.co/Akimfromparis), and [GitHub](https://github.com/AkimParis)*")
|
|