-
Notifications
You must be signed in to change notification settings - Fork 32
Add data cleaning in fast-llm prepare, concept #210
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
Draft
bigximik
wants to merge
2
commits into
main
Choose a base branch
from
denis/prepare_filters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+595
β41
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
21 changes: 21 additions & 0 deletions
21
fast_llm/data/preparator/hf_processors/configs/agregator.py
bigximik marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,21 @@ | ||
import datasets | ||
|
||
from fast_llm.data.preparator.hf_processors.configs.base import Applicable, ShardProcessorConfig | ||
from fast_llm.config import Field, Config, config_class | ||
|
||
from fast_llm.data.preparator.hf_processors.configs.doc_length_filter import DocLengthFilterConfig | ||
|
||
def default_processors(): | ||
"""Default processors to apply""" | ||
return [DocLengthFilterConfig()] | ||
|
||
|
||
@config_class | ||
class AgregatorConfig(Config, Applicable): | ||
steps: list[ShardProcessorConfig] = Field(default_factory=default_processors) | ||
|
||
def apply(self, dataset: datasets.Dataset) -> datasets.Dataset: | ||
from fast_llm.data.preparator.hf_processors.implementations.agregator import apply | ||
return apply(self, dataset) | ||
|
||
|
This file contains hidden or 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,19 @@ | ||
import abc | ||
import typing | ||
import datasets | ||
|
||
from fast_llm.config import TypeableConfig, config_class | ||
from fast_llm.utils import Registry | ||
|
||
|
||
class Applicable: | ||
bigximik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@abc.abstractmethod | ||
def apply(self, dataset: datasets.Dataset) -> datasets.Dataset: | ||
raise NotImplementedError | ||
|
||
|
||
@config_class() | ||
class ShardProcessorConfig(TypeableConfig, Applicable): | ||
_registry: typing.ClassVar[Registry[str, type["ShardProcessorConfig"]] | None] = Registry( | ||
"ShardProcessorConfig", {} | ||
) |
22 changes: 22 additions & 0 deletions
22
fast_llm/data/preparator/hf_processors/configs/doc_length_filter.py
This file contains hidden or 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,22 @@ | ||
import abc | ||
import typing | ||
import datasets | ||
|
||
from fast_llm.data.preparator.hf_processors.configs.base import Applicable, ShardProcessorConfig | ||
from fast_llm.config import Field, config_class | ||
|
||
|
||
@config_class | ||
class DocLengthFilterConfig(ShardProcessorConfig): | ||
_abstract: typing.ClassVar[bool] = False | ||
type_: typing.ClassVar[str | None] = "length_filter" | ||
|
||
field: str = Field(default='text') | ||
min_length_chars: int = Field(default=0) | ||
max_length_chars: int = Field(default=1_000_000) | ||
|
||
def apply(self, dataset: datasets.Dataset) -> datasets.Dataset: | ||
from fast_llm.data.preparator.hf_processors.implementations.doc_length_filter import apply | ||
return apply(self, dataset) | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
fast_llm/data/preparator/hf_processors/implementations/agregator.py
This file contains hidden or 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,11 @@ | ||
import datasets | ||
|
||
from fast_llm.data.preparator.hf_processors.configs.agregator import AgregatorConfig | ||
|
||
def apply(config: AgregatorConfig, dataset: datasets.Dataset) -> datasets.Dataset: | ||
bigximik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# do something before applyting each processor | ||
for step in config.steps: | ||
dataset = step.apply(dataset) | ||
# compute metrics | ||
# save meterics, from all ranks? | ||
return dataset |
7 changes: 7 additions & 0 deletions
7
fast_llm/data/preparator/hf_processors/implementations/doc_length_filter.py
This file contains hidden or 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,7 @@ | ||
import datasets | ||
|
||
from fast_llm.data.preparator.hf_processors.configs.doc_length_filter import DocLengthFilterConfig | ||
|
||
def apply(config: DocLengthFilterConfig, dataset: datasets.Dataset) -> datasets.Dataset: | ||
# do dataset.filter eliminating too long or too short docs | ||
return dataset |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.