synapse.ml.cognitive.openai package

Submodules

synapse.ml.cognitive.openai.OpenAICompletion module

class synapse.ml.cognitive.openai.OpenAICompletion.OpenAICompletion(java_obj=None, AADToken=None, AADTokenCol=None, apiVersion=None, apiVersionCol=None, batchIndexPrompt=None, batchIndexPromptCol=None, batchPrompt=None, batchPromptCol=None, bestOf=None, bestOfCol=None, cacheLevel=None, cacheLevelCol=None, concurrency=1, concurrentTimeout=None, deploymentName=None, deploymentNameCol=None, echo=None, echoCol=None, errorCol='OpenAPICompletion_9f006475244b_error', frequencyPenalty=None, frequencyPenaltyCol=None, handler=None, indexPrompt=None, indexPromptCol=None, logProbs=None, logProbsCol=None, maxTokens=None, maxTokensCol=None, model=None, modelCol=None, n=None, nCol=None, outputCol='OpenAPICompletion_9f006475244b_output', presencePenalty=None, presencePenaltyCol=None, prompt=None, promptCol=None, stop=None, stopCol=None, subscriptionKey=None, subscriptionKeyCol=None, temperature=None, temperatureCol=None, timeout=60.0, topP=None, topPCol=None, url=None, user=None, userCol=None)[source]

Bases: synapse.ml.core.schema.Utils.ComplexParamsMixin, pyspark.ml.util.JavaMLReadable, pyspark.ml.util.JavaMLWritable, pyspark.ml.wrapper.JavaTransformer

Parameters
  • AADToken (object) – AAD Token used for authentication

  • apiVersion (object) – version of the api

  • batchIndexPrompt (object) – Sequence of index sequences to complete

  • batchPrompt (object) – Sequence of prompts to complete

  • bestOf (object) – How many generations to create server side, and display only the best. Will not stream intermediate progress if best_of > 1. Has maximum value of 128.

  • cacheLevel (object) – can be used to disable any server-side caching, 0=no cache, 1=prompt prefix enabled, 2=full cache

  • concurrency (int) – max number of concurrent calls

  • concurrentTimeout (float) – max number seconds to wait on futures if concurrency >= 1

  • deploymentName (object) – The name of the deployment

  • echo (object) – Echo back the prompt in addition to the completion

  • errorCol (str) – column to hold http errors

  • frequencyPenalty (object) – How much to penalize new tokens based on whether they appear in the text so far. Increases the likelihood of the model to talk about new topics.

  • handler (object) – Which strategy to use when handling requests

  • indexPrompt (object) – Sequence of indexes to complete

  • logProbs (object) – Include the log probabilities on the logprobs most likely tokens, as well the chosen tokens. So for example, if logprobs is 10, the API will return a list of the 10 most likely tokens. If logprobs is 0, only the chosen tokens will have logprobs returned. Minimum of 0 and maximum of 100 allowed.

  • maxTokens (object) – The maximum number of tokens to generate. Has minimum of 0.

  • model (object) – The name of the model to use

  • n (object) – How many snippets to generate for each prompt. Minimum of 1 and maximum of 128 allowed.

  • outputCol (str) – The name of the output column

  • presencePenalty (object) – How much to penalize new tokens based on their existing frequency in the text so far. Decreases the likelihood of the model to repeat the same line verbatim. Has minimum of -2 and maximum of 2.

  • prompt (object) – The text to complete

  • stop (object) – A sequence which indicates the end of the current document.

  • subscriptionKey (object) – the API key to use

  • temperature (object) – What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or top_p but not both. Minimum of 0 and maximum of 2 allowed.

  • timeout (float) – number of seconds to wait before closing the connection

  • topP (object) – An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10 percent probability mass are considered. We generally recommend using this or temperature but not both. Minimum of 0 and maximum of 1 allowed.

  • url (str) – Url of the service

  • user (object) – The ID of the end-user, for use in tracking and rate-limiting.

AADToken = Param(parent='undefined', name='AADToken', doc='ServiceParam: AAD Token used for authentication')
apiVersion = Param(parent='undefined', name='apiVersion', doc='ServiceParam: version of the api')
batchIndexPrompt = Param(parent='undefined', name='batchIndexPrompt', doc='ServiceParam: Sequence of index sequences to complete')
batchPrompt = Param(parent='undefined', name='batchPrompt', doc='ServiceParam: Sequence of prompts to complete')
bestOf = Param(parent='undefined', name='bestOf', doc='ServiceParam: How many generations to create server side, and display only the best. Will not stream intermediate progress if best_of > 1. Has maximum value of 128.')
cacheLevel = Param(parent='undefined', name='cacheLevel', doc='ServiceParam: can be used to disable any server-side caching, 0=no cache, 1=prompt prefix enabled, 2=full cache')
concurrency = Param(parent='undefined', name='concurrency', doc='max number of concurrent calls')
concurrentTimeout = Param(parent='undefined', name='concurrentTimeout', doc='max number seconds to wait on futures if concurrency >= 1')
deploymentName = Param(parent='undefined', name='deploymentName', doc='ServiceParam: The name of the deployment')
echo = Param(parent='undefined', name='echo', doc='ServiceParam: Echo back the prompt in addition to the completion')
errorCol = Param(parent='undefined', name='errorCol', doc='column to hold http errors')
frequencyPenalty = Param(parent='undefined', name='frequencyPenalty', doc='ServiceParam: How much to penalize new tokens based on whether they appear in the text so far. Increases the likelihood of the model to talk about new topics.')
getAADToken()[source]
Returns

AAD Token used for authentication

Return type

AADToken

getApiVersion()[source]
Returns

version of the api

Return type

apiVersion

getBatchIndexPrompt()[source]
Returns

Sequence of index sequences to complete

Return type

batchIndexPrompt

getBatchPrompt()[source]
Returns

Sequence of prompts to complete

Return type

batchPrompt

getBestOf()[source]
Returns

How many generations to create server side, and display only the best. Will not stream intermediate progress if best_of > 1. Has maximum value of 128.

Return type

bestOf

getCacheLevel()[source]
Returns

can be used to disable any server-side caching, 0=no cache, 1=prompt prefix enabled, 2=full cache

Return type

cacheLevel

getConcurrency()[source]
Returns

max number of concurrent calls

Return type

concurrency

getConcurrentTimeout()[source]
Returns

max number seconds to wait on futures if concurrency >= 1

Return type

concurrentTimeout

getDeploymentName()[source]
Returns

The name of the deployment

Return type

deploymentName

getEcho()[source]
Returns

Echo back the prompt in addition to the completion

Return type

echo

getErrorCol()[source]
Returns

column to hold http errors

Return type

errorCol

getFrequencyPenalty()[source]
Returns

How much to penalize new tokens based on whether they appear in the text so far. Increases the likelihood of the model to talk about new topics.

Return type

frequencyPenalty

getHandler()[source]
Returns

Which strategy to use when handling requests

Return type

handler

getIndexPrompt()[source]
Returns

Sequence of indexes to complete

Return type

indexPrompt

static getJavaPackage()[source]

Returns package name String.

getLogProbs()[source]
Returns

Include the log probabilities on the logprobs most likely tokens, as well the chosen tokens. So for example, if logprobs is 10, the API will return a list of the 10 most likely tokens. If logprobs is 0, only the chosen tokens will have logprobs returned. Minimum of 0 and maximum of 100 allowed.

Return type

logProbs

getMaxTokens()[source]
Returns

The maximum number of tokens to generate. Has minimum of 0.

Return type

maxTokens

getModel()[source]
Returns

The name of the model to use

Return type

model

getN()[source]
Returns

How many snippets to generate for each prompt. Minimum of 1 and maximum of 128 allowed.

Return type

n

getOutputCol()[source]
Returns

The name of the output column

Return type

outputCol

getPresencePenalty()[source]
Returns

How much to penalize new tokens based on their existing frequency in the text so far. Decreases the likelihood of the model to repeat the same line verbatim. Has minimum of -2 and maximum of 2.

Return type

presencePenalty

getPrompt()[source]
Returns

The text to complete

Return type

prompt

getStop()[source]
Returns

A sequence which indicates the end of the current document.

Return type

stop

getSubscriptionKey()[source]
Returns

the API key to use

Return type

subscriptionKey

getTemperature()[source]
Returns

What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or top_p but not both. Minimum of 0 and maximum of 2 allowed.

Return type

temperature

getTimeout()[source]
Returns

number of seconds to wait before closing the connection

Return type

timeout

getTopP()[source]
Returns

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10 percent probability mass are considered. We generally recommend using this or temperature but not both. Minimum of 0 and maximum of 1 allowed.

Return type

topP

getUrl()[source]
Returns

Url of the service

Return type

url

getUser()[source]
Returns

The ID of the end-user, for use in tracking and rate-limiting.

Return type

user

handler = Param(parent='undefined', name='handler', doc='Which strategy to use when handling requests')
indexPrompt = Param(parent='undefined', name='indexPrompt', doc='ServiceParam: Sequence of indexes to complete')
logProbs = Param(parent='undefined', name='logProbs', doc='ServiceParam: Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. So for example, if `logprobs` is 10, the API will return a list of the 10 most likely tokens. If `logprobs` is 0, only the chosen tokens will have logprobs returned. Minimum of 0 and maximum of 100 allowed.')
maxTokens = Param(parent='undefined', name='maxTokens', doc='ServiceParam: The maximum number of tokens to generate. Has minimum of 0.')
model = Param(parent='undefined', name='model', doc='ServiceParam: The name of the model to use')
n = Param(parent='undefined', name='n', doc='ServiceParam: How many snippets to generate for each prompt. Minimum of 1 and maximum of 128 allowed.')
outputCol = Param(parent='undefined', name='outputCol', doc='The name of the output column')
presencePenalty = Param(parent='undefined', name='presencePenalty', doc='ServiceParam: How much to penalize new tokens based on their existing frequency in the text so far. Decreases the likelihood of the model to repeat the same line verbatim. Has minimum of -2 and maximum of 2.')
prompt = Param(parent='undefined', name='prompt', doc='ServiceParam: The text to complete')
classmethod read()[source]

Returns an MLReader instance for this class.

setAADToken(value)[source]
Parameters

AADToken – AAD Token used for authentication

setAADTokenCol(value)[source]
Parameters

AADToken – AAD Token used for authentication

setApiVersion(value)[source]
Parameters

apiVersion – version of the api

setApiVersionCol(value)[source]
Parameters

apiVersion – version of the api

setBatchIndexPrompt(value)[source]
Parameters

batchIndexPrompt – Sequence of index sequences to complete

setBatchIndexPromptCol(value)[source]
Parameters

batchIndexPrompt – Sequence of index sequences to complete

setBatchPrompt(value)[source]
Parameters

batchPrompt – Sequence of prompts to complete

setBatchPromptCol(value)[source]
Parameters

batchPrompt – Sequence of prompts to complete

setBestOf(value)[source]
Parameters

bestOf – How many generations to create server side, and display only the best. Will not stream intermediate progress if best_of > 1. Has maximum value of 128.

setBestOfCol(value)[source]
Parameters

bestOf – How many generations to create server side, and display only the best. Will not stream intermediate progress if best_of > 1. Has maximum value of 128.

setCacheLevel(value)[source]
Parameters

cacheLevel – can be used to disable any server-side caching, 0=no cache, 1=prompt prefix enabled, 2=full cache

setCacheLevelCol(value)[source]
Parameters

cacheLevel – can be used to disable any server-side caching, 0=no cache, 1=prompt prefix enabled, 2=full cache

setConcurrency(value)[source]
Parameters

concurrency – max number of concurrent calls

setConcurrentTimeout(value)[source]
Parameters

concurrentTimeout – max number seconds to wait on futures if concurrency >= 1

setCustomServiceName(value)[source]
setDeploymentName(value)[source]
Parameters

deploymentName – The name of the deployment

setDeploymentNameCol(value)[source]
Parameters

deploymentName – The name of the deployment

setEcho(value)[source]
Parameters

echo – Echo back the prompt in addition to the completion

setEchoCol(value)[source]
Parameters

echo – Echo back the prompt in addition to the completion

setEndpoint(value)[source]
setErrorCol(value)[source]
Parameters

errorCol – column to hold http errors

setFrequencyPenalty(value)[source]
Parameters

frequencyPenalty – How much to penalize new tokens based on whether they appear in the text so far. Increases the likelihood of the model to talk about new topics.

setFrequencyPenaltyCol(value)[source]
Parameters

frequencyPenalty – How much to penalize new tokens based on whether they appear in the text so far. Increases the likelihood of the model to talk about new topics.

setHandler(value)[source]
Parameters

handler – Which strategy to use when handling requests

setIndexPrompt(value)[source]
Parameters

indexPrompt – Sequence of indexes to complete

setIndexPromptCol(value)[source]
Parameters

indexPrompt – Sequence of indexes to complete

setLogProbs(value)[source]
Parameters

logProbs – Include the log probabilities on the logprobs most likely tokens, as well the chosen tokens. So for example, if logprobs is 10, the API will return a list of the 10 most likely tokens. If logprobs is 0, only the chosen tokens will have logprobs returned. Minimum of 0 and maximum of 100 allowed.

setLogProbsCol(value)[source]
Parameters

logProbs – Include the log probabilities on the logprobs most likely tokens, as well the chosen tokens. So for example, if logprobs is 10, the API will return a list of the 10 most likely tokens. If logprobs is 0, only the chosen tokens will have logprobs returned. Minimum of 0 and maximum of 100 allowed.

setMaxTokens(value)[source]
Parameters

maxTokens – The maximum number of tokens to generate. Has minimum of 0.

setMaxTokensCol(value)[source]
Parameters

maxTokens – The maximum number of tokens to generate. Has minimum of 0.

setModel(value)[source]
Parameters

model – The name of the model to use

setModelCol(value)[source]
Parameters

model – The name of the model to use

setN(value)[source]
Parameters

n – How many snippets to generate for each prompt. Minimum of 1 and maximum of 128 allowed.

setNCol(value)[source]
Parameters

n – How many snippets to generate for each prompt. Minimum of 1 and maximum of 128 allowed.

setOutputCol(value)[source]
Parameters

outputCol – The name of the output column

setParams(AADToken=None, AADTokenCol=None, apiVersion=None, apiVersionCol=None, batchIndexPrompt=None, batchIndexPromptCol=None, batchPrompt=None, batchPromptCol=None, bestOf=None, bestOfCol=None, cacheLevel=None, cacheLevelCol=None, concurrency=1, concurrentTimeout=None, deploymentName=None, deploymentNameCol=None, echo=None, echoCol=None, errorCol='OpenAPICompletion_9f006475244b_error', frequencyPenalty=None, frequencyPenaltyCol=None, handler=None, indexPrompt=None, indexPromptCol=None, logProbs=None, logProbsCol=None, maxTokens=None, maxTokensCol=None, model=None, modelCol=None, n=None, nCol=None, outputCol='OpenAPICompletion_9f006475244b_output', presencePenalty=None, presencePenaltyCol=None, prompt=None, promptCol=None, stop=None, stopCol=None, subscriptionKey=None, subscriptionKeyCol=None, temperature=None, temperatureCol=None, timeout=60.0, topP=None, topPCol=None, url=None, user=None, userCol=None)[source]

Set the (keyword only) parameters

setPresencePenalty(value)[source]
Parameters

presencePenalty – How much to penalize new tokens based on their existing frequency in the text so far. Decreases the likelihood of the model to repeat the same line verbatim. Has minimum of -2 and maximum of 2.

setPresencePenaltyCol(value)[source]
Parameters

presencePenalty – How much to penalize new tokens based on their existing frequency in the text so far. Decreases the likelihood of the model to repeat the same line verbatim. Has minimum of -2 and maximum of 2.

setPrompt(value)[source]
Parameters

prompt – The text to complete

setPromptCol(value)[source]
Parameters

prompt – The text to complete

setStop(value)[source]
Parameters

stop – A sequence which indicates the end of the current document.

setStopCol(value)[source]
Parameters

stop – A sequence which indicates the end of the current document.

setSubscriptionKey(value)[source]
Parameters

subscriptionKey – the API key to use

setSubscriptionKeyCol(value)[source]
Parameters

subscriptionKey – the API key to use

setTemperature(value)[source]
Parameters

temperature – What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or top_p but not both. Minimum of 0 and maximum of 2 allowed.

setTemperatureCol(value)[source]
Parameters

temperature – What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or top_p but not both. Minimum of 0 and maximum of 2 allowed.

setTimeout(value)[source]
Parameters

timeout – number of seconds to wait before closing the connection

setTopP(value)[source]
Parameters

topP – An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10 percent probability mass are considered. We generally recommend using this or temperature but not both. Minimum of 0 and maximum of 1 allowed.

setTopPCol(value)[source]
Parameters

topP – An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10 percent probability mass are considered. We generally recommend using this or temperature but not both. Minimum of 0 and maximum of 1 allowed.

setUrl(value)[source]
Parameters

url – Url of the service

setUser(value)[source]
Parameters

user – The ID of the end-user, for use in tracking and rate-limiting.

setUserCol(value)[source]
Parameters

user – The ID of the end-user, for use in tracking and rate-limiting.

stop = Param(parent='undefined', name='stop', doc='ServiceParam: A sequence which indicates the end of the current document.')
subscriptionKey = Param(parent='undefined', name='subscriptionKey', doc='ServiceParam: the API key to use')
temperature = Param(parent='undefined', name='temperature', doc='ServiceParam: What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or `top_p` but not both. Minimum of 0 and maximum of 2 allowed.')
timeout = Param(parent='undefined', name='timeout', doc='number of seconds to wait before closing the connection')
topP = Param(parent='undefined', name='topP', doc='ServiceParam: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10 percent probability mass are considered. We generally recommend using this or `temperature` but not both. Minimum of 0 and maximum of 1 allowed.')
url = Param(parent='undefined', name='url', doc='Url of the service')
user = Param(parent='undefined', name='user', doc='ServiceParam: The ID of the end-user, for use in tracking and rate-limiting.')

synapse.ml.cognitive.openai.OpenAIEmbedding module

class synapse.ml.cognitive.openai.OpenAIEmbedding.OpenAIEmbedding(java_obj=None, AADToken=None, AADTokenCol=None, apiVersion=None, apiVersionCol=None, concurrency=1, concurrentTimeout=None, deploymentName=None, deploymentNameCol=None, errorCol='OpenAIEmbedding_703c909d5540_error', handler=None, outputCol='OpenAIEmbedding_703c909d5540_output', subscriptionKey=None, subscriptionKeyCol=None, text=None, textCol=None, timeout=60.0, url=None)[source]

Bases: synapse.ml.core.schema.Utils.ComplexParamsMixin, pyspark.ml.util.JavaMLReadable, pyspark.ml.util.JavaMLWritable, pyspark.ml.wrapper.JavaTransformer

Parameters
  • AADToken (object) – AAD Token used for authentication

  • apiVersion (object) – version of the api

  • concurrency (int) – max number of concurrent calls

  • concurrentTimeout (float) – max number seconds to wait on futures if concurrency >= 1

  • deploymentName (object) – The name of the deployment

  • errorCol (str) – column to hold http errors

  • handler (object) – Which strategy to use when handling requests

  • outputCol (str) – The name of the output column

  • subscriptionKey (object) – the API key to use

  • text (object) – Input text to get embeddings for.

  • timeout (float) – number of seconds to wait before closing the connection

  • url (str) – Url of the service

AADToken = Param(parent='undefined', name='AADToken', doc='ServiceParam: AAD Token used for authentication')
apiVersion = Param(parent='undefined', name='apiVersion', doc='ServiceParam: version of the api')
concurrency = Param(parent='undefined', name='concurrency', doc='max number of concurrent calls')
concurrentTimeout = Param(parent='undefined', name='concurrentTimeout', doc='max number seconds to wait on futures if concurrency >= 1')
deploymentName = Param(parent='undefined', name='deploymentName', doc='ServiceParam: The name of the deployment')
errorCol = Param(parent='undefined', name='errorCol', doc='column to hold http errors')
getAADToken()[source]
Returns

AAD Token used for authentication

Return type

AADToken

getApiVersion()[source]
Returns

version of the api

Return type

apiVersion

getConcurrency()[source]
Returns

max number of concurrent calls

Return type

concurrency

getConcurrentTimeout()[source]
Returns

max number seconds to wait on futures if concurrency >= 1

Return type

concurrentTimeout

getDeploymentName()[source]
Returns

The name of the deployment

Return type

deploymentName

getErrorCol()[source]
Returns

column to hold http errors

Return type

errorCol

getHandler()[source]
Returns

Which strategy to use when handling requests

Return type

handler

static getJavaPackage()[source]

Returns package name String.

getOutputCol()[source]
Returns

The name of the output column

Return type

outputCol

getSubscriptionKey()[source]
Returns

the API key to use

Return type

subscriptionKey

getText()[source]
Returns

Input text to get embeddings for.

Return type

text

getTimeout()[source]
Returns

number of seconds to wait before closing the connection

Return type

timeout

getUrl()[source]
Returns

Url of the service

Return type

url

handler = Param(parent='undefined', name='handler', doc='Which strategy to use when handling requests')
outputCol = Param(parent='undefined', name='outputCol', doc='The name of the output column')
classmethod read()[source]

Returns an MLReader instance for this class.

setAADToken(value)[source]
Parameters

AADToken – AAD Token used for authentication

setAADTokenCol(value)[source]
Parameters

AADToken – AAD Token used for authentication

setApiVersion(value)[source]
Parameters

apiVersion – version of the api

setApiVersionCol(value)[source]
Parameters

apiVersion – version of the api

setConcurrency(value)[source]
Parameters

concurrency – max number of concurrent calls

setConcurrentTimeout(value)[source]
Parameters

concurrentTimeout – max number seconds to wait on futures if concurrency >= 1

setCustomServiceName(value)[source]
setDeploymentName(value)[source]
Parameters

deploymentName – The name of the deployment

setDeploymentNameCol(value)[source]
Parameters

deploymentName – The name of the deployment

setEndpoint(value)[source]
setErrorCol(value)[source]
Parameters

errorCol – column to hold http errors

setHandler(value)[source]
Parameters

handler – Which strategy to use when handling requests

setOutputCol(value)[source]
Parameters

outputCol – The name of the output column

setParams(AADToken=None, AADTokenCol=None, apiVersion=None, apiVersionCol=None, concurrency=1, concurrentTimeout=None, deploymentName=None, deploymentNameCol=None, errorCol='OpenAIEmbedding_703c909d5540_error', handler=None, outputCol='OpenAIEmbedding_703c909d5540_output', subscriptionKey=None, subscriptionKeyCol=None, text=None, textCol=None, timeout=60.0, url=None)[source]

Set the (keyword only) parameters

setSubscriptionKey(value)[source]
Parameters

subscriptionKey – the API key to use

setSubscriptionKeyCol(value)[source]
Parameters

subscriptionKey – the API key to use

setText(value)[source]
Parameters

text – Input text to get embeddings for.

setTextCol(value)[source]
Parameters

text – Input text to get embeddings for.

setTimeout(value)[source]
Parameters

timeout – number of seconds to wait before closing the connection

setUrl(value)[source]
Parameters

url – Url of the service

subscriptionKey = Param(parent='undefined', name='subscriptionKey', doc='ServiceParam: the API key to use')
text = Param(parent='undefined', name='text', doc='ServiceParam: Input text to get embeddings for.')
timeout = Param(parent='undefined', name='timeout', doc='number of seconds to wait before closing the connection')
url = Param(parent='undefined', name='url', doc='Url of the service')

synapse.ml.cognitive.openai.OpenAIPrompt module

class synapse.ml.cognitive.openai.OpenAIPrompt.OpenAIPrompt(java_obj=None, AADToken=None, AADTokenCol=None, apiVersion=None, apiVersionCol=None, concurrency=1, concurrentTimeout=None, deploymentName=None, deploymentNameCol=None, errorCol='Error', maxTokens=None, maxTokensCol=None, model=None, modelCol=None, outputCol='out', postProcessing='', postProcessingOptions={}, promptTemplate=None, stop=None, stopCol=None, subscriptionKey=None, subscriptionKeyCol=None, temperature=None, temperatureCol=None, timeout=60.0, url=None)[source]

Bases: synapse.ml.core.schema.Utils.ComplexParamsMixin, pyspark.ml.util.JavaMLReadable, pyspark.ml.util.JavaMLWritable, pyspark.ml.wrapper.JavaTransformer

Parameters
  • AADToken (object) – AAD Token used for authentication

  • apiVersion (object) – version of the api

  • concurrency (int) – max number of concurrent calls

  • concurrentTimeout (float) – max number seconds to wait on futures if concurrency >= 1

  • deploymentName (object) – The name of the deployment

  • errorCol (str) – column to hold http errors

  • maxTokens (object) – The maximum number of tokens to generate. Has minimum of 0.

  • model (object) – The name of the model to use

  • outputCol (str) – The name of the output column

  • postProcessing (str) – Post processing options: csv, json, regex

  • postProcessingOptions (dict) – Options (default): delimiter=’,’, jsonSchema, regex, regexGroup=0

  • promptTemplate (str) – The prompt. supports string interpolation {col1}: {col2}.

  • stop (object) – A sequence which indicates the end of the current document.

  • subscriptionKey (object) – the API key to use

  • temperature (object) – What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or top_p but not both. Minimum of 0 and maximum of 2 allowed.

  • timeout (float) – number of seconds to wait before closing the connection

  • url (str) – Url of the service

AADToken = Param(parent='undefined', name='AADToken', doc='ServiceParam: AAD Token used for authentication')
apiVersion = Param(parent='undefined', name='apiVersion', doc='ServiceParam: version of the api')
concurrency = Param(parent='undefined', name='concurrency', doc='max number of concurrent calls')
concurrentTimeout = Param(parent='undefined', name='concurrentTimeout', doc='max number seconds to wait on futures if concurrency >= 1')
deploymentName = Param(parent='undefined', name='deploymentName', doc='ServiceParam: The name of the deployment')
errorCol = Param(parent='undefined', name='errorCol', doc='column to hold http errors')
getAADToken()[source]
Returns

AAD Token used for authentication

Return type

AADToken

getApiVersion()[source]
Returns

version of the api

Return type

apiVersion

getConcurrency()[source]
Returns

max number of concurrent calls

Return type

concurrency

getConcurrentTimeout()[source]
Returns

max number seconds to wait on futures if concurrency >= 1

Return type

concurrentTimeout

getDeploymentName()[source]
Returns

The name of the deployment

Return type

deploymentName

getErrorCol()[source]
Returns

column to hold http errors

Return type

errorCol

static getJavaPackage()[source]

Returns package name String.

getMaxTokens()[source]
Returns

The maximum number of tokens to generate. Has minimum of 0.

Return type

maxTokens

getModel()[source]
Returns

The name of the model to use

Return type

model

getOutputCol()[source]
Returns

The name of the output column

Return type

outputCol

getPostProcessing()[source]
Returns

Post processing options: csv, json, regex

Return type

postProcessing

getPostProcessingOptions()[source]
Returns

Options (default): delimiter=’,’, jsonSchema, regex, regexGroup=0

Return type

postProcessingOptions

getPromptTemplate()[source]
Returns

The prompt. supports string interpolation {col1}: {col2}.

Return type

promptTemplate

getStop()[source]
Returns

A sequence which indicates the end of the current document.

Return type

stop

getSubscriptionKey()[source]
Returns

the API key to use

Return type

subscriptionKey

getTemperature()[source]
Returns

What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or top_p but not both. Minimum of 0 and maximum of 2 allowed.

Return type

temperature

getTimeout()[source]
Returns

number of seconds to wait before closing the connection

Return type

timeout

getUrl()[source]
Returns

Url of the service

Return type

url

maxTokens = Param(parent='undefined', name='maxTokens', doc='ServiceParam: The maximum number of tokens to generate. Has minimum of 0.')
model = Param(parent='undefined', name='model', doc='ServiceParam: The name of the model to use')
outputCol = Param(parent='undefined', name='outputCol', doc='The name of the output column')
postProcessing = Param(parent='undefined', name='postProcessing', doc='Post processing options: csv, json, regex')
postProcessingOptions = Param(parent='undefined', name='postProcessingOptions', doc="Options (default): delimiter=',', jsonSchema, regex, regexGroup=0")
promptTemplate = Param(parent='undefined', name='promptTemplate', doc='The prompt. supports string interpolation {col1}: {col2}.')
classmethod read()[source]

Returns an MLReader instance for this class.

setAADToken(value)[source]
Parameters

AADToken – AAD Token used for authentication

setAADTokenCol(value)[source]
Parameters

AADToken – AAD Token used for authentication

setApiVersion(value)[source]
Parameters

apiVersion – version of the api

setApiVersionCol(value)[source]
Parameters

apiVersion – version of the api

setConcurrency(value)[source]
Parameters

concurrency – max number of concurrent calls

setConcurrentTimeout(value)[source]
Parameters

concurrentTimeout – max number seconds to wait on futures if concurrency >= 1

setCustomServiceName(value)[source]
setDeploymentName(value)[source]
Parameters

deploymentName – The name of the deployment

setDeploymentNameCol(value)[source]
Parameters

deploymentName – The name of the deployment

setEndpoint(value)[source]
setErrorCol(value)[source]
Parameters

errorCol – column to hold http errors

setMaxTokens(value)[source]
Parameters

maxTokens – The maximum number of tokens to generate. Has minimum of 0.

setMaxTokensCol(value)[source]
Parameters

maxTokens – The maximum number of tokens to generate. Has minimum of 0.

setModel(value)[source]
Parameters

model – The name of the model to use

setModelCol(value)[source]
Parameters

model – The name of the model to use

setOutputCol(value)[source]
Parameters

outputCol – The name of the output column

setParams(AADToken=None, AADTokenCol=None, apiVersion=None, apiVersionCol=None, concurrency=1, concurrentTimeout=None, deploymentName=None, deploymentNameCol=None, errorCol='Error', maxTokens=None, maxTokensCol=None, model=None, modelCol=None, outputCol='out', postProcessing='', postProcessingOptions={}, promptTemplate=None, stop=None, stopCol=None, subscriptionKey=None, subscriptionKeyCol=None, temperature=None, temperatureCol=None, timeout=60.0, url=None)[source]

Set the (keyword only) parameters

setPostProcessing(value)[source]
Parameters

postProcessing – Post processing options: csv, json, regex

setPostProcessingOptions(value)[source]
Parameters

postProcessingOptions – Options (default): delimiter=’,’, jsonSchema, regex, regexGroup=0

setPromptTemplate(value)[source]
Parameters

promptTemplate – The prompt. supports string interpolation {col1}: {col2}.

setStop(value)[source]
Parameters

stop – A sequence which indicates the end of the current document.

setStopCol(value)[source]
Parameters

stop – A sequence which indicates the end of the current document.

setSubscriptionKey(value)[source]
Parameters

subscriptionKey – the API key to use

setSubscriptionKeyCol(value)[source]
Parameters

subscriptionKey – the API key to use

setTemperature(value)[source]
Parameters

temperature – What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or top_p but not both. Minimum of 0 and maximum of 2 allowed.

setTemperatureCol(value)[source]
Parameters

temperature – What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or top_p but not both. Minimum of 0 and maximum of 2 allowed.

setTimeout(value)[source]
Parameters

timeout – number of seconds to wait before closing the connection

setUrl(value)[source]
Parameters

url – Url of the service

stop = Param(parent='undefined', name='stop', doc='ServiceParam: A sequence which indicates the end of the current document.')
subscriptionKey = Param(parent='undefined', name='subscriptionKey', doc='ServiceParam: the API key to use')
temperature = Param(parent='undefined', name='temperature', doc='ServiceParam: What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend using this or `top_p` but not both. Minimum of 0 and maximum of 2 allowed.')
timeout = Param(parent='undefined', name='timeout', doc='number of seconds to wait before closing the connection')
url = Param(parent='undefined', name='url', doc='Url of the service')

Module contents

SynapseML is an ecosystem of tools aimed towards expanding the distributed computing framework Apache Spark in several new directions. SynapseML adds many deep learning and data science tools to the Spark ecosystem, including seamless integration of Spark Machine Learning pipelines with Microsoft Cognitive Toolkit (CNTK), LightGBM and OpenCV. These tools enable powerful and highly-scalable predictive and analytical models for a variety of datasources.

SynapseML also brings new networking capabilities to the Spark Ecosystem. With the HTTP on Spark project, users can embed any web service into their SparkML models. In this vein, SynapseML provides easy to use SparkML transformers for a wide variety of Microsoft Cognitive Services. For production grade deployment, the Spark Serving project enables high throughput, sub-millisecond latency web services, backed by your Spark cluster.

SynapseML requires Scala 2.12, Spark 3.0+, and Python 3.6+.