import requests
url = "https://application_id.applications.lucidworks.com/ai/prediction/ner/{MODEL_ID}"
payload = {
"batch": [{ "text": "Mahatma Gandhi, born on October 2, 1869, in Porbandar, India, led a life that profoundly shaped the course of history. Inspired by his principles of non-violence, truth, and civil disobedience, Gandhi became a pivotal figure in India'\''s struggle for independence from British rule. His journey began as a lawyer in South Africa, where he experienced racial discrimination and injustice, sparking his commitment to social justice. Returning to India, he became the face of the nonviolent resistance movement, employing methods like peaceful protests, fasting, and marches. The iconic Salt March of 1930 exemplified his philosophy as thousands followed him in the defiance of salt taxes imposed by the British. Gandhi'\''s ascetic lifestyle, clad in simple attire and practicing self-sufficiency, endeared him to the masses. Despite facing imprisonment multiple times, he remained steadfast in his pursuit of India'\''s freedom. Tragically, Gandhi was assassinated on January 30, 1948, but his legacy endures globally as a symbol of peace, tolerance, and the transformative power of nonviolent resistance." }],
"useCaseConfig": { "entityTypeMap": { "entity": ["example1, example2"] } },
"modelConfig": {
"temperature": 0.8,
"topP": 1,
"topK": -1,
"presencePenalty": 2,
"frequencyPenalty": 1,
"maxTokens": 1,
"apiKey": "API key specific to use case and model",
"azureDeployment": "DEPLOYMENT_NAME",
"azureEndpoint": "https://azure.endpoint.com",
"googleProjectId": "[GOOGLE_PROJECT_ID]",
"googleRegion": "[GOOGLE_PROJECT_REGION_OF_MODEL_ACCESS]"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"predictions": [
{
"tokensUsed": {
"promptTokens": 148,
"completionTokens": 27,
"totalTokens": 175
},
"entities": {
"entity": [
"<string>"
]
},
"response": "{\\n\\\"Location\\\": [\\n\\\"Porbandar\\\",\\n\\\"India\\\"\\n]\\n}"
}
]
}In the Named Entity Recognition (NER) use case, the LLM ingests text and entities to extract and return a JSON response that contains a list of entities extracted from the text. No options can be configured.
This use case can be used to extract nouns and proper nouns such as Brand, Date, Company, Places, and Category in order to guide and refine searches.
import requests
url = "https://application_id.applications.lucidworks.com/ai/prediction/ner/{MODEL_ID}"
payload = {
"batch": [{ "text": "Mahatma Gandhi, born on October 2, 1869, in Porbandar, India, led a life that profoundly shaped the course of history. Inspired by his principles of non-violence, truth, and civil disobedience, Gandhi became a pivotal figure in India'\''s struggle for independence from British rule. His journey began as a lawyer in South Africa, where he experienced racial discrimination and injustice, sparking his commitment to social justice. Returning to India, he became the face of the nonviolent resistance movement, employing methods like peaceful protests, fasting, and marches. The iconic Salt March of 1930 exemplified his philosophy as thousands followed him in the defiance of salt taxes imposed by the British. Gandhi'\''s ascetic lifestyle, clad in simple attire and practicing self-sufficiency, endeared him to the masses. Despite facing imprisonment multiple times, he remained steadfast in his pursuit of India'\''s freedom. Tragically, Gandhi was assassinated on January 30, 1948, but his legacy endures globally as a symbol of peace, tolerance, and the transformative power of nonviolent resistance." }],
"useCaseConfig": { "entityTypeMap": { "entity": ["example1, example2"] } },
"modelConfig": {
"temperature": 0.8,
"topP": 1,
"topK": -1,
"presencePenalty": 2,
"frequencyPenalty": 1,
"maxTokens": 1,
"apiKey": "API key specific to use case and model",
"azureDeployment": "DEPLOYMENT_NAME",
"azureEndpoint": "https://azure.endpoint.com",
"googleProjectId": "[GOOGLE_PROJECT_ID]",
"googleRegion": "[GOOGLE_PROJECT_REGION_OF_MODEL_ACCESS]"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"predictions": [
{
"tokensUsed": {
"promptTokens": 148,
"completionTokens": 27,
"totalTokens": 175
},
"entities": {
"entity": [
"<string>"
]
},
"response": "{\\n\\\"Location\\\": [\\n\\\"Porbandar\\\",\\n\\\"India\\\"\\n]\\n}"
}
]
}The authentication and authorization access token.
application/json
"application/json"
Unique identifier for the model.
"6a092bd4-5098-466c-94aa-40bf6829430\""
The batch of key:value pairs used as inputs in the prediction. Up to 32 inputs per request are allowed.
32Show child attributes
The content the model analyzes.
"Mahatma Gandhi, born on October 2, 1869, in Porbandar, India, led a life that profoundly shaped the course of history. Inspired by his principles of non-violence, truth, and civil disobedience, Gandhi became a pivotal figure in India'\\''s struggle for independence from British rule. His journey began as a lawyer in South Africa, where he experienced racial discrimination and injustice, sparking his commitment to social justice. Returning to India, he became the face of the nonviolent resistance movement, employing methods like peaceful protests, fasting, and marches. The iconic Salt March of 1930 exemplified his philosophy as thousands followed him in the defiance of salt taxes imposed by the British. Gandhi'\\''s ascetic lifestyle, clad in simple attire and practicing self-sufficiency, endeared him to the masses. Despite facing imprisonment multiple times, he remained steadfast in his pursuit of India'\\''s freedom. Tragically, Gandhi was assassinated on January 30, 1948, but his legacy endures globally as a symbol of peace, tolerance, and the transformative power of nonviolent resistance."
Show child attributes
Show child attributes
"entity": [exampleA, exampleB], "entity1": [exampleC, exampleD]
For example:
"Location": ["India", "South Africa"]
This parameter provides a map with entity type as a key with a list of example values to search. The entity type is required, but example values are optional and can be empty. Multiple entities with examples can be entered in the request.
In the LWAI Prediction index stage and the LWAI Prediction query stage, the useCaseConfig entityTypeMap parameter only supports a string. Therefore, the string entered in Fusion is converted to a JSON string, which is required in the Lucidworks AI entityTypeMap variable.
Provides fields and values that specify ranges for tokens. Fields used for specific use cases and models are specified. The default values are used if other values are not specified.
Show child attributes
A sampling temperature between 0 and 2. A higher sampling temperature such as 0.8, results in more random (creative) output. A lower value such as 0.2 results in more focused (conservative) output. A lower value does not guarantee the model returns the same response for the same input. We recommend staying at or below a temperature of 1.0. Values above 1.0 might return nonsense unless the topP value is lowered to be more deterministic.
0 <= x <= 20.8
A floating-point number between 0 and 1 that controls the cumulative probability of the top tokens to consider, known as the randomness of the LLM's response. This parameter is also referred to as top probability. Set topP to 1 to consider all tokens. A higher value specifies a higher probability threshold and selects tokens whose cumulative probability is greater than the threshold. The higher the value, the more diverse the output.
0 <= x <= 11
An integer that controls the number of top tokens to consider. Set top_k to -1 to consider all tokens.
-1
A floating-point number between -2.0 and 2.0 that penalizes new tokens based on whether they have already appeared in the text. This increases the model's use of diverse tokens. A value greater than zero (0) encourages the model to use new tokens. A value less than zero (0) encourages the model to repeat existing tokens. This is applicable for all OpenAI, Mistral, and Llama models.
-2 <= x <= 22
A floating-point number between -2.0 and 2.0 that penalizes new tokens based on their frequency in the generated text. A value greater than zero (0) encourages the model to use new tokens. A value less than zero (0) encourages the model to repeat existing tokens. This is applicable for all OpenAI, Mistral, and Llama models.
-2 <= x <= 21
The maximum number of tokens to generate per output sequence. The value is different for each model. Review individual model specifications when the value exceeds 2048.
1
This optional parameter is only required when using the model for prediction. You can find this value in your model's settings:
OpenAI: Copy and paste the API key found in your organization's settings. For more information, see OpenAI Authentication API keys.
Azure OpenAI: Copy and paste the API key found in your Azure portal. See Authenticate with API key.
Anthropic: Copy and paste the API key found in your Anthrophic console or by using the Anthropic API.
Google Vertex AI: Copy and paste the base64-encoded service account key JSON found in your Google Cloud console. This service account key must have the Vertex AI user role enabled. For more information, see generate service account key.
"API key specific to use case and model"
This optional parameter is the name of the deployed Azure OpenAI model and is only required when a deployed Azure OpenAI model is used for prediction.
"DEPLOYMENT_NAME"
This optional parameter is the URL endpoint of the deployed Azure OpenAI model and is only required when a deployed Azure OpenAI model is used for prediction.
"https://azure.endpoint.com"
This parameter is optional, and is only required when a Google Vertex AI model is used for prediction.
"[GOOGLE_PROJECT_ID]"
This parameter is optional, and is only required when a Google Vertex AI model is used for prediction. The possible region values are:
"[GOOGLE_PROJECT_REGION_OF_MODEL_ACCESS]"
OK
Show child attributes
Show child attributes
The number of tokens generated to prompt the model to continue generating results.
148
The number of tokens used until the model completes.
27
The sum of the prompt and completion tokens used in the model.
175
The results returned from the request.
"{\\n\\\"Location\\\": [\\n\\\"Porbandar\\\",\\n\\\"India\\\"\\n]\\n}"
Was this page helpful?