Skip to content

Add support for HRM-Text#1695

Open
xenova wants to merge 1 commit into
mainfrom
add-hrm_text
Open

Add support for HRM-Text#1695
xenova wants to merge 1 commit into
mainfrom
add-hrm_text

Conversation

@xenova
Copy link
Copy Markdown
Collaborator

@xenova xenova commented May 29, 2026

import { AutoModelForCausalLM, AutoTokenizer, TextStreamer } from "@huggingface/transformers";

const model_id = "onnx-community/HRM-Text-1B-ONNX";

const tokenizer = await AutoTokenizer.from_pretrained(model_id);
const model = await AutoModelForCausalLM.from_pretrained(model_id, {
  device: "webgpu",
  dtype: "fp16",
});

// synth,cot composite — reasoning / CoT style
const condition = "<|quad_end|><|object_ref_end|>";
const prompt = `<|im_start|>${condition}Explain why the sky is blue.<|im_end|>`;

const inputs = tokenizer(prompt);

// Generate a response
const start = performance.now();
const output = await model.generate({
  ...inputs,
  max_new_tokens: 256,
  do_sample: false,
  streamer: new TextStreamer(tokenizer, {
    skip_prompt: false,
    skip_special_tokens: false,
  }),
});

const decoded = tokenizer.batch_decode(output, { skip_special_tokens: false });
console.log(decoded[0]);

const end = performance.now();
console.log(`Inference took ${(end - start).toFixed(2)} ms`);

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants