Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Configuration

Example configuration in a yaml:

servers:
  - localhost:8125
connection:
  connectTimeout: 5s
  readTimeout: 10s
  pool:
    size: 10
    keepAlive: 1m
backoffPolicy:
  type: EXPONENTIAL
  initialDelay: 5s
  retries: 2

Configuration parameters

servers

(Required, List) A list of strings (or ConnectionInfo objects) with the location to the BERT service

connection.connectTimeout

(Optional, String. Default: 60s) The duration for the connection timeout

connection.readTimeout

(Optional, String. Default: 60s) The duration for the read timeout

connection.pool.size

(Optional, Integer, Default: 5) The size of the connection pool

connection.pool.keepAlive

(Optional, String, Default: 5m) The duration of the connection in the pool

backoffPolicy.type

(Optional, String. Default: EXPONENTIAL) The backoff policy for retries: NONE, CONSTANT, EXPONENTIAL

backoffPolicy.initialDelay

(Optional, String. Default: 50ms) The initial delay before the first retry

backoffPolicy.retries

(Optional, Integer. Default: 2) The number of retries

Initialization

Example initialization of the BERTRestClient:

...

Encode Request

var encodeRequest = EncodeRequest.builder()
    .id("123")
    .chunk("First chunk of text for the encoding")
    .chunk("Second chunk of text for the prediction")
    .withReadTimeout(Duration.ofSeconds(5))
    .withConnectionPool(5, Duration.ofMinutes(30))
    .withObjectMapper(new ObjectMapper())model("sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2") // if this is null, the server will use the default model
    .withBackoffPolicy(BackoffPolicyProperties.builder().retries(10).build());

var result = client.meterRegistryencode(meterRegistryrequest);

The result will return 200 for the status code and the corresponding list of vectors:

{
   .build()) {"id": 123,
  "results": [[float-list],  // Do something with the client
}

...

[float-list]],
  "status": 200
}