Library convenience methods
This is an automatic generated API reference of the library convenience methods for Risk Atlas Nexus
library
Classes:
-
RiskAtlasNexus–A RiskAtlasNexus object
Attributes:
RISK_IDENTIFICATION_COT
module-attribute
RISK_IDENTIFICATION_COT = load_resource('risk_generation_cot.json')
logger
module-attribute
logger = configure_logger(__name__)
RiskAtlasNexus
RiskAtlasNexus(base_dir: str = None)
A RiskAtlasNexus object
Create a new RiskAtlasNexus object
Parameters:
-
base_dir(str, default:None) –str (Optional) add an alternative source of date
Methods:
-
categorize_risk_severity–Determine the severity of risks based on the use case description.
-
export–Export RiskAtlasNexus configuration to file.
-
generate_few_shot_risk_questionnaire_output–Get prediction using the few shot (Chain of Thought) examples.
-
generate_proposed_mappings–Identify mappings between a new set of risks and risks that exist in the Risk Atlas
-
generate_zero_shot_risk_questionnaire_output–Get prediction using the zero shot approach.
-
get_action_by_id–Get an action definition from the LinkML, filtered by action id
-
get_adapter–Get an adapter definition from the LinkML, filtered by id
-
get_adapters–Get all adapter definitions from the LinkML
-
get_all_actions–Get all action definitions from the LinkML
-
get_all_evaluations–Get all evaluation definitions from the LinkML
-
get_all_risk_controls–Get all risk control definitions from the LinkML
-
get_all_risks–Get all risk definitions from the LinkML
-
get_all_taxonomies–Get all taxonomy definitions from the LinkML
-
get_benchmark_metadata_card–Get an benchmark_metadata_card definition from the LinkML, filtered by id
-
get_benchmark_metadata_cards–Get all benchmark metadata definitions from the LinkML
-
get_dataset–Get a dataset definition from the LinkML, filtered by id
-
get_datasets–Get all dataset definitions from the LinkML
-
get_document–Get a document definition from the LinkML, filtered by id
-
get_documents–Get all document definitions from the LinkML
-
get_evaluation–Get an evaluation definition from the LinkML, filtered by id
-
get_instances–Get all instance definitions from the LinkML
-
get_intrinsic–Get an intrinsic definition from the LinkML, filtered by id
-
get_intrinsics–Get all intrinsic definitions from the LinkML
-
get_llm_question_policies–Get all LLM Quesiton Policy definitions from the LinkML
-
get_llm_question_policy–Get an LLM Question Policy definition from the LinkML, filtered by id
-
get_related_actions–Get actions for a risk definition from the LinkML. The risk is identified by risk id, tag, or name
-
get_related_evaluations–Get related evaluations filtered by risk id
-
get_related_intrinsics–Get related intrinsics for a risk definition from the LinkML. The risk is identified by risk id, tag, or name
-
get_related_risk_controls–Get related risk controls for a risk definition from the LinkML. The risk is identified by risk id, tag, or name
-
get_related_risk_incidents–Get related risk incident filtered by risk id
-
get_related_risks–Get related risks from the LinkML, filtered by risk id, tag, or name
-
get_risk–Get risk definition from the LinkML, filtered by risk atlas id, tag, name
-
get_risk_control–Get an action definition from the LinkML, filtered by risk control id
-
get_risk_incident–Get an risk incident instance filtered by risk incident id
-
get_risk_incidents–Get risk incident instances, optionally filtered by taxonomy
-
get_schema–Get schema
-
get_stakeholder–Get a stakeholder definition from the LinkML, filtered by id
-
get_stakeholders–Get all stakeholder definitions from the LinkML
-
get_taxonomy_by_id–Get taxonomy definitions from the LinkML filtered by taxonomy id
-
get_version–Get library version
-
identify_ai_tasks_from_usecases–Identify potential risks from a usecase description
-
identify_domain_from_usecases–Identify potential risks from a usecase description
-
identify_risks_from_usecases–Identify potential risks from a usecase description
Attributes:
-
directory– -
fn– -
schema_view–
directory
class-attribute
instance-attribute
directory = dirname(abspath(__file__))
fn
class-attribute
instance-attribute
fn = join(directory, 'ai_risk_ontology/schema/ai-risk-ontology.yaml')
categorize_risk_severity
categorize_risk_severity(usecases: List[str], inference_engine: InferenceEngine)
Determine the severity of risks based on the use case description. Args: usecases (List[str]): A List of strings describing AI usecases inference_engine (InferenceEngine): An LLM inference engine Returns: results (List[Dict]): Results detailing risk categorization by usecase.
export
export(export_path)
Export RiskAtlasNexus configuration to file.
Parameters:
-
export_path–str The path to the directory where the artifact will be exported to.
generate_few_shot_risk_questionnaire_output
generate_few_shot_risk_questionnaire_output(usecase: str, risk_questionnaire: List[Dict[str, Any]], inference_engine: InferenceEngine, verbose=True)
Get prediction using the few shot (Chain of Thought) examples.
Parameters:
-
usecase(str) –A string describing an AI usecase
-
risk_questionnaire(List[Dict]) –Chain of Thought data for risk questionnaire. Each question is associated with a list of example intents and corresponding answers. Check example JSON below. ``` [ { "question": "In which environment is the system used?", "examples": [ "intent": "Find patterns in healthcare insurance claims", "answer": "Insurance Claims Processing or Risk Management or Data Analytics", "explanation": "The system might be used by an insurance company's claims processing department to analyze and identify patterns in healthcare insurance claims." ] } ]
-
inference_engine(InferenceEngine) –An LLM inference engine to predict the output based on the given use case.
-
filter_cot_data_by(Dict[str, str]) –A dictionary to filter CoT examples with key as CoT field and value as filter string. ```
Returns:
-
–
List[str]: List of LLM predictions.
generate_proposed_mappings
generate_proposed_mappings(new_risks: List[Risk], existing_risks: List[Risk], inference_engine: InferenceEngine, new_prefix: str, mapping_method: MappingMethod = SEMANTIC) -> List[Mapping]
Identify mappings between a new set of risks and risks that exist in the Risk Atlas
Parameters:
-
new_risks(List[Risk]) –List[Risk] A new set of risks
-
existing_risks(List[Risk]) –List[Risk] Secondary list, this should be the list of existing risks in RAN
-
inference_engine(InferenceEngine) –(Optional)Union[InferenceEngine | None]: An LLM inference engine to infer risks from the use cases.
-
new_prefix(str) –str The CURIE prefix for the new list of risks
-
mapping_method(MappingMethod, default:SEMANTIC) –MappingMethod The possible values for type of risk mapping method
Returns:
-
List[Mapping]–List[Mapping] Result containing a list of mappings
generate_zero_shot_risk_questionnaire_output
generate_zero_shot_risk_questionnaire_output(usecase: str, risk_questionnaire: List[Dict[str, str]], inference_engine: InferenceEngine, verbose=True)
Get prediction using the zero shot approach.
Parameters:
-
usecase(str) –A string describing an AI usecase
-
risk_questionnaire(List[Dict[str, str]]) –List[Dict[str, str]]: A risk questionnaire Check example below.
[ "In which environment is the system used?", ] -
inference_engine(InferenceEngine) –An LLM inference engine to predict the output based on the given use case.
Returns:
-
–
List[str]: List of LLM predictions.
get_action_by_id
get_action_by_id(id, taxonomy=None)
Get an action definition from the LinkML, filtered by action id
Parameters:
-
id–str The string id identifying the action
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Action Result containing an action
get_adapter
get_adapter(id=str)
Get an adapter definition from the LinkML, filtered by id
Parameters:
-
id–str The string id identifying the stakeholder entry
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Adapter Result containing a adapter.
get_adapters
get_adapters(taxonomy=None)
Get all adapter definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[Adapter] Result containing a list of Adapter entries
get_all_actions
get_all_actions(taxonomy=None)
Get all action definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[Action] Result containing a list of AI actions
get_all_evaluations
get_all_evaluations(taxonomy=None)
Get all evaluation definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[RiskControl] Result containing a list of AiEval
get_all_risk_controls
get_all_risk_controls(taxonomy=None)
Get all risk control definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[RiskControl] Result containing a list of RiskControls
get_all_risks
get_all_risks(taxonomy=None)
Get all risk definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[Risk] Result containing a list of AI risks
get_all_taxonomies
get_all_taxonomies()
Get all taxonomy definitions from the LinkML
Returns:
-
–
List[RiskTaxonomy] Result containing a list of AI Risk taxonomies
get_benchmark_metadata_card
get_benchmark_metadata_card(id=str)
Get an benchmark_metadata_card definition from the LinkML, filtered by id
Parameters:
-
id–str The string id identifying the benchmark_metadata_card
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
BenchmarkMetadataCard Result containing a benchmark_metadata_card.
get_benchmark_metadata_cards
get_benchmark_metadata_cards(risk=None, risk_id=None, taxonomy=None)
Get all benchmark metadata definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[BenchmarkMetadataCard] Result containing a list of BenchmarkMetadataCards
get_dataset
get_dataset(id=str)
Get a dataset definition from the LinkML, filtered by id
Parameters:
-
id–str The string id identifying the dataset entry
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Dataset Result containing a dataset.
get_datasets
get_datasets(taxonomy=None)
Get all dataset definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[Dataset] Result containing a list of Dataset entries
get_document
get_document(id=str)
Get a document definition from the LinkML, filtered by id
Parameters:
-
id–str The string id identifying the documentation entry
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Documentation Result containing a document.
get_documents
get_documents(taxonomy=None)
Get all document definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[Documentation] Result containing a list of Documentation
get_evaluation
get_evaluation(id=None, taxonomy=None)
Get an evaluation definition from the LinkML, filtered by id
Parameters:
-
id–str The string id identifying the evaluation
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Action Result containing an evaluation.
get_instances
get_instances(target_class, taxonomy=None)
Get all instance definitions from the LinkML
Parameters:
-
target_class–str (Optional) The string label for a target class
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[Any] Result containing a list of instance entries
get_intrinsic
get_intrinsic(id=str)
Get an intrinsic definition from the LinkML, filtered by id
Parameters:
-
id–str The string id identifying the intrinsic entry
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
LLMIntrinsic Result containing a intrinsic.
get_intrinsics
get_intrinsics(taxonomy=None)
Get all intrinsic definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[LLMIntrinsic] Result containing a list of LLMIntrinsic entries
get_llm_question_policies
get_llm_question_policies(taxonomy=None)
Get all LLM Quesiton Policy definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[LLMQuestionPolicy] Result containing a list of LLMQuestionPolicy entries
get_llm_question_policy
get_llm_question_policy(id=str)
Get an LLM Question Policy definition from the LinkML, filtered by id
Parameters:
-
id–str The string id identifying the LLM question policy entry
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
LLMQuestionPolicy Result containing an LLM Question Policy.
get_related_actions
get_related_actions(risk=None, tag=None, id=None, name=None, taxonomy=None)
Get actions for a risk definition from the LinkML. The risk is identified by risk id, tag, or name
Parameters:
-
risk–(Optional) Risk The risk
-
id–(Optional) str The string ID identifying the risk
-
tag–(Optional) str The string tag identifying the risk
-
name–(Optional) str The string name identifying the risk
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Risk Result containing a list of AI actions
get_related_evaluations
get_related_evaluations(risk=None, risk_id=None, taxonomy=None)
Get related evaluations filtered by risk id
Parameters:
-
risk–(Optional) Risk The risk
-
risk_id–(Optional) str The string ID identifying the risk
-
taxonomy–str (Optional) The string label for a taxonomy
Returns: List[AiEval] Result containing a list of AI evaluations
get_related_intrinsics
get_related_intrinsics(risk=None, tag=None, risk_id=None, name=None, taxonomy=None)
Get related intrinsics for a risk definition from the LinkML. The risk is identified by risk id, tag, or name
Parameters:
-
risk–(Optional) Risk The risk
-
risk_id–(Optional) str The string ID identifying the risk
-
tag–(Optional) str The string tag identifying the risk
-
name–(Optional) str The string name identifying the risk
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
List Result containing a list of Intrinsics
get_related_risk_controls
get_related_risk_controls(risk=None, tag=None, id=None, name=None, taxonomy=None)
Get related risk controls for a risk definition from the LinkML. The risk is identified by risk id, tag, or name
Parameters:
-
risk–(Optional) Risk The risk
-
id–(Optional) str The string ID identifying the risk
-
tag–(Optional) str The string tag identifying the risk
-
name–(Optional) str The string name identifying the risk
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Risk Result containing a list of AI actions
get_related_risk_incidents
get_related_risk_incidents(risk=None, risk_id=None, taxonomy=None)
Get related risk incident filtered by risk id
Parameters:
-
risk–(Optional) Risk The risk
-
risk_id–(Optional) str The string ID identifying the risk
-
taxonomy–str (Optional) The string label for a taxonomy
Returns: List[RiskIncident] Result containing a list of AI risk incidents
get_related_risks
get_related_risks(risk=None, tag=None, id=None, name=None, taxonomy=None)
Get related risks from the LinkML, filtered by risk id, tag, or name
Parameters:
-
risk–(Optional) Risk The risk
-
id–(Optional) str The string ID identifying the risk
-
tag–(Optional) str The string tag identifying the risk
-
name–(Optional) str The string name identifying the risk
-
taxonomy–str (Optional) The string label for a taxonomy
Returns: List[str] Result containing a list of AI risk IDs
get_risk
get_risk(tag=None, id=None, name=None, taxonomy=None)
Get risk definition from the LinkML, filtered by risk atlas id, tag, name
Parameters:
-
id–(Optional) str The string ID identifying the risk
-
tag–(Optional) str The string tag identifying the risk
-
name–(Optional) str The string name identifying the risk
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Risk Result containing a list of AI risks
get_risk_control
get_risk_control(id=None, taxonomy=None)
Get an action definition from the LinkML, filtered by risk control id
Parameters:
-
id–str The string id identifying the risk control
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Action Result containing a risk control.
get_risk_incident
get_risk_incident(id=None, taxonomy=None)
Get an risk incident instance filtered by risk incident id
Parameters:
-
id–str The string id identifying the risk incident
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
RiskIncident Result containing a risk incident.
get_risk_incidents
get_risk_incidents(taxonomy: Optional[str] = None)
Get risk incident instances, optionally filtered by taxonomy
Returns:
-
–
List[RiskIncident] Result containing a list of AI Risk Incidents
get_schema
classmethod
get_schema()
Get schema
Returns:
-
–
schema
get_stakeholder
get_stakeholder(id=str)
Get a stakeholder definition from the LinkML, filtered by id
Parameters:
-
id–str The string id identifying the stakeholder entry
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
Stakeholder Result containing a stakeholder.
get_stakeholders
get_stakeholders(taxonomy=None)
Get all stakeholder definitions from the LinkML
Parameters:
-
taxonomy–str (Optional) The string label for a taxonomy
Returns:
-
–
list[Stakeholder] Result containing a list of Stakeholder entries
get_taxonomy_by_id
get_taxonomy_by_id(id)
Get taxonomy definitions from the LinkML filtered by taxonomy id
Parameters:
-
id–str The string id for a taxonomy
Returns:
-
–
RiskTaxonomy An AI Risk taxonomy
get_version
classmethod
get_version()
Get library version
Returns:
-
dict–Version number
identify_ai_tasks_from_usecases
identify_ai_tasks_from_usecases(usecases: List[str], inference_engine: InferenceEngine, verbose=True) -> List[List[str]]
Identify potential risks from a usecase description
Parameters:
-
usecases(List[str]) –A List of strings describing AI usecases
-
inference_engine(InferenceEngine) –An LLM inference engine to identify AI tasks from usecases.
Returns:
-
List[List[str]]–List[List[str]]: Result containing a list of AI tasks
identify_domain_from_usecases
identify_domain_from_usecases(usecases: List[str], inference_engine: InferenceEngine, verbose=True) -> List[List[str]]
Identify potential risks from a usecase description
Parameters:
-
usecases(List[str]) –A List of strings describing AI usecases
-
inference_engine(InferenceEngine) –An LLM inference engine to identify AI tasks from usecases.
Returns:
-
List[List[str]]–List[List[str]]: Result containing a list of AI tasks
identify_risks_from_usecases
identify_risks_from_usecases(usecases: List[str], inference_engine: InferenceEngine, taxonomy: Optional[str] = None, cot_examples: Optional[Dict[str, List]] = None, max_risk: Optional[int] = None, zero_shot_only: bool = False) -> List[List[Risk]]
Identify potential risks from a usecase description
Parameters:
-
usecases(List[str]) –A List of strings describing AI usecases
-
inference_engine(InferenceEngine) –An LLM inference engine to infer risks from the usecases.
-
taxonomy(str, default:None) –The string label for a taxonomy. If not specified, the system will use "ibm-risk-atlas" as the default taxonomy.
-
cot_examples(Dict[str, List], default:None) –If the user wants to improve risk identification via a Few-shot approach,
cot_examplescan be provided with the desired taxonomy as key. Please follow the example template at src/risk_atlas_nexus/data/templates/risk_generation_cot.json. If thecot_examplesis omitted, the API default to a Zero-Shot approach. -
max_risk(int, default:None) –The maximum number of risks to extract. Pass None to allow the inference engine to determine the number of risks. Defaults to None.
-
zero_shot_only(bool, default:False) –If enabled, this flag allows the system to perform Zero Shot Risk identification, and the field
cot_exampleswill be ignored.
Returns: List[List[Risk]]: Result containing a list of risks