LLM teacher and active labeling
from mixle.task import *
# pool = ["free prize today", ...]
# calibration = ["cheap loan offer", ...]
# requests = ["winner click now", ...]
teacher = llm_labeler(
OpenAICompatLLM(
"http://localhost:11434/v1",
"llama3.1",
),
["spam", "ham"],
)
cascade = Cascade(
CalibratedTaskModel(
active_distill(
teacher,
pool,
budget=60,
).model,
).calibrate(calibration, teacher(calibration)),
teacher,
cost=CostModel(c_frontier=0.01),
)
cascade.serve(requests)
cascade.report()
Heterogeneous latent model
from mixle.inference import *
from mixle.stats import *
# data is a list of numeric sequences:
# data[:2] == [
# [-1.2, -0.9, -1.0, 0.8, 1.1],
# [1.0, 1.3, 0.9, -0.8, -1.1],
# ]
fit = optimize(data, HiddenMarkovEstimator([
GaussianEstimator(),
GaussianEstimator(),
]))
fit.log_density(data[0])