Skip to content

Commit 2a9f924

Browse files
committed
Set pad_token_id in ModelConfig as Option
It can be provided / set to `null` e.g., https://huggingface.co/jinaai/jina-embeddings-v5-text-small-retrieval/blob/main/config.json#L51
1 parent b38b8f1 commit 2a9f924

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

router/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub async fn run(
108108
// Load config
109109
let config_path = model_root.join("config.json");
110110
let config = fs::read_to_string(config_path).context("`config.json` not found")?;
111+
tracing::info!("config contains {:?}", config);
111112
let config: ModelConfig =
112113
serde_json::from_str(&config).context("Failed to parse `config.json`")?;
113114

@@ -181,7 +182,7 @@ pub async fn run(
181182
|| &config.model_type == "camembert"
182183
|| &config.model_type == "roberta"
183184
{
184-
config.pad_token_id + 1
185+
config.pad_token_id.unwrap_or(0) + 1
185186
} else {
186187
0
187188
};
@@ -459,7 +460,7 @@ pub struct ModelConfig {
459460
#[serde(alias = "n_positions")]
460461
pub max_position_embeddings: usize,
461462
#[serde(default)]
462-
pub pad_token_id: usize,
463+
pub pad_token_id: Option<usize>,
463464
pub id2label: Option<HashMap<String, String>>,
464465
pub label2id: Option<HashMap<String, usize>>,
465466
pub auto_map: Option<HashMap<String, String>>,

0 commit comments

Comments
 (0)