Einzelnen Beitrag anzeigen

Benutzerbild von Phoenix
Phoenix
(Moderator)

Registriert seit: 25. Jun 2002
Ort: Hausach
7.630 Beiträge
 
#24

AW: KI in eigene Anwendung integrieren

  Alt 28. Jun 2024, 07:48
Hast Du ein praktisches "Hello World" für ein lokales LLM (Mit Delphi)
Wie gesagt, lokale LLMs sind (aktuell) bei weitem nicht so intelligent wie gehostete.

Dennoch: Mit Ollama (https://ollama.com/) kannst Du viele LLMs lokal betreiben:

Phi3 in einer passenden Quantisierung die nicht zu langsam ist geht z.B. so:
Code:
ollama run phi3:3.8b-mini-instruct-4k-fp16
Dann kannst Du schonmal auf der Kommandozeile mit dem Model chatten.
Ollama hat auch eine web-api, die Du von anderen Programmen aus ansprechen kannst.

Dazu habe ich ein Delphi-UI gefunden: https://github.com/HuichanKIM/Ollama-Delphi-GUI
Da ich aber schon ewig kein Delphi mehr mache, kann ich Dir dazu nicht sagen, wie gut das wirklich ist.

Edit / Ergänzung:

Wenn ich das o.a. Phi3 mit folgender Frage befeuere:
Code:
(Invoke-WebRequest -method POST -Body '{"model":"phi3:3.8b-mini-instruct-4k-fp16", "prompt":"Why is the sky blue?", "stream": false}' -uri http://localhost:11434/api/generate ).Content | ConvertFrom-json
erhalte ich folgende Antwort:

Code:
model               : phi3:3.8b-mini-instruct-4k-fp16
created_at          : 28.06.2024 06:49:41
response            : The sky appears blue to us because of a phenomenon called Rayleigh scattering. Sunlight, which
                       contains all colors of light in its spectrum, travels through Earth's atmosphere and interacts
                       with molecules and small particles present there.

                       When sunlight reaches our atmosphere, it encounters tiny air molecules (like nitrogen and
                       oxygen) and other aerosols suspended in the air. These particles scatter short-wavelength
                       light, like blue and violet colors, more than they do long-wavelength light, such as red or
                       yellow.

                       However, our eyes are more sensitive to blue light (around 475 nanometers) compared to violet
                       light (which is shorter wavelength). Also, the Earth's atmosphere absorbs some of the sunlight
                       in the ultraviolet and near-ultraviolet region, which means there's less scattering for these
                       colors.

                       As a result, when we look up at the sky away from direct sources of light like the Sun, we
                       perceive it as blue due to the dominance of scattered blue light in all directions. When
                       sunlight passes through the Earth's atmosphere during dawn and dusk, shorter wavelengths (blue
                       and violet) scatter more than longer wavelengths (red and orange). This is why the sky appears
                       redder at these times.

                       It's also worth mentioning that under certain conditions, such as heavy pollution or volcanic
                       activity, the sky may not appear blue but take on other colors due to changes in aerosols
                       present in the atmosphere.
done                : True
done_reason         : stop
context             : {32010, 3750, 338, 278…}
total_duration      : 265333993700
load_duration       : 4458200
prompt_eval_count   : 10
prompt_eval_duration : 5340166000
eval_count          : 340
eval_duration       : 259982060000
Für das bisschen Text braucht es knapp unter viereinhalb Minuten.
Also wie gesagt, lokal ist aktuell noch nicht wirklich geil.
Sebastian Gingter
Phoenix - 不死鳥, Microsoft MVP, Rettungshundeführer
Über mich: Sebastian Gingter @ Thinktecture Mein Blog: https://gingter.org

Geändert von Phoenix (28. Jun 2024 um 07:54 Uhr)
  Mit Zitat antworten Zitat