Skip to content

Instantly share code, notes, and snippets.

@a-agmon
Created July 7, 2024 13:10
Show Gist options
  • Save a-agmon/5fac5fdde9e427ba0574d122fbddc751 to your computer and use it in GitHub Desktop.
Save a-agmon/5fac5fdde9e427ba0574d122fbddc751 to your computer and use it in GitHub Desktop.
fn process_text_file(sender: Sender<EmbeddingEntry>, filename: &str) -> anyhow::Result<()> {
let bert_model = models::bert::get_model_reference(EMB_MODEL_ID, EMB_MODEL_REV)?;
let text_chunks: Vec<&str> = read_file_in_chunks(filename, 256)?;
let file_vector = embed_multiple_sentences(&text_chunks, false, &bert_model)?;
sender.send(EmbeddingEntry {
filename: filename.to_string(),
embedding: file_vector[0].clone(),
})?;
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment