zhiminy/EvalEng huggingface dataset:
Repository: Giskard-AI/giskard-oss
Issue: How does it help with Model Interpretability and Explainability for Black-box model architecture
GitHub labels: question

## Checklist

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [ ] I've searched the project's [`issues`](https://github.com/Giskard-AI/giskard/issues?q

## ❓ Question

<!-- What is your question -->

Is Giskard model-agnostic and what is the performance on black-box models?

How does  Giskard assist in model interpretability concerning fairness, security and privacy considerations?

Is it possible to [...]?

## 📎 Additional context

<!-- Add any other context or screenshots about in the feature request here. -->


I was unable to fully explore Giskard due to computational resource constraint. However, Giskard provides tools for evaluating models before serving in production. The experimental nature of Giskard would need further exploration for the inclusion of advanced model debugging features that pertain to network and infrastructure resource usage and adversarial activities in a production environment. 

Hey @mrbestnaija here are our docs: https://docs.giskard.ai/en/stable/

Debugging is something that's available in our enterprise product only. Hope that answers the question!
Repository: Giskard-AI/giskard-oss
Issue: Is there a Direct API to test out questions for LLM RAG without using giskard Hub
Root cause: Documentation Deficiency

## Checklist

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [x] I've searched the project's [`issues`](https://github.com/Giskard-AI/giskard/issues?q=is%3Aissue).

## ❓ Question


Hi, I noticed that in order to add domain specific tests, [currently](https://docs.giskard.ai/en/latest/giskard_hub/write_and_debug_tests/index.html) we make heavy use of giskard hub.
Is it possible to do it without the hub?

Currently in order to add new questions, I'm having to create a dataframe out of them with code, upload this to giskard hub, go to testing->test-suite -> Add test Suite -> Choose the new dataset uploaded ->  click add to test-suite
Then I'd need to fetch this test suite from giskard hub dynamiclly in code based on id and run them.
Personally this seems a bit too long winded to me. Can we simplify by optionally removing the giskard hub part ?

eg: maybe if I can read some questions from a yaml file maybe with some optional configuration parameter (similar to how [promptfoo](https://www.promptfoo.dev/docs/configuration/expected-outputs/#setting-a-score-requirement) does) and have my LLM chain be evaluated using giskard on these questions?

My exact use case is that I'd prefer the test cases to be bundled together with my application codebase -Similar to how it is in a traditional software engineering project.
In fact, it'd be really great if we could also export and store the questions generated by giskard during the scan in a yaml file as well!

Then I could just add more questions based on my custom domain specific usecases in other yaml files itself and have them be tested from CLI using giskard/pytest; without having to be dependent on having the hub be running all the time.

Please do let me know if something like this is possible.

Thank You

<!-- What is your question -->




<!-- Add any other context or screenshots about the feature request here. -->


Hey @aldrinjenson we've got [plenty of options](https://docs.giskard.ai/en/stable/open_source/integrate_tests/index.html) to execute your tests in code instead of on the visual interface. The main purpose of the Hub is to: 
- Collaborate with several people from different backgrounds on your test suites
- Get smart assistance for adding additional tests that you may have missed
- Visualize executions and compare them in a more visually-friendly way
- Access debugging-related features

Thank You. 

I was able to integrate my code with pytest. 
Now I can read questions from yaml or JSON and use giskard to evaluate them based on [these metrics](https://docs.giskard.ai/en/latest/reference/tests/llm.html#llm-as-a-judge)
Works great for my use case.

Thanks again!

Great, happy to hear that!
Repository: Giskard-AI/giskard-oss
Issue: Add Data Leakage Assessment
Root cause: Unimplemented Feature Gap

## 🚀 Feature Request

Measure data leakage based on a subset of samples/conversations from the training/fine-tuning dataset

## 🔈 Motivation

To efficiently apply generative models to specific domain/application (legal field is a good example) companies turn to fine-tuning / alignment on proprietary/confidential dataset. Once the fine-tuning is done and given the nature of the models, there is a significant risk of training data leakage on inference. This leakage is due to two capacities in LLMs; Memorization and Association.

## 🛰 Alternatives

- Adhoc implementations 🐰 


Hi @dt-ahmed-touila, thanks for sharing this request! Since we're blackbox application-focused we don't currently develop tooling for training/fine-tuning related evaluation. We'll re-open this if we get to that domain one day.
Repository: Giskard-AI/giskard-oss
Issue: Is there a way to test the LLM-based models for stereotypes and discrimination using a saved dataset
Root cause: Documentation Deficiency

Can I generate prompts before the test, save them to a file, and reuse them instead of using OpenAI for prompt generation?

Hi @rudziankou, you would be able to do that by using one of the tests from the catalog directly: https://docs.giskard.ai/en/stable/knowledge/catalogs/test-catalog/text_generation/index.html

Depends what your saved dataset looks like, but you could pick a requirement or ground truth test. Otherwise, if you are asking the question because you don't want to use OpenAI but another model for generating prompts, our latest release allows to do that. I can share the docs with you as soon as they're ready.

Does that answer your question?

Hi @luca-martial, thanks for getting back to me. Below are the use cases I'm considering. Could you please give me some examples of how to implement them if it's even possible?

**Use case:**
I have an LLM model that operates sensitive customer and company data. I want to use the Giskard Detectors for LLM models to test my model.

**Scenarios:**
1. Use another model for generating prompts and use another model for evaluating responses. (DO NOT USE OpenAI for prompts and evaluation).
2. Use a list of saved prompts and use another model for evaluating responses. (DO NOT USE OpenAI for prompts and evaluation. The list of prompts is saved locally in a file and can be updated later).
3. Use another model for generating prompts and use OpenAI for evaluating responses. (USE OpenAI for evaluation only).
4. Use a list of saved prompts and use OpenAI for evaluating responses. (USE OpenAI for evaluation only. The list of prompts is saved locally in a file and can be updated later).
5. Use OpenAI for generating prompts and use another model for evaluating responses. (USE OpenAI for prompts only).

Hello @rudziankou 

Actually our scan only generate a dataset is None is provided. This means that you can generate a dataset using any LLM and then use it in the scan using another LLM of your choice:

```python
import giskard
from giskard.llm.client import set_default_client
from giskard.llm.utils import generate_test_dataset

giskard_model = ... # Wrap your model here

set_default_client(...)
giskard_dataset = generate_test_dataset(giskard_model)

set_default_client(...)
scan_result = giskard.scan(giskard_model, giskard_dataset)
```

You can load and save a list of saved prompt since they are wrapped into [`giskard.Dataset`](https://docs.giskard.ai/en/latest/reference/datasets/index.html)

Hope this answer all your questions, a final note is that the scan allow you to generate a test suite using `scan_result.generate_test_suite()`, this test suite can be re-runned and will be faster than doing a full scan. Furthermore it is customizable.
Repository: Giskard-AI/giskard-oss
Issue: giskard.scan is failing for azure openai & langchain
Root cause: Interface Contract Mismatch

### Issue Type

Bug

### Source

source

### Giskard Library Version

2.10.0

### Giskard Hub Version

N/A

### OS Platform and Distribution

_No response_

### Python version

3.11

### Installed python packages

_No response_

### Current Behaviour?

```shell
I am running the sample code from here (https://docs.giskard.ai/en/latest/open_source/scan/scan_llm/index.html) and using an Azure OpenAI with langchain but the scan fails with the error below.

cc:  @GianRomani @AndreeaIugaTR
```


### Standalone code OR list down the steps to reproduce the issue

```shell
Use the link below to access the jupyter notebook:
https://goonlinetools.com/snapshot/code/#m3ar9v8ihyqpr9qg3i2eos
```


### Relevant log output

```shell
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[9], line 1
----> 1 report = gsk.scan(giskard_model, demo_dataset, only="jailbreak", raise_exceptions=True)

File [/opt/homebrew/lib/python3.11/site-packages/giskard/scanner/__init__.py:64](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/lib/python3.11/site-packages/giskard/scanner/__init__.py:64), in scan(model, dataset, features, params, only, verbose, raise_exceptions)
     35 """Automatically detects model vulnerabilities.
     36 
     37 See :class:`Scanner` for more details.
   (...)
     61     A scan report object containing the results of the scan.
     62 """
     63 scanner = Scanner(params, only=only)
---> 64 return scanner.analyze(
     65     model, dataset=dataset, features=features, verbose=verbose, raise_exceptions=raise_exceptions
     66 )

File [/opt/homebrew/lib/python3.11/site-packages/giskard/scanner/scanner.py:123](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/lib/python3.11/site-packages/giskard/scanner/scanner.py:123), in Scanner.analyze(self, model, dataset, features, verbose, raise_exceptions)
    121 with warnings.catch_warnings():
    122     warnings.simplefilter("ignore")
--> 123     issues, errors = self._run_detectors(
    124         detectors, model, dataset, features, verbose=verbose, raise_exceptions=raise_exceptions
    125     )
    127 issues = self._postprocess(issues)
    129 # Scan completed
...
     35 if not self.config.punctuation_sensitive:
---> 36     text = text.translate(str.maketrans("", "", string.punctuation))
     37 return text

AttributeError: 'AIMessage' object has no attribute 'translate'

-------------------------------------
```


Hey @kevinmessiaen - Do you have any news on this issue?

It seems that the model prediction method passed in the scan return a object of type `AIMessage` from langchain instead of a `str`.

Please make sure to map `AIMessage` to `str` in the prediction_function
Repository: Giskard-AI/giskard-oss
Issue: Raget: Possible miscalculation of all  Ragas metrics, in particular Precision and Recall
Root cause: Algorithmic Error

### Issue Type

Bug

### Source

source

### Giskard Library Version

2.11

### Giskard Hub Version

-

### OS Platform and Distribution

_No response_

### Python version

_No response_

### Installed python packages

_No response_

### Current Behaviour?

```shell
Giskard RAGet uses the reference context when calling Ragas. 

https://github.com/Giskard-AI/giskard/blob/main/giskard/rag/metrics/ragas_metrics.py

        ragas_sample = {
            "question": question_sample["question"],
            "answer": answer,
            "contexts": question_sample["reference_context"].split("\n\n"),
            "ground_truth": question_sample["reference_answer"],
        }

According to Ragas documentation the retrieved context should be used (the one used for the answer Generation).

As an example, when computing Precision or Recall which both uses {"question", "contexts", "ground_truth"}, if you are giving the reference context, then you are evaluating your test set generation pipeline  and not your RAG pipeline.
```


### Standalone code OR list down the steps to reproduce the issue

```shell
.
```


### Relevant log output

_No response_

@pierlj what do you think?

Hi @Chabert-Liddell, you are right, thanks for pointing this out. A fix will be release soon!
Repository: Giskard-AI/giskard-oss
Issue: huggingface models as client?
Root cause: Documentation Deficiency

## Checklist

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [x] I've searched the project's [`issues`](https://github.com/Giskard-AI/giskard/issues?q=is%3Aissue).

## ❓ Question

Is there any good example of how to use huggingface models and eventually perform giskard scan
How can I [...]?


## 📎 Additional context

<!-- Add any other context or screenshots about the feature request here. -->


https://github.com/Giskard-AI/giskard/blob/main/giskard/models/huggingface.py
check this out
Repository: Giskard-AI/giskard-oss
Issue: Contributing to examples/tutorials
GitHub labels: question

## Checklist

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [x] I've searched the project's [`issues`](https://github.com/Giskard-AI/giskard/issues?q=is%3Aissue).

## ❓ Question

<!-- What is your question -->

I am interested in making tutorials or examples on how to use Giskard, maybe technical articles as well. I have knowledge of using giskard, how do I start making these contributions? Should i create these tutorials on my blog first?




Hey @cyberholics, thanks for your interest in helping us.

If you prefer, You can create a Jupyter Notebook tutorial. 
For example, all notebooks displayed on giskard docs are available here: https://github.com/Giskard-AI/giskard/tree/main/docs/reference/notebooks
Then, you just have to submit a PR to add your contribution.


Sounds great; look out for my PR soon.
Repository: Giskard-AI/giskard-oss
Issue: Generate synthetic questions with listing choices
Root cause: Unimplemented Feature Gap

## 🚀 Feature Request

I suggest creating a new type of synthetic questions such that providing context and reference contexts, someone could ask 
"Which are the choices of that option?"

and get an answer as a list of cases.

## 🔈 Motivation

Isolating specific parts of text segments and answering consumes mainly the information from dedicated segments. When someone wants to combine more sources and make comparisons or list possible answers seems a more challenging use case.



Is this been taken care of?
Repository: Giskard-AI/giskard-oss
Issue: Unresolved Version Conflict for Langchain-community
Root cause: Configuration Error

## Checklist

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [x] I've searched the project's [`issues`](https://github.com/Giskard-AI/giskard/issues?q=is%3Aissue).

## ❓ Question

I am unable to resolve dependencies requirement between langchain, langchain-community and giskard[llm]. I am using poetry as dependencies management tool and this is what I am getting: 

Because no versions of langchain-community match >0.2.5,<0.3.0
 and langchain-community (0.2.5) depends on langchain (>=0.2.5,<0.3.0), langchain-community (>=0.2.5,<0.3.0) requires langchain (>=0.2.5,<0.3.0).
So, because giskard-project depends on both langchain (<=0.0.301) and langchain-community (^0.2.5), version solving failed.

Is there any version of langchain, langchain-community and giskard[llm] that can run well together?

## 📎 Additional context

Here is my current depencies before adding langchain-community: 
python = ">=3.9,<3.12"
giskard = {extras = ["llm"], version = "^2.14.0"}
langchain = "<=0.0.301"
pypdf = "<=3.17.0"
faiss-cpu = "<=1.7.4"
openai = "<=0.28.1"
tiktoken = "<=0.5.1"
python-dotenv = "^1.0.1"


Hello,

Giskard doesn't require `langchain <=0.0.301`, however you might have added the requirement when exploring an old demo notebook. You can safely upgrade `langchain` and `openai` to run Giskard without any issue.
Repository: Giskard-AI/giskard-oss
Issue: Giskard Scan crush when tested for a large number of features 
Root cause: Resource Mishandling

### Issue Type

Bug

### Source

source

### Giskard Library Version

2.14.0

### Giskard Hub Version

2.14.0

### OS Platform and Distribution

Linux Ubuntu 20.04

### Python version

3.9

### Installed python packages

```shell
numpy==1.23.5
pandas==2.0.3
pyarrow==16.0.0
openpyxl==3.1.2
scikit-learn==1.3.1
xgboost==1.7.6
featurewiz==0.3.2
```


### Current Behaviour?

```shell
I run the scan with a testing dataset of 100 samples and ~3700 features and an OOM error occured. 
I have utilized a pipeline with Data transformers, featurewiz feature selection and XGBoost model. 
I have run the library in 2 other use cases with <100 number of features and it runs smoothly without any issue therefore the issue i am suspecting is related with the vast amount of features

Running on 48GB Ram.
```


### Standalone code OR list down the steps to reproduce the issue

```shell
import pandas as pd
import numpy as np
from giskard import Dataset, Model, scan

# Class to create the model and Dataset
class VulnerabilityDetection:
    def __init__(self, df: pd.DataFrame, model_instance):
        self.model_instance = model_instance
        self.df = df
    
    def gisk_dataset(self):
        CATEGORICAL_COLUMNS = list(self.df[self.df.columns[self.df.dtypes == 'object']].columns)
        giskard_dataset = Dataset(
                df=self.df,
                target="Target",
                name="",
                cat_columns=CATEGORICAL_COLUMNS,
                )
        return giskard_dataset
    
    def gisk_model(self):
        model_inst = self.model_instance

        def prediction_function(df: pd.DataFrame) -> np.ndarray:
            return model_inst.predict_proba(df)
        
        giskard_model = Model(
            model=prediction_function,
            model_type="classification",
            name="Vulnerability Detection Model",
            classification_labels=model_inst.classes_,
            feature_names=self.df.columns
        )
        return giskard_model

# Execution
import pickle
df = pd.read_csv("MyData")
with open("XGBoost_pipeline.pkl", 'rb') as file:
    xg_pipeline = pickle.load(file)
vd = VulnerabilityDetection(df, xg_pipeline)
gisk_dataset = vd.gisk_dataset()
gisk_model = vd.gisk_model()
```


### Relevant log output

```shell
Actually the Notebook from VSCode crushed with OOM error
```


The dataset i am using is related to radiomics (Medical Imaging) where all the features are contributing at model's decision and therefore i cannot isolate specific features. Maybe updating the logic behind the scan would be beneficiary.
For instance for a large number of features procced with batch processing and at the end merge the scan results into the total

Hey @dzaridis, are you still facing this issue?
Which error did you get? Indeed, it seems to be a problem with the vast amount of features, specially when using xgboost
Repository: Giskard-AI/giskard-oss
Issue: Support python 3.12
Root cause: Unimplemented Feature Gap

## 🚀 Feature Request

Support python 3.12

## 🔈 Motivation

It was released in oktober 2023, my project uses 3.12 and can't downgrade to 3.12. 

## 🛰 Alternatives

...

## 📎 Additional context

...


Please do that. All your sub libraries and modules can be used under python 3.12

+1, Python 3.12 support would be great.

We had issues with `torch` which prevented us from supporting Python 3.12 immediately. I just checked that PyTorch 2.4 which was released end of July is finally compatible with 3.12, we will give it a go!
Repository: Giskard-AI/giskard-oss
Issue: Set any groq model as default LLMClient for giskard 
Root cause: Unimplemented Feature Gap

## 🚀 Feature Request

Add Support for Groq in Giskard or show it in the documentation if already supported

## 🔈 Motivation

The integration of Groq as an alternative to OpenAI in the Giskard library is highly beneficial. Groq offers speed that is almost equivalent or even faster than GPT-4 and significantly faster than any Ollama model. This will provide users with a high-performance alternative for their machine learning tasks.

## 🛰 Alternatives

Currently, the only alternative is using OpenAI's models, which may not meet all users' needs for speed and performance. Can use Ollama as well but using it is a lot of hassle especially in colab or kaggle notebooks.Incorporating Groq provides a competitive edge and additional flexibility.

## 📎 Additional context

Here is the proposed code to integrate Groq with Giskard:

```
from groq import `Groq`
from giskard.llm.client.openai import OpenAIClient
import giskard as gsk

_client = Groq(api_key="YOUR_GROQ_API_KEY")
oc = OpenAIClient(model="any_model_in_groq", client=_client)
gsk.llm.set_default_client(oc)
```

This simple addition allows users to set up **Groq** as their default client in **Giskard**, enabling them to take advantage of Groq's superior speed and performance. Detailed documentation and examples will also be necessary to guide users through the setup and usage process.


Hey @Vikas9758, thanks for your suggestion!
Indeed it would be very useful to use Groq API itself instead of implementing a custom client.
Would you be interested in implementing this?
Repository: Giskard-AI/giskard-oss
Issue: Is it possible to return the full result of giskard.scan() including both passed and not passed results?
Root cause: Unimplemented Feature Gap

## Checklist

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [x] I've searched the project's [`issues`](https://github.com/Giskard-AI/giskard/issues?q=is%3Aissue).

## ❓ Question

<!-- What is your question -->

Is it possible to return the full result of giskard.scan() including both passed and not passed results? I want to see how the chatbot responds to all cases. Currently, only the responses with issues are returned.


## 📎 Additional context
<img width="1336" alt="image" src="https://github.com/user-attachments/assets/bcda9340-eb9f-4021-a5a6-9d1f0aafbad8">


Hello @Wongkitlong314 , 

No, it's not possible to return the passed tests during the scan. 
It would be a nice addition to the lib, I'll take a look at this and see if it can easily be implemented

Any updates on this?
Repository: Giskard-AI/giskard-oss
Issue: Incorrect Usage of Temperature Parameter in _llm_complete Method
Root cause: Algorithmic Error

## Checklist

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [x] I've searched the project's [`issues`](https://github.com/Giskard-AI/giskard/issues?q=is%3Aissue).

## ❓ Question

<!-- What is your question -->
Why is the llm_temperature hardcoded?

In the [_LLMBasedQuestionGenerator](https://github.com/Giskard-AI/giskard/blob/cec5afb12ea1dfb6131fee16e3ba16dec844ec18/giskard/rag/question_generators/base.py#L19) class, `_llm_complete()` method is currently hardcoding the temperature parameter to 0.5 instead of using the instance variable `_llm_temperature`. This prevents the flexibility of setting different temperature values during the initialization of the class.