Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Apr 25, 2024
2 parents f195b66 + cf25160 commit f4b19a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions javascript/encoders.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class TextProcessor {
async process(texts) {

const encoded = await this.tokenizer(texts, {
addSpecialTokens: true,
returnAttentionMask: true,
add_special_tokens: true,
padding: 'max_length',
max_length: this.maxSeqLen,
truncation: true,
Expand Down
6 changes: 3 additions & 3 deletions javascript/encoders_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async function tryImageEncoderForwardPass(modelId) {
}

function cosineSimilarity(vecA, vecB) {
// We may be receiving a complex tesnor type, so let's check if it
// We may be receiving a complex tensor type, so let's check if it
// has an array member named `data`.
if (vecA.data) {
vecA = vecA.data;
Expand Down Expand Up @@ -180,8 +180,8 @@ async function tryCrossReferencingImageAndText(modelId) {
const textEmbedding = await textEncoder.encode(processedText);
const imageEmbedding = await imageEncoder.encode(processedImage);

textEmbeddings.push(new Float32Array(textEmbedding.embeddings.cpuData));
imageEmbeddings.push(new Float32Array(imageEmbedding.embeddings.cpuData));
textEmbeddings.push(new Float32Array(textEmbedding.embeddings.data));
imageEmbeddings.push(new Float32Array(imageEmbedding.embeddings.data));

// Print-based debugging at its best :)
// console.log(`Text: ${text}, Image: ${imageUrl}`);
Expand Down

0 comments on commit f4b19a8

Please sign in to comment.