Comments (7)
PS: need to improve error handling when using embedbase-js sdk at some level to determine
from embedbase.
need to try dot product instead of cos sim in pgvector:
...
select
STUFFHERE,
(documents.embedding <#> embedding) * -1 as similarity
from documents
-- The dot product is negative because of a Postgres limitation, so we negate it
and (documents.embedding <#> embedding) * -1 > match_threshold
-- OpenAI embeddings are normalized to length 1, so
-- cosine similarity and dot product will produce the same results.
-- Using dot product which can be computed slightly faster.
--
-- For the different syntaxes, see https://github.com/pgvector/pgvector
order by documents.embedding <#> embedding
limit match_count;
end;
$$;
need to setup performance monitoring beforehand though
from embedbase.
from embedbase.
different thing that could be tried that will highly likely improve perf:
- https://github.com/pgvector/pgvector#query-options
- increase list size (because table starts growing beyond the optimal 100)
CREATE INDEX ON items USING ivfflat (embedding vector_ip_ops) WITH (lists = 220);
- use SCANN/FAISS + Supabase
from embedbase.
To update the index to use 220 lists, you'll need to first drop the existing index and then create a new index with the desired lists value. Here are the SQL commands to do that:
-- Drop the existing index
DROP INDEX documents_embedding_vector_cosine_ops_idx;
-- Create a new index with 220 lists
CREATE INDEX documents_embedding_vector_cosine_ops_idx
ON documents
USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 220);
Replace documents_embedding_vector_cosine_ops_idx
with the actual name of your index if it's different.
Dropping and recreating an index can have some impact on your users, depending on your database's current usage and workload. Here's how it might affect your users:
-
Query performance: While the index is being dropped and recreated, any queries that rely on this index may experience slower performance because the database will need to do a full table scan instead of using the index.
-
Table lock: Depending on the PostgreSQL version and configuration, dropping and creating an index might lock the table or cause other queries to be blocked. This can cause delays for users trying to access the table during the index operation.
To minimize the impact on your users, consider performing the index update during a maintenance window or a period of low database usage. Additionally, you can use the CONCURRENTLY
keyword when creating the new index to avoid locking the table:
-- Create a new index with 220 lists, concurrently
CREATE INDEX CONCURRENTLY documents_embedding_vector_cosine_ops_idx
ON documents
USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 220);
Note that you cannot use the CONCURRENTLY
keyword when dropping an index. However, dropping an index is generally a quick operation and should not cause significant disruption.
from embedbase.
nvm all this. just need to distinct the select query when optimizing duplicates
from embedbase.
fixed 🚢🚢🚢🚢🚢
from embedbase.
Related Issues (20)
- [Dashboard]: chat kept in state
- [Dashboard, Core, Python SDK, Javascript SDK]: publish appropriate changelog on release
- [Python SDK, Javascript SDK]: improve error handling HOT 1
- [Dashboard, Core, Python SDK, Javascript SDK]: integration unit tests concurrency issue HOT 1
- [Python SDK]: async combining two dataset doesn't work after python SDK update HOT 3
- [Core]: ValueError: Out of range float values are not JSON compliant HOT 3
- [Core]: add response model
- [Core]: tiktoken stackoverflow
- [Python SDK]: ImportError: cannot import name 'EmbedbaseAsyncClient' from 'embedbase_client' HOT 1
- [Python SDK]: Where implementation in postgres db HOT 1
- [Core]: YamlModel is a deprecated class in pydantic_yaml HOT 1
- merge docs apis into a single one using wasm hacks HOT 1
- Getting started examples
- async function call not working (uvicorn, fastapi) HOT 10
- ValueError: Out of range float values are not JSON compliant HOT 2
- Add references to github and pdf uploader
- metadata unicode issue with supabase
- Add .ratio to embedbase sdk HOT 3
- [Core/Hosted]: search feedback HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embedbase.