LLM Synthethis package
The package provides methods for using LLMs to blend the results of analysis into various process perspectives (causal, process and XAI) and available process documentation to answer user queries related to the process.
Subpackages
Submodules
sax.core.synthesis.sax_explainability module
- sax.core.synthesis.sax_explainability.createDocumentContextRetriever(modelType: ModelTypes, modelName: str, temperature: int, documentsPath: str, filter=None, chunk_size=None, chunk_overlap=None, retrieved_results=None, dbPath=None) BaseRetriever
Create a document context retriever to use later for retreiving query-appropriate context.
- Parameters:
modelType (ModelTypes) -- the model provider type to use
modelName (str) -- the name of the model by the model provider to use as generative model
temperature (int) -- the temperature to use with the generative model
documentsPath (str) -- the path to the document/documents' folder
filter (str, optional) -- file extension of the files to be considered, defaults to None
chunk_size (int, optional) -- chunk_size for document splitting, defaults to None
chunk_overlap (int, optional) -- chunk overlap for document splitting, defaults to None
retrieved_results (int, optional) -- number of results to retrieve, defaults to None
dbPath (str, optional) -- path to the vectore store db, defaults to None
- Returns:
document retriever to be used later in rag-enhanced syntethis
- Return type:
- sax.core.synthesis.sax_explainability.enumerateDisrepancies(processModel, causalModel, p_value_threshold=None)
Enumerate the disrepancies between provided process and causal models
- Parameters:
processModel (dict) -- process model as dfg dictionary
causalModel (dict) -- causal model as dictionary
p_value_threshold (int, optional) -- filtering threshold for causal connections
- Returns:
array of disrepancies
- Return type:
array[str]
- sax.core.synthesis.sax_explainability.getExplanations(data: RawEventData, modality, variants: List[str] | None = None, prior_knowledge=None, p_value_threshold=None)
Return an array of semantic explanations for all process-causal disrepancies
- Parameters:
data (RawEventData) -- event log data
modality (Modality) -- chosen modality for causal discovery
prior_knowledge (boolean, optional) -- whether to use prior knowledge in causal discovery, defaults to None
p_value_threshold (int, optional) -- a filter for causal connections, connections with strength below the specified threshold will be disregarded, defaults to None
- Returns:
array of disrepancies
- Return type:
array[str]
- sax.core.synthesis.sax_explainability.getModel(modelType: ModelTypes, modelName: str, temperature: int)
Retrieve desired model wrapper based on the specified model provider, model name and temperature
- Parameters:
modelType (ModelTypes) -- model provider type
modelName (str) -- the name of the generative model provided by chosen provider
temperature (int) -- temperature to use for generation
- Returns:
Chosen model wrapper
- Return type:
- sax.core.synthesis.sax_explainability.getSyntethis(data: RawEventData, query: str, model: BaseLLM, causal: bool, process: bool, xai: bool, rag: bool, retriever: DocumentRetrieverLLM = None, modality=Modality.PARENT, prior_knowledge=True, p_value_threshold=None, variants: List[str] | None = None)
Get blended answer based on the user-chosen perspectives for the user provided query
- Parameters:
data (RawEventData) -- event log data
query (str) -- user query
model (BaseLLM) -- LLM model wrapper
causal (bool) -- indication whether to use causal perspective
process (bool) -- indication whether to use process perspective
xai (bool) -- indication whether to use xai perspective
rag (bool) -- indicatin whether to use document context
retriever (DocumentRetrieverLLM, optional) -- in case rag is chosen, need to provide previously created retreiver, defaults to None
modality (Modality, optional) -- in case causal perspective is chosen, the desired analysis modality, defaults to Modality.PARENT
prior_knowledge (bool, optional) -- in case causal perspective is chosen, whether to use prior knowledge or not, defaults to True
p_value_threshold (float, optional) -- in case causal perspective is chosen, whether to filter causal connections below specified threshold, defaults to None
- Returns:
Blended anwer to the query based on all chosen perspectives
- Return type:
str