Andre Bandarra: From PyTorch to Browser: Creating a Web-Friendly AI Model

Link: From PyTorch to Browser: Creating a Web-Friendly AI Model
I loved this post from Andre about running sentiment analysis in the browser using a model that he’d trained on embeddings generated from a YouTube comments data was great and shows that you don’t have to run everything through the full language model and instead can use just the embedding APIs to get a decent result.
The client side part of the code can be seen below:


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan

Link: From PyTorch to Browser: Creating a Web-Friendly AI Model

I loved this post from Andre about running sentiment analysis in the browser using a model that he'd trained on embeddings generated from a YouTube comments data was great and shows that you don't have to run everything through the full language model and instead can use just the embedding APIs to get a decent result.

The client side part of the code can be seen below:

const input = 'Hello, your video is amazing!'; const embedResult = await genAi.models.embedContent({ model: 'text-embedding-004', contents: [input], }); const embeddings = embedResult.embeddings.map(embedding => embedding.values); const outputTensor = await model.predict(tf.tensor2d(embeddings)); const argmax = await tf.argMax(outputTensor, 1).array(); const labels = ['Positive', 'Neutral', 'Negative']; const results = argmax.map(i => labels[i]); console.log(results);

const probabilities = await tf.softmax(outputTensor, 1).array() console.log(probabilities);


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan


Print Share Comment Cite Upload Translate Updates
APA

Paul Kinlan | Sciencx (2025-05-02T12:50:17+00:00) Andre Bandarra: From PyTorch to Browser: Creating a Web-Friendly AI Model. Retrieved from https://www.scien.cx/2025/05/02/andre-bandarra-from-pytorch-to-browser-creating-a-web-friendly-ai-model/

MLA
" » Andre Bandarra: From PyTorch to Browser: Creating a Web-Friendly AI Model." Paul Kinlan | Sciencx - Friday May 2, 2025, https://www.scien.cx/2025/05/02/andre-bandarra-from-pytorch-to-browser-creating-a-web-friendly-ai-model/
HARVARD
Paul Kinlan | Sciencx Friday May 2, 2025 » Andre Bandarra: From PyTorch to Browser: Creating a Web-Friendly AI Model., viewed ,<https://www.scien.cx/2025/05/02/andre-bandarra-from-pytorch-to-browser-creating-a-web-friendly-ai-model/>
VANCOUVER
Paul Kinlan | Sciencx - » Andre Bandarra: From PyTorch to Browser: Creating a Web-Friendly AI Model. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/05/02/andre-bandarra-from-pytorch-to-browser-creating-a-web-friendly-ai-model/
CHICAGO
" » Andre Bandarra: From PyTorch to Browser: Creating a Web-Friendly AI Model." Paul Kinlan | Sciencx - Accessed . https://www.scien.cx/2025/05/02/andre-bandarra-from-pytorch-to-browser-creating-a-web-friendly-ai-model/
IEEE
" » Andre Bandarra: From PyTorch to Browser: Creating a Web-Friendly AI Model." Paul Kinlan | Sciencx [Online]. Available: https://www.scien.cx/2025/05/02/andre-bandarra-from-pytorch-to-browser-creating-a-web-friendly-ai-model/. [Accessed: ]
rf:citation
» Andre Bandarra: From PyTorch to Browser: Creating a Web-Friendly AI Model | Paul Kinlan | Sciencx | https://www.scien.cx/2025/05/02/andre-bandarra-from-pytorch-to-browser-creating-a-web-friendly-ai-model/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.