XU XUv0.16.0

#github.com/xulang-org/packages/synth

import: synth #github.com/xulang-org/packages/synth

counts: 12 functions, 0 methods, 4 types, 0 constants, 0 method sets

External package `synth #github.com/xulang-org/packages/synth`, provided by github.com/xulang-org/packages.

github.com/xulang-org/packages · 1.17.2 · Install and use

struct SftExample

XuAPI
pub struct SftExample {
    pub instruction string
    pub input string
    pub output string
    pub system string
}

Purpose

Structure encapsulating instruction, input, output, system.

Public fields

instruction string
field (string)
input string
field (string)
output string
field (string)
system string
field (string)

struct DpoPair

XuAPI
pub struct DpoPair {
    pub prompt string
    pub chosen string
    pub rejected string
}

Purpose

Structure encapsulating prompt, chosen, rejected.

Public fields

prompt string
field (string)
chosen string
field (string)
rejected string
field (string)

struct RlvrTask

XuAPI
pub struct RlvrTask {
    pub id string
    pub prompt string
    pub expected string
    pub verifier string
}

Purpose

Structure encapsulating id, prompt, expected, verifier.

Public fields

id string
field (string)
prompt string
field (string)
expected string
field (string)
verifier string
field (string)

struct FilterStats

XuAPI
pub struct FilterStats {
    pub total_input int
    pub kept int
    pub dropped_empty int
    pub dropped_duplicate int
}

Purpose

Structure encapsulating total_input, kept, dropped_empty, dropped_duplicate.

Public fields

total_input int
field (int)
kept int
field (int)
dropped_empty int
field (int)
dropped_duplicate int
field (int)

jaccard_ngram_similarity

XuAPI
pub fn jaccard_ngram_similarity(a &string, b &string, n int) f64

Purpose

Jaccard ngram similarity.

Parameters

a &string
value (read-only borrow; caller keeps the original; type &string)
b &string
b (read-only borrow; caller keeps the original; type &string)
n int
count, length, or limit (int)

Returns

f64 — a value of this type

format_sft_jsonl

XuAPI
pub fn format_sft_jsonl(examples &[]SftExample) string

Purpose

Format as sft jsonl.

Parameters

examples &[]SftExample
examples (read-only borrow; caller keeps the original; type &[]SftExample)

Returns

string — result string

parse_sft_jsonl

XuAPI
pub fn parse_sft_jsonl(jsonl &string) []SftExample

Purpose

Parse as sft jsonl. Throws on failure; handle the error or propagate it to the caller.

Parameters

jsonl &string
jsonl (read-only borrow; caller keeps the original; type &string)

Returns

[]SftExample — slice result

format_dpo_jsonl

XuAPI
pub fn format_dpo_jsonl(pairs &[]DpoPair) string

Purpose

Format as dpo jsonl.

Parameters

pairs &[]DpoPair
pairs (read-only borrow; caller keeps the original; type &[]DpoPair)

Returns

string — result string

format_rlvr_jsonl

XuAPI
pub fn format_rlvr_jsonl(tasks &[]RlvrTask) string

Purpose

Format as rlvr jsonl.

Parameters

tasks &[]RlvrTask
tasks (read-only borrow; caller keeps the original; type &[]RlvrTask)

Returns

string — result string

save_jsonl

XuAPI
pub fn save_jsonl(path string, content &string) int

Purpose

Save jsonl. Throws on failure; handle the error or propagate it to the caller.

Parameters

path string
filesystem path (string)
content &string
content (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

dedup_exact

XuAPI
pub fn dedup_exact(items &[]string) []string

Purpose

Dedup exact.

Parameters

items &[]string
items (read-only borrow; caller keeps the original; type &[]string)

Returns

[]string — slice result

dedup_near_jaccard

XuAPI
pub fn dedup_near_jaccard(items &[]string, ngram int, threshold f64) []string

Purpose

Dedup near jaccard.

Parameters

items &[]string
items (read-only borrow; caller keeps the original; type &[]string)
ngram int
ngram (int)
threshold f64
threshold (f64)

Returns

[]string — slice result

filter_sft_quality

XuAPI
pub fn filter_sft_quality(examples &[]SftExample, min_output_chars int, dedup_jaccard f64, stats_out $&FilterStats) []SftExample

Purpose

Filter sft quality.

Parameters

examples &[]SftExample
examples (read-only borrow; caller keeps the original; type &[]SftExample)
min_output_chars int
min_output_chars (int)
dedup_jaccard f64
dedup_jaccard (f64)
stats_out $&FilterStats
stats_out (exclusive borrow; may modify the original; type $&FilterStats)

Returns

[]SftExample — slice result

generate_sft_openai

XuAPI
pub fn generate_sft_openai(client &openai.Client, model string, topic string, count int, system_hint string) []SftExample

Purpose

Generate sft openai. Throws on failure; handle the error or propagate it to the caller.

Parameters

client &openai.Client
client (read-only borrow; caller keeps the original; type &openai.Client)
model string
model (string)
topic string
topic (string)
count int
count (int)
system_hint string
system_hint (string)

Returns

[]SftExample — slice result

generate_dpo_pair_openai

XuAPI
pub fn generate_dpo_pair_openai(client &openai.Client, strong_model string, weak_model string, prompt string) DpoPair

Purpose

Generate dpo pair openai. Throws on failure; handle the error or propagate it to the caller.

Parameters

client &openai.Client
client (read-only borrow; caller keeps the original; type &openai.Client)
strong_model string
strong_model (string)
weak_model string
weak_model (string)
prompt string
prompt (string)

Returns

DpoPair — a value of this type

distill_dataset_openai

XuAPI
pub fn distill_dataset_openai(teacher &openai.Client, teacher_model string, prompts &[]string, system_prompt string) []SftExample

Purpose

Distill dataset openai. Throws on failure; handle the error or propagate it to the caller.

Parameters

teacher &openai.Client
teacher (read-only borrow; caller keeps the original; type &openai.Client)
teacher_model string
teacher_model (string)
prompts &[]string
prompts (read-only borrow; caller keeps the original; type &[]string)
system_prompt string
system_prompt (string)

Returns

[]SftExample — slice result