Firefox AI Runtime
1
1
Tarek Ziadé
Creator of the French Python User Group (Afpy)
Part of the Firefox AI/ML team at Mozilla
Author of some books about Python
Gawel et Tarek - Pycon FR 2009
2
Firefox AI Runtime Goal
Provide an inference API that runs offline, that we can use for our internal use cases, and surface it for web extension developers.
3
Firefox Translations
4
Firefox Translations / Architecture
Web Page
Inference Process
bergamot.wasm
Remote Settings
Eng -> FR
Gemmology
avx-vnni
neon i8mm
5
Beyond translation
How can we support more inference tasks ?
Can’t use Bergamot
6
🤗 Transformers.js
7
Example
const captioner = await pipeline('image-to-text',
'Xenova/vit-gpt2-image-captioning');
const url = 'https://example.com/cats.jpg';
const output = await captioner(url);
// [{ generated_text: 'a cat laying on a couch with another cat' }]
8
Transformers.js @ Firefox 133+
Web Page
Inference Process
onnx.wasm
Remote Settings
https://model-hub.mozilla.org
bergamot.wasm
9
PDF.js alt-text
10
Enabling the �Mozilla Community
to build AI/ML features in Firefox
Do not zoom on people faces, it’s scary
11
WebExtensions AI API
12
WebExtensions AI API
// SVE - Smallest Viable Example
// 1. Create the ML engine.
await browser.trial.ml.createEngine({taskName: "summarization"});
// 2. Call it.
const res = await browser.trial.ml.runEngine({
args: ["This is the text to summarize"],
});
// 3. Display the results.
console.log(res);
13
Demo. Let’s build a web extension.
Internet has always been about cats.
14
Thanks!
Discord : https://discord.gg/Jmmq9mGwy7
All the doc https://firefox-source-docs.mozilla.org/toolkit/components/ml/
Full example : https://searchfox.org/mozilla-central/source/toolkit/components/ml/docs/extensions-api-example
15