index int64 0 50.7k | project_path stringclasses 279
values | completion_path stringlengths 57 199 | signature_postion stringlengths 3 11 | class_position stringlengths 3 11 | function_name stringlengths 1 62 | class_name stringlengths 0 55 | body_position stringlengths 3 11 | body_position_with_comments stringlengths 3 11 | masked_class stringlengths 14 8.32k | masked_class_with_comment stringlengths 14 8.32k | func_body stringlengths 9 6.72k | func_body_with_comment stringlengths 9 6.72k | len_func_body int64 1 643 | len_input int64 10 2.02k | len_output int64 4 1.9k | total int64 20 2.05k | file_code stringlengths 14 442k | file_code_with_comment stringlengths 14 442k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/cli.py | 22,23 | 1,103 | main | 23,94 | 23,94 | import argparse
import os
import torch
from llava.conversation import conv_templates
from llava.mm_utils import (
KeywordsStoppingCriteria,
get_model_name_from_path,
load_pretrained_model,
process_images,
tokenizer_image_token,
)
from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IN... | import argparse
import os
import torch
from llava.conversation import conv_templates
from llava.mm_utils import (
KeywordsStoppingCriteria,
get_model_name_from_path,
load_pretrained_model,
process_images,
tokenizer_image_token,
)
from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IN... | model_path = os.path.expanduser(args.model_path)
key_info["model_path"] = model_path
get_model_name_from_path(model_path)
tokenizer, model, image_processor, _ = load_pretrained_model(model_path)
conv = conv_templates["mm_default"].copy()
roles = conv.roles
image = load_image(args.image_fil... | model_path = os.path.expanduser(args.model_path)
key_info["model_path"] = model_path
get_model_name_from_path(model_path)
tokenizer, model, image_processor, _ = load_pretrained_model(model_path)
conv = conv_templates["mm_default"].copy()
roles = conv.roles
image = load_image(args.image_fil... | 152 | 313 | 772 | 1,085 | import argparse
import os
import torch
from llava.conversation import conv_templates
from llava.mm_utils import (
KeywordsStoppingCriteria,
get_model_name_from_path,
load_pretrained_model,
process_images,
tokenizer_image_token,
)
from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IN... | import argparse
import os
import torch
from llava.conversation import conv_templates
from llava.mm_utils import (
KeywordsStoppingCriteria,
get_model_name_from_path,
load_pretrained_model,
process_images,
tokenizer_image_token,
)
from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IN... | |
1 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/conversation.py | 27,28 | 12,184 | get_prompt | Conversation | 28,56 | 28,56 | @dataclasses.dataclass
class Conversation:
"""A class that keeps all conversation history."""
system: str
roles: List[str]
messages: List[List[str]]
offset: int
sep_style: SeparatorStyle = SeparatorStyle.SINGLE
sep: str = "###"
sep2: str = None
version: str = "Unknown"
skip_nex... | @dataclasses.dataclass
class Conversation:
"""A class that keeps all conversation history."""
system: str
roles: List[str]
messages: List[List[str]]
offset: int
sep_style: SeparatorStyle = SeparatorStyle.SINGLE
sep: str = "###"
sep2: str = None
version: str = "Unknown"
skip_nex... | messages = self.messages
if len(messages) > 0 and type(messages[0][1]) is tuple:
messages = self.messages.copy()
init_role, init_msg = messages[0].copy()
init_msg = init_msg[0].replace("<image_placeholder>", "").strip()
if "mmtag" in self.version:
... | messages = self.messages
if len(messages) > 0 and type(messages[0][1]) is tuple:
messages = self.messages.copy()
init_role, init_msg = messages[0].copy()
init_msg = init_msg[0].replace("<image_placeholder>", "").strip()
if "mmtag" in self.version:
... | 103 | 1,467 | 355 | 1,822 | import dataclasses
from enum import Enum, auto
from typing import List
class SeparatorStyle(Enum):
"""Different separator style."""
SINGLE = auto()
@dataclasses.dataclass
class Conversation:
"""A class that keeps all conversation history."""
system: str
roles: List[str]
messages: List[List... | import dataclasses
from enum import Enum, auto
from typing import List
class SeparatorStyle(Enum):
"""Different separator style."""
SINGLE = auto()
@dataclasses.dataclass
class Conversation:
"""A class that keeps all conversation history."""
system: str
roles: List[str]
messages: List[List... |
2 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/model/llava_llama.py | 137,145 | 39,164 | prepare_inputs_for_generation | LlavaLlamaForCausalLM | 145,164 | 145,164 | class LlavaLlamaForCausalLM(LlamaForCausalLM, LlavaMetaForCausalLM):
config_class = LlavaConfig
def __init__(self, config):
super(LlamaForCausalLM, self).__init__(config)
self.model = LlavaLlamaModel(config)
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
... | class LlavaLlamaForCausalLM(LlamaForCausalLM, LlavaMetaForCausalLM):
config_class = LlavaConfig
def __init__(self, config):
super(LlamaForCausalLM, self).__init__(config)
self.model = LlavaLlamaModel(config)
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
... | if past_key_values:
input_ids = input_ids[:, -1:]
# if `inputs_embeds` are passed, we only want to use them in the 1st generation step
if inputs_embeds is not None and past_key_values is None:
model_inputs = {"inputs_embeds": inputs_embeds}
else:
mode... | if past_key_values:
input_ids = input_ids[:, -1:]
# if `inputs_embeds` are passed, we only want to use them in the 1st generation step
if inputs_embeds is not None and past_key_values is None:
model_inputs = {"inputs_embeds": inputs_embeds}
else:
mode... | 58 | 1,128 | 224 | 1,352 | # Copyright 2023 Haotian Liu
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... | # Copyright 2023 Haotian Liu
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... |
3 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/model/multimodal_projector/builder.py | 32,33 | 1,65 | build_vision_projector | 33,65 | 33,65 | import re
import torch.nn as nn
class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
return x
@property
def config(self):
return {"mm_projector_type": "identity"}
class SimpleResBlock(nn.Module):
def __init__(self,... | import re
import torch.nn as nn
class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
return x
@property
def config(self):
return {"mm_projector_type": "identity"}
class SimpleResBlock(nn.Module):
def __init__(self,... | projector_type = getattr(config, "mm_projector_type", "linear")
if projector_type == "linear":
return nn.Linear(config.mm_hidden_size, config.hidden_size)
use_norm = False
if "_Norm" in projector_type:
use_norm = True
projector_type = projector_type.replace("_Norm", "")
mlp... | projector_type = getattr(config, "mm_projector_type", "linear")
if projector_type == "linear":
return nn.Linear(config.mm_hidden_size, config.hidden_size)
use_norm = False
if "_Norm" in projector_type:
use_norm = True
projector_type = projector_type.replace("_Norm", "")
mlp... | 76 | 245 | 432 | 677 | import re
import torch.nn as nn
class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
return x
@property
def config(self):
return {"mm_projector_type": "identity"}
class SimpleResBlock(nn.Module):
def __init__(self,... | import re
import torch.nn as nn
class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
return x
@property
def config(self):
return {"mm_projector_type": "identity"}
class SimpleResBlock(nn.Module):
def __init__(self,... | |
4 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/model/multimodal_projector/builder.py | 10,11 | 6,18 | forward | IdentityMap | 11,13 | 11,13 | class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
FILL_FUNC_BODY @property
def config(self):
return {"mm_projector_type": "identity"}
| class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
FILL_FUNC_BODY @property
def config(self):
return {"mm_projector_type": "identity"}
| return x
| return x
| 2 | 79 | 7 | 86 | import re
import torch.nn as nn
class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
FILL_FUNC_BODY @property
def config(self):
return {"mm_projector_type": "identity"}
class SimpleResBlock(nn.Module):
def __init__(self, cha... | import re
import torch.nn as nn
class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
FILL_FUNC_BODY @property
def config(self):
return {"mm_projector_type": "identity"}
class SimpleResBlock(nn.Module):
def __init__(self, cha... |
5 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/model/multimodal_projector/builder.py | 27,28 | 18,32 | forward | SimpleResBlock | 28,32 | 28,32 | class SimpleResBlock(nn.Module):
def __init__(self, channels):
super().__init__()
self.pre_norm = nn.LayerNorm(channels)
self.proj = nn.Sequential(
nn.Linear(channels, channels), nn.GELU(), nn.Linear(channels, channels)
)
def forward(self, x):
FILL_FUNC_BODY | class SimpleResBlock(nn.Module):
def __init__(self, channels):
super().__init__()
self.pre_norm = nn.LayerNorm(channels)
self.proj = nn.Sequential(
nn.Linear(channels, channels), nn.GELU(), nn.Linear(channels, channels)
)
def forward(self, x):
FILL_FUNC_BODY | x = self.pre_norm(x)
return x + self.proj(x)
| x = self.pre_norm(x)
return x + self.proj(x)
| 7 | 111 | 29 | 140 | import re
import torch.nn as nn
class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
return x
@property
def config(self):
return {"mm_projector_type": "identity"}
class SimpleResBlock(nn.Module):
def __init__(self,... | import re
import torch.nn as nn
class IdentityMap(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, *args, **kwargs):
return x
@property
def config(self):
return {"mm_projector_type": "identity"}
class SimpleResBlock(nn.Module):
def __init__(self,... |
6 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/single_inference.py | 27,28 | 1,111 | single_infer | 28,94 | 28,94 | import argparse
import os
import torch
from llava.conversation import conv_templates
from llava.mm_utils import (
KeywordsStoppingCriteria,
expand2square,
get_model_name_from_path,
load_pretrained_model,
tokenizer_image_token,
)
from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IND... | import argparse
import os
import torch
from llava.conversation import conv_templates
from llava.mm_utils import (
KeywordsStoppingCriteria,
expand2square,
get_model_name_from_path,
load_pretrained_model,
tokenizer_image_token,
)
from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IND... | disable_torch_init()
model_path = os.path.expanduser(args.model_path)
key_info["model_path"] = model_path
get_model_name_from_path(model_path)
tokenizer, model, image_processor, context_len = load_pretrained_model(model_path)
image_file = args.image_file
qs = args.question
qs = DEFAULT_... | disable_torch_init()
model_path = os.path.expanduser(args.model_path)
key_info["model_path"] = model_path
get_model_name_from_path(model_path)
tokenizer, model, image_processor, context_len = load_pretrained_model(model_path)
image_file = args.image_file
qs = args.question
qs = DEFAULT_... | 153 | 477 | 845 | 1,322 | import argparse
import os
import torch
from llava.conversation import conv_templates
from llava.mm_utils import (
KeywordsStoppingCriteria,
expand2square,
get_model_name_from_path,
load_pretrained_model,
tokenizer_image_token,
)
from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IND... | import argparse
import os
import torch
from llava.conversation import conv_templates
from llava.mm_utils import (
KeywordsStoppingCriteria,
expand2square,
get_model_name_from_path,
load_pretrained_model,
tokenizer_image_token,
)
from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IND... | |
8 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/demo/text_generation.py | 36,37 | 1,73 | main | 37,70 | 37,70 | import argparse
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
def parse_inputs():
parser = argparse.ArgumentParser(description="Yi-6B text generation demo")
parser.add_argument(
"--model",
type=str,
default="01-ai/Yi-6B",
help="pretrained model pat... | import argparse
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
def parse_inputs():
parser = argparse.ArgumentParser(description="Yi-6B text generation demo")
parser.add_argument(
"--model",
type=str,
default="01-ai/Yi-6B",
help="pretrained model pat... | print(args)
if args.cpu:
device_map = "cpu"
else:
device_map = "auto"
model = AutoModelForCausalLM.from_pretrained(
args.model, device_map=device_map, torch_dtype="auto"
)
tokenizer = AutoTokenizer.from_pretrained(args.model)
inputs = tokenizer(
args.prompt,... | print(args)
if args.cpu:
device_map = "cpu"
else:
device_map = "auto"
model = AutoModelForCausalLM.from_pretrained(
args.model, device_map=device_map, torch_dtype="auto"
)
tokenizer = AutoTokenizer.from_pretrained(args.model)
inputs = tokenizer(
args.prompt,... | 58 | 337 | 327 | 664 | import argparse
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
def parse_inputs():
parser = argparse.ArgumentParser(description="Yi-6B text generation demo")
parser.add_argument(
"--model",
type=str,
default="01-ai/Yi-6B",
help="pretrained model pat... | import argparse
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
def parse_inputs():
parser = argparse.ArgumentParser(description="Yi-6B text generation demo")
parser.add_argument(
"--model",
type=str,
default="01-ai/Yi-6B",
help="pretrained model pat... | |
9 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/data/raw_datasets.py | 77,78 | 41,81 | get_prompt_and_rejected | DahoasRmstaticDataset | 78,81 | 78,81 | class DahoasRmstaticDataset(PromptRawDataset):
def __init__(self, output_path, seed, local_rank, dataset_name):
print("init DahoasRMStaicDataset")
super().__init__(output_path, seed, local_rank, dataset_name)
print("loading at dataset_name {}".format(dataset_name))
self.raw_datasets ... | class DahoasRmstaticDataset(PromptRawDataset):
def __init__(self, output_path, seed, local_rank, dataset_name):
print("init DahoasRMStaicDataset")
super().__init__(output_path, seed, local_rank, dataset_name)
print("loading at dataset_name {}".format(dataset_name))
self.raw_datasets ... | return sample["prompt"] + sample["rejected"]
| return sample["prompt"] + sample["rejected"]
| 4 | 441 | 19 | 460 | # Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py
from datasets import load_dataset
# The template prompt dataset class that all new dataset porting needs to
# follow in order to have a unified API and unified ... | # Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py
from datasets import load_dataset
# The template prompt dataset class that all new dataset porting needs to
# follow in order to have a unified API and unified ... |
10 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/data/raw_datasets.py | 105,106 | 81,134 | get_prompt | LocalJsonFileDataset | 106,111 | 106,111 | class LocalJsonFileDataset(PromptRawDataset):
def __init__(self, output_path, seed, local_rank, dataset_name, chat_path):
super().__init__(output_path, seed, local_rank, dataset_name)
self.dataset_name = "local/jsonfile"
self.dataset_name_clean = "jsonfile"
self.raw_datasets = load_d... | class LocalJsonFileDataset(PromptRawDataset):
def __init__(self, output_path, seed, local_rank, dataset_name, chat_path):
super().__init__(output_path, seed, local_rank, dataset_name)
self.dataset_name = "local/jsonfile"
self.dataset_name_clean = "jsonfile"
self.raw_datasets = load_d... | if sample["prompt"] is not None:
return " " + sample["prompt"]
return None
# The chosen response should be in the format of: " " + actual_response_sentence
| if sample["prompt"] is not None:
return " " + sample["prompt"]
return None
# The chosen response should be in the format of: " " + actual_response_sentence
| 26 | 539 | 55 | 594 | # Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py
from datasets import load_dataset
# The template prompt dataset class that all new dataset porting needs to
# follow in order to have a unified API and unified ... | # Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py
from datasets import load_dataset
# The template prompt dataset class that all new dataset porting needs to
# follow in order to have a unified API and unified ... |
11 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/data/raw_datasets.py | 25,26 | 7,41 | get_chosen | PromptRawDataset | 26,30 | 26,30 | class PromptRawDataset(object):
def __init__(self, output_path, seed, local_rank, dataset_name):
print("init PromptRawDataset with dataname {}".format(dataset_name))
self.output_path = output_path
self.seed = seed
self.local_rank = local_rank
def get_train_data(self):
re... | class PromptRawDataset(object):
def __init__(self, output_path, seed, local_rank, dataset_name):
print("init PromptRawDataset with dataname {}".format(dataset_name))
self.output_path = output_path
self.seed = seed
self.local_rank = local_rank
def get_train_data(self):
re... | return
# The rejected response should be in the format of: " " + actual_response_sentence
# If the dataset does not have rejected response, return None
| return
# The rejected response should be in the format of: " " + actual_response_sentence
# If the dataset does not have rejected response, return None
| 26 | 265 | 44 | 309 | # Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py
from datasets import load_dataset
# The template prompt dataset class that all new dataset porting needs to
# follow in order to have a unified API and unified ... | # Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py
from datasets import load_dataset
# The template prompt dataset class that all new dataset porting needs to
# follow in order to have a unified API and unified ... |
12 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/data/raw_datasets.py | 158,159 | 134,167 | get_prompt | YiDataset | 159,163 | 159,163 | class YiDataset(PromptRawDataset):
def __init__(self, output_path, seed, local_rank, dataset_name, chat_path):
super().__init__(output_path, seed, local_rank, dataset_name)
print("data path is {}".format(chat_path))
self.dataset_name = "yi"
self.dataset_name_clean = "yi"
self... | class YiDataset(PromptRawDataset):
def __init__(self, output_path, seed, local_rank, dataset_name, chat_path):
super().__init__(output_path, seed, local_rank, dataset_name)
print("data path is {}".format(chat_path))
self.dataset_name = "yi"
self.dataset_name_clean = "yi"
self... | if sample["prompt"] is not None:
return " " + sample["prompt"]
return None
| if sample["prompt"] is not None:
return " " + sample["prompt"]
return None
| 12 | 344 | 32 | 376 | # Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py
from datasets import load_dataset
# The template prompt dataset class that all new dataset porting needs to
# follow in order to have a unified API and unified ... | # Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py
from datasets import load_dataset
# The template prompt dataset class that all new dataset porting needs to
# follow in order to have a unified API and unified ... |
13 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/model/model_utils.py | 7,16 | 1,60 | create_hf_model | 16,60 | 16,60 | import math
from transformers import AutoConfig
from transformers.deepspeed import HfDeepSpeedConfig
def create_hf_model(
model_class,
model_name_or_path,
tokenizer,
ds_config=None,
rlhf_training=False,
disable_dropout=False,
eval_mode=False,
):
FILL_FUNC_BODY | import math
from transformers import AutoConfig
from transformers.deepspeed import HfDeepSpeedConfig
def create_hf_model(
model_class,
model_name_or_path,
tokenizer,
ds_config=None,
rlhf_training=False,
disable_dropout=False,
eval_mode=False,
):
FILL_FUNC_BODY | model_config = AutoConfig.from_pretrained(
model_name_or_path, trust_remote_code=True
)
# print(model_config)
if disable_dropout:
model_config.dropout = 0.0
# Note: dschf is defined in function scope to avoid global effects
# https://huggingface.co/docs/transformers/main_classes/... | model_config = AutoConfig.from_pretrained(
model_name_or_path, trust_remote_code=True
)
# print(model_config)
if disable_dropout:
model_config.dropout = 0.0
# Note: dschf is defined in function scope to avoid global effects
# https://huggingface.co/docs/transformers/main_classes/... | 103 | 108 | 536 | 644 | import math
from transformers import AutoConfig
from transformers.deepspeed import HfDeepSpeedConfig
def create_hf_model(
model_class,
model_name_or_path,
tokenizer,
ds_config=None,
rlhf_training=False,
disable_dropout=False,
eval_mode=False,
):
FILL_FUNC_BODY | import math
from transformers import AutoConfig
from transformers.deepspeed import HfDeepSpeedConfig
def create_hf_model(
model_class,
model_name_or_path,
tokenizer,
ds_config=None,
rlhf_training=False,
disable_dropout=False,
eval_mode=False,
):
FILL_FUNC_BODY | |
14 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/perf.py | 5,6 | 1,74 | print_throughput | 6,45 | 6,45 | import torch
# This function can be used to print throughput for Step 1 and 2 only
def print_throughput(hf_model, args, e2e_time, rank=0):
FILL_FUNC_BODYdef calculate_flops(checkpoint_activations_factor, batch_size, seq_length, hf_config):
num_layers, hidden_size, vocab_size = get_hf_configs(hf_config)
# TODO... | import torch
# This function can be used to print throughput for Step 1 and 2 only
def print_throughput(hf_model, args, e2e_time, rank=0):
FILL_FUNC_BODYdef calculate_flops(checkpoint_activations_factor, batch_size, seq_length, hf_config):
num_layers, hidden_size, vocab_size = get_hf_configs(hf_config)
# TODO... | if rank <= 0:
hf_config = hf_model.config
num_layers, hidden_size, vocab_size = get_hf_configs(hf_config)
gpus_per_model = torch.distributed.get_world_size()
seq_length = args.max_seq_len
batch_size = args.per_device_train_batch_size
samples_per_second = batch_size /... | if rank <= 0:
hf_config = hf_model.config
num_layers, hidden_size, vocab_size = get_hf_configs(hf_config)
gpus_per_model = torch.distributed.get_world_size()
seq_length = args.max_seq_len
batch_size = args.per_device_train_batch_size
samples_per_second = batch_size /... | 139 | 422 | 583 | 1,005 | import torch
# This function can be used to print throughput for Step 1 and 2 only
def print_throughput(hf_model, args, e2e_time, rank=0):
FILL_FUNC_BODYdef calculate_flops(checkpoint_activations_factor, batch_size, seq_length, hf_config):
num_layers, hidden_size, vocab_size = get_hf_configs(hf_config)
# TODO... | import torch
# This function can be used to print throughput for Step 1 and 2 only
def print_throughput(hf_model, args, e2e_time, rank=0):
FILL_FUNC_BODYdef calculate_flops(checkpoint_activations_factor, batch_size, seq_length, hf_config):
num_layers, hidden_size, vocab_size = get_hf_configs(hf_config)
# TODO... | |
15 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/quantization/gptq/eval_quantized_model.py | 4,5 | 1,46 | run_quantization | 5,35 | 5,35 | from transformers import AutoModelForCausalLM, AutoTokenizer
def run_quantization(args):
FILL_FUNC_BODYif __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Run GPTQ quantized model")
parser.add_argument("--model", type=str, help="The quantized name")
parser.add_arg... | from transformers import AutoModelForCausalLM, AutoTokenizer
def run_quantization(args):
FILL_FUNC_BODYif __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Run GPTQ quantized model")
parser.add_argument("--model", type=str, help="The quantized name")
parser.add_arg... | # Load model
tokenizer = AutoTokenizer.from_pretrained(
args.model,
trust_remote_code=args.trust_remote_code,
local_files_only=True,
legacy=True,
use_fast=False,
)
model = AutoModelForCausalLM.from_pretrained(
args.model,
device_map="cuda:0",
... | # Load model
tokenizer = AutoTokenizer.from_pretrained(
args.model,
trust_remote_code=args.trust_remote_code,
local_files_only=True,
legacy=True,
use_fast=False,
)
model = AutoModelForCausalLM.from_pretrained(
args.model,
device_map="cuda:0",
... | 52 | 154 | 311 | 465 | from transformers import AutoModelForCausalLM, AutoTokenizer
def run_quantization(args):
FILL_FUNC_BODYif __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Run GPTQ quantized model")
parser.add_argument("--model", type=str, help="The quantized name")
parser.add_arg... | from transformers import AutoModelForCausalLM, AutoTokenizer
def run_quantization(args):
FILL_FUNC_BODYif __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Run GPTQ quantized model")
parser.add_argument("--model", type=str, help="The quantized name")
parser.add_arg... | |
16 | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi | /home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/quantization/gptq/quant_autogptq.py | 7,8 | 1,69 | run_quantization | 8,43 | 8,43 | import argparse
import logging
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GPTQConfig
def run_quantization(args):
FILL_FUNC_BODYif __name__ == "__main__":
logger = logging.getLogger()
logging.basicConfig(
format="%(asctime)s %(levelname)s [%(name)s] %(message)s",
... | import argparse
import logging
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GPTQConfig
def run_quantization(args):
FILL_FUNC_BODYif __name__ == "__main__":
logger = logging.getLogger()
logging.basicConfig(
format="%(asctime)s %(levelname)s [%(name)s] %(message)s",
... | # Load model
tokenizer = AutoTokenizer.from_pretrained(
args.model,
trust_remote_code=args.trust_remote_code,
local_files_only=True,
legacy=True,
use_fast=False,
)
model_config = AutoConfig.from_pretrained(
args.model,
trust_remote_code=args.trust... | # Load model
tokenizer = AutoTokenizer.from_pretrained(
args.model,
trust_remote_code=args.trust_remote_code,
local_files_only=True,
legacy=True,
use_fast=False,
)
model_config = AutoConfig.from_pretrained(
args.model,
trust_remote_code=args.trust... | 52 | 372 | 354 | 726 | import argparse
import logging
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GPTQConfig
def run_quantization(args):
FILL_FUNC_BODYif __name__ == "__main__":
logger = logging.getLogger()
logging.basicConfig(
format="%(asctime)s %(levelname)s [%(name)s] %(message)s",
... | import argparse
import logging
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GPTQConfig
def run_quantization(args):
FILL_FUNC_BODYif __name__ == "__main__":
logger = logging.getLogger()
logging.basicConfig(
format="%(asctime)s %(levelname)s [%(name)s] %(message)s",
... | |
20 | /home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim | /home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/docs/example.py | 4,5 | 3,21 | construct | SquareToCircle | 5,21 | 5,21 | class SquareToCircle(Scene):
def construct(self):
FILL_FUNC_BODY | class SquareToCircle(Scene):
def construct(self):
FILL_FUNC_BODY | circle = Circle()
circle.set_fill(BLUE, opacity=0.5)
circle.set_stroke(BLUE_E, width=4)
square = Square()
self.play(ShowCreation(square))
self.wait()
self.play(ReplacementTransform(square, circle))
self.wait()
# Try typing the following lines
... | circle = Circle()
circle.set_fill(BLUE, opacity=0.5)
circle.set_stroke(BLUE_E, width=4)
square = Square()
self.play(ShowCreation(square))
self.wait()
self.play(ReplacementTransform(square, circle))
self.wait()
# Try typing the following lines
... | 40 | 27 | 222 | 249 | from manimlib import *
class SquareToCircle(Scene):
def construct(self):
FILL_FUNC_BODYclass SquareToCircleEmbed(Scene):
def construct(self):
circle = Circle()
circle.set_fill(BLUE, opacity=0.5)
circle.set_stroke(BLUE_E, width=4)
self.add(circle)
self.wait()
sel... | from manimlib import *
class SquareToCircle(Scene):
def construct(self):
FILL_FUNC_BODYclass SquareToCircleEmbed(Scene):
def construct(self):
circle = Circle()
circle.set_fill(BLUE, opacity=0.5)
circle.set_stroke(BLUE_E, width=4)
self.add(circle)
self.wait()
sel... |
21 | /home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim | /home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/docs/example.py | 22,23 | 21,38 | construct | SquareToCircleEmbed | 23,38 | 23,38 | class SquareToCircleEmbed(Scene):
def construct(self):
FILL_FUNC_BODY | class SquareToCircleEmbed(Scene):
def construct(self):
FILL_FUNC_BODY | circle = Circle()
circle.set_fill(BLUE, opacity=0.5)
circle.set_stroke(BLUE_E, width=4)
self.add(circle)
self.wait()
self.play(circle.animate.stretch(4, dim=0))
self.wait(1.5)
self.play(Rotate(circle, TAU / 4))
self.wait(1.5)
self.play(cir... | circle = Circle()
circle.set_fill(BLUE, opacity=0.5)
circle.set_stroke(BLUE_E, width=4)
self.add(circle)
self.wait()
self.play(circle.animate.stretch(4, dim=0))
self.wait(1.5)
self.play(Rotate(circle, TAU / 4))
self.wait(1.5)
self.play(cir... | 27 | 30 | 215 | 245 | from manimlib import *
class SquareToCircle(Scene):
def construct(self):
circle = Circle()
circle.set_fill(BLUE, opacity=0.5)
circle.set_stroke(BLUE_E, width=4)
square = Square()
self.play(ShowCreation(square))
self.wait()
self.play(ReplacementTransform(squa... | from manimlib import *
class SquareToCircle(Scene):
def construct(self):
circle = Circle()
circle.set_fill(BLUE, opacity=0.5)
circle.set_stroke(BLUE_E, width=4)
square = Square()
self.play(ShowCreation(square))
self.wait()
self.play(ReplacementTransform(squa... |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 8