-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work in progress on support for ragas as per explodinggradients/ragas#1165 and #232 Add an optional evaluator to a pipeline. Evaluators need to handle transformation events in the query pipeline. The Ragas evaluator captures the transformations as per https://docs.ragas.io/en/latest/howtos/applications/data_preparation.html. You can find a working notebook here https://github.com/bosun-ai/swiftide-tutorial/blob/c510788a625215f46575415161659edf26fc1fd5/ragas/notebook.ipynb with a pipeline using it here bosun-ai/swiftide-tutorial#1 TODO: - [x] Test it with Ragas - [x] Add more tests
- Loading branch information
Showing
14 changed files
with
587 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::querying::{states, Query}; | ||
|
||
/// Wraps a query for evaluation. Used by the [`EvaluateQuery`] trait. | ||
pub enum QueryEvaluation { | ||
/// Retrieve documents | ||
RetrieveDocuments(Query<states::Retrieved>), | ||
/// Answer the query | ||
AnswerQuery(Query<states::Answered>), | ||
} | ||
|
||
impl From<Query<states::Retrieved>> for QueryEvaluation { | ||
fn from(val: Query<states::Retrieved>) -> Self { | ||
QueryEvaluation::RetrieveDocuments(val) | ||
} | ||
} | ||
|
||
impl From<Query<states::Answered>> for QueryEvaluation { | ||
fn from(val: Query<states::Answered>) -> Self { | ||
QueryEvaluation::AnswerQuery(val) | ||
} | ||
} | ||
|
||
// TODO: must be a nicer way, maybe not needed and full encapsulation is better anyway | ||
impl QueryEvaluation { | ||
pub fn retrieve_documents_query(self) -> Option<Query<states::Retrieved>> { | ||
if let QueryEvaluation::RetrieveDocuments(query) = self { | ||
Some(query) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
pub fn answer_query(self) -> Option<Query<states::Answered>> { | ||
if let QueryEvaluation::AnswerQuery(query) = self { | ||
Some(query) | ||
} else { | ||
None | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/*! | ||
This module contains evaluators for evaluating the quality of a pipeline. | ||
Evaluators must implement the [`swiftide_core::traits::Evaluator`] trait. | ||
*/ | ||
pub mod ragas; |
Oops, something went wrong.