-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate evaluation test dataset
Signed-off-by: bjwswang <[email protected]>
- Loading branch information
Showing
18 changed files
with
285 additions
and
25 deletions.
There are no files selected for viewing
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
6 changes: 3 additions & 3 deletions
6
config/samples/arcadia_v1alpha1_worker_bge-large-zh-v1.5.yaml
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
\apiVersion: arcadia.kubeagi.k8s.com.cn/v1alpha1 | ||
apiVersion: arcadia.kubeagi.k8s.com.cn/v1alpha1 | ||
kind: Worker | ||
metadata: | ||
name: bge-large-zh | ||
namespace: arcadia | ||
namespace: kubeagi-system | ||
spec: | ||
displayName: BGE模型服务 | ||
description: "这是一个Embedding模型服务,由BGE提供" | ||
type: "fastchat" | ||
replicas: 1 | ||
model: | ||
kind: "Models" | ||
name: "bge-large-zh-v1.5" | ||
name: "bge-large-zh-v1.5" |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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,109 @@ | ||
/* | ||
Copyright 2024 KubeAGI. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package arctl | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"io" | ||
"os" | ||
|
||
basev1alpha1 "github.com/kubeagi/arcadia/api/base/v1alpha1" | ||
"github.com/kubeagi/arcadia/apiserver/graph/generated" | ||
"github.com/kubeagi/arcadia/apiserver/pkg/common" | ||
"github.com/kubeagi/arcadia/pkg/evaluation" | ||
"github.com/spf13/cobra" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/client-go/dynamic" | ||
) | ||
|
||
func NewEvalCmd(kubeClient dynamic.Interface, namespace string) *cobra.Command { | ||
var app string | ||
|
||
cmd := &cobra.Command{ | ||
Use: "eval", | ||
Short: "Manage evaluations", | ||
} | ||
|
||
cmd.Flags().StringVar(&app, "app", "", "The application that is going to be evaluated") | ||
|
||
cmd.AddCommand(EvalGenTestDataset(kubeClient, namespace, app)) | ||
|
||
return cmd | ||
} | ||
|
||
func EvalGenTestDataset(kubeClient dynamic.Interface, namespace string, appName string) *cobra.Command { | ||
var file string | ||
var questionColumn string | ||
var groundTruthsColumn string | ||
|
||
cmd := &cobra.Command{ | ||
Use: "gen_test_dataset", | ||
Short: "Generate a test dataset for evaluation", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
// read file content | ||
f, err := os.Open(file) | ||
if err != nil { | ||
return err | ||
} | ||
data, err := io.ReadAll(f) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// read files | ||
app := &basev1alpha1.Application{} | ||
obj, err := common.ResouceGet(context.Background(), kubeClient, generated.TypedObjectReferenceInput{ | ||
APIGroup: &common.ArcadiaAPIGroup, | ||
Kind: "Application", | ||
Namespace: &namespace, | ||
Name: appName, | ||
}, v1.GetOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(obj.UnstructuredContent(), app) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
generator, err := evaluation.NewRagasDatasetGenerator(context.Background(), kubeClient, app) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = generator.Generate( | ||
context.Background(), | ||
bytes.NewReader(data), | ||
evaluation.WithQuestionColumn(questionColumn), | ||
evaluation.WithGroundTruthsColumn(groundTruthsColumn), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().StringVar(&file, "file", "", "The file(CSV) which provides question and ground_truths") | ||
cmd.Flags().StringVar(&questionColumn, "question-column", "q", "The column name which provides questions") | ||
cmd.Flags().StringVar(&groundTruthsColumn, "ground-truths-column", "a", "The column name which provides the answers") | ||
|
||
return cmd | ||
} |
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
Oops, something went wrong.