laya / test.py
PIXMELT's picture
Upload folder using huggingface_hub
97155c0 verified
Raw History Blame Contribute Delete
1.89 kB
import os
os.environ["HF_HUB_OFFLINE"] = "1"
import warnings
warnings.filterwarnings("ignore", message="laya: this checkpoint ships temperatures")
import laya
import time
# Load current model
agent = laya.load(".")
# Content
article = "By 2031, artificial intelligences no longer merely answer: they anticipate, negotiate and sometimes push back. In newsrooms, hospitals and courtrooms, autonomous agents propose decisions, draft summaries and flag their own uncertainty. Some observers speak of a 'second cognitive wave': systems capable of doubting, asking for clarification and refusing a poorly specified task. Others worry about a silent dependency, where humans approve without truly understanding. One thing is certain: the question is no longer whether AIs think, but how we will coexist with them."
# Questions
payload = {
"tone": {
"type": "choice",
"instructions": "What is the dominant tone of `body`?",
"criteria": {
"neutral": "factual account, no judgment",
"alarmist": "emphasis on risks and dangers",
"enthusiastic": "emphasis on promises and benefits"
}
},
"domain_coverage": {
"type": "score",
"instructions": "How many distinct application domains are covered in `body`?",
"criteria": ["none", "one", "two", "three or more"]
},
"mentions_doubt": {
"type": "noul",
"instructions": "Does the text mention AIs' ability to doubt or flag their own uncertainty?"
}
}
# Predict/Evaluate
timer = time.perf_counter()
result = agent.predict({ "body": article }, payload)
# Show result
for name in payload:
print(payload[name]['instructions'])
print('->', result["answers"][name][payload[name]['type']], '\n')
# Debug
print(f"Duration: {((time.perf_counter() - timer) * 1000):.2f} ms")