Digital Sleuthing: Extracting Artist Names from a Book Using Technology | May 31 2024, 01:50

How convenient it has become to work with books nowadays. On Saturday, Alla Prima II by artist Richard Schmid will arrive for me. But even before the purchase, I couldn’t resist and found a 500MB PDF version of the book online, and have already read 50 pages. And then I thought, what if I wanted to extract all the mentioned artists in the book, could I do it?

It turned out to be quite simple.

1) Split the PDF into individual pages using pdfseparate . This resulted in 332 PDFs totaling 472 MB. It takes a few minutes.

2) Convert the individual PDFs to JPG using pdftoppm -jpeg . This resulted in 332 JPGs. It takes a few minutes.

3) Recognize the text using tesseract . This process takes about 10 minutes.

4) Pass each page’s text to the local llama3, and request it to extract the names of artists from the text of each of the 332 pages (i.e., 332 requests). On my Mac, this took 12 minutes. In the end, I got 953 lines.

Llama3 is a bit slow, but overall it does reasonably well. It generates a lot of “noise” also like “Based on the provided text, here are the extracted names of painters” or “I’m happy to help!”. The output text after processing 332 pages is small, only 953 lines. We sort it, remove duplicates (resulted in 556). We remove all more than three words and fewer than two words through cat names.txt | awk ‘NF>=2 && NF<=4’. Ended up with 139 lines. Among them, there is still some noise, for example, names like “Cobalt Blue”, “What an interesting text!” and “Sherlock Holmes” were included as artist names. To clean them up, we use openai, which is smarter. We ask it to keep only artists and remove everything else. We got the list.

Alfred Sisley, Alphonse Mucha, Anders Zorn, Andrew Loomis, Anton Sterba, Antonio Mancini, Arthur Rackham, Berthe Morisot, Bill Mosby, Cecilia Beaux, Charles Hunter, Claude Monet, Dan Gerhartz, Dean Mitchell, Diego Velazquez, Donald Llanuza, Edmund Tarbell, Edouard Manet, Edouard Vuillard, Edward Atkinson Hornel, Eliot Goldfinger, Elizabeth Sparhawk-Jones, Frank Duveneck, Frank Vincent DuMond, Franz Hals, Frederic Remington, Gene Byrnes, George Bridgman, Georges Seurat, Gilbert Stuart, Giovanni Boldini, Grace Arnold, Hans Holbein, Harry Anderson, Heinrich Kley, Henri de Toulouse-Lautrec, Howard Pyle, Ilya Repin, Isaac Levitan, J. W. Waterhouse, J. C. Leyendecker, J.H. Vanderpoel, James M. Dunlop, Jean Dagnan-Bouveret, Jeremy Lipking, Jessie H. Vanderpoel, Joaquin Sorolla, John Gannam, John Singer Sargent, John Singleton Copley, John Twachtman, Katie Swatland, Marcus Thomas, Mary Cassatt, Michael Wilcox, N. C. Wyeth, Nancy Guzik, Nicolai Fechin, Norman Rockwell, Paolo Michetti, Paul Mullally, Peter Paul Rubens, Philip Andreevich Maliavin, Ralph Mayer, Richard Schmid, Robert Henri, Rose Frantzen, Scott Burdick, Shannon Two, Stephen Rogers Peck, Susan Lyon, Thomas Eakins, Thomas Wilmer Dewing, Valentin Serov, Vincent Van Gogh, Wayman Adams, William H. Mosby, William Harnett, William Merritt Chase

5) Now, we send this list back to openai and ask if there are any non-artists among these names. It turned out that all are fine, all of them are artists.

6) For reliability, we also ask openai if there are names in this “clean” list that were not in the original (“dirty”) list, to check if openai invented any artist names when asked to extract from the “dirty” list. Great, it did not invent any.

Voilà! In just over half an hour, I have a list of artists mentioned in the book.

7) We ask openai to categorize the list and provide a brief description

RESULT

Impressionists and Post-Impressionists

=================================

* Alfred Sisley – French impressionist, known for his landscapes.

* Claude Monet – Founder of Impressionism, famous for his water lilies and series of landscapes.

* Berthe Morisot – French impressionist, known for her portraits and scenes from everyday life.

* Edouard Manet – French artist, a precursor to Impressionism, known for his portraits and scenes from Parisian life.

* Georges Seurat – French post-impressionist, founder of pointillism.

* Vincent Van Gogh – Dutch post-impressionist, known for his vivid and emotional paintings.

Realism and Academic Painting

=============================

* Edouard Vuillard – French artist, member of the Nabis group, known for his interiors and figurative compositions.

* Anders Zorn – Swedish artist, known for his portraits and genre scenes.

* Cecilia Beaux – American portrait artist who worked in the style of academic realism.

* Diego Velazquez – Spanish Baroque artist, known for his portraits and historical scenes.

* Edmund Tarbell – American artist, known for his impressionistic portraits and genre scenes.

* Franz Hals – Dutch portrait artist, one of the greatest artists of Holland’s Golden Age.

* Frederic Remington – American artist and sculptor, specialized in scenes of the Wild West.

* Gilbert Stuart – American artist, known for his portraits, including the depiction of George Washington.

* Hans Holbein – German Renaissance artist, known for his portraits and religious paintings.

* Ilya Repin – Russian realistic artist, known for his historical and genre paintings.

* Isaac Levitan – Russian landscape artist, master of lyrical landscape.

* John Singer Sargent – American portrait artist, known for his exquisite and elegant portraits.

* Thomas Eakins – American realist, known for his portraits and genre scenes.

* Valentin Serov – Russian portrait artist, one of the leading representatives of the Russian realistic school.

Art Nouveau and Illustration

=================================

* Alphonse Mucha – Czech artist, a key figure in Art Nouveau, known for his decorative posters.

* Arthur Rackham – British illustrator, known for his magical and fantastical images.

* Howard Pyle – American illustrator, founder of the Brandywine School of illustration.

* J. C. Leyendecker – American illustrator, known for his advertising and magazine covers.

* N. C. Wyeth – American illustrator and artist, known for his works for classic adventure novels.

* Norman Rockwell – American artist and illustrator, known for his idealized images of American life.

* Frank Vincent DuMond – American artist and educator, known for his landscapes and genre scenes.

Portraitists and Genre Artists

=============================

* Cecilia Beaux – American portrait artist who worked in the style of academic realism.

* Diego Velazquez – Spanish Baroque artist, known for his portraits and historical scenes.

* Franz Hals – Dutch portrait artist, one of the greatest artists of Holland’s Golden Age.

* John Singer Sargent – American portrait artist, known for his exquisite and elegant portraits.

* Thomas Eakins – American realist, known for his portraits and genre scenes.

* Valentin Serov – Russian portrait artist, one of the leading representatives of the Russian realistic school.

* Jean Dagnan-Bouveret – French academic artist, known for his genre scenes and portraits.

* Joaquin Sorolla – Spanish artist, master of light, known for his portraits and beach scenes.

* John Singleton Copley – American colonial artist, known for his portraits.

Masters of Landscape

==============

* Alfred Sisley – French impressionist, known for his landscapes.

* Claude Monet – Founder of Impressionism, famous for his water lilies and series of landscapes.

* Isaac Levitan – Russian landscape artist, master of lyrical landscape.

* John Twachtman – American impressionist, known for his lyrical landscapes.

* Dan Gerhartz – Contemporary American artist, known for his atmospheric landscapes and figurative works.

* Dean Mitchell – American artist, known for his watercolor landscapes and urban scenes.

Contemporary Artists

====================

* Dan Gerhartz – Contemporary American artist, known for his atmospheric landscapes and figurative works.

* Dean Mitchell – American artist, known for his watercolor landscapes and urban scenes.

* Jeremy Lipking – Contemporary American artist, known for his portraits and figurative works.

* Nancy Guzik – Contemporary American artist, known for her lyrical and romantic figurative works.

* Richard Schmid – American artist and educator, master of figurative painting.

Other Famous Artists

========================

* J. W. Waterhouse – British artist, known for his paintings on mythological and literary themes.

* Paolo Michetti – Italian artist, worked in the genres of realism and symbolism.

* Peter Paul Rubens – Flemish Baroque artist, known for his allegorical and mythological paintings.

* Gilbert Stuart – American artist, known for his portraits, including the depiction of George Washington.

* Giovanni Boldini – Italian portrait artist, known for his elegant and dynamic portraits.

* Henri de Toulouse-Lautrec – French post-impressionist, known for his posters and scenes of Parisian life.

* Howard Pyle – American illustrator, founder of the Brandywine School of illustration.

* Franz Hals – Dutch portrait artist, one of the greatest artists of Holland’s Golden Age.

* Frederic Remington – American artist and sculptor, specialized in scenes of the Wild West.

* Hans Holbein – German Renaissance artist, known for his portraits and religious paintings.

It’s amazing what you can now do with a computer and information!

LLMs Struggle with Simple Word Filtering Task | May 28 2024, 13:56

I recently encountered a task that no LLM can solve. It should be super simple for an LLM, but somehow they can’t manage it.

There’s a list of about 1000 words. I need to keep only the most functional words from it, like which, should, would, etc.

Request: I have a list of words: …. Select only 50 words from this list that are primarily functional and carry minimal meaning in the context of keyword searches (for example, which generate significant noise in the case of partial matches). Example – which, shall, very. Do not add any words not present on the list above. The resulting experienced list should contain only words, one word per line.

ChatGPT-4o: started outputting some words alphabetically, ending at the word asking. Thus, it did not even go past asking.

Google Gemini: began inventing words not in the list, despite clear instructions not to do so.

Google Gemini Pro: produced something, but again, invented words that weren’t on the list. Almost half invented.

Anthropic Claude also listed words alphabetically, and stopped at words starting with the letter d.

Mistral 8x7B Instruct also made up half.

In fact, no LLM has managed the task. And it’s about words, not mathematics.

https://pastebin.com/5B8w96au

Programming Quirks: Moon Phases and Easter Eggs in Code | May 26 2024, 11:19

Two fun stories about the daily life of programmers.

The first one:

Researchers (@maciejwolczyk, @CupiaBart) trained a neural network to play NetHack, an old role-playing game where everything is represented by text characters. It’s a very old RPG from the days (1987) when there were no normal user interfaces, and everything happened in the console. The player goes through levels, collects items and rewards, participates in battles, and scores points — all expressed through the simplest characters.

In general, they trained it. The model consistently scored 5000 points. However, suddenly something went wrong — the model started scoring only 3000 points. That is, it showed a significantly worse result. Debugging solutions is always fun, so the thread author tried:

— to find a problem in the agent model loading code

— to roll back the code a few days ago

— to roll back the code several weeks ago (well, surely everything works there?)

— to rebuild the environment

— to change the version of CUDA (drivers for running neural networks on a video card)

— to run the code on a personal laptop, not a server

Nothing helped — the model consistently showed 3000 points.

In desperation, the author wrote to the creator of the model @JensTuyls, and received an unexpected response:

— Maybe it’s a full moon today 🌕

What?? 😑

Upon checking the lunar calendar, it turned out that indeed it was a full moon that day. The author launched the game and saw the message: “You’re lucky! It’s a full moon today.”

In NetHack, there is a mechanic that changes the gameplay during a full moon, based on the system time. The character becomes luckier, werewolves appear in their beastly guise, and dogs start howling. The model was not trained with data from the full moon, so its scores dropped to 3000 points. By changing the system time, the author confirmed that the model again scored 5000 points.

This did not make the game more difficult, but the model simply did not understand how the rules had changed and tried to play as usual — hence the drop in points. To check, you can change the time on your computer — and the model again scores 5000 points.

Moral: When faced with an unexpected error, don’t forget to check the lunar calendar.

* * *

The second story is about the ‘man’ command in the console.

This is a command that outputs documentation about what is entered as the second parameter. For example, “man ls” provides documentation on ls, which shows a list of files and subdirectories of the current directory, and “man man” provides documentation about itself.

On StackExchange, someone was wondering why their tests were failing. Answers

Marnanel Thurman:

Uh, that’s my fault, I suggested it. Sorry. Almost the entire story is outlined in the commit. The programmer maintaining the ‘man’, a good friend of mine, and one day, six years ago, I jokingly told him that if you called ‘man’ after midnight, it should print “gimme gimme gimme”, because of the Abba song “Gimme gimme gimme a man after midnight”:

Well, he actually added it. It was fun for someone to discover this, and we mostly forgot about it until today.

I can’t speak for Cola, of course, but I never expected that it would ever cause any issues: what test would break down parsing man output with no specified page? I suppose I shouldn’t have been surprised that such a test was eventually found, but it took six years.”

Voice UI | May 21 2024, 16:55

“In one interview, Sam Altman mentioned that what impressed him the most about ChatGPT-4o was the ability to turn on the audio mode in the background and intermittently ask it questions.”

My article from seven years ago:

https://hybrismart.com/2017/06/06/rethinking-the-user-interface-of-tomorrow-voice-and-emotion-recognition-as-auxiliary-channels/

A380 landing | May 19 2024, 02:14

We have an international airport nearby, and planes are almost always in the sky (plus, even closer by, a small airfield where small private planes are constantly taking off and landing). And I’ve noticed something interesting several times—a plane virtually hanging in the air. Just driving along, you look up—at some point in the sky, there’s a plane. Look up a few seconds later, and it’s exactly in the same spot!

Yes, it’s almost always flying almost directly towards me, so the angular velocity is not noticeable. But again, there are many planes flying, and I have something to compare it with. Encountered it again today, but I went the extra mile and checked on flightradar to see what this four-engine aircraft was.

I investigated. It was an Airbus A380—the largest airliner in the world. It’s just big, the wings are huge, and with a strong headwind, and specifically the one I saw was decelerating to 155 km/h according to flightradar24 while approaching for landing. But the following B777 also landed at a similar speed, give or take. The difference is, the B777 is significantly smaller than the A380 (30% shorter in fuselage height and nearly 20% in wingspan), and the same visual angular size for A380 appears at a higher altitude, where angular velocity is lower. Meaning, I saw the A380 when it was further away than I am used to seeing Boeings, and therefore its speed seemed very slow.

Perhaps, in addition to this, there might be a headwind. It can really drastically reduce the plane’s speed relative to the ground. Here I’m “out of my depth” and don’t know what pilots do when landing against the wind.

While I was figuring this out, I read that apparently, the A380 engages its thrust reversers (which direct the engine’s thrust forward) quite late, when the speed drops to 80 km/h. Although a fully loaded Airbus A380 weighs 573 tons, its braking system does not rely heavily on reversers. They are not a mandatory element for airliners, and on the A380, they are installed only on the two inner engines.

Although reversers help slow down the A380, their contribution to braking is not as significant as on most airliners, including the Boeing 747, where thrust reversers do significantly reduce the braking distance compared to brakes and spoilers.

It turns out, A380’s main braking effort is performed by huge Honeywell composite brakes on 16 of the 20 main landing gear wheels. The brakes on the A380 are equipped with a car-like anti-lock braking system. The aerodynamic braking, thanks to 16 large spoilers on the wings, which create drag and reduce lift, also plays an important role. Reducing lift improves mechanical braking, increasing pressure on the wheels.

The A380 slows down from cruising speed of 500 knots (926 km/h) to a complete stop within a few minutes thanks to the overall design of the plane. The descent begins at cruising altitude at about 0.85 Mach (1235 km/h). Below 10,000 feet, the speed decreases to 250 knots (463 km/h), and on the approach glide, the plane moves at 180 knots (333 km/h). The A380 crosses the landing threshold at 140 knots (259 km/h) and touches down at 130 knots (240 km/h).

By the way, here’s how beautifully the landing gear of the A380 extends:

Intercepting and Modifying API Requests and Responses without Code Alterations | May 16 2024, 13:40

I published a new article on my hybrismart. Just imagine, you have a website (frontend + backend) and they are exchanging requests, and you want to change a request on the fly — the parameters or even the JSON that is sent or received from the server back to the browser, all without altering the website’s code. Theoretically, the site might not even be yours 🙂 The reasons can vary — perhaps to test a concept before asking developers to implement it properly, to swap the actual response with a template one, to enable debugging through some debug parameter, to simulate an erroneous/invalid API response, or to remove or alternatively set some headers. For all of this, there isn’t a straightforward free solution “out of the box.” I had to create one myself. The article includes analysis and code that can be used.

https://hybrismart.com/2024/05/16/how-to-inject-custom-logic-to-intercept-and-modify-api-requests-and-responses-without-touching-frontend-backend-code/

Tracking and Visualizing Operational Metrics in E-Commerce | May 12 2024, 15:35

Published a new article on Hybrismart.com. It’s about building a monitoring system for e-commerce business metrics. Things like order volume, SLA compliance for business processes, tracking the creation of new database items, etc. Come read it.

https://hybrismart.com/2024/05/12/tracking-and-visualizing-real-time-operational-metrics-in-e-commerce/

Tracking and Visualizing Real-Time Operational Metrics in E-commerce

Exploring Sheet Sage: Converting MP3 to Sheet Music | May 09 2024, 21:47

I played around a bit with converting mp3 music into sheet music. It’s called Sheet Sage. You feed it a YouTube link, and it spits out a PDF with sheet music and a midi file. The result isn’t exactly great, but it’s better than I expected. Here are two videos—one with the original track, the other with how the midi sounds (I changed the default instruments a bit), and the sheet music right here.

original:

how it sounds:

Exploring Facebook’s LLAMA 3 AI: Local Processing with Promising Outcomes | May 05 2024, 19:03

I’m experimenting with LLAMA 3 from Facebook. There’s a modification called llama3-gradient:8b-instruct-1048k-q6_K, which has a context window of 1M tokens (that’s about 2 megabytes). And there’s even more. I feed it the entire book about Elon Musk (highly recommend it, by the way!) and it produces a pretty good summary—and does it quickly, any text from a screenshot is generated in about 40-60 seconds. And yet, it’s still relatively a weaker model (8B), while Facebook has a 70B. But the main feature here is that all this works locally on a laptop. No need to pay for API, it works quite fast, the script is small, fits on one screen.

Still, there are some rough edges—for example, for direct questions about the text (questions to which I definitely know the answers), the system does not always confidently provide answers. When you send significantly less text, it works fine.