Hacker News· Bluestein·· 8 天前AI 评分22
Sage:让软件在运行时"思考"的新编程方式
Intelligence. At runtime. What if software could think while it runs?
AI 导读
Sage 提出一种在程序运行时调用模型做语义判断的编程方式:同一份文档,正则匹配 SSN、信用卡号等已知模式会漏掉姓名和地址,而通过 `decide(doc, yesno("Contains personal information?
正文 · 原文
A new way to write software
Document: Maya Chen lives at 14 Cedar Lane.. The shown regexes find neither a name nor an address.
Match known patterns
ssn = r"\b\d{3}-\d{2}-\d{4}\b"
card = r"\b(?:\d[ -]?){16}\b"
if (re.search(ssn, doc)
or re.search(card, doc)
or "passport" in doc.lower()):
block(doc)
else:
publish(doc)The running program asks Sage
private = decide(
doc, yesno("Contains personal information?")
)
match private["answer"]:
case "yes": block(doc)
case "no": publish(doc)
case None: review(doc)Sage returns yes, so the application blocks the document. No publishes it; null sends it for review.
01 / Inside the machine
A new way
to write software.
Same input
Maya Chen lives at 14 Cedar Lane.
Before
Match known patterns.
ssn = r"\b\d{3}-\d{2}-\d{4}\b"
card = r"\b(?:\d[ -]?){16}\b"
if (re.search(ssn, doc)
or re.search(card, doc)
or "passport" in doc.lower()):
block(doc)
else:
publish(doc)These checks miss the name and address.
With Sage
Ask about meaning.
private = decide(
doc, yesno("Contains personal information?")
)
match private["answer"]:
case "yes": block(doc)
case "no": publish(doc)
case None: review(doc)The same document. A semantic decision.
The application asks
Does this document contain personal information?
The question and the document go to Sage while the program runs.
Sage responds
{
"answer": "yes",
"probability": 0.99
}The application blocks publication. An uncertain answer goes to a person.
来源:Hacker News · levanto.ai