mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-14 15:27:42 +01:00
Fix typos (#1328)
This commit is contained in:
@@ -126,7 +126,7 @@ AI for Science:
|
||||
|
||||
* [uni-fold-multimer](https://modelscope.cn/models/DPTech/uni-fold-multimer/summary)
|
||||
|
||||
**Note:** Most models on ModelScope are public and can be downloaded without account registration on modelscope website([www.modelscope.cn](www.modelscope.cn)), please refer to instructions for [model download](https://modelscope.cn/docs/%E6%A8%A1%E5%9E%8B%E7%9A%84%E4%B8%8B%E8%BD%BD), for dowloading models with api provided by modelscope library or git.
|
||||
**Note:** Most models on ModelScope are public and can be downloaded without account registration on modelscope website([www.modelscope.cn](www.modelscope.cn)), please refer to instructions for [model download](https://modelscope.cn/docs/%E6%A8%A1%E5%9E%8B%E7%9A%84%E4%B8%8B%E8%BD%BD), for downloading models with api provided by modelscope library or git.
|
||||
|
||||
# QuickTour
|
||||
|
||||
@@ -158,7 +158,7 @@ The output image with the background removed is:
|
||||

|
||||
|
||||
|
||||
Fine-tuning and evaluation can also be done with a few more lines of code to set up training dataset and trainer, with the heavy-lifting work of training and evaluation a model encapsulated in the implementation of `traner.train()` and
|
||||
Fine-tuning and evaluation can also be done with a few more lines of code to set up training dataset and trainer, with the heavy-lifting work of training and evaluation a model encapsulated in the implementation of `trainer.train()` and
|
||||
`trainer.evaluate()` interfaces.
|
||||
|
||||
For example, the gpt3 base model (1.3B) can be fine-tuned with the chinese-poetry dataset, resulting in a model that can be used for chinese-poetry generation.
|
||||
|
||||
@@ -227,7 +227,7 @@ conda activate modelscope
|
||||
|
||||
安装完前置依赖,你可以按照如下方式安装 ModelScope Library。
|
||||
|
||||
ModelScope Libarary 由核心框架,以及不同领域模型的对接组件组成。如果只需要 ModelScope 模型和数据集访问等基础能力,可以只安装 ModelScope 的核心框架:
|
||||
ModelScope Library 由核心框架,以及不同领域模型的对接组件组成。如果只需要 ModelScope 模型和数据集访问等基础能力,可以只安装 ModelScope 的核心框架:
|
||||
|
||||
```shell
|
||||
pip install modelscope
|
||||
|
||||
@@ -143,8 +143,8 @@ def print_example(example: Dict[str, Any], tokenizer) -> None:
|
||||
print(f'[INPUT] {tokenizer.decode(input_ids)}')
|
||||
print()
|
||||
n_mask = Counter(labels)[-100]
|
||||
print(f'[LABLES_IDS] {labels}')
|
||||
print(f'[LABLES] <-100 * {n_mask}>{tokenizer.decode(labels[n_mask:])}')
|
||||
print(f'[LABELS_IDS] {labels}')
|
||||
print(f'[LABELS] <-100 * {n_mask}>{tokenizer.decode(labels[n_mask:])}')
|
||||
|
||||
|
||||
def data_collate_fn(batch: List[Dict[str, Any]], tokenizer) -> Dict[str, Any]:
|
||||
|
||||
@@ -202,7 +202,7 @@ def print_examples(examples: Dict[str, Any], tokenizer) -> None:
|
||||
print(f'[INPUT_IDS] {tokenizer.decode(input_ids)}')
|
||||
print()
|
||||
print(
|
||||
f'[LABLES] {tokenizer.decode([lb if lb != -100 else 0 for lb in labels])}'
|
||||
f'[LABELS] {tokenizer.decode([lb if lb != -100 else 0 for lb in labels])}'
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -297,12 +297,12 @@ class Heads(object):
|
||||
class Pipelines(object):
|
||||
""" Names for different pipelines.
|
||||
|
||||
Holds the standard pipline name to use for identifying different pipeline.
|
||||
Holds the standard pipeline name to use for identifying different pipeline.
|
||||
This should be used to register pipelines.
|
||||
|
||||
For pipeline which support different models and implements the common function, we
|
||||
should use task name for this pipeline.
|
||||
For pipeline which suuport only one model, we should use ${Model}-${Task} as its name.
|
||||
For pipeline which support only one model, we should use ${Model}-${Task} as its name.
|
||||
"""
|
||||
pipeline_template = 'pipeline-template'
|
||||
# vision tasks
|
||||
@@ -1105,7 +1105,7 @@ class Preprocessors(object):
|
||||
|
||||
For a general preprocessor, just use the function name as preprocessor name such as
|
||||
resize-image, random-crop
|
||||
For a model-specific preprocessor, use ${modelname}-${fuction}
|
||||
For a model-specific preprocessor, use ${modelname}-${function}
|
||||
"""
|
||||
|
||||
# cv preprocessor
|
||||
|
||||
@@ -20,7 +20,7 @@ def precook(s, n=4, out=False):
|
||||
can take string arguments as well.
|
||||
:param s: string : sentence to be converted into ngrams
|
||||
:param n: int : number of ngrams for which representation is calculated
|
||||
:return: term frequency vector for occuring ngrams
|
||||
:return: term frequency vector for occurring ngrams
|
||||
"""
|
||||
words = s.split()
|
||||
counts = defaultdict(int)
|
||||
|
||||
@@ -98,7 +98,7 @@ class INCEPTION_V3_FID(nn.Module):
|
||||
# Maps feature dimensionality to their output blocks indices
|
||||
BLOCK_INDEX_BY_DIM = {
|
||||
64: 0, # First max pooling features
|
||||
192: 1, # Second max pooling featurs
|
||||
192: 1, # Second max pooling features
|
||||
768: 2, # Pre-aux classifier features
|
||||
2048: 3 # Final average pooling features
|
||||
}
|
||||
@@ -295,7 +295,7 @@ def calculate_frechet_distance(mu1, sigma1, mu2, sigma2, eps=1e-6):
|
||||
nception net (like returned by the function 'get_predictions')
|
||||
or generated samples.
|
||||
mu2: The sample mean over activations, precalculated on an
|
||||
representive data set.
|
||||
representative data set.
|
||||
sigma1: The covariance matrix over activations for generated samples.
|
||||
sigma2: The covariance matrix over activations, precalculated on an
|
||||
epresentive data set.
|
||||
|
||||
@@ -37,7 +37,7 @@ class InverseTextProcessingPipeline(Pipeline):
|
||||
>>> sentence = 'sembilan ribu sembilan ratus sembilan puluh sembilan'
|
||||
>>> print(pipeline_itn(sentence))
|
||||
|
||||
To view other examples plese check tests/pipelines/test_inverse_text_processing.py.
|
||||
To view other examples please check tests/pipelines/test_inverse_text_processing.py.
|
||||
"""
|
||||
|
||||
def __init__(self, model: Union[Model, str] = None, **kwargs):
|
||||
|
||||
@@ -84,8 +84,8 @@ def resize(input,
|
||||
eps = fw.finfo(fw.float32).eps
|
||||
device = input.device if fw is torch else None
|
||||
|
||||
# set missing scale factors or output shapem one according to another,
|
||||
# scream if both missing. this is also where all the defults policies
|
||||
# set missing scale factors or output shape one according to another,
|
||||
# scream if both missing. this is also where all the defaults policies
|
||||
# take place. also handling the by_convs attribute carefully.
|
||||
scale_factors, out_shape, by_convs = set_scale_and_out_sz(
|
||||
in_shape, out_shape, scale_factors, by_convs, scale_tolerance,
|
||||
@@ -155,15 +155,15 @@ def resize(input,
|
||||
|
||||
|
||||
def get_projected_grid(in_sz, out_sz, scale_factor, fw, by_convs, device=None):
|
||||
# we start by having the ouput coordinates which are just integer locations
|
||||
# in the special case when usin by_convs, we only need two cycles of grid
|
||||
# we start by having the output coordinates which are just integer locations
|
||||
# in the special case when using by_convs, we only need two cycles of grid
|
||||
# points. the first and last.
|
||||
grid_sz = out_sz if not by_convs else scale_factor.numerator
|
||||
out_coordinates = fw_arange(grid_sz, fw, device)
|
||||
|
||||
# This is projecting the ouput pixel locations in 1d to the input tensor,
|
||||
# This is projecting the output pixel locations in 1d to the input tensor,
|
||||
# as non-integer locations.
|
||||
# the following fomrula is derived in the paper
|
||||
# the following formula is derived in the paper
|
||||
# "From Discrete to Continuous Convolutions" by Shocher et al.
|
||||
v1 = out_coordinates / float(scale_factor) + (in_sz - 1) / 2
|
||||
v2 = (out_sz - 1) / (2 * float(scale_factor))
|
||||
|
||||
@@ -155,7 +155,7 @@ class GridVlpPipeline(Pipeline):
|
||||
Tasks.visual_question_answering,
|
||||
module_name=Pipelines.gridvlp_multi_modal_classification)
|
||||
class GridVlpClassificationPipeline(GridVlpPipeline):
|
||||
""" Pipeline for gridvlp classification, including cate classfication and
|
||||
""" Pipeline for gridvlp classification, including cate classification and
|
||||
brand classification.
|
||||
|
||||
Example:
|
||||
@@ -174,7 +174,7 @@ class GridVlpClassificationPipeline(GridVlpPipeline):
|
||||
"""
|
||||
|
||||
def __init__(self, model_name_or_path: str, **kwargs):
|
||||
""" Pipeline for gridvlp classification, including cate classfication and
|
||||
""" Pipeline for gridvlp classification, including cate classification and
|
||||
brand classification.
|
||||
Args:
|
||||
model: path to local model directory.
|
||||
|
||||
@@ -49,7 +49,7 @@ class CanmtTranslationPipeline(Pipeline):
|
||||
>>> # Or use the list input:
|
||||
>>> print(pipeline_ins([sentence1])
|
||||
|
||||
To view other examples plese check tests/pipelines/test_canmt_translation.py.
|
||||
To view other examples please check tests/pipelines/test_canmt_translation.py.
|
||||
"""
|
||||
super().__init__(
|
||||
model=model,
|
||||
|
||||
@@ -415,7 +415,7 @@ def get_rank(guess_item, gold_item, k, rank_keys, verbose=False):
|
||||
f'for a robust recall@{k} computation (you provided {len(guess_ids)} item(s)).'
|
||||
)
|
||||
|
||||
# 3. rank by gruping pages in each evidence set (each evidence set count as 1),
|
||||
# 3. rank by grouping pages in each evidence set (each evidence set count as 1),
|
||||
# the position in the rank of each evidence set is given by the last page in guess_ids
|
||||
# non evidence pages counts as 1
|
||||
rank = []
|
||||
|
||||
@@ -55,7 +55,7 @@ class FillMaskPipeline(Pipeline):
|
||||
NOTE2: Please pay attention to the model's special tokens.
|
||||
If bert based model(bert, structbert, etc.) is used, the mask token is '[MASK]'.
|
||||
If the xlm-roberta(xlm-roberta, veco, etc.) based model is used, the mask token is '<mask>'.
|
||||
To view other examples plese check tests/pipelines/test_fill_mask.py.
|
||||
To view other examples please check tests/pipelines/test_fill_mask.py.
|
||||
"""
|
||||
super().__init__(
|
||||
model=model,
|
||||
|
||||
@@ -48,7 +48,7 @@ class NamedEntityRecognitionPipeline(TokenClassificationPipeline):
|
||||
>>> input = '这与温岭市新河镇的一个神秘的传说有关。'
|
||||
>>> print(pipeline_ins(input))
|
||||
|
||||
To view other examples plese check the tests/pipelines/test_plugin_model.py.
|
||||
To view other examples please check the tests/pipelines/test_plugin_model.py.
|
||||
"""
|
||||
super().__init__(
|
||||
model=model,
|
||||
|
||||
@@ -60,7 +60,7 @@ class SiameseUiePipeline(Pipeline):
|
||||
>>> sentence = '1944年毕业于北大的名古屋铁道会长谷口清太郎等人在日本积极筹资,共筹款2.7亿日元,参加捐款的日本企业有69家。'
|
||||
>>> print(pipeline_ins(sentence, schema={'人物': None, '地理位置': None, '组织机构': None}))
|
||||
|
||||
To view other examples plese check tests/pipelines/test_siamese_uie.py.
|
||||
To view other examples please check tests/pipelines/test_siamese_uie.py.
|
||||
"""
|
||||
super().__init__(
|
||||
model=model,
|
||||
|
||||
@@ -43,7 +43,7 @@ class TextErrorCorrectionPipeline(Pipeline):
|
||||
>>> sentence1 = '随着中国经济突飞猛近,建造工业与日俱增'
|
||||
>>> print(pipeline_ins(sentence1))
|
||||
|
||||
To view other examples plese check tests/pipelines/test_text_error_correction.py.
|
||||
To view other examples please check tests/pipelines/test_text_error_correction.py.
|
||||
"""
|
||||
super().__init__(
|
||||
model=model,
|
||||
|
||||
@@ -64,7 +64,7 @@ class TextGenerationPipeline(Pipeline, PipelineStreamingOutputMixin):
|
||||
>>> # Or use the dict input:
|
||||
>>> print(pipeline_ins({'sentence': sentence1}))
|
||||
|
||||
To view other examples plese check tests/pipelines/test_text_generation.py.
|
||||
To view other examples please check tests/pipelines/test_text_generation.py.
|
||||
"""
|
||||
super().__init__(
|
||||
model=model,
|
||||
@@ -517,7 +517,7 @@ class Llama2TaskPipeline(TextGenerationPipeline):
|
||||
>>> temperature=1.0, repetition_penalty=1., eos_token_id=2, bos_token_id=1, pad_token_id=0)
|
||||
>>> print(result['text'])
|
||||
|
||||
To view other examples plese check tests/pipelines/test_llama2_text_generation_pipeline.py.
|
||||
To view other examples please check tests/pipelines/test_llama2_text_generation_pipeline.py.
|
||||
"""
|
||||
self.model = Model.from_pretrained(
|
||||
model, device_map='auto', torch_dtype=torch.float16)
|
||||
@@ -604,7 +604,7 @@ class Llama2chatTaskPipeline(Pipeline):
|
||||
>>> pad_token_id=0, history=history_demo)
|
||||
>>> print(result['response'])
|
||||
|
||||
To view other examples plese check tests/pipelines/test_llama2_text_generation_pipeline.py.
|
||||
To view other examples please check tests/pipelines/test_llama2_text_generation_pipeline.py.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
||||
@@ -35,7 +35,7 @@ class WordSegmentationPipeline(TokenClassificationPipeline):
|
||||
>>> sentence1 = '今天天气不错,适合出去游玩'
|
||||
>>> print(pipeline_ins(sentence1))
|
||||
|
||||
To view other examples plese check tests/pipelines/test_word_segmentation.py.
|
||||
To view other examples please check tests/pipelines/test_word_segmentation.py.
|
||||
"""
|
||||
|
||||
def postprocess(self,
|
||||
|
||||
@@ -59,7 +59,7 @@ class ZeroShotClassificationPipeline(Pipeline):
|
||||
>>> template = '这篇文章的标题是{}'
|
||||
>>> print(pipeline_ins(sentence1, candidate_labels=labels, hypothesis_template=template))
|
||||
|
||||
To view other examples plese check tests/pipelines/test_zero_shot_classification.py.
|
||||
To view other examples please check tests/pipelines/test_zero_shot_classification.py.
|
||||
"""
|
||||
super().__init__(
|
||||
model=model,
|
||||
|
||||
Reference in New Issue
Block a user