export default async function embed(sentence: string): Promise<Float32Array> {
const result = await extractor(sentence, {
pooling: "mean",
normalize: true,
});
return result.data as Float32Array; // the vector
}
Hello, consider this code. Here I have cast result.data. Normally, result is a tensor and result.data is of type DataArray. This doesn't align with the data Float32Array so I've just cast it, is it ok/recommended or is there a better way of doing it pls.