AkimfromParis's picture
Uploade 2 file app.py and req
197aba7 verified
raw
history blame
9.93 kB
import os, sys
import streamlit as st
st.set_page_config(page_title="Pricing for scalar and binary embeddings", page_icon=":floppy-disk:", layout="wide", initial_sidebar_state="expanded", menu_items={'Report a bug': "mailto:[email protected]"})
# SIDEBAR
st.sidebar.write('***"Exit float32, hello binary!"***')
cloud_price = st.sidebar.slider("Price of the instance: ", 0.0,20.00,3.8)
st.sidebar.write("*From 0 to 20 (default $3.8 per GB/mo estimated on x2gd instances on AWS)*")
st.sidebar.divider() ###
docs = st.sidebar.slider("Number of vector embeddings: ", 100000000,1000000000,250000000, step=10000000) #Defaul 250M
st.sidebar.write("*From 100M to 1 Billion (default 250M)*")
st.sidebar.write(" ")
st.sidebar.write("***Akim Mousterou*** (April 2024) *[LinkedIn](https://www.linkedin.com/in/akim-mousterou/),[HuggingFace](https://huggingface.co/Akimfromparis), and [GitHub](https://github.com/AkimParis)*")
kb2gb = 1024**3 #Conversion memory
# MAIN
st.title("***Pricing model on billion-scale vector with scalar and binary embeddings***")
st.write("*The real democratization of AI can only be achieved by a powerful open-source ecosystem and low prices for memory/GPU usage.*")
st.write("*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).*")
st.write('*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. The following financial projections 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.*')
col1, col2, col3, col4, col5, col6, col7, col8 = st.columns([1,1,1,1,1,1,1,1])
with col1:
st.write("***Embedding dimension***")
st.divider() ###
st.write("***384***")
st.write("***512***")
st.write("***768***")
st.write("***1024***")
st.write("***1536***")
st.write("***2048***")
st.write("***3072***")
st.write("***4096***")
with col2:
st.write("***Memory usage in Gb***")
st.divider() ###
dim_1 = ((384 * 4) * docs) / kb2gb
st.write(str(round(dim_1, 2)) + " GB")
dim_2 = ((512 * 4) * docs) / kb2gb
r = st.write(str(round(dim_2, 2)) + " GB")
dim_3 = ((768 * 4) * docs) / kb2gb
r = st.write(str(round(dim_3, 2)) + " GB")
dim_4 = ((1024 * 4) * docs) / kb2gb
r = st.write(str(round(dim_4, 2)) + " GB")
dim_5 = ((1536 * 4) * docs) / kb2gb
r = st.write(str(round(dim_5, 2)) + " GB")
dim_6 = ((2048 * 4) * docs) / kb2gb
r = st.write(str(round(dim_6, 2)) + " GB")
dim_7 = ((3072 * 4) * docs) / kb2gb
r = st.write(str(round(dim_7, 2)) + " GB")
dim_8 = ((4096 * 4) * docs) / kb2gb
r = st.write(str(round(dim_8, 2)) + " GB")
with col3:
st.write("***$ Price by month***")
st.divider() ###
price_month_1 = dim_1 * cloud_price
st.write(str(round(price_month_1, 2)) + " $")
price_month_2 = dim_2 * cloud_price
st.write(str(round(price_month_2, 2)) + " $")
price_month_3 = dim_3 * cloud_price
st.write(str(round(price_month_3, 2)) + " $")
price_month_4 = dim_4 * cloud_price
st.write(str(round(price_month_4, 2)) + " $")
price_month_5 = dim_5 * cloud_price
st.write(str(round(price_month_5, 2)) + " $")
price_month_6 = dim_6 * cloud_price
st.write(str(round(price_month_6, 2)) + " $")
price_month_7 = dim_7 * cloud_price
st.write(str(round(price_month_7, 2)) + " $")
price_month_8 = dim_8 * cloud_price
st.write(str(round(price_month_8, 2)) + " $")
with col4:
st.write("***$ Price by year***")
st.divider() ###
price_year_1 = price_month_1 * 12
st.write(str(round(price_year_1, 2)) + " $")
price_year_2 = price_month_2 * 12
st.write(str(round(price_year_2, 2)) + " $")
price_year_3 = price_month_3 * 12
st.write(str(round(price_year_3, 2)) + " $")
price_year_4 = price_month_4 * 12
st.write(str(round(price_year_4, 2)) + " $")
price_year_5 = price_month_5 * 12
st.write(str(round(price_year_5, 2)) + " $")
price_year_6 = price_month_6 * 12
st.write(str(round(price_year_6, 2)) + " $")
price_year_7 = price_month_7 * 12
st.write(str(round(price_year_7, 2)) + " $")
price_year_8 = price_month_8 * 12
st.write(str(round(price_year_8, 2)) + " $")
with col5:
st.write("***Int8 memory*** (div. 4)")
st.divider() ###
int8_mem_1 = dim_1 / 4
st.write(str(round(int8_mem_1, 2)) + " GB")
int8_mem_2 = dim_2 / 4
st.write(str(round(int8_mem_2, 2)) + " GB")
int8_mem_3 = dim_3 / 4
st.write(str(round(int8_mem_3, 2)) + " GB")
int8_mem_4 = dim_4 / 4
st.write(str(round(int8_mem_4, 2)) + " GB")
int8_mem_5 = dim_5 / 4
st.write(str(round(int8_mem_5, 2)) + " GB")
int8_mem_6 = dim_6 / 4
st.write(str(round(int8_mem_6, 2)) + " GB")
int8_mem_7 = dim_7 / 4
st.write(str(round(int8_mem_7, 2)) + " GB")
int8_mem_8 = dim_8 / 4
st.write(str(round(int8_mem_8, 2)) + " GB")
with col6:
st.write("***$ Int8 price*** (div. 4)")
st.divider() ###
int8_price_1 = price_month_1 / 4
st.write(str(round(int8_price_1, 2)) + " $")
int8_price_2 = price_month_2 / 4
st.write(str(round(int8_price_2, 2)) + " $")
int8_price_3 = price_month_3 / 4
st.write(str(round(int8_price_3, 2)) + " $")
int8_price_4 = price_month_4 / 4
st.write(str(round(int8_price_4, 2)) + " $")
int8_price_5 = price_month_5 / 4
st.write(str(round(int8_price_5, 2)) + " $")
int8_price_6 = price_month_6 / 4
st.write(str(round(int8_price_6, 2)) + " $")
int8_price_7 = price_month_7 / 4
st.write(str(round(int8_price_7, 2)) + " $")
int8_price_8 = price_month_8 / 4
st.write(str(round(int8_price_8, 2)) + " $")
with col7:
st.write("***Bin memory*** (div. 32)")
st.divider() ###
binary_mem_1 = dim_1 / 32
st.write(str(round(binary_mem_1, 2)) + " GB")
binary_mem_2 = dim_2 / 32
st.write(str(round(binary_mem_2, 2)) + " GB")
binary_mem_3 = dim_3 / 32
st.write(str(round(binary_mem_3, 2)) + " GB")
binary_mem_4 = dim_4 / 32
st.write(str(round(binary_mem_4, 2)) + " GB")
binary_mem_5 = dim_5 / 32
st.write(str(round(binary_mem_5, 2)) + " GB")
binary_mem_6 = dim_6 / 32
st.write(str(round(binary_mem_6, 2)) + " GB")
binary_mem_7 = dim_7 / 32
st.write(str(round(binary_mem_7, 2)) + " GB")
binary_mem_8 = dim_8 / 32
st.write(str(round(binary_mem_8, 2)) + " GB")
with col8:
st.write("***$ Bin price*** (div. 32)")
st.divider() ###
binary_price_1 = price_month_1 / 32
st.write(str(round(binary_price_1, 2)) + " $")
binary_price_2 = price_month_2 / 32
st.write(str(round(binary_price_2, 2)) + " $")
binary_price_3 = price_month_3 / 32
st.write(str(round(binary_price_3, 2)) + " $")
binary_price_4 = price_month_4 / 32
st.write(str(round(binary_price_4, 2)) + " $")
binary_price_5 = price_month_5 / 32
st.write(str(round(binary_price_5, 2)) + " $")
binary_price_6 = price_month_6 / 32
st.write(str(round(binary_price_6, 2)) + " $")
binary_price_7 = price_month_7 / 32
st.write(str(round(binary_price_7, 2)) + " $")
binary_price_8 = price_month_8 / 32
st.write(str(round(binary_price_8, 2)) + " $")
st.divider() ###
st.write("***- Open-source vector databases for Scalar and binary quantization:***")
col9, col10 = st.columns([1,1])
with col9:
st.write("- [FAISS](https://github.com/facebookresearch/faiss) from :flag-us:")
st.write("- [VESPA AI](https://github.com/vespa-engine/vespa) from :flag-no:")
st.write("- [Pgvector](https://github.com/pgvector/pgvector) from :flag-us:")
st.write("- [Milvus](https://github.com/milvus-io/milvus) from :flag-cn:")
st.write("- [Usearch](https://github.com/unum-cloud/usearch) from :flag-us:")
with col10:
st.write("- [Qdrant](https://github.com/qdrant) from :flag-de:")
st.write("- [pgvecto.rs](https://github.com/tensorchord/pgvecto.rs) from :flag-cn:")
st.write("- [TencentVectorDB](https://github.com/Tencent/vectordatabase-sdk-python) from :flag-cn:")
st.write("- [BinaryVectorDB](https://github.com/cohere-ai/BinaryVectorDB) from :flag-ca:")
st.write("- [Weaviate](https://github.com/weaviate/weaviate) from :flag-de:")
st.divider() ###
st.write("***- For further readings:***")
st.write("- [Billion-scale similarity search with GPUs](https://arxiv.org/abs/1702.08734)")
st.write("- [Efficient Passage Retrieval with Hashing for Open-domain Question Answering](https://arxiv.org/abs/2106.00882)")
st.write("- [Matryoshka Representation Learning](https://arxiv.org/abs/2205.13147)")
st.write("- [Incorporating Relevance Feedback for Information-Seeking Retrieval using Few-Shot Document Re-Ranking](https://arxiv.org/abs/2210.10695)")
st.write("- [Binary Embedding-based Retrieval at Tencent](https://arxiv.org/abs/2302.08714)")