github huggingface/transformers.js 3.6.2

latest releases: 3.8.1, 3.8.0, 3.7.6...
7 months ago

What's new?

  • Add support for SmolLM3 in #1359

    SmolLM3 is a 3B parameter language model designed to push the boundaries of small models. It supports 6 languages, advanced reasoning and long context. SmolLM3 is a fully open model that offers strong performance at the 3B–4B scale.

    Example:

    import { pipeline, TextStreamer } from "@huggingface/transformers";
    
    // Create a text generation pipeline
    const generator = await pipeline(
      "text-generation",
      "HuggingFaceTB/SmolLM3-3B-ONNX",
      { dtype: "q4f16" },
    );
    
    // Define the list of messages
    const messages = [
      { role: "system", content: "You are SmolLM, a language model created by Hugging Face. If asked by the user, here is some information about you: SmolLM has 3 billion parameters and can converse in 6 languages: English, Spanish, German, French, Italian, and Portuguese. SmolLM is a fully open model and was trained on a diverse mix of public datasets./think" },
      { role: "user", content: "Solve the equation x^2 - 3x + 2 = 0" },
    ];
    
    // Generate a response
    const output = await generator(messages, {
        max_new_tokens: 1024,
        do_sample: false,
        streamer: new TextStreamer(generator.tokenizer, { skip_prompt: true, skip_special_tokens: true }),
    });
    console.log(output[0].generated_text.at(-1).content);
  • Add support for ERNIE-4.5 in #1354
    Example:

    import { pipeline, TextStreamer } from "@huggingface/transformers";
    
    // Create a text generation pipeline
    const generator = await pipeline(
      "text-generation",
      "onnx-community/ERNIE-4.5-0.3B-ONNX",
      { dtype: "fp32" }, // Options: "fp32", "fp16", "q8", "q4", "q4f16"
    );
    
    // Define the list of messages
    const messages = [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: "What is the capital of France?" },
    ];
    
    // Generate a response
    const output = await generator(messages, {
        max_new_tokens: 512,
        do_sample: false,
        streamer: new TextStreamer(generator.tokenizer, { skip_prompt: true, skip_special_tokens: true }),
    });
    console.log(output[0].generated_text.at(-1).content);
    // The capital of France is Paris.

Full Changelog: 3.6.1...3.6.2

Don't miss a new transformers.js release

NewReleases is sending notifications on new releases.