Embeddings

TODO:

/api/embeddings/definitions

Returns a list of EmbeddingDefintions. An EmbeddingDefinition combines a specific embedding model and a reference to a Chunker.

Parameter Description

page

Optional. The number of the requested page.

size

Optional. The number of objects of the requested page.

Example
$ curl 'http://localhost:8080/api/embeddings/definitions?size=1' -i -X GET
HTTP/1.1 200 OK
X-Rate-Limit-Remaining: 99
Content-Type: application/json
Content-Length: 628

{
  "responseHeader" : {
    "httpStatus" : null,
    "msg" : "",
    "query" : "http://localhost:8080/api/embeddings/definitions?size=1",
    "state" : "OK"
  },
  "content" : [ {
    "machineName" : "default",
    "modelName" : "sentence-transformers/paraphrase-MiniLM-L12-v2",
    "dimensions" : 384,
    "chunkerMachineName" : "default"
  }, {
    "machineName" : "tests",
    "modelName" : "sentence-transformers/paraphrase-MiniLM-L12-v2",
    "dimensions" : 384,
    "chunkerMachineName" : "default"
  } ],
  "page" : {
    "size" : 2,
    "number" : 0,
    "totalElements" : 2,
    "totalPages" : 1
  },
  "links" : { }
}

/api/embeddings/status

Returns a list with status information of the computation and indexing of embeddings of Snapshots. Returns only information of Snapshots the current user has access to.

Parameter Description

def

The machineName of a the EmbeddingDef. Defaults to 'default'

panel

Optional. The machineName of a Panel. Return only Snapshots which embeddings have been started/finalized computing. Either 'panel' or 'snapshot' can be specified.

snapshot

Optional. The machineName of a Snapshot. Either 'panel' or 'snapshot' can be specified.

Example
$ curl 'http://localhost:8080/api/embeddings/status' -i -X GET
HTTP/1.1 200 OK
X-Rate-Limit-Remaining: 99
Content-Type: application/json
Content-Length: 434

{
  "responseHeader" : {
    "httpStatus" : null,
    "msg" : "",
    "query" : "http://localhost:8080/api/embeddings/status",
    "state" : "OK"
  },
  "content" : [ {
    "snapshot" : "20121227_intermediaries",
    "embeddingDef" : "default",
    "computationStatus" : "STARTED",
    "indexStatus" : "STARTED"
  } ],
  "page" : {
    "size" : 1,
    "number" : 0,
    "totalElements" : 1,
    "totalPages" : 1
  },
  "links" : { }
}

/api/embeddings/search

Creates a list of "nearby" chunks of documents based on the used embedding sorted ascending on the distance. As distance the cosinus similarity is used.

Parameter Description

index

Optional. The EmbeddingIndex to use. Defaults to 'MilvusDiskANNEmbeddingsIndex'.

snapshot

The snapshot

selection

The selection. (currently not used)

domain

A Domain on which the search should be restricted. Can be specified multiple times.

embeddingsDef

The machineName of the EmbeddingsDef

query

The text for comparing with embeddings

maxDistance

The maximum distance of text chunks. Defaults to 0.5

limit

The limit of matching Chunks to return. If active disables paging. Defaults to 1000

minTokenCount

CURRENTLY IGNORED and fixed to 15. Only consider Chunks with more than minTokensCount. Defaults to 15

expectedElements

MITIGATES a bug in MariaDB with inconsistent results

Example
$ curl 'http://localhost:8080/api/embeddings/search?snapshot=20121227_intermediaries&embeddingsDef=default&query=Nachhaltigkeit&limit=2' -i -X GET
HTTP/1.1 200 OK
X-Rate-Limit-Remaining: 99
Content-Type: application/json
Content-Length: 1437

{
  "responseHeader" : {
    "httpStatus" : null,
    "msg" : "",
    "query" : "http://localhost:8080/api/embeddings/search?snapshot=20121227_intermediaries&embeddingsDef=default&query=Nachhaltigkeit&limit=2",
    "state" : "OK"
  },
  "content" : [ {
    "domain" : "www.dfg.de",
    "reference" : "/dfg_magazin/wissenschaft_oeffentlichkeit/dfg_wissenschaftsjahre/2012_nachhaltigkeit/index.jsp",
    "textChunk" : "Das \"Wissenschaftsjahr 2012 – Zukunftsprojekt Erde\" beschäftigt sich mit Forschung für nachhaltige Entwicklung. Alle Aspekte der Nachhaltigkeit werden angesprochen: Im Fokus stehen Möglichkeiten und Realisierbarkeit wirtschaftlichen, ökologischen und sozial nachhaltigen Handelns.",
    "embedding" : [ ],
    "similarity" : 0.6509945,
    "dist" : 0.34900552
  }, {
    "domain" : "www.dfg.de",
    "reference" : "/service/presse/das_neueste/index.html",
    "textChunk" : "(30.05.12) Am 30. Mai startet die MS Wissenschaft ihre Tour 2012. An Bord präsentieren auch von der DFG unterstützte Projekte ihre Forschung für nachhaltige Entwicklungen. Zum Start des Schiffes erscheint auch „Das blaue ABC. Forschung – Wissen – Nachhaltigkeit“, das DFG-geförderte Forschung zur Nachhaltigkeit vorstellt.",
    "embedding" : [ ],
    "similarity" : 0.52392614,
    "dist" : 0.47607386
  } ],
  "page" : {
    "size" : 2,
    "number" : 0,
    "totalElements" : 2,
    "totalPages" : 1
  },
  "links" : { }
}

/api/embeddings/searchForStream

Content-Type: application/x-ndjson

Creates a list of "nearby" chunks of documents based on the used embedding sorted ascending on the distance. As distance the cosinus similarity is used.

Parameter Description

snapshot

The snapshot

selection

The selection. (currently not used)

domain

A Domain on which the search should be restricted. Can be specified multiple times.

embeddingsDef

The machineName of the EmbeddingsDef

query

The text for comparing with embeddings

maxDistance

The maximum distance of text chunks. Defaults to 0.5

limit

The limit of matching Chunks to return. If active disables paging. Defaults to 1000

minTokenCount

CURRENTY IGNORED and fixed to 15. Only consider Chunks with more than minTokensCount. Defaults to 15

expectedElements

MITIGATES a bug in MariaDB with inconsistent results

Example
$ curl 'http://localhost:8080/api/embeddings/searchForStream?snapshot=20121227_intermediaries&embeddingsDef=default&query=Nachhaltigkeit&limit=2' -i -X GET
HTTP/1.1 200 OK
X-Rate-Limit-Remaining: 99
Content-Type: application/x-ndjson
Content-Length: 1039

{
  "domain" : "www.dfg.de",
  "reference" : "/dfg_magazin/wissenschaft_oeffentlichkeit/dfg_wissenschaftsjahre/2012_nachhaltigkeit/index.jsp",
  "textChunk" : "Das \"Wissenschaftsjahr 2012 – Zukunftsprojekt Erde\" beschäftigt sich mit Forschung für nachhaltige Entwicklung. Alle Aspekte der Nachhaltigkeit werden angesprochen: Im Fokus stehen Möglichkeiten und Realisierbarkeit wirtschaftlichen, ökologischen und sozial nachhaltigen Handelns.",
  "embedding" : [ ],
  "similarity" : 0.6509945,
  "dist" : 0.34900552
}
{
  "domain" : "www.dfg.de",
  "reference" : "/service/presse/das_neueste/index.html",
  "textChunk" : "(30.05.12) Am 30. Mai startet die MS Wissenschaft ihre Tour 2012. An Bord präsentieren auch von der DFG unterstützte Projekte ihre Forschung für nachhaltige Entwicklungen. Zum Start des Schiffes erscheint auch „Das blaue ABC. Forschung – Wissen – Nachhaltigkeit“, das DFG-geförderte Forschung zur Nachhaltigkeit vorstellt.",
  "embedding" : [ ],
  "similarity" : 0.52392614,
  "dist" : 0.47607386
}