Skip to content

Commit 0ee24af

Browse files
pavanjavapavanmantha
andauthored
Evaluations integration (#55)
* -improved version of langchain rag with observability * -improved version of langchain rag with arize-phoenix * removed the secret * removed the secret * pushed mlflow basic evals --------- Co-authored-by: pavanmantha <pavan.mantha@thevaslabs.io>
1 parent 45f7055 commit 0ee24af

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import mlflow
2+
import openai
3+
import pandas as pd
4+
from dotenv import load_dotenv, find_dotenv
5+
6+
load_dotenv(find_dotenv())
7+
8+
eval_data = pd.read_csv("input_data.csv")
9+
10+
with mlflow.start_run() as run:
11+
system_prompt = "Answer the following question in two sentences"
12+
# Wrap "gpt-4" as an MLflow model.
13+
logged_model_info = mlflow.openai.log_model(
14+
model="gpt-4",
15+
task=openai.chat.completions,
16+
artifact_path="model",
17+
messages=[
18+
{"role": "system", "content": system_prompt},
19+
{"role": "user", "content": "{question}"},
20+
],
21+
)
22+
23+
# Use predefined question-answering metrics to evaluate our model.
24+
results = mlflow.evaluate(
25+
logged_model_info.model_uri,
26+
eval_data,
27+
targets="ground_truth",
28+
model_type="question-answering",
29+
)
30+
print(f"See aggregated evaluation results below: \n{results.metrics}")
31+
32+
# Evaluation result for each data record is available in `results.tables`.
33+
eval_table = results.tables["eval_results_table"]
34+
print(f"See evaluation table below: \n{eval_table}")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
,inputs,ground_truth
2+
0,What is MLflow?,"MLflow is an open-source platform for managing the end-to-end machine learning (ML) lifecycle. It was developed by Databricks, a company that specializes in big data and machine learning solutions. MLflow is designed to address the challenges that data scientists and machine learning engineers face when developing, training, and deploying machine learning models."
3+
1,What is Spark?,"Apache Spark is an open-source, distributed computing system designed for big data processing and analytics. It was developed in response to limitations of the Hadoop MapReduce computing model, offering improvements in speed and ease of use. Spark provides libraries for various tasks such as data ingestion, processing, and analysis through its components like Spark SQL for structured data, Spark Streaming for real-time data processing, and MLlib for machine learning tasks"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mlflow==2.16.2
2+
python-dotenv==1.0.1
3+
pandas==2.2.3

0 commit comments

Comments
 (0)