code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def __init__(self,
api_model: str = 'gpt-4o',
meta_tag_key: str = MetaKeys.dialog_sentiment_labels,
target_tags: Optional[List[str]] = None,
*,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
... |
Initialization method.
:param api_model: API model name.
:param meta_tag_key: The key of the meta tag to be mapped.
:param target_tags: The tags that is supposed to be mapped to.
:param api_endpoint: URL endpoint for the API.
:param response_path: Path to extract content... | __init__ | python | modelscope/data-juicer | data_juicer/ops/aggregator/meta_tags_aggregator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/aggregator/meta_tags_aggregator.py | Apache-2.0 |
def strip(document, strip_characters):
"""
Way faster than document.strip(strip_characters) since strip_characters is
now a set instead of a str, and it contains a lot of elements (all the
emojis).
:param document: document to be processed
:param strip_characters: characters used for stripping ... |
Way faster than document.strip(strip_characters) since strip_characters is
now a set instead of a str, and it contains a lot of elements (all the
emojis).
:param document: document to be processed
:param strip_characters: characters used for stripping document
:return: stripped document
| strip | python | modelscope/data-juicer | data_juicer/ops/common/helper_func.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/helper_func.py | Apache-2.0 |
def split_on_whitespace(document, new_line=False, tab=False):
"""
This method also removes concatenated spaces.
:param document: document to be split
:param new_line: whether to split document with '\\\\n'
:param tag: whether to split document with '\\\\t'
:return: word list obtained after spli... |
This method also removes concatenated spaces.
:param document: document to be split
:param new_line: whether to split document with '\\n'
:param tag: whether to split document with '\\t'
:return: word list obtained after splitting document
| split_on_whitespace | python | modelscope/data-juicer | data_juicer/ops/common/helper_func.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/helper_func.py | Apache-2.0 |
def split_on_newline_tab_whitespace(document):
"""
This method is used to split the document into different levels of sub-
sentences.
First split on "\\\\n", then on "\\\\t", then on " ".
:param document: document to be split
:return: sentence list obtained after splitting document
"""
... |
This method is used to split the document into different levels of sub-
sentences.
First split on "\\n", then on "\\t", then on " ".
:param document: document to be split
:return: sentence list obtained after splitting document
| split_on_newline_tab_whitespace | python | modelscope/data-juicer | data_juicer/ops/common/helper_func.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/helper_func.py | Apache-2.0 |
def merge_on_whitespace_tab_newline(sentences):
"""
This method is used to merge different levels of sub-sentences into one
document. Invert the method split_on_newline_tab_whitespace. Removes
concatenated separators.
:param sentences: sentence list to be merged
:return: document obtained after... |
This method is used to merge different levels of sub-sentences into one
document. Invert the method split_on_newline_tab_whitespace. Removes
concatenated separators.
:param sentences: sentence list to be merged
:return: document obtained after merging sub-sentences
| merge_on_whitespace_tab_newline | python | modelscope/data-juicer | data_juicer/ops/common/helper_func.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/helper_func.py | Apache-2.0 |
def words_augmentation(words, group_size, join_char):
"""
Augment words, especially for Chinese (without a space between words) and
Vietnamese (with a space between syllables).
:param word: word list to be augmented
:param group_size: the size of word groups that need to be merged
:param join_c... |
Augment words, especially for Chinese (without a space between words) and
Vietnamese (with a space between syllables).
:param word: word list to be augmented
:param group_size: the size of word groups that need to be merged
:param join_char: characters to be added between word group
:return: w... | words_augmentation | python | modelscope/data-juicer | data_juicer/ops/common/helper_func.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/helper_func.py | Apache-2.0 |
def get_words_from_document(
document,
token_func=None,
new_line=True,
tab=True,
):
"""
Get words from a document. Useful to compute ratios, like the
stopwords ratio.
:param document: document that need to split words.
:param token_func: function of tokenizer, if specified, the func... |
Get words from a document. Useful to compute ratios, like the
stopwords ratio.
:param document: document that need to split words.
:param token_func: function of tokenizer, if specified, the function
will be used for split document into different tokens.
:param new_line: whether to use '\\n' ... | get_words_from_document | python | modelscope/data-juicer | data_juicer/ops/common/helper_func.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/helper_func.py | Apache-2.0 |
def words_refinement(words,
lower_case=False,
strip_chars=None,
use_words_aug=False,
words_aug_group_sizes=[2],
words_aug_join_char=''):
"""
Refine split words. Non reversible since the document is split on
... |
Refine split words. Non reversible since the document is split on
multiple characters, words are stripped of special characters and
characters are converted to lower case.
:param words: the word list to be augmented
:param lower_case: whether to convert word to lowercase
:param strip_chars: ch... | words_refinement | python | modelscope/data-juicer | data_juicer/ops/common/helper_func.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/helper_func.py | Apache-2.0 |
def get_sentences_from_document(document, model_func=None):
"""
Get sentences from a document.
:param document: document that need to split sentences
:param model_func: function of sentence model, if specified, the
function will be used for splitting document into different
sentences.
... |
Get sentences from a document.
:param document: document that need to split sentences
:param model_func: function of sentence model, if specified, the
function will be used for splitting document into different
sentences.
:return: document with the sentences separated by '\\n'
| get_sentences_from_document | python | modelscope/data-juicer | data_juicer/ops/common/helper_func.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/helper_func.py | Apache-2.0 |
def split_text_by_punctuation(text):
"""
Split text by any zh and en punctuation
:param text: text to be split.
:return: sub texts split by any zh and en punctuation
"""
# any zh and en punctuation
punctuation_pattern = r'[\u3000-\u303f\uff00-\uffef]|[!"#$%&\'()*+,-./:;<=>?@[\\\]^_`{|}~]' ... |
Split text by any zh and en punctuation
:param text: text to be split.
:return: sub texts split by any zh and en punctuation
| split_text_by_punctuation | python | modelscope/data-juicer | data_juicer/ops/common/helper_func.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/helper_func.py | Apache-2.0 |
def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
"""
Rescale `noise_cfg` according to `guidance_rescale`. Based on
findings of [Common Diffusion Noise Schedules and
Sample Steps are Flawed](https://arxiv.org/pdf/2305.08891.pdf).
See Section 3.4
"""
std_text = noise_p... |
Rescale `noise_cfg` according to `guidance_rescale`. Based on
findings of [Common Diffusion Noise Schedules and
Sample Steps are Flawed](https://arxiv.org/pdf/2305.08891.pdf).
See Section 3.4
| rescale_noise_cfg | python | modelscope/data-juicer | data_juicer/ops/common/prompt2prompt_pipeline.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/common/prompt2prompt_pipeline.py | Apache-2.0 |
def __init__(self,
lowercase: bool = False,
ignore_non_character: bool = False,
*args,
**kwargs):
"""
Initialization method.
:param lowercase: Whether to convert sample text to lower case
:param ignore_non_character: Wh... |
Initialization method.
:param lowercase: Whether to convert sample text to lower case
:param ignore_non_character: Whether to ignore non-alphabet
characters, including whitespaces, digits, and punctuations
:param args: extra args
:param kwargs: extra args.
| __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_deduplicator.py | Apache-2.0 |
def compute_hash(self, sample):
"""
Compute md5 hash values for the sample.
:param sample: input sample
:return: sample with md5 hash value.
"""
# check if it's computed already
if HashKeys.hash in sample:
return sample
text = sample[self.tex... |
Compute md5 hash values for the sample.
:param sample: input sample
:return: sample with md5 hash value.
| compute_hash | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_deduplicator.py | Apache-2.0 |
def process(self, dataset, show_num=0):
"""
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
"""
# no n... |
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
| process | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_deduplicator.py | Apache-2.0 |
def optimal_param(
threshold: float,
num_perm: int,
false_positive_weight: float = 0.5,
false_negative_weight: float = 0.5,
):
"""
Compute the optimal `MinHashLSH` parameter that minimizes the weighted sum
of probabilities of false positive and false negative, taken from
datasketch.
... |
Compute the optimal `MinHashLSH` parameter that minimizes the weighted sum
of probabilities of false positive and false negative, taken from
datasketch.
:param threshold: float. The threshold for similarity
:param num_perm: int. The number of permutations
:param false_positive_weight: float. T... | optimal_param | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_minhash_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_minhash_deduplicator.py | Apache-2.0 |
def __init__(
self,
tokenization: str = 'space',
window_size: PositiveInt = 5,
lowercase: bool = True,
ignore_pattern: Optional[str] = None,
num_permutations: PositiveInt = 256,
jaccard_threshold: Annotated[float, Field(ge=0, le=1)] = 0.7,
num_bands: Optio... |
Initialization method.
:param tokenization: tokenization method for sample texts. It
should be one of [space, punctuation, character,
sentencepiece]. For English-like languages, we recommend
to use 'space', for Chinese-like languages, we recommend
to use... | __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_minhash_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_minhash_deduplicator.py | Apache-2.0 |
def compute_hash(self, sample):
"""
Compute minhash values for the sample.
:param sample: input sample
:return: sample with minhash value.
"""
# check if it's computed already
if HashKeys.minhash in sample:
return sample
text = sample[self.te... |
Compute minhash values for the sample.
:param sample: input sample
:return: sample with minhash value.
| compute_hash | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_minhash_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_minhash_deduplicator.py | Apache-2.0 |
def process(self, dataset, show_num=0):
"""
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
"""
# no n... |
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
| process | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_minhash_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_minhash_deduplicator.py | Apache-2.0 |
def __init__(self,
tokenization: str = 'space',
window_size: PositiveInt = 6,
lowercase: bool = True,
ignore_pattern: Optional[str] = None,
num_blocks: PositiveInt = 6,
hamming_distance: PositiveInt = 4,
... |
Initialization method :param tokenization: tokenization method for
sample texts.
It should be one of [space, punctuation, character]. For
English-like languages, we recommend to use 'space'. And for
Chinese-like languages, we recommend to use 'character'
:param window_... | __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_simhash_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_simhash_deduplicator.py | Apache-2.0 |
def compute_hash(self, sample):
"""
Compute simhash values for the sample.
:param sample: input sample
:return: sample with simhash value.
"""
# check if it's computed already
if HashKeys.simhash in sample:
return sample
text = sample[self.te... |
Compute simhash values for the sample.
:param sample: input sample
:return: sample with simhash value.
| compute_hash | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_simhash_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_simhash_deduplicator.py | Apache-2.0 |
def process(self, dataset, show_num=0):
"""
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
"""
# no n... |
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
| process | python | modelscope/data-juicer | data_juicer/ops/deduplicator/document_simhash_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/document_simhash_deduplicator.py | Apache-2.0 |
def __init__(self,
method: str = 'phash',
consider_text: bool = False,
*args,
**kwargs):
"""
Initialization method.
:param method: hash method for image
:param consider_text: whether to consider text hash together with ... |
Initialization method.
:param method: hash method for image
:param consider_text: whether to consider text hash together with image
hash when applying deduplication.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/image_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/image_deduplicator.py | Apache-2.0 |
def process(self, dataset, show_num=0):
"""
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
"""
# no n... |
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
| process | python | modelscope/data-juicer | data_juicer/ops/deduplicator/image_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/image_deduplicator.py | Apache-2.0 |
def __init__(self,
backend: str = 'ray_actor',
redis_address: str = 'redis://localhost:6379',
*args,
**kwargs):
"""
Initialization.
:param backend: the backend for dedup, either 'ray_actor' or 'redis'
:param redis_addres... |
Initialization.
:param backend: the backend for dedup, either 'ray_actor' or 'redis'
:param redis_address: the address of redis server
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/ray_basic_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/ray_basic_deduplicator.py | Apache-2.0 |
def get_remote_classes():
"""Get remote versions of classes with Ray decorators applied at runtime."""
# Apply ray.method decorator to get_next_id at runtime
IdGenerator.get_next_id = ray.method(num_returns=2)(
IdGenerator.get_next_id)
return {
'IdGenerator': ray.remote(IdGenerator),
... | Get remote versions of classes with Ray decorators applied at runtime. | get_remote_classes | python | modelscope/data-juicer | data_juicer/ops/deduplicator/ray_bts_minhash_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/ray_bts_minhash_deduplicator.py | Apache-2.0 |
def __init__(
self,
tokenization: str = 'space',
window_size: PositiveInt = 5,
lowercase: bool = True,
ignore_pattern: Optional[str] = None,
num_permutations: PositiveInt = 256,
jaccard_threshold: Annotated[float, Field(ge=0, le=1)] = 0.7,
num_bands: Optio... |
Initialization method.
:param tokenization: tokenization method for sample texts. It
should be one of [space, punctuation, character,
sentencepiece]. For English-like languages, we recommend
to use 'space', for Chinese-like languages, we recommend
to use... | __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/ray_bts_minhash_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/ray_bts_minhash_deduplicator.py | Apache-2.0 |
def __init__(self,
backend: str = 'ray_actor',
redis_address: str = 'redis://localhost:6379',
lowercase: bool = False,
ignore_non_character: bool = False,
*args,
**kwargs):
"""
Initialization method.
... |
Initialization method.
:param backend: the backend for dedup, either 'ray_actor' or 'redis'
:param redis_address: the address of redis server
:param lowercase: Whether to convert sample text to lower case
:param ignore_non_character: Whether to ignore non-alphabet
charac... | __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/ray_document_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/ray_document_deduplicator.py | Apache-2.0 |
def __init__(self,
backend: str = 'ray_actor',
redis_address: str = 'redis://localhost:6379',
method: str = 'phash',
*args,
**kwargs):
"""
Initialization.
:param backend: the backend for dedup, either 'ray_actor... |
Initialization.
:param backend: the backend for dedup, either 'ray_actor' or 'redis'
:param redis_address: the address of redis server
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/ray_image_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/ray_image_deduplicator.py | Apache-2.0 |
def __init__(self,
backend: str = 'ray_actor',
redis_address: str = 'redis://localhost:6379',
*args,
**kwargs):
"""
Initialization.
:param backend: the backend for dedup, either 'ray_actor' or 'redis'
:param redis_addres... |
Initialization.
:param backend: the backend for dedup, either 'ray_actor' or 'redis'
:param redis_address: the address of redis server
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/ray_video_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/ray_video_deduplicator.py | Apache-2.0 |
def __init__(self, consider_text: bool = False, *args, **kwargs):
"""
Initialization.
:param consider_text: whether to consider text hash together with video
hash when applying deduplication.
:param args: extra args
:param kwargs: extra args
"""
super... |
Initialization.
:param consider_text: whether to consider text hash together with video
hash when applying deduplication.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/deduplicator/video_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/video_deduplicator.py | Apache-2.0 |
def process(self, dataset, show_num=0):
"""
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
"""
# no n... |
For doc-level, dataset --> dataset.
:param dataset: input dataset
:param show_num: number of traced samples used when tracer is
open.
:return: deduplicated dataset and the sampled duplicate pairs.
| process | python | modelscope/data-juicer | data_juicer/ops/deduplicator/video_deduplicator.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/deduplicator/video_deduplicator.py | Apache-2.0 |
def __init__(self,
tokenization: bool = False,
min_ratio: float = 0.25,
max_ratio: float = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param tokenization: Whether to count the ratio of alphanumer... |
Initialization method.
:param tokenization: Whether to count the ratio of alphanumeric
to the total number of tokens. if tokenization=False, it
will count the ratio of alphanumeric to the total number of
characters.
:param min_ratio: The min filter ratio in ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/alphanumeric_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/alphanumeric_filter.py | Apache-2.0 |
def __init__(self,
min_duration: int = 0,
max_duration: int = sys.maxsize,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
:param min_duration: The min audio duration to keep samples in se... |
Initialization method.
:param min_duration: The min audio duration to keep samples in seconds.
It's 0 by default.
:param max_duration: The max audio duration to keep samples in seconds.
It's sys.maxsize by default.
:param any_or_all: keep this sample with 'any' ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/audio_duration_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/audio_duration_filter.py | Apache-2.0 |
def __init__(self,
min_snr: float = 0,
max_snr: float = sys.maxsize,
nmf_iter_num: PositiveInt = 500,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
:param min_snr: The m... |
Initialization method.
:param min_snr: The min audio SNR to keep samples in dB. It's 0 by
default.
:param max_snr: The max audio SNR to keep samples in dB. It's
sys.maxsize by default.
:param nmf_iter_num: The max number of iterations to run NMF. It's 500
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/audio_nmf_snr_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/audio_nmf_snr_filter.py | Apache-2.0 |
def __init__(self,
min_len: int = 10,
max_len: int = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param min_len: The min filter length in this op, samples will
be filtered if their average line length ... |
Initialization method.
:param min_len: The min filter length in this op, samples will
be filtered if their average line length is below this
parameter.
:param max_len: The max filter length in this op, samples will
be filtered if their average line length ex... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/average_line_length_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/average_line_length_filter.py | Apache-2.0 |
def __init__(self,
rep_len: PositiveInt = 10,
min_ratio: float = 0.0,
max_ratio: float = 0.5,
*args,
**kwargs):
"""
Initialization method.
:param rep_len: Repetition length for char-level n-gram.
:param... |
Initialization method.
:param rep_len: Repetition length for char-level n-gram.
:param min_ratio: The min filter ratio in this op, samples will
be filtered if their char-level n-gram repetition ratio is
below this parameter.
:param max_ratio: The max filter rati... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/character_repetition_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/character_repetition_filter.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
tokenization: bool = False,
max_ratio: float = 0.045,
flagged_words_dir: str = ASSET_DIR,
use_words_aug: bool = False,
words_aug_group_sizes: List[PositiveInt] = [2],
... |
Initialization method.
:param lang: Consider flagged words in what language. If lang ==
"all", we will adopt the one merged from all the available
languages
:param tokenization: Whether to use model to tokenize documents
:param max_ratio: The max filter ratio in... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/flagged_words_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/flagged_words_filter.py | Apache-2.0 |
def __init__(self, filter_condition: str = '', *args, **kwargs):
"""
Initialization method.
:param filter_condition: The filter condition as a string.
It can include logical operators (and/or) and chain comparisons.
For example: "10 < num <= 30 and text != 'nothing here' ... |
Initialization method.
:param filter_condition: The filter condition as a string.
It can include logical operators (and/or) and chain comparisons.
For example: "10 < num <= 30 and text != 'nothing here' and __dj__meta__.a == 3".
| __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/general_field_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/general_field_filter.py | Apache-2.0 |
def __init__(self,
hf_scorer_model: str = '',
trust_remote_code: bool = False,
min_score: float = 0.5,
max_score: float = 1.0,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initializat... |
Initialization method.
:param hf_scorer_model: Huggingface model name for the aesthetics
predictor. By default, we will use
'shunk031/aesthetics-predictor-v2-sac-logos-ava1-l14-linearMSE',
refer to pypi.org/project/simple-aesthetics-predictor
:param min_scor... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_aesthetics_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_aesthetics_filter.py | Apache-2.0 |
def __init__(self,
min_ratio: float = 0.333,
max_ratio: float = 3.0,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
:param min_ratio: The min aspect ratio to keep samples.
:param ... |
Initialization method.
:param min_ratio: The min aspect ratio to keep samples.
:param max_ratio: The max aspect ratio to keep samples.
:param any_or_all: keep this sample with 'any' or 'all' strategy of
all images. 'any': keep this sample if any images meet the
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_aspect_ratio_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_aspect_ratio_filter.py | Apache-2.0 |
def __init__(self,
cv_classifier: str = '',
min_face_count: int = 1,
max_face_count: int = 1,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
:param cv_classifier: OpenCV ... |
Initialization method.
:param cv_classifier: OpenCV classifier path for face detection.
By default, we will use 'haarcascade_frontalface_alt.xml'.
:param min_face_count: Minimum number of faces required for samples.
:param max_face_count: Maximum number of faces required fo... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_face_count_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_face_count_filter.py | Apache-2.0 |
def __init__(self,
cv_classifier: str = '',
min_ratio: float = 0.0,
max_ratio: float = 0.4,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
:param cv_classifier: OpenCV cl... |
Initialization method.
:param cv_classifier: OpenCV classifier path for face detection.
By default, we will use 'haarcascade_frontalface_alt.xml'.
:param min_ratio: Min ratio for the largest face area in an image.
:param max_ratio: Max ratio for the largest face area in an ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_face_ratio_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_face_ratio_filter.py | Apache-2.0 |
def __init__(self,
hf_nsfw_model: str = 'Falconsai/nsfw_image_detection',
trust_remote_code: bool = False,
max_score: float = 0.5,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
... |
Initialization method.
:param hf_nsfw_model: nsfw detection model name on huggingface.
:param max_score: the nsfw score threshold for samples.
range from 0 to 1. Samples with nsfw score less than this threshold
will be kept.
:param any_or_all: keep this sample w... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_nsfw_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_nsfw_filter.py | Apache-2.0 |
def __init__(self,
hf_clip='openai/clip-vit-base-patch32',
trust_remote_code=False,
min_score: ClosedUnitInterval = 0.1,
max_score: ClosedUnitInterval = 1.0,
any_or_all: str = 'any',
*args,
**kwargs):
... |
Initialization method.
:param hf_clip: clip model name on huggingface to compute
the similarity between image and text.
:param min_score: The min similarity to keep samples.
:param max_score: The max similarity to keep samples.
:param any_or_all: keep this sample wi... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_pair_similarity_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_pair_similarity_filter.py | Apache-2.0 |
def __init__(self,
min_width: int = 1,
max_width: int = sys.maxsize,
min_height: int = 1,
max_height: int = sys.maxsize,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization me... |
Initialization method.
:param min_width: The min width to keep samples.
:param max_width: The max width to keep samples.
:param min_height: The min height to keep samples.
:param max_height: The max height to keep samples.
:param any_or_all: keep this sample with 'any' ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_shape_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_shape_filter.py | Apache-2.0 |
def __init__(self,
hf_blip: str = 'Salesforce/blip-itm-base-coco',
trust_remote_code: bool = False,
min_score: float = 0.003,
max_score: float = 1.0,
horizontal_flip: bool = False,
vertical_flip: bool = False,
... |
Initialization method.
:param hf_blip: blip model name on huggingface to compute
the matching score between image and text.
:param min_score: The min matching score to keep samples.
:param max_score: The max matching score to keep samples.
:param horizontal_flip: Fl... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_text_matching_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_text_matching_filter.py | Apache-2.0 |
def __init__(self,
hf_clip: str = 'openai/clip-vit-base-patch32',
trust_remote_code: bool = False,
min_score: float = 0.1,
max_score: float = 1.0,
horizontal_flip: bool = False,
vertical_flip: bool = False,
... |
Initialization method.
:param hf_clip: clip model name on huggingface to compute
the similarity between image and text.
:param min_score: The min similarity to keep samples.
:param max_score: The max similarity to keep samples.
:param horizontal_flip: Flip image hor... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_text_similarity_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_text_similarity_filter.py | Apache-2.0 |
def __init__(self,
hf_watermark_model: str = 'amrul-hzz/watermark_detector',
trust_remote_code: bool = False,
prob_threshold: float = 0.8,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization m... |
Initialization method.
:param hf_watermark_model: watermark detection model name on
huggingface.
:param prob_threshold: the predicted watermark probability threshold
for samples. range from 0 to 1. Samples with watermark probability
less than this threshold ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/image_watermark_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/image_watermark_filter.py | Apache-2.0 |
def __init__(self,
lang: Union[str, List[str]] = '',
min_score: float = 0.8,
*args,
**kwargs):
"""
Initialization method.
:param lang: Samples in which languages to keep.
:param min_score: The min language identificatio... |
Initialization method.
:param lang: Samples in which languages to keep.
:param min_score: The min language identification confidence
scores of samples to keep.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/language_id_score_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/language_id_score_filter.py | Apache-2.0 |
def __init__(self,
api_or_hf_model: str = 'gpt-4o',
min_score: float = 0.5,
is_hf_model: bool = False,
*,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
input_keys: List[str] ... |
Initialization method.
:param api_or_hf_model: API or huggingface model name.
:param min_score: The lowest difficulty score threshold to keep
the sample.
:param api_endpoint: URL endpoint for the API.
:param response_path: Path to extract content from the API respon... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/llm_difficulty_score_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/llm_difficulty_score_filter.py | Apache-2.0 |
def __init__(self,
api_or_hf_model: str = 'gpt-4o',
min_score: float = 0.5,
is_hf_model: bool = False,
*,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
input_keys: List[str] ... |
Initialization method.
:param api_or_hf_model: API or huggingface model name.
:param min_score: The lowest quality score threshold to keep the
sample.
:param api_endpoint: URL endpoint for the API.
:param response_path: Path to extract content from the API response.... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/llm_quality_score_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/llm_quality_score_filter.py | Apache-2.0 |
def __init__(self,
min_len: int = 10,
max_len: int = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param min_len: The min filter length in this op, samples will
be filtered if their maximum line length ... |
Initialization method.
:param min_len: The min filter length in this op, samples will
be filtered if their maximum line length is below this
parameter.
:param max_len: The max filter length in this op, samples will
be filtered if their maximum line length ex... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/maximum_line_length_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/maximum_line_length_filter.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
max_ppl: float = 1500,
*args,
**kwargs):
"""
Initialization method.
:param lang: Compute perplexity for samples in which language.
:param max_ppl: The max filter perplexity in this o... |
Initialization method.
:param lang: Compute perplexity for samples in which language.
:param max_ppl: The max filter perplexity in this op, samples
will be filtered if their perplexity exceeds this parameter.
:param args: extra args
:param kwargs: extra args
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/perplexity_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/perplexity_filter.py | Apache-2.0 |
def __init__(self,
hf_owlvit: str = 'google/owlvit-base-patch32',
trust_remote_code: bool = False,
min_recall: float = 0.1,
max_recall: float = 1.0,
horizontal_flip: bool = False,
vertical_flip: bool = False,
... |
Initialization method.
:param hf_owlvit: Owl-ViT model name on huggingface to locate the
phrases extracted from the text.
:param min_recall: The min phrase grounding recall to keep samples.
:param max_recall: The max phrase grounding recall to keep samples.
:param h... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/phrase_grounding_recall_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/phrase_grounding_recall_filter.py | Apache-2.0 |
def __init__(self,
min_ratio: float = 0.0,
max_ratio: float = 0.25,
*args,
**kwargs):
"""
Initialization method.
:param min_ratio: The min filter ratio in this op, samples will
be filtered if their special-char rati... |
Initialization method.
:param min_ratio: The min filter ratio in this op, samples will
be filtered if their special-char ratio is below this
parameter.
:param max_ratio: The max filter ratio in this op, samples will
be filtered if their special-char ratio ex... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/special_characters_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/special_characters_filter.py | Apache-2.0 |
def __init__(self,
field_key: str = '',
target_value: List = [],
*args,
**kwargs):
"""
Initialization method.
:param field_key: Filter based on the specified value
corresponding to the target key. The target key
... |
Initialization method.
:param field_key: Filter based on the specified value
corresponding to the target key. The target key
corresponding to multi-level field information need to be
separated by '.'.
:param target_value: The range of specified field informa... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/specified_field_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/specified_field_filter.py | Apache-2.0 |
def __init__(self,
field_key: str = '',
min_value: float = -sys.maxsize,
max_value: float = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param field_key: Filter based on the specified numeric valu... |
Initialization method.
:param field_key: Filter based on the specified numeric value
corresponding to the target key. The target key
corresponding to multi-level field information need to be
separated by '.'.
:param min_value: The min filter value in Specifi... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/specified_numeric_field_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/specified_numeric_field_filter.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
tokenization: bool = False,
min_ratio: float = 0.3,
stopwords_dir: str = ASSET_DIR,
use_words_aug: bool = False,
words_aug_group_sizes: List[PositiveInt] = [2],
wor... |
Initialization method.
:param lang: Consider stopwords in what language. If lang ==
"all", we will adopt the one merged from all the available
languages
:param tokenization: whether to use model to tokenize documents
:param min_ratio: The min filter ratio in thi... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/stopwords_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/stopwords_filter.py | Apache-2.0 |
def __init__(self, suffixes: Union[str, List[str]] = [], *args, **kwargs):
"""
Initialization method.
:param suffixes: the suffix of text that will be keep.
For example: '.txt', 'txt' or ['txt', '.pdf', 'docx']
:param args: extra args
:param kwargs: extra args
... |
Initialization method.
:param suffixes: the suffix of text that will be keep.
For example: '.txt', 'txt' or ['txt', '.pdf', 'docx']
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/suffix_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/suffix_filter.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
min_action_num: int = 1,
*args,
**kwargs):
"""
Initialization method.
:param lang: language of the text in the samples. 'en' for detection of
actions in English and 'zh' for dete... |
Initialization method.
:param lang: language of the text in the samples. 'en' for detection of
actions in English and 'zh' for detection of actions in Chinese.
:param mini_action_num: The min action number in the filtering. samples
will be filtered if their action numbe... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/text_action_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/text_action_filter.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
min_dependency_num: int = 1,
any_or_all: str = 'all',
*args,
**kwargs):
"""
Initialization method.
:param lang: language of the text in the samples. 'en' for detection of
... |
Initialization method.
:param lang: language of the text in the samples. 'en' for detection of
entities in English and 'zh' for detection of entities in Chinese.
:param mini_dependency_num: The min token number in the filtering.
Objects is independent if their number of... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/text_entity_dependency_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/text_entity_dependency_filter.py | Apache-2.0 |
def __init__(self,
min_len: int = 10,
max_len: int = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param min_len: The min text length in the filtering. samples
will be filtered if their text length is b... |
Initialization method.
:param min_len: The min text length in the filtering. samples
will be filtered if their text length is below this
parameter.
:param max_len: The max text length in the filtering. samples
will be filtered if their text length exceeds th... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/text_length_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/text_length_filter.py | Apache-2.0 |
def __init__(self,
hf_clip='openai/clip-vit-base-patch32',
trust_remote_code=False,
min_score: ClosedUnitInterval = 0.1,
max_score: ClosedUnitInterval = 1.0,
text_key_second=None,
any_or_all: str = 'any',
... |
Initialization method.
:param hf_clip: clip model name on huggingface to compute
the similarity between image and text.
:param min_score: The min similarity to keep samples.
:param max_score: The max similarity to keep samples.
:param text_key_second: used to store the ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/text_pair_similarity_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/text_pair_similarity_filter.py | Apache-2.0 |
def __init__(self,
hf_tokenizer: str = 'EleutherAI/pythia-6.9b-deduped',
min_num: int = 10,
max_num: int = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param hf_tokenizer: the tokenizer name of Hu... |
Initialization method.
:param hf_tokenizer: the tokenizer name of Hugging Face tokenizers.
:param min_num: The min filter token number in this op, samples
will be filtered if their token number is below this
parameter.
:param max_num: The max filter token number... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/token_num_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/token_num_filter.py | Apache-2.0 |
def __init__(self,
hf_scorer_model: str = '',
trust_remote_code: bool = False,
min_score: float = 0.4,
max_score: float = 1.0,
frame_sampling_method: str = 'uniform',
frame_num: PositiveInt = 3,
any_or... |
Initialization method.
:param hf_scorer_model: Huggingface model name for the aesthetics
predictor. By default, we will use
'shunk031/aesthetics-predictor-v2-sac-logos-ava1-l14-linearMSE',
refer to pypi.org/project/simple-aesthetics-predictor
:param min_scor... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_aesthetics_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_aesthetics_filter.py | Apache-2.0 |
def __init__(self,
min_ratio: str = '9/21',
max_ratio: str = '21/9',
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
:param min_ratio: The minimum aspect ratio to keep samples,
... |
Initialization method.
:param min_ratio: The minimum aspect ratio to keep samples,
supported format is a string, such as "9:21" or "9/21".
:param max_ratio: The maximum aspect ratio to keep samples,
supported format is a string, such as "21:9" or "21/9".
:param ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_aspect_ratio_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_aspect_ratio_filter.py | Apache-2.0 |
def __init__(self,
min_duration: float = 0,
max_duration: float = sys.maxsize,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization method.
:param min_duration: The min video duration to keep samples i... |
Initialization method.
:param min_duration: The min video duration to keep samples in seconds.
It's 0 by default.
:param max_duration: The max video duration to keep samples in seconds.
It's sys.maxsize by default.
:param any_or_all: keep this sample with 'any' ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_duration_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_duration_filter.py | Apache-2.0 |
def __init__(self,
hf_clip='openai/clip-vit-base-patch32',
trust_remote_code=False,
min_score: float = 0.1,
max_score: float = 1.0,
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
... |
Initialization method.
:param hf_clip: clip model name on huggingface to compute
the similarity between frame image and text. It's kind of
language-related. For example, for Chinese datasets, ChineseCLIP
might be a better choice.
:param min_score: the min si... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_frames_text_similarity_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_frames_text_similarity_filter.py | Apache-2.0 |
def __init__(self,
min_score: float = 0.25,
max_score: float = sys.float_info.max,
sampling_fps: PositiveFloat = 2,
size: Union[PositiveInt, Tuple[PositiveInt],
Tuple[PositiveInt, PositiveInt], None] = None,
... |
Initialization method.
:param min_score: The minimum motion score to keep samples.
:param max_score: The maximum motion score to keep samples.
:param sampling_fps: The sampling rate in frames_per_second for
optical flow calculations.
:param size: Resize frames befor... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_motion_score_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_motion_score_filter.py | Apache-2.0 |
def __init__(self,
hf_nsfw_model: str = 'Falconsai/nsfw_image_detection',
trust_remote_code: bool = False,
max_score: float = 0.5,
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
reduce_mode: ... |
Initialization method.
:param hf_nsfw_model: nsfw detection model name on huggingface.
:param max_score: the nsfw score threshold for samples.
range from 0 to 1. Samples with nsfw score less than this threshold
will be kept.
:param frame_sampling_method: samplin... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_nsfw_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_nsfw_filter.py | Apache-2.0 |
def triangle_area(p1, p2, p3):
"""
Compute the triangle area according to its coordinates.
"""
x1, y1 = p1
x2, y2 = p2
x3, y3 = p3
tri_area = 0.5 * np.abs(x1 * y2 + x2 * y3 + x3 * y1 - x2 * y1 - x3 * y2 -
x1 * y3)
return tri_area |
Compute the triangle area according to its coordinates.
| triangle_area | python | modelscope/data-juicer | data_juicer/ops/filter/video_ocr_area_ratio_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_ocr_area_ratio_filter.py | Apache-2.0 |
def __init__(self,
min_area_ratio: float = 0,
max_area_ratio: float = 1.0,
frame_sample_num: PositiveInt = 3,
languages_to_detect: Union[str, List[str]] = ['ch_sim', 'en'],
any_or_all: str = 'any',
*args,
... |
Initialization method.
:param min_area_ratio: The min ocr area ratio to keep samples. It's 0
by default.
:param max_area_ratio: The max ocr area ratio to keep samples. It's 1.0
by default.
:param frame_sample_num: The number of sampled frames to calculate the
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_ocr_area_ratio_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_ocr_area_ratio_filter.py | Apache-2.0 |
def __init__(self,
min_width: int = 1,
max_width: int = sys.maxsize,
min_height: int = 1,
max_height: int = sys.maxsize,
any_or_all: str = 'any',
*args,
**kwargs):
"""
Initialization me... |
Initialization method.
:param min_width: The min horizontal resolution.
:param max_width: The max horizontal resolution.
:param min_height: The min vertical resolution.
:param max_height: The max vertical resolution.
:param any_or_all: keep this sample with 'any' or 'al... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_resolution_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_resolution_filter.py | Apache-2.0 |
def __init__(self,
tags: List[str] = ['people'],
contain: str = 'any',
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
tag_field_name: str = MetaKeys.video_frame_tags,
any_or_all: str = 'any',... |
Initialization method.
:param tags: a tag list to shift the videos, total tags can be found
in https://github.com/xinyu1205/recognize-anything/blob/main/ram/data/ram_tag_list.txt # noqa: E501
:param contain: require the videos containing 'any' or 'all' tags.
When tags e... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_tagging_from_frames_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_tagging_from_frames_filter.py | Apache-2.0 |
def __init__(self,
hf_watermark_model: str = 'amrul-hzz/watermark_detector',
trust_remote_code: bool = False,
prob_threshold: float = 0.8,
frame_sampling_method: str = 'all_keyframes',
frame_num: PositiveInt = 3,
reduc... |
Initialization method.
:param hf_watermark_model: watermark detection model name on
huggingface.
:param prob_threshold: the predicted watermark probability threshold
for samples. range from 0 to 1. Samples with watermark probability
less than this threshold ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/video_watermark_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/video_watermark_filter.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
tokenization: bool = False,
min_num: int = 10,
max_num: int = sys.maxsize,
*args,
**kwargs):
"""
Initialization method.
:param lang: sample in which languag... |
Initialization method.
:param lang: sample in which language.
:param tokenization: whether to use model to tokenize documents
:param min_num: The min filter word number in this op, samples
will be filtered if their word number is below this
parameter.
:p... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/words_num_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/words_num_filter.py | Apache-2.0 |
def __init__(self,
lang: str = 'en',
tokenization: bool = False,
rep_len: PositiveInt = 10,
min_ratio: float = 0.0,
max_ratio: float = 0.5,
*args,
**kwargs):
"""
Initialization method.
... |
Initialization method.
:param lang: sample in which language.
:param tokenization: whether to use model to tokenize documents
:param rep_len: Repetition length for word-level n-gram.
:param min_ratio: The min filter ratio in this op, samples will
be filtered if thei... | __init__ | python | modelscope/data-juicer | data_juicer/ops/filter/word_repetition_filter.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/filter/word_repetition_filter.py | Apache-2.0 |
def __init__(self,
group_by_keys: Optional[List[str]] = None,
*args,
**kwargs):
"""
Initialization method.
:param group_by_keys: group samples according values in the keys.
Support for nested keys such as "__dj__stats__.text_len".
... |
Initialization method.
:param group_by_keys: group samples according values in the keys.
Support for nested keys such as "__dj__stats__.text_len".
It is [self.text_key] in default.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/grouper/key_value_grouper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/grouper/key_value_grouper.py | Apache-2.0 |
def __init__(self, batch_meta_export_path=None, *args, **kwargs):
"""
Initialization method.
:param batch_meta_export_path: the path to export the batch meta.
Just drop the batch meta if it is None.
:param args: extra args
:param kwargs: extra args
"""
... |
Initialization method.
:param batch_meta_export_path: the path to export the batch meta.
Just drop the batch meta if it is None.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/grouper/naive_reverse_grouper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/grouper/naive_reverse_grouper.py | Apache-2.0 |
def __init__(self,
min_amplitude: float = 0.001,
max_amplitude: float = 0.015,
p: float = 0.5,
*args,
**kwargs):
"""
Initialization method.
min_amplitude: float unit: linear amplitude.
Default: 0.0... |
Initialization method.
min_amplitude: float unit: linear amplitude.
Default: 0.001. Minimum noise amplification factor.
max_amplitude: float unit: linear amplitude.
Default: 0.015. Maximum noise amplification factor.
p: float range: [0.0, 1.0]. Default: 0.5.
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/audio_add_gaussian_noise_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/audio_add_gaussian_noise_mapper.py | Apache-2.0 |
def __init__(
self,
filter_name: Optional[str] = None,
filter_kwargs: Optional[Dict] = None,
global_args: Optional[List[str]] = None,
capture_stderr: bool = True,
overwrite_output: bool = True,
*args,
**kwargs,
):
"""
Initialization met... |
Initialization method.
:param filter_name: ffmpeg audio filter name.
:param filter_kwargs: keyword-arguments passed to ffmpeg filter.
:param global_args: list-arguments passed to ffmpeg command-line.
:param capture_stderr: whether to capture stderr.
:param overwrite_out... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/audio_ffmpeg_wrapped_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/audio_ffmpeg_wrapped_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
*,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
system_prompt: Optional[str] = None,
input_template: Optional[str] = None,
refe... |
Initialization method.
:param api_model: API model name.
:param api_endpoint: URL endpoint for the API.
:param response_path: Path to extract content from the API response.
Defaults to 'choices.0.message.content'.
:param system_prompt: System prompt for the calibrat... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/calibrate_qa_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/calibrate_qa_mapper.py | Apache-2.0 |
def __init__(self, *args, **kwargs):
"""
Initialization method.
:param args: extra args
:param kwargs: extra args
"""
super().__init__(*args, **kwargs)
self.pat = re.compile('/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/')
self.cpat = re.compile('copyright', re.IGNOR... |
Initialization method.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/clean_copyright_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/clean_copyright_mapper.py | Apache-2.0 |
def __init__(self,
pattern: Optional[str] = None,
repl: str = '',
*args,
**kwargs):
"""
Initialization method.
:param pattern: regular expression pattern to search for within text.
:param repl: replacement string, defau... |
Initialization method.
:param pattern: regular expression pattern to search for within text.
:param repl: replacement string, default is empty string.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/clean_email_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/clean_email_mapper.py | Apache-2.0 |
def __init__(self,
pattern: Optional[str] = None,
repl: str = '',
*args,
**kwargs):
"""
Initialization method.
:param pattern: regular expression pattern to search for within text.
:param repl: replacement string, defau... |
Initialization method.
:param pattern: regular expression pattern to search for within text.
:param repl: replacement string, default is empty string.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/clean_ip_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/clean_ip_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
intent_candidates: Optional[List[str]] = None,
max_round: NonNegativeInt = 10,
*,
labels_key: str = MetaKeys.dialog_intent_labels,
analysis_key: str = MetaKeys.dialog_inten... |
Initialization method.
:param api_model: API model name.
:param intent_candidates: The output intent candidates. Use the
intent labels of the open domain if it is None.
:param max_round: The max num of round in the dialog to build the
prompt.
:param labe... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/dialog_intent_detection_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/dialog_intent_detection_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
sentiment_candidates: Optional[List[str]] = None,
max_round: NonNegativeInt = 10,
*,
labels_key: str = MetaKeys.dialog_sentiment_labels,
analysis_key: str = MetaKeys.dialog... |
Initialization method.
:param api_model: API model name.
:param sentiment_candidates: The output sentiment candidates. Use
open-domain sentiment labels if it is None.
:param max_round: The max num of round in the dialog to build the
prompt.
:param labels... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/dialog_sentiment_detection_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/dialog_sentiment_detection_mapper.py | Apache-2.0 |
def __init__(
self,
api_model: str = 'gpt-4o',
max_round: NonNegativeInt = 10,
*,
intensities_key: str = MetaKeys.dialog_sentiment_intensity,
analysis_key: str = MetaKeys.dialog_sentiment_intensity_analysis,
api_endpoint: Optional[str] ... |
Initialization method.
:param api_model: API model name.
:param max_round: The max num of round in the dialog to build the
prompt.
:param intensities_key: The key name in the meta field to store
the output sentiment intensities. It is
'dialog_sentime... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/dialog_sentiment_intensity_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/dialog_sentiment_intensity_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
topic_candidates: Optional[List[str]] = None,
max_round: NonNegativeInt = 10,
*,
labels_key: str = MetaKeys.dialog_topic_labels,
analysis_key: str = MetaKeys.dialog_topic_l... |
Initialization method.
:param api_model: API model name.
:param topic_candidates: The output topic candidates. Use
open-domain topic labels if it is None.
:param max_round: The max num of round in the dialog to build the
prompt.
:param labels_key: The ke... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/dialog_topic_detection_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/dialog_topic_detection_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
query_entities: List[str] = [],
query_attributes: List[str] = [],
*,
entity_key: str = MetaKeys.main_entities,
attribute_key: str = MetaKeys.attributes,
at... |
Initialization method.
:param api_model: API model name.
:param query_entities: Entity list to be queried.
:param query_attributes: Attribute list to be queried.
:param entity_key: The key name in the meta field to store the
given main entity for attribute extraction... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_entity_attribute_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_entity_attribute_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
*,
event_desc_key: str = MetaKeys.event_description,
relevant_char_key: str = MetaKeys.relevant_characters,
api_endpoint: Optional[str] = None,
response_path: Optional[str]... |
Initialization method.
:param api_model: API model name.
:param event_desc_key: The key name to store the event descriptions
in the meta field. It's "event_description" in default.
:param relevant_char_key: The field name to store the relevant
characters to the e... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_event_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_event_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
*,
nickname_key: str = MetaKeys.nickname,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
system_prompt: Optional[str] = None,
inp... |
Initialization method.
:param api_model: API model name.
:param nickname_key: The key name to store the nickname
relationship in the meta field. It's "nickname" in default.
:param api_endpoint: URL endpoint for the API.
:param response_path: Path to extract content f... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_nickname_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_nickname_mapper.py | Apache-2.0 |
def __init__(self,
api_model: str = 'gpt-4o',
*,
summary_key: str = MetaKeys.event_description,
support_text_key: str = MetaKeys.support_text,
api_endpoint: Optional[str] = None,
response_path: Optional[str] = None,
... |
Initialization method.
:param api_model: API model name.
:param summary_key: The key name to store the input summary in the
meta field. It's "event_description" in default.
:param support_text_key: The key name to store the output
support text for the summary in ... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_support_text_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_support_text_mapper.py | Apache-2.0 |
def __init__(self,
tables_field_name: str = MetaKeys.html_tables,
retain_html_tags: bool = False,
include_header: bool = True,
*args,
**kwargs):
"""
Initialization method.
:param tables_field_name: Field name to... |
Initialization method.
:param tables_field_name: Field name to store the extracted tables.
:param retain_html_tags: If True, retains HTML tags in the tables;
otherwise, removes them.
:param include_header: If True, includes the table header;
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/extract_tables_from_html_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/extract_tables_from_html_mapper.py | Apache-2.0 |
def __init__(self, normalization: str = None, *args, **kwargs):
"""
Initialization method.
:param normalization: the specified form of Unicode
normalization mode, which can be one of
['NFC', 'NFKC', 'NFD', and 'NFKD'], default 'NFC'.
:param args: extra args
... |
Initialization method.
:param normalization: the specified form of Unicode
normalization mode, which can be one of
['NFC', 'NFKC', 'NFD', and 'NFKD'], default 'NFC'.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/fix_unicode_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/fix_unicode_mapper.py | Apache-2.0 |
def __init__(self,
hf_model: str = 'Qwen/Qwen2.5-7B-Instruct',
*,
seed_file: str = '',
example_num: PositiveInt = 3,
similarity_threshold: float = 0.7,
system_prompt: Optional[str] = None,
input_templa... |
Initialization method.
:param hf_model: Huggingface model ID.
:param seed_file: Path to the seed file in chatml format.
:param example_num: The number of selected examples.
Randomly select N examples from "seed_file" and
put them into prompt as QA examples.
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/generate_qa_from_examples_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/generate_qa_from_examples_mapper.py | Apache-2.0 |
def _load_seed_qa_samples(self):
"""Load QA pairs from chatml format file."""
qa_samples = []
with open(self.seed_file, encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
line = line.strip()
qa_pairs = self._parse_chatml_str(l... | Load QA pairs from chatml format file. | _load_seed_qa_samples | python | modelscope/data-juicer | data_juicer/ops/mapper/generate_qa_from_examples_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/generate_qa_from_examples_mapper.py | Apache-2.0 |
def __init__(self,
p: float = 0.2,
blur_type: str = 'gaussian',
radius: float = 2,
*args,
**kwargs):
"""
Initialization method.
:param p: Probability of the image being blurred.
:param blur_type: Type o... |
Initialization method.
:param p: Probability of the image being blurred.
:param blur_type: Type of blur kernel, including
['mean', 'box', 'gaussian'].
:param radius: Radius of blur kernel.
:param args: extra args
:param kwargs: extra args
| __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_blur_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_blur_mapper.py | Apache-2.0 |
def __init__(self,
mode: str = 'description',
api_key: str = '',
max_token: int = 500,
temperature: Annotated[float, Field(ge=0, le=1)] = 1.0,
system_prompt: str = '',
user_prompt: str = '',
user_promp... |
Initialization method.
:param mode: mode of text generated from images, can be one of
['reasoning', 'description', 'conversation', 'custom']
:param api_key: the API key to authenticate the request.
:param max_token: the maximum number of tokens to generate.
Defa... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_captioning_from_gpt4v_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_captioning_from_gpt4v_mapper.py | Apache-2.0 |
def __init__(self,
hf_img2seq: str = 'Salesforce/blip2-opt-2.7b',
trust_remote_code: bool = False,
caption_num: PositiveInt = 1,
keep_candidate_mode: str = 'random_any',
keep_original_sample: bool = True,
prompt: Optio... |
Initialization method.
:param hf_img2seq: model name on huggingface to generate caption
:param caption_num: how many candidate captions to generate
for each image
:param keep_candidate_mode: retain strategy for the generated
$caption_num$ candidates.
... | __init__ | python | modelscope/data-juicer | data_juicer/ops/mapper/image_captioning_mapper.py | https://github.com/modelscope/data-juicer/blob/master/data_juicer/ops/mapper/image_captioning_mapper.py | Apache-2.0 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.