kevineen commited on
Commit
c6abd78
1 Parent(s): 29faabc

class 使用使用

Browse files
target_dataset.txt → huggingface_dataset.txt RENAMED
@@ -67,7 +67,7 @@ fileSize 116MB
67
  - good bool
68
  - bad bool
69
  - score int64
70
- - is_proofreading boolean
71
- - answer_text string
72
- - is_proofreadin_2 boolean
73
  - answer_text_2 string
 
67
  - good bool
68
  - bad bool
69
  - score int64
70
+ - is_proofreading_1 bool
71
+ - answer_text_1 string
72
+ - is_proofreading_2 bool
73
  - answer_text_2 string
run.py CHANGED
@@ -1,8 +1,34 @@
 
1
  import gradio as gr
2
- from huggingface_hub import list_models
3
  from datasets import load_dataset
4
  from type.dataset_type import TanukiPhase2AnnotationDataset
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  # HF保存先
7
  output_dataset = [
8
  "kevineen/Phase2_dataset_annotation"
@@ -20,35 +46,11 @@ annotation_dataset_list = [
20
  "kanhatakeyama/LogicalDatasetsByMixtral8x22b",
21
  ]
22
 
23
-
24
- # アノテーションクラス
25
- class AnnotationState:
26
- def __init__(self, gr):
27
- # 選択中のデータセット 初期値は"hatakeyama-llm-team/AutoGeneratedJapaneseQA"
28
- self.dropdown_dataset = gr.State(value=annotation_dataset_list[1])
29
- self.current_dataset = gr.State(None) # 現在のデータ
30
- self.current_idx = gr.State(0) # 現在のインデックス
31
- self.target_dataset = gr.State(None) # 出力先データセット
32
- self.initial_answer_text = gr.State("") # 文を整形したかチェック用
33
- self.initial_answer_text_2 = gr.State("") # 文を整形したかチェック用
34
-
35
- # 出力用
36
- self.id = gr.State(0) # 出力先のデータセットをチェックし、末尾IDを追加
37
- self.dataset = gr.State("") # 編集に使用したデータセット
38
- self.dataset_id = gr.State(0) # 加工元データセットのidx
39
- self.who = gr.State("") # アノテーション者
40
- self.good = gr.State(False) # 良
41
- self.bad = gr.State(False) # 悪
42
- self.score = gr.State(3) # スコア 初期値は3
43
- self.is_proofreading = gr.State(False) # 文を整形したか_1
44
- self.answer_text = gr.State("") # answer_1 回答
45
- self.is_proofreading_2 = gr.State(False) # 文を整形したか_2
46
- self.answer_text_2 = gr.State("") # answer_2 回答
47
-
48
- state = AnnotationState(gr)
49
 
50
  # 選択中のデータセット 初期値は"hatakeyama-llm-team/AutoGeneratedJapaneseQA",
51
- dropdown_dataset = gr.State(value = annotation_dataset_list[1])
52
  current_dataset = gr.State(None) # 現在のデータ
53
  target_dataset = gr.State(None) # データセット
54
  current_idx = gr.State(0) # 現在のインデックス
@@ -135,8 +137,6 @@ with gr.Blocks(theme=theme_, css=load_css()) as demo:
135
 
136
  profile_name = gr.Markdown()
137
 
138
- # theme_button = gr.Button("Switch Theme")
139
- # theme_button.click(fn=update_theme, outputs=None)
140
 
141
  # お名前表示 出力データセット用
142
  demo.load(hello, inputs=None, outputs=profile_name)
@@ -162,7 +162,7 @@ with gr.Blocks(theme=theme_, css=load_css()) as demo:
162
 
163
  question_text = gr.Textbox(label="質問: ", interactive=False)
164
 
165
- with gr.Tab("シンプルモード"):
166
 
167
  with gr.Column():
168
 
@@ -203,7 +203,7 @@ with gr.Blocks(theme=theme_, css=load_css()) as demo:
203
  outputs=None
204
  )
205
 
206
- with gr.Tab("丁寧モード"):
207
 
208
  score_slider = gr.Slider(1, 5, label="スコア: 1-5 (1:大変悪い、2:悪い、3:普通、4:良い、5:大変良い)", step=1, value=score.value, interactive=True)
209
 
 
1
+ from typing import Optional, List
2
  import gradio as gr
 
3
  from datasets import load_dataset
4
  from type.dataset_type import TanukiPhase2AnnotationDataset
5
 
6
+ class CurrentData:
7
+ def __init__(self, gr, annotation_dataset_list: List[str]):
8
+ # 選択中のデータセット 初期値は"hatakeyama-llm-team/AutoGeneratedJapaneseQA"
9
+ self.dropdown_dataset = gr.State(value=annotation_dataset_list[0])
10
+ self.current_dataset = gr.State(None) # 現在のデータ
11
+ self.current_idx = gr.State(0) # 現在のインデックス
12
+ self.target_dataset = gr.State(None) # 出力先データセット
13
+ self.initial_answer_text = gr.State("") # 回答1を整形したかチェック用
14
+ self.initial_answer_text_2 = gr.State("") # 回答2を整形したかチェック用
15
+
16
+
17
+ # アノテーション中のデータセット
18
+ class AnnotationState (TanukiPhase2AnnotationDataset):
19
+ def __init__(self, gr):
20
+ self.id = gr.State(0) # 出力先のデータセットをチェックし、末尾IDを追加
21
+ self.dataset = gr.State("") # 編集に使用したデータセット
22
+ self.dataset_id = gr.State(0) # 加工元データセットのidx
23
+ self.who = gr.State("") # アノテーション者
24
+ self.good = gr.State(False) # 良
25
+ self.bad = gr.State(False) # 悪
26
+ self.score = gr.State(3) # スコア 初期値は3
27
+ self.is_proofreading_1 = gr.State(False) # 回答1を整形したか_1
28
+ self.answer_text = gr.State("") # answer_1 回答
29
+ self.is_proofreading_2 = gr.State(False) # 回答2を整形したか_2
30
+ self.answer_text_2 = gr.State("") # answer_2 回答
31
+
32
  # HF保存先
33
  output_dataset = [
34
  "kevineen/Phase2_dataset_annotation"
 
46
  "kanhatakeyama/LogicalDatasetsByMixtral8x22b",
47
  ]
48
 
49
+ current_data = CurrentData(gr, annotation_dataset_list)
50
+ annotation_state = AnnotationState(gr)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  # 選択中のデータセット 初期値は"hatakeyama-llm-team/AutoGeneratedJapaneseQA",
53
+ dropdown_dataset = gr.State(value = annotation_dataset_list[0])
54
  current_dataset = gr.State(None) # 現在のデータ
55
  target_dataset = gr.State(None) # データセット
56
  current_idx = gr.State(0) # 現在のインデックス
 
137
 
138
  profile_name = gr.Markdown()
139
 
 
 
140
 
141
  # お名前表示 出力データセット用
142
  demo.load(hello, inputs=None, outputs=profile_name)
 
162
 
163
  question_text = gr.Textbox(label="質問: ", interactive=False)
164
 
165
+ with gr.Tab("シンプルモード(良い・悪いのみ選択)"):
166
 
167
  with gr.Column():
168
 
 
203
  outputs=None
204
  )
205
 
206
+ with gr.Tab("丁寧モード(5段階評価・文章校正)"):
207
 
208
  score_slider = gr.Slider(1, 5, label="スコア: 1-5 (1:大変悪い、2:悪い、3:普通、4:良い、5:大変良い)", step=1, value=score.value, interactive=True)
209
 
type/dataset_type.py CHANGED
@@ -54,16 +54,16 @@ class LogicalDatasetsByMixtral8x22b:
54
  question: str
55
  answer: str
56
 
57
-
58
  class TanukiPhase2AnnotationDataset:
59
  id: int
60
  dataset: str
61
- database_id: int
62
  who: str
63
  good: bool
64
  bad: bool
65
  score: float
66
- is_proofreading: bool
67
- answer_text : str
68
- is_proofreading_2: str
69
- answer_text2 : str
 
54
  question: str
55
  answer: str
56
 
57
+ # 加工後提出用
58
  class TanukiPhase2AnnotationDataset:
59
  id: int
60
  dataset: str
61
+ dataset_id: int
62
  who: str
63
  good: bool
64
  bad: bool
65
  score: float
66
+ is_proofreading_1: bool
67
+ answer_text_1 : str
68
+ is_proofreading_2: bool
69
+ answer_text_2 : str