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

Auto embedding #100

Merged
merged 20 commits into from
Dec 16, 2023
Merged

Auto embedding #100

merged 20 commits into from
Dec 16, 2023

Conversation

richard-epsilla
Copy link
Contributor

@richard-epsilla richard-epsilla commented Dec 14, 2023

Automatically embed the attributes

  1. When start DB, need provide embedding service base url:
./build/vectordb -e http://localhost:8889
  1. Define embedding indices:
{
    "name": "MyTable124",
    "returnTableId": true,
    "fields": [
        {
        "name": "ID2",
        "dataType": "FLOAT"
        },
        {
        "name": "Document",
        "dataType": "STRING"
        },
        {
        "name": "Document2",
        "dataType": "STRING"
        },
        {
        "name": "ID1",
        "dataType": "BIGINT"
        },
        {
            "name": "Embedding",
            "dataType": "VECTOR_FLOAT",
            "dimensions": 4,
            "metricType": "COSINE"
        }
    ],
    "indices": [
        {
            "name": "MyIndex",
            "field": "Document",
            "model": "BAAI/bge-base-en-v1.5"
        },
        {
            "name": "MyIndex2",
            "field": "Document2",
            "model": "BAAI/bge-small-en-v1.5"
        }
    ]
}
  1. When insert the attributes, the indices will be automatically embedded
    Supported embedding models:
    BAAI/bge-small-en
    BAAI/bge-small-en-v1.5
    BAAI/bge-small-zh-v1.5
    BAAI/bge-base-en
    BAAI/bge-base-en-v1.5
    sentence-transformers/all-MiniLM-L6-v2
    openai/text-embedding-ada-002

When using openai embedding for a table, need pass X-OpenAI-API-Key in request header to insert, query, and loaddb API

  1. When query, can query by index. Can provide either a query vector, or a query string. If provide query string, it will automatically embed using the model defined in the index
POST http://localhost:8888/api/<DB>/data/query
Option 1: with query
{
    "table": "VideoData",
    "query": "What's the best way to code xxx?",
    "queryIndex": "Embedding",
    "limit": 5
}
If there is just 1 index, the queryIndex can be omitted:
{
    "table": "VideoData",
    "query": "What's the best way to code xxx?",
    "limit": 5
}

Option 2: with query vector
{
    "table": "VideoData",
    "queryVector": [ 0.06929776072502136,
                0.49731335043907166,
                0.6196035146713257,
                0.6032981276512146 ...],
    "queryIndex": "Embedding",
    "limit": 5
}

@richard-epsilla richard-epsilla marked this pull request as ready for review December 15, 2023 21:21
@richard-epsilla richard-epsilla merged commit 989060e into main Dec 16, 2023
1 check passed
@richard-epsilla richard-epsilla deleted the auto-embedding branch February 12, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants