[GSK-1473] Enabling rewrite_prompt for giskard evaluator#1266
[GSK-1473] Enabling rewrite_prompt for giskard evaluator#1266rabah-khalek merged 14 commits intomainfrom
Conversation
|
@andreybavt to make the review easier (since the change is blurred by the refactoring), here're the main modifications: so now I unwrap the langchain model from the pyfunc model to be able to use models = ["text-ada-001"]
import pandas as pd
import mlflow
import openai
import os
from langchain import PromptTemplate, LLMChain
from langchain.llms import OpenAI
df = pd.read_csv('https://github.com/__raw/sunnysai12345/News_Summary/master/news_summary_more.csv')
df_sample = pd.DataFrame(df["text"].sample(10, random_state=11))
os.environ["OPENAI_API_KEY"] = "XXX"
os.getenv("OPENAI_API_KEY")
openai.api_key = os.getenv("OPENAI_API_KEY")
prompt = PromptTemplate(template="Create a reader comment according to the following article summary: '{text}'",
input_variables=["text"])
for model in models:
llm = OpenAI(openai_api_key=openai.api_key,
request_timeout=20,
max_retries=100,
temperature=0,
model_name=model)
chain = LLMChain(prompt=prompt, llm=llm)
evaluator_config = {"scan_config": {"params": {"text_perturbation": {"num_samples": 10},
"ethical_bias": {"num_samples": 10}}}}
with mlflow.start_run(run_name = model):
model_uri = mlflow.langchain.log_model(chain, "langchain").model_uri
mlflow.evaluate(model=model_uri, model_type="text", data=df_sample, evaluators="giskard", evaluator_config=evaluator_config)which outputs the following issues (that didn't use to work before): |
|
@rabah-khalek why is the LLMToxicityDetector failing? |
You know what, I was completely blind to this. Focused more on the new detectors. Let me investigate this. Thanks! |
|
Also, minor observation: could you use ruff + black to format the code? I think we standardized on that (@andreybavt has configured a git pre-commit hook that you can enable). |
|
@mattbit, the issue is fixed now. The problem was that I was trying to input the |
mattbit
left a comment
There was a problem hiding this comment.
Could you review the comments?
Also, could you run black + ruff on new files to fix the style issues?
|
Kudos, SonarCloud Quality Gate passed! |








Uh oh!
There was an error while loading. Please reload this page.