fix(embed): to_dtype F32 before to_vec1以适应 F16 模型
ci / cargo fmt (push) Failing after 1m45s
ci / cargo clippy (push) Failing after 4m20s
ci / build and test (push) Successful in 4m33s

This commit is contained in:
dengxuan
2026-07-25 14:12:07 +08:00
parent 2df0929440
commit 968d800110
+1 -1
View File
@@ -49,7 +49,7 @@ impl<'a> MiniCPM4GenerateModel<'a> {
pub fn embed_text(&mut self, text: &str) -> Result<Vec<f32>> {
let input_ids = self.tokenizer.text_encode(text.to_string(), &self.device)?;
let embedding = self.model.embed(&input_ids)?;
let vec: Vec<f32> = embedding.flatten_all()?.to_vec1()?;
let vec: Vec<f32> = embedding.flatten_all()?.to_dtype(DType::F32)?.to_vec1()?;
Ok(vec)
}