bluesearch.server.embedding_server module

Implementation of a server that computes sentence embeddings.

class EmbeddingServer(embedding_models)[source]

Bases: flask.app.Flask

Wrapper class representing the embedding server.

Parameters

embedding_models (dict) – Dictionary whom keys are name of embedding_models and values are instance of the embedding models.

embed_text(model, text)[source]

Embed text.

Parameters
  • model (str) – String representing the model name.

  • text (str) – Text to be embedded.

Returns

1D array representing the text embedding.

Return type

np.ndarray

Raises

InvalidUsage – If the model name is invalid.

static handle_invalid_usage(error)[source]

Handle invalid usage.

help()[source]

Help the user by sending information about the server.

static make_csv_response(embedding)[source]

Generate a csv response.

static make_json_response(embedding)[source]

Generate a json response.

request_embedding(output_type)[source]

Request embedding.

request_welcome()[source]

Generate a welcome page.