Archiv der Kategorie: AI

n8n and Ollama translate Swedish

Due to some peculiar reason, I had to analyze the source code of an Infocom Z-machine story file. All the strings within the file were in Swedish, which I (sadly?) don’t understand.

Therefore, translating the strings into English seemed like the most logical approach. However, initial attempts using Google Translate or DeepL were unsuccessful. While the strings were typically translated reasonably well, the subsequent program code became severely corrupted.

The following approach provided the solution:

1. Using a PHP script, I read the source code file, extracted the strings using regular expressions, and saved them in a JSON file.

2. For translation, I downloaded the „translategemma“ model, which now runs on my on-premise AI machine (AMD Ryzen™ AI Max+ 395), along with Ollama and LM Studio.

3. I created an n8n workflow that can be triggered via a webhook. The workflow calls Ollama, which then uses translategemma for translation.

n8n workflow

n8n workflow calling Ollama via an AI Agent, triggered by a Webhook.

n8n AI Agent configuration

Configuration of the n8n AI Agent, e.g. the system prompt.

4. Another script reads the JSON file from step 1, sends each string to the n8n workflow for translation, and returns the English translation.

As a result, the Swedish strings in the source code are now automatically replaced with their English counterparts … everything is readable now … and … that’s all 😉

example translation

Example of a translation in the temporary JSON file.

Conclusio: This is a fast & neat solution, built using open-source and other license-free components. This solution can, of course, also be used for other languages. Furthermore, it could also be used to automatically translate comments in source code.

How to talk to your Blockchain?

Interessante Frage …
Gemeinsam mit M. von der https://infinite-trust-digital.com sind wir dieser nachgegangen und es wurde folgender Prototyp aufgebaut:

Prototyp: Komponenten und Datenfluss

  • Datenquelle ist die „Air-Quality-Chain“, die seit 2018 die Protokollierung, unveränderliche Speicherung und dezentrale Verteilung von Umweltmessdaten durchführt. Es werden Daten vom Luftmessnetz der Stadt Wien, dem NÖ Luftgüteüberwachungsnetz und dem Umweltbundesamt periodisch aus OpenData geladen und in einer Multichain-basierten Blockchain gespeichert, Details siehe https://datnos.com/aqc/
  • Diese Daten werden (aus Perfocmancegründen für Abfragen) in eine Datenbank gespiegelt.
  • M. hat nun einen Chat-Bot zur Abfrage und Interpretation dieser Daten gebaut, der LangChain als Framework für die Anwendungen des LLMs verwendet.
  • Dieser Chat-Bot kann über ein Web-GUI mit Fragen gefüttert werden, interpretiert diese, wendet die Interpretation auf die bestehenden Daten an und … liefert eine Antwort.

Erste Erkenntnisse mit diesem Protptypen sind unter unter diesem Blogbeitrag zu finden.

Zusammenfassung

  • Chat-Bots bzw. LLMs können auch auf „eigene“ (zB. auch unternehmensinterne …) Daten zugreifen und mehr oder weniger sinnvolle Antworten auf mehr oder weniger sinnvolle Fragen geben.
  • Bestehende Blockchain-APIs sind zu langsam dafür, Datenbanken als Schnittstelle optimal (wie auch bei Blockchain-Explorern).
  • Das Experiment hat gezeigt, dass AI auch mit Blockchain-Daten arbeiten kann, was weitere zukünftige Einsatzbereiche eröffnet.

Es bleibt also spannend … stay tuned!