Lurker News
Hi HN,

OpenAI recently released a model for automatic speech recognition called Whisper [0]. I decided to reimplement the inference of the model from scratch using C/C++. To achieve this I implemented a minimalistic tensor library in C and ported the high-level architecture of the model in C++. The entire code is less than 8000 lines of code and is contained in just 2 source files without any third-party dependencies. The Github project is here:
https://github.com/ggerganov/whisper.cpp
With this implementation I can very easily build and run the model - “make base.en”. It also allows me to run it on a wide range of devices. For example, I have provided examples of running the model on an iPhone, Raspberry Pi 4 and even in a web page via WebAssembly!
The implementation runs fully on the CPU and utilizes FP16, AVX intrinsics on x86 architectures and NEON + Accelerate framework on Apple Silicon. The latter is especially efficient and I observe that the inference is about 2-3 times faster compared to the current PyTorch implementation provided by OpenAI when running it on my MacBook M1 Pro. The WASM port utilizes SIMD 128-bit intrinsics - a feature supported in some modern web browsers [1].
I am very happy with the performance that I observe on Apple Silicon devices. I didn’t expect that the Accelerate framework [2] (i.e. CBLAS) offers such a dramatic performance boost for matrix multiplications so I was very pleasantly surprised! To enable the framework in your C/C++ projects, all you have to do is add `-framework Accelerate` to your clang command-line flags.
This entire exercise of implementing the Whisper model was very interesting to me and helped me understand a lot about how the transformer architecture works. I also got a lot of positive feedback from people finding and using my project. We brainstormed on a lot of interesting tools that can potentially be created with this library (such as speech-to-text plugin for Vim, RPi4 voice assistant, WASM chat bot, etc). If interested, checkout the “Examples” section and the “Show and tell” discussions for some ideas!
Would love to know what you think about this project and about your experience with using the Accelerate framework in any of your projects. Cheers!
[0] https://github.com/openai/whisper
[1] https://chromestatus.com/feature/6533147810332672
[2] https://developer.apple.com/documentation/accelerate

Comments (87) 48 threads

Show all comments

Showing thread 38 of 48

jarbus1 reply#
There are tons of open source STT models, what makes whisper so valuable? I especially don't get it on mobile, where the native STT built into the OS is now real-time and includes punctuation (at least for iOS). I love the open-source approach to the model, but it didn't strike me as particularly better than other open-source or built-in models.
fastball1 reply#
In my limited testing, I've found Whisper to be much better (accuracy-wise) than other STT models.
jarbus1 reply#
For some reason, I recalled Whisper to be on-par or slightly worse than the other open source ones, but much better across languages. I appear to be wrong.
Jayakumark#
Just curious on What open source ones did you compare them with ? do you mean WER was high or ?