Tokenization by MODEL_ID
import requests
url = "https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}"
payload = {
"batch": [{ "text": "Mr. and Mrs. Dursley and O'\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much" }],
"useCaseConfig": { "dataType": "passage" },
"modelConfig": {
"vectorQuantizationMethod": "max-scale",
"dimReductionSize": 256
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}")
.header("Content-Type", "application/json")
.body("{\n \"batch\": [\n {\n \"text\": \"Mr. and Mrs. Dursley and O'\\\\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much\"\n }\n ],\n \"useCaseConfig\": {\n \"dataType\": \"passage\"\n },\n \"modelConfig\": {\n \"vectorQuantizationMethod\": \"max-scale\",\n \"dimReductionSize\": 256\n }\n}")
.asString();const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
batch: [
{
text: 'Mr. and Mrs. Dursley and O\'\'\'Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much'
}
],
useCaseConfig: {dataType: 'passage'},
modelConfig: {vectorQuantizationMethod: 'max-scale', dimReductionSize: 256}
})
};
fetch('https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"batch\": [\n {\n \"text\": \"Mr. and Mrs. Dursley and O'\\\\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much\"\n }\n ],\n \"useCaseConfig\": {\n \"dataType\": \"passage\"\n },\n \"modelConfig\": {\n \"vectorQuantizationMethod\": \"max-scale\",\n \"dimReductionSize\": 256\n }\n}"
response = http.request(request)
puts response.read_bodypackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}"
payload := strings.NewReader("{\n \"batch\": [\n {\n \"text\": \"Mr. and Mrs. Dursley and O'\\\\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much\"\n }\n ],\n \"useCaseConfig\": {\n \"dataType\": \"passage\"\n },\n \"modelConfig\": {\n \"vectorQuantizationMethod\": \"max-scale\",\n \"dimReductionSize\": 256\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'batch' => [
[
'text' => 'Mr. and Mrs. Dursley and O\'\\\'\'Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much'
]
],
'useCaseConfig' => [
'dataType' => 'passage'
],
'modelConfig' => [
'vectorQuantizationMethod' => 'max-scale',
'dimReductionSize' => 256
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}curl --request POST \
--url https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID} \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"batch": [
{
"text": "Mr. and Mrs. Dursley and O'\\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much"
}
],
"useCaseConfig": {
"dataType": "passage"
},
"modelConfig": {
"vectorQuantizationMethod": "max-scale",
"dimReductionSize": 256
}
}
EOF{
"generatedTokens": [
{
"tokens": [
"\"[CLS]\", \"query\", \":\", \"mr\", \".\", \"and\", \"mrs\", \".\", \"du\", \"##rs\", \"##ley\", \"and\", \"o\", \"'\", \"malley\", \",\", \"of\", \"number\", \"four\", \",\", \"pri\", \"##vet\", \"drive\", \",\", \"were\", \"proud\", \"to\", \"say\", \"that\", \"they\", \"were\", \"perfectly\", \"normal\", \",\", \"thank\", \"you\", \"very\", \"much\", \".\", \"[SEP]\""
]
}
],
"tokensUsed": {
"inputTokens": 40,
"promptTokens": 148,
"completionTokens": 0,
"totalTokens": 175
}
}Tokenization by MODEL_ID
The tokenization request for the pre-trained and custom embedding use cases and specified embedding modelId (model name) sends text to return results in formats supported by embedding models.
POST
/
ai
/
tokenization
/
{MODEL_ID}
Tokenization by MODEL_ID
import requests
url = "https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}"
payload = {
"batch": [{ "text": "Mr. and Mrs. Dursley and O'\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much" }],
"useCaseConfig": { "dataType": "passage" },
"modelConfig": {
"vectorQuantizationMethod": "max-scale",
"dimReductionSize": 256
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}")
.header("Content-Type", "application/json")
.body("{\n \"batch\": [\n {\n \"text\": \"Mr. and Mrs. Dursley and O'\\\\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much\"\n }\n ],\n \"useCaseConfig\": {\n \"dataType\": \"passage\"\n },\n \"modelConfig\": {\n \"vectorQuantizationMethod\": \"max-scale\",\n \"dimReductionSize\": 256\n }\n}")
.asString();const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
batch: [
{
text: 'Mr. and Mrs. Dursley and O\'\'\'Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much'
}
],
useCaseConfig: {dataType: 'passage'},
modelConfig: {vectorQuantizationMethod: 'max-scale', dimReductionSize: 256}
})
};
fetch('https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"batch\": [\n {\n \"text\": \"Mr. and Mrs. Dursley and O'\\\\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much\"\n }\n ],\n \"useCaseConfig\": {\n \"dataType\": \"passage\"\n },\n \"modelConfig\": {\n \"vectorQuantizationMethod\": \"max-scale\",\n \"dimReductionSize\": 256\n }\n}"
response = http.request(request)
puts response.read_bodypackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}"
payload := strings.NewReader("{\n \"batch\": [\n {\n \"text\": \"Mr. and Mrs. Dursley and O'\\\\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much\"\n }\n ],\n \"useCaseConfig\": {\n \"dataType\": \"passage\"\n },\n \"modelConfig\": {\n \"vectorQuantizationMethod\": \"max-scale\",\n \"dimReductionSize\": 256\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'batch' => [
[
'text' => 'Mr. and Mrs. Dursley and O\'\\\'\'Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much'
]
],
'useCaseConfig' => [
'dataType' => 'passage'
],
'modelConfig' => [
'vectorQuantizationMethod' => 'max-scale',
'dimReductionSize' => 256
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}curl --request POST \
--url https://application_id.applications.lucidworks.com/ai/tokenization/{MODEL_ID} \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"batch": [
{
"text": "Mr. and Mrs. Dursley and O'\\''Malley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much"
}
],
"useCaseConfig": {
"dataType": "passage"
},
"modelConfig": {
"vectorQuantizationMethod": "max-scale",
"dimReductionSize": 256
}
}
EOF{
"generatedTokens": [
{
"tokens": [
"\"[CLS]\", \"query\", \":\", \"mr\", \".\", \"and\", \"mrs\", \".\", \"du\", \"##rs\", \"##ley\", \"and\", \"o\", \"'\", \"malley\", \",\", \"of\", \"number\", \"four\", \",\", \"pri\", \"##vet\", \"drive\", \",\", \"were\", \"proud\", \"to\", \"say\", \"that\", \"they\", \"were\", \"perfectly\", \"normal\", \",\", \"thank\", \"you\", \"very\", \"much\", \".\", \"[SEP]\""
]
}
],
"tokensUsed": {
"inputTokens": 40,
"promptTokens": 148,
"completionTokens": 0,
"totalTokens": 175
}
}Headers
The authentication and authorization access token.
application/json
Example:
"application/json"
Path Parameters
The name of the pre-trained or custom embedding model.
Example:
"e5-small-v2"
Body
application/json
Was this page helpful?
⌘I