Prefer safetensors to pytorch when both are available

This commit is contained in:
Louis Dureuil 2024-04-03 11:05:59 +02:00
parent 75f81a0bab
commit a1eccc762a
No known key found for this signature in database

View File

@ -87,11 +87,11 @@ impl Embedder {
let config = api.get("config.json").map_err(NewEmbedderError::api_get)?; let config = api.get("config.json").map_err(NewEmbedderError::api_get)?;
let tokenizer = api.get("tokenizer.json").map_err(NewEmbedderError::api_get)?; let tokenizer = api.get("tokenizer.json").map_err(NewEmbedderError::api_get)?;
let (weights, source) = { let (weights, source) = {
api.get("pytorch_model.bin") api.get("model.safetensors")
.map(|filename| (filename, WeightSource::Pytorch)) .map(|filename| (filename, WeightSource::Safetensors))
.or_else(|_| { .or_else(|_| {
api.get("model.safetensors") api.get("pytorch_model.bin")
.map(|filename| (filename, WeightSource::Safetensors)) .map(|filename| (filename, WeightSource::Pytorch))
}) })
.map_err(NewEmbedderError::api_get)? .map_err(NewEmbedderError::api_get)?
}; };