validmind 2.1.1__py3-none-any.whl → 2.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. validmind/__version__.py +1 -1
  2. validmind/ai.py +3 -3
  3. validmind/api_client.py +2 -3
  4. validmind/client.py +68 -25
  5. validmind/datasets/llm/rag/__init__.py +11 -0
  6. validmind/datasets/llm/rag/datasets/rfp_existing_questions_client_1.csv +30 -0
  7. validmind/datasets/llm/rag/datasets/rfp_existing_questions_client_2.csv +30 -0
  8. validmind/datasets/llm/rag/datasets/rfp_existing_questions_client_3.csv +53 -0
  9. validmind/datasets/llm/rag/datasets/rfp_existing_questions_client_4.csv +53 -0
  10. validmind/datasets/llm/rag/datasets/rfp_existing_questions_client_5.csv +53 -0
  11. validmind/datasets/llm/rag/rfp.py +41 -0
  12. validmind/html_templates/__init__.py +0 -0
  13. validmind/html_templates/content_blocks.py +89 -14
  14. validmind/models/__init__.py +7 -4
  15. validmind/models/foundation.py +8 -34
  16. validmind/models/function.py +51 -0
  17. validmind/models/huggingface.py +16 -46
  18. validmind/models/metadata.py +42 -0
  19. validmind/models/pipeline.py +66 -0
  20. validmind/models/pytorch.py +8 -42
  21. validmind/models/r_model.py +33 -82
  22. validmind/models/sklearn.py +39 -38
  23. validmind/template.py +8 -26
  24. validmind/tests/__init__.py +43 -20
  25. validmind/tests/data_validation/ANOVAOneWayTable.py +1 -1
  26. validmind/tests/data_validation/ChiSquaredFeaturesTable.py +1 -1
  27. validmind/tests/data_validation/DescriptiveStatistics.py +2 -4
  28. validmind/tests/data_validation/Duplicates.py +1 -1
  29. validmind/tests/data_validation/IsolationForestOutliers.py +2 -2
  30. validmind/tests/data_validation/LaggedCorrelationHeatmap.py +1 -1
  31. validmind/tests/data_validation/TargetRateBarPlots.py +1 -1
  32. validmind/tests/data_validation/nlp/LanguageDetection.py +59 -0
  33. validmind/tests/data_validation/nlp/PolarityAndSubjectivity.py +48 -0
  34. validmind/tests/data_validation/nlp/Punctuations.py +11 -12
  35. validmind/tests/data_validation/nlp/Sentiment.py +57 -0
  36. validmind/tests/data_validation/nlp/Toxicity.py +45 -0
  37. validmind/tests/decorator.py +2 -2
  38. validmind/tests/model_validation/BertScore.py +100 -98
  39. validmind/tests/model_validation/BleuScore.py +93 -64
  40. validmind/tests/model_validation/ContextualRecall.py +74 -91
  41. validmind/tests/model_validation/MeteorScore.py +86 -74
  42. validmind/tests/model_validation/RegardScore.py +103 -121
  43. validmind/tests/model_validation/RougeScore.py +118 -0
  44. validmind/tests/model_validation/TokenDisparity.py +84 -121
  45. validmind/tests/model_validation/ToxicityScore.py +109 -123
  46. validmind/tests/model_validation/embeddings/CosineSimilarityComparison.py +96 -0
  47. validmind/tests/model_validation/embeddings/CosineSimilarityHeatmap.py +71 -0
  48. validmind/tests/model_validation/embeddings/EuclideanDistanceComparison.py +92 -0
  49. validmind/tests/model_validation/embeddings/EuclideanDistanceHeatmap.py +69 -0
  50. validmind/tests/model_validation/embeddings/PCAComponentsPairwisePlots.py +78 -0
  51. validmind/tests/model_validation/embeddings/StabilityAnalysis.py +35 -23
  52. validmind/tests/model_validation/embeddings/StabilityAnalysisKeyword.py +3 -0
  53. validmind/tests/model_validation/embeddings/StabilityAnalysisRandomNoise.py +7 -1
  54. validmind/tests/model_validation/embeddings/StabilityAnalysisSynonyms.py +3 -0
  55. validmind/tests/model_validation/embeddings/StabilityAnalysisTranslation.py +3 -0
  56. validmind/tests/model_validation/embeddings/TSNEComponentsPairwisePlots.py +99 -0
  57. validmind/tests/model_validation/ragas/AnswerCorrectness.py +131 -0
  58. validmind/tests/model_validation/ragas/AnswerRelevance.py +134 -0
  59. validmind/tests/model_validation/ragas/AnswerSimilarity.py +119 -0
  60. validmind/tests/model_validation/ragas/AspectCritique.py +167 -0
  61. validmind/tests/model_validation/ragas/ContextEntityRecall.py +133 -0
  62. validmind/tests/model_validation/ragas/ContextPrecision.py +123 -0
  63. validmind/tests/model_validation/ragas/ContextRecall.py +123 -0
  64. validmind/tests/model_validation/ragas/ContextRelevancy.py +114 -0
  65. validmind/tests/model_validation/ragas/Faithfulness.py +119 -0
  66. validmind/tests/model_validation/ragas/utils.py +66 -0
  67. validmind/tests/model_validation/sklearn/OverfitDiagnosis.py +3 -7
  68. validmind/tests/model_validation/sklearn/PermutationFeatureImportance.py +8 -9
  69. validmind/tests/model_validation/sklearn/PopulationStabilityIndex.py +5 -10
  70. validmind/tests/model_validation/sklearn/PrecisionRecallCurve.py +3 -2
  71. validmind/tests/model_validation/sklearn/ROCCurve.py +2 -1
  72. validmind/tests/model_validation/sklearn/RegressionR2Square.py +1 -1
  73. validmind/tests/model_validation/sklearn/RobustnessDiagnosis.py +2 -3
  74. validmind/tests/model_validation/sklearn/SHAPGlobalImportance.py +7 -11
  75. validmind/tests/model_validation/sklearn/WeakspotsDiagnosis.py +3 -4
  76. validmind/tests/model_validation/statsmodels/RegressionModelForecastPlot.py +1 -1
  77. validmind/tests/model_validation/statsmodels/RegressionModelForecastPlotLevels.py +1 -1
  78. validmind/tests/model_validation/statsmodels/RegressionModelInsampleComparison.py +1 -1
  79. validmind/tests/model_validation/statsmodels/RegressionModelOutsampleComparison.py +1 -1
  80. validmind/tests/model_validation/statsmodels/RegressionModelSummary.py +1 -1
  81. validmind/tests/model_validation/statsmodels/RegressionModelsCoeffs.py +1 -1
  82. validmind/tests/model_validation/statsmodels/RegressionModelsPerformance.py +1 -1
  83. validmind/tests/model_validation/statsmodels/ScorecardHistogram.py +5 -6
  84. validmind/unit_metrics/__init__.py +26 -49
  85. validmind/unit_metrics/composite.py +5 -1
  86. validmind/unit_metrics/regression/sklearn/AdjustedRSquaredScore.py +1 -1
  87. validmind/utils.py +56 -6
  88. validmind/vm_models/__init__.py +1 -1
  89. validmind/vm_models/dataset/__init__.py +7 -0
  90. validmind/vm_models/dataset/dataset.py +558 -0
  91. validmind/vm_models/dataset/utils.py +146 -0
  92. validmind/vm_models/model.py +97 -72
  93. validmind/vm_models/test/result_wrapper.py +61 -24
  94. validmind/vm_models/test_context.py +1 -1
  95. validmind/vm_models/test_suite/summary.py +3 -4
  96. {validmind-2.1.1.dist-info → validmind-2.2.2.dist-info}/METADATA +5 -3
  97. {validmind-2.1.1.dist-info → validmind-2.2.2.dist-info}/RECORD +100 -75
  98. validmind/models/catboost.py +0 -33
  99. validmind/models/statsmodels.py +0 -50
  100. validmind/models/xgboost.py +0 -30
  101. validmind/tests/model_validation/BertScoreAggregate.py +0 -90
  102. validmind/tests/model_validation/RegardHistogram.py +0 -148
  103. validmind/tests/model_validation/RougeMetrics.py +0 -147
  104. validmind/tests/model_validation/RougeMetricsAggregate.py +0 -133
  105. validmind/tests/model_validation/SelfCheckNLIScore.py +0 -112
  106. validmind/tests/model_validation/ToxicityHistogram.py +0 -136
  107. validmind/vm_models/dataset.py +0 -1303
  108. {validmind-2.1.1.dist-info → validmind-2.2.2.dist-info}/LICENSE +0 -0
  109. {validmind-2.1.1.dist-info → validmind-2.2.2.dist-info}/WHEEL +0 -0
  110. {validmind-2.1.1.dist-info → validmind-2.2.2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,53 @@
1
+ Project_Title,RFP_Question_ID,question,ground_truth,Area,Last_Accessed_At,Requester,Status
2
+ "Generative AI Solutions for Fraud Detection and Financial Security
3
+ ",1,Please share your experience with developing AI-enabled applications and provide examples of notable projects.,"Our company has 15 years of experience in developing AI-based applications, with a strong portfolio in sectors such as healthcare, finance, and education. For instance, our project MediAI Insight for the healthcare industry demonstrated significant achievements in patient data analysis, resulting in a 30% reduction in diagnostic errors and a 40% improvement in treatment personalization. Our platform has engaged over 200 healthcare facilities, achieving a user satisfaction rate of 95%.",General,18/10/2022,Bank E,Under Review
4
+ "Generative AI Solutions for Fraud Detection and Financial Security
5
+ ",2,How do you maintain your AI applications with the newest AI technologies and advancements?,"We maintain a dedicated R&D team focused on integrating the latest AI advancements into our applications. This includes regular updates and feature enhancements based on cutting-edge technologies such as GPT (Generative Pre-trained Transformer) for natural language understanding, CNNs (Convolutional Neural Networks) for advanced image recognition tasks, and DQN (Deep Q-Networks) for decision-making processes in complex environments. Our commitment to these AI methodologies ensures that our applications remain innovative, with capabilities that adapt to evolving market demands and client needs. This approach has enabled us to enhance the predictive accuracy of our financial forecasting tools by 25% and improve the efficiency of our educational content personalization by 40%",General,18/10/2022,Bank E,Under Review
6
+ "Generative AI Solutions for Fraud Detection and Financial Security
7
+ ",3,Can your AI applications be tailored to meet unique organizational or user-specific requirements?,"Absolutely, customization is a core aspect of our offering. We work closely with clients to understand their specific needs and tailor our AI algorithms and app functionalities accordingly, using technologies such as TensorFlow for machine learning models, React for responsive UI/UX designs, and Kubernetes for scalable cloud deployment. This personalized approach allows us to optimize AI functionalities to match unique business processes, enhancing user experience and operational efficiency for each client. For example, for a retail client, we customized our recommendation engine to increase customer retention by 20% through more accurate and personalized product suggestions.",General,18/10/2022,Bank E,Under Review
8
+ "Generative AI Solutions for Fraud Detection and Financial Security
9
+ ",4,What actions do you undertake to secure user data and maintain privacy within your AI platforms?,"User privacy and data security are paramount. We implement robust measures such as end-to-end encryption to secure data transmissions, anonymization techniques to protect user identities, and comprehensive compliance with data protection laws like GDPR and CCPA. We also employ regular security audits and vulnerability assessments to ensure our systems are impenetrable. Additionally, our deployment of advanced intrusion detection systems and the use of secure coding practices reinforce our commitment to safeguarding user data at all times",General,18/10/2022,Bank E,Under Review
10
+ "Generative AI Solutions for Fraud Detection and Financial Security
11
+ ",5,What considerations do you take into account for user interface and user experience design in your AI applications?,"Our design philosophy centers on simplicity and intuitiveness. We conduct extensive user research and testing to inform our UI/UX designs, ensuring that our AI-based apps are accessible and engaging for all users, regardless of their technical expertise. This includes applying principles from human-centered design, utilizing accessibility guidelines such as WCAG 2.1, and conducting iterative testing with diverse user groups. Our commitment to inclusivity and usability leads to higher user adoption rates and satisfaction. For instance, feedback-driven enhancements in our visual design have improved user engagement by over 30% across our applications.",General,18/10/2022,Bank E,Under Review
12
+ "Generative AI Solutions for Fraud Detection and Financial Security
13
+ ",6,What support and maintenance do you provide following the deployment of AI applications?,"Post-launch, we offer comprehensive support and maintenance services, including regular updates, bug fixes, and performance optimization. Our support team is available 24/7 to assist with any issues or questions. We utilize a ticketing system that ensures swift response times, with an average initial response time of under 2 hours. Additionally, we provide monthly performance reports and hold quarterly reviews with clients to discuss system status and potential improvements. Our proactive approach includes using automated monitoring tools to detect and resolve issues before they impact users, ensuring that our applications perform optimally at all times. This service structure has been instrumental in maintaining a client satisfaction rate above 98%.",General,18/10/2022,Bank E,Under Review
14
+ "Generative AI Solutions for Fraud Detection and Financial Security
15
+ ",7,How do you evaluate the success of your AI applications in fulfilling client goals?,"Success measurement is tailored to each project's objectives. We establish key performance indicators (KPIs) in collaboration with our clients, such as user engagement rates, efficiency improvements, or return on investment (ROI). We then regularly review these metrics using advanced analytics platforms and business intelligence tools to assess the app’s impact. Our approach includes monthly performance analysis meetings where we provide detailed reports and insights on metrics like session duration, user retention rates, and cost savings achieved through automation. We also implement A/B testing to continuously refine and optimize the application based on real-world usage data, ensuring that we make data-driven improvements that align closely with our clients' strategic goals.",General,18/10/2022,Bank E,Under Review
16
+ "Generative AI Solutions for Fraud Detection and Financial Security
17
+ ",8,How are ethical issues like bias detection and data privacy managed in your LLM applications?,"We adhere to ethical AI practices by implementing bias detection and mitigation techniques during the training of our Large Language Models (LLMs). This involves using diverse datasets to prevent skewed results and deploying algorithms specifically designed to identify and correct bias in AI outputs. For data privacy, we employ data anonymization and secure data handling protocols, ensuring compliance with GDPR, CCPA, and other relevant regulations. Our systems use state-of-the-art encryption methods for data at rest and in transit, and our data governance policies are rigorously audited by third-party security firms to maintain high standards of data integrity and confidentiality. This commitment extends to regular training for our staff on the latest privacy laws and ethical AI use to ensure that our practices are up-to-date and effective.",Large Language Models,18/10/2022,Bank E,Under Review
18
+ "Generative AI Solutions for Fraud Detection and Financial Security
19
+ ",9,"Please outline the training process for your LLMs, including choices regarding data, models, and validation approaches.","Our LLM training process begins with the meticulous sourcing of diverse and comprehensive datasets from global sources, ensuring a rich variety that includes various languages, dialects, and cultural contexts. This diversity is critical for building models that perform equitably across different demographics. We leverage cutting-edge tools like Apache Kafka for real-time data streaming and Apache Hadoop for handling large datasets efficiently during preprocessing stages. For model architecture selection, we utilize TensorFlow and PyTorch frameworks to design and iterate on neural network structures that best suit each application's unique requirements, whether it's for predictive analytics in finance or customer service chatbots. Depending on the use case, we might choose from a variety of architectures such as Transformer models for their robust handling of sequential data or GANs (Generative Adversarial Networks) for generating new, synthetic data samples for training.",Large Language Models,18/10/2022,Bank E,Under Review
20
+ "Generative AI Solutions for Fraud Detection and Financial Security
21
+ ",10,How do your LLMs continuously learn and update to reflect new data and changing user expectations?,"We implement advanced continuous learning mechanisms that allow our Large Language Models (LLMs) to adapt over time by incorporating new data and feedback loops, ensuring our models remain current and effective. We utilize incremental learning techniques where the model is periodically updated with fresh data without the need for retraining from scratch. This is facilitated by employing online learning algorithms such as Online Gradient Descent, which can quickly adjust model weights in response to new information.
22
+ To efficiently manage this continuous learning process, we use tools like Apache Spark for handling large-scale data processing in a distributed computing environment. This allows for seamless integration of new data streams into our training datasets. We also implement active learning cycles where the models request human feedback on specific outputs that are uncertain, thus refining model predictions over time based on actual user interactions and feedback.
23
+ Additionally, we incorporate reinforcement learning techniques where models are rewarded for improvements in performance metrics like accuracy and user engagement. This helps in fine-tuning the models' responses based on what is most effective in real-world scenarios.
24
+ For monitoring and managing these updates, we use TensorFlow Extended (TFX) for a robust end-to-end platform that ensures our models are consistently validated against performance benchmarks before being deployed. This continuous adaptation framework guarantees that our LLMs are not only keeping pace with evolving user needs and preferences but are also progressively enhancing their relevance and effectiveness.",Large Language Models,18/10/2022,Bank E,Under Review
25
+ "Generative AI Solutions for Fraud Detection and Financial Security
26
+ ",11,What measures do you employ to ensure your LLMs' decisions are clear and explicable?,"We prioritize transparency and explainability in our AI models by incorporating advanced features such as model interpretability layers and providing comprehensive documentation on how model decisions are made. This approach ensures that users can understand and trust the outputs of our Large Language Models (LLMs). To achieve this, we integrate tools like LIME (Local Interpretable Model-agnostic Explanations) and SHAP (SHapley Additive exPlanations) into our models. These tools allow us to break down and communicate the reasoning behind each model decision, fostering trust and facilitating easier audits by stakeholders.",Large Language Models,18/10/2022,Bank E,Under Review
27
+ "Generative AI Solutions for Fraud Detection and Financial Security
28
+ ",12,How do you ensure your LLMs can efficiently handle increased loads and demand?,"We conduct extensive performance testing under various load conditions to assess scalability and ensure our LLMs can handle high-demand scenarios efficiently. This involves using tools like Apache JMeter and LoadRunner to simulate different levels of user interaction and data volume, allowing us to evaluate how our systems perform under stress. Additionally, we employ scalable cloud infrastructure, utilizing services like Amazon Web Services (AWS) Elastic Compute Cloud (EC2) and Google Cloud Platform (GCP) Compute Engine, which support dynamic scaling. Optimization techniques such as auto-scaling groups and load balancers are implemented to ensure that our resources adjust automatically based on real-time demands, providing both robustness and cost efficiency.",Large Language Models,18/10/2022,Bank E,Under Review
29
+ "Generative AI Solutions for Fraud Detection and Financial Security
30
+ ",13,"Could you provide case studies on successful LLM-based application deployments, focusing on challenges and solutions?","We can share case studies of successful LLM-based application deployments, highlighting specific challenges such as data scarcity or model interpretability, and detailing the strategies and solutions we implemented to overcome these challenges. For example, in a project involving natural language processing for a legal firm, we faced significant data scarcity. To address this, we employed techniques like synthetic data generation and transfer learning from related domains to enrich our training datasets. Additionally, the issue of model interpretability was critical for our client’s trust and regulatory compliance. We tackled this by integrating SHAP (SHapley Additive exPlanations) to provide clear, understandable insights into how our model's decisions were made, ensuring transparency and boosting user confidence in the AI system.",Large Language Models,18/10/2022,Bank E,Under Review
31
+ "Generative AI Solutions for Fraud Detection and Financial Security
32
+ ",14,Describe your strategy for integrating LLMs into existing organizational frameworks and systems.,"Our approach involves conducting a thorough analysis of the existing systems and workflows, designing integration plans that minimize disruption, and using APIs and custom connectors to ensure seamless integration of our LLM-based applications. We start by meticulously mapping the client's current infrastructure and operational flows to identify the most efficient points of integration. This is followed by the development of tailored integration plans that prioritize operational continuity and minimize downtime. To achieve seamless integration, we utilize robust APIs and develop custom connectors where necessary, ensuring compatibility with existing software platforms and databases. These tools allow for the smooth transfer of data and maintain the integrity and security of the system, ensuring that the new AI capabilities enhance functionality without compromising existing processes.",Large Language Models,18/10/2022,Bank E,Under Review
33
+ "Generative AI Solutions for Fraud Detection and Financial Security
34
+ ",15,"What is your approach to maintaining and supporting LLM-based applications post-deployment, especially in terms of updates and addressing model drift?","Our post-deployment support is designed to ensure sustained performance and relevance of our LLM-based applications. We actively monitor for model drift to detect and address any degradation in model accuracy over time due to changes in underlying data patterns. This includes implementing automated systems that alert our team to potential drifts, allowing for timely interventions. Regular model updates and improvements are also part of our support protocol, ensuring that our solutions adapt to new data and evolving industry standards. Additionally, our dedicated technical support team is available to swiftly address any operational issues or adapt to changes in client requirements. This comprehensive support structure guarantees that our applications continue to deliver optimal performance and align with our clients' strategic objectives.",Large Language Models,18/10/2022,Bank E,Under Review
35
+ "Generative AI Solutions for Fraud Detection and Financial Security
36
+ ",16,How does your AI strategy align with the NIST AI RMF for trustworthy and responsible use of AI?,"Our AI solution is meticulously designed to align with the NIST AI Risk Management Framework (RMF) guidelines, ensuring adherence to principles of trustworthiness and responsibility. We have implemented comprehensive governance structures that oversee the ethical development and deployment of our AI technologies. This includes risk identification and assessment processes where potential risks are analyzed and categorized at each stage of the AI lifecycle. To manage these risks, we have instituted robust risk management controls that are deeply integrated into our development and operational processes. These controls are based on the NIST framework’s best practices, ensuring that our AI solutions are not only effective but also secure and ethical, maintaining transparency and accountability at all times.",AI Regulation,18/10/2022,Bank E,Under Review
37
+ "Generative AI Solutions for Fraud Detection and Financial Security
38
+ ",17,Can you discuss your governance framework for managing AI risks in accordance with the NIST AI RMF?,"We have established an AI Risk Council that plays a pivotal role in overseeing AI risk management across our organization. This council is tasked with defining clear roles and responsibilities for AI governance, ensuring that there is a structured approach to managing AI risks. It also integrates AI risk management into our existing governance frameworks to enhance coherence and alignment with broader corporate policies and objectives. Additionally, the AI Risk Council promotes robust collaboration between various business units and our IT department. This collaboration is crucial for sharing insights, aligning strategies, and implementing comprehensive risk management practices effectively across the entire organization. This framework not only supports proactive risk management but also fosters an environment where AI technologies are used responsibly and ethically.",AI Regulation,18/10/2022,Bank E,Under Review
39
+ "Generative AI Solutions for Fraud Detection and Financial Security
40
+ ",18,How do you perform risk assessment and identification according to the NIST AI RMF's 'Map' function?,"We conduct thorough assessments of AI systems and the people using AI within our organization. This process involves meticulously identifying potential risks such as data privacy, security, bias, and legal compliance. We assess both the impact and the likelihood of each identified risk to effectively prioritize them. Our approach includes the use of sophisticated tools and methodologies, such as risk matrices and scenario analysis, to quantify and categorize risks accurately. This comprehensive assessment enables us to develop targeted risk mitigation strategies and allocate resources more efficiently, ensuring that the most critical risks are addressed promptly and effectively. This proactive risk management practice helps us maintain the integrity of our AI systems and uphold our ethical and legal responsibilities.",AI Regulation,18/10/2022,Bank E,Under Review
41
+ "Generative AI Solutions for Fraud Detection and Financial Security
42
+ ",19,What steps do you take to ensure the transparency and explainability of your AI systems' decisions?,"We prioritize transparency by incorporating explainability features into our AI models, providing detailed documentation on the decision-making processes, and ensuring that stakeholders can understand and trust the outputs of our AI systems. To achieve this, we integrate explainability tools like feature importance scores and decision trees that clearly outline how and why decisions are made by our AI. We supplement these technical tools with comprehensive documentation that describes the algorithms' functions in accessible language. This approach is designed to demystify the AI's operations for non-technical stakeholders, fostering a higher level of trust and acceptance. By ensuring that our AI systems are transparent and their workings understandable, we maintain open communication and build confidence among users and regulators alike.",AI Regulation,18/10/2022,Bank E,Under Review
43
+ "Generative AI Solutions for Fraud Detection and Financial Security
44
+ ",20,How do you monitor and assess AI risk exposure using metrics suggested by the NIST AI RMF's 'Measure' function?,"We have developed a set of Key Performance Indicators (KPIs) and metrics specifically designed to assess and analyze AI risk exposure across our systems. These metrics are tracked continuously to provide a clear, quantifiable measure of risk at any given time. To streamline this process, we utilize AI risk assessment tools that automate both data collection and analysis, enhancing the accuracy and efficiency of our monitoring efforts.
45
+ These tools employ advanced analytics to detect subtle shifts in risk patterns, enabling proactive risk management. Regular updates to our risk assessment protocols ensure that they remain aligned with current threat landscapes and regulatory requirements. This systematic monitoring and analysis not only help us maintain control over AI risks but also ensure that we can respond swiftly and effectively to any changes in risk levels, keeping our AI systems secure and compliant.",AI Regulation,18/10/2022,Bank E,Under Review
46
+ "Generative AI Solutions for Fraud Detection and Financial Security
47
+ ",21,How do you handle the management and mitigation of AI risks in line with the NIST AI RMF's 'Manage' function?,"We implement and maintain robust risk management controls to mitigate identified risks effectively. This comprehensive approach includes regular updates to our AI models to address evolving challenges and improve performance. We also implement stringent security measures, such as encryption, access controls, and continuous monitoring systems, to safeguard our data and systems from unauthorized access and potential breaches.
48
+ Furthermore, ensuring compliance with data protection laws is a critical part of our risk management strategy. We stay abreast of legal requirements in all operational jurisdictions, such as GDPR in Europe and CCPA in California, and integrate compliance measures into our AI deployments. Regular audits, both internal and by third-party assessors, help ensure that our practices are up-to-date and that we maintain the highest standards of data privacy and security. This holistic approach to risk management enables us to maintain trust and reliability in our AI applications.",AI Regulation,18/10/2022,Bank E,Under Review
49
+ "Generative AI Solutions for Fraud Detection and Financial Security
50
+ ",22,How do you ensure your AI solutions adhere to U.S. regulations on data privacy and security?,"We ensure compliance with U.S. regulations such as the Federal Information Security Modernization Act (FISMA) and other applicable laws and directives by adopting a risk-based approach to control selection and specification. This approach meticulously considers the constraints and requirements imposed by these regulations. We conduct regular audits and assessments to verify that our security controls meet or exceed the stipulated standards, ensuring that all our data handling and processing activities are fully compliant.
51
+ Our compliance framework is designed to adapt to the specific needs of the environments in which our systems operate, integrating best practices and guidance from regulatory bodies. We also engage with legal and compliance experts to stay updated on any changes in legislation, ensuring our practices remain in line with the latest requirements. This proactive and informed approach allows us to manage risk effectively while maintaining the highest levels of data protection and security as mandated by U.S. law.",AI Regulation,18/10/2022,Bank E,Under Review
52
+ "Generative AI Solutions for Fraud Detection and Financial Security
53
+ ",23,How do you contribute to the ongoing development of AI risk management practices following the NIST AI RMF?,"We actively participate in industry working groups and public-private partnerships to contribute to the continual improvement of AI risk management practices. Our engagement in these collaborative efforts not only allows us to share our insights and strategies but also enables us to learn from the collective experiences of the industry, helping to elevate the standards of AI safety and reliability across the board. Additionally, we stay abreast of updates to the NIST AI Risk Management Framework (RMF) and adjust our practices accordingly. This commitment to staying current ensures that our risk management approaches align with the latest guidelines and best practices, reinforcing our dedication to leading-edge, responsible AI development and deployment.",AI Regulation,18/10/2022,Bank E,Under Review
@@ -0,0 +1,41 @@
1
+ # Copyright © 2023-2024 ValidMind Inc. All rights reserved.
2
+ # See the LICENSE file in the root of this repository for details.
3
+ # SPDX-License-Identifier: AGPL-3.0 AND ValidMind Commercial
4
+
5
+ import os
6
+ from csv import DictReader
7
+ from uuid import uuid4
8
+
9
+ import pandas as pd
10
+ from sklearn.model_selection import train_test_split
11
+
12
+ current_path = os.path.dirname(os.path.abspath(__file__))
13
+ dataset_path = os.path.join(current_path, "datasets")
14
+ drop_columns = ["RFP_Question_ID", "Last_Accessed_At"]
15
+ target_column = "RFP_Answer"
16
+ categorical_columns = []
17
+
18
+
19
+ def load_data(full_dataset=False):
20
+ documents = []
21
+ for file in os.listdir(dataset_path):
22
+ if file.endswith(".csv"):
23
+ # use csv dict reader to load the csv file
24
+ with open(os.path.join(dataset_path, file)) as f:
25
+ reader = DictReader(f)
26
+ for row in reader:
27
+ # add a unique id to the row
28
+ row["id"] = str(uuid4())
29
+ documents.append(row)
30
+
31
+ df = pd.DataFrame(documents)
32
+ df.drop(drop_columns, axis=1, inplace=True)
33
+
34
+ return df
35
+
36
+
37
+ def preprocess(df):
38
+ df = df.copy()
39
+ train_df, test_df = train_test_split(df, test_size=0.20)
40
+
41
+ return train_df, test_df
File without changes
@@ -16,16 +16,50 @@ test_content_block_html = """
16
16
  <h2>{title}</h2>
17
17
  {description}
18
18
  </div>
19
- <h5 class="vm_required_context">
20
- Required Inputs: <span style="font-size: 13px"><i>{required_inputs}</i></span>
21
- </h5>
22
- <table class="vm_params_table" style="display: {table_display};">
23
- <tr>
24
- <th>Parameter</th>
25
- <th>Default Value</th>
26
- </tr>
27
- {params_table}
28
- </table>
19
+
20
+ <div class="unset">
21
+ <h3>How to Run:</h3>
22
+
23
+ <button
24
+ onclick="(() => {{e = document.getElementById('expandable_instructions_{uuid}'); e.style.display === 'none' ? e.style.display = 'block' : e.style.display = 'none'}})()"
25
+ >Show/Hide Instructions</button>
26
+
27
+ <div id="expandable_instructions_{uuid}" style="display: {instructions_display};">
28
+ <h4>Code:</h4>
29
+ <pre>
30
+ <code class='language-python'>import validmind as vm
31
+
32
+ # inputs dictionary maps your inputs to the expected input names
33
+ # keys are the expected input names and values are the actual inputs
34
+ # values may be string input_ids or the actual VMDataset or VMModel objects
35
+ inputs = {example_inputs}
36
+ params = {example_params}
37
+
38
+ # to run and view the result of this test, run the following code:
39
+ result = vm.tests.run_test(
40
+ "{test_id}", inputs=inputs, params=params
41
+ )
42
+
43
+ # To see the result of the test, ensure that you have called `vm.init()` and then run:
44
+ result.log()</code>
45
+ </pre>
46
+
47
+ <h4 class="vm_required_context">
48
+ Required Inputs: <span style="font-size: 13px"><i>{required_inputs}</i></span>
49
+ </h4>
50
+
51
+ <div style="display: {table_display};">
52
+ <h4>Parameters:</h4>
53
+ <table class="vm_params_table" style="display: {table_display};">
54
+ <tr>
55
+ <th>Parameter</th>
56
+ <th>Default Value</th>
57
+ </tr>
58
+ {params_table}
59
+ </table>
60
+ </div>
61
+ </div>
62
+ </div>
29
63
 
30
64
  <style>
31
65
  h5.vm_required_context {{
@@ -33,8 +67,9 @@ h5.vm_required_context {{
33
67
  }}
34
68
  table.vm_params_table {{
35
69
  margin-top: 20px;
36
- width: 300px;
70
+ width: 350px;
37
71
  border-collapse: collapse;
72
+ border-color: --jp-border-color0;
38
73
  }}
39
74
  table.vm_params_table td, table.vm_params_table th {{
40
75
  text-align: right;
@@ -42,19 +77,59 @@ table.vm_params_table td, table.vm_params_table th {{
42
77
  table.vm_params_table td:first-child, table.vm_params_table th:first-child {{
43
78
  text-align: left;
44
79
  }}
80
+ table.vm_params_table th {{
81
+ background-color: --jp-content-color0;
82
+ font-weight: bold;
83
+ font-size: 14px !important;
84
+ }}
85
+ table.vm_params_table tr:nth-child(even) {{
86
+ background-color: --jp-layout-color1;
87
+ }}
45
88
  table.vm_params_table tr:nth-child(odd) {{
46
- background-color: #f2f2f2;
89
+ background-color: --jp-layout-color2;
47
90
  }}
48
91
  table.vm_params_table tr:hover {{
49
- background-color: #ddd;
92
+ background-color: --jp-layout-color3;
50
93
  }}
51
94
  table.vm_params_table td, table.vm_params_table th {{
52
95
  padding: 5px;
53
- border: .8px solid #ddd;
96
+ border: .8px solid --jp-border-color0;
54
97
  }}
55
98
  </style>
56
99
  """
57
100
 
101
+ python_syntax_highlighting = """
102
+ <script defer type="module">
103
+ import hljs from 'https://unpkg.com/@highlightjs/cdn-assets@11.9.0/es/highlight.min.js';
104
+ import python from 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/es/languages/python.min.js';
105
+
106
+ hljs.registerLanguage('python', python);
107
+ hljs.highlightAll();
108
+ </script>
109
+ """
110
+
111
+ # FIXME: this is a bit too hacky
112
+ math_jax_snippet = """
113
+ <script>
114
+ window.MathJax = {
115
+ tex2jax: {
116
+ inlineMath: [['$', '$'], ['\\\\(', '\\\\)']],
117
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
118
+ processEscapes: true,
119
+ skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
120
+ ignoreClass: ".*",
121
+ processClass: "math"
122
+ }
123
+ };
124
+ setTimeout(function () {
125
+ var script = document.createElement('script');
126
+ script.type = 'text/javascript';
127
+ script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_HTML';
128
+ document.head.appendChild(script);
129
+ }, 300);
130
+ </script>
131
+ """
132
+
58
133
  failed_content_block_html = """
59
134
  <div
60
135
  class="lm-Widget p-Widget jupyter-widget-Collapse-header"
@@ -2,19 +2,22 @@
2
2
  # See the LICENSE file in the root of this repository for details.
3
3
  # SPDX-License-Identifier: AGPL-3.0 AND ValidMind Commercial
4
4
 
5
- from .catboost import CatBoostModel
6
5
  from .foundation import FoundationModel, Prompt
6
+ from .function import FunctionModel
7
7
  from .huggingface import HFModel
8
+ from .metadata import MetadataModel
9
+ from .pipeline import PipelineModel
8
10
  from .pytorch import PyTorchModel
9
- from .sklearn import SKlearnModel
10
- from .statsmodels import StatsModelsModel
11
- from .xgboost import XGBoostModel
11
+ from .sklearn import CatBoostModel, SKlearnModel, StatsModelsModel, XGBoostModel
12
12
 
13
13
  __all__ = [
14
14
  "CatBoostModel",
15
15
  "FoundationModel",
16
+ "FunctionModel",
16
17
  "HFModel",
18
+ "MetadataModel",
17
19
  "Prompt",
20
+ "PipelineModel",
18
21
  "PyTorchModel",
19
22
  "SKlearnModel",
20
23
  "StatsModelsModel",
@@ -7,7 +7,7 @@ from dataclasses import dataclass
7
7
  import pandas as pd
8
8
 
9
9
  from validmind.logging import get_logger
10
- from validmind.vm_models.model import ModelAttributes, VMModel
10
+ from validmind.models.function import FunctionModel
11
11
 
12
12
  logger = get_logger(__name__)
13
13
 
@@ -18,7 +18,7 @@ class Prompt:
18
18
  variables: list
19
19
 
20
20
 
21
- class FoundationModel(VMModel):
21
+ class FoundationModel(FunctionModel):
22
22
  """FoundationModel class wraps a Foundation LLM endpoint
23
23
 
24
24
  This class wraps a predict function that is user-defined and adapts it to works
@@ -29,22 +29,14 @@ class FoundationModel(VMModel):
29
29
  and return the result from the model
30
30
  prompt (Prompt): The prompt object that defines the prompt template and the
31
31
  variables (if any)
32
- attributes (ModelAttributes, optional): The attributes of the model. Defaults to None.
32
+ name (str, optional): The name of the model. Defaults to name of the predict_fn
33
33
  """
34
34
 
35
- def __init__(
36
- self,
37
- predict_fn: callable,
38
- prompt: Prompt, # prompt used for model (for now just a string)
39
- attributes: ModelAttributes = None,
40
- input_id: str = None,
41
- ):
42
- super().__init__(
43
- attributes=attributes,
44
- input_id=input_id,
45
- )
46
- self.predict_fn = predict_fn
47
- self.prompt = prompt
35
+ def __post_init__(self):
36
+ if not getattr(self, "predict_fn") or not callable(self.predict_fn):
37
+ raise ValueError("FoundationModel requires a callable predict_fn")
38
+
39
+ self.name = self.name or self.predict_fn.__name__
48
40
 
49
41
  def _build_prompt(self, x: pd.DataFrame):
50
42
  """
@@ -59,21 +51,3 @@ class FoundationModel(VMModel):
59
51
  Predict method for the model. This is a wrapper around the model's
60
52
  """
61
53
  return [self.predict_fn(self._build_prompt(x[1])) for x in X.iterrows()]
62
-
63
- def model_library(self):
64
- """
65
- Returns the model library name
66
- """
67
- return "FoundationModel"
68
-
69
- def model_class(self):
70
- """
71
- Returns the model class name
72
- """
73
- return "FoundationModel"
74
-
75
- def model_name(self):
76
- """
77
- Returns model name
78
- """
79
- return "FoundationModel"
@@ -0,0 +1,51 @@
1
+ # Copyright © 2023-2024 ValidMind Inc. All rights reserved.
2
+ # See the LICENSE file in the root of this repository for details.
3
+ # SPDX-License-Identifier: AGPL-3.0 AND ValidMind Commercial
4
+
5
+ from validmind.vm_models.model import VMModel
6
+
7
+
8
+ # semi-immutable dict
9
+ class Input(dict):
10
+ def __init__(self, *args, **kwargs):
11
+ super().__init__(*args, **kwargs)
12
+ self._new = set()
13
+
14
+ def __setitem__(self, key, value):
15
+ self._new.add(key)
16
+ super().__setitem__(key, value)
17
+
18
+ def __delitem__(self, _):
19
+ raise TypeError("Cannot delete keys from Input")
20
+
21
+ def get_new(self):
22
+ return {k: self[k] for k in self._new}
23
+
24
+
25
+ class FunctionModel(VMModel):
26
+ """
27
+ FunctionModel class wraps a user-defined predict function
28
+
29
+ Attributes:
30
+ predict_fn (callable): The predict function that should take a dictionary of
31
+ input features and return a prediction.
32
+ input_id (str, optional): The input ID for the model. Defaults to None.
33
+ name (str, optional): The name of the model. Defaults to the name of the predict_fn.
34
+ """
35
+
36
+ def __post_init__(self):
37
+ if not getattr(self, "predict_fn") or not callable(self.predict_fn):
38
+ raise ValueError("FunctionModel requires a callable predict_fn")
39
+
40
+ self.name = self.name or self.predict_fn.__name__
41
+
42
+ def predict(self, X):
43
+ """Compute predictions for the input (X)
44
+
45
+ Args:
46
+ X (pandas.DataFrame): The input features to predict on
47
+
48
+ Returns:
49
+ list: The predictions
50
+ """
51
+ return [self.predict_fn(x) for x in X.to_dict(orient="records")]
@@ -4,41 +4,32 @@
4
4
 
5
5
  from dataclasses import dataclass
6
6
 
7
- import pandas as pd
8
-
9
7
  from validmind.errors import MissingOrInvalidModelPredictFnError
10
8
  from validmind.logging import get_logger
11
- from validmind.vm_models.model import (
12
- ModelAttributes,
13
- VMModel,
14
- has_method_with_arguments,
15
- )
9
+ from validmind.vm_models.model import VMModel, has_method_with_arguments
16
10
 
17
11
  logger = get_logger(__name__)
18
12
 
19
13
 
20
14
  @dataclass
21
15
  class HFModel(VMModel):
22
- """
23
- An Hugging Face model class that wraps a trained model instance and its associated data.
24
-
25
- Attributes:
26
- attributes (ModelAttributes, optional): The attributes of the model. Defaults to None.
27
- model (object, optional): The trained model instance. Defaults to None.
28
- """
29
-
30
16
  def __init__(
31
17
  self,
32
18
  input_id: str = None,
33
- model: object = None, # Trained model instance
34
- attributes: ModelAttributes = None,
19
+ model: object = None,
20
+ attributes: object = None,
21
+ name: str = None,
22
+ **kwargs,
35
23
  ):
36
24
  super().__init__(
37
- model=model,
38
- input_id=input_id,
39
- attributes=attributes,
25
+ input_id=input_id, model=model, attributes=attributes, name=name, **kwargs
40
26
  )
41
27
 
28
+ def __post_init__(self):
29
+ self.library = self.model.__class__.__module__.split(".")[0]
30
+ self.class_ = self.model.__class__.__name__
31
+ self.name = self.name or type(self.model).__name__
32
+
42
33
  def predict_proba(self, *args, **kwargs):
43
34
  """
44
35
  Invoke predict_proba from underline model
@@ -57,36 +48,15 @@ class HFModel(VMModel):
57
48
  Predict method for the model. This is a wrapper around the HF model's pipeline function
58
49
  """
59
50
  results = self.model([str(datapoint) for datapoint in data])
60
-
61
51
  tasks = self.model.__class__.__module__.split(".")
62
52
 
63
53
  if "text2text_generation" in tasks:
64
- return pd.DataFrame(results).summary_text.values
54
+ return [result["summary_text"] for result in results]
65
55
  elif "text_classification" in tasks:
66
- return pd.DataFrame(results).label.values
56
+ return [result["label"] for result in results]
67
57
  elif tasks[-1] == "feature_extraction":
68
- # extract [CLS] token embedding for each input and wrap in dataframe
69
- return pd.DataFrame([embedding[0][0] for embedding in results])
58
+ # Extract [CLS] token embedding for each input and return as list of lists
59
+ print(f"len(results): {len(results)}")
60
+ return [embedding[0][0] for embedding in results]
70
61
  else:
71
62
  return results
72
-
73
- def model_library(self):
74
- """
75
- Returns the model library name
76
- """
77
- return self.model.__class__.__module__.split(".")[0]
78
-
79
- def model_class(self):
80
- """
81
- Returns the model class name
82
- """
83
- return self.model.__class__.__name__
84
-
85
- def model_name(self):
86
- """
87
- Returns model name
88
- """
89
- return type(self.model).__name__
90
-
91
- def is_pytorch_model(self):
92
- return self.model_library() == "torch"
@@ -0,0 +1,42 @@
1
+ # Copyright © 2023-2024 ValidMind Inc. All rights reserved.
2
+ # See the LICENSE file in the root of this repository for details.
3
+ # SPDX-License-Identifier: AGPL-3.0 AND ValidMind Commercial
4
+
5
+ from validmind.errors import MissingOrInvalidModelPredictFnError
6
+ from validmind.vm_models.model import VMModel
7
+
8
+
9
+ class MetadataModel(VMModel):
10
+ """
11
+ MetadataModel is designed to represent a model that is not available for inference
12
+ for various reasons but for which metadata and pre-computed predictions are available.
13
+
14
+ Model attributes are required since this will be the only information we can
15
+ collect and log about the model.
16
+
17
+ This class should not be instantiated directly. Instead call `vm.init_model()` and
18
+ pass in a dictionary with the required metadata as `attributes`.
19
+
20
+ Attributes:
21
+ attributes (ModelAttributes): The attributes of the model. Required.
22
+ input_id (str, optional): The input ID for the model. Defaults to None.
23
+ name (str, optional): The name of the model. Defaults to the class name.
24
+ """
25
+
26
+ def __post_init__(self):
27
+ if not getattr(self, "attributes"):
28
+ raise ValueError("MetadataModel requires attributes")
29
+
30
+ self.name = self.name or "Metadata Model"
31
+
32
+ def predict(self, *args, **kwargs):
33
+ """Not implemented for MetadataModel"""
34
+ raise MissingOrInvalidModelPredictFnError(
35
+ "MetadataModel does not support inference"
36
+ )
37
+
38
+ def predict_proba(self, *args, **kwargs):
39
+ """Not implemented for MetadataModel"""
40
+ raise MissingOrInvalidModelPredictFnError(
41
+ "MetadataModel does not support inference"
42
+ )
@@ -0,0 +1,66 @@
1
+ # Copyright © 2023-2024 ValidMind Inc. All rights reserved.
2
+ # See the LICENSE file in the root of this repository for details.
3
+ # SPDX-License-Identifier: AGPL-3.0 AND ValidMind Commercial
4
+
5
+ from validmind.logging import get_logger
6
+ from validmind.vm_models.model import ModelAttributes, ModelPipeline, VMModel
7
+
8
+ logger = get_logger(__name__)
9
+
10
+
11
+ class PipelineModel(VMModel):
12
+ """
13
+ An base class that wraps a trained model instance and its associated data.
14
+
15
+ Attributes:
16
+ pipeline (ModelPipeline): A pipeline of models to be executed. ModelPipeline
17
+ is just a simple container class with a list that can be chained with the
18
+ `|` operator.
19
+ input_id (str, optional): The input ID for the model. Defaults to None.
20
+ attributes (ModelAttributes, optional): The attributes of the model. Defaults to None.
21
+ name (str, optional): The name of the model. Defaults to the class name.
22
+ """
23
+
24
+ predict_col: str = None
25
+
26
+ def __init__(
27
+ self,
28
+ pipeline: ModelPipeline,
29
+ attributes: ModelAttributes = None,
30
+ input_id: str = None,
31
+ name: str = None,
32
+ ):
33
+ self.pipeline = pipeline
34
+ self.input_id = input_id
35
+
36
+ self.language = "Python"
37
+ self.library = self.__class__.__name__
38
+ self.library_version = "N/A"
39
+ self.class_ = self.__class__.__name__
40
+
41
+ self.name = name or self.__class__.__name__
42
+
43
+ self.attributes = attributes
44
+
45
+ def __or__(self, other):
46
+ if not isinstance(other, VMModel):
47
+ raise ValueError("Can only chain VMModel objects")
48
+
49
+ return ModelPipeline([self, other])
50
+
51
+ def serialize(self):
52
+ """
53
+ Serializes the model to a dictionary so it can be sent to the API
54
+ """
55
+ return {
56
+ "attributes": self.attributes.__dict__,
57
+ }
58
+
59
+ def predict(self, X):
60
+ X = X.copy()
61
+
62
+ for model in self.pipeline.models:
63
+ predictions = model.predict(X)
64
+ X[model.input_id] = predictions
65
+
66
+ return predictions