-
-
Notifications
You must be signed in to change notification settings - Fork 378
[GSK-1473] Enabling rewrite_prompt for giskard evaluator #1266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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://raw.githubusercontent.com/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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you review the comments?
Also, could you run black + ruff on new files to fix the style issues?
python-client/giskard/integrations/mlflow/giskard_evaluator_utils.py
Outdated
Show resolved
Hide resolved
python-client/giskard/integrations/mlflow/giskard_evaluator_utils.py
Outdated
Show resolved
Hide resolved
python-client/giskard/integrations/mlflow/giskard_evaluator_utils.py
Outdated
Show resolved
Hide resolved
python-client/giskard/integrations/mlflow/giskard_evaluator_utils.py
Outdated
Show resolved
Hide resolved
python-client/giskard/integrations/mlflow/giskard_evaluator_utils.py
Outdated
Show resolved
Hide resolved
python-client/giskard/integrations/mlflow/giskard_evaluator_utils.py
Outdated
Show resolved
Hide resolved
|
Kudos, SonarCloud Quality Gate passed! |








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