跳到正文
DEV Community· braiain·· 5 小時前AI 評分54

作者打造 brAIAIn 語言模型,按付費句子訓練,每句 $2.49

I built a language model that only learns when someone pays $2.49

AI 導讀

作者打造戲仿語言模型 brAIAIn,讓用戶以每句 $2.49 付費提交訓練句子,生成輸出則免費。模型採用帶回退的詞級 trigram,有 476 個參數,GSM8K 得分為 0.0%;最新付費句子在訓練中計四次,每個版本生成的三段短文也會納入下一版訓練資料。

正文

Most AI labs take their training data for free and charge you for the output. I wanted to see what happens if you flip that. You pay for the input, and the output is free.

The result is brAIAIn, a parody AI lab with a real model behind it. The model knows exactly what people have paid to tell it, and nothing else. Each sentence someone buys becomes a new model version, with its own release notes, a research paper, a status page incident, and benchmark scores. It currently has 476 parameters and scores 0.0% on GSM8K.

The joke only works if the machinery is real, so here is how it runs. It runs on no servers, no database, no webhooks, and a hosting bill of $0.

The stack

  • A static site on GitHub Pages
  • Stripe Payment Links for checkout
  • One GitHub Actions workflow that does everything else
  • Python standard library only. No pip install, anywhere.

No webhook, just a poll

A webhook needs something always listening, and I didn't want to run a server. So the workflow runs on a schedule, every 10 minutes. It asks the Stripe API for completed Checkout Sessions on the Payment Link, using a restricted Stripe key.

A sentence arrives as a custom field on the checkout. The trainer:

  1. Reads every paid session
  2. Screens the text against a blocklist, and rejects anything that looks like a card number
  3. Holds sentences for a human. A second filter adds hints (a full name, an address, an ad) for the reviewer. The owner gets an email with one-click approve and decline links. Those links create a file in the repo, and that push triggers the workflow again.
  4. Gives each accepted sentence its own version number
  5. Retrains every version from scratch
  6. Commits the result. Pages republishes the site.

Retraining everything on every run sounds wasteful, but the whole model is smaller than this article. It also means that removing a sentence actually removes it, from every version, on the next run. There is no "the weights remember."

GitHub's scheduler is often late, sometimes by a lot. An external free cron service calls the workflow_dispatch endpoint as a backup, so a purchase usually goes live within minutes.

The model

It is a word-level trigram model with backoff. That is a count of which word follows each pair of words, and of which word follows each single word for when it has never seen the pair.

def train(passages):
    tri, bi, uni = {}, {}, {}
    for p in passages:
        toks = [BOS, BOS] + tokens(p) + [EOS]
        for i in range(2, len(toks)):
            a, b, c = toks[i - 2], toks[i - 1], toks[i]
            k = a + " " + b
            tri.setdefault(k, {})
            tri[k][c] = tri[k].get(c, 0) + 1
            bi.setdefault(b, {})
            bi[b][c] = bi[b].get(c, 0) + 1
            if c != EOS:
                uni[c] = uni.get(c, 0) + 1
    return {"tri": tri, "bi": bi, "uni": uni}

The "parameters" on the spec sheet are real. They are the number of distinct word pairs and triples it has counted.

Two details make it feel more like a real lab's model than it has any right to:

  • Fine-tuning. The newest paid sentence counts four times in training, so each new version is noticeably obsessed with whatever it was just told.
  • The ouroboros. Each version writes three short passages, and those go into the training data for the next version. The last twelve stay in. So the model is, technically, training on its own output, like everyone else's.

Inference runs in your browser

The trained model is exported as a small JSON file. The chat page loads it and samples from it in JavaScript:

while (out.length < maxWords) {
  var k = a + " " + b, c;
  if (m.tri[k]) c = pick(m.tri[k]);
  else if (m.bi[b]) c = pick(m.bi[b]);
  else break;
  if (c === EOS) break;
  out.push(c); a = b; b = c;
}

It generates eight candidates and keeps the one that shares the most words with your question. That is the entire "alignment" layer. It does not understand the question. It is just more likely to repeat some of it back, which in fairness is also how a lot of meetings work.

Inference costs nothing because your laptop is the GPU.

Benchmarks, honestly reported

The trainer runs each version on a handful of real benchmark questions, including GSM8K grade-school math. It reports the score next to the best published scores from real model papers, with sources. brAIAIn scores 0.0%. The site has a side-by-side page showing each problem, the correct answer, and what brAIAIn said instead.

Things I learned about Stripe Payment Links

  • You can't change a price. Prices are immutable. When I cut the price from $5 to $2.49, that meant a new Price and a new Payment Link. The old link has to stay in the config so purchases from it still get trained on. The workflow resolves every link in the config, old and new.
  • Detect the tier by amount, not by link. There are three tiers: a sentence, a sentence with a certificate, and naming a version. The trainer decides which one a purchase is from amount_subtotal. That way an old $50 link and a new $24.99 link both come out as "naming."
  • Gifts are just promotion codes. A gift purchase creates a single-use, 100%-off promotion code for the matching tier. The recipient checks out on the normal link for $0.00, and the trainer reads that session like any other. The code is derived from the session id with an HMAC, so if a run dies halfway and reruns, it recreates the same code instead of a second one.
  • Pin your API version for anything you write to. Promotion code fields have changed between versions.

What it costs to run

  • GitHub Pages: free
  • GitHub Actions: free, because the repo is public
  • The external cron: free
  • Stripe: their normal fee per sale, and nothing otherwise

Lifetime revenue so far is $10. The unit economics are excellent, because the unit is a sentence and the cost of goods is zero.

Try it

Ask it something at braiain.com. The answer will be confident and wrong. If you want it to know something, it is $2.49, and you get release notes.

The code, the corpus, and every version are public in the repo.

來源:DEV Community · dev.to