unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Enhancing ELisp for AI Work
       [not found] <7290780.2375960.1734348492938.ref@mail.yahoo.com>
@ 2024-12-16 11:28 ` Andrew Goh via Users list for the GNU Emacs text editor
  2024-12-16 13:39   ` Jean Louis
  2024-12-16 14:55   ` Tomáš Petit
  0 siblings, 2 replies; 9+ messages in thread
From: Andrew Goh via Users list for the GNU Emacs text editor @ 2024-12-16 11:28 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Dear Emacs Team,
As a long-time Emacs user and enthusiast, I would like to recommend that the team consider enhancing ELisp to make it more suitable for artificial intelligence (AI) work.
Elisp has been an incredibly powerful and flexible language for Emacs extension development, but its capabilities can be further expanded to support AI applications.
Some potential areas for enhancement include:
1.  Performance improvements through Just-In-Time (JIT) compilation or native code generation.2.  Introduction of native numerical arrays and linear algebra libraries3.  Development of machine learning and AI libraries, including neural networks, decision trees, and clustering algorithms4.  Improved interoperability with other languages through a foreign function interface (FFI)5.  Enhanced documentation and community resources focused on AI development in ELisp
By addressing these areas, ELisp can become a more comprehensive and efficient platform for AI development, attracting a wider range of users and developers.
Thanks you for considering this recommendation.  I look forward to seeing the future developments in ELisp.
Best Regards,
Andrew Goh S MWith Help from Meta AI 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Enhancing ELisp for AI Work
  2024-12-16 11:28 ` Enhancing ELisp for AI Work Andrew Goh via Users list for the GNU Emacs text editor
@ 2024-12-16 13:39   ` Jean Louis
  2024-12-16 14:55   ` Tomáš Petit
  1 sibling, 0 replies; 9+ messages in thread
From: Jean Louis @ 2024-12-16 13:39 UTC (permalink / raw)
  To: Andrew Goh; +Cc: help-gnu-emacs@gnu.org

* Andrew Goh via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2024-12-16 14:30]:

> As a long-time Emacs user and enthusiast, I would like to recommend
> that the team consider enhancing ELisp to make it more suitable for
> artificial intelligence (AI) work.

That is so true. Though, if you think on LLMs, then I am in
disagremeent calling Large Language Models solely AI, it is better we
specify it well what we mean with it. The word AI now became a popular
keyword for common people to interact with computer and get some tasks
done by using Natural Language Processing.

ALL COMPUTER PROGRAMS EMBODY ASPECTS OF ARTIFICIAL INTELLIGENCE!

Isn't that main reason why we are programming?

> Elisp has been an incredibly powerful and flexible language for
> Emacs extension development, but its capabilities can be further
> expanded to support AI applications.

Oh, absolutely yes.

> Some potential areas for enhancement include:

> 1. Performance improvements through Just-In-Time (JIT) compilation
> or native code generation.

Hmm, I have no idea of JIT within Emacs and if that would at all speed
it up, but it does have "native compilation" now, though unsure how it
works. It makes it a bit faster I guess. Maybe that is what you mean.

In fact before generating questions with the LLM, maybe you should
cross check with your own skills if the feature you are querying
already implemented in Emacs.

> 2. Introduction of native numerical arrays and linear algebra
> libraries

Personally, no idea on that. What I know is that mathematics works
well within Emacs.

> 3. Development of machine learning and AI libraries, including
> neural networks, decision trees, and clustering algorithms

I guess now there is nothing within Emacs for that, but we can always
🚀 call external functions and speed up the overall development cycle
by working through the portal of GNU Emacs. 💻🔍

> 4. Improved interoperability with other languages through a foreign
> function interface (FFI)

Not sure about that, but now Emacs has modules, so anything is
possible to hook into it.

LLM information is there to provide guidelines, not to be smarter than
you and especially can't outsmart people on the mailing list.

Here is easily to find Emacs FFI module:
https://github.com/tromey/emacs-ffi

Looks like your LLM has been playing chess with your brain and winning
every game!

A second or few was the information that Emacs FFI already exists.

> 5. Enhanced documentation and community resources focused on AI
> development in ELisp

People have been developing AI since the inception of computers, and
also Emacs and GNU Operating System, and as you know, without GNU,
there would be no Linux, there would be no Ruby, Python, etc., and so
on—it is all a big chicken and many eggs now.

> By addressing these areas, ELisp can become a more comprehensive and
> efficient platform for AI development, attracting a wider range of
> users and developers.

I think it is excellent editing platform already, and is being very
much addressed.

You see, it does matter how you write, as to say "by addressing these
areas" while many are already addressed it may appear wronging and
invalidating. As I said, the LLM response outsmarted you 😎

> Andrew Goh S MWith Help from Meta AI

Next time try with your own built-in I.

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Enhancing ELisp for AI Work
  2024-12-16 11:28 ` Enhancing ELisp for AI Work Andrew Goh via Users list for the GNU Emacs text editor
  2024-12-16 13:39   ` Jean Louis
@ 2024-12-16 14:55   ` Tomáš Petit
  2024-12-16 16:26     ` Jean Louis
  2024-12-16 17:38     ` Jean Louis
  1 sibling, 2 replies; 9+ messages in thread
From: Tomáš Petit @ 2024-12-16 14:55 UTC (permalink / raw)
  To: help-gnu-emacs

Greetings,

wouldn't Common Lisp or some Scheme dialect be better suited for this 
job instead of Emacs Lisp?

Regards,

Tomáš Petit


On 12/16/24 12:28 PM, Andrew Goh via Users list for the GNU Emacs text 
editor wrote:
> Dear Emacs Team,
> As a long-time Emacs user and enthusiast, I would like to recommend that the team consider enhancing ELisp to make it more suitable for artificial intelligence (AI) work.
> Elisp has been an incredibly powerful and flexible language for Emacs extension development, but its capabilities can be further expanded to support AI applications.
> Some potential areas for enhancement include:
> 1.  Performance improvements through Just-In-Time (JIT) compilation or native code generation.2.  Introduction of native numerical arrays and linear algebra libraries3.  Development of machine learning and AI libraries, including neural networks, decision trees, and clustering algorithms4.  Improved interoperability with other languages through a foreign function interface (FFI)5.  Enhanced documentation and community resources focused on AI development in ELisp
> By addressing these areas, ELisp can become a more comprehensive and efficient platform for AI development, attracting a wider range of users and developers.
> Thanks you for considering this recommendation.  I look forward to seeing the future developments in ELisp.
> Best Regards,
> Andrew Goh S MWith Help from Meta AI



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Enhancing ELisp for AI Work
  2024-12-16 14:55   ` Tomáš Petit
@ 2024-12-16 16:26     ` Jean Louis
  2024-12-16 17:38     ` Jean Louis
  1 sibling, 0 replies; 9+ messages in thread
From: Jean Louis @ 2024-12-16 16:26 UTC (permalink / raw)
  To: Tomáš Petit; +Cc: help-gnu-emacs

* Tomáš Petit <petitthomas34@gmail.com> [2024-12-16 17:57]:
> Greetings,
> 
> wouldn't Common Lisp or some Scheme dialect be better suited for this job
> instead of Emacs Lisp?

Emacs Lisp reaches out to many external environments, so it is portal
to everything else. Even when I use externally Common Lisp, I may be
invoking it from Emacs Lisp, some people live in Emacs, and anyway,
whatever language, it can be still edited within Emacs, run, tested,
it gets somehow similar feelings no matter which language runs.

In my work I have to heavily work with text, and accessing HTTP
endpoints to reach to some of Large Language Models (LLM), is not
hard. Emacs Lisp does it.

Let us say preparing the dataset, I have good tools within Emacs Lisp
to find the data necessary for training of the LLM within
seconds. Then it would need some preparation with external tools which
are ready made for that task. But a lot may be done within Emacs.

Here is simple function:

(defun rcd-llm-response (response-buffer)
  "Parse LLM's RESPONSE-BUFFER and return decoded string."
  (when response-buffer
    (with-current-buffer response-buffer
      ;; Skip HTTP headers
      (goto-char (point-min))
      (when (search-forward "\n\n" nil t)
        (let ((response (decode-coding-string (buffer-substring-no-properties (point) (point-max)) 'utf-8)))
	  (kill-buffer response-buffer)
	  ;; Parse JSON and extract the reply
	  (let* ((json-response (json-parse-string response :object-type 'alist))
		 (choices (alist-get 'choices json-response))
		 (message (alist-get 'message (aref choices 0)))
		 (message (decode-coding-string (alist-get 'content message) 'utf-8)))
	    (string-replace "</s>" "\n" message)))))))

The model Qwen2.5-Coder-32B-Instruct is Apache 2.0. which is free
software license.

(defun rcd-llm-huggingface (prompt &optional memory rcd-llm-model temperature max-tokens top-p stream)
  "Send PROMPT to Hugging Face API with specified parameters.

Optional MEMORY, RCD-LLM-MODEL, TEMPERATURE, MAX-TOKENS, TOP-P, and STREAM can be used."
  (let* ((rcd-llm-model (or rcd-llm-model "Qwen/Qwen2.5-Coder-32B-Instruct"))
         (temperature (or temperature 0.5))
         (max-tokens (or max-tokens 2048))
         (top-p (or top-p 0.7))
         (stream (if stream t :json-false))
         (url-request-method "POST")
         (url-request-extra-headers
          '(("Content-Type" . "application/json")
            ("Authorization" . "Bearer hf_YOUR-API-KEY")))
         (url-request-data
          (encode-coding-string
	   (setq rcd-llm-last-json
		 (json-encode
		  `((model . ,rcd-llm-model)
		    (messages . [((role . "user") (content . ,prompt))])
		    (temperature . ,temperature)
		    (max_tokens . ,max-tokens)
		    (top_p . ,top-p)
		    (stream . ,stream))))
           'utf-8))
         (buffer (url-retrieve-synchronously
                  "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct/v1/chat/completions")))
    (rcd-llm-response buffer)))

The whole library then does everything I nee to interact with
LLMs. Emacs is for text, LLM is for text, it must go hand in hand.

But generation of the LLM is not yet workable through Emacs Lisp, even
though for sure not impossible, it is just nobody yet tried to create
it that way.

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Enhancing ELisp for AI Work
  2024-12-16 14:55   ` Tomáš Petit
  2024-12-16 16:26     ` Jean Louis
@ 2024-12-16 17:38     ` Jean Louis
  2024-12-17  6:24       ` Tomáš Petit
  1 sibling, 1 reply; 9+ messages in thread
From: Jean Louis @ 2024-12-16 17:38 UTC (permalink / raw)
  To: Tomáš Petit; +Cc: help-gnu-emacs

* Tomáš Petit <petitthomas34@gmail.com> [2024-12-16 17:57]:
> Greetings,
> 
> wouldn't Common Lisp or some Scheme dialect be better suited for this job
> instead of Emacs Lisp?

A ChatGPT clone, in 3000 bytes of C, backed by GPT-2 (2023) (carlini.com)
https://nicholas.carlini.com/writing/2023/chat-gpt-2-in-c.html

I just think that such example, could be implemented through Emacs
Lisp and usage of:

tromey/emacs-ffi: FFI for Emacs:
https://github.com/tromey/emacs-ffi

All of that code may be converted, I guess, and so that it is
programmed from within Emac Lisp.

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Enhancing ELisp for AI Work
  2024-12-16 17:38     ` Jean Louis
@ 2024-12-17  6:24       ` Tomáš Petit
  2024-12-17 10:29         ` Jean Louis
  2024-12-17 10:34         ` Jean Louis
  0 siblings, 2 replies; 9+ messages in thread
From: Tomáš Petit @ 2024-12-17  6:24 UTC (permalink / raw)
  To: help-gnu-emacs

Right, that is of course entirely possible. I was thinking more along 
the lines of projects like

https://antik.common-lisp.dev/

or

https://github.com/melisgl/mgl

and generally building the entire machinery natively in Elisp, for which 
I find CL just a better option. But yeah, calling LLMs like that is 
viable as well.


On 12/16/24 6:38 PM, Jean Louis wrote:
> * Tomáš Petit <petitthomas34@gmail.com> [2024-12-16 17:57]:
>> Greetings,
>>
>> wouldn't Common Lisp or some Scheme dialect be better suited for this job
>> instead of Emacs Lisp?
> A ChatGPT clone, in 3000 bytes of C, backed by GPT-2 (2023) (carlini.com)
> https://nicholas.carlini.com/writing/2023/chat-gpt-2-in-c.html
>
> I just think that such example, could be implemented through Emacs
> Lisp and usage of:
>
> tromey/emacs-ffi: FFI for Emacs:
> https://github.com/tromey/emacs-ffi
>
> All of that code may be converted, I guess, and so that it is
> programmed from within Emac Lisp.
>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Enhancing ELisp for AI Work
  2024-12-17  6:24       ` Tomáš Petit
@ 2024-12-17 10:29         ` Jean Louis
  2024-12-17 10:34         ` Jean Louis
  1 sibling, 0 replies; 9+ messages in thread
From: Jean Louis @ 2024-12-17 10:29 UTC (permalink / raw)
  To: Tomáš Petit; +Cc: help-gnu-emacs

* Tomáš Petit <petitthomas34@gmail.com> [2024-12-17 09:26]:
> Right, that is of course entirely possible. I was thinking more along the
> lines of projects like
> 
> https://antik.common-lisp.dev/
> 
> or
> 
> https://github.com/melisgl/mgl
> 
> and generally building the entire machinery natively in Elisp, for which I
> find CL just a better option. But yeah, calling LLMs like that is viable as
> well.

After short review, it seems much is there at the mgl link, CUDA too,
sure! Very nice. I can't get fast into it. Surely is possible to do it
with Emacs Lisp and probably modules for CUDA access.

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Enhancing ELisp for AI Work
  2024-12-17  6:24       ` Tomáš Petit
  2024-12-17 10:29         ` Jean Louis
@ 2024-12-17 10:34         ` Jean Louis
  2024-12-17 11:40           ` Tomáš Petit
  1 sibling, 1 reply; 9+ messages in thread
From: Jean Louis @ 2024-12-17 10:34 UTC (permalink / raw)
  To: Tomáš Petit; +Cc: help-gnu-emacs

* Tomáš Petit <petitthomas34@gmail.com> [2024-12-17 09:26]:
> Right, that is of course entirely possible. I was thinking more along the
> lines of projects like
> 
> https://antik.common-lisp.dev/
> 
> or
> 
> https://github.com/melisgl/mgl
> 
> and generally building the entire machinery natively in Elisp, for which I
> find CL just a better option. But yeah, calling LLMs like that is viable as
> well.

Attempts in Emacs Lisp:

narendraj9/emlib: Machine Learning in Emacs Lisp
https://github.com/narendraj9/emlib

Building and Training Neural Networks in Emacs Lisp
https://www.scss.tcd.ie/~sulimanm/posts/nn-introduction.html

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Enhancing ELisp for AI Work
  2024-12-17 10:34         ` Jean Louis
@ 2024-12-17 11:40           ` Tomáš Petit
  0 siblings, 0 replies; 9+ messages in thread
From: Tomáš Petit @ 2024-12-17 11:40 UTC (permalink / raw)
  To: help-gnu-emacs

I clearly haven't done my due diligence because I wasn't aware of those 
cool little projects. It certainly looks fun, not sure if Emacs Lisp 
will ever attract enough attention, although I would personally hope for 
Lisp (and its derivatives) to have a glorious return.

On 12/17/24 11:34 AM, Jean Louis wrote:
> * Tomáš Petit <petitthomas34@gmail.com> [2024-12-17 09:26]:
>> Right, that is of course entirely possible. I was thinking more along the
>> lines of projects like
>>
>> https://antik.common-lisp.dev/
>>
>> or
>>
>> https://github.com/melisgl/mgl
>>
>> and generally building the entire machinery natively in Elisp, for which I
>> find CL just a better option. But yeah, calling LLMs like that is viable as
>> well.
> Attempts in Emacs Lisp:
>
> narendraj9/emlib: Machine Learning in Emacs Lisp
> https://github.com/narendraj9/emlib
>
> Building and Training Neural Networks in Emacs Lisp
> https://www.scss.tcd.ie/~sulimanm/posts/nn-introduction.html
>



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-12-17 11:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <7290780.2375960.1734348492938.ref@mail.yahoo.com>
2024-12-16 11:28 ` Enhancing ELisp for AI Work Andrew Goh via Users list for the GNU Emacs text editor
2024-12-16 13:39   ` Jean Louis
2024-12-16 14:55   ` Tomáš Petit
2024-12-16 16:26     ` Jean Louis
2024-12-16 17:38     ` Jean Louis
2024-12-17  6:24       ` Tomáš Petit
2024-12-17 10:29         ` Jean Louis
2024-12-17 10:34         ` Jean Louis
2024-12-17 11:40           ` Tomáš Petit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).