aya-se commited on
Commit
3cff5d9
·
1 Parent(s): 8499e52

Update README.md

Browse files
Files changed (2) hide show
  1. README.md +23 -11
  2. README_ja.md +38 -1
README.md CHANGED
@@ -1,7 +1,7 @@
1
  ---
2
  license: other
3
  license_name: mixed
4
- license_link: https://huggingface.co/datasets/tokyotech-llm/edu-classifier/blob/main/README.md
5
  language: ja
6
  pipeline_tag: text-classification
7
  library_name: fasttext
@@ -9,7 +9,7 @@ library_name: fasttext
9
 
10
  # Swallow Edu Classifier
11
 
12
- [日本語版の README はこちら](https://huggingface.co/datasets/tokyotech-llm/edu-classifier/blob/main/README_ja.md)
13
 
14
  ## Model summary
15
 
@@ -17,8 +17,8 @@ library_name: fasttext
17
 
18
  This repository contains fastText classifiers for judging the educational value of Japanese web pages. It includes two types of classifiers:
19
 
20
- 1. **Wiki-based classifier**: trained on Japanese Wikipedia text from academic categories. This classifier is released under the [Apache-2.0 License](https://huggingface.co/datasets/tokyotech-llm/edu-classifier/blob/main/APACHE_LICENSE_VERSION_2.0.md).
21
- 2. **LLM-based classifier**: trained on annotations provided by an LLM, governed by the license applicable to the underlying LLM used for annotation ([Llama 3.1 Community License Agreement](https://huggingface.co/datasets/tokyotech-llm/edu-classifier/blob/main/LLAMA_3) or [Gemma Terms of Use](https://huggingface.co/datasets/tokyotech-llm/edu-classifier/blob/main/GEMMA_TERMS_OF_USE.md)).
22
 
23
  These classifiers were developed as part of a quality-filtering process for Swallow Corpus Version 2, used in the training of the [Llama 3.1 Swallow](https://huggingface.co/collections/tokyotech-llm/llama-31-swallow-66fd4f7da32705cadd1d5bc6) series. Our ablation experiments have shown that applying a filter based on the classifier’s scores improved the LLM’s ability related to Japanese knowledge.
24
 
@@ -30,18 +30,30 @@ The Wiki-based classifier outputs a probability between 0 and 1, indicating how
30
  from huggingface_hub import hf_hub_download
31
  import fasttext
32
 
33
- model = fasttext.load_model(hf_hub_download("tokyotech-llm/edu-classifier", "model.bin"))
34
- ```
 
35
 
36
- ### Best practice
 
 
37
 
38
- If you aim to assign appropriate ranked scores to a wide range of documents, it is recommended to use the LLM-based classifier. The Wiki-based classifier tends to assign scores close to 0 for most documents, making it specialized for detecting the few documents that resemble Wikipedia. In contrast, the LLM-based classifier can provide grading based on a broader definition of educational value.
 
39
 
40
- ## Training
 
 
 
 
41
 
42
- ### Wiki-based classifier
 
 
43
 
44
- ### LLM-based classifier
 
 
45
 
46
  ## How to cite
47
 
 
1
  ---
2
  license: other
3
  license_name: mixed
4
+ license_link: https://huggingface.co/tokyotech-llm/edu-classifier/blob/main/README.md
5
  language: ja
6
  pipeline_tag: text-classification
7
  library_name: fasttext
 
9
 
10
  # Swallow Edu Classifier
11
 
12
+ [日本語版の README はこちら](https://huggingface.co/tokyotech-llm/edu-classifier/blob/main/README_ja.md)
13
 
14
  ## Model summary
15
 
 
17
 
18
  This repository contains fastText classifiers for judging the educational value of Japanese web pages. It includes two types of classifiers:
19
 
20
+ 1. **Wiki-based classifier**: trained on Japanese Wikipedia text from academic categories. This classifier is released under the [Apache-2.0 License](https://huggingface.co/tokyotech-llm/edu-classifier/blob/main/APACHE_LICENSE_VERSION_2.0.md).
21
+ 2. **LLM-based classifier**: trained on annotations provided by an LLM, governed by the license applicable to the underlying LLM used for annotation ([Llama 3.1 Community License Agreement](https://huggingface.co/tokyotech-llm/edu-classifier/blob/main/LLAMA_3) or [Gemma Terms of Use](https://huggingface.co/tokyotech-llm/edu-classifier/blob/main/GEMMA_TERMS_OF_USE.md)).
22
 
23
  These classifiers were developed as part of a quality-filtering process for Swallow Corpus Version 2, used in the training of the [Llama 3.1 Swallow](https://huggingface.co/collections/tokyotech-llm/llama-31-swallow-66fd4f7da32705cadd1d5bc6) series. Our ablation experiments have shown that applying a filter based on the classifier’s scores improved the LLM’s ability related to Japanese knowledge.
24
 
 
30
  from huggingface_hub import hf_hub_download
31
  import fasttext
32
 
33
+ # Example text
34
+ text = "Llama 3.1 Swallow\nLlama 3.1 SwallowはLlama 3.1の英語の能力を維持しながら、日本語の能力を強化した大規模言語モデル (8B, 70B) です。"
35
+ text = text.replace("\n", " ")
36
 
37
+ # If you use Wiki-based classifier
38
+ model = fasttext.load_model(hf_hub_download("tokyotech-llm/edu-classifier", "wiki.bin"))
39
+ res = model.predict(text, k=-1)
40
 
41
+ ## Use the positive prediction probability as the educational score
42
+ edu_score = res[1][0] if res[0][0] == "__label__pos" else 1 - res[1][0]
43
 
44
+ # If you use LLM-based classifier
45
+ model = fasttext.load_model(
46
+ hf_hub_download("tokyotech-llm/edu-classifier", "llm_llama.bin")
47
+ )
48
+ res = model.predict(text, k=-1)
49
 
50
+ ## Use the weighted sum of the prediction probabilities as the educational score
51
+ edu_score = sum([int(label[-1]) * prob for label, prob in zip(res[0], res[1])])
52
+ ```
53
 
54
+ ### Best practice
55
+
56
+ If you aim to assign appropriate ranked scores to a wide range of documents, it is recommended to use the LLM-based classifier. The Wiki-based classifier tends to assign scores close to 0 for most documents, making it specialized for detecting the few documents that resemble Wikipedia. In contrast, the LLM-based classifier can provide grading based on a broader definition of educational value.
57
 
58
  ## How to cite
59
 
README_ja.md CHANGED
@@ -4,7 +4,7 @@
4
 
5
  **注意**:日本語でのみ動作します。英語やそれ以外の言語での品質は保証しません。
6
 
7
- 日本語ウェブページの教育的価値を判定する fastText 分類器です。本リポジトリには学術カテゴリに属する日本語 Wikipedia テキストを元に訓練された分類器(Wiki-based classifier)と、LLM によるアノテーションを元に訓練された分類器(LLM-based classifier)が含まれます。前者には [Apache-2.0 ライセンス](https://huggingface.co/datasets/tokyotech-llm/edu-classifier/blob/main/APACHE_LICENSE_VERSION_2.0.md)、後者にはアノテーションに使用された LLM に応じたライセンス([Llama 3.1 Community License Agreement](https://huggingface.co/datasets/tokyotech-llm/edu-classifier/blob/main/LLAMA_3.1_COMMUNITY_LICENSE_AGREEMENT.md)、[Gemma Terms of Use](https://huggingface.co/datasets/tokyotech-llm/edu-classifier/blob/main/GEMMA_TERMS_OF_USE.md))が適用されます。
8
 
9
  これらの分類器は[Llama 3.1 Swallow](https://huggingface.co/collections/tokyotech-llm/llama-31-swallow-66fd4f7da32705cadd1d5bc6)シリーズの訓練に用いられた Swallow Corpus Version 2 の品質フィルタリングの一環として開発されました。Ablation 実験では、分類器のスコアに基づくフィルタリングの適用により、LLM の日本語知識が向上することを確認しました。
10
 
@@ -12,6 +12,43 @@
12
 
13
  Wiki-based classifier は与えられた文書が Wikipedia らしいかどうかを 0〜1 の確率で出力します。一方、LLM-based classifier は与えられた文書の教育的スコアが 0、1、2、3 のいずれに属するかどうかを 4 ラベル分類問題として予測します。各ラベルの予測確率に基づくスコアの期待値(0〜3)を最終的なスコアとして用いることができます。
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ### ベストプラクティス
16
 
17
  広範な文書に適切な序列のスコアを付与したい場合、LLM-based classifier の使用を推奨します。Wiki-based classifier はほとんどの文書に 0 付近のスコアを付与する傾向にあるため、Wikipedia らしいわずかな文書の検出に特化しています。一方、LLM-based classifier はより一般的な教育的価値の定義に基づいた採点をすることができます。
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  **注意**:日本語でのみ動作します。英語やそれ以外の言語での品質は保証しません。
6
 
7
+ 日本語ウェブページの教育的価値を判定する fastText 分類器です。本リポジトリには学術カテゴリに属する日本語 Wikipedia テキストを元に訓練された分類器(Wiki-based classifier)と、LLM によるアノテーションを元に訓練された分類器(LLM-based classifier)が含まれます。前者には [Apache-2.0 ライセンス](https://huggingface.co/tokyotech-llm/edu-classifier/blob/main/APACHE_LICENSE_VERSION_2.0.md)、後者にはアノテーションに使用された LLM に応じたライセンス([Llama 3.1 Community License Agreement](https://huggingface.co/tokyotech-llm/edu-classifier/blob/main/LLAMA_3.1_COMMUNITY_LICENSE_AGREEMENT.md)、[Gemma Terms of Use](https://huggingface.co/tokyotech-llm/edu-classifier/blob/main/GEMMA_TERMS_OF_USE.md))が適用されます。
8
 
9
  これらの分類器は[Llama 3.1 Swallow](https://huggingface.co/collections/tokyotech-llm/llama-31-swallow-66fd4f7da32705cadd1d5bc6)シリーズの訓練に用いられた Swallow Corpus Version 2 の品質フィルタリングの一環として開発されました。Ablation 実験では、分類器のスコアに基づくフィルタリングの適用により、LLM の日本語知識が向上することを確認しました。
10
 
 
12
 
13
  Wiki-based classifier は与えられた文書が Wikipedia らしいかどうかを 0〜1 の確率で出力します。一方、LLM-based classifier は与えられた文書の教育的スコアが 0、1、2、3 のいずれに属するかどうかを 4 ラベル分類問題として予測します。各ラベルの予測確率に基づくスコアの期待値(0〜3)を最終的なスコアとして用いることができます。
14
 
15
+ ```python
16
+ from huggingface_hub import hf_hub_download
17
+ import fasttext
18
+
19
+ # テキストの例
20
+ text = "Llama 3.1 Swallow\nLlama 3.1 SwallowはLlama 3.1の英語の能力を維持しながら、日本語の能力を強化した大規模言語モデル (8B, 70B) です。"
21
+ text = text.replace("\n", " ")
22
+
23
+ # Wiki-based classifierを使用する場合
24
+ model = fasttext.load_model(hf_hub_download("tokyotech-llm/edu-classifier", "wiki.bin"))
25
+ res = model.predict(text, k=-1)
26
+
27
+ ## 正例の予測確率を教育的スコアとみなす
28
+ edu_score = res[1][0] if res[0][0] == "__label__pos" else 1 - res[1][0]
29
+
30
+ # LLM-based classifierを使用する場合
31
+ model = fasttext.load_model(
32
+ hf_hub_download("tokyotech-llm/edu-classifier", "llm_llama.bin")
33
+ )
34
+ res = model.predict(text, k=-1)
35
+
36
+ ## 各スコアの予測確率の期待値を教育的スコアとみなす
37
+ edu_score = sum([int(label[-1]) * prob for label, prob in zip(res[0], res[1])])
38
+ ```
39
+
40
  ### ベストプラクティス
41
 
42
  広範な文書に適切な序列のスコアを付与したい場合、LLM-based classifier の使用を推奨します。Wiki-based classifier はほとんどの文書に 0 付近のスコアを付与する傾向にあるため、Wikipedia らしいわずかな文書の検出に特化しています。一方、LLM-based classifier はより一般的な教育的価値の定義に基づいた採点をすることができます。
43
+
44
+ ## 引用
45
+
46
+ ```bibtex
47
+ @inproceedings{hattori-2025-swallow-v2,
48
+ author = {服部 翔 and 岡崎 直観 and 水木 栄 and 藤井 一喜 and 中村 泰士 and 大井 聖也 and 塩谷 泰平 and 齋藤 幸史郎 and Youmi Ma and 前田 航希 and 岡本 拓己 and 石田 茂樹 and 横田 理央 and 高村 大也},
49
+ title = {Swallowコーパスv2: 教育的な日本語ウェブコーパスの構築},
50
+ booktitle = {言語処理学会第31回年次大会 (NLP2025)},
51
+ comment = mar,
52
+ year = {2025},
53
+ }
54
+ ```