Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fast tokenizer conversion should happen offline #106

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions launcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,19 +870,24 @@ fn save_fast_tokenizer(
info!("Saving fast tokenizer for `{model_name}` to `{save_path}`");
let model_name = model_name.escape_default();
let revision = revision.map(|v| v.escape_default());
let code = if let Some(revision) = revision {
format!(
"from transformers import AutoTokenizer; \
AutoTokenizer.from_pretrained(\"{model_name}\", \
revision=\"{revision}\", local_files_only=True).save_pretrained(\"{save_path}\")"
)
let revision_arg = if let Some(revision) = revision {
format!("revision=\"{revision}\", ")
} else {
format!(
"from transformers import AutoTokenizer; \
AutoTokenizer.from_pretrained(\"{model_name}\").save_pretrained(\"{save_path}\")"
)
"".to_string()
};
match Command::new("python").args(["-c", &code]).status() {
let code = format!(
"from transformers import AutoTokenizer; \
AutoTokenizer.from_pretrained( \
\"{model_name}\", \
{revision_arg} \
local_files_only=True \
).save_pretrained(\"{save_path}\")"
);
match Command::new("python")
.args(["-c", &code])
.env("HF_HUB_OFFLINE", "1")
.status()
{
Ok(status) => {
if status.success() {
Ok(())
Expand Down