integrations.kd.collator_online_teacher

integrations.kd.collator_online_teacher

Packed data loader for online teacher training supporting vllm and sglang.

Classes

Name Description
OnlineTeacherCollator Collator for online teacher training.

OnlineTeacherCollator

integrations.kd.collator_online_teacher.OnlineTeacherCollator(
    *args,
    kd_online_server_base_url=None,
    kd_online_topk=None,
    kd_temperature=1.0,
    kd_online_server='vllm',
    kd_online_timeout=120,
    kd_cache_dir=None,
    kd_normalize_topk=True,
    **kwargs,
)

Collator for online teacher training.

Methods

Name Description
fetch_online_logprobs_sglang Fetches logprobs from an online teacher served by sglang for a batch of input_ids.
fetch_online_logprobs_vllm Fetches logprobs from an online teacher served by vllm for a batch of input_ids.
fetch_online_logprobs_sglang
integrations.kd.collator_online_teacher.OnlineTeacherCollator.fetch_online_logprobs_sglang(
    batch_input_ids,
    labels,
)

Fetches logprobs from an online teacher served by sglang for a batch of input_ids. Assumes API returns token IDs as strings in logprob dictionary keys.

fetch_online_logprobs_vllm
integrations.kd.collator_online_teacher.OnlineTeacherCollator.fetch_online_logprobs_vllm(
    batch_input_ids,
    labels,
)

Fetches logprobs from an online teacher served by vllm for a batch of input_ids. Assumes API returns token IDs as strings in logprob dictionary keys.

Functions

Name Description
hmac_sha_from_int_list Create HMAC-SHA hash from a list of integers

hmac_sha_from_int_list

integrations.kd.collator_online_teacher.hmac_sha_from_int_list(
    int_list,
    key,
    hash_func=hashlib.sha256,
)

Create HMAC-SHA hash from a list of integers

Parameters

Name Type Description Default
int_list List of integers required
key Secret key (string or bytes) required
hash_func Hash function (default: sha256) hashlib.sha256

Returns

Name Type Description
HMAC digest as hex string