Normale Ansicht

Sprachmodelle (LLMs) lokal ausführen

18. April 2024 um 18:38

ChatGPT, Copilot & Co. verwenden Large Language Models (LLMs). Diese werden auf leistungsstarken Servern ausgeführt und als Cloud-Services angeboten. Das funktioniert wunderbar. Aber nicht jeder will Daten, Text und Code ständig in die Cloud hochladen. Kann man also — mit »gewöhnlicher« Hardware — LLMs auch lokal ausführen?

Tatsächlich ist das verblüffend einfach. Das Tool der Wahl heißt Ollama. Was Docker für Container ist, ist Ollama für LLMs!

Ollama kann ziemlich mühelos unter Linux, macOS und Windows installiert werden. Unter Windows und macOS starten Sie Ollama als Hintergrunddienst mit einer winzigen grafischen Oberfläche (im Prinzip nur ein Icon, das den Status anzeigt). Unter Linux richten Sie den Dienst mit systemctl ein:

systemctl enable --now ollama
Ollama läuft im Terminal, kann aber auch per API genutzt werden (z.B. zur Realisierung einer Web-Schnittstelle).

Ollama anwenden

Jetzt können Sie Ollama mit dem gleichnamigen Kommando im Terminal ausführen. Mit ollama run <llmname> installieren Sie eines der öffentlich verfügbaren Sprachmodelle (mehr dazu im nächsten Abschnitt) und können dann im Textmodus Kommandos ausführen:

ollama run llama2

>>> I need a regex to verify a date in US format. Can you help?

Of course! To match a date in the format of "MM/DD/YYYY" (month-day-year) 
or "MM/DD/YYYY HH:MM AM/PM", you can use the following regular expression:

\b(\d{1,2}/\d{1,2}/\d{4})|(\d{1,2}/\d{1,2}/\d{4} \d{0,2})?\b

Here's a breakdown of how this regex works:

* \b: Matches a word boundary (the start or end of a word) to ensure 
  we're matching the entire date field.

* (\d{1,2}/\d{1,2}/\d{4}): Matches the month/day/year format. The 
  (\d{1,2}) captures the month and day as individual digits (0-2 
  digits for the month and 1-2 digits for the day). The / separates 
  the date components.

* |: Or, used to match the alternative format.

* (\d{1,2}/\d{1,2}/\d{4} \d{0,2})?: Matches the month/day/year with 
  time format. The (\d{1,2}) captures the month and day as individual 
  digits (0-2 digits for the month and 1-2 digits for the day). The / 
  separates the date components. The \d{0,2} matches the time component 
  (0-2 digits representing the hour and minute).

* \b: Matches a word boundary to ensure we're matching the entire date field again.

Note that this regex will match both US and international dates in the 
"MM/DD/YYYY" format, as well as dates in the "MM/DD/YYYY HH:MM AM/PM" 
format. If you need a more specific format (e.g., only US dates), 
feel free to modify the regex accordingly.

Manche Sprachmodelle können auch Deutsch (nochmals llama2), wenngleich die sprachliche Qualität mitunter nur mittelmäßig ist.

>>> Was ist der Dopplereffekt?

Der Dopplereffekt ist ein physikalischer Effekt, der durch die Beugung von
Lichtwellen verursacht wird, wenn diese durch eine mediummässige Materie
passt. In einer bestimmten Umgebung oder Situation kann das Licht, das durch
eine bestimmte Fläche oder ein Objekt passt, sich "verlangsamen" und eine
Dopplereffekthelligkeit erzeugen.

Der Dopplereffekt ist ein spezifischer Effekt, der auf der Beugung von
Lichtwellen basiert. Wenn Licht durch ein Medium passt, wird es durch die Faser
des Mediums beugt und umgestaltet. Die Intensität des Lichts, das durch ein
Medium passt, kann sich durch den Dopplereffekt ändern.

Im Alltag können wir den Dopplereffekt beispielsweise bei der Anähnlichkeit von
Objekten in einer Ferne sehen. Wenn ein Auto oder eine andere Objekte in der
Ferne auf uns zukommt, wird es durch die Luft des Raumes beugt und erscheint
größer und weiter weg, als es tatsächlich ist.

Der Dopplereffekt kann auch in anderen Bereichen wie der Optik, Elektrotechnik
oder Medizin verwendet werden. Zum Beispiel können Dopplereffekte in der
Medizin verwendet werden, um die Blutungen in einem Körperteil zu bestimmen.

Es gibt verschiedene Arten von Dopplereffekten, darunter:

* LichtDopplereffekt: Der Effekt, den das Licht erzeugt, wenn es durch ein
  Medium passt.
* ZeitDopplereffekt: Der Effekt, den die Zeit erzeugt, wenn sie durch ein
  Objekt oder eine bestimmte Umgebung verändert wird.
* Räumliche Dopplereffekte: Der Effekt, den die räumliche Position von Objekten
  oder der Standort eines Beobachters auf die Erscheinung des Dopplereffekts
  ausübt.

Insgesamt ist der Dopplereffekt ein interessanter und wichtiger
physikalischerEffekt, der in vielen Bereichen der Wissenschaft und Technologie
Verwendung findet.

Ollama stellt seine Funktionen über eine REST-API zur Verfügung und kann somit lokal auch durch eigene Scripts und Editor-Plugins (z.B. Continue für VSCode) genutzt werden. Natürlich gibt es auch Module/Bibliotheken für diverse Sprachen, z.B. für Python.

Öffentliche Sprachmodelle

Die bekanntesten Sprachmodelle sind zur Zeit GPT-3.5 und GPT-4. Sie wurden von der Firma openAI entwickelt und sind die Basis für ChatGPT. Leider sind die aktellen GPT-Versionen nicht öffentlich erhältlich.

Zum Glück gibt es aber eine Menge anderer Sprachmodelle, die wie Open-Source-Software kostenlos heruntergeladen und von Ollama ausgeführt werden können. Gut geeignet für erste Experimente sind llama2, gemma und mistral. Einen Überblick über wichtige, Ollama-kompatible LLMs finden Sie hier:

https://ollama.com/library

Noch viel mehr LLMs finden Sie auf HuggingFace, einer öffentlichen Plattform für KI-Forscher und -Anwender:

https://huggingface.co/models

Viele Sprachmodelle stehen in unterschiedlicher Größe zur Verfügung. Die Größe wird in der Anzahl der Parameter gemessen (7b = 7 billions = 7 Milliarden). Die Formel »größer ist besser« gilt dabei nur mit Einschränkungen. Mehr Parameter versprechen eine bessere Qualität, das Modell ist dann aber langsamer in der Ausführung und braucht mehr Platz im Arbeitsspeicher. Die folgende Tabelle gilt für llama2, einem frei verfügbaren Sprachmodell der Firma Meta (Facebook & Co.).

Name.        Parameter     Größe
----------  ----------  --------
llama2           7 Mrd.     4 GB
llama2:13b      13 Mrd.     7 GB
llama2:70b      70 Mrd.    39 GB

Wenn Sie llama2:70b ausführen wollen, sollte Ihr Rechner über 64 GB RAM verfügen.

Update: Quasi zugleich mit diesem Artikel wurde llama3 fertiggestellt (Details und noch mehr Details). Aktuell gibt es zwei Größen, 8b (5 GB) und 80b (40 GB).

Bildverarbeitung

Ollama kann aber auch KI-Modelle zur Bildverarbeitung ausführen, z.B. LLaVA (siehe https://ollama.com/blog/vision-models).

ollama run llava:13b

>>> describe this image: raspap3.jpg 

Added image 'raspap3.jpg' 

The image shows a small, single-board computer like the Raspberry Pi 3, which is 
known for its versatility and uses in various projects. It appears to be connected 
to an external device via what looks like a USB cable with a small, rectangular
module on the end, possibly an adapter or expansion board. This connection
suggests that the device might be used for communication purposes, such as
connecting it to a network using an antenna. The antenna is visible in the
upper part of the image and is connected to the single-board computer by a
cable, indicating that this setup could be used for Wi-Fi or other wireless
connectivity.

The environment seems to be an indoor setting with wooden flooring, providing a
simple and clean background for the electronic components. There's also a label
on the antenna, though it's not clear enough to read in this image. The setup
is likely part of an electronics project or demonstration, given the simplicity
and focus on the connectivity equipment rather than any additional peripherals
or complex arrangements.

Eigentlich eine ganz passable Beschreibung für das folgende Bild!

Auf dem Bild ist ein Raspberry Pi 3B+ mit angeschlossenem USB-WLAN-Adapter und Netzwerkkabel zu sehen. Der WLAN-Adapter ist über einen der USB-Ports verbunden, während das gelbe Ethernet-Kabel in den LAN-Port eingesteckt ist. Der Raspberry Pi wird zusätzlich über ein schwarzes Micro-USB-Kabel mit Strom versorgt.
Raspberry Pi 3B+ mit USB-WLAN-Adapter

Praktische Erfahrungen, Qualität

Es ist erstaunlich, wie rasch die Qualität kommerzieller KI-Tools — gerade noch als IT-Wunder gefeiert — zur Selbstverständlichkeit wird. Lokale LLMs funktionieren auch gut, können aber in vielerlei Hinsicht (noch) nicht mit den kommerziellen Modellen mithalten. Dafür gibt es mehrere Gründe:

  • Bei kommerziellen Modellen fließt mehr Geld und Mühe in das Fine-Tuning.
  • Auch das Budget für das Trainingsmaterial ist größer.

  • Kommerzielle Modelle sind oft größer und laufen auf besserer Hardware. Das eigene Notebook ist mit der Ausführung (ganz) großer Sprachmodelle überfordert. (Siehe auch den folgenden Abschnitt.)

Wodurch zeichnet sich die geringere Qualität im Vergleich zu ChatGPT oder Copilot aus?

  • Die Antworten sind weniger schlüssig und sprachlich nicht so ausgefeilt.
  • Wenn Sie LLMs zum Coding verwenden, passt der produzierte Code oft weniger gut zur Fragestellung.

  • Die Antworten werden je nach Hardware viel langsamer generiert. Der Rechner läuft dabei heiß.

  • Die meisten von mir getesteten Modelle funktionieren nur dann zufriedenstellend, wenn ich in englischer Sprache mit ihnen kommuniziere.

Die optimale Hardware für Ollama

Als Minimal-Benchmark haben Bernd Öggl und ich das folgende Ollama-Kommando auf diversen Rechnern ausgeführt:

ollama run  llama2 "write a python function to extract email addresses from a string" --verbose

Die Ergebnisse dieses Kommandos sehen immer ziemlich ähnlich aus, aber die erforderliche Wartezeit variiert beträchtlich!

Update: Grafische Darstellung der Geschwindigkeit unter https://kofler.info/mini-benchmark-fuer-die-ausfuehrung-lokaler-sprachmodelle/

Lenovo T16, Linux. 12th Gen Intel i5-1250P cores=12, 32 GiB RAM, Alder Lake-P Integrated Graphics Controller

total duration:       4m7.981004535s
load duration:        979.201µs
prompt eval count:    31 token(s)
prompt eval duration: 3.061771s
prompt eval rate:     10.12 tokens/s
eval count:           478 token(s)
eval duration:        4m4.913456s
eval rate:            1.95 tokens/s

Lenovo P1 (2018), Linux. Intel i8750H 6 cores / 12 threads, 32 GiB RAM, NVIDIA Quadro P1000

Die GPU wurde nicht genutzt.

total duration:       1m48.168754835s
load duration:        204.369µs
prompt eval duration: 146.12ms
prompt eval rate:     0.00 tokens/s
eval count:           629 token(s)
eval duration:        1m48.021933s
eval rate:            5.82 tokens/s 

MacBook Air 2020, M1, 8GiB RAM

total duration:       52.303529042s
load duration:        4.741221334s
prompt eval count:    31 token(s)
prompt eval duration: 331.908ms
prompt eval rate:     93.40 tokens/s
eval count:           567 token(s)
eval duration:        47.211456s
eval rate:            12.01 tokens/s

MacBook Air M2 2023, 24 GB

total duration:       35.853232792s
load duration:        5.297790333s
prompt eval count:    32 token(s)
prompt eval duration: 211.272ms
prompt eval rate:     151.46 tokens/s
eval count:           617 token(s)
eval duration:        30.343375s
eval rate:            20.33 tokens/s

MacBook Pro M3 Pro 2023, 36 GB

total duration:       28.392226667s
load duration:        5.532561667s
prompt eval count:    31 token(s)
prompt eval duration: 119.313ms
prompt eval rate:     259.82 tokens/s
eval count:           667 token(s)
eval duration:        22.740198s
eval rate:            29.33 tokens/s 

Bzw. mit llama3:8b: 26,6 tokens/s.

Windows PC i7 64GB RAM + Nvidia 3070

total duration:       12.9912206s
load duration:        5.2628606s
prompt eval count:    31 token(s)
prompt eval duration: 83.136ms
prompt eval rate:     372.88 tokens/s
eval count:           514 token(s)
eval duration:        7.644094s
eval rate:            67.24 tokens/s 

Linux PC, AMD Ryzen 5 7600 64 GB RAM + Nvidia RTX3090 mit 24 GB RAM

(mit llama3)

total duration:       5.008054596s
load duration:        899.374µs
prompt eval duration: 17.275ms
prompt eval rate:     0.00 tokens/s
eval count:           473 token(s)
eval duration:        4.948306s
eval rate:            95.59 tokens/s

Grundsätzlich kann Ollama GPUs nutzen (siehe auch hier und hier). Im Detail hängt es wie immer vom spezifischen GPU-Modell, von den installierten Treibern usw. ab. Wenn Sie unter Linux mit einer NVIDIA-Grafikkarte arbeiten, müssen Sie CUDA-Treiber installieren und ollama-cuda ausführen. Beachten Sie auch, dass das Sprachmodell im Speicher der Grafikkarte Platz finden muss, damit die GPU genutzt werden kann.

Apple-Rechner mit M1/M2/M3-CPUs sind für Ollama aus zweierlei Gründen ideal: Es gibt keinen Ärger mit Treibern, und der gemeinsame Speicher für CPU/GPU ist vorteilhaft. Die GPUs verfügen über so viel RAM wie der Rechner. Außerdem bleibt der Rechner lautlos, wenn Sie Ollama nicht ununterbrochen mit neuen Abfragen beschäftigen. Allerdings verlangt Apple leider vollkommen absurde Preise für RAM-Erweiterungen.

Zum Schluss noch eine Bitte: Falls Sie Ollama auf Ihrem Rechner installiert haben, posten Sie bitte Ihre Ergebnisse des Kommandos ollama run llama2 "write a python function to extract email addresses from a string" --verbose im Forum!

Quellen/Links

Weitere Links zum Thema GPU/NPU-Nutzung:

Tor Browser 13.0.14 – Mullvad Browser 13.0.14

Von: jdo
18. April 2024 um 11:25

Ab sofort kannst Du Tor Browser 13.0.14 herunterladen oder bestehende Installationen aktualisieren. Aktuelle Versionen des Browsers aktualisieren sich selbst. Hier siehst Du, wie das bei mir abläuft. Tor Browser 13.0.14 bringt wichtige Sicherheits-Updates bezüglich Firefox mit sich. Ein Bugfix beschäftigt sich mit Fingerprinting, beziehungsweise ist eine Schutzmaßnahme gegen Fingerprinting. Bei der neuesten Version wurde Tor auf 0.4.8.11 aktualisiert. Für Linux, macOS und Windows basiert Tor Browser 13.0.14 auf Firefox 115.10.0esr. Für Android wurde die Software auf GeckoView 115.10.0esr aktualisiert. Für […]

Der Beitrag Tor Browser 13.0.14 – Mullvad Browser 13.0.14 ist von bitblokes.de.

Red Hat: Warum die Zukunft der Fertigung auf Open Source basiert

16. April 2024 um 12:00

Edge Computing und Künstliche Intelligenz beschleunigen die Integration von IT und OT in der Fertigung. Francis Chow von Red Hat erklärt die Vorteile offener Technologien und die Partnerschaft mit Intel, die Automatisierung und Effizienz in der Fertigung durch einheitliche Plattformen steigert.

Quelle

Martin Loschwitz: Die Rolle offener Schnittstellen in der digitalen Souveränität

17. April 2024 um 11:52

Martin Loschwitz von True West erklärt die Bedeutung offener Schnittstellen und Standards für digitale Souveränität. Er kritisiert die Reduktion souveräner Clouds auf geografische Serverstandorte und betont die Notwendigkeit echter Anbieterwahl zur Erreichung wahrer digitaler Souveränität.

Quelle

Stackable Data Platform (SDP) 24.3: Neue Version der Open-Source-Datenplattform mit Fokus auf Sicherheit und Flexibilität

08. April 2024 um 10:00

Entdecken Sie die neueste Version 24.3 der Stackable Data Platform, eine umfassende Open-Source-Datenplattform auf Kubernetes-Basis. Diese Version bietet erweiterte Sicherheitsfeatures, verbesserte Authentifizierung und neue Funktionen für effiziente Datenverarbeitung.

Quelle

Are Free Software developers at risk?

16. April 2024 um 23:00

Are Free Software developers at risk?

Free Software is everywhere, with studies estimating that it is present in about 96% of the applications that we use. But what are the responsibilities and liabilities of the Free Software developers? A potential threat to Free Software developers looms in the form of an ongoing lawsuit in the UK involving Bitcoin and its core developers.

Bitcoin (BTC) is a cryptocurrency created in 2009 that operates under the MIT Free Software licence. After its creator disappeared, a group of software developers continued to develop Bitcoin independently. Currently, Dr. Craig Wright, who claimed to be the creator of Bitcoin, is suing the Bitcoin developers in the UK courts through his company, Tulip Trading Limited (Tulip). This company claims to have lost £3 billion worth of bitcoin due to a hack that compromised the private keys, resulting in the loss of access to the funds. In this lawsuit Tulip is demanding that the Bitcoin developers provide access to the lost Bitcoin, arguing that the developers have a legal obligation to provide access or offer equitable compensation or damages.

As such, this legal case is currently drawing attention to the issue of Free Software developers' liability, in particular the extent to which they are responsible to their users.

UK High Court’s opinion: Developers have no legal duties or a duty of care in this case, but they do have certain duties in some specific situations.

The High Court considered whether software developers and controllers of digital asset networks bear legal obligations to cryptocurrency holders who rely on their software. The court ruled in favour of the developers, stating that as a "fluctuating body of individuals", the developers could not realistically maintain ongoing obligations. The court rejected the notion that developers should be compelled to provide software updates upon the request of digital asset owners, emphasising the absence of any explicit commitment or assurance by the developers. Regarding the alleged tortious duties, the Court determined that the developers did not owe Tulip a duty of care, highlighting that Tulip's loss was solely economic.

A duty of care is a legal responsibility imposed on an individual that requires them to follow a level of reasonable care when conducting any acts that could endanger others.

However, the court recognized that, in certain cases, software developers have specific duties. For instance, developers must exercise caution to avoid harming users' interests and may have an obligation to remedy bugs or faults in the system.

The court also acknowledged that the disclaimer in the MIT license, broadly disclaims liability for software issues. However, the court did not confirm whether this disclaimer absolved BTC Network developers of responsibility for its operation. This is because:

  • the MIT disclaimer has never been litigated, and the court is free to decide and set precedent.
  • such disclaimers are not easily found when using software.

UK Court of Appeal’s opinion: Arguable that developers owe some fiduciary legal duties

On appeal, the Court of Appeal (the second highest court in the UK) overturned the High Court's decision, concluding that it was at least arguable that the developers owe fiduciary legal duties to cryptocurrency owners. The court noted the exclusive control of the Bitcoin software code by a small group of developers and their decision-making role on behalf of all Bitcoin owners, resembling fiduciary responsibilities. The court also noted that only a handful of developers have exclusive access to the Bitcoin software code on GitHub. For example, if a Bitcoin owner notices a bug, he or she is unable to fix it because only the developers with access can do so, and they have to agree to do so. In the eyes of the court, this is a clear exercise of the de facto power of the developers. The court completely missed the point that no one can prevent others from applying a fix to the code - that is part of the fundamental freedom that comes with Free Software: if the developers of a particular repository refuse to apply needed fixes, the community can fork the project and bypass those developers.

Furthermore, code is speech. Freedom of expression includes expression in the language of computer code as well. Imposing disproportionate duties on Free Software developers forces them to change their code, and therefore infringes on their freedom of expression. The court also observed that the developers have a positive duty to fix bugs and code errors and a negative duty to refrain from acting in their own self-interest.

In summary, Tulip's case raises significant legal questions, and according to the latest developments, Tulip must prove ownership of the alleged stolen bitcoins in a preliminary trial.

Chilling effect on Free Software development?

Common law in the UK (and other countries) is developed through court decisions and precedents. When a court makes a decision in a case, it establishes a legal precedent that serves as a guide for future cases with similar circumstances. Lower courts generally have to follow the precedents set by the higher courts. Courts in common law countries tend to also borrow concepts and precedents from other countries if there is no local precedent available. The law and legal scholarship around Free Software developers’ duties is underdeveloped and almost non-existent. If Tulip succeeds in their case, it may set an international legal precedent, opening the floodgates to litigation. This means that any user of Free Software could potentially sue developers for alleged breaches of duty.

A fiduciary duty, as claimed by Tulip, refers to the legal duty of a person or entity to act in the best interests of another party, typically referred to as the beneficiary or principal. This duty is characterized by trust, confidence, and reliance on the fiduciary to act ethically and responsibly on behalf of the beneficiary. Fiduciary duties exist in only very specific relationships, like those of trustees, solicitors, agents, partners, and company directors. Attaching these duties to Free Software developers is unprecedented and disproportionate.

Free Software production, a catalyst for technological innovation, relies on voluntary contributions. Imposing fiduciary duties (or any disproportionate duties) on developers could deter them from participating in Free Software projects, fearing legal repercussions. This could lead to a chilling effect, where developers opt for more restrictive licensing, or refrain from sharing their code altogether, or release the software only in jurisdictions where there are no duties out of fear of litigation. The results of such an effect would be disastrous; stifling innovation and potentially halting the progress of specific Free Software endeavours.

In essence, if the court rules in favour of Tulip, it can have far-reaching consequences that can be detrimental to the Free Software developers in the following ways:

  1. Courts may impose an active duty on Free Software developers to fix what the courts deem to be problematic issues.
  2. In future courts may impose an active duty on Free Software developers to not cause any bugs that impact users. This can potentially expose the developers to litigation for just letting through a bug or failing to spot a bug.
  3. Courts may also impose obligations on Free Software developers that require them to compromise the cryptographic integrity guarantees of the software. This could involve mandates to weaken encryption algorithms or provide backdoor access, directly undermining the security measures designed to protect user privacy and data confidentiality. Such orders would not only compromise the effectiveness of encryption software but also the tools such as secure file deletion or data recovery.

Free Software development thrives on the collaborative efforts of developers worldwide, continually evolving. The developers’ autonomy inherent in Free Software must not be jeopardized by the fear of unjust litigation. FSFE remains vigilant in safeguarding against threats to developer autonomy that could stifle innovation. In the light of these concerns, we call upon the developers to persist in their invaluable work without fear.

Support FSFE

❌