Using pretrained AI models in Elixir / Phoenix application

This year the Elixir team has made a huge progress in the AI area, it has started with NX, then came Axon with somewhat higher level API and finally Bumblebee which makes using pretrained AI models and integrating them into Phoenix app really easy (I hate it when people say that, but in this case it’s the truth – it’s easy).

This Christmas I finally got to play with it and was surprised at how well it went. Bumblebee is still very new, the documentation is “fresh”, but despite that, it works quite well. There are also few libraries that would help working with the data (Scholar, Explorer, all came this year), but the important part is that we now have the ability to use available open source models without the need to train them.

I am not sure how commercially viable it is, but it’s definitely fun to play with ๐Ÿ™‚

Here’s the result showcasing few models integrated into a sample Phoenix application.

Streaming Data From The Database In Elixir

Say we have a search feature and an index_article/1 function that knows what to do with the given article – can fetch all related data, concatenate it into a tsvector field and then save in the search cache table. With it we can index any article – so far so good.

Now what if we want to rebuild the whole search index? Looping over each entry in the database and indexing it with the existing function would work, but will require loading everything in RAM which will definitely break in the long run.

Usually we would create some kind of Task that loops as long as there are unprocessed entries in the Database, takes a number of those entries, processes each of them adjusts offset etc.

Well, Elixir can do better, using Repo.stream/2 we can create a stream that we can use with the Stream module, this way we can greatly simplify the above logic.

Here is the whole function that reindexes all articles of the given type:
Continue reading

Recover Linux Dual Boot after update to Windows 10

Here’s the problem: I dual boot Windows 7 and Ubuntu 14.04, after deciding to upgrade Windows to 10, I ended up with upgrade partially finished and GRUB going into rescue mode.

That means that Windows messed up GRUB and possibly corrupted Linux’s partition. Here are basic steps I had to take to recover Linux + Windows dual boot (make sure you have a live USB to boot from): Continue reading

AI Web Develoment

Here is a fancy new project: the worldโ€™s first AI platform that designs websites. And the Worlds very first AI developer seems to speak English and have a sense of humor ๐Ÿ™‚

Here is what they say on their website:

This is not a website builder. This is your personal AI web developer. Its first masterpiece is the website you’re looking at right now.

Sure thing it makes sense to look into the code, turns out there are actually some helpful comments in English, like these:

// Don't follow link
      event.preventDefault();

or even like these:

catch (e) {
    // noop
  }

Man, it’s Super-Future-Cyberpunk-Christmas-Today, this things seems like fun until it actually decides to take over the world.

Fix No Sound in Steam for Linux Problem

There is an issue with Steam for Linux that seem to be persistent on machines with HDMI enabled displays or similar unused HD audio inputs.

Steam for Linux seems to use these controllers despite them being ignored by the system, which results in weirdly muted games while YouTube as well as any sound tests are loud and clear.

To fix this issue open sound settings and select analog controller or (for pulseaudio sound server) install pulseaudio volume control

sudo apt-get install pavucontrol

under “Output Devices” check if it tries to use the HD audio controller to output sound, go to “Configuration” and disable the HD audio controller profile so that analog audio will always be used.