Remove-auth-token (#27060)
* don't use `use_auth_token`internally * let's use token everywhere * fixup
This commit is contained in:
@@ -1117,7 +1117,7 @@ params = model.init(key2, x)
|
||||
|
||||
bytes_output = serialization.to_bytes(params)
|
||||
|
||||
repo = Repository("flax-model", clone_from="flax-community/flax-model-dummy", use_auth_token=True)
|
||||
repo = Repository("flax-model", clone_from="flax-community/flax-model-dummy", token=True)
|
||||
with repo.commit("My cool Flax model :)"):
|
||||
with open("flax_model.msgpack", "wb") as f:
|
||||
f.write(bytes_output)
|
||||
|
||||
@@ -250,7 +250,7 @@ def main():
|
||||
"nielsr/funsd-layoutlmv3",
|
||||
data_args.dataset_config_name,
|
||||
cache_dir=model_args.cache_dir,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
elif data_args.dataset_name == "cord":
|
||||
# Downloading and loading a dataset from the hub.
|
||||
@@ -258,7 +258,7 @@ def main():
|
||||
"nielsr/cord-layoutlmv3",
|
||||
data_args.dataset_config_name,
|
||||
cache_dir=model_args.cache_dir,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
else:
|
||||
raise ValueError("This script only supports either FUNSD or CORD out-of-the-box.")
|
||||
@@ -313,7 +313,7 @@ def main():
|
||||
finetuning_task=data_args.task_name,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
|
||||
processor = AutoProcessor.from_pretrained(
|
||||
@@ -321,7 +321,7 @@ def main():
|
||||
cache_dir=model_args.cache_dir,
|
||||
use_fast=True,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
add_prefix_space=True,
|
||||
apply_ocr=False,
|
||||
)
|
||||
@@ -332,7 +332,7 @@ def main():
|
||||
config=config,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
|
||||
# Set the correspondences label/ID inside the model config
|
||||
|
||||
@@ -325,7 +325,7 @@ def main():
|
||||
config=config,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
else:
|
||||
logger.info("Training new model from scratch")
|
||||
|
||||
@@ -322,14 +322,14 @@ def main():
|
||||
model_args.config_name if model_args.config_name else model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
model_args.tokenizer_name if model_args.tokenizer_name else model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
use_fast=True,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
model = QDQBertForQuestionAnswering.from_pretrained(
|
||||
model_args.model_name_or_path,
|
||||
@@ -337,7 +337,7 @@ def main():
|
||||
config=config,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
|
||||
# Tokenizer check: this script requires a fast tokenizer.
|
||||
|
||||
@@ -65,7 +65,7 @@ def normalize_text(text: str) -> str:
|
||||
|
||||
def main(args):
|
||||
# load dataset
|
||||
dataset = load_dataset(args.dataset, args.config, split=args.split, use_auth_token=True)
|
||||
dataset = load_dataset(args.dataset, args.config, split=args.split, token=True)
|
||||
|
||||
# for testing: only process the first two examples as a test
|
||||
# dataset = dataset.select(range(10))
|
||||
|
||||
@@ -418,7 +418,7 @@ def main():
|
||||
data_args.dataset_name,
|
||||
data_args.dataset_config_name,
|
||||
split=data_args.train_split_name,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
)
|
||||
|
||||
if data_args.audio_column_name not in raw_datasets["train"].column_names:
|
||||
@@ -443,7 +443,7 @@ def main():
|
||||
data_args.dataset_name,
|
||||
data_args.dataset_config_name,
|
||||
split=data_args.eval_split_name,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
)
|
||||
|
||||
if data_args.max_eval_samples is not None:
|
||||
@@ -481,7 +481,7 @@ def main():
|
||||
# the tokenizer
|
||||
# load config
|
||||
config = AutoConfig.from_pretrained(
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, use_auth_token=data_args.use_auth_token
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, token=data_args.use_auth_token
|
||||
)
|
||||
|
||||
# 4. Next, if no tokenizer file is defined,
|
||||
@@ -532,11 +532,11 @@ def main():
|
||||
# load feature_extractor and tokenizer
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
tokenizer_name_or_path,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
**tokenizer_kwargs,
|
||||
)
|
||||
feature_extractor = AutoFeatureExtractor.from_pretrained(
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, use_auth_token=data_args.use_auth_token
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, token=data_args.use_auth_token
|
||||
)
|
||||
|
||||
# adapt config
|
||||
@@ -564,7 +564,7 @@ def main():
|
||||
model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
config=config,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
)
|
||||
|
||||
# freeze encoder
|
||||
|
||||
@@ -395,7 +395,7 @@ def main():
|
||||
# so we just need to set the correct target sampling rate and normalize the input
|
||||
# via the `feature_extractor`
|
||||
feature_extractor = AutoFeatureExtractor.from_pretrained(
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, use_auth_token=data_args.use_auth_token
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, token=data_args.use_auth_token
|
||||
)
|
||||
|
||||
if training_args.do_train:
|
||||
@@ -403,7 +403,7 @@ def main():
|
||||
path=data_args.dataset_name,
|
||||
name=data_args.dataset_config_name,
|
||||
split=data_args.train_split_name,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
streaming=True,
|
||||
sampling_rate=feature_extractor.sampling_rate,
|
||||
)
|
||||
@@ -431,7 +431,7 @@ def main():
|
||||
path=data_args.dataset_name,
|
||||
name=data_args.dataset_config_name,
|
||||
split=data_args.eval_split_name,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
streaming=True,
|
||||
sampling_rate=feature_extractor.sampling_rate,
|
||||
)
|
||||
@@ -465,7 +465,7 @@ def main():
|
||||
# 3. Next, let's load the config as we might need it to create
|
||||
# the tokenizer
|
||||
config = AutoConfig.from_pretrained(
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, use_auth_token=data_args.use_auth_token
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, token=data_args.use_auth_token
|
||||
)
|
||||
|
||||
# 4. Now we can instantiate the tokenizer and model
|
||||
@@ -481,7 +481,7 @@ def main():
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
tokenizer_name_or_path,
|
||||
config=config,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
)
|
||||
|
||||
# adapt config
|
||||
@@ -509,7 +509,7 @@ def main():
|
||||
model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
config=config,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
)
|
||||
|
||||
# freeze encoder
|
||||
|
||||
@@ -292,7 +292,7 @@ def main():
|
||||
num_labels=num_labels,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
# load tapex tokenizer
|
||||
tokenizer = TapexTokenizer.from_pretrained(
|
||||
@@ -300,7 +300,7 @@ def main():
|
||||
cache_dir=model_args.cache_dir,
|
||||
use_fast=model_args.use_fast_tokenizer,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
add_prefix_space=True,
|
||||
)
|
||||
model = BartForSequenceClassification.from_pretrained(
|
||||
@@ -309,7 +309,7 @@ def main():
|
||||
config=config,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
|
||||
# Padding strategy
|
||||
|
||||
@@ -329,7 +329,7 @@ def main():
|
||||
model_args.config_name if model_args.config_name else model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
|
||||
# IMPORTANT: the initial BART model's decoding is penalized by no_repeat_ngram_size, and thus
|
||||
@@ -344,7 +344,7 @@ def main():
|
||||
cache_dir=model_args.cache_dir,
|
||||
use_fast=model_args.use_fast_tokenizer,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
add_prefix_space=True,
|
||||
)
|
||||
|
||||
@@ -355,7 +355,7 @@ def main():
|
||||
config=config,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
|
||||
if model.config.decoder_start_token_id is None:
|
||||
|
||||
@@ -327,7 +327,7 @@ def main():
|
||||
model_args.config_name if model_args.config_name else model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
|
||||
# IMPORTANT: the initial BART model's decoding is penalized by no_repeat_ngram_size, and thus
|
||||
@@ -342,7 +342,7 @@ def main():
|
||||
cache_dir=model_args.cache_dir,
|
||||
use_fast=model_args.use_fast_tokenizer,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
add_prefix_space=True,
|
||||
)
|
||||
|
||||
@@ -353,7 +353,7 @@ def main():
|
||||
config=config,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
)
|
||||
|
||||
if model.config.decoder_start_token_id is None:
|
||||
|
||||
@@ -502,7 +502,7 @@ def main():
|
||||
data_args.dataset_name,
|
||||
config_name,
|
||||
split=data_args.train_split_name,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
cache_dir=model_args.cache_dir,
|
||||
)
|
||||
|
||||
@@ -528,7 +528,7 @@ def main():
|
||||
data_args.dataset_name,
|
||||
config_name,
|
||||
split=data_args.eval_split_name,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
cache_dir=model_args.cache_dir,
|
||||
)
|
||||
|
||||
@@ -540,7 +540,7 @@ def main():
|
||||
data_args.dataset_name,
|
||||
config_name,
|
||||
split=data_args.predict_split_name,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
cache_dir=model_args.cache_dir,
|
||||
)
|
||||
|
||||
@@ -595,7 +595,7 @@ def main():
|
||||
# 3. Next, let's load the config as we might need it to create
|
||||
# the tokenizer
|
||||
config = AutoConfig.from_pretrained(
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, use_auth_token=data_args.use_auth_token
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, token=data_args.use_auth_token
|
||||
)
|
||||
|
||||
if is_text_target:
|
||||
@@ -651,11 +651,11 @@ def main():
|
||||
if is_text_target:
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
tokenizer_name_or_path,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
**tokenizer_kwargs,
|
||||
)
|
||||
feature_extractor = AutoFeatureExtractor.from_pretrained(
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, use_auth_token=data_args.use_auth_token
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, token=data_args.use_auth_token
|
||||
)
|
||||
|
||||
# adapt config
|
||||
@@ -694,14 +694,14 @@ def main():
|
||||
model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
config=config,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
)
|
||||
elif config.is_encoder_decoder:
|
||||
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
||||
model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
config=config,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
)
|
||||
if model.config.decoder_start_token_id is None:
|
||||
raise ValueError("Make sure that `config.decoder_start_token_id` is correctly defined")
|
||||
@@ -710,7 +710,7 @@ def main():
|
||||
model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
config=config,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
token=data_args.use_auth_token,
|
||||
)
|
||||
|
||||
# freeze encoder
|
||||
|
||||
Reference in New Issue
Block a user