Spaces:
Running
Running
Luong Huu Thanh
commited on
Commit
·
d8c261b
1
Parent(s):
25d6f5a
Update README.md
Browse files
README.md
CHANGED
|
@@ -51,6 +51,51 @@ hf_oauth_expiration_minutes: 480
|
|
| 51 |
- **Generate Simple Image:** Generate a simple image (gradient, noise, pattern, chart)
|
| 52 |
- **Combine Images:** Combine multiple images (collage, stack, blend)
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
## **Installation**
|
| 56 |
Clone the repository, change the current working directory to this repository's root folder:
|
|
|
|
| 51 |
- **Generate Simple Image:** Generate a simple image (gradient, noise, pattern, chart)
|
| 52 |
- **Combine Images:** Combine multiple images (collage, stack, blend)
|
| 53 |
|
| 54 |
+
## **Database Setup**
|
| 55 |
+
|
| 56 |
+
### **Supabase Vector Store**
|
| 57 |
+
This project uses Supabase as a vector database to store and retrieve GAIA benchmark questions and answers. The vector store enables semantic search capabilities for finding relevant examples.
|
| 58 |
+
|
| 59 |
+
### **Creating the `match_documents_2` Function**
|
| 60 |
+
To set up the vector similarity search function in your Supabase database, execute the following SQL commands:
|
| 61 |
+
|
| 62 |
+
```sql
|
| 63 |
+
-- 1. Make sure pgvector is enabled
|
| 64 |
+
CREATE EXTENSION IF NOT EXISTS vector;
|
| 65 |
+
|
| 66 |
+
-- 2. Create the RPC for your "documents2" table
|
| 67 |
+
CREATE OR REPLACE FUNCTION public.match_documents_2(
|
| 68 |
+
query_embedding vector(768)
|
| 69 |
+
)
|
| 70 |
+
RETURNS TABLE(
|
| 71 |
+
id bigint,
|
| 72 |
+
content text,
|
| 73 |
+
metadata jsonb,
|
| 74 |
+
embedding vector(768),
|
| 75 |
+
similarity double precision
|
| 76 |
+
)
|
| 77 |
+
LANGUAGE sql STABLE
|
| 78 |
+
AS $$
|
| 79 |
+
SELECT
|
| 80 |
+
id,
|
| 81 |
+
content,
|
| 82 |
+
metadata,
|
| 83 |
+
embedding,
|
| 84 |
+
1 - (embedding <=> query_embedding) AS similarity
|
| 85 |
+
FROM public.documents2
|
| 86 |
+
ORDER BY embedding <=> query_embedding
|
| 87 |
+
LIMIT 10;
|
| 88 |
+
$$;
|
| 89 |
+
|
| 90 |
+
-- 3. Grant execute to anon/authenticated
|
| 91 |
+
GRANT EXECUTE ON FUNCTION public.match_documents(vector) TO anon, authenticated;
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
This setup:
|
| 95 |
+
1. Enables the pgvector extension for vector operations
|
| 96 |
+
2. Creates a stored function that performs vector similarity search using cosine distance (`<=>`)
|
| 97 |
+
3. Grants execution permissions to anonymous and authenticated users
|
| 98 |
+
4. Returns the top 10 most similar documents with their similarity scores
|
| 99 |
|
| 100 |
## **Installation**
|
| 101 |
Clone the repository, change the current working directory to this repository's root folder:
|