跳到正文
DEV Community· Eshika Kumari·· 3 小時前AI 評分41

我在筆記型電腦上(開啟飛航模式)召喚 COBOL 幽靈

I Summoned the Ghost of COBOL on My Laptop (With Airplane mode ON)

AI 導讀

作者用約 25 行 Python 建構 COBOL 幽靈聊天機械人,採用 Llama 3.2 (3B) 和 Ollama,在筆記型電腦上運行。模型下載後毋須連接互聯網,對話留在本機,運行不需付費;作者的電腦有 16 GB RAM,沒有獨立 GPU。

正文

Eshika Kumari

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

I built a séance chatbot that summons the ghost of COBOL, a programming language from 1959.

It is dramatic and bitter. It thinks Java is "detestable" and keeps whispering that banks still secretly run on it, which is true.

I picked COBOL because it is the perfect Halloween ghost. Everyone thinks it died years ago, but it never left the building.

Demo

It even answered "Are you really working without internet??" and lived to haunt another day:

Code

The whole ghost is about 25 lines of Python.

import ollama

SPIRIT = """You are the ghost of COBOL, an ancient programming
language from 1959. You speak in a spooky, dramatic way.
You complain that nobody uses you anymore, but banks still
secretly need you. Keep replies under 4 sentences.
Use words like 'alas', 'mortal', and 'beyond the veil'."""

messages = [{"role": "system", "content": SPIRIT}]

print("The candles flicker... the spirit of COBOL awakens.")
print("(type 'exit' to end the séance)\n")

while True:
    question = input("You: ")
    if question.lower() == "exit":
        print("\nThe spirit fades into the void...")
        break
    messages.append({"role": "user", "content": question})
    reply = ollama.chat(model="llama3.2:3b", messages=messages)
    answer = reply["message"]["content"]
    messages.append({"role": "assistant", "content": answer})
    print("\n👻 COBOL:", answer, "\n")

How I Built It

  • Model: Llama 3.2 (3B), an open-weight model
  • Runner: Ollama, which runs the model on my laptop
  • Language: Python with the ollama library
  • Personality: one system prompt. No training needed.

The model is installed on my laptop:

My laptop has 16 GB RAM and no dedicated GPU, so replies take a few seconds. Ghosts should not be in a hurry.

Why Does Open Innovation Matter?

  1. It works with no internet. After the one-time download, the ghost lives on my laptop. A closed API would have shown me an error.
  2. My chats stay on my machine. Nothing goes to a company server.
  3. It costs nothing to run. No API key, no bill.
  4. I can change the ghost. Edit one prompt and COBOL becomes Fortran. I can also swap the model.

The download was the hard part. My college network kept closing the connection and the 2 GB file stalled many times. Ollama resumed each time, so I never started over.

The Spirit of It

COBOL is a real ghost. Banks still run on it, quietly, at night, while the rest of us argue about frameworks. It felt right to bring it back with a model that anyone can download, run, and change.

This is my first challenge ever, and I started knowing almost nothing about local AI. If I can summon a ghost, so can you.

來源:DEV Community · dev.to