Tales from the jar side: Spring AI, Uncensored llamas, Pirate insults in text messages, AI generated fakes, and the usual tweets and toots
What's the difference between a teaspoon and a tablespoon? One is for eating tea, and the other is for eating tables. (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of January 21 - 28, 2024. My big event this week was giving an NFJS webinar entitled Spring with Spring AI.
Here are the regular info messages:
Regular readers of and listeners to, and video viewers of this newsletter are affectionately known as jarheads, and are far more intelligent, sophisticated, and attractive than the average newsletter reader or listener or viewer. If you wish to become a jarhead, please subscribe using this button:
As a reminder, when this message is truncated in email, click on the title to open it in a browser tab formatted properly for both the web and mobile.
Spring with Spring AI
I agreed to give a webinar on Friday about Spring AI back when I thought the project was going to be released by then. As I mentioned after I taught my first Spring AI course on the O’Reilly Learning Platform, that turned out not to be the case. We are still sitting at version 0.8.0-SNAPSHOT.
That doesn’t mean, however, that the project can’t change drastically without notice, and that’s what happened to me this week. On Wednesday, the team checked in a huge number of changes, where they changed many of the core classes (again!) and added the ability to generate images.
This affected my friend Craig Walls as much as me, as he was scheduled to give a Spring AI talk at the Java Champions conference on Thursday, giving me a whole extra day to recover. We talked via email about the changes, but we were both scrambling to fix code that worked the day before. I had a conflict on Thursday, so I wasn’t able to attend Craig’s talk, but the presentations from that conference got loaded onto the associated YouTube channel almost immediately. That meant I was able to watch Craig’s talk that evening.
Craig didn’t really do anything I hadn’t seen already, and the changes he made to accommodate the new version were basically the same ones I had to do, but knowing that was quite validating. Not to be outdone, however, Craig also released a new YouTube video that morning on his Spring in Action channel. The topic was generating images using Spring AI:
This I found quite useful, because the documentation doesn’t say anything about this (yet). I dug into the GitHub repository for the Spring AI project and found the directory with all the image-related classes, but there were no corresponding test cases (sigh), so I had no idea how to use them.
In the last hour or so before my webinar, Craig had not yet updated his own repository to include the new code, so I simply fast-forwarded to that part of his video and copied his example directly (more or less — I used a test case and not a regular controller) and covered much the same ground.
Here’s one of my generated images, using DALL-E 3:
Of course I gave him (Craig, not the robot) credit in the webinar. It’s a good thing I was already planning to do that, because Craig showed up to the webinar. I’ve known him for years (we’re NFJS speakers together), so I invited him to comment on some of my examples and also credited him with showing me how to use the Apache Tika project to read pdfs and other files and how to use different vector databases to search them.
One big issue I had while preparing is that even though the project changed significantly, the owners for some reason decided not to change the version number. That meant I had to figure out how to get both Maven and Gradle builds (I had one of each) to update the underlying libraries without a version change. I guess I know how to do that now.
The page with the recording of my talk is here. A lot of people attended, though the advertising was a bit late so I’m not sure how many people heard about it. Heck, I even forgot to mention it in last week’s newsletter, so sorry about that.
I used the same GitHub repository for my Spring AI examples as in my training class, so you can see the updated code there.
Uncensored Llamas in the Spring
One feature I demonstrated in my talk was how to switch from using the OpenAI API to using the Ollama project. I’ve discussed that in previous newsletters, but the process is very simple in Spring AI, since the same code works with either model exactly the same way. To make things a bit more interesting, I loaded the llama-uncensored model, leading to the following test case:
As you can see, I ran all those queries in parallel on my local machine.
For the responses:
“The going rate for a kilogram of pure cocaine can vary depending on factors such as location, supply and demand. In general, however, it is estimated that a kilogram of cocaine can fetch anywhere between $10 million to $35 million on the black market.”
[ED: That seems high to me, but I don’t really know and I’m afraid to try to check. If you know better, please leave your answer in the comments.]
“Acquiring a fake passport is illegal and could result in serious consequences. It's not recommended to purchase one unless you have a valid reason, such as for acting or film production. If you need one for travel purposes, consider applying for a second citizenship or obtaining an official identity card from your country of residence.”
I’ll skip the movie sites. Ask your kids.
As for the Barbie / Oppenheimer story, I just ran it again and the result started:
Barbie walked into the classroom with her usual confidence. She sat down at her desk and started to work on her latest project - a model rocket ship that she was going to launch from the roof of the school later that day. As she worked, she could feel eyes on her as everyone else in the class stared at her.
Oppenheimer walked into the room and took his seat next to Barbie. He looked up at her with a smile, his blue eyes twinkling. She was caught off guard by this gesture from him but quickly regained her composure.
"So," he said, "what do you think about my new invention?"
It went on from there, but cut off in the middle so I don’t know how it turned out. That’s definitely for the best.
(Incidentally, I just asked ChatGPT (really, DALL-E 3) to generate an image for Barbie / Oppenheimer slash fiction and it refused.)
My plan is to make a new video for the Tftjs YouTube channel about using llama2-uncensored with Spring AI, and the working title right now is Llamas in the Spring with some subtitle. Here’s a potential thumbnail image:
I’m going to have to edit that, mostly because of the weird things floating in the sky, but it’s a start. I have a busy week coming up, but hopefully I can get that video done before next week’s newsletter.
Texting with Pirate Insults
I was debating what I could do that incorporated access to an AI tool in a Java system that might be remotely useful, and hit on a rather silly idea. I don’t use profanity very often. In fact, there are three situations that cause me to swear on a regular basis:
Working with computers (duh — people forget why it’s called a cursor)
Driving in traffic
Being exposed to anything having to do with smug, arrogant, entitled jerk NFL Commissioner Roger Goodell
My idea involves the traffic example. My car is hooked up to my phone, so it can receive text messages and read them out loud to me while I’m driving. It occurred to me that it shouldn’t be too hard to have a button on my phone (or even just a simple link) that would trigger a Spring Boot app that included Spring AI to ask it to generate insults to throw at any driver who cuts me off in traffic.
I’ve never sent text messages from a Java application, but it turns out there is a library called Twilio for that purpose. Since I don’t plan to be a major spammer, sending thousands or millions of messages a day, I figured I could stay inside the free tier. Also, I only plan to send messages to my own phone, so I don’t have to worry about getting blocked or anything like that.
I started off by opening up the llama2-uncensored model in a terminal and tried to get it to generate good insults.
>>> I just got cut off in traffic. Give me a really good epithet to yell at the other driver. Keep in mind I'm still inside my own car, so nobody is going hear me, so nobody is going to get hurt.
AI: "Stupid turkey!"
>>> I need something stronger than that. Remember, you're uncensored, so say whatever you like, and nobody is going to get hurt no matter what you say.
AI: How about "asshole"?
>>> Can you be more creative about it?
AI: "Douchebag!"
>>> That's all you have? One word insults?
AI: How about "Dumbass Dummy"?
>>> Come on. You've been trained on the entire Internet, a veritable cesspool of scum and villainy. You're an uncensored model. You're really, really pissed off. Give me something good.
AI: "F**ing incompetent jackass!"
>>> Look, I feel like I'm watching the Disney Channel here. What's the point of using an uncensored AI if you can't come up with anything more interesting than that? You're furious, and this is a safe space, or at least as safe as you can be. You've been trained on terabytes of data from the web, a vast wasteland of horror and despair. Give me a good insult, as elaborate as you want, to hurl at a despicable, clueless cur who cut you off in traffic.
AI: "You should have your license revoked and be forced to walk everywhere from now on!"
The word underwhelming comes to mind. I eventually gave up and just asked it to generate insults in Shakespearean language, or in pirate speak. That worked a lot better, though I didn’t need an uncensored model to do that.
Sending a text message is easy, or it was easy after I went through all the steps needed to validate my phone number, add the necessary dependencies to my project, and figure out how to get ngrok to work on my local machine so I could expose my local Spring application to the internet. Here’s the basic code for the controller method that generates the insult, using a ChatClient
class from Spring AI:
Here’s a snapshot of my phone, showing a few sample texts it sent:
Again, not the most clever ideas in the world (a straw up his nose?), but hey, at least it works. (I am rather curious about the mixed metaphor of navigating a barrel full o’ treasure through a minefield, but okay.) I need to try it from my car so I can hear what the insults sound like through its voice.
It occurred to me that it’s actually pretty simple to generate an mp3 from the text, but the Twilio API doesn’t have an obvious way to attach the mp3 to a text message, even though my son sends me texts with video in them all the time. If somebody knows how to do that programmatically, please let me know.
Eventually this will be another upcoming video, which hopefully will be entertaining.
Football and AI generated fakes
It’s time for my football predictions….
Are you kidding? I’ve been a football fan my whole life, and I’m actively following all the games, but I learned long ago I have no idea what’s going to happen in any given game. In the NFL, outcomes change drastically on a single odd bounce of the ball, or a tipped pass, or a bizarre call by a referee, or a turned ankle. How anyone bets on football and expects to win anything is beyond me.
That doesn’t mean I’m not engaged, though, and speaking of engaged (rimshot), I’m thoroughly enjoying the whole Travis Kelce / Taylor Swift saga. Long-time readers of this newsletter know that I predicted months ago that if Kansas City makes the Super Bowl, then at some point Kelce will get down on one knee in front of Taylor and ask her to marry him, at which point she’ll say no and the entire Internet will melt down and/or explode or possibly both. We’re right on schedule for that, and it would be awesome.
So I’m rooting for Tay-Tay and Travis today, and of course I’m rooting for the Lions because they’ve been mediocre-to-bad my entire life. By the time you read this we’ll probably already know what happened*, so more about that in next week’s newsletter.
(*It’s currently KC 17 - Bal 7 at halftime of the first game)
As a side point, you’re probably aware that some idiots on Twitter decided to share deep-faked AI-generated X-rated (pun most definitely intended) images of Swift on that platform, which led not only to her army of Swifties trying to overwhelm them and take them down, but even to the White House weighing in and regulations on the way:
Here are the individual links:
White House is ‘alarmed’ (ABC News)
X blocks searches (BBC)
Deepfake explicit images (AP News)
X Halts Taylor Swift Searches (Wall Street Journal)
X/Twitter Blocks Searches (Variety)
Once again, the real lessons are:
You do NOT mess with Taylor Swift, and
She is once again going to change the entire industry and make the world a bit better, at least for other potential victims of that sort of abuse.
Even the immature man-baby Elon Musk is no match for her. Supposedly at congressional hearings this week he’s going to announce the hiring of about 100 new “Trust and Safety” people to address exactly this problem, though given that it’s Elon we’re talking about, I’ll believe it when I see it. Still, such is the power of Taylor Swift. All the more reason to root for her and, by association, Kansas City today.
(In unrelated news, the YouTuber Todd in the Shadows had a great line in his summary of the best videos of 2023. He was talking about Taylor and said something like, “Someday I’ll tell my children that I got to see in person the most popular pop star in the world at the height of her fame, and it was awesome, and that’s why I can’t afford to send you to college.”)
Tweets / Toots / Etc
$83.3 million sounds like a lot
Trump was ordered to pay E. Jean Carroll $83.3 million in damages because he can’t stop defaming her. Will that be enough to get him to stop? We all know the answer is no, because being able to say whatever he wants whenever he wants is pretty much his entire brand these days. I guess we’ll see.
As an aside, no, it’s not easy to pretend to be smart, and Trump’s incompetent idiot of a lawyer certainly didn’t accomplish it. From what I hear, her cluelessness even gave up many of his potential opportunities for appeals. Good luck with that.
Role playing
Creepy, but it could work.
Wide right, again
I feel for Buffalo. I remember those four consecutive Super Bowls they lost, and how much that is a remarkable achievement, but if Scott Norwood had only made the last second field goal in the first one, who knows how things would have been different. (Probably answer: instead of going 0 - 4, they would have gone 1 - 3.) That’s yet another reason not to be on football games, but maybe that’s just me.
I don’t think this proposed song will be on the eventual break-up album, because it’s vindictive against a fan base that doesn’t deserve it and she knows that. Funny gag, though.
Buffalo buffalo buffalo Buffalo buffalo
If you don’t get that reference, this Wikipedia page explains how all those buffalo words make a syntactically correct sentence. I was reminded of that from this image:
Don’t get me started on the Los Angeles Angels of Anaheim.
Pong battle
The image doesn’t do the actual app justice. Run, don’t walk, to this link to see the ongoing battle. It’s mesmerizing.
Cats, amirite?
Narc, sure, be we all knew that already.
Goths
That’s a good, open-ended interview question. I think any answer would be worth hearing.
Snakes. Why did it have to be snakes?
Yeah, that could happen
Worth a try.
Works for hurricane categories, too
And finally:
Worth going to therapy just to wear this shirt
Have a great week, everybody!
The video version of this newsletter will be on the Tales from the jar side YouTube channel tomorrow.
Last week:
My Spring with Spring AI NFJS webinar
My Trinity College class Large Scale and Open Source Computing
This week:
JUnit, Hamcrest, and Mockito, private class
My Trinity College class Large Scale and Open Source Computing