in reply to perl hooks for AI
While Python has become the de facto language for AI and machine learning, let's not forget the versatility of Perl
There is a great deal that can be done with Perl and publically available APIs. Not everything AI requires Python!
Earlier this year, I created AI::Embedding and I'm working on other pure Perl modules that will help bring AI capabilities to a script near you... As far as I can tell, there is no inherent benefit that Python has when it comes to AI.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: perl hooks for AI
by cavac (Prior) on Nov 20, 2023 at 15:52 UTC | |
I completely agree. More and more of that stuff runs "in the cloud" anyway, because running a couple of racks of high end hardware under your office desk just isn't feasable. Cloud almost always means "HTTP", and Perl is very good at interfacing with stuff like that directly, without having to remote-control a browser. (Yes, sometime you have to pay extra to use those "professional" APIs). In my experience, it's often easier to interface with those newer services, because they provide modern APIs based on modern standards. It's much more work to interface with old services that originally pre-dated the modern web and just converted their paper-based data exchange to textfile-based ones. My bet is, you get get an interface to ChatGPT going much faster that ingress NOAA space weather prediction data. ChatGPT has some well defined Web APIs. They have a docomented workflow, documented return codes, etc... NOAA gives you a text file. When to pull new data? What are the exact parsing rules? Are there exceptions when the format could slightly change? How to convert the values into a nice 1-5 scale? Those are the things you have to spend a day painstakingly searching and reading obscure documents...
PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
| [reply] |
by stevieb (Canon) on Nov 20, 2023 at 17:46 UTC | |
NOAA gives you a text file. When to pull new data? What are the exact parsing rules? Are there exceptions when the format could slightly change? How to convert the values into a nice 1-5 scale? Those are the things you have to spend a day painstakingly searching and reading obscure documents... That. First, you have to create a known data set from the data, then you have to do a whole bunch of very complex math to normalize all the data that's way above my head (super thanks goes out to no_slogan who did all of the math for me in this thread). After that, you do have to remember to update the data (typically every five years, but there are known to be incremental changes as well. If the format changes at all, you have to rewrite your parser code that translates it to a format the code understands. An API would be much more helpful :) | [reply] |
by Aldebaran (Curate) on Dec 18, 2023 at 07:47 UTC | |
Hey stevie, how's tricks? Did you get stomped by winter storms? (They went north of me.) I thought I was closing in on this:
It comes back as a 404, and looks like this in the debugger:
Fishing for tips, | [reply] [d/l] [select] |
Re^2: perl hooks for AI
by Aldebaran (Curate) on Dec 18, 2023 at 06:54 UTC | |
Thx for your response, Bod. I took a look at these embeddings, feeling out the topic with the debugger and chatgpt. I took a peek at what one of these things looks like, and it looks like a giant vector of floats: -0.818496979663585,-0.572010804875021,-0.409478105446063,-0.937661798043237'I'm always curious about the compression, and asked how expensive it is to represent and it came to pass
The representation seems expensive to me, but maybe I'm old-fashioned. The new Q* model that made recent news in another variety of the same, so I'm going to withhold on pronouncements of AGI, as are the boasts on youtube. (Are there alternatives to youtube?) I did try out some source:
This compiles but gets lost in runtime:
Not sure what this means. The success of this so far is getting a proper api key. I'm suuuper rusty with all this. Can't find any perl install I recognize from before...yikes.... Anyways, assume mistakes are mine so far. (I usually have a couple dozen to make before I get anywhere.) My question might be: how do I dial up this api properly? Cheers from the 'Ho | [reply] [d/l] [select] |
by Bod (Parson) on Dec 18, 2023 at 21:09 UTC | |
Check your API key! I've modified your code for obtaining the API key and hardcoded it into the subroutine...with a valid API key, your code works for me. With an invalid key, I get the same error as you are seeing.
Output:
In the next release, I will put some more helpful error message that directs the user to check their AP key...thanks for discovering this issue :) | [reply] [d/l] [select] |
by Bod (Parson) on Dec 18, 2023 at 20:32 UTC | |
The representation seems expensive to me... If we were to store each float as a separate DB field, it would be rather expensive. This is why the AI::Embedding documentation suggests storing the vector as a string in a TEXT field. See the embedding method Because the purpose of an embedding is to compare it with another embedding, the floats that make up the vector are dealt with as a single unit. Generally, we have no reason to access the individual components of the vector. The vector comparison is carried out internally with Data::CosineSimilarity. This compiles but gets lost in runtime: From a cursory look, I'm not sure what to make of that error! The problem is in a private method but I cannot recall where it's called from. I shall look into this further over the next few days when I've got a little more time...I'm on domestic duties, making the house look festive right now! AI::Embedding is working in a production environment, so I am hopeful there isn't a fundamental problem with the module. But it shouldn't really thrown the error you are experiencing. | [reply] [d/l] [select] |
by Bod (Parson) on Dec 19, 2023 at 13:58 UTC | |
Version 1.1 of AI::Embedding is now live on CPAN - update the module and you'll get a more helpful error if the API Key is wrong. | [reply] |