mirror of
https://github.com/huggingface/candle.git
synced 2025-06-20 12:06:35 +00:00
BERT Wasm (#902)
* implement wasm module * add example to workspace * add UI explore semantic similiarity * change status messages * formatting * minor changes
This commit is contained in:
20
candle-wasm-examples/bert/src/lib.rs
Normal file
20
candle-wasm-examples/bert/src/lib.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use candle_transformers::models::bert;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
pub use bert::{BertModel, Config, DTYPE};
|
||||
pub use tokenizers::{PaddingParams, Tokenizer};
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
// Use `js_namespace` here to bind `console.log(..)` instead of just
|
||||
// `log(..)`
|
||||
#[wasm_bindgen(js_namespace = console)]
|
||||
pub fn log(s: &str);
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! console_log {
|
||||
// Note that this is using the `log` function imported above during
|
||||
// `bare_bones`
|
||||
($($t:tt)*) => ($crate::log(&format_args!($($t)*).to_string()))
|
||||
}
|
Reference in New Issue
Block a user