-
Notifications
You must be signed in to change notification settings - Fork 65
docs: update README #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: update README #299
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -260,8 +260,19 @@ outputs/ | |||||
| class MyCustomRule(BaseRule): | ||||||
| @classmethod | ||||||
| def eval(cls, input_data: Data) -> EvalDetail: | ||||||
| # あなたのロジック | ||||||
| return EvalDetail(status=False, label=['QUALITY_GOOD']) | ||||||
| # 例:コンテンツが空かチェック | ||||||
| if not input_data.content: | ||||||
| return EvalDetail( | ||||||
| metric=cls.__name__, | ||||||
| status=True, # 問題を発見 | ||||||
| label=[f'{cls.metric_type}.{cls.__name__}'], | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example is a great improvement. For better clarity, since
Suggested change
|
||||||
| reason=["コンテンツが空です"] | ||||||
| ) | ||||||
| return EvalDetail( | ||||||
| metric=cls.__name__, | ||||||
| status=False, # 問題なし | ||||||
| label=['QUALITY_GOOD'] | ||||||
| ) | ||||||
| ``` | ||||||
| **重要性**:コードベースをフォークせずにドメイン固有のニーズに適応。 | ||||||
|
|
||||||
|
|
@@ -435,22 +446,26 @@ Dingo はドメイン固有のニーズに対応する柔軟な拡張メカニ | |||||
| ```python | ||||||
| from dingo.model import Model | ||||||
| from dingo.model.rule.base import BaseRule | ||||||
| from dingo.config.input_args import EvaluatorRuleArgs | ||||||
| from dingo.io import Data | ||||||
| from dingo.io.output.eval_detail import EvalDetail | ||||||
|
|
||||||
|
|
||||||
| @Model.rule_register('QUALITY_BAD_RELEVANCE', ['default']) | ||||||
| class MyCustomRule(BaseRule): | ||||||
| """テキスト内のカスタムパターンをチェック""" | ||||||
|
|
||||||
| dynamic_config = EvaluatorRuleArgs(pattern=r'your_pattern_here') | ||||||
| @Model.rule_register('QUALITY_BAD_CUSTOM', ['default']) | ||||||
| class DomainSpecificRule(BaseRule): | ||||||
| """ドメイン固有のパターンをチェック""" | ||||||
|
|
||||||
| @classmethod | ||||||
| def eval(cls, input_data: Data) -> EvalDetail: | ||||||
| res = EvalDetail() | ||||||
| # ここにルール実装 | ||||||
| return res | ||||||
| text = input_data.content | ||||||
|
|
||||||
| # あなたのカスタムロジック | ||||||
| is_valid = your_validation_logic(text) | ||||||
|
|
||||||
| return EvalDetail( | ||||||
| metric=cls.__name__, | ||||||
| status=not is_valid, # False = 良好, True = 問題あり | ||||||
| label=['QUALITY_GOOD' if is_valid else 'QUALITY_BAD_CUSTOM'], | ||||||
| reason=["検証の詳細..."] | ||||||
| ) | ||||||
| ``` | ||||||
|
|
||||||
| ### カスタムLLM統合 | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -262,8 +262,19 @@ outputs/ | |||||
| class MyCustomRule(BaseRule): | ||||||
| @classmethod | ||||||
| def eval(cls, input_data: Data) -> EvalDetail: | ||||||
| # 你的逻辑 | ||||||
| return EvalDetail(status=False, label=['QUALITY_GOOD']) | ||||||
| # 示例:检查内容是否为空 | ||||||
| if not input_data.content: | ||||||
| return EvalDetail( | ||||||
| metric=cls.__name__, | ||||||
| status=True, # 发现问题 | ||||||
| label=[f'{cls.metric_type}.{cls.__name__}'], | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example is a great improvement. For better clarity, since
Suggested change
|
||||||
| reason=["内容为空"] | ||||||
| ) | ||||||
| return EvalDetail( | ||||||
| metric=cls.__name__, | ||||||
| status=False, # 未发现问题 | ||||||
| label=['QUALITY_GOOD'] | ||||||
| ) | ||||||
| ``` | ||||||
| **为什么重要**:适应特定领域需求而无需分叉代码库。 | ||||||
|
|
||||||
|
|
@@ -437,22 +448,26 @@ Dingo 提供灵活的扩展机制来满足特定领域需求。 | |||||
| ```python | ||||||
| from dingo.model import Model | ||||||
| from dingo.model.rule.base import BaseRule | ||||||
| from dingo.config.input_args import EvaluatorRuleArgs | ||||||
| from dingo.io import Data | ||||||
| from dingo.io.output.eval_detail import EvalDetail | ||||||
|
|
||||||
|
|
||||||
| @Model.rule_register('QUALITY_BAD_RELEVANCE', ['default']) | ||||||
| class MyCustomRule(BaseRule): | ||||||
| """检查文本中的自定义模式""" | ||||||
|
|
||||||
| dynamic_config = EvaluatorRuleArgs(pattern=r'your_pattern_here') | ||||||
| @Model.rule_register('QUALITY_BAD_CUSTOM', ['default']) | ||||||
| class DomainSpecificRule(BaseRule): | ||||||
| """检查特定领域的模式""" | ||||||
|
|
||||||
| @classmethod | ||||||
| def eval(cls, input_data: Data) -> EvalDetail: | ||||||
| res = EvalDetail() | ||||||
| # 您的规则实现 | ||||||
| return res | ||||||
| text = input_data.content | ||||||
|
|
||||||
| # 你的自定义逻辑 | ||||||
| is_valid = your_validation_logic(text) | ||||||
|
|
||||||
| return EvalDetail( | ||||||
| metric=cls.__name__, | ||||||
| status=not is_valid, # False = 良好, True = 有问题 | ||||||
| label=['QUALITY_GOOD' if is_valid else 'QUALITY_BAD_CUSTOM'], | ||||||
| reason=["验证详情..."] | ||||||
| ) | ||||||
| ``` | ||||||
|
|
||||||
| ### 自定义LLM集成 | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is a great improvement. For better clarity, since
cls.metric_typeis defined by the@Model.rule_registerdecorator which isn't visible in this snippet, consider adding a small inline comment to explain where it comes from. This will help users understand the example more easily.