from huggingfacehub import hfhubdownload import fasttext Example text text = "Llama 3.1…
- User
from huggingface_hub import hf_hub_download import fasttext
Example text
text = "Llama 3.1 Swallow\nLlama 3.1 SwallowはLlama 3.1の英語の能力を維持しながら、日本語の能力を強化した大規模言語モデル (8B, 70B) です。" text = text.replace("\n", " ")
If you use Wiki-based classifier
model = fasttext.load_model(hf_hub_download("tokyotech-llm/edu-classifier", "wiki.bin")) res = model.predict(text, k=-1)
Use the positive prediction probability as the educational score
edu_score = res[1][0] if res[0][0] == "__label__pos" else 1 - res[1][0]
If you use LLM-based classifier
model = fasttext.load_model( hf_hub_download("tokyotech-llm/edu-classifier", "llm_llama.bin") ) res = model.predict(text, k=-1)
Use the weighted sum of the prediction probabilities as the educational score
edu_score = sum([int(label[-1]) * prob for label, prob in zip(res[0], res[1])])
- Assistant
このコードは、与えられたテキストに対して教育的価値を評価するためのモデルを使用する方法を示しています。以下の手順で行います:
- Hugging Face Hubから必要なモデルをダウンロードします。ここでは、日本語のテキストに対応するために「tokyotech-llm/edu-classifier」というモデルを使用します。
- ダウンロードしたモデルを使って、テキストの教育的価値を評価します。
具体的なコードの説明は以下の通りです:
python
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.